[asterisk-scf-commits] asterisk-scf/integration/sip.git branch "party-id" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Thu Oct 13 18:50:27 CDT 2011


branch "party-id" has been updated
       via  d03e55a9a03a9fd63ac7a236859552ab215af8a7 (commit)
       via  a4414ee3a8b0ee71bbf703e7c31f66995ad45005 (commit)
      from  79b290400e05f79f049b5b5cc087092f34813662 (commit)

Summary of changes:
 src/PJSipSessionModule.cpp |   50 +++++++++++++++++++++++++++++++++++--------
 src/PJSipSessionModule.h   |    6 ++++-
 src/SipConfiguration.cpp   |    5 ++-
 3 files changed, 48 insertions(+), 13 deletions(-)


- Log -----------------------------------------------------------------
commit d03e55a9a03a9fd63ac7a236859552ab215af8a7
Author: Mark Michelson <mmichelson at digium.com>
Date:   Thu Oct 13 18:50:15 2011 -0500

    Add privacy and reason parsing.

diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index 65c2388..ff0ed75 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -545,7 +545,31 @@ private:
     RedirectionsPtr mRedirections;
 };
 
-void PJSipSessionModule::getIds(const char *headerName, pjsip_rx_data *rdata, IdSeq& ids)
+bool PJSipSessionModule::getPrivacy(pjsip_rx_data *rdata)
+{
+    pj_str_t privacyHdrName;
+    pj_cstr(&privacyHdrName, "Privacy");
+
+    pjsip_generic_string_hdr *privacyHdr = (pjsip_generic_string_hdr *) pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &privacyHdrName, rdata->msg_info.msg->hdr.next);
+
+    if (!privacyHdr)
+    {
+        return false;
+    }
+
+    std::string privacyVal(pj_strbuf(&privacyHdr->hvalue), pj_strlen(&privacyHdr->hvalue));
+    if (privacyVal == "id")
+    {
+        return true;
+    }
+
+    return false;
+}
+
+void PJSipSessionModule::getIds(const char *headerName,
+        pjsip_rx_data *rdata,
+        bool privacySet,
+        IdSeq& ids)
 {
     pj_str_t hdrName;
     pj_cstr(&hdrName, headerName);
@@ -585,7 +609,7 @@ void PJSipSessionModule::getIds(const char *headerName, pjsip_rx_data *rdata, Id
         pjsip_sip_uri *idURI = (pjsip_sip_uri *) pjsip_uri_get_uri(idNameAddr);
         NumberPtr number (new Number(std::string(pj_strbuf(&idURI->user), pj_strlen(&idURI->user))));
 
-        IdPtr id(new Id(name, number));
+        IdPtr id(new Id(name, number, new Privacy(privacySet)));
         ids.push_back(id);
     }
 }
