[asterisk-scf-commits] asterisk-scf/integration/sip.git branch "transfer" created.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Mon Oct 11 17:55:34 CDT 2010


branch "transfer" has been created
        at  c183f79c5692593ca6c29bd733f0e91a58ed6eac (commit)

- Log -----------------------------------------------------------------
commit c183f79c5692593ca6c29bd733f0e91a58ed6eac
Author: Joshua Colp <jcolp at digium.com>
Date:   Mon Oct 11 19:56:13 2010 -0300

    Utilize the routing service for handling blind transfer requests.

diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index 08a7569..762a290 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -393,7 +393,7 @@ void PJSipSessionModule::handleNewInvite(pjsip_rx_data *rdata)
    }
 }
 
-void PJSipSessionModule::handleRefer(pjsip_dialog *dlg, pjsip_rx_data *rdata)
+void PJSipSessionModule::handleRefer(pjsip_inv_session *inv, pjsip_rx_data *rdata)
 {
    const pj_str_t str_refer_to = { (char*)"Refer-To", 8 };
    pjsip_generic_string_hdr *refer_to = static_cast<pjsip_generic_string_hdr *>(pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &str_refer_to, NULL));
@@ -401,7 +401,7 @@ void PJSipSessionModule::handleRefer(pjsip_dialog *dlg, pjsip_rx_data *rdata)
    if (!refer_to)
    {
       // Uh... so they didn't tell us where to REFER this to... yeah no
-      pjsip_dlg_respond(dlg, rdata, 400, NULL, NULL, NULL);
+      pjsip_dlg_respond(inv->dlg, rdata, 400, NULL, NULL, NULL);
       return;
    }
 
@@ -410,13 +410,13 @@ void PJSipSessionModule::handleRefer(pjsip_dialog *dlg, pjsip_rx_data *rdata)
    // TODO: Provide method to send back suitable response
 
    // Now parse the URI to get the actual target they want to refer to
-   pjsip_uri *target_uri = static_cast<pjsip_uri *>(pjsip_parse_uri(dlg->pool, refer_to->hvalue.ptr, refer_to->hvalue.slen, 0));
+   pjsip_uri *target_uri = static_cast<pjsip_uri *>(pjsip_parse_uri(inv->dlg->pool, refer_to->hvalue.ptr, refer_to->hvalue.slen, 0));
 
    // We only support SIP URIs, anything else is rubbish to us
    if (!PJSIP_URI_SCHEME_IS_SIP(target_uri) && !PJSIP_URI_SCHEME_IS_SIPS(target_uri))
    {
       // TODO: Place proper response code in here
-      pjsip_dlg_respond(dlg, rdata, 400, NULL, NULL, NULL);
+      pjsip_dlg_respond(inv->dlg, rdata, 400, NULL, NULL, NULL);
       return;
    }
 
@@ -424,10 +424,22 @@ void PJSipSessionModule::handleRefer(pjsip_dialog *dlg, pjsip_rx_data *rdata)
    std::string target = std::string(pj_strbuf(&target_sip_uri->user), pj_strlen(&target_sip_uri->user));
 
    // Now that we have the target user we can pass this into routing and go on our marry way
-   lg(Debug) << "Doing a blind transfer to: " << target;
-
-   // TODO: Actually... you know... do it
-   pjsip_dlg_respond(dlg, rdata, 400, NULL, NULL, NULL);
+   try
+   {
+      PJSipSessionModInfo *session_mod_info = (PJSipSessionModInfo*)inv->mod_data[mModule.id];
+      SipSessionPtr session = session_mod_info->getSessionPtr();
+      mSessionRouter->replaceSessionWithDestination(session->getSessionProxy(), target);
+   }
+   catch (AsteriskSCF::Core::Routing::V1::DestinationNotFoundException&)
+   {
+      pjsip_dlg_respond(inv->dlg, rdata, 404, NULL, NULL, NULL);
+      return;
+   }
+   catch (...)
+   {
+      pjsip_dlg_respond(inv->dlg, rdata, 400, NULL, NULL, NULL);
+      return;
+   }
 }
 
 pj_bool_t PJSipSessionModule::on_rx_request(pjsip_rx_data *rdata)
