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

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Mon Sep 13 15:27:01 CDT 2010


branch "master" has been updated
       via  e82d13835b5f93bc220c5924a3821cffea1c588f (commit)
      from  e943e3ef5c8ec7cfd317ca23f53114540b4933cf (commit)

Summary of changes:
 local-slice/SipStateReplicationIf.ice |    1 +
 src/SipStateReplicator.cpp            |   93 ++++++++++++++++++++++++++++----
 src/SipStateReplicator.h              |   13 +++++
 3 files changed, 95 insertions(+), 12 deletions(-)


- Log -----------------------------------------------------------------
commit e82d13835b5f93bc220c5924a3821cffea1c588f
Author: Mark Michelson <mmichelson at digium.com>
Date:   Mon Sep 13 15:16:59 2010 -0500

    More progress with State replicators.

diff --git a/local-slice/SipStateReplicationIf.ice b/local-slice/SipStateReplicationIf.ice
index 3971387..464170e 100644
--- a/local-slice/SipStateReplicationIf.ice
+++ b/local-slice/SipStateReplicationIf.ice
@@ -13,6 +13,7 @@ module V1
 
    class SipStateItem
    {
+      string mId;
    };
 
    sequence<SipStateItem> SipStateItemSeq;
diff --git a/src/SipStateReplicator.cpp b/src/SipStateReplicator.cpp
index cd22740..73d8f4d 100644
--- a/src/SipStateReplicator.cpp
+++ b/src/SipStateReplicator.cpp
@@ -6,6 +6,8 @@
  * All rights reserved.
  */
 
+#include <IceUtil/UUID.h>
+
 #include "SipStateReplicator.h"
 
 namespace AsteriskSCF
@@ -18,40 +20,70 @@ using namespace AsteriskSCF::SIP::V1;
 struct SipStateReplicatorImpl
 {
 public:
-   SipStateReplicatorImpl()
-   {
-      //stub;
-   }
+   SipStateReplicatorImpl() {}
    void addListenerImpl(SipStateReplicatorListenerPrx listener)
    {
-      //stub;
+      mListeners.push_back(listener);
    }
    void removeListenerImpl(SipStateReplicatorListenerPrx listener)
    {
-      //stub;
+      mListeners.erase(std::find(mListeners.begin(), mListeners.end(), listener));
    }
    void setStateImpl(SipStateItemSeq items)
    {
-      //stub;
+      for (SipStateItemSeq::iterator iter = items.begin();
+            iter != items.end(); ++iter)
+      {
+         //Here, we try to find the item in mStateItems so 
+         //that we can update it if necessary. If we don't
+         //find it, we just push the new item onto mStateItems.
+
+		 //Then after we update our local stuff, we need to
+         //iterate over mListeners and call setStateNotice
+         //for each of the listeners.
+      }
    }
    void removeStateImpl(SipStateItemSeq items)
    {
-      //stub;
+      Ice::StringSeq removalKeys;
+      for (SipStateItemSeq::iterator iter = items.begin();
+            iter != items.end(); ++iter)
+      {
+	     mStateItems.erase(iter);
+		 removalKeys.push_back((*iter)->mId);
+      }
+      for (std::vector<SipStateReplicatorListenerPrx>::iterator listenerIter = mListeners.begin();
+               listenerIter != mListeners.end(); ++listenerIter)
+      {
+         (*listenerIter)->removeStateNotice(removalKeys);
+      }
    }
+
    SipStateItemSeq getStateImpl(Ice::StringSeq itemKeys)
    {
-      //stub;
-	  return SipStateItemSeq(0);
+      SipStateItemSeq returnItems;
+	  //XXX Once I have the SipStateItem class set up,
+	  //this'll be a simple call to std::set_intersection
+	  //to get the items to return.
+	  return returnItems;
    }
+
    SipStateItemSeq getAllStatesImpl()
    {
-      //stub;
-	  return SipStateItemSeq(0);
+      return mStateItems;
    }
+
+   std::vector<SipStateReplicatorListenerPrx> mListeners;
+   SipStateItemSeq mStateItems;
 };
 
 SipStateReplicatorI::SipStateReplicatorI() : mImpl(new SipStateReplicatorImpl) {}
 
+SipStateReplicatorI::~SipStateReplicatorI()
+{
+   delete mImpl;
+}
+
 void SipStateReplicatorI::addListener(SipStateReplicatorListenerPrx listener, Ice::Current &)
 {
    mImpl->addListenerImpl(listener);
@@ -82,5 +114,42 @@ SipStateItemSeq SipStateReplicatorI::getAllStates(Ice::Current &)
    return mImpl->getAllStatesImpl();
 }
 
+struct SipStateReplicatorListenerImpl
+{
+public:
+   SipStateReplicatorListenerImpl() : mId(IceUtil::generateUUID()) {}
+   void removeStateNoticeImpl(Ice::StringSeq itemKeys)
+   {
+      //stub
+   }
+   void setStateNoticeImpl(SipStateItemSeq items)
+   {
+      //stub
+   }
+   std::string mId;
+};
+
+SipStateReplicatorListenerI::SipStateReplicatorListenerI() : mImpl(new SipStateReplicatorListenerImpl) {}
+
+SipStateReplicatorListenerI::~SipStateReplicatorListenerI()
+{
+   delete mImpl;
+}
+
+void SipStateReplicatorListenerI::removeStateNotice(Ice::StringSeq itemKeys, Ice::Current &)
+{
+   mImpl->removeStateNoticeImpl(itemKeys);
+}
+
+void SipStateReplicatorListenerI::setStateNotice(SipStateItemSeq items, Ice::Current &)
+{
+   mImpl->setStateNoticeImpl(items);
+}
+
+bool SipStateReplicatorListenerI::operator==(SipStateReplicatorListenerI &rhs)
+{
+   return mImpl->mId == rhs.mImpl->mId;
+}
+
 };
 };
diff --git a/src/SipStateReplicator.h b/src/SipStateReplicator.h
index 7847b3f..8e1ec6a 100644
--- a/src/SipStateReplicator.h
+++ b/src/SipStateReplicator.h
@@ -18,6 +18,7 @@ class SipStateReplicatorI : public SipStateReplicator
 {
 public:
    SipStateReplicatorI();
+   ~SipStateReplicatorI();
    void addListener(SipStateReplicatorListenerPrx listener, Ice::Current&);
    void removeListener(SipStateReplicatorListenerPrx listener, Ice::Current &);
    void setState(SipStateItemSeq items, Ice::Current &);
@@ -29,5 +30,17 @@ private:
    //SipStateReplicatorImpl *mImpl;
 };
 
+class SipStateReplicatorListenerI : public SipStateReplicatorListener
+{
+public:
+   SipStateReplicatorListenerI();
+   ~SipStateReplicatorListenerI();
+   void removeStateNotice(Ice::StringSeq itemKeys, Ice::Current &);
+   void setStateNotice(SipStateItemSeq items, Ice::Current &);
+   bool operator==(SipStateReplicatorListenerI &rhs);
+private:
+   struct SipStateReplicatorListenerImpl *mImpl;
+};
+
 };
 };

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


-- 
asterisk-scf/integration/sip.git



More information about the asterisk-scf-commits mailing list