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

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


branch "master" has been updated
       via  74d1103527d97fa8cd5887ab510a748b20ceb8ff (commit)
      from  052d08061987f9d76a4bfa5784db4de1e003f672 (commit)

Summary of changes:
 src/SipTelephonyEventSource.cpp |   84 +++++++++++++++++++++++++++++----------
 src/SipTelephonyEventSource.h   |   24 ++++++-----
 2 files changed, 77 insertions(+), 31 deletions(-)


- Log -----------------------------------------------------------------
commit 74d1103527d97fa8cd5887ab510a748b20ceb8ff
Author: Ken Hunt <ken.hunt at digium.com>
Date:   Sun Oct 2 18:08:10 2011 -0500

    Adapt to API changes. Asynchronous add/get/remove sinks operations.

diff --git a/src/SipTelephonyEventSource.cpp b/src/SipTelephonyEventSource.cpp
index b424dfa..b3a7626 100644
--- a/src/SipTelephonyEventSource.cpp
+++ b/src/SipTelephonyEventSource.cpp
@@ -15,6 +15,7 @@
  */
 
 #include "SipTelephonyEventSource.h"
+#include <AsteriskSCF/Helpers/ProxyHelper.h>
 #include <AsteriskSCF/System/WorkQueue/WorkQueueIf.h>
 
 namespace AsteriskSCF