@@ -593,7 +617,8 @@ void PJSipSessionModule::getIds(const char *headerName, pjsip_rx_data *rdata, Id
 CallerPtr PJSipSessionModule::getCallerID(pjsip_rx_data *rdata)
 {
     CallerPtr caller(new Caller);
-    getIds("P-Asserted-Identity", rdata, caller->ids); 
+    bool privacySet = getPrivacy(rdata);
+    getIds("P-Asserted-Identity", rdata, privacySet, caller->ids); 
     if (!caller->ids.empty())
     {
         return caller;
@@ -601,7 +626,7 @@ CallerPtr PJSipSessionModule::getCallerID(pjsip_rx_data *rdata)
 
     //There were no P-Asserted-Identity headers present. On an incoming call, we'll get caller ID from the
     //From header instead.
-    getIds("From", rdata, caller->ids);
+    getIds("From", rdata, privacySet, caller->ids);
     return caller;
 }
 
@@ -609,11 +634,13 @@ RedirectionsPtr PJSipSessionModule::getRedirections(pjsip_rx_data *rdata, pjsip_
 {
     RedirectionsPtr redirections(new Redirections);
     IdSeq ids;
-    getIds("Diversion", rdata, ids);
+    bool privacySet = getPrivacy(rdata);
+    getIds("Diversion", rdata, privacySet, ids);
     
     NamePtr rURIName(new Name(std::string(pj_strbuf(&ruri->user), pj_strlen(&ruri->user))));
     NumberPtr rURINumber(new Number(std::string(pj_strbuf(&ruri->user), pj_strlen(&ruri->user))));
-    IdPtr rURIId(new Id(rURIName, rURINumber));
+    PrivacyPtr rURIPrivacy(new Privacy(false));
+    IdPtr rURIId(new Id(rURIName, rURINumber, rURIPrivacy));
     for (IdSeq::iterator id = ids.begin(); id != ids.end(); ++id)
     {
         //Each ID we've read indicates a redirection *from* something,
@@ -633,7 +660,9 @@ RedirectionsPtr PJSipSessionModule::getRedirections(pjsip_rx_data *rdata, pjsip_
         {
             toId = *nextId;
         }
-        RedirectionPtr redirect(new Redirection(*id, toId));
+        //XXX TODO get the reason from the Diversion headah!
+        RedirectionReasonPtr reason(new RedirectionReason(Unknown));
+        RedirectionPtr redirect(new Redirection(*id, toId, reason));
         redirections->redirects.push_back(redirect);
     }
     return redirections;
@@ -642,7 +671,8 @@ RedirectionsPtr PJSipSessionModule::getRedirections(pjsip_rx_data *rdata, pjsip_
 ConnectedLinePtr PJSipSessionModule::getConnectedID(pjsip_rx_data *rdata)
 {
     ConnectedLinePtr connected(new ConnectedLine);
-    getIds("P-Asserted-Identity", rdata, connected->ids);
+    bool privacySet = getPrivacy(rdata);
+    getIds("P-Asserted-Identity", rdata, privacySet, connected->ids);
     if (!connected->ids.empty())
     {
         return connected;
@@ -650,7 +680,7 @@ ConnectedLinePtr PJSipSessionModule::getConnectedID(pjsip_rx_data *rdata)
 
     //There were no P-Asserted-Identity headers present. Maybe
     //they've used Remote-Party-ID instead...
-    getIds("Remote-Party-ID", rdata, connected->ids);
+    getIds("Remote-Party-ID", rdata, privacySet, connected->ids);
     return connected;
 }
 
diff --git a/src/PJSipSessionModule.h b/src/PJSipSessionModule.h
index d34fe6b..cefb899 100644
--- a/src/PJSipSessionModule.h
+++ b/src/PJSipSessionModule.h
@@ -140,7 +140,11 @@ public:
 
 private:
     void handleNewInvite(pjsip_rx_data *rdata);
-    void getIds(const char *headerName, pjsip_rx_data *rdata, AsteriskSCF::SessionCommunications::PartyIdentification::V1::IdSeq& ids);
+    bool getPrivacy(pjsip_rx_data *rdata);
+    void getIds(const char *headerName,
+            pjsip_rx_data *rdata,
+            bool privacySet,
+            AsteriskSCF::SessionCommunications::PartyIdentification::V1::IdSeq& ids);
     AsteriskSCF::SessionCommunications::PartyIdentification::V1::CallerPtr getCallerID(pjsip_rx_data *rdata);
     AsteriskSCF::SessionCommunications::PartyIdentification::V1::ConnectedLinePtr getConnectedID(pjsip_rx_data *rdata);
     AsteriskSCF::SessionCommunications::PartyIdentification::V1::RedirectionsPtr getRedirections(pjsip_rx_data *rdata, pjsip_sip_uri *ruri);
diff --git a/src/SipConfiguration.cpp b/src/SipConfiguration.cpp
index 895aee0..84b3ec3 100644
--- a/src/SipConfiguration.cpp
+++ b/src/SipConfiguration.cpp
@@ -464,7 +464,8 @@ public:
 
     SessionOwnerIdPtr createSessionOwnerId(string name, string number)
     {
-        IdPtr id = new Id(new Name(name), new Number(number));
+        //XXX Should privacy be configurable?
+        IdPtr id = new Id(new Name(name), new Number(number), new Privacy(false));
         IdSeq ids;
         ids.push_back(id);
         return new SessionOwnerId(ids);
@@ -478,7 +479,7 @@ public:
             return;
         }
 
-        IdPtr id = new Id(new Name(name), new Number(number));
+        IdPtr id = new Id(new Name(name), new Number(number), new Privacy(false));
         mSessionOwnerId->ids.push_back(id);
     }
 

commit a4414ee3a8b0ee71bbf703e7c31f66995ad45005
Author: Mark Michelson <mmichelson at digium.com>
Date:   Thu Oct 13 13:54:50 2011 -0500

    Adjust for change in routeSession()

diff --git a/src/PJSipSessionModule.cpp b/src/PJSipSessionModule.cpp
index 6e86c85..65c2388 100644
--- a/src/PJSipSessionModule.cpp
+++ b/src/PJSipSessionModule.cpp
@@ -500,7 +500,7 @@ protected:
                 SuspendableWorkListenerPtr listener = 0;
                 SipAMICallbackPtr cb(new SipAMICallback(listener, mSession, this, false, true));
                 Ice::CallbackPtr d = Ice::newCallback(cb, &SipAMICallback::callback);
-                mSessionRouter->begin_routeSession(operationId, mSession->getSessionProxy(), mDestination, 0, mCallerID, d);
+                mSessionRouter->begin_routeSession(operationId, mSession->getSessionProxy(), mDestination, 0, mCallerID, mRedirections, d);
             }
         }
         catch (const Ice::CommunicatorDestroyedException &)

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


-- 
asterisk-scf/integration/sip.git



More information about the asterisk-scf-commits mailing list