[asterisk-scf-commits] asterisk-scf/integration/bridging.git branch "party-id" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Tue Nov 22 15:12:09 CST 2011


branch "party-id" has been updated
       via  3e4b56039f0e66ed3ea869db4ba76ca45398a053 (commit)
      from  c773b8ab340721d73d9d740ca55d7b61bf288858 (commit)

Summary of changes:
 src/BridgeImpl.cpp    |   87 +++++++++++++++++++++++++++++++++++++++---------
 test/TestBridging.cpp |   44 +++++++++++++++++++++----
 2 files changed, 107 insertions(+), 24 deletions(-)


- Log -----------------------------------------------------------------
commit 3e4b56039f0e66ed3ea869db4ba76ca45398a053
Author: Mark Michelson <mmichelson at digium.com>
Date:   Tue Nov 1 16:57:46 2011 -0500

    Add ConnectedLine sequences to the addSessions() and replaceSession() calls.

diff --git a/src/BridgeImpl.cpp b/src/BridgeImpl.cpp
index a4c62be..f520f95 100755
--- a/src/BridgeImpl.cpp
+++ b/src/BridgeImpl.cpp
@@ -79,7 +79,10 @@ public:
     //
     // AsteriskSCF::SessionCommunications::Bridging::Bridge Interface
     //
-    void addSessions_async(const AMD_Bridge_addSessionsPtr& callback, const SessionSeq& sessions, const Ice::Current&);
+    void addSessions_async(const AMD_Bridge_addSessionsPtr& callback,
+            const SessionSeq& sessions,
+            const ConnectedLineSeq& connectedLines,
+            const Ice::Current&);
     void removeSessions_async(const AMD_Bridge_removeSessionsPtr& callback, const SessionSeq& sessions,
             const Ice::Current&);
 
@@ -90,8 +93,11 @@ public:
     void addListener(const BridgeListenerPrx& listener, const Ice::Current& current);
     void removeListener(const BridgeListenerPrx& listener, const Ice::Current& current);
 
-    void replaceSession_async(const AMD_Bridge_replaceSessionPtr& callbac, const SessionPrx& sessionToReplace,
-            const SessionSeq& newSessions, const Ice::Current& current);
+    void replaceSession_async(const AMD_Bridge_replaceSessionPtr& callbac,
+            const SessionPrx& sessionToReplace,
+            const SessionSeq& newSessions,
+            const ConnectedLineSeq& newConnectedLines,
+            const Ice::Current& current);
 
     void setCookies(const BridgeCookies& cookies, const Ice::Current&);
     void removeCookies(const BridgeCookies& cookies, const Ice::Current&);
