[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
Fri Oct 14 16:18:45 CDT 2011


branch "party-id" has been updated
       via  cb74d1811198e4b47d128852a887bd2aef79dc67 (commit)
      from  acc52bcd5208a0f34d86da53f78194cd5b19dd31 (commit)

Summary of changes:
 src/PJSipSessionModule.h |   51 ++++++++++++++++++++++++++++++++++++++++++++++
 src/SipSession.cpp       |   36 ++++++++++++++++++++++++++++++++
 2 files changed, 87 insertions(+), 0 deletions(-)


- Log -----------------------------------------------------------------
commit cb74d1811198e4b47d128852a887bd2aef79dc67
Author: Mark Michelson <mmichelson at digium.com>
Date:   Fri Oct 14 16:18:31 2011 -0500

    Add privacy header to outgoing caller and connected updates.

diff --git a/src/PJSipSessionModule.h b/src/PJSipSessionModule.h
index 56c5ed6..3b9c3a0 100644
--- a/src/PJSipSessionModule.h
+++ b/src/PJSipSessionModule.h
@@ -144,22 +144,73 @@ public:
 
 private:
     void handleNewInvite(pjsip_rx_data *rdata);
+
+    /**
+     * Gets the value of the Privacy setting and returns true if
+     * the value is set to "id"
+     */
     bool getPrivacy(pjsip_rx_data *rdata);
+    /**
+     * Generic method to get Ids from a header name.
+     * 
+     * This can be used for any header type that does not
+     * have specific parameters that need to be read.
+     */
     void getIds(const char *headerName,
             pjsip_rx_data *rdata,
             bool privacySet,
             AsteriskSCF::SessionCommunications::PartyIdentification::V1::IdSeq& ids);
+    /**
+     * Get the IDs in Diversion headers.
+     *
+     * This will also parse the reason parameters from the headers.
+     */
     void getRedirectionIds(pjsip_rx_data *rdata,
             bool privacySet,
             ReasonIdSeq& ids);
+
+    /**
+     * Get the IDs from Remote-Party-ID headers.
+     *
+     * This will also parse the privacy and screen parameters.
+     */
     void getRemotePartyIds(pjsip_rx_data *rdata,
             bool privacySet,
             AsteriskSCF::SessionCommunications::PartyIdentification::V1::IdSeq& ids);
+
+    /**
+     * Generic method to get a specific parameter from a header
+     */
     std::string getParam(const std::string& headerVal, const char *paramName);
+
+    /**
+     * Translate a reason string into the appropriate slice enum value
+     */
     AsteriskSCF::SessionCommunications::PartyIdentification::V1::Reason translateReason(const std::string& reason);
+
+    /**
+     * Get caller ID
+     *
+     * This will first attempt to find P-Asserted-Identity headers. If none are present, it
+     * will use the From header to find the caller ID.
+     */
     AsteriskSCF::SessionCommunications::PartyIdentification::V1::CallerPtr getCallerID(pjsip_rx_data *rdata);
+
+    /**
+     * Get the connected ID
+     *
+     * This will first attempt to find P-Asserted-Identity headers. If none are present, it
+     * will search for Remote-Party-ID headers.
+     */
     AsteriskSCF::SessionCommunications::PartyIdentification::V1::ConnectedLinePtr getConnectedID(pjsip_rx_data *rdata);
+
+    /**
+     * Get Redirections
+     *
+     * This will attempt to find Diversion headers.
+     */
     AsteriskSCF::SessionCommunications::PartyIdentification::V1::RedirectionsPtr getRedirections(pjsip_rx_data *rdata, pjsip_sip_uri *ruri);
+
     void handleInviteResponse(pjsip_inv_session *inv, pjsip_rx_data *rdata, pjsip_dialog *dlg);
     void handleRefer(pjsip_inv_session *inv, pjsip_rx_data *rdata);
     void handleInfo(pjsip_inv_session *inv, pjsip_rx_data *rdata);
diff --git a/src/SipSession.cpp b/src/SipSession.cpp
index 2357091..edd975a 100755
--- a/src/SipSession.cpp
+++ b/src/SipSession.cpp
@@ -1564,10 +1564,17 @@ private:
         }
 
         ConnectedLinePtr caller = ConnectedLinePtr::dynamicCast(iter->second);
+        bool addPrivacy = false;
         for (IdSeq::iterator id = caller->ids.begin(); id != caller->ids.end(); ++id)
         {
             std::string connectedName = (*id)->partyName->partyName;
             std::string connectedNumber = (*id)->partyNumber->partyNumber;
+            //Logic here is that if any ID has privacy set on it, we'll add a privacy
+            //header.
+            if (!addPrivacy)
+            {
+                addPrivacy = (*id)->partyPrivacy->isPrivate;
+            }
 
             pj_str_t paiHeader;
             pj_cstr(&paiHeader, "P-Asserted-Identity");
@@ -1585,6 +1592,18 @@ private:
 
             pjsip_msg_add_hdr(packet->msg, (pjsip_hdr*) hdr);
         }
+
+        if (addPrivacy)
+        {
+            pj_str_t privacyHeader;
+            pj_cstr(&privacyHeader, "Privacy");
+            pj_str_t privacyValue;
+            pj_cstr(&privacyValue, "id");
+            pjsip_generic_string_hdr *hdr =
+                pjsip_generic_string_hdr_create(packet->pool, &privacyHeader, &privacyValue);
+
+            pjsip_msg_add_hdr(packet->msg, (pjsip_hdr*) hdr);
+        }
     }
 
     AsteriskSCF::SessionCommunications::V1::AMD_Session_indicatePtr mCb;
@@ -2084,10 +2103,15 @@ private:
         }
 
         CallerPtr caller = CallerPtr::dynamicCast(iter->second);
+        bool addPrivacy = false;
         for (IdSeq::iterator id = caller->ids.begin(); id != caller->ids.end(); ++id)
         {
             std::string callerName = (*id)->partyName->partyName;
             std::string callerNumber = (*id)->partyNumber->partyNumber;
+            if (!addPrivacy)
+            {
+                addPrivacy = (*id)->partyPrivacy->isPrivate;
+            }
 
             pj_str_t paiHeader;
             pj_cstr(&paiHeader, "P-Asserted-Identity");
@@ -2105,6 +2129,18 @@ private:
 
             pjsip_msg_add_hdr(packet->msg, (pjsip_hdr*) hdr);
         }
+
+        if (addPrivacy)
+        {
+            pj_str_t privacyHeader;
+            pj_cstr(&privacyHeader, "Privacy");
+            pj_str_t privacyValue;
+            pj_cstr(&privacyValue, "id");
+            pjsip_generic_string_hdr *hdr =
+                pjsip_generic_string_hdr_create(packet->pool, &privacyHeader, &privacyValue);
+
+            pjsip_msg_add_hdr(packet->msg, (pjsip_hdr*) hdr);
+        }
     }
 
     void addDiversion(pjsip_tx_data *packet)

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


-- 
asterisk-scf/integration/sip.git



More information about the asterisk-scf-commits mailing list