[asterisk-scf-commits] asterisk-scf/integration/sip.git branch "bridgetelephony" created.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Wed Sep 7 17:15:49 CDT 2011
branch "bridgetelephony" has been created
at 31ea93ee5fa0bb32e1fd83eaa7cf8547b1026784 (commit)
- Log -----------------------------------------------------------------
commit 31ea93ee5fa0bb32e1fd83eaa7cf8547b1026784
Author: Ken Hunt <ken.hunt at digium.com>
Date: Wed Sep 7 17:07:07 2011 -0500
Updates for changes to telephony events API. Added a removeSinks() operation. Changed addSink() to addSinks() to cut down on RPC calls.
diff --git a/src/SipTelephonyEventSource.cpp b/src/SipTelephonyEventSource.cpp
index b424dfa..b3a7626 100644
--- a/src/SipTelephonyEventSource.cpp
+++ b/src/SipTelephonyEventSource.cpp
@@ -15,6 +15,7 @@
*/
#include "SipTelephonyEventSource.h"
+#include <AsteriskSCF/Helpers/ProxyHelper.h>
#include <AsteriskSCF/System/WorkQueue/WorkQueueIf.h>
namespace AsteriskSCF
@@ -24,10 +25,11 @@ namespace SipSessionManager
{
using namespace AsteriskSCF::System::WorkQueue::V1;
+using namespace AsteriskSCF::SessionCommunications::V1;
-void SipTelephonyEventSource::distributeToSinks(const AsteriskSCF::SessionCommunications::V1::TelephonyEventPtr& event)
+void SipTelephonyEventSource::distributeToSinks(const TelephonyEventPtr& event)
{
- for (AsteriskSCF::SessionCommunications::V1::TelephonyEventSinkSeq::const_iterator iter = mSinks.begin();
+ for (TelephonyEventSinkSeq::const_iterator iter = mSinks.begin();
iter != mSinks.end(); ++iter)
{
(*iter)->write(event);
@@ -37,40 +39,80 @@ void SipTelephonyEventSource::distributeToSinks(const AsteriskSCF::SessionCommun
SipTelephonyEventSource::SipTelephonyEventSource(const SessionWorkPtr& sessionWork)
: mSessionWork(sessionWork) { }
-class AddSink : public SuspendableWork
+class AddSinks : public SuspendableWork
{
public:
- AddSink(
- const AsteriskSCF::SessionCommunications::V1::AMD_TelephonyEventSource_addSinkPtr& cb,
+ AddSinks(
+ const AMD_TelephonyEventSource_addSinksPtr& cb,
const SipTelephonyEventSourcePtr& source,
- const AsteriskSCF::SessionCommunications::V1::TelephonyEventSinkPrx& sink)
- : mCB(cb), mSource(source), mSink(sink) { }
+ const TelephonyEventSinkSeq& sinks)
+ : mCB(cb), mSource(source), mSinks(sinks) { }
SuspendableWorkResult execute(const SuspendableWorkListenerPtr&)
{
- mSource->addSink(mSink);
+ mSource->addSinks(mSinks);
mCB->ice_response();
return Complete;
}
private:
- AsteriskSCF::SessionCommunications::V1::AMD_TelephonyEventSource_addSinkPtr mCB;
+ AMD_TelephonyEventSource_addSinksPtr mCB;
SipTelephonyEventSourcePtr mSource;
- AsteriskSCF::SessionCommunications::V1::TelephonyEventSinkPrx mSink;
+ TelephonyEventSinkSeq mSinks;
};
-void SipTelephonyEventSource::addSink_async(
- const AsteriskSCF::SessionCommunications::V1::AMD_TelephonyEventSource_addSinkPtr& cb,
- const AsteriskSCF::SessionCommunications::V1::TelephonyEventSinkPrx& sink,
+class RemoveSinks : public SuspendableWork
+{
+public:
+ RemoveSinks(
+ const AMD_TelephonyEventSource_removeSinksPtr& cb,
+ const SipTelephonyEventSourcePtr& source,
+ const TelephonyEventSinkSeq& sinks)
+ : mCB(cb), mSource(source), mSinks(sinks) { }
+
+ SuspendableWorkResult execute(const SuspendableWorkListenerPtr&)
+ {
+ mSource->removeSinks(mSinks);
+ mCB->ice_response();
+ return Complete;
+ }
+private:
+ AMD_TelephonyEventSource_removeSinksPtr mCB;
+ SipTelephonyEventSourcePtr mSource;
+ TelephonyEventSinkSeq mSinks;
+};
+
+void SipTelephonyEventSource::addSinks_async(
+ const AMD_TelephonyEventSource_addSinksPtr& cb,
+ const TelephonyEventSinkSeq& sinks,
+ const Ice::Current&)
+{
+ mSessionWork->enqueueWork(new AddSinks(cb, this, sinks));
+}
+
+void SipTelephonyEventSource::removeSinks_async(
+ const AMD_TelephonyEventSource_removeSinksPtr& cb,
+ const TelephonyEventSinkSeq& sinks,
const Ice::Current&)
{
- mSessionWork->enqueueWork(new AddSink(cb, this, sink));
+ mSessionWork->enqueueWork(new RemoveSinks(cb, this, sinks));
+}
+
+void SipTelephonyEventSource::addSinks(const TelephonyEventSinkSeq& sinks)
+{
+ for (TelephonyEventSinkSeq::const_iterator i = sinks.begin(); i != sinks.end(); ++i)
+ {
+ if (std::find_if(mSinks.begin(), mSinks.end(), IdentityComparePredicate<TelephonyEventSinkPrx>(*i)) == mSinks.end())
+ {
+ mSinks.push_back(*i);
+ }
+ }
}
-void SipTelephonyEventSource::addSink(const AsteriskSCF::SessionCommunications::V1::TelephonyEventSinkPrx& sink)
+void SipTelephonyEventSource::removeSinks(const TelephonyEventSinkSeq& sinks)
{
- if (std::find(mSinks.begin(), mSinks.end(), sink) == mSinks.end())
+ for (TelephonyEventSinkSeq::const_iterator i = sinks.begin(); i != sinks.end(); ++i)
{
- mSinks.push_back(sink);
+ mSinks.erase(remove_if(mSinks.begin(), mSinks.end(), IdentityComparePredicate<TelephonyEventSinkPrx>(*i)), mSinks.end());
}
}
@@ -78,7 +120,7 @@ class GetSinks : public SuspendableWork
{
public:
GetSinks(
- const AsteriskSCF::SessionCommunications::V1::AMD_TelephonyEventSource_getSinksPtr& cb,
+ const AMD_TelephonyEventSource_getSinksPtr& cb,
const SipTelephonyEventSourcePtr& source)
: mCB(cb), mSource(source) { }
@@ -88,18 +130,18 @@ public:
return Complete;
}
private:
- AsteriskSCF::SessionCommunications::V1::AMD_TelephonyEventSource_getSinksPtr mCB;
+ AMD_TelephonyEventSource_getSinksPtr mCB;
SipTelephonyEventSourcePtr mSource;
};
void SipTelephonyEventSource::getSinks_async(
- const AsteriskSCF::SessionCommunications::V1::AMD_TelephonyEventSource_getSinksPtr& cb,
+ const AMD_TelephonyEventSource_getSinksPtr& cb,
const Ice::Current&)
{
mSessionWork->enqueueWork(new GetSinks(cb, this));
}
-AsteriskSCF::SessionCommunications::V1::TelephonyEventSinkSeq SipTelephonyEventSource::getSinks()
+TelephonyEventSinkSeq SipTelephonyEventSource::getSinks()
{
return mSinks;
}
diff --git a/src/SipTelephonyEventSource.h b/src/SipTelephonyEventSource.h
index 730b4bd..11a65ef 100644
--- a/src/SipTelephonyEventSource.h
+++ b/src/SipTelephonyEventSource.h
@@ -29,24 +29,28 @@ public:
SipTelephonyEventSource(const SessionWorkPtr&);
- void addSink_async(
- const AsteriskSCF::SessionCommunications::V1::AMD_TelephonyEventSource_addSinkPtr&,
- const AsteriskSCF::SessionCommunications::V1::TelephonyEventSinkPrx& sink,
+ // TelephonyEventSource API implementation...
+
+ void addSinks_async(
+ const AsteriskSCF::SessionCommunications::V1::AMD_TelephonyEventSource_addSinksPtr&,
+ const AsteriskSCF::SessionCommunications::V1::TelephonyEventSinkSeq& sinks,
const Ice::Current&);
- /**
- * Only to be called from within a queued operation
- */
- void addSink(const AsteriskSCF::SessionCommunications::V1::TelephonyEventSinkPrx& sink);
+ void removeSinks_async(
+ const AsteriskSCF::SessionCommunications::V1::AMD_TelephonyEventSource_removeSinksPtr&,
+ const AsteriskSCF::SessionCommunications::V1::TelephonyEventSinkSeq& sinks,
+ const Ice::Current&);
void getSinks_async(
const AsteriskSCF::SessionCommunications::V1::AMD_TelephonyEventSource_getSinksPtr&,
const Ice::Current&);
- /**
- * Only to be called from within a queued operation
- */
+ // Only to be called from within a queued operation...
+
AsteriskSCF::SessionCommunications::V1::TelephonyEventSinkSeq getSinks();
+ void addSinks(const AsteriskSCF::SessionCommunications::V1::TelephonyEventSinkSeq& sinks);
+ void removeSinks(const AsteriskSCF::SessionCommunications::V1::TelephonyEventSinkSeq& sinks);
+
/**
* Write an event to all the configured sinks.
*
commit 6635bf7183e7868f54c35dbcf1bf5f2d05777b84
Author: Joshua Colp <jcolp at digium.com>
Date: Tue Aug 30 14:48:43 2011 -0300
Use pjsip to create a challenge for authentication.
diff --git a/src/AuthManager.cpp b/src/AuthManager.cpp
index f91994e..0bd0d15 100644
--- a/src/AuthManager.cpp
+++ b/src/AuthManager.cpp
@@ -143,13 +143,6 @@ std::vector<AuthHookPrx> AuthInstance::getHooks()
return mImpl->hooks;
}
-static pj_status_t lookup_cred(pj_pool_t *, const pj_str_t *,
- const pj_str_t *, pjsip_cred_info *)
-{
- // Return non-success for now just so it doesn't seem like authentication is actually succeeding.
- return !PJ_SUCCESS;
-}
-
bool AuthInstance::authenticate(pjsip_rx_data *rdata)
{
//For each server auth, we need to call pjsip_auth_srv_verify(), which will then
@@ -195,7 +188,13 @@ void AuthInstance::addDigests(pjsip_tx_data *tdata, const DigestChallengeSeq &di
pjsip_auth_srv *authServer = PJ_POOL_ZALLOC_T(mImpl->mPool, pjsip_auth_srv);
pj_str_t realm;
pj_cstr(&realm, (*digest)->realm.c_str());
- pjsip_auth_srv_init(mImpl->mPool, authServer, &realm, lookup_cred, 0);
+ pjsip_auth_srv_init(mImpl->mPool, authServer, &realm, NULL, 0);
+
+ pj_strdup2(mImpl->mPool, &authServer->cred_info.username, (*digest)->username.c_str());
+ authServer->cred_info.data_type = PJSIP_CRED_DATA_PLAIN_PASSWD;
+ pj_strdup2(mImpl->mPool, &authServer->cred_info.data, (*digest)->password.c_str());
+ pj_strdup2(mImpl->mPool, &authServer->cred_info.realm, (*digest)->realm.c_str());
+
pj_str_t nonce, opaque, *noncePtr = NULL, *opaquePtr = NULL;
if (!(*digest)->opaque.empty())
{
@@ -396,6 +395,20 @@ void AuthManager::destroyAuthInstance(const boost::shared_ptr<AuthInstance> &ins
}
}
+void AuthManager::destroyAuthInstance(const AuthInstance* instance)
+{
+ boost::lock_guard<boost::mutex> lock(mImpl->mAuthInstancesLock);
+ for (std::vector<boost::shared_ptr<AuthInstance> >::iterator iter = mImpl->mAuthInstances.begin();
+ iter != mImpl->mAuthInstances.end(); ++ iter)
+ {
+ if ((*iter).get() == instance)
+ {
+ mImpl->mAuthInstances.erase(iter);
+ break;
+ }
+ }
+}
+
void AuthManager::scheduleAuthTimeout(const boost::shared_ptr<AuthInstance> &instance)
{
instance->scheduleAuthTimeout(mImpl->mCounter++);
@@ -403,8 +416,7 @@ void AuthManager::scheduleAuthTimeout(const boost::shared_ptr<AuthInstance> &ins
void AuthManager::authTimeout(pj_timer_heap_t *, pj_timer_entry *entry)
{
- boost::shared_ptr<AuthInstance> killMe(static_cast<AuthInstance *>(entry->user_data));
- destroyAuthInstance(killMe);
+ destroyAuthInstance(static_cast<AuthInstance *>(entry->user_data));
}
void AuthManager::addAuthHook(const AsteriskSCF::SIP::ExtensionPoint::V1::AuthHookPrx &hook,
diff --git a/src/AuthManager.h b/src/AuthManager.h
index 07930ab..f113ea0 100644
--- a/src/AuthManager.h
+++ b/src/AuthManager.h
@@ -158,6 +158,10 @@ public:
*/
void destroyAuthInstance(const boost::shared_ptr<AuthInstance> &instance);
/**
+ * Destroy an AuthInstance
+ */
+ void destroyAuthInstance(const AuthInstance* instance);
+ /**
* This is the callback that scheduleAuthDestruction sets up.
*
* Do not call this method directly.
diff --git a/src/PJSipModule.cpp b/src/PJSipModule.cpp
index 12497e4..5a85362 100644
--- a/src/PJSipModule.cpp
+++ b/src/PJSipModule.cpp
@@ -160,17 +160,26 @@ TransactionState PJSipTransactionModInfo::transactionStateTranslate(pjsip_tsx_st
void PJSipModule::addAuthHook(const AsteriskSCF::SIP::ExtensionPoint::V1::AuthHookPrx &hook, int priority, const AsteriskSCF::SIP::ExtensionPoint::V1::RequestTypeSeq &types)
{
- mAuthManager->addAuthHook(hook, priority, types);
+ if (mAuthManager.get())
+ {
+ mAuthManager->addAuthHook(hook, priority, types);
+ }
}
void PJSipModule::removeAuthHook(const AsteriskSCF::SIP::ExtensionPoint::V1::AuthHookPrx &hook)
{
- mAuthManager->removeAuthHook(hook);
+ if (mAuthManager.get())
+ {
+ mAuthManager->removeAuthHook(hook);
+ }
}
void PJSipModule::clearAuthHooks()
{
- mAuthManager->clearAuthHooks();
+ if (mAuthManager.get())
+ {
+ mAuthManager->clearAuthHooks();
+ }
}
};
-----------------------------------------------------------------------
--
asterisk-scf/integration/sip.git
More information about the asterisk-scf-commits
mailing list