@@ -385,7 +391,7 @@ class ForwardConnectedLineTask : public QueuedTask
 {
 public:
     ForwardConnectedLineTask(const BridgeImplPtr& bridge, 
-            const SessionWrapperPtr& sourceSession,
+            const SessionPrx& sourceSession,
             const Logger& logger) :
         QueuedTask("ForwardConnectedLineTask"),
         mBridge(bridge),
@@ -402,7 +408,8 @@ protected:
             mLogger(Debug) << FUNLOG;
 
             ConnectedLinePtr currentConnectedLine;
-            bool isSet = mSourceSession->getConnectedLine(currentConnectedLine);
+            SessionWrapperPtr sourceWrapper = mBridge->getSessions()->getSession(mSourceSession);
+            bool isSet = sourceWrapper->getConnectedLine(currentConnectedLine);
 
             if (!isSet)
             {
@@ -415,7 +422,7 @@ protected:
             for(SessionSeq::iterator i = sessions.begin();
                 i != sessions.end(); ++i)
             {
-                if ((*i)->ice_getIdentity() == mSourceSession->getSession()->ice_getIdentity())
+                if ((*i)->ice_getIdentity() == mSourceSession->ice_getIdentity())
                 {
                     continue;
                 }
@@ -449,7 +456,7 @@ protected:
             try
             {
                 // Apply a hook
-                AsteriskSCF::System::Hook::V1::HookResult hookResult = (*i)->modifyForwardingConnectedLine(mSourceSession->getSession(),
+                AsteriskSCF::System::Hook::V1::HookResult hookResult = (*i)->modifyForwardingConnectedLine(mSourceSession,
                     destinationSession->getSession(),
                     currentConnectedLine, destSpecificConnectedLine);
 
@@ -470,7 +477,7 @@ protected:
 
 private:
     BridgeImplPtr mBridge;
-    SessionWrapperPtr mSourceSession;
+    SessionPrx mSourceSession;
     Logger mLogger;
 };
 
@@ -569,7 +576,7 @@ class UpdateConnectedLineTask : public QueuedTask
 {
 public:
     UpdateConnectedLineTask(const BridgeImplPtr& bridge, 
-            const SessionWrapperPtr& sourceSession,
+            const SessionPrx& sourceSession,
             const ConnectedLinePtr& connectedLine,
             const Logger& logger) :
         QueuedTask("UpdateConnectedLineTask"),
@@ -587,6 +594,7 @@ protected:
 
         ConnectedLinePtr currentConnectedLine = mConnectedLine;
         ConnectedLinePtr updatedConnectedLine = mConnectedLine;
+        SessionWrapperPtr wrapper = mBridge->getSessions()->getSession(mSourceSession);
 
         PartyIdHooksPtr partyIdHooks = mBridge->getPartyIdHooks();
 
@@ -597,7 +605,7 @@ protected:
             try
             {
                 // Apply this hook. 
-                AsteriskSCF::System::Hook::V1::HookResult hookResult = (*i)->modifyReceivedConnectedLine(mSourceSession->getSession(),
+                AsteriskSCF::System::Hook::V1::HookResult hookResult = (*i)->modifyReceivedConnectedLine(mSourceSession,
                     currentConnectedLine, updatedConnectedLine);
 
                 if (hookResult.status == AsteriskSCF::System::Hook::V1::Succeeded)
@@ -612,14 +620,14 @@ protected:
         }
 
         // Cache this value.
-        mSourceSession->setConnectedLine(currentConnectedLine);
+        wrapper->setConnectedLine(currentConnectedLine);
 
         return true;
     }
            
 private:
     BridgeImplPtr mBridge;
-    SessionWrapperPtr mSourceSession;
+    SessionPrx mSourceSession;
     ConnectedLinePtr mConnectedLine;
     Logger mLogger;
 };
@@ -1284,12 +1292,12 @@ void BridgeImpl::updateConnectedLine(const SessionWrapperPtr& sourceSession, con
 
         // Updates the cached ConnectedLine party id information for the given session.
         //  - Applies receive hooks on the received ConnectedLine info before caching.
-        tasks.push_back(new UpdateConnectedLineTask(this, sourceSession, connectedLine, mLogger));
+        tasks.push_back(new UpdateConnectedLineTask(this, sourceSession->getSession(), connectedLine, mLogger));
 
 
         // Forwards the ConnectedLine information to the other sessions in the bridge.
         //  - Applies forwarding hooks to the cached ConnectedLine info before forwarding.
-        tasks.push_back(new ForwardConnectedLineTask(this, sourceSession, mLogger));
+        tasks.push_back(new ForwardConnectedLineTask(this, sourceSession->getSession(), mLogger));
 
         ExecutorPtr runner(new Executor(tasks, mLogger));
         runner->start();
@@ -1321,7 +1329,9 @@ void BridgeImpl::updateRedirections(const SessionWrapperPtr& sourceSession, cons
     }
 }
 
-void BridgeImpl::addSessions_async(const AMD_Bridge_addSessionsPtr& callback, const SessionSeq& sessions,
+void BridgeImpl::addSessions_async(const AMD_Bridge_addSessionsPtr& callback,
+        const SessionSeq& sessions,
+        const ConnectedLineSeq& connectedLines,
         const Ice::Current&)
 {
     try
@@ -1345,6 +1355,26 @@ void BridgeImpl::addSessions_async(const AMD_Bridge_addSessionsPtr& callback, co
         tasks.push_back(new SetBridgeTask(mSessions, mPrx, mSessionListenerPrx, sessions, tracker));
         tasks.push_back(new AddToListeners(mListeners, tracker, getCookies()));
         tasks.push_back(new SetAndGetSessionControllerTask(mObjAdapter, mSessions, sessions, this, mLogger));
+
+        //The new sessions being added to the bridge need to have their connected line set and
+        //forwarded to the existing sessions.
+        ConnectedLineSeq::const_iterator connectedIter;
+        SessionSeq::const_iterator sessionIter;
+        for (connectedIter = connectedLines.begin(), sessionIter = sessions.begin();
+                connectedIter != connectedLines.end(); ++connectedIter, ++sessionIter)
+        {
+            tasks.push_back(new UpdateConnectedLineTask(this, *sessionIter, *connectedIter, mLogger));
+            tasks.push_back(new ForwardConnectedLineTask(this, *sessionIter, mLogger));
+        }
+
+        //The existing sessions need to have their stored connected line forwarded to the new
+        //sessions
+        SessionSeq existingSessions = getSessions()->getSessionSeq();
+        for (sessionIter = existingSessions.begin(); sessionIter != existingSessions.end(); ++sessionIter)
+        {
+            tasks.push_back(new ForwardConnectedLineTask(this, *sessionIter, mLogger));
+        }
+
         tasks.push_back(new GenericAMDCallback<AMD_Bridge_addSessionsPtr>(callback, tracker));
         tasks.push_back(new SetupMedia(this));
         tasks.push_back(new ConnectTelephonyEventsTask(this, sessions, mLogger));
@@ -1570,8 +1600,11 @@ void BridgeImpl::removeListener(const BridgeListenerPrx& listener, const Ice::Cu
     }
 }
 
-void BridgeImpl::replaceSession_async(const AMD_Bridge_replaceSessionPtr& callback, const SessionPrx& sessionToReplace,
-        const SessionSeq& newSessions, const Ice::Current& current)
+void BridgeImpl::replaceSession_async(const AMD_Bridge_replaceSessionPtr& callback,
+        const SessionPrx& sessionToReplace,
+        const SessionSeq& newSessions,
+        const ConnectedLineSeq& newConnectedLines,
+        const Ice::Current& current)
 {
     try
     {
@@ -1618,6 +1651,26 @@ void BridgeImpl::replaceSession_async(const AMD_Bridge_replaceSessionPtr& callba
         tasks.push_back(new SetBridgeTask(mSessions, mPrx, mSessionListenerPrx, newSessions, tracker));
         tasks.push_back(new AddToListeners(mListeners, tracker, cookies));
         tasks.push_back(new SetAndGetSessionControllerTask(mObjAdapter, mSessions, newSessions, this, mLogger));
+
+        //The new sessions being added to the bridge need to have their connected line set and
+        //forwarded to the existing sessions.
+        ConnectedLineSeq::const_iterator connectedIter;
+        SessionSeq::const_iterator sessionIter;
+        for (connectedIter = newConnectedLines.begin(), sessionIter = newSessions.begin();
+                connectedIter != newConnectedLines.end(); ++connectedIter, ++sessionIter)
+        {
+            tasks.push_back(new UpdateConnectedLineTask(this, *sessionIter, *connectedIter, mLogger));
+            tasks.push_back(new ForwardConnectedLineTask(this, *sessionIter, mLogger));
+        }
+
+        //The existing sessions need to have their stored connected line forwarded to the new
+        //sessions
+        SessionSeq existingSessions = getSessions()->getSessionSeq();
+        for (sessionIter = existingSessions.begin(); sessionIter != existingSessions.end(); ++sessionIter)
+        {
+            tasks.push_back(new ForwardConnectedLineTask(this, *sessionIter, mLogger));
+        }
+
         tasks.push_back(new GenericAMDCallback<AMD_Bridge_replaceSessionPtr>(callback, tracker));
         tasks.push_back(new SetupMedia(this));
         tasks.push_back(new ConnectTelephonyEventsTask(this, newSessions, mLogger));
diff --git a/test/TestBridging.cpp b/test/TestBridging.cpp
index 13f2996..8a4a2e4 100644
--- a/test/TestBridging.cpp
+++ b/test/TestBridging.cpp
@@ -555,7 +555,11 @@ public:
                 channel.commands()->getlog(idB, log);
                 BOOST_CHECK(!find(log, "start"));
 
-                bridge->addSessions(sessions);
+                AsteriskSCF::SessionCommunications::PartyIdentification::V1::ConnectedLineSeq connectedLines;
+                connectedLines.push_back(a->getConnectedLine());
+                connectedLines.push_back(b->getConnectedLine());
+
+                bridge->addSessions(sessions, connectedLines);
                 //
                 // Check for regression where the bridge was calling start on sessions.
                 //
@@ -655,7 +659,11 @@ public:
                 channel.commands()->getlog(idB, log);
                 BOOST_CHECK(!find(log, "start"));
 
-                bridge->addSessions(sessions);
+                AsteriskSCF::SessionCommunications::PartyIdentification::V1::ConnectedLineSeq connectedLines;
+                connectedLines.push_back(a->getConnectedLine());
+                connectedLines.push_back(b->getConnectedLine());
+
+                bridge->addSessions(sessions, connectedLines);
                 //
                 // Check for regression where the bridge was calling start on sessions.
                 //
@@ -753,7 +761,11 @@ public:
                 channel.commands()->getlog(idB, log);
                 BOOST_CHECK(!find(log, "start"));
 
-                bridge->addSessions(sessions);
+                AsteriskSCF::SessionCommunications::PartyIdentification::V1::ConnectedLineSeq connectedLines;
+                connectedLines.push_back(a->getConnectedLine());
+                connectedLines.push_back(b->getConnectedLine());
+
+                bridge->addSessions(sessions, connectedLines);
                 //
                 // Check for regression where the bridge was calling start on sessions.
                 //
@@ -909,7 +921,11 @@ public:
                 dumplog(log);
                 b->start();
                 IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(2));
-                bridge->replaceSession(a, sessions);
+
+                AsteriskSCF::SessionCommunications::PartyIdentification::V1::ConnectedLineSeq connectedLines;
+                connectedLines.push_back(b->getConnectedLine());
+
+                bridge->replaceSession(a, sessions, connectedLines);
                 log.clear();
                 channel.commands()->answer(idB);
                 IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(2));
@@ -1098,7 +1114,12 @@ public:
                 bridge->addListener(bridgeListenerPrx);
 
                 AsteriskSCF::SessionCommunications::V1::SessionSeq eventSessions;
-                bridge->addSessions(sessions);
+
+                AsteriskSCF::SessionCommunications::PartyIdentification::V1::ConnectedLineSeq connectedLines;
+                connectedLines.push_back(a->getConnectedLine());
+                connectedLines.push_back(b->getConnectedLine());
+
+                bridge->addSessions(sessions, connectedLines);
                 BOOST_REQUIRE(bridgeListener->waitForAdded(5000, eventSessions));
                 CookieMap cookieMap = bridgeListener->getCookieMap();
                 BOOST_REQUIRE(!cookieMap.empty());
@@ -1193,7 +1214,12 @@ public:
                 bridge->addListener(bridgeListenerPrx);
 
                 AsteriskSCF::SessionCommunications::V1::SessionSeq eventSessions;
-                bridge->addSessions(sessions);
+
+                AsteriskSCF::SessionCommunications::PartyIdentification::V1::ConnectedLineSeq connectedLines;
+                connectedLines.push_back(a->getConnectedLine());
+                connectedLines.push_back(b->getConnectedLine());
+
+                bridge->addSessions(sessions, connectedLines);
                 BOOST_REQUIRE(bridgeListener->waitForAdded(5000, eventSessions));
                 CookieMap cookieMap = bridgeListener->getCookieMap();
                 BOOST_REQUIRE(!cookieMap.empty());
@@ -1284,6 +1310,7 @@ public:
                 AsteriskSCF::SessionCommunications::V1::SessionPrx b = channel.getSession("312");
                 sessions.push_back(a);
                 sessions.push_back(b);
+
                 hook->addSessions(sessions);
                 sessions.clear();
 
@@ -1417,7 +1444,10 @@ public:
                 TelephonyEventSourceSeq cSources = tc->getSources();
                 TelephonyEventSinkSeq cSinks = tc->getSinks();
 
-                bridge->replaceSession(b, sessions);
+                AsteriskSCF::SessionCommunications::PartyIdentification::V1::ConnectedLineSeq connectedLines;
+                connectedLines.push_back(c->getConnectedLine());
+
+                bridge->replaceSession(b, sessions, connectedLines);
 
                 IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(2));
 

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


-- 
asterisk-scf/integration/bridging.git



More information about the asterisk-scf-commits mailing list