[asterisk-scf-commits] asterisk-scf/release/test_channel.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Sun Oct 2 18:11:45 CDT 2011


branch "master" has been updated
       via  ecdc524619fb486d95d9aded350f935344f434e0 (commit)
      from  cd0b4f5a9dc0b7e753f28160eaacb6457fc7477b (commit)

Summary of changes:
 src/TestEndpoint.cpp |  126 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 125 insertions(+), 1 deletions(-)


- Log -----------------------------------------------------------------
commit ecdc524619fb486d95d9aded350f935344f434e0
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Sun Oct 2 18:11:11 2011 -0500

    Added Telephony Event sink and source support.

diff --git a/src/TestEndpoint.cpp b/src/TestEndpoint.cpp
index 18fd07c..0b0315c 100644
--- a/src/TestEndpoint.cpp
+++ b/src/TestEndpoint.cpp
@@ -20,6 +20,7 @@
 #include <Ice/Ice.h>
 #include <IceUtil/UUID.h>
 
+#include <AsteriskSCF/Helpers/ProxyHelper.h>
 #include <AsteriskSCF/SessionCommunications/SessionCommunicationsIf.h>
 
 #include <boost/thread/locks.hpp>
@@ -131,15 +132,95 @@ protected:
 
 typedef IceUtil::Handle<SessionListenerMgr> SessionListenerMgrPtr;
 
+class TelephonyEventSinkI : public AsteriskSCF::SessionCommunications::V1::TelephonyEventSink
+{
+public:
+    TelephonyEventSinkI() {}
+
+    void write_async(
+            const AsteriskSCF::SessionCommunications::V1::AMD_TelephonyEventSink_writePtr& cb,
+            const AsteriskSCF::SessionCommunications::V1::TelephonyEventPtr& telephonyEvent,
+            const Ice::Current&)
+    {
+        mEvents.push_back(telephonyEvent);
+        cb->ice_response();
+    }
+
+    void setSource_async(
+            const AsteriskSCF::SessionCommunications::V1::AMD_TelephonyEventSink_setSourcePtr& cb,
+            const AsteriskSCF::SessionCommunications::V1::TelephonyEventSourcePrx& source,
+            const Ice::Current&)
+    {
+        mSource = source;
+        cb->ice_response();
+    }
+
+
+    void getSource_async(
+            const AsteriskSCF::SessionCommunications::V1::AMD_TelephonyEventSink_getSourcePtr& cb,
+            const Ice::Current&)
+    {
+        cb->ice_response(mSource);
+    }
+
+private:
+
+    AsteriskSCF::SessionCommunications::V1::TelephonyEventSourcePrx mSource;
+    std::vector<AsteriskSCF::SessionCommunications::V1::TelephonyEventPtr> mEvents;
+};
+typedef IceUtil::Handle<TelephonyEventSinkI> TelephonyEventSinkIPtr;
+
+class TelephonyEventSourceI : public AsteriskSCF::SessionCommunications::V1::TelephonyEventSource
+{
+public:
+
+    TelephonyEventSourceI() {}
+
+    // TelephonyEventSource API implementation...
+
+    void addSinks_async(
+            const AsteriskSCF::SessionCommunications::V1::AMD_TelephonyEventSource_addSinksPtr& cb,
+            const AsteriskSCF::SessionCommunications::V1::TelephonyEventSinkSeq& sinks,
+            const Ice::Current&)
+    {
+        mSinks.insert(mSinks.end(), sinks.begin(), sinks.end());
+        cb->ice_response();
+    }
+
+    void removeSinks_async(
+            const AsteriskSCF::SessionCommunications::V1::AMD_TelephonyEventSource_removeSinksPtr& cb,
+            const AsteriskSCF::SessionCommunications::V1::TelephonyEventSinkSeq& sinks,
+            const Ice::Current&)
+    {
+        for (TelephonyEventSinkSeq::const_iterator i = sinks.begin(); i != sinks.end(); ++i)
+        {
+            mSinks.erase(std::remove_if(mSinks.begin(), mSinks.end(), AsteriskSCF::IdentityComparePredicate<TelephonyEventSinkPrx>(*i)), mSinks.end());
+        }
+        cb->ice_response();
+    }
+
+    void getSinks_async(
+            const AsteriskSCF::SessionCommunications::V1::AMD_TelephonyEventSource_getSinksPtr& cb,
+            const Ice::Current&)
+    {
+        cb->ice_response(mSinks);
+    }
+
+private:
+    AsteriskSCF::SessionCommunications::V1::TelephonyEventSinkSeq mSinks;
+};
+typedef IceUtil::Handle<TelephonyEventSourceI> TelephonyEventSourceIPtr;
+
 //
 // Needs some intelligence:
 //   - scheduled ringing
 //   - etc.
