[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
Tue Jun 21 15:02:50 CDT 2011
branch "master" has been updated
via b49bbffd540cb56846df38c934fb05b14fbb61dd (commit)
from 14ca1270f07e4bd0ce0debd064cd5a4c9c8a0372 (commit)
Summary of changes:
.../SipSessionManager/SipStateReplicationIf.ice | 1 +
src/PJSipSessionModule.cpp | 9 +-
src/SipSession.cpp | 149 ++++++++++++++++++++
src/SipSession.h | 6 +
src/SipStateReplicatorListener.cpp | 1 +
5 files changed, 162 insertions(+), 4 deletions(-)
- Log -----------------------------------------------------------------
commit b49bbffd540cb56846df38c934fb05b14fbb61dd
Author: Joshua Colp <jcolp at digium.com>
Date: Tue Jun 21 17:02:05 2011 -0300
Merge session cookies support.
diff --git a/slice/AsteriskSCF/Replication/SipSessionManager/SipStateReplicationIf.ice b/slice/AsteriskSCF/Replication/SipSessionManager/SipStateReplicationIf.ice
index 733deef..5e613db 100644
--- a/slice/AsteriskSCF/Replication/SipSessionManager/SipStateReplicationIf.ice
+++ b/slice/AsteriskSCF/Replication/SipSessionManager/SipStateReplicationIf.ice
@@ -157,6 +157,7 @@ module V1
AsteriskSCF::Media::V1::Session *mMediaSession;
SessionListenerSeq mListeners;
AsteriskSCF::SessionCommunications::V1::Bridge *mBridge;
+ AsteriskSCF::SessionCommunications::V1::SessionCookieDict mCookies;
};
}; /* module V1 */
diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index b2aec9b..3acfb28 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -104,6 +104,7 @@ void PJSipSessionModInfo::updateSessionState(pjsip_inv_session *inv_session)
{
mSessionState->mBridge = 0;
}
+ mSessionState->mCookies = mSession->getAllCookies();
}
//Now we get stuff from the inv_session itself.
@@ -995,7 +996,7 @@ protected:
{
SipAMICallbackPtr cb(new SipAMICallback(0, mSession, this, false, true));
Ice::CallbackPtr d = Ice::newCallback(cb, &SipAMICallback::callback);
- (*listener)->begin_indicated(mSession->getSessionProxy(), new RingingIndication(), d);
+ (*listener)->begin_indicated(mSession->getSessionProxy(), new RingingIndication(), mSession->getCookies(), d);
}
catch (const Ice::Exception &ex)
{
@@ -1019,7 +1020,7 @@ protected:
Ice::CallbackPtr d = Ice::newCallback(cb, &SipAMICallback::callback);
ProgressingIndicationPtr progressing(new ProgressingIndication());
progressing->response = response;
- (*listener)->begin_indicated(mSession->getSessionProxy(), progressing, d);
+ (*listener)->begin_indicated(mSession->getSessionProxy(), progressing, mSession->getCookies(), d);
}
catch (const Ice::Exception &ex)
{
@@ -1041,7 +1042,7 @@ protected:
{
SipAMICallbackPtr cb(new SipAMICallback(0, mSession, this, false, true));
Ice::CallbackPtr d = Ice::newCallback(cb, &SipAMICallback::callback);
- (*listener)->begin_indicated(mSession->getSessionProxy(), new ConnectedIndication(), d);
+ (*listener)->begin_indicated(mSession->getSessionProxy(), new ConnectedIndication(), mSession->getCookies(), d);
}
catch (const Ice::Exception &ex)
{
@@ -1202,7 +1203,7 @@ protected:
{
try
{
- (*listener)->indicated(session->getSessionProxy(), stopped);
+ (*listener)->indicated(session->getSessionProxy(), stopped, session->getCookies());
}
catch (const Ice::Exception &ex)
{
diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index 979358a..a4d23b1 100644
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -239,6 +239,11 @@ public:
AsteriskSCF::SessionCommunications::V1::BridgePrx mBridge;
/**
+ * Cookies present on the session.
+ */
+ AsteriskSCF::SessionCommunications::V1::SessionCookieDict mSessionCookies;
+
+ /**
* The PJSIP manager
*/
PJSipManager *mManager;
@@ -839,6 +844,150 @@ void SipSession::stop(const AsteriskSCF::SessionCommunications::V1::ResponseCode
enqueueSessionWork(new StopOperation(response, mImplPriv->mInviteSession));
}
+class SetCookiesOperation : public SuspendableWork
+{
+public:
+ SetCookiesOperation(const AsteriskSCF::SessionCommunications::V1::SessionCookies& cookies,
+ const boost::shared_ptr<SipSessionPriv>& sessionPriv)
+ : mCookies(cookies), mImplPriv(sessionPriv) { }
+
+ SuspendableWorkResult execute(const SuspendableWorkListenerPtr&)
+ {
+ for (AsteriskSCF::SessionCommunications::V1::SessionCookies::const_iterator i = mCookies.begin();
+ i != mCookies.end();
+ ++i)
+ {
+ mImplPriv->mSessionCookies.erase((*i)->ice_id());
+ mImplPriv->mSessionCookies.insert(make_pair((*i)->ice_id(), (*i)));
+ }
+
+ if (mImplPriv->mInviteSession)
+ {
+ PJSipSessionModInfo *session_mod_info = static_cast<PJSipSessionModInfo*>(mImplPriv->mInviteSession->mod_data[mImplPriv->mManager->getSessionModule()->getModule().id]);
+ session_mod_info->updateSessionState(mImplPriv->mInviteSession);
+ mImplPriv->mManager->getSessionModule()->replicateState(NULL, NULL, session_mod_info);
+ }
+
+ return Complete;
+ }
+
+private:
+ AsteriskSCF::SessionCommunications::V1::SessionCookies mCookies;
+ boost::shared_ptr<SipSessionPriv> mImplPriv;
+};
+
+/**
+ * An implementation of the setCookies method as defined in SessionCommunications.ice which sets cookies
+ * on the session.
+ */
+void SipSession::setCookies(const AsteriskSCF::SessionCommunications::V1::SessionCookies& cookies, const Ice::Current&)
+{
+ lg(Debug) << "queuing a setCookies operation";
+ enqueueSessionWork(new SetCookiesOperation(cookies, mImplPriv));
+}
+
+/**
+ * Internal function to set the cookies (used in replication).
+ */
+void SipSession::setCookies(const AsteriskSCF::SessionCommunications::V1::SessionCookieDict& cookies)
+{
+ mImplPriv->mSessionCookies = cookies;
+}
+
+class RemoveCookiesOperation : public SuspendableWork
+{
+public:
+ RemoveCookiesOperation(const AsteriskSCF::SessionCommunications::V1::SessionCookies& cookieTypes,
+ const boost::shared_ptr<SipSessionPriv>& sessionPriv)
+ : mCookieTypes(cookieTypes), mImplPriv(sessionPriv) { }
+
+ SuspendableWorkResult execute(const SuspendableWorkListenerPtr&)
+ {
+ for (AsteriskSCF::SessionCommunications::V1::SessionCookies::const_iterator i = mCookieTypes.begin();
+ i != mCookieTypes.end();
+ ++i)
+ {
+ mImplPriv->mSessionCookies.erase((*i)->ice_id());
+ }
+
+ if (mImplPriv->mInviteSession)
+ {
+ PJSipSessionModInfo *session_mod_info = static_cast<PJSipSessionModInfo*>(mImplPriv->mInviteSession->mod_data[mImplPriv->mManager->getSessionModule()->getModule().id]);
+ session_mod_info->updateSessionState(mImplPriv->mInviteSession);
+ mImplPriv->mManager->getSessionModule()->replicateState(NULL, NULL, session_mod_info);
+ }
+
+ return Complete;
+ }
+
+private:
+ AsteriskSCF::SessionCommunications::V1::SessionCookies mCookieTypes;
+ boost::shared_ptr<SipSessionPriv> mImplPriv;
+};
+
+/**
+ * An implementation of the removeCookies method as defined in SessionCommunications.ice which removes specific
+ * cookies from the session.
+ */
+void SipSession::removeCookies(const AsteriskSCF::SessionCommunications::V1::SessionCookies& cookieTypes, const Ice::Current&)
+{
+ lg(Debug) << "queuing a removeCookies operation";
+ enqueueSessionWork(new RemoveCookiesOperation(cookieTypes, mImplPriv));
+}
+
+/**
+ * An implementation of the getCookies method as defined in SessionCommunications.ice which gets specific cookies
+ * from the session.
+ */
+AsteriskSCF::SessionCommunications::V1::SessionCookies SipSession::getCookies(const AsteriskSCF::SessionCommunications::V1::SessionCookies& cookieTypes, const Ice::Current&)
+{
+ AsteriskSCF::SessionCommunications::V1::SessionCookies cookies;
+
+ for (AsteriskSCF::SessionCommunications::V1::SessionCookies::const_iterator i = cookieTypes.begin();
+ i != cookieTypes.end();
+ ++i)
+ {
+ AsteriskSCF::SessionCommunications::V1::SessionCookieDict::const_iterator cookie = mImplPriv->mSessionCookies.find((*i)->ice_id());
+
+ if (cookie == mImplPriv->mSessionCookies.end())
+ {
+ continue;
+ }
+
+ cookies.push_back(cookie->second);
+ }
+
+ return cookies;
+}
+
+/**
+ * Internal function which returns all cookies on the session.
+ */
+AsteriskSCF::SessionCommunications::V1::SessionCookies SipSession::getCookies()
+{
+ AsteriskSCF::SessionCommunications::V1::SessionCookies cookies;
+
+ for (AsteriskSCF::SessionCommunications::V1::SessionCookieDict::const_iterator i = mImplPriv->mSessionCookies.begin();
+ i != mImplPriv->mSessionCookies.end();
+ ++i)
+ {
+ cookies.push_back(i->second);
+ }
+
+ return cookies;
+}
+
+/**
+ * Internal function which returns all cookies on the session.
+ */
+AsteriskSCF::SessionCommunications::V1::SessionCookieDict SipSession::getAllCookies()
+{
+ return mImplPriv->mSessionCookies;
+}
+
+/**
+ * Internal function called to destroy an endpoint. This is controlled by signaling.
+ */
class DestroyOperation : public SuspendableWork
{
public:
diff --git a/src/SipSession.h b/src/SipSession.h
index f603fb5..6887630 100644
--- a/src/SipSession.h
+++ b/src/SipSession.h
@@ -161,6 +161,12 @@ public:
void start(const Ice::Current&);
void stop(const AsteriskSCF::SessionCommunications::V1::ResponseCodePtr&, const Ice::Current&);
void unhold(const Ice::Current&);
+ void setCookies(const AsteriskSCF::SessionCommunications::V1::SessionCookies&, const Ice::Current&);
+ void setCookies(const AsteriskSCF::SessionCommunications::V1::SessionCookieDict&);
+ void removeCookies(const AsteriskSCF::SessionCommunications::V1::SessionCookies&, const Ice::Current&);
+ AsteriskSCF::SessionCommunications::V1::SessionCookies getCookies(const AsteriskSCF::SessionCommunications::V1::SessionCookies&, const Ice::Current&);
+ AsteriskSCF::SessionCommunications::V1::SessionCookies getCookies();
+ AsteriskSCF::SessionCommunications::V1::SessionCookieDict getAllCookies();
/**
* Implementation specific functions.
diff --git a/src/SipStateReplicatorListener.cpp b/src/SipStateReplicatorListener.cpp
index b04abc3..6949339 100644
--- a/src/SipStateReplicatorListener.cpp
+++ b/src/SipStateReplicatorListener.cpp
@@ -112,6 +112,7 @@ public:
localitem->getSession()->setListeners(session->mListeners);
localitem->getSession()->setBridge(session->mBridge);
+ localitem->getSession()->setCookies(session->mCookies);
}
else if ((dialog = SipDialogStateItemPtr::dynamicCast((*item))))
{
-----------------------------------------------------------------------
--
asterisk-scf/release/sip.git
More information about the asterisk-scf-commits
mailing list