Commit f8fd1cf9 authored by Alexandre Savard's avatar Alexandre Savard

[#2274] Parse the Display Name in sip INVITE message

parent 155bc0c2
......@@ -125,6 +125,20 @@ class Call: public Recordable{
*/
const std::string& getPeerName() { return _peerName; }
/**
* Set the display name (caller in ingoing)
* not protected by mutex (when created)
* @return std::string The peer display name
*/
void setDisplayName(const std::string& name) { _displayName = name; }
/**
* Get the peer display name (caller in ingoing)
* not protected by mutex (when created)
* @return std::string The peer name
*/
const std::string& getDisplayName() { return _displayName; }
/**
* Tell if the call is incoming
* @return true if yes
......@@ -260,8 +274,13 @@ class Call: public Recordable{
/** Number of the peer */
std::string _peerNumber;
/** Display Name */
std::string _displayName;
/** File name for his call : time YY-MM-DD */
std::string _filename;
};
#endif
......@@ -1745,7 +1745,7 @@ bool
ManagerImpl::incomingCall (Call* call, const AccountID& accountId)
{
PulseLayer *pulselayer;
std::string from, number;
std::string from, number, display_name;
stopTone (true);
......@@ -1775,8 +1775,12 @@ ManagerImpl::incomingCall (Call* call, const AccountID& accountId)
from = call->getPeerName();
display_name = call->getDisplayName();
number = call->getPeerNumber();
_debug( "incomingCall display_name from: %s, number: %s\n");
if (from != "" && number != "") {
from.append (" <");
from.append (number);
......@@ -1797,7 +1801,8 @@ ManagerImpl::incomingCall (Call* call, const AccountID& accountId)
*/
/* Broadcast a signal over DBus */
if (_dbus) _dbus->getCallManager()->incomingCall (accountId, call->getCallId(), from);
_debug(" From: %s, Number: %s\n", from.c_str(), number.c_str());
if (_dbus) _dbus->getCallManager()->incomingCall (accountId, call->getCallId(), from.c_str());
//if (_dbus) _dbus->getCallManager()->callStateChanged(call->getCallId(), "INCOMING");
......@@ -2626,6 +2631,8 @@ ManagerImpl::setAudioOutputDevice (const int index)
alsalayer = dynamic_cast<AlsaLayer*> (getAudioDriver ());
alsaplugin = alsalayer->getAudioPlugin ();
_debug(" set output plugin: %s\n", alsaplugin.c_str());
_audiodriver->openDevice (_audiodriver->getIndexIn(), index, _audiodriver->getSampleRate(), _audiodriver->getFrameSize(), SFL_PCM_PLAYBACK, alsaplugin);
if (_audiodriver -> getErrorMessage() != -1)
......@@ -2646,6 +2653,7 @@ ManagerImpl::getAudioInputDeviceList (void)
audiolayer = dynamic_cast<AlsaLayer *> (getAudioDriver());
if (audiolayer)
devices = audiolayer->getSoundCardsInfo (SFL_PCM_CAPTURE);
......@@ -2668,6 +2676,8 @@ ManagerImpl::setAudioInputDevice (const int index)
alsalayer = dynamic_cast<AlsaLayer*> (getAudioDriver ());
alsaplugin = alsalayer->getAudioPlugin ();
_debug(" set input plugin: %s\n", alsaplugin.c_str());
_audiodriver->openDevice (index, _audiodriver->getIndexOut(), _audiodriver->getSampleRate(), _audiodriver->getFrameSize(), SFL_PCM_CAPTURE, alsaplugin);
if (_audiodriver -> getErrorMessage() != -1)
......
......@@ -41,6 +41,7 @@
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
#include <istream>
#define CAN_REINVITE 1
......@@ -2836,7 +2837,7 @@ mod_on_rx_request (pjsip_rx_data *rdata)
AccountID account_id;
pjsip_uri *uri;
pjsip_sip_uri *sip_uri;
std::string userName, server;
std::string userName, server, displayName;
SIPVoIPLink *link;
CallID id;
SIPCall* call;
......@@ -2844,6 +2845,8 @@ mod_on_rx_request (pjsip_rx_data *rdata)
SIPAccount *account;
pjmedia_sdp_session *r_sdp;
pjsip_generic_string_hdr* hdr;
// voicemail part
std::string method_name;
std::string request;
......@@ -2882,12 +2885,26 @@ mod_on_rx_request (pjsip_rx_data *rdata)
return false;
}
char* from_header = strstr(rdata->msg_info.msg_buf, "From: ");
// _debug("------------------------------ thefromheader: %s\n", from_header);
char* display_name = strtok(from_header, "\"");
display_name = strtok(NULL, "\"");
_debug("UserAgent: The displayname for this call: %s\n", display_name);
displayName = string(display_name);
_debug ("UserAgent: The receiver is : %s@%s\n", userName.data(), server.data());
_debug ("UserAgent: The callee account id is %s\n", account_id.c_str());
/* Now, it is the time to find the information of the caller */
uri = rdata->msg_info.from->uri;
// display_name = rdata->msg_info.from->name;
std::string temp((char*)(&display_name));
sip_uri = (pjsip_sip_uri *) pjsip_uri_get_uri (uri);
// Store the peer number
......@@ -3009,6 +3026,8 @@ mod_on_rx_request (pjsip_rx_data *rdata)
call->setPeerNumber (peerNumber);
call->setDisplayName(displayName);
call->initRecFileName();
// Notify UI there is an incoming call
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment