Hi,

I have added Alert-Info/P-Called-Party-Id support to my softphone.
These headers can be used for changing ring tone or getting caller's
external number. It is typically required on Japanese PBX system.

Since I could not find functions to get header value, I made
invite message passed to event handler. Please let me know if
there is appropriate interface.
Attached diff file is a patch for sipXtapi-media-update branch.

Regards,
Kenichi Aramaki
diff -Naur 20060811/sipXcallLib/include/tapi/sipXtapi.h 
20060830/sipXcallLib/include/tapi/sipXtapi.h
--- 20060811/sipXcallLib/include/tapi/sipXtapi.h        Thu Aug 10 12:52:12 2006
+++ 20060830/sipXcallLib/include/tapi/sipXtapi.h        Wed Aug 30 07:15:28 2006
@@ -3703,4 +3703,10 @@
 //@}
 
 
+//@@
+SIPXTAPI_API SIPX_RESULT sipxCallGetAlertInfo(const SIPX_CALL hCall, char* 
szAlertInfo, const size_t iMaxLength);
+SIPXTAPI_API SIPX_RESULT sipxCallGetPCalledPartyID(const SIPX_CALL hCall, 
char* szPartyID, const size_t iMaxLength);
+//@@
+
+
 #endif // _sipXtapi_h_
diff -Naur 20060811/sipXcallLib/include/tapi/sipXtapiInternal.h 
20060830/sipXcallLib/include/tapi/sipXtapiInternal.h
--- 20060811/sipXcallLib/include/tapi/sipXtapiInternal.h        Tue Aug 08 
13:15:48 2006
+++ 20060830/sipXcallLib/include/tapi/sipXtapiInternal.h        Wed Aug 30 
07:15:46 2006
@@ -187,6 +187,10 @@
     UtlString* remoteAddress ;
     UtlString* lineURI ;
     UtlString* contactAddress ;
+//@@
+    UtlString* AlertInfo;
+    UtlString* PCalledPartyID;
+//@@
     SIPX_LINE  hLine ;
     SIPX_INSTANCE_DATA* pInst ;
     OsRWMutex* pMutex ;
diff -Naur 20060811/sipXcallLib/src/cp/SipConnection.cpp 
20060830/sipXcallLib/src/cp/SipConnection.cpp
--- 20060811/sipXcallLib/src/cp/SipConnection.cpp       Wed Aug 02 13:46:18 2006
+++ 20060830/sipXcallLib/src/cp/SipConnection.cpp       Mon Aug 21 10:21:25 2006
@@ -2898,8 +2898,10 @@
     if(!doesReplaceCallLegExist)
     {
         setState(CONNECTION_OFFERING, CONNECTION_LOCAL, cause);
-        fireSipXEvent(CALLSTATE_OFFERING, CALLSTATE_CAUSE_NORMAL) ;
-
+//@@
+        // pass invite message to get alert-info or p-called-party-id.
+//        fireSipXEvent(CALLSTATE_OFFERING, CALLSTATE_CAUSE_NORMAL) ;
+        fireSipXEvent(CALLSTATE_OFFERING, CALLSTATE_CAUSE_NORMAL, inviteMsg);
     }
 
     // If we are replacing a call let answer the call
diff -Naur 20060811/sipXcallLib/src/tapi/sipXtapi.cpp 
20060830/sipXcallLib/src/tapi/sipXtapi.cpp
--- 20060811/sipXcallLib/src/tapi/sipXtapi.cpp  Tue Aug 08 13:23:34 2006
+++ 20060830/sipXcallLib/src/tapi/sipXtapi.cpp  Wed Aug 30 07:21:00 2006
@@ -155,6 +155,20 @@
             delete pData->sessionCallId ;
             pData->sessionCallId = NULL ;
         }
+
+//@@
+        if (pData->AlertInfo != NULL)
+        {
+            delete pData->AlertInfo;
+            pData->AlertInfo = NULL;
+        }
+        if (pData->PCalledPartyID != NULL)
+        {
+            delete pData->PCalledPartyID;
+            pData->PCalledPartyID = NULL;
+        }
+//@@
+
         OsRWMutex* pMutex = pData->pMutex;
         pData->pMutex = NULL;
         delete pData ;
@@ -7997,4 +8011,47 @@
     nUrl = results.length() + 1 ;
 
     return rc ;
-}
\ No newline at end of file
+}
+
+
+//@@
+SIPXTAPI_API SIPX_RESULT sipxCallGetAlertInfo(const SIPX_CALL hCall,
+                                                    char* szAlertInfo,
+                                                    const size_t iMaxLength)
+{
+    OsStackTraceLogger stackLogger(FAC_SIPXTAPI, PRI_DEBUG, 
"sipxCallGetAlertInfo");
+
+    SIPX_RESULT sr = SIPX_RESULT_FAILURE;
+    SIPX_CALL_DATA* pData = sipxCallLookup(hCall, SIPX_LOCK_READ, stackLogger);
+    if (pData != NULL) {
+        if (pData->AlertInfo != NULL) {
+            strncpy(szAlertInfo, *pData->AlertInfo, iMaxLength);
+            szAlertInfo[iMaxLength - 1] = '\0';
+            sr = SIPX_RESULT_SUCCESS;
+        }
+        sipxCallReleaseLock(pData, SIPX_LOCK_READ, stackLogger);
+    }
+    return sr;
+}
+
+
+//@@
+SIPXTAPI_API SIPX_RESULT sipxCallGetPCalledPartyID(const SIPX_CALL hCall,
+                                                    char* szPartyID,
+                                                    const size_t iMaxLength)
+{
+    OsStackTraceLogger stackLogger(FAC_SIPXTAPI, PRI_DEBUG, 
"sipxCallGetPCalledPartyID");
+
+    SIPX_RESULT sr = SIPX_RESULT_FAILURE;
+    SIPX_CALL_DATA* pData = sipxCallLookup(hCall, SIPX_LOCK_READ, stackLogger);
+    if (pData != NULL) {
+        if (pData->PCalledPartyID != NULL) {
+            strncpy(szPartyID, *pData->PCalledPartyID, iMaxLength);
+            szPartyID[iMaxLength - 1] = '\0';
+            sr = SIPX_RESULT_SUCCESS;
+        }
+        sipxCallReleaseLock(pData, SIPX_LOCK_READ, stackLogger);
+    }
+    return sr;
+}
+
diff -Naur 20060811/sipXcallLib/src/tapi/sipXtapiEvents.cpp 
20060830/sipXcallLib/src/tapi/sipXtapiEvents.cpp
--- 20060811/sipXcallLib/src/tapi/sipXtapiEvents.cpp    Tue Aug 08 13:15:48 2006
+++ 20060830/sipXcallLib/src/tapi/sipXtapiEvents.cpp    Fri Aug 18 04:15:10 2006
@@ -1149,6 +1149,35 @@
         }
 
 
+//@@
+        if (event == CALLSTATE_OFFERING && pEventData != NULL)
+        {
+            const char *pszAlertInfo = ((HttpMessage 
*)pEventData)->getHeaderValue(0, "Alert-Info");
+            if ( pszAlertInfo != NULL ) {
+                pCallData = sipxCallLookup(hCall, SIPX_LOCK_WRITE, 
stackLogger);
+                if (pCallData) {
+                    if (pCallData->AlertInfo) {
+                        delete pCallData->AlertInfo;
+                    }
+                    pCallData->AlertInfo = new UtlString(pszAlertInfo);
+                    sipxCallReleaseLock(pCallData, SIPX_LOCK_WRITE, 
stackLogger);
+                }
+            }
+            const char *pszPartyID = ((HttpMessage 
*)pEventData)->getHeaderValue(0, "P-Called-Party-ID");
+            if ( pszPartyID != NULL ) {
+                pCallData = sipxCallLookup(hCall, SIPX_LOCK_WRITE, 
stackLogger);
+                if (pCallData) {
+                    if (pCallData->PCalledPartyID) {
+                        delete pCallData->PCalledPartyID;
+                    }
+                    pCallData->PCalledPartyID = new UtlString(pszPartyID);
+                    sipxCallReleaseLock(pCallData, SIPX_LOCK_WRITE, 
stackLogger);
+                }
+            }
+        }
+//@@
+
+
         if (g_bListenersEnabled)
         {
             OsLock eventLock(*g_pEventListenerLock) ;
diff -Naur 20060811/sipXportLib/include/tapi/sipXtapiInternal.h 
20060830/sipXportLib/include/tapi/sipXtapiInternal.h
--- 20060811/sipXportLib/include/tapi/sipXtapiInternal.h        Sat Aug 05 
02:53:12 2006
+++ 20060830/sipXportLib/include/tapi/sipXtapiInternal.h        Wed Aug 30 
07:15:46 2006
@@ -187,6 +187,10 @@
     UtlString* remoteAddress ;
     UtlString* lineURI ;
     UtlString* contactAddress ;
+//@@
+    UtlString* AlertInfo;
+    UtlString* PCalledPartyID;
+//@@
     SIPX_LINE  hLine ;
     SIPX_INSTANCE_DATA* pInst ;
     OsRWMutex* pMutex ;
diff -Naur 20060811/sipXtackLib/include/tapi/sipXtapiInternal.h 
20060830/sipXtackLib/include/tapi/sipXtapiInternal.h
--- 20060811/sipXtackLib/include/tapi/sipXtapiInternal.h        Tue Aug 08 
13:15:48 2006
+++ 20060830/sipXtackLib/include/tapi/sipXtapiInternal.h        Wed Aug 30 
07:15:46 2006
@@ -187,6 +187,10 @@
     UtlString* remoteAddress ;
     UtlString* lineURI ;
     UtlString* contactAddress ;
+//@@
+    UtlString* AlertInfo;
+    UtlString* PCalledPartyID;
+//@@
     SIPX_LINE  hLine ;
     SIPX_INSTANCE_DATA* pInst ;
     OsRWMutex* pMutex ;
_______________________________________________
sipxtapi-dev mailing list
[email protected]
List Archive: http://list.sipfoundry.org/archive/sipxtapi-dev/

Reply via email to