-class SessionI : public AsteriskSCF::SessionCommunications::V1::Session
+class SessionI : public AsteriskSCF::SessionCommunications::V1::TelephonySession
 {
 public:
     SessionI(const InternalManagerPtr& m, const AsteriskSCF::SessionCommunications::V1::SessionEndpointPrx& prx,  const std::string& id,
         const Ice::ObjectAdapterPtr& adapter) :
+        mAdapter(adapter),
         mEndpointManager(m),
         mEndpointPrx(prx),
         mId(id),
@@ -175,6 +256,15 @@ public:
         RedirectionPtr redirect = new Redirection(dialedId, connectedId);
         redirects.push_back(redirect);
         mRedirections = new Redirections(redirects);
+
+        mTelephonyEventSinkPtr = new TelephonyEventSinkI();
+        TelephonyEventSinkPrx sinkPrx = TelephonyEventSinkPrx::uncheckedCast(mAdapter->addWithUUID(mTelephonyEventSinkPtr));
+        mTelephonyEventSinks.push_back(sinkPrx);
+
+        mTelephonyEventSourcePtr = new TelephonyEventSourceI();
+        TelephonyEventSourcePrx sourcePrx = TelephonyEventSourcePrx::uncheckedCast(mAdapter->addWithUUID(mTelephonyEventSourcePtr));
+        mTelephonyEventSources.push_back(sourcePrx);
+
     }
 
     void addListener_async(
@@ -419,8 +509,36 @@ public:
         cb->ice_response(mRedirections);
     }
 
+
+    //// TelephonySession overrides
+ 
+    void getSources_async(
+            const AsteriskSCF::SessionCommunications::V1::AMD_TelephonySession_getSourcesPtr& cb,
+            const Ice::Current&)
+    {
+        cb->ice_response(mTelephonyEventSources);
+    }
+
+    void getSinks_async(
+            const AsteriskSCF::SessionCommunications::V1::AMD_TelephonySession_getSinksPtr& cb,
+            const Ice::Current&)
+    {
+        cb->ice_response(mTelephonyEventSinks);
+    }
+
+    TelephonyEventSourceIPtr getSource()
+    {
+        return mTelephonyEventSourcePtr;
+    }
+
+    TelephonyEventSinkIPtr getSink()
+    {
+        return mTelephonyEventSinkPtr;
+    }
+
 private:
     boost::shared_mutex mMutex;
+    Ice::ObjectAdapterPtr mAdapter;
     InternalManagerPtr mEndpointManager;
     AsteriskSCF::SessionCommunications::V1::SessionEndpointPrx mEndpointPrx;
     AsteriskSCF::SessionCommunications::V1::SessionInfoPtr mInfo;
@@ -429,11 +547,17 @@ private:
     AsteriskSCF::Media::V1::SessionPrx mMediaSession;
     SessionListenerMgrPtr mListeners;
     AsteriskSCF::SessionCommunications::V1::BridgePrx mCurrentBridge;
+
     SessionOwnerIdPtr mSessionOwnerId;
     CallerPtr mCaller;
     DialedPtr mDialed;
     ConnectedLinePtr mConnectedLine;
     RedirectionsPtr mRedirections;
+
+    TelephonyEventSourceIPtr mTelephonyEventSourcePtr;
+    TelephonyEventSinkIPtr mTelephonyEventSinkPtr;
+    TelephonyEventSourceSeq mTelephonyEventSources;
+    TelephonyEventSinkSeq mTelephonyEventSinks;
 };
 
 typedef IceUtil::Handle<SessionI> SessionIPtr;

-----------------------------------------------------------------------


-- 
asterisk-scf/release/test_channel.git



More information about the asterisk-scf-commits mailing list