@@ -630,7 +642,7 @@ void PJSipSessionModule::invOnTsxStateChanged(pjsip_inv_session *inv, pjsip_tran
 {
    if (tsx->role == PJSIP_ROLE_UAS && tsx->state == PJSIP_TSX_STATE_TRYING && !pjsip_method_cmp(&tsx->method, pjsip_get_refer_method()))
    {
-      handleRefer(inv->dlg, e->body.tsx_state.src.rdata);
+      handleRefer(inv, e->body.tsx_state.src.rdata);
    }
    //This will be our key point for updating transaction state.
    //This function will not be called until after a module has registered
diff --git a/src/PJSipSessionModule.h b/src/PJSipSessionModule.h
index 0c4a97a..0612d13 100644
--- a/src/PJSipSessionModule.h
+++ b/src/PJSipSessionModule.h
@@ -71,7 +71,7 @@ private:
 		PJSipSessionModInfo *sessionInfo);
 	void handleNewInvite(pjsip_rx_data *rdata);
 	void handleInviteResponse(pjsip_inv_session *inv, pjsip_rx_data *rdata, pjsip_dialog *dlg);
-	void handleRefer(pjsip_dialog *dlg, pjsip_rx_data *rdata);
+	void handleRefer(pjsip_inv_session *inv, pjsip_rx_data *rdata);
 	pjsip_inv_callback mInvCallback;
 	pjsip_ua_init_param mUaParam;
 	const std::string mName;

commit abf3baccf1d882471b293656aa4393e6f98aab45
Author: Joshua Colp <jcolp at digium.com>
Date:   Mon Oct 11 19:47:59 2010 -0300

    Implement some additional bridge related methods on the SipSession implementation.

diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index 7e1ef67..71a2514 100644
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -136,8 +136,13 @@ SipSessionPriv(Ice::ObjectAdapterPtr adapter, SipEndpointPtr endpoint,
    std::vector<AsteriskSCF::SessionCommunications::V1::SessionListenerPrx> mListeners;
 
    /**
-	* The PJSIP manager
-	*/
+    * A proxy to the bridge that this session is currently in.
+    */
+   AsteriskSCF::SessionCommunications::V1::BridgePrx mBridge;
+
+   /**
+    * The PJSIP manager
+    */
    PJSipManager *mManager;
 
    AsteriskSCF::Core::Discovery::V1::ServiceLocatorPrx mServiceLocator;
@@ -278,6 +283,43 @@ AsteriskSCF::Media::V1::SessionPrx SipSession::getMediaSession(const Ice::Curren
 }
 
 /**
+ * An implementation of the getBridge method as defined in SessionCommunications.ice
+ */
+AsteriskSCF::SessionCommunications::V1::BridgePrx SipSession::getBridge(const Ice::Current&)
+{
+   if (mImplPriv->mBridge == 0)
+   {
+      throw new AsteriskSCF::SessionCommunications::V1::NotBridged();
+   }
+
+   return mImplPriv->mBridge;
+}
+
+/**
+ * An implementation of the setBridge method as defined in SessionCommunications.ice
+ */
+void SipSession::setBridge(const AsteriskSCF::SessionCommunications::V1::BridgePrx& bridge, const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx& listener, const Ice::Current& current)
+{
+   mImplPriv->mBridge = bridge;
+   addListener(listener, current);
+}
+
+/**
+ * An implementation of the removeBridge method as defined in SessionCommunications.ice
+ */
+void SipSession::removeBridge(const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx& listener, const Ice::Current& current)
+{
+   if (mImplPriv->mBridge == 0)
+   {
+      throw new AsteriskSCF::SessionCommunications::V1::NotBridged();
+   }
+
+   mImplPriv->mBridge = 0;
+
+   removeListener(listener, current);
+}
+
+/**
  * An implementation of the hold method as defined in SessionCommunications.ice which sends
  * a reinvite with sendonly attribute and no connection info to the SIP endpoint.
  */
diff --git a/src/SipSession.h b/src/SipSession.h
index 2ef6f54..d0af06e 100644
--- a/src/SipSession.h
+++ b/src/SipSession.h
@@ -73,6 +73,9 @@ public:
    AsteriskSCF::SessionCommunications::V1::SessionEndpointPrx getEndpoint(const Ice::Current&);
    AsteriskSCF::SessionCommunications::V1::SessionInfoPtr getInfo(const Ice::Current&);
    AsteriskSCF::Media::V1::SessionPrx getMediaSession(const Ice::Current&);
+   AsteriskSCF::SessionCommunications::V1::BridgePrx getBridge(const Ice::Current&);
+   void setBridge(const AsteriskSCF::SessionCommunications::V1::BridgePrx&, const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx&, const Ice::Current&);
+   void removeBridge(const AsteriskSCF::SessionCommunications::V1::SessionListenerPrx&, const Ice::Current&);
    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/integration/sip.git



More information about the asterisk-scf-commits mailing list