[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
Tue Sep 21 07:56:31 CDT 2010


branch "master" has been updated
       via  1abad6694e0a22498d264b09584d7e6922a76953 (commit)
      from  89c824518dd35f1e87b934ccb937588bf287db40 (commit)

Summary of changes:
 src/CMakeLists.txt                                 |    2 +-
 src/SipStateReplicator.cpp                         |   90 ---------------
 ...plicator.cpp => SipStateReplicatorListener.cpp} |  121 ++++----------------
 3 files changed, 25 insertions(+), 188 deletions(-)
 copy src/{SipStateReplicator.cpp => SipStateReplicatorListener.cpp} (53%)


- Log -----------------------------------------------------------------
commit 1abad6694e0a22498d264b09584d7e6922a76953
Author: Joshua Colp <jcolp at digium.com>
Date:   Tue Sep 21 10:01:44 2010 -0300

    Split listener implementation away from core replicator implementation. It is being intermingled enough with the SIP component that linking it into the replicator component is just no longer feasible.

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index ee46173..f8aadd3 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -31,7 +31,7 @@ hydra_component_add_file(SipChannelService PJSipManager.cpp)
 hydra_component_add_file(SipChannelService PJSipManager.h)
 hydra_component_add_file(SipChannelService PJSipSessionModule.cpp)
 hydra_component_add_file(SipChannelService PJSipSessionModule.h)
-hydra_component_add_file(SipChannelService SipStateReplicator.cpp)
+hydra_component_add_file(SipChannelService SipStateReplicatorListener.cpp)
 hydra_component_add_file(SipChannelService SipStateReplicator.h)
 
 hydra_component_add_ice_libraries(SipChannelService IceStorm)
diff --git a/src/SipStateReplicator.cpp b/src/SipStateReplicator.cpp
index e63caab..4a744a7 100644
--- a/src/SipStateReplicator.cpp
+++ b/src/SipStateReplicator.cpp
@@ -117,95 +117,5 @@ SipStateItemSeq SipStateReplicatorI::getAllStates(Ice::Current &)
    return mImpl->getAllStatesImpl();
 }
 
-class SipStateReplicatorItem
-{
-public:
-	SipStateReplicatorItem() { }
-	~SipStateReplicatorItem() { }
-private:
-};
-
-struct SipStateReplicatorListenerImpl
-{
-public:
-   SipStateReplicatorListenerImpl() : mId(IceUtil::generateUUID()) {}
-   void removeStateNoticeImpl(Ice::StringSeq itemKeys)
-   {
-      for (Ice::StringSeq::const_iterator key = itemKeys.begin(); key != itemKeys.end(); ++key)
-      {
-	 // Just erasing this from the map will cause the destructor to actually shut things down
-	 mStateItems.erase((*key));
-      }
-   }
-   void setStateNoticeImpl(SipStateItemSeq items)
-   {
-      for (SipStateItemSeq::const_iterator item = items.begin(); item != items.end(); ++item)
-      {
-	 std::map<std::string, boost::shared_ptr<SipStateReplicatorItem> >::iterator i = mStateItems.find((*item)->mSessionId);
-	 SipSessionStateItemPtr session;
-	 SipDialogStateItemPtr dialog;
-	 SipTransactionStateItemPtr transaction;
-	 boost::shared_ptr<SipStateReplicatorItem> localitem;
-
-	 // Depending on the type of state item we apply it differently
-	 if ((session = SipSessionStateItemPtr::dynamicCast((*item))))
-	 {
-	    if (i == mStateItems.end())
-	    {
-	       // Unlike other state items sessions are special in that they create the local class that binds everything together
-	       boost::shared_ptr<SipStateReplicatorItem> newitem(new SipStateReplicatorItem());
-	       mStateItems.insert(std::make_pair<std::string, boost::shared_ptr<SipStateReplicatorItem> >((*item)->mSessionId, newitem));
-	       localitem = newitem;
-	    }
-	    else
-	    {
-	       localitem = i->second;
-	    }
-	 }
-	 else if ((dialog = SipDialogStateItemPtr::dynamicCast((*item))))
-	 {
-	    if (i == mStateItems.end())
-	    {
-	       continue;
-	    }
-	    localitem = i->second;
-	 }
-	 else if ((transaction = SipTransactionStateItemPtr::dynamicCast((*item))))
-	 {
-	    // This check also needs to look for the dialog
-	    if (i == mStateItems.end())
-	    {
-	       continue;
-	    }
-	    localitem = i->second;
-	 }
-      }
-   }
-   std::string mId;
-   std::map<std::string, boost::shared_ptr<SipStateReplicatorItem> > mStateItems;
-};
-
-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.cpp b/src/SipStateReplicatorListener.cpp
similarity index 53%
copy from src/SipStateReplicator.cpp
copy to src/SipStateReplicatorListener.cpp
index e63caab..7faccc6 100644
--- a/src/SipStateReplicator.cpp
+++ b/src/SipStateReplicatorListener.cpp
@@ -12,6 +12,8 @@
 #include <boost/shared_ptr.hpp>
 
 #include "SipStateReplicator.h"