@@ -24,10 +25,11 @@ namespace SipSessionManager
 {
 
 using namespace AsteriskSCF::System::WorkQueue::V1;
+using namespace AsteriskSCF::SessionCommunications::V1;
 
-void SipTelephonyEventSource::distributeToSinks(const AsteriskSCF::SessionCommunications::V1::TelephonyEventPtr& event)
+void SipTelephonyEventSource::distributeToSinks(const TelephonyEventPtr& event)
 {
-    for (AsteriskSCF::SessionCommunications::V1::TelephonyEventSinkSeq::const_iterator iter = mSinks.begin();
+    for (TelephonyEventSinkSeq::const_iterator iter = mSinks.begin();
             iter != mSinks.end(); ++iter)
     {
         (*iter)->write(event);
@@ -37,40 +39,80 @@ void SipTelephonyEventSource::distributeToSinks(const AsteriskSCF::SessionCommun
 SipTelephonyEventSource::SipTelephonyEventSource(const SessionWorkPtr& sessionWork)
     : mSessionWork(sessionWork) { }
 
-class AddSink : public SuspendableWork
+class AddSinks : public SuspendableWork
 {
 public:
-    AddSink(
-            const AsteriskSCF::SessionCommunications::V1::AMD_TelephonyEventSource_addSinkPtr& cb,
+    AddSinks(
+            const AMD_TelephonyEventSource_addSinksPtr& cb,
             const SipTelephonyEventSourcePtr& source,
-            const AsteriskSCF::SessionCommunications::V1::TelephonyEventSinkPrx& sink)
-        : mCB(cb), mSource(source), mSink(sink) { }
+            const TelephonyEventSinkSeq& sinks)
+        : mCB(cb), mSource(source), mSinks(sinks) { }
 
     SuspendableWorkResult execute(const SuspendableWorkListenerPtr&)
     {
-        mSource->addSink(mSink);
+        mSource->addSinks(mSinks);
         mCB->ice_response();
         return Complete;
     }
 private:
-    AsteriskSCF::SessionCommunications::V1::AMD_TelephonyEventSource_addSinkPtr mCB;
+    AMD_TelephonyEventSource_addSinksPtr mCB;
     SipTelephonyEventSourcePtr mSource;
-    AsteriskSCF::SessionCommunications::V1::TelephonyEventSinkPrx mSink;
+    TelephonyEventSinkSeq mSinks;
 };
 
-void SipTelephonyEventSource::addSink_async(
-        const AsteriskSCF::SessionCommunications::V1::AMD_TelephonyEventSource_addSinkPtr& cb,
-        const AsteriskSCF::SessionCommunications::V1::TelephonyEventSinkPrx& sink,
+class RemoveSinks : public SuspendableWork
+{
+public:
+    RemoveSinks(
+            const AMD_TelephonyEventSource_removeSinksPtr& cb,
+            const SipTelephonyEventSourcePtr& source,
+            const TelephonyEventSinkSeq& sinks)
+        : mCB(cb), mSource(source), mSinks(sinks) { }
+
+    SuspendableWorkResult execute(const SuspendableWorkListenerPtr&)
+    {
+        mSource->removeSinks(mSinks);
+        mCB->ice_response();
+        return Complete;
+    }
+private:
+    AMD_TelephonyEventSource_removeSinksPtr mCB;
+    SipTelephonyEventSourcePtr mSource;
+    TelephonyEventSinkSeq mSinks;
+};
+
+void SipTelephonyEventSource::addSinks_async(
+        const AMD_TelephonyEventSource_addSinksPtr& cb,
+        const TelephonyEventSinkSeq& sinks,
+        const Ice::Current&)
+{
+    mSessionWork->enqueueWork(new AddSinks(cb, this, sinks));
+}
+
+void SipTelephonyEventSource::removeSinks_async(
+        const AMD_TelephonyEventSource_removeSinksPtr& cb,
+        const TelephonyEventSinkSeq& sinks,
         const Ice::Current&)
 {
-    mSessionWork->enqueueWork(new AddSink(cb, this, sink));
+    mSessionWork->enqueueWork(new RemoveSinks(cb, this, sinks));
+}
+
+void SipTelephonyEventSource::addSinks(const TelephonyEventSinkSeq& sinks)
+{
+    for (TelephonyEventSinkSeq::const_iterator i = sinks.begin(); i != sinks.end(); ++i)
+    {
+        if (std::find_if(mSinks.begin(), mSinks.end(), IdentityComparePredicate<TelephonyEventSinkPrx>(*i)) == mSinks.end())
+        {
+            mSinks.push_back(*i);
+        }
+    }
 }
 
-void SipTelephonyEventSource::addSink(const AsteriskSCF::SessionCommunications::V1::TelephonyEventSinkPrx& sink)
+void SipTelephonyEventSource::removeSinks(const TelephonyEventSinkSeq& sinks)
 {
-    if (std::find(mSinks.begin(), mSinks.end(), sink) == mSinks.end())
+    for (TelephonyEventSinkSeq::const_iterator i = sinks.begin(); i != sinks.end(); ++i)
     {
-        mSinks.push_back(sink);
+        mSinks.erase(remove_if(mSinks.begin(), mSinks.end(), IdentityComparePredicate<TelephonyEventSinkPrx>(*i)), mSinks.end());
     }
 }
 
@@ -78,7 +120,7 @@ class GetSinks : public SuspendableWork
 {
 public:
     GetSinks(
-            const AsteriskSCF::SessionCommunications::V1::AMD_TelephonyEventSource_getSinksPtr& cb,
+            const AMD_TelephonyEventSource_getSinksPtr& cb,
             const SipTelephonyEventSourcePtr& source)
         : mCB(cb), mSource(source) { }
 
@@ -88,18 +130,18 @@ public:
         return Complete;
     }
 private:
-    AsteriskSCF::SessionCommunications::V1::AMD_TelephonyEventSource_getSinksPtr mCB;
+    AMD_TelephonyEventSource_getSinksPtr mCB;
     SipTelephonyEventSourcePtr mSource;
 };
 
 void SipTelephonyEventSource::getSinks_async(
-        const AsteriskSCF::SessionCommunications::V1::AMD_TelephonyEventSource_getSinksPtr& cb,
+        const AMD_TelephonyEventSource_getSinksPtr& cb,
         const Ice::Current&)
 {
     mSessionWork->enqueueWork(new GetSinks(cb, this));
 }
 
-AsteriskSCF::SessionCommunications::V1::TelephonyEventSinkSeq SipTelephonyEventSource::getSinks()
+TelephonyEventSinkSeq SipTelephonyEventSource::getSinks()
 {
     return mSinks;
 }
diff --git a/src/SipTelephonyEventSource.h b/src/SipTelephonyEventSource.h
index 730b4bd..11a65ef 100644
--- a/src/SipTelephonyEventSource.h
+++ b/src/SipTelephonyEventSource.h
@@ -29,24 +29,28 @@ public:
 
     SipTelephonyEventSource(const SessionWorkPtr&);
 
-    void addSink_async(
-            const AsteriskSCF::SessionCommunications::V1::AMD_TelephonyEventSource_addSinkPtr&,
-            const AsteriskSCF::SessionCommunications::V1::TelephonyEventSinkPrx& sink,
+    // TelephonyEventSource API implementation...
+
+    void addSinks_async(
+            const AsteriskSCF::SessionCommunications::V1::AMD_TelephonyEventSource_addSinksPtr&,
+            const AsteriskSCF::SessionCommunications::V1::TelephonyEventSinkSeq& sinks,
             const Ice::Current&);
 
-    /**
-     * Only to be called from within a queued operation
-     */
-    void addSink(const AsteriskSCF::SessionCommunications::V1::TelephonyEventSinkPrx& sink);
+    void removeSinks_async(
+            const AsteriskSCF::SessionCommunications::V1::AMD_TelephonyEventSource_removeSinksPtr&,
+            const AsteriskSCF::SessionCommunications::V1::TelephonyEventSinkSeq& sinks,
+            const Ice::Current&);
 
     void getSinks_async(
             const AsteriskSCF::SessionCommunications::V1::AMD_TelephonyEventSource_getSinksPtr&,
             const Ice::Current&);
 
-    /**
-     * Only to be called from within a queued operation
-     */
+    // Only to be called from within a queued operation...
+
     AsteriskSCF::SessionCommunications::V1::TelephonyEventSinkSeq getSinks();
+    void addSinks(const AsteriskSCF::SessionCommunications::V1::TelephonyEventSinkSeq& sinks);
+    void removeSinks(const AsteriskSCF::SessionCommunications::V1::TelephonyEventSinkSeq& sinks);
+
     /**
      * Write an event to all the configured sinks.
      *

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


-- 
asterisk-scf/release/sip.git



More information about the asterisk-scf-commits mailing list