[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
Wed Jul 20 15:56:22 CDT 2011


branch "master" has been updated
       via  b18bdac4a5042928247a0a708b7e62fe4cec801f (commit)
       via  abc64b8ab827c6e1a59a6440f0c82ed4662cd8cb (commit)
       via  e19711fb128b2538bd793dd6993fa1a89a99909e (commit)
       via  4f79a16c7cb94d0b6aa5ed13c3bfdc81fc764641 (commit)
       via  26ec91cf1ad7ae654b38a57e355d85cd7b2a6495 (commit)
       via  c36e88cc66b3a9f5e5cce710df4359e88079d9d9 (commit)
       via  b41a0dc88850f05a29d0adbf62016e22e625a26e (commit)
       via  1b8c6f710bab05f5864611477838d6b56c673eb5 (commit)
       via  f256218dea09a6d6e3e177b35d333b6881bc6ed7 (commit)
       via  ba77572c9c5e5d5abdff517a1f4e144440d5906f (commit)
       via  bd53a89af2c3104984d46c118e2b7b158155f25c (commit)
       via  c58ab8b3d3623ccd57d63077f902eda632faaf7d (commit)
       via  59ccbfc493c091ebfe6d2a71d61026d9abf5a77c (commit)
      from  2b0ba42f2e557f5f5f3e5dba3b41f87a0937d8db (commit)

Summary of changes:
 src/PJSipManager.cpp                   |    6 ++-
 src/PJSipManager.h                     |    4 ++-
 src/PJSipSessionModule.cpp             |   29 ++++++++++++++++
 src/PJSipSessionModule.h               |   25 +++++++++++++-
 src/PJSipSessionModuleConstruction.cpp |   23 +++++++++++--
 src/SipEndpointFactory.h               |    1 +
 src/SipSession.cpp                     |   57 ++++++++++++++++++++++++++++---
 src/SipSession.h                       |    3 ++
 src/SipSessionManagerApp.cpp           |    2 +-
 9 files changed, 136 insertions(+), 14 deletions(-)


- Log -----------------------------------------------------------------
commit b18bdac4a5042928247a0a708b7e62fe4cec801f
Merge: 2b0ba42 abc64b8
Author: Mark Michelson <mmichelson at digium.com>
Date:   Wed Jul 20 15:56:38 2011 -0500

    Merge branch 'session-decorator'

diff --cc src/SipSession.cpp
index 044455b,5052af9..7beb61d
mode 100755,100644..100755
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@@ -445,15 -417,14 +487,14 @@@ SipSession::SipSession(const Ice::Objec
   * Replica constructor.
   */
  SipSession::SipSession(const Ice::ObjectAdapterPtr& adapter, const SipEndpointPtr& endpoint,
 -                       const std::string& destination, const Ice::Identity& sessionid,
 -                       const Ice::Identity& mediaid, const AsteriskSCF::Replication::SipSessionManager::V1::RTPMediaSessionSeq& mediasessions,
 -                       const AsteriskSCF::Media::V1::StreamSourceSeq& sources, const AsteriskSCF::Media::V1::StreamSinkSeq& sinks,
 -                       PJSipManager *manager, const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
 -                       const AsteriskSCF::System::Component::V1::ReplicaPtr& replica, bool isUAC)
 -    : mImplPriv(new SipSessionPriv(adapter, endpoint, destination, manager, serviceLocator, replica))
 +        const std::string& destination, const Ice::Identity& sessionid,
 +        const Ice::Identity& mediaid, const AsteriskSCF::Replication::SipSessionManager::V1::RTPMediaSessionSeq& mediasessions,
 +        const AsteriskSCF::Media::V1::StreamSourceSeq& sources, const AsteriskSCF::Media::V1::StreamSinkSeq& sinks,
 +        const PJSipManagerPtr& manager, const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
 +        const AsteriskSCF::System::Component::V1::ReplicaPtr& replica, bool isUAC, const NATEndpointOptions& natOptions)
 +    : mImplPriv(new SipSessionPriv(adapter, endpoint, destination, manager, serviceLocator, replica, natOptions))
  {
-     mImplPriv->mSessionProxy =
-         AsteriskSCF::SessionCommunications::V1::SessionPrx::uncheckedCast(adapter->add(this, sessionid));
+     activateIceObjects(mImplPriv->mManager->getSessionModule()->getSessionCreationHooks());
  
      mImplPriv->mMediaSession = new SipMediaSession(this);
      mImplPriv->mMediaSessionProxy =

commit abc64b8ab827c6e1a59a6440f0c82ed4662cd8cb
Author: Mark Michelson <mmichelson at digium.com>
Date:   Wed Jul 20 14:33:43 2011 -0500

    decorateSession->modifySession

diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index f733e56..5052af9 100644
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -366,7 +366,7 @@ void SipSession::activateIceObjects(const AsteriskSCF::SessionCommunications::Ex
         AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookDataPtr out;
         try
         {
-            result = (*iter)->decorateSession(in, out);
+            result = (*iter)->modifySession(in, out);
         }
         catch (const Ice::Exception& ex)
         {

commit e19711fb128b2538bd793dd6993fa1a89a99909e
Author: Mark Michelson <mmichelson at digium.com>
Date:   Fri Jul 15 13:43:39 2011 -0500

    Remove remaining references to the word "decorator"

diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index 294a8f6..f282cf0 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -173,23 +173,23 @@ SessionWorkPtr PJSipSessionModInfo::getSessionWork()
     return mSessionWork;
 }
 
-void SipSessionDecorator::addDecorator(const SessionDecoratorHookPrx& hook, const Ice::Current&)
+void SipSessionCreationExtensionPoint::addSessionCreationHook(const SessionCreationHookPrx& hook, const Ice::Current&)
 {
     boost::unique_lock<boost::shared_mutex> lock(mLock);
     mHooks.push_back(hook);
 }
-void SipSessionDecorator::removeDecorator(const SessionDecoratorHookPrx& hook, const Ice::Current&)
+void SipSessionCreationExtensionPoint::removeSessionCreationHook(const SessionCreationHookPrx& hook, const Ice::Current&)
 {
     boost::unique_lock<boost::shared_mutex> lock(mLock);
     mHooks.erase(std::find(mHooks.begin(), mHooks.end(), hook));
 }
-void SipSessionDecorator::clearDecorators(const Ice::Current&)
+void SipSessionCreationExtensionPoint::clearSessionCreationHooks(const Ice::Current&)
 {
     boost::unique_lock<boost::shared_mutex> lock(mLock);
     mHooks.clear();
 }
 
-SessionDecoratorHookSeq SipSessionDecorator::getHooks()
+SessionCreationHookSeq SipSessionCreationExtensionPoint::getHooks()
 {
     boost::shared_lock<boost::shared_mutex> lock(mLock);
     return mHooks;
@@ -1542,9 +1542,9 @@ QueuePtr PJSipSessionModule::getThreadPoolQueue()
     return mPoolQueue;
 }
 
-SessionDecoratorHookSeq PJSipSessionModule::getSessionDecoratorHooks()
+SessionCreationHookSeq PJSipSessionModule::getSessionCreationHooks()
 {
-    return mSessionDecorator->getHooks();
+    return mSessionCreationExtensionPoint->getHooks();
 }
 
 void PJSipSessionModule::enqueueSessionWork(const SuspendableWorkPtr& work, pjsip_inv_session *inv)
diff --git a/src/PJSipSessionModule.h b/src/PJSipSessionModule.h
index e3a72b0..7ea7e5d 100644
--- a/src/PJSipSessionModule.h
+++ b/src/PJSipSessionModule.h
@@ -82,20 +82,20 @@ private:
 
 typedef IceUtil::Handle<PJSipSessionModuleThreadPoolListener> PJSipSessionModuleThreadPoolListenerPtr;
 
-class SipSessionDecorator : public AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorExtensionPoint
+class SipSessionCreationExtensionPoint : public AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationExtensionPoint
 {
 public:
-    void addDecorator(const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookPrx& hook, const Ice::Current&);
-    void removeDecorator(const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookPrx& hook, const Ice::Current&);
-    void clearDecorators(const Ice::Current&);
-    AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq getHooks();
+    void addSessionCreationHook(const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookPrx& hook, const Ice::Current&);
+    void removeSessionCreationHook(const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookPrx& hook, const Ice::Current&);
+    void clearSessionCreationHooks(const Ice::Current&);
+    AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookSeq getHooks();
 
 private:
-    AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq mHooks;
+    AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookSeq mHooks;
     boost::shared_mutex mLock;
 };
 
-typedef IceUtil::Handle<SipSessionDecorator> SipSessionDecoratorPtr;
+typedef IceUtil::Handle<SipSessionCreationExtensionPoint> SipSessionCreationExtensionPointPtr;
 
 class PJSipSessionModule : public PJSipModule
 {
@@ -135,7 +135,7 @@ public:
 
     AsteriskSCF::System::WorkQueue::V1::QueuePtr getThreadPoolQueue();
     
-    AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq getSessionDecoratorHooks();
+    AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookSeq getSessionCreationHooks();
 
 private:
     void handleNewInvite(pjsip_rx_data *rdata);
@@ -153,9 +153,9 @@ private:
     AsteriskSCF::System::ThreadPool::V1::PoolPtr mPool;
     AsteriskSCF::System::WorkQueue::V1::QueuePtr mPoolQueue;
     AsteriskSCF::System::ThreadPool::V1::PoolListenerPtr mPoolListener;
-    SipSessionDecoratorPtr mSessionDecorator;
+    SipSessionCreationExtensionPointPtr mSessionCreationExtensionPoint;
     Ice::ObjectAdapterPtr mAdapter;
-    AsteriskSCF::Core::Discovery::V1::ServiceManagementPrx mDecoratorService;
+    AsteriskSCF::Core::Discovery::V1::ServiceManagementPrx mSessionCreationExtensionPointService;
 };
 
 typedef IceUtil::Handle<PJSipSessionModule> PJSipSessionModulePtr;
diff --git a/src/PJSipSessionModuleConstruction.cpp b/src/PJSipSessionModuleConstruction.cpp
index 459cd9b..8bf443b 100644
--- a/src/PJSipSessionModuleConstruction.cpp
+++ b/src/PJSipSessionModuleConstruction.cpp
@@ -25,7 +25,7 @@ using namespace AsteriskSCF::System::Logging;
 namespace
 {
 Logger lg = getLoggerFactory().getLogger("AsteriskSCF.SipSessionManager");
-const std::string DecoratorId("SipSessionDecorator");
+const std::string SessionCreationExtensionPointId("SipSessionCreationExtensionPoint");
 }
 
 namespace AsteriskSCF
@@ -118,7 +118,7 @@ PJSipSessionModule::PJSipSessionModule(pjsip_endpoint *endpt,
     : mName(moduleName), mEndpointFactory(endpointFactoryPtr),
       mSessionRouter(sessionRouter), mServiceLocator(serviceLocator),
       mStateReplicator(stateReplicator), mReplica(replica), mEndpoint(endpt),
-      mSessionDecorator(new SipSessionDecorator()), mAdapter(adapter)
+      mSessionCreationExtensionPoint(new SipSessionCreationExtensionPoint()), mAdapter(adapter)
 {
     sessionModule = this;
     mModule.name = pj_str(moduleName);
@@ -133,12 +133,12 @@ PJSipSessionModule::PJSipSessionModule(pjsip_endpoint *endpt,
     mModule.on_tx_response = NULL;
     mModule.on_tsx_state = NULL;
 
-    Ice::ObjectPrx decoratorObjPrx = mAdapter->add(mSessionDecorator, mAdapter->getCommunicator()->stringToIdentity(DecoratorId));
-    SessionDecoratorExtensionPointPrx decoratorPrx =
-        SessionDecoratorExtensionPointPrx::uncheckedCast(decoratorObjPrx);
+    Ice::ObjectPrx extensionPointObjPrx = mAdapter->add(mSessionCreationExtensionPoint, mAdapter->getCommunicator()->stringToIdentity(SessionCreationExtensionPointId));
+    SessionCreationExtensionPointPrx extensionPointPrx =
+        SessionCreationExtensionPointPrx::uncheckedCast(extensionPointObjPrx);
 
-    mDecoratorService = serviceLocatorManagement->addService(decoratorPrx, DecoratorId);
-    mDecoratorService->addLocatorParams(new AsteriskSCF::Core::Discovery::V1::ServiceLocatorParams(SessionDecoratorLocatorCategory), "");
+    mSessionCreationExtensionPointService = serviceLocatorManagement->addService(extensionPointPrx, SessionCreationExtensionPointId);
+    mSessionCreationExtensionPointService->addLocatorParams(new AsteriskSCF::Core::Discovery::V1::ServiceLocatorParams(SessionCreationHookLocatorCategory), "");
 
     mPoolQueue = new AsteriskSCF::WorkQueue::WorkQueue();
     mPoolListener = new PJSipSessionModuleThreadPoolListener(); 
@@ -181,8 +181,8 @@ PJSipSessionModule::~PJSipSessionModule()
     try
     {
         mPoolQueue->shutdown();
-        mDecoratorService->unregister();
-        mAdapter->remove(mAdapter->getCommunicator()->stringToIdentity(DecoratorId));
+        mSessionCreationExtensionPointService->unregister();
+        mAdapter->remove(mAdapter->getCommunicator()->stringToIdentity(SessionCreationExtensionPointId));
     }
     catch (const AsteriskSCF::System::WorkQueue::V1::ShuttingDown&)
     {
diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index 0b54281..f733e56 100644
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -196,9 +196,11 @@ public:
     AsteriskSCF::SessionCommunications::V1::SessionPrx mSessionProxy;
 
     /**
-     * A proxy to the decorator for this session.
+     * When someone asks for our session proxy, we give them this. This may
+     * be the same as mSessionProxy, or it may be a different one set by
+     * a session creation hook.
      */
-    AsteriskSCF::SessionCommunications::V1::SessionPrx mSessionDecoratorProxy;
+    AsteriskSCF::SessionCommunications::V1::SessionPrx mPublicSessionProxy;
 
     /**
      * The Ice object adapter that our proxies were added to.
@@ -348,22 +350,23 @@ void SipSession::initializePJSIPStructs()
     setInviteSession(inviteSession);
 }
 
-void SipSession::activateIceObjects(const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq& hooks)
+void SipSession::activateIceObjects(const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookSeq& hooks)
 {
     mImplPriv->mSessionProxy = 
         AsteriskSCF::SessionCommunications::V1::SessionPrx::uncheckedCast(mImplPriv->mAdapter->addWithUUID(this));
 
-    bool decoratorSet = false;
-    for (AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq::const_iterator iter = hooks.begin();
+    AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookDataPtr initial(new AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookData(mImplPriv->mSessionProxy, mImplPriv->mListeners));
+
+    AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookDataPtr in = initial;
+
+    for (AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookSeq::const_iterator iter = hooks.begin();
             iter != hooks.end(); ++iter)
     {
-        AsteriskSCF::SessionCommunications::V1::SessionPrx decorator;
-        AsteriskSCF::SessionCommunications::V1::SessionListenerPrx decoratorListener;
         AsteriskSCF::System::Hook::V1::HookResult result;
-
+        AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookDataPtr out;
         try
         {
-            result = (*iter)->decorateSession(mImplPriv->mSessionProxy, mImplPriv->mListeners, decorator, decoratorListener);
+            result = (*iter)->decorateSession(in, out);
         }
         catch (const Ice::Exception& ex)
         {
@@ -374,12 +377,11 @@ void SipSession::activateIceObjects(const AsteriskSCF::SessionCommunications::Ex
 
         if (result.status == AsteriskSCF::System::Hook::V1::Succeeded)
         {
-            lg(Debug) << "Setting our session proxy to be the decorator " << decorator->ice_getIdentity().name;
-            mImplPriv->mSessionDecoratorProxy = decorator;
+            lg(Debug) << "Setting our session proxy to be " << out->session->ice_getIdentity().name;
+            mImplPriv->mPublicSessionProxy = out->session;
             mImplPriv->mListeners.clear();
-            mImplPriv->mListeners.push_back(decoratorListener);
-            decoratorSet = true;
-            break;
+            mImplPriv->mListeners = out->listeners;
+            in = out;
         }
     }
 }
@@ -398,7 +400,7 @@ SipSession::SipSession(const Ice::ObjectAdapterPtr& adapter, const SipEndpointPt
         mImplPriv->mListeners.push_back(listener);
     }
 
-    activateIceObjects(mImplPriv->mManager->getSessionModule()->getSessionDecoratorHooks());
+    activateIceObjects(mImplPriv->mManager->getSessionModule()->getSessionCreationHooks());
 
     mImplPriv->mMediaSession = new SipMediaSession(this);
     mImplPriv->mMediaSessionProxy =
@@ -422,7 +424,7 @@ SipSession::SipSession(const Ice::ObjectAdapterPtr& adapter, const SipEndpointPt
                        const AsteriskSCF::System::Component::V1::ReplicaPtr& replica, bool isUAC)
     : mImplPriv(new SipSessionPriv(adapter, endpoint, destination, manager, serviceLocator, replica))
 {
-    activateIceObjects(mImplPriv->mManager->getSessionModule()->getSessionDecoratorHooks());
+    activateIceObjects(mImplPriv->mManager->getSessionModule()->getSessionCreationHooks());
 
     mImplPriv->mMediaSession = new SipMediaSession(this);
     mImplPriv->mMediaSessionProxy =
@@ -1619,9 +1621,9 @@ SipEndpointPtr SipSession::getEndpoint()
  */
 AsteriskSCF::SessionCommunications::V1::SessionPrx& SipSession::getSessionProxy()
 {
-    if (mImplPriv->mSessionDecoratorProxy)
+    if (mImplPriv->mPublicSessionProxy)
     {
-        return mImplPriv->mSessionDecoratorProxy;
+        return mImplPriv->mPublicSessionProxy;
     }
     return mImplPriv->mSessionProxy;
 }
diff --git a/src/SipSession.h b/src/SipSession.h
index 99fadd7..91b4f6c 100644
--- a/src/SipSession.h
+++ b/src/SipSession.h
@@ -156,7 +156,7 @@ public:
             const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx&,
             const Ice::Current&);
 
-    void activateIceObjects(const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq& hooks);
+    void activateIceObjects(const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionCreationHookSeq& hooks);
 
     void hold(const Ice::Current&);
     void progress(const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr&, const Ice::Current&);

commit 4f79a16c7cb94d0b6aa5ed13c3bfdc81fc764641
Merge: 26ec91c 6577d75
Author: Mark Michelson <mmichelson at digium.com>
Date:   Fri Jul 15 10:40:51 2011 -0500

    Merge branch 'master' into session-decorator
    
    Conflicts:
    	src/SipEndpointFactory.h

diff --cc src/SipEndpointFactory.h
index 6dca59f,ce8c59b..b6ccbd4
--- a/src/SipEndpointFactory.h
+++ b/src/SipEndpointFactory.h
@@@ -21,7 -21,7 +21,8 @@@
  #include <boost/enable_shared_from_this.hpp>
  
  #include <AsteriskSCF/Core/Endpoint/EndpointIf.h>
 +#include <AsteriskSCF/SessionCommunications/SessionCommunicationsExtensionPointsIf.h>
+ #include <AsteriskSCF/SIP/SIPRegistrarIf.h>
  
  namespace AsteriskSCF
  {

commit 26ec91cf1ad7ae654b38a57e355d85cd7b2a6495
Merge: c36e88c fc8f711
Author: Mark Michelson <mmichelson at digium.com>
Date:   Wed Jul 13 09:43:48 2011 -0500

    Merge branch 'master' into session-decorator

diff --cc src/PJSipSessionModule.cpp
index 41cf906,7128453..294a8f6
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@@ -26,8 -26,9 +26,10 @@@
  #include <AsteriskSCF/Core/Endpoint/EndpointIf.h>
  #include <AsteriskSCF/Core/Routing/RoutingIf.h>
  #include <AsteriskSCF/SessionCommunications/SessionCommunicationsIf.h>
 +#include <AsteriskSCF/SessionCommunications/SessionCommunicationsExtensionPointsIf.h>
  #include <AsteriskSCF/Media/MediaIf.h>
+ #include <AsteriskSCF/Media/RTP/MediaRTPIf.h>
+ #include <AsteriskSCF/Media/SDP/MediaSDPIf.h>
  #include <AsteriskSCF/logger.h>
  #include <AsteriskSCF/WorkQueue/WorkQueue.h>
  #include <AsteriskSCF/WorkQueue/SuspendableWorkQueue.h>
@@@ -53,8 -54,9 +55,10 @@@ namespace SipSessionManage
  using namespace AsteriskSCF::Core::Routing::V1;
  using namespace AsteriskSCF::Core::Endpoint::V1;
  using namespace AsteriskSCF::SessionCommunications::V1;
 +using namespace AsteriskSCF::SessionCommunications::ExtensionPoints::V1;
  using namespace AsteriskSCF::Media::V1;
+ using namespace AsteriskSCF::Media::RTP::V1;
+ using namespace AsteriskSCF::Media::SDP::V1;
  using namespace AsteriskSCF::Replication::SipSessionManager::V1;
  using namespace AsteriskSCF::System::ThreadPool::V1;
  using namespace AsteriskSCF::System::WorkQueue::V1;
diff --cc src/SipSession.cpp
index c32f64e,6210963..0b54281
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@@ -390,14 -375,15 +415,14 @@@ SipSession::SipSession(const Ice::Objec
   * Replica constructor.
   */
  SipSession::SipSession(const Ice::ObjectAdapterPtr& adapter, const SipEndpointPtr& endpoint,
-         const std::string& destination, const Ice::Identity& sessionid,
-         const Ice::Identity& mediaid, const AsteriskSCF::Media::V1::SessionPrx& mediasession,
-         const AsteriskSCF::Media::V1::StreamSourceSeq& sources, const AsteriskSCF::Media::V1::StreamSinkSeq& sinks,
-         PJSipManager *manager, const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
-         const AsteriskSCF::System::Component::V1::ReplicaPtr& replica, bool isUAC)
+                        const std::string& destination, const Ice::Identity& sessionid,
+                        const Ice::Identity& mediaid, const AsteriskSCF::Replication::SipSessionManager::V1::RTPMediaSessionSeq& mediasessions,
+                        const AsteriskSCF::Media::V1::StreamSourceSeq& sources, const AsteriskSCF::Media::V1::StreamSinkSeq& sinks,
+                        PJSipManager *manager, const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
+                        const AsteriskSCF::System::Component::V1::ReplicaPtr& replica, bool isUAC)
      : mImplPriv(new SipSessionPriv(adapter, endpoint, destination, manager, serviceLocator, replica))
  {
 -    mImplPriv->mSessionProxy =
 -        AsteriskSCF::SessionCommunications::V1::SessionPrx::uncheckedCast(adapter->add(this, sessionid));
 +    activateIceObjects(mImplPriv->mManager->getSessionModule()->getSessionDecoratorHooks());
  
      mImplPriv->mMediaSession = new SipMediaSession(this);
      mImplPriv->mMediaSessionProxy =

commit c36e88cc66b3a9f5e5cce710df4359e88079d9d9
Author: Mark Michelson <mmichelson at digium.com>
Date:   Tue Jul 12 18:07:36 2011 -0500

    Adjust for new slice API for session decorator.

diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index 96efd1f..c32f64e 100644
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -236,7 +236,7 @@ public:
     /**
      * A vector of listeners that want to be notified of responses from the SIP endpoint.
      */
-    std::vector<AsteriskSCF::SessionCommunications::V1::SessionListenerPrx> mListeners;
+    AsteriskSCF::SessionCommunications::V1::SessionListenerSeq mListeners;
 
     /**
      * A proxy to the bridge that this session is currently in.
@@ -329,11 +329,12 @@ void SipSession::activateIceObjects(const AsteriskSCF::SessionCommunications::Ex
             iter != hooks.end(); ++iter)
     {
         AsteriskSCF::SessionCommunications::V1::SessionPrx decorator;
+        AsteriskSCF::SessionCommunications::V1::SessionListenerPrx decoratorListener;
         AsteriskSCF::System::Hook::V1::HookResult result;
 
         try
         {
-            result = (*iter)->decorateSession(mImplPriv->mSessionProxy, decorator);
+            result = (*iter)->decorateSession(mImplPriv->mSessionProxy, mImplPriv->mListeners, decorator, decoratorListener);
         }
         catch (const Ice::Exception& ex)
         {
@@ -346,6 +347,8 @@ void SipSession::activateIceObjects(const AsteriskSCF::SessionCommunications::Ex
         {
             lg(Debug) << "Setting our session proxy to be the decorator " << decorator->ice_getIdentity().name;
             mImplPriv->mSessionDecoratorProxy = decorator;
+            mImplPriv->mListeners.clear();
+            mImplPriv->mListeners.push_back(decoratorListener);
             decoratorSet = true;
             break;
         }
@@ -1274,7 +1277,7 @@ AsteriskSCF::Media::V1::StreamSinkSeq& SipSession::getSinks()
 /**
  * Internal function which gets the listeners on this session.
  */
-std::vector<AsteriskSCF::SessionCommunications::V1::SessionListenerPrx> SipSession::getListeners()
+AsteriskSCF::SessionCommunications::V1::SessionListenerSeq SipSession::getListeners()
 {
     return mImplPriv->mListeners;
 }

commit b41a0dc88850f05a29d0adbf62016e22e625a26e
Author: Mark Michelson <mmichelson at digium.com>
Date:   Wed Jul 6 13:35:43 2011 -0500

    Make corrections based on CR-ASTSCF-115 feedback.

diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index 1bc6327..41cf906 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -169,28 +169,26 @@ SessionWorkPtr PJSipSessionModInfo::getSessionWork()
     return mSessionWork;
 }
 
-SipSessionDecorator::SipSessionDecorator() { }
-
 void SipSessionDecorator::addDecorator(const SessionDecoratorHookPrx& hook, const Ice::Current&)
 {
     boost::unique_lock<boost::shared_mutex> lock(mLock);
-    hooks.push_back(hook);
+    mHooks.push_back(hook);
 }
 void SipSessionDecorator::removeDecorator(const SessionDecoratorHookPrx& hook, const Ice::Current&)
 {
     boost::unique_lock<boost::shared_mutex> lock(mLock);
-    hooks.erase(std::find(hooks.begin(), hooks.end(), hook));
+    mHooks.erase(std::find(mHooks.begin(), mHooks.end(), hook));
 }
 void SipSessionDecorator::clearDecorators(const Ice::Current&)
 {
     boost::unique_lock<boost::shared_mutex> lock(mLock);
-    hooks.clear();
+    mHooks.clear();
 }
 
 SessionDecoratorHookSeq SipSessionDecorator::getHooks()
 {
     boost::shared_lock<boost::shared_mutex> lock(mLock);
-    return hooks;
+    return mHooks;
 }
 
 void PJSipSessionModule::replicateState(PJSipDialogModInfo *dlgInfo, PJSipTransactionModInfo *tsxInfo,
diff --git a/src/PJSipSessionModule.h b/src/PJSipSessionModule.h
index c743a55..e3a72b0 100644
--- a/src/PJSipSessionModule.h
+++ b/src/PJSipSessionModule.h
@@ -85,14 +85,13 @@ typedef IceUtil::Handle<PJSipSessionModuleThreadPoolListener> PJSipSessionModule
 class SipSessionDecorator : public AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorExtensionPoint
 {
 public:
-    SipSessionDecorator();
     void addDecorator(const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookPrx& hook, const Ice::Current&);
     void removeDecorator(const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookPrx& hook, const Ice::Current&);
     void clearDecorators(const Ice::Current&);
     AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq getHooks();
 
 private:
-    AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq hooks;
+    AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq mHooks;
     boost::shared_mutex mLock;
 };
 
diff --git a/src/PJSipSessionModuleConstruction.cpp b/src/PJSipSessionModuleConstruction.cpp
index 9aeb449..459cd9b 100644
--- a/src/PJSipSessionModuleConstruction.cpp
+++ b/src/PJSipSessionModuleConstruction.cpp
@@ -36,7 +36,7 @@ namespace SipSessionManager
 
 using namespace AsteriskSCF::WorkQueue;
 using namespace AsteriskSCF::ThreadPool;
-
+using namespace AsteriskSCF::SessionCommunications::ExtensionPoints::V1;
 
 static char moduleName[] = "PJSipSessionModule";
 
@@ -134,11 +134,11 @@ PJSipSessionModule::PJSipSessionModule(pjsip_endpoint *endpt,
     mModule.on_tsx_state = NULL;
 
     Ice::ObjectPrx decoratorObjPrx = mAdapter->add(mSessionDecorator, mAdapter->getCommunicator()->stringToIdentity(DecoratorId));
-    AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorExtensionPointPrx decoratorPrx =
-        AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorExtensionPointPrx::uncheckedCast(decoratorObjPrx);
+    SessionDecoratorExtensionPointPrx decoratorPrx =
+        SessionDecoratorExtensionPointPrx::uncheckedCast(decoratorObjPrx);
 
-    mDecoratorService = serviceLocatorManagement->addService(decoratorPrx, "Spit");
-    mDecoratorService->addLocatorParams(new AsteriskSCF::Core::Discovery::V1::ServiceLocatorParams(AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorLocatorCategory), "");
+    mDecoratorService = serviceLocatorManagement->addService(decoratorPrx, DecoratorId);
+    mDecoratorService->addLocatorParams(new AsteriskSCF::Core::Discovery::V1::ServiceLocatorParams(SessionDecoratorLocatorCategory), "");
 
     mPoolQueue = new AsteriskSCF::WorkQueue::WorkQueue();
     mPoolListener = new PJSipSessionModuleThreadPoolListener(); 
@@ -188,6 +188,10 @@ PJSipSessionModule::~PJSipSessionModule()
     {
         lg(Warning) << "Attempted to shut down a Queue that is already shut down.";
     }
+    catch (const Ice::Exception& ex)
+    {
+        lg(Warning) << "Caught exception trying to destroy the PJSipSessionModule: " << ex.what();
+    }
 }
 
 }; //end namespace SipSessionManager
diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index 0bb8857..96efd1f 100644
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -319,7 +319,7 @@ void SipSession::initializePJSIPStructs()
     setInviteSession(inviteSession);
 }
 
-void SipSession::setSessionProxy(const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq& hooks)
+void SipSession::activateIceObjects(const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq& hooks)
 {
     mImplPriv->mSessionProxy = 
         AsteriskSCF::SessionCommunications::V1::SessionPrx::uncheckedCast(mImplPriv->mAdapter->addWithUUID(this));
@@ -366,7 +366,7 @@ SipSession::SipSession(const Ice::ObjectAdapterPtr& adapter, const SipEndpointPt
         mImplPriv->mListeners.push_back(listener);
     }
 
-    setSessionProxy(mImplPriv->mManager->getSessionModule()->getSessionDecoratorHooks());
+    activateIceObjects(mImplPriv->mManager->getSessionModule()->getSessionDecoratorHooks());
 
     mImplPriv->mMediaSession = new SipMediaSession(this);
     mImplPriv->mMediaSessionProxy =
@@ -394,7 +394,7 @@ SipSession::SipSession(const Ice::ObjectAdapterPtr& adapter, const SipEndpointPt
         const AsteriskSCF::System::Component::V1::ReplicaPtr& replica, bool isUAC)
     : mImplPriv(new SipSessionPriv(adapter, endpoint, destination, manager, serviceLocator, replica))
 {
-    setSessionProxy(mImplPriv->mManager->getSessionModule()->getSessionDecoratorHooks());
+    activateIceObjects(mImplPriv->mManager->getSessionModule()->getSessionDecoratorHooks());
 
     mImplPriv->mMediaSession = new SipMediaSession(this);
     mImplPriv->mMediaSessionProxy =
diff --git a/src/SipSession.h b/src/SipSession.h
index 54b7b95..541f1aa 100644
--- a/src/SipSession.h
+++ b/src/SipSession.h
@@ -156,7 +156,7 @@ public:
             const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx&,
             const Ice::Current&);
 
-    void setSessionProxy(const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq& hooks);
+    void activateIceObjects(const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq& hooks);
 
     void hold(const Ice::Current&);
     void progress(const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr&, const Ice::Current&);

commit 1b8c6f710bab05f5864611477838d6b56c673eb5
Author: Mark Michelson <mmichelson at digium.com>
Date:   Tue Jul 5 13:36:04 2011 -0500

    Remove extra debug message.

diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index 610e450..0bb8857 100644
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -130,7 +130,6 @@ public:
 
     void addListener(const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx& listener)
     {
-        lg(Debug) << "Hey there?";
         mListeners.push_back(listener);
         if (mInviteSession)
         {

commit f256218dea09a6d6e3e177b35d333b6881bc6ed7
Author: Mark Michelson <mmichelson at digium.com>
Date:   Thu Jun 30 14:56:41 2011 -0500

    Safely remove session proxy from the object adapter when the session is destroyed

diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index a3b47bb..610e450 100644
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -130,6 +130,7 @@ public:
 
     void addListener(const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx& listener)
     {
+        lg(Debug) << "Hey there?";
         mListeners.push_back(listener);
         if (mInviteSession)
         {
@@ -189,6 +190,11 @@ public:
     AsteriskSCF::SessionCommunications::V1::SessionPrx mSessionProxy;
 
     /**
+     * A proxy to the decorator for this session.
+     */
+    AsteriskSCF::SessionCommunications::V1::SessionPrx mSessionDecoratorProxy;
+
+    /**
      * The Ice object adapter that our proxies were added to.
      */
     Ice::ObjectAdapterPtr mAdapter;
@@ -316,7 +322,7 @@ void SipSession::initializePJSIPStructs()
 
 void SipSession::setSessionProxy(const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq& hooks)
 {
-    AsteriskSCF::SessionCommunications::V1::SessionPrx us = 
+    mImplPriv->mSessionProxy = 
         AsteriskSCF::SessionCommunications::V1::SessionPrx::uncheckedCast(mImplPriv->mAdapter->addWithUUID(this));
 
     bool decoratorSet = false;
@@ -328,7 +334,7 @@ void SipSession::setSessionProxy(const AsteriskSCF::SessionCommunications::Exten
 
         try
         {
-            result = (*iter)->decorateSession(us, decorator);
+            result = (*iter)->decorateSession(mImplPriv->mSessionProxy, decorator);
         }
         catch (const Ice::Exception& ex)
         {
@@ -339,16 +345,12 @@ void SipSession::setSessionProxy(const AsteriskSCF::SessionCommunications::Exten
 
         if (result.status == AsteriskSCF::System::Hook::V1::Succeeded)
         {
-            mImplPriv->mSessionProxy = decorator;
+            lg(Debug) << "Setting our session proxy to be the decorator " << decorator->ice_getIdentity().name;
+            mImplPriv->mSessionDecoratorProxy = decorator;
             decoratorSet = true;
             break;
         }
     }
-    
-    if (!decoratorSet)
-    {
-        mImplPriv->mSessionProxy = us;
-    }
 }
 
 /**
@@ -1291,6 +1293,10 @@ SipEndpointPtr SipSession::getEndpoint()
  */
 AsteriskSCF::SessionCommunications::V1::SessionPrx& SipSession::getSessionProxy()
 {
+    if (mImplPriv->mSessionDecoratorProxy)
+    {
+        return mImplPriv->mSessionDecoratorProxy;
+    }
     return mImplPriv->mSessionProxy;
 }
 

commit ba77572c9c5e5d5abdff517a1f4e144440d5906f
Author: Mark Michelson <mmichelson at digium.com>
Date:   Wed Jun 29 17:45:19 2011 -0500

    Populate the session decorator with something for real.

diff --git a/src/PJSipSessionModuleConstruction.cpp b/src/PJSipSessionModuleConstruction.cpp
index 6dd0a56..9aeb449 100644
--- a/src/PJSipSessionModuleConstruction.cpp
+++ b/src/PJSipSessionModuleConstruction.cpp
@@ -118,7 +118,7 @@ PJSipSessionModule::PJSipSessionModule(pjsip_endpoint *endpt,
     : mName(moduleName), mEndpointFactory(endpointFactoryPtr),
       mSessionRouter(sessionRouter), mServiceLocator(serviceLocator),
       mStateReplicator(stateReplicator), mReplica(replica), mEndpoint(endpt),
-      mAdapter(adapter)
+      mSessionDecorator(new SipSessionDecorator()), mAdapter(adapter)
 {
     sessionModule = this;
     mModule.name = pj_str(moduleName);

commit bd53a89af2c3104984d46c118e2b7b158155f25c
Author: Mark Michelson <mmichelson at digium.com>
Date:   Wed Jun 29 16:36:22 2011 -0500

    Register the decorator extension point with the service locator.

diff --git a/src/PJSipManager.cpp b/src/PJSipManager.cpp
index 407dcbe..c7402ce 100644
--- a/src/PJSipManager.cpp
+++ b/src/PJSipManager.cpp
@@ -82,11 +82,12 @@ void PJSipManager::registerSessionModule(const boost::shared_ptr<SipEndpointFact
         const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
         const AsteriskSCF::Discovery::SmartProxy<SipStateReplicatorPrx>& stateReplicator,
         const AsteriskSCF::System::Component::V1::ReplicaPtr& replica,
-        const Ice::ObjectAdapterPtr& adapter
+        const Ice::ObjectAdapterPtr& adapter,
+        const AsteriskSCF::Core::Discovery::V1::ServiceLocatorManagementPrx& serviceLocatorManagement
     )
 {
     mSessionModule = new PJSipSessionModule(mEndpoint, endpointFactoryPtr, sessionRouter,
-        serviceLocator, stateReplicator, replica, adapter);
+        serviceLocator, stateReplicator, replica, adapter, serviceLocatorManagement);
 }
 
 void PJSipManager::registerLoggingModule()
diff --git a/src/PJSipManager.h b/src/PJSipManager.h
index 3149c76..75c7f87 100644
--- a/src/PJSipManager.h
+++ b/src/PJSipManager.h
@@ -75,7 +75,8 @@ public:
         const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
         const AsteriskSCF::Discovery::SmartProxy<SipStateReplicatorPrx>& stateReplicator,
         const AsteriskSCF::System::Component::V1::ReplicaPtr& replica,
-        const Ice::ObjectAdapterPtr& adapter
+        const Ice::ObjectAdapterPtr& adapter,
+        const AsteriskSCF::Core::Discovery::V1::ServiceLocatorManagementPrx& serviceLocatorManagement
         );
 
     /**
diff --git a/src/PJSipSessionModule.h b/src/PJSipSessionModule.h
index 4798c64..c743a55 100644
--- a/src/PJSipSessionModule.h
+++ b/src/PJSipSessionModule.h
@@ -107,7 +107,8 @@ public:
         const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
         const AsteriskSCF::Discovery::SmartProxy<SipStateReplicatorPrx>& stateReplicator,
         const AsteriskSCF::System::Component::V1::ReplicaPtr& replica,
-        const Ice::ObjectAdapterPtr& adapter);
+        const Ice::ObjectAdapterPtr& adapter,
+        const AsteriskSCF::Core::Discovery::V1::ServiceLocatorManagementPrx& serviceLocatorManagement);
     ~PJSipSessionModule();
     pj_status_t load(pjsip_endpoint *endpoint);
     pj_status_t start();
@@ -155,6 +156,7 @@ private:
     AsteriskSCF::System::ThreadPool::V1::PoolListenerPtr mPoolListener;
     SipSessionDecoratorPtr mSessionDecorator;
     Ice::ObjectAdapterPtr mAdapter;
+    AsteriskSCF::Core::Discovery::V1::ServiceManagementPrx mDecoratorService;
 };
 
 typedef IceUtil::Handle<PJSipSessionModule> PJSipSessionModulePtr;
diff --git a/src/PJSipSessionModuleConstruction.cpp b/src/PJSipSessionModuleConstruction.cpp
index 12fb15e..6dd0a56 100644
--- a/src/PJSipSessionModuleConstruction.cpp
+++ b/src/PJSipSessionModuleConstruction.cpp
@@ -113,7 +113,8 @@ PJSipSessionModule::PJSipSessionModule(pjsip_endpoint *endpt,
     const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
     const AsteriskSCF::Discovery::SmartProxy<SipStateReplicatorPrx>& stateReplicator,
     const AsteriskSCF::System::Component::V1::ReplicaPtr& replica,
-    const Ice::ObjectAdapterPtr& adapter)
+    const Ice::ObjectAdapterPtr& adapter,
+    const AsteriskSCF::Core::Discovery::V1::ServiceLocatorManagementPrx& serviceLocatorManagement)
     : mName(moduleName), mEndpointFactory(endpointFactoryPtr),
       mSessionRouter(sessionRouter), mServiceLocator(serviceLocator),
       mStateReplicator(stateReplicator), mReplica(replica), mEndpoint(endpt),
@@ -132,7 +133,12 @@ PJSipSessionModule::PJSipSessionModule(pjsip_endpoint *endpt,
     mModule.on_tx_response = NULL;
     mModule.on_tsx_state = NULL;
 
-    mAdapter->add(mSessionDecorator, mAdapter->getCommunicator()->stringToIdentity(DecoratorId));
+    Ice::ObjectPrx decoratorObjPrx = mAdapter->add(mSessionDecorator, mAdapter->getCommunicator()->stringToIdentity(DecoratorId));
+    AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorExtensionPointPrx decoratorPrx =
+        AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorExtensionPointPrx::uncheckedCast(decoratorObjPrx);
+
+    mDecoratorService = serviceLocatorManagement->addService(decoratorPrx, "Spit");
+    mDecoratorService->addLocatorParams(new AsteriskSCF::Core::Discovery::V1::ServiceLocatorParams(AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorLocatorCategory), "");
 
     mPoolQueue = new AsteriskSCF::WorkQueue::WorkQueue();
     mPoolListener = new PJSipSessionModuleThreadPoolListener(); 
@@ -175,6 +181,7 @@ PJSipSessionModule::~PJSipSessionModule()
     try
     {
         mPoolQueue->shutdown();
+        mDecoratorService->unregister();
         mAdapter->remove(mAdapter->getCommunicator()->stringToIdentity(DecoratorId));
     }
     catch (const AsteriskSCF::System::WorkQueue::V1::ShuttingDown&)
diff --git a/src/SipSessionManagerApp.cpp b/src/SipSessionManagerApp.cpp
index f34f1d0..12f6411 100644
--- a/src/SipSessionManagerApp.cpp
+++ b/src/SipSessionManagerApp.cpp
@@ -470,7 +470,7 @@ void SipSessionManager::registerPJSipModules()
         if (*i == "Session")
         {
             mPJSipManager->registerSessionModule(mEndpointFactory,
-                mSessionRouter, mServiceLocator, mStateReplicator, mReplicaService, mGlobalAdapter);
+                mSessionRouter, mServiceLocator, mStateReplicator, mReplicaService, mGlobalAdapter, mServiceLocatorManagement);
         }
         else if (*i == "Logging" || *i == "Logger")
         {

commit c58ab8b3d3623ccd57d63077f902eda632faaf7d
Author: Mark Michelson <mmichelson at digium.com>
Date:   Wed Jun 29 14:26:44 2011 -0500

    Change decorator hooks to be stored in the session module.
    
    This also adds the adapter to the session module so that we can
    add the decorator to the adapter.

diff --git a/src/PJSipManager.cpp b/src/PJSipManager.cpp
index 928d47a..407dcbe 100644
--- a/src/PJSipManager.cpp
+++ b/src/PJSipManager.cpp
@@ -81,11 +81,12 @@ void PJSipManager::registerSessionModule(const boost::shared_ptr<SipEndpointFact
             AsteriskSCF::SessionCommunications::V1::SessionRouterPrx>& sessionRouter,
         const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
         const AsteriskSCF::Discovery::SmartProxy<SipStateReplicatorPrx>& stateReplicator,
-        const AsteriskSCF::System::Component::V1::ReplicaPtr& replica
+        const AsteriskSCF::System::Component::V1::ReplicaPtr& replica,
+        const Ice::ObjectAdapterPtr& adapter
     )
 {
     mSessionModule = new PJSipSessionModule(mEndpoint, endpointFactoryPtr, sessionRouter,
-        serviceLocator, stateReplicator, replica);
+        serviceLocator, stateReplicator, replica, adapter);
 }
 
 void PJSipManager::registerLoggingModule()
diff --git a/src/PJSipManager.h b/src/PJSipManager.h
index d82829e..3149c76 100644
--- a/src/PJSipManager.h
+++ b/src/PJSipManager.h
@@ -74,7 +74,8 @@ public:
             sessionRouter,
         const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
         const AsteriskSCF::Discovery::SmartProxy<SipStateReplicatorPrx>& stateReplicator,
-        const AsteriskSCF::System::Component::V1::ReplicaPtr& replica
+        const AsteriskSCF::System::Component::V1::ReplicaPtr& replica,
+        const Ice::ObjectAdapterPtr& adapter
         );
 
     /**
diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index b6719d5..1bc6327 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -26,6 +26,7 @@
 #include <AsteriskSCF/Core/Endpoint/EndpointIf.h>
 #include <AsteriskSCF/Core/Routing/RoutingIf.h>
 #include <AsteriskSCF/SessionCommunications/SessionCommunicationsIf.h>
+#include <AsteriskSCF/SessionCommunications/SessionCommunicationsExtensionPointsIf.h>
 #include <AsteriskSCF/Media/MediaIf.h>
 #include <AsteriskSCF/logger.h>
 #include <AsteriskSCF/WorkQueue/WorkQueue.h>
@@ -52,6 +53,7 @@ namespace SipSessionManager
 using namespace AsteriskSCF::Core::Routing::V1;
 using namespace AsteriskSCF::Core::Endpoint::V1;
 using namespace AsteriskSCF::SessionCommunications::V1;
+using namespace AsteriskSCF::SessionCommunications::ExtensionPoints::V1;
 using namespace AsteriskSCF::Media::V1;
 using namespace AsteriskSCF::Replication::SipSessionManager::V1;
 using namespace AsteriskSCF::System::ThreadPool::V1;
@@ -167,6 +169,30 @@ SessionWorkPtr PJSipSessionModInfo::getSessionWork()
     return mSessionWork;
 }
 
+SipSessionDecorator::SipSessionDecorator() { }
+
+void SipSessionDecorator::addDecorator(const SessionDecoratorHookPrx& hook, const Ice::Current&)
+{
+    boost::unique_lock<boost::shared_mutex> lock(mLock);
+    hooks.push_back(hook);
+}
+void SipSessionDecorator::removeDecorator(const SessionDecoratorHookPrx& hook, const Ice::Current&)
+{
+    boost::unique_lock<boost::shared_mutex> lock(mLock);
+    hooks.erase(std::find(hooks.begin(), hooks.end(), hook));
+}
+void SipSessionDecorator::clearDecorators(const Ice::Current&)
+{
+    boost::unique_lock<boost::shared_mutex> lock(mLock);
+    hooks.clear();
+}
+
+SessionDecoratorHookSeq SipSessionDecorator::getHooks()
+{
+    boost::shared_lock<boost::shared_mutex> lock(mLock);
+    return hooks;
+}
+
 void PJSipSessionModule::replicateState(PJSipDialogModInfo *dlgInfo, PJSipTransactionModInfo *tsxInfo,
     PJSipSessionModInfo *sessionInfo)
 {
@@ -1529,6 +1555,11 @@ QueuePtr PJSipSessionModule::getThreadPoolQueue()
     return mPoolQueue;
 }
 
+SessionDecoratorHookSeq PJSipSessionModule::getSessionDecoratorHooks()
+{
+    return mSessionDecorator->getHooks();
+}
+
 void PJSipSessionModule::enqueueSessionWork(const SuspendableWorkPtr& work, pjsip_inv_session *inv)
 {
     PJSipSessionModInfo *session_mod_info =
diff --git a/src/PJSipSessionModule.h b/src/PJSipSessionModule.h
index 7b4cd30..4798c64 100644
--- a/src/PJSipSessionModule.h
+++ b/src/PJSipSessionModule.h
@@ -82,6 +82,22 @@ private:
 
 typedef IceUtil::Handle<PJSipSessionModuleThreadPoolListener> PJSipSessionModuleThreadPoolListenerPtr;
 
+class SipSessionDecorator : public AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorExtensionPoint
+{
+public:
+    SipSessionDecorator();
+    void addDecorator(const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookPrx& hook, const Ice::Current&);
+    void removeDecorator(const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookPrx& hook, const Ice::Current&);
+    void clearDecorators(const Ice::Current&);
+    AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq getHooks();
+
+private:
+    AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq hooks;
+    boost::shared_mutex mLock;
+};
+
+typedef IceUtil::Handle<SipSessionDecorator> SipSessionDecoratorPtr;
+
 class PJSipSessionModule : public PJSipModule
 {
 public:
@@ -90,7 +106,8 @@ public:
             sessionRouter,
         const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
         const AsteriskSCF::Discovery::SmartProxy<SipStateReplicatorPrx>& stateReplicator,
-        const AsteriskSCF::System::Component::V1::ReplicaPtr& replica);
+        const AsteriskSCF::System::Component::V1::ReplicaPtr& replica,
+        const Ice::ObjectAdapterPtr& adapter);
     ~PJSipSessionModule();
     pj_status_t load(pjsip_endpoint *endpoint);
     pj_status_t start();
@@ -117,6 +134,9 @@ public:
             pjsip_inv_session *);
 
     AsteriskSCF::System::WorkQueue::V1::QueuePtr getThreadPoolQueue();
+    
+    AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq getSessionDecoratorHooks();
+
 private:
     void handleNewInvite(pjsip_rx_data *rdata);
     void handleInviteResponse(pjsip_inv_session *inv, pjsip_rx_data *rdata, pjsip_dialog *dlg);
@@ -133,6 +153,8 @@ private:
     AsteriskSCF::System::ThreadPool::V1::PoolPtr mPool;
     AsteriskSCF::System::WorkQueue::V1::QueuePtr mPoolQueue;
     AsteriskSCF::System::ThreadPool::V1::PoolListenerPtr mPoolListener;
+    SipSessionDecoratorPtr mSessionDecorator;
+    Ice::ObjectAdapterPtr mAdapter;
 };
 
 typedef IceUtil::Handle<PJSipSessionModule> PJSipSessionModulePtr;
diff --git a/src/PJSipSessionModuleConstruction.cpp b/src/PJSipSessionModuleConstruction.cpp
index 0b034aa..12fb15e 100644
--- a/src/PJSipSessionModuleConstruction.cpp
+++ b/src/PJSipSessionModuleConstruction.cpp
@@ -25,6 +25,7 @@ using namespace AsteriskSCF::System::Logging;
 namespace
 {
 Logger lg = getLoggerFactory().getLogger("AsteriskSCF.SipSessionManager");
+const std::string DecoratorId("SipSessionDecorator");
 }
 
 namespace AsteriskSCF
@@ -111,10 +112,12 @@ PJSipSessionModule::PJSipSessionModule(pjsip_endpoint *endpt,
     const AsteriskSCF::Discovery::SmartProxy<AsteriskSCF::SessionCommunications::V1::SessionRouterPrx>& sessionRouter,
     const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
     const AsteriskSCF::Discovery::SmartProxy<SipStateReplicatorPrx>& stateReplicator,
-    const AsteriskSCF::System::Component::V1::ReplicaPtr& replica)
+    const AsteriskSCF::System::Component::V1::ReplicaPtr& replica,
+    const Ice::ObjectAdapterPtr& adapter)
     : mName(moduleName), mEndpointFactory(endpointFactoryPtr),
       mSessionRouter(sessionRouter), mServiceLocator(serviceLocator),
-      mStateReplicator(stateReplicator), mReplica(replica), mEndpoint(endpt)
+      mStateReplicator(stateReplicator), mReplica(replica), mEndpoint(endpt),
+      mAdapter(adapter)
 {
     sessionModule = this;
     mModule.name = pj_str(moduleName);
@@ -129,6 +132,8 @@ PJSipSessionModule::PJSipSessionModule(pjsip_endpoint *endpt,
     mModule.on_tx_response = NULL;
     mModule.on_tsx_state = NULL;
 
+    mAdapter->add(mSessionDecorator, mAdapter->getCommunicator()->stringToIdentity(DecoratorId));
+
     mPoolQueue = new AsteriskSCF::WorkQueue::WorkQueue();
     mPoolListener = new PJSipSessionModuleThreadPoolListener(); 
 
@@ -170,6 +175,7 @@ PJSipSessionModule::~PJSipSessionModule()
     try
     {
         mPoolQueue->shutdown();
+        mAdapter->remove(mAdapter->getCommunicator()->stringToIdentity(DecoratorId));
     }
     catch (const AsteriskSCF::System::WorkQueue::V1::ShuttingDown&)
     {
diff --git a/src/SipEndpoint.cpp b/src/SipEndpoint.cpp
index 06b5d2e..2a6af1a 100644
--- a/src/SipEndpoint.cpp
+++ b/src/SipEndpoint.cpp
@@ -189,8 +189,7 @@ AsteriskSCF::SessionCommunications::V1::SessionPrx SipEndpoint::createSession(co
     }
 
     SipSessionPtr session = new SipSession(mImplPriv->mAdapter, this, destination, listener, mImplPriv->mManager,
-        mImplPriv->mServiceLocator, mImplPriv->mReplica, mImplPriv->mConfig.sessionConfig.rtpOverIPv6, true,
-        mImplPriv->mEndpointFactory->getDecorators());
+        mImplPriv->mServiceLocator, mImplPriv->mReplica, mImplPriv->mConfig.sessionConfig.rtpOverIPv6, true);
     mImplPriv->mSessions.push_back(session);
     std::cout << "And now we're returing a session proxy..." << std::endl;
     return session->getSessionProxy();
@@ -199,8 +198,7 @@ AsteriskSCF::SessionCommunications::V1::SessionPrx SipEndpoint::createSession(co
 AsteriskSCF::SipSessionManager::SipSessionPtr SipEndpoint::createSession(const std::string& destination)
 {
     SipSessionPtr session = new SipSession(mImplPriv->mAdapter, this, destination, 0, mImplPriv->mManager,
-        mImplPriv->mServiceLocator, mImplPriv->mReplica, mImplPriv->mConfig.sessionConfig.rtpOverIPv6, false,
-        mImplPriv->mEndpointFactory->getDecorators());
+        mImplPriv->mServiceLocator, mImplPriv->mReplica, mImplPriv->mConfig.sessionConfig.rtpOverIPv6, false);
     mImplPriv->mSessions.push_back(session);
     return session;
 }
@@ -211,8 +209,7 @@ AsteriskSCF::SipSessionManager::SipSessionPtr SipEndpoint::createSession(const s
         const AsteriskSCF::Media::V1::StreamSinkSeq& sinks)
 {
     SipSessionPtr session = new SipSession(mImplPriv->mAdapter, this, destination, sessionid, mediaid, mediasession,
-            sources, sinks, mImplPriv->mManager, mImplPriv->mServiceLocator, mImplPriv->mReplica, false,
-            mImplPriv->mEndpointFactory->getDecorators());
+            sources, sinks, mImplPriv->mManager, mImplPriv->mServiceLocator, mImplPriv->mReplica, false);
     mImplPriv->mSessions.push_back(session);
     return session;
 }
diff --git a/src/SipEndpointFactory.cpp b/src/SipEndpointFactory.cpp
index ff5b6b3..61349c9 100644
--- a/src/SipEndpointFactory.cpp
+++ b/src/SipEndpointFactory.cpp
@@ -60,10 +60,6 @@ void SipEndpointFactory::generateRoutingDestinations(AsteriskSCF::Core::Routing:
         destinations.push_back((*iter)->getName());
     }
 }
-AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq SipEndpointFactory::getDecorators()
-{
-    return mHooks;
-}
 
 }; // end SipSessionManager
 }; // end AsteriskSCF
diff --git a/src/SipEndpointFactory.h b/src/SipEndpointFactory.h
index f29e8dc..6dca59f 100644
--- a/src/SipEndpointFactory.h
+++ b/src/SipEndpointFactory.h
@@ -48,8 +48,6 @@ public:
     SipEndpointPtr findByName(const std::string& endpointName);
 
     void generateRoutingDestinations(AsteriskSCF::Core::Routing::V1::RegExSeq&);
-
-    AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq getDecorators();
 private:
     /**
      * A pointer to the object adapter that endpoints will be added to.
@@ -75,11 +73,6 @@ private:
      * A pointer to the replica information.
      */
     AsteriskSCF::System::Component::V1::ReplicaPtr mReplica;
-    
-    /**
-     * All the registered session decorator hooks
-     */
-    AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq mHooks;
 };
 
 }; // end SipSessionManager
diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index 35a1285..a3b47bb 100644
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -357,8 +357,7 @@ void SipSession::setSessionProxy(const AsteriskSCF::SessionCommunications::Exten
 SipSession::SipSession(const Ice::ObjectAdapterPtr& adapter, const SipEndpointPtr& endpoint,
         const std::string& destination,  const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx& listener,
         PJSipManager *manager, const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
-        const AsteriskSCF::System::Component::V1::ReplicaPtr& replica, bool ipv6, bool isUAC,
-        const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq& hooks)
+        const AsteriskSCF::System::Component::V1::ReplicaPtr& replica, bool ipv6, bool isUAC)
     : mImplPriv(new SipSessionPriv(adapter, endpoint, destination, manager, serviceLocator, replica))
 {
     if (listener != 0)
@@ -366,7 +365,7 @@ SipSession::SipSession(const Ice::ObjectAdapterPtr& adapter, const SipEndpointPt
         mImplPriv->mListeners.push_back(listener);
     }
 
-    setSessionProxy(hooks);
+    setSessionProxy(mImplPriv->mManager->getSessionModule()->getSessionDecoratorHooks());
 
     mImplPriv->mMediaSession = new SipMediaSession(this);
     mImplPriv->mMediaSessionProxy =
@@ -391,11 +390,10 @@ SipSession::SipSession(const Ice::ObjectAdapterPtr& adapter, const SipEndpointPt
         const Ice::Identity& mediaid, const AsteriskSCF::Media::V1::SessionPrx& mediasession,
         const AsteriskSCF::Media::V1::StreamSourceSeq& sources, const AsteriskSCF::Media::V1::StreamSinkSeq& sinks,
         PJSipManager *manager, const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
-        const AsteriskSCF::System::Component::V1::ReplicaPtr& replica, bool isUAC,
-        const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq& hooks)
+        const AsteriskSCF::System::Component::V1::ReplicaPtr& replica, bool isUAC)
     : mImplPriv(new SipSessionPriv(adapter, endpoint, destination, manager, serviceLocator, replica))
 {
-    setSessionProxy(hooks);
+    setSessionProxy(mImplPriv->mManager->getSessionModule()->getSessionDecoratorHooks());
 
     mImplPriv->mMediaSession = new SipMediaSession(this);
     mImplPriv->mMediaSessionProxy =
diff --git a/src/SipSession.h b/src/SipSession.h
index d3d838a..54b7b95 100644
--- a/src/SipSession.h
+++ b/src/SipSession.h
@@ -99,16 +99,14 @@ public:
         const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx&, PJSipManager *manager,
         const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
         const AsteriskSCF::System::Component::V1::ReplicaPtr& replica,
-        bool ipv6, bool isUAC,
-        const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq& hooks);
+        bool ipv6, bool isUAC);
 
     SipSession(const Ice::ObjectAdapterPtr&, const SipEndpointPtr&, const std::string&, const Ice::Identity&,
         const Ice::Identity&, const AsteriskSCF::Media::V1::SessionPrx&,
         const AsteriskSCF::Media::V1::StreamSourceSeq&, const AsteriskSCF::Media::V1::StreamSinkSeq&,
         PJSipManager *manager, const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
         const AsteriskSCF::System::Component::V1::ReplicaPtr& replica,
-        bool isUAC,
-        const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq& hooks);
+        bool isUAC);
 
     bool operator==(const SipSession &other) const;
 
diff --git a/src/SipSessionManagerApp.cpp b/src/SipSessionManagerApp.cpp
index 1d89753..f34f1d0 100644
--- a/src/SipSessionManagerApp.cpp
+++ b/src/SipSessionManagerApp.cpp
@@ -470,7 +470,7 @@ void SipSessionManager::registerPJSipModules()
         if (*i == "Session")
         {
             mPJSipManager->registerSessionModule(mEndpointFactory,
-                mSessionRouter, mServiceLocator, mStateReplicator, mReplicaService);
+                mSessionRouter, mServiceLocator, mStateReplicator, mReplicaService, mGlobalAdapter);
         }
         else if (*i == "Logging" || *i == "Logger")
         {

commit 59ccbfc493c091ebfe6d2a71d61026d9abf5a77c
Author: Mark Michelson <mmichelson at digium.com>
Date:   Tue Jun 28 17:58:26 2011 -0500

    Add initial support for calling out to decorators.
    
    Right now, we will call out and retrieve them, but we haven't implemented
    the method of actually adding new hooks yet.

diff --git a/src/SipEndpoint.cpp b/src/SipEndpoint.cpp
index 2a6af1a..06b5d2e 100644
--- a/src/SipEndpoint.cpp
+++ b/src/SipEndpoint.cpp
@@ -189,7 +189,8 @@ AsteriskSCF::SessionCommunications::V1::SessionPrx SipEndpoint::createSession(co
     }
 
     SipSessionPtr session = new SipSession(mImplPriv->mAdapter, this, destination, listener, mImplPriv->mManager,
-        mImplPriv->mServiceLocator, mImplPriv->mReplica, mImplPriv->mConfig.sessionConfig.rtpOverIPv6, true);
+        mImplPriv->mServiceLocator, mImplPriv->mReplica, mImplPriv->mConfig.sessionConfig.rtpOverIPv6, true,
+        mImplPriv->mEndpointFactory->getDecorators());
     mImplPriv->mSessions.push_back(session);
     std::cout << "And now we're returing a session proxy..." << std::endl;
     return session->getSessionProxy();
@@ -198,7 +199,8 @@ AsteriskSCF::SessionCommunications::V1::SessionPrx SipEndpoint::createSession(co
 AsteriskSCF::SipSessionManager::SipSessionPtr SipEndpoint::createSession(const std::string& destination)
 {
     SipSessionPtr session = new SipSession(mImplPriv->mAdapter, this, destination, 0, mImplPriv->mManager,
-        mImplPriv->mServiceLocator, mImplPriv->mReplica, mImplPriv->mConfig.sessionConfig.rtpOverIPv6, false);
+        mImplPriv->mServiceLocator, mImplPriv->mReplica, mImplPriv->mConfig.sessionConfig.rtpOverIPv6, false,
+        mImplPriv->mEndpointFactory->getDecorators());
     mImplPriv->mSessions.push_back(session);
     return session;
 }
@@ -209,7 +211,8 @@ AsteriskSCF::SipSessionManager::SipSessionPtr SipEndpoint::createSession(const s
         const AsteriskSCF::Media::V1::StreamSinkSeq& sinks)
 {
     SipSessionPtr session = new SipSession(mImplPriv->mAdapter, this, destination, sessionid, mediaid, mediasession,
-            sources, sinks, mImplPriv->mManager, mImplPriv->mServiceLocator, mImplPriv->mReplica, false);
+            sources, sinks, mImplPriv->mManager, mImplPriv->mServiceLocator, mImplPriv->mReplica, false,
+            mImplPriv->mEndpointFactory->getDecorators());
     mImplPriv->mSessions.push_back(session);
     return session;
 }
diff --git a/src/SipEndpointFactory.cpp b/src/SipEndpointFactory.cpp
index 61349c9..ff5b6b3 100644
--- a/src/SipEndpointFactory.cpp
+++ b/src/SipEndpointFactory.cpp
@@ -60,6 +60,10 @@ void SipEndpointFactory::generateRoutingDestinations(AsteriskSCF::Core::Routing:
         destinations.push_back((*iter)->getName());
     }
 }
+AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq SipEndpointFactory::getDecorators()
+{
+    return mHooks;
+}
 
 }; // end SipSessionManager
 }; // end AsteriskSCF
diff --git a/src/SipEndpointFactory.h b/src/SipEndpointFactory.h
index d16637f..f29e8dc 100644
--- a/src/SipEndpointFactory.h
+++ b/src/SipEndpointFactory.h
@@ -21,6 +21,7 @@
 #include <boost/enable_shared_from_this.hpp>
 
 #include <AsteriskSCF/Core/Endpoint/EndpointIf.h>
+#include <AsteriskSCF/SessionCommunications/SessionCommunicationsExtensionPointsIf.h>
 
 namespace AsteriskSCF
 {
@@ -47,6 +48,8 @@ public:
     SipEndpointPtr findByName(const std::string& endpointName);
 
     void generateRoutingDestinations(AsteriskSCF::Core::Routing::V1::RegExSeq&);
+
+    AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq getDecorators();
 private:
     /**
      * A pointer to the object adapter that endpoints will be added to.
@@ -72,6 +75,11 @@ private:
      * A pointer to the replica information.
      */
     AsteriskSCF::System::Component::V1::ReplicaPtr mReplica;
+    
+    /**
+     * All the registered session decorator hooks
+     */
+    AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq mHooks;
 };
 
 }; // end SipSessionManager
diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index 972b5b0..35a1285 100644
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -314,13 +314,51 @@ void SipSession::initializePJSIPStructs()
     setInviteSession(inviteSession);
 }
 
+void SipSession::setSessionProxy(const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq& hooks)
+{
+    AsteriskSCF::SessionCommunications::V1::SessionPrx us = 
+        AsteriskSCF::SessionCommunications::V1::SessionPrx::uncheckedCast(mImplPriv->mAdapter->addWithUUID(this));
+
+    bool decoratorSet = false;
+    for (AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq::const_iterator iter = hooks.begin();
+            iter != hooks.end(); ++iter)
+    {
+        AsteriskSCF::SessionCommunications::V1::SessionPrx decorator;
+        AsteriskSCF::System::Hook::V1::HookResult result;
+
+        try
+        {
+            result = (*iter)->decorateSession(us, decorator);
+        }
+        catch (const Ice::Exception& ex)
+        {
+            lg(Warning) << "Exception caught while trying to set a decorator: " << ex.what();
+            //XXX Probably should remove this hook from the list...
+            continue;
+        }
+
+        if (result.status == AsteriskSCF::System::Hook::V1::Succeeded)
+        {
+            mImplPriv->mSessionProxy = decorator;
+            decoratorSet = true;
+            break;
+        }
+    }
+    
+    if (!decoratorSet)
+    {
+        mImplPriv->mSessionProxy = us;
+    }
+}
+
 /**
  * Default constructor.
  */
 SipSession::SipSession(const Ice::ObjectAdapterPtr& adapter, const SipEndpointPtr& endpoint,
         const std::string& destination,  const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx& listener,
         PJSipManager *manager, const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
-        const AsteriskSCF::System::Component::V1::ReplicaPtr& replica, bool ipv6, bool isUAC)
+        const AsteriskSCF::System::Component::V1::ReplicaPtr& replica, bool ipv6, bool isUAC,
+        const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq& hooks)
     : mImplPriv(new SipSessionPriv(adapter, endpoint, destination, manager, serviceLocator, replica))
 {
     if (listener != 0)
@@ -328,8 +366,7 @@ SipSession::SipSession(const Ice::ObjectAdapterPtr& adapter, const SipEndpointPt
         mImplPriv->mListeners.push_back(listener);
     }
 
-    mImplPriv->mSessionProxy =
-        AsteriskSCF::SessionCommunications::V1::SessionPrx::uncheckedCast(adapter->addWithUUID(this));
+    setSessionProxy(hooks);
 
     mImplPriv->mMediaSession = new SipMediaSession(this);
     mImplPriv->mMediaSessionProxy =
@@ -354,11 +391,11 @@ SipSession::SipSession(const Ice::ObjectAdapterPtr& adapter, const SipEndpointPt
         const Ice::Identity& mediaid, const AsteriskSCF::Media::V1::SessionPrx& mediasession,
         const AsteriskSCF::Media::V1::StreamSourceSeq& sources, const AsteriskSCF::Media::V1::StreamSinkSeq& sinks,
         PJSipManager *manager, const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
-        const AsteriskSCF::System::Component::V1::ReplicaPtr& replica, bool isUAC)
+        const AsteriskSCF::System::Component::V1::ReplicaPtr& replica, bool isUAC,
+        const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq& hooks)
     : mImplPriv(new SipSessionPriv(adapter, endpoint, destination, manager, serviceLocator, replica))
 {
-    mImplPriv->mSessionProxy =
-        AsteriskSCF::SessionCommunications::V1::SessionPrx::uncheckedCast(adapter->add(this, sessionid));
+    setSessionProxy(hooks);
 
     mImplPriv->mMediaSession = new SipMediaSession(this);
     mImplPriv->mMediaSessionProxy =
diff --git a/src/SipSession.h b/src/SipSession.h
index f670454..d3d838a 100644
--- a/src/SipSession.h
+++ b/src/SipSession.h
@@ -30,6 +30,7 @@
 
 #include <AsteriskSCF/Core/Endpoint/EndpointIf.h>
 #include <AsteriskSCF/SessionCommunications/SessionCommunicationsIf.h>
+#include <AsteriskSCF/SessionCommunications/SessionCommunicationsExtensionPointsIf.h>
 #include <AsteriskSCF/Media/MediaIf.h>
 #include <AsteriskSCF/Media/RTP/MediaRTPIf.h>
 #include <AsteriskSCF/System/Component/ReplicaIf.h>
@@ -98,14 +99,16 @@ public:
         const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx&, PJSipManager *manager,
         const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
         const AsteriskSCF::System::Component::V1::ReplicaPtr& replica,
-        bool ipv6, bool isUAC);
+        bool ipv6, bool isUAC,
+        const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq& hooks);
 
     SipSession(const Ice::ObjectAdapterPtr&, const SipEndpointPtr&, const std::string&, const Ice::Identity&,
         const Ice::Identity&, const AsteriskSCF::Media::V1::SessionPrx&,
         const AsteriskSCF::Media::V1::StreamSourceSeq&, const AsteriskSCF::Media::V1::StreamSinkSeq&,
         PJSipManager *manager, const AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx& serviceLocator,
         const AsteriskSCF::System::Component::V1::ReplicaPtr& replica,
-        bool isUAC);
+        bool isUAC,
+        const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq& hooks);
 
     bool operator==(const SipSession &other) const;
 
@@ -155,6 +158,8 @@ public:
             const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx&,
             const Ice::Current&);
 
+    void setSessionProxy(const AsteriskSCF::SessionCommunications::ExtensionPoints::V1::SessionDecoratorHookSeq& hooks);
+
     void hold(const Ice::Current&);
     void progress(const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr&, const Ice::Current&);
     void removeListener(const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx&, const Ice::Current&);

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


-- 
asterisk-scf/release/sip.git



More information about the asterisk-scf-commits mailing list