+#include "SipEndpoint.h"
+#include "SipSession.h"
 
 namespace AsteriskSCF
 {
@@ -20,109 +22,20 @@ namespace SipChannelService
 
 using namespace AsteriskSCF::SIP::V1;
 
-struct SipStateReplicatorImpl
-{
-public:
-   SipStateReplicatorImpl() {}
-   void addListenerImpl(SipStateReplicatorListenerPrx listener)
-   {
-      mListeners.push_back(listener);
-   }
-   void removeListenerImpl(SipStateReplicatorListenerPrx listener)
-   {
-      mListeners.erase(std::find(mListeners.begin(), mListeners.end(), listener));
-   }
-   void setStateImpl(SipStateItemSeq items)
-   {
-      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)
-   {
-      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)
-   {
-      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()
-   {
-      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);
-}
-
-void SipStateReplicatorI::removeListener(SipStateReplicatorListenerPrx listener, Ice::Current &)
-{
-   mImpl->removeListenerImpl(listener);
-}
-
-void SipStateReplicatorI::setState(SipStateItemSeq items, Ice::Current &)
-{
-   mImpl->setStateImpl(items);
-}
-
-void SipStateReplicatorI::removeState(SipStateItemSeq items, Ice::Current &)
-{
-   mImpl->removeStateImpl(items);
-}
-
-SipStateItemSeq SipStateReplicatorI::getState(Ice::StringSeq itemKeys, Ice::Current &)
-{
-   return mImpl->getStateImpl(itemKeys);
-}
-
-SipStateItemSeq SipStateReplicatorI::getAllStates(Ice::Current &)
-{
-   return mImpl->getAllStatesImpl();
-}
-
 class SipStateReplicatorItem
 {
 public:
 	SipStateReplicatorItem() { }
 	~SipStateReplicatorItem() { }
+
+	// Helper function which sets the session on this replicator item
+	void setSession(SipSessionPtr session) { mSession = session; };
+
+	// Helper function which gets the session
+	SipSessionPtr getSession() { return mSession; };
 private:
+	// Pointer to the session that we are managing
+	SipSessionPtr mSession;
 };
 
 struct SipStateReplicatorListenerImpl
@@ -152,14 +65,28 @@ public:
 	 {
 	    if (i == mStateItems.end())
 	    {
+	       // TODO: Use value in state item to find endpoint
+	       SipEndpointPtr endpoint;
+
+	       // If we lack the endpoint (due to misconfiguration) we can't procceed
+	       if (endpoint == 0)
+	       {
+		  continue;
+	       }
+
 	       // Unlike other state items sessions are special in that they create the local class that binds everything together
 	       boost::shared_ptr<SipStateReplicatorItem> newitem(new SipStateReplicatorItem());
 	       mStateItems.insert(std::make_pair<std::string, boost::shared_ptr<SipStateReplicatorItem> >((*item)->mSessionId, newitem));
 	       localitem = newitem;
+
+	       // Now that all is well we can create an actual session
+	       SipSessionPtr localSession = endpoint->createSession("", session->mSessionObjectId, session->mMediaSessionObjectId, session->mMediaSession, session->mSources, session->mSinks);
+	       localitem->setSession(localSession);
 	    }
 	    else
 	    {
 	       localitem = i->second;
+	       // TODO: Determine if there is anything that can change a session and not just create it, currently the answer is no
 	    }
 	 }
 	 else if ((dialog = SipDialogStateItemPtr::dynamicCast((*item))))

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


-- 
asterisk-scf/integration/sip.git



More information about the asterisk-scf-commits mailing list