diff --git a/sflphone-gtk/src/call.c b/sflphone-gtk/src/call.c index 4df77fccf423e86cd6701f862efed245d75d3ad1..05a67d373fd908133cc3cddcb40bdaca21b0040e 100644 --- a/sflphone-gtk/src/call.c +++ b/sflphone-gtk/src/call.c @@ -96,7 +96,22 @@ void create_new_call (gchar *to, gchar *from, call_state_t state, gchar *account *new_call = call; } -void +void create_new_call_from_details (const gchar *call_id, GHashTable *details, call_t **call) +{ + gchar *from, *to, *accountID; + call_t *new_call; + GHashTable *call_details; + + accountID = g_hash_table_lookup (details, "ACCOUNTID"); + to = g_hash_table_lookup (details, "PEER_NUMBER"); + from = g_markup_printf_escaped("\"\" <%s>", to); + + create_new_call (from, from, CALL_STATE_DIALING, accountID, &new_call); + *call = new_call; +} + + + void free_call_t (call_t *c) { g_free (c->callID); diff --git a/sflphone-gtk/src/call.h b/sflphone-gtk/src/call.h index 91f1db5d88116b69b18ce87ddab1cb9538ba899d..b32ba9920ce0a95ca27853e6b982bccca77f08c7 100644 --- a/sflphone-gtk/src/call.h +++ b/sflphone-gtk/src/call.h @@ -143,6 +143,9 @@ call_get_recipient( const call_t *); void create_new_call (gchar *, gchar *, call_state_t, gchar *, call_t **); +void +create_new_call_from_details (const gchar *, GHashTable *, call_t **); + void attach_thumbnail (call_t *, GdkPixbuf *); diff --git a/sflphone-gtk/src/dbus/dbus.c b/sflphone-gtk/src/dbus/dbus.c index 9eabf1a43227ccddb9ab5f54bf585b53f69c3164..6cfe2d8156710770dc0da2a6dd55d1a6dd41a712 100644 --- a/sflphone-gtk/src/dbus/dbus.c +++ b/sflphone-gtk/src/dbus/dbus.c @@ -153,16 +153,25 @@ call_state_cb (DBusGProxy *proxy UNUSED, } } else - { //The callID is unknow, threat it like a new call + { + // The callID is unknow, threat it like a new call + // If it were an incoming call, we won't be here + // It means that a new call has been initiated with an other client (cli for instance) if ( strcmp(state, "RINGING") == 0 ) { - g_print ("New ringing call! %s\n",callID); - call_t * c = g_new0 (call_t, 1); - c->accountID = g_strdup("1"); - c->callID = g_strdup(callID); - c->from = g_strdup("\"\" <>"); - c->state = CALL_STATE_RINGING; - sflphone_incoming_call (c); + call_t *new_call; + GHashTable *call_details; + + g_print ("New ringing call! accountID: %s\n", callID); + + // We fetch the details associated to the specified call + call_details = dbus_get_call_details (callID); + create_new_call_from_details (callID, call_details, &new_call); + + // Restore the callID to be synchronous with the daemon + new_call->callID = g_strdup(callID); + + sflphone_incoming_call (new_call); } } } @@ -1549,4 +1558,16 @@ void dbus_set_hook_settings (GHashTable * settings){ } } +GHashTable* dbus_get_call_details (const gchar *callID) +{ + GError *error = NULL; + GHashTable *details = NULL; + org_sflphone_SFLphone_CallManager_get_call_details (callManagerProxy, callID, &details, &error); + if (error){ + g_print ("Error calling org_sflphone_SFLphone_CallManager_get_call_details\n"); + g_error_free (error); + } + + return details; +} diff --git a/sflphone-gtk/src/dbus/dbus.h b/sflphone-gtk/src/dbus/dbus.h index 220e0557336c0f854d4c887e31994b71d9950692..4e10fba74cc9a400d53ca5fdbb4bee489cece6d9 100644 --- a/sflphone-gtk/src/dbus/dbus.h +++ b/sflphone-gtk/src/dbus/dbus.h @@ -477,4 +477,6 @@ void dbus_set_hook_settings (GHashTable *); gboolean dbus_get_is_recording(const call_t *); +GHashTable* dbus_get_call_details (const gchar* callID); + #endif diff --git a/src/dbus/callmanager.cpp b/src/dbus/callmanager.cpp index 9830253434321f52eddf4fcc3bf584e2ba68cdac..e013410ad59c63693896cd68bb70a40c7fed976c 100644 --- a/src/dbus/callmanager.cpp +++ b/src/dbus/callmanager.cpp @@ -140,11 +140,10 @@ CallManager::getCurrentCodecName(const std::string& callID) std::map< std::string, std::string > -CallManager::getCallDetails( const std::string& callID UNUSED ) +CallManager::getCallDetails( const std::string& callID ) { _debug("CallManager::getCallDetails received\n"); - std::map<std::string, std::string> a; - return a; + return Manager::instance().getCallDetails (callID); } std::string diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp index ba90279fdfd4e7654e5d6394efe423681371870b..0dd7228ec0b0abc02eeb6837a182727ab6e5a8d3 100644 --- a/src/managerimpl.cpp +++ b/src/managerimpl.cpp @@ -708,7 +708,7 @@ ManagerImpl::incomingCall(Call* call, const AccountID& accountId) stopTone(true); - _debug("Incoming call %s\n", call->getCallId().data()); + _debug("Incoming call %s for account %s\n", call->getCallId().data(), accountId.c_str()); associateCallToAccount(call->getCallId(), accountId); @@ -2675,3 +2675,44 @@ bool ManagerImpl::removeCallConfig(const CallID& callID) { return false; } +std::map< std::string, std::string > ManagerImpl::getCallDetails(const CallID& callID) { + + std::map<std::string, std::string> call_details; + AccountID accountid; + Account *account; + VoIPLink *link; + Call *call; + + // We need here to retrieve the call information attached to the call ID + // To achieve that, we need to get the voip link attached to the call + // But to achieve that, we need to get the account the call was made with + + // So first we fetch the account + accountid = getAccountFromCall (callID); + + // Then the VoIP link this account is linked with (IAX2 or SIP) + if ( (account=getAccount (accountid)) != 0) { + link = account->getVoIPLink (); + + if (link) { + call = link->getCall (callID); + } + + } + + if (call) + { + call_details.insert (std::pair<std::string, std::string> ("ACCOUNTID", accountid)); + call_details.insert (std::pair<std::string, std::string> ("PEER_NUMBER", call->getPeerNumber ())); + call_details.insert (std::pair<std::string, std::string> ("PEER_NAME", call->getPeerName ())); + } + else + { + _debug ("Error: Managerimpl - getCallDetails ()\n"); + call_details.insert (std::pair<std::string, std::string> ("ACCOUNTID", AccountNULL)); + call_details.insert (std::pair<std::string, std::string> ("PEER_NUMBER", "Unknown")); + call_details.insert (std::pair<std::string, std::string> ("PEER_NAME", "Unknown")); + } + + return call_details; +} diff --git a/src/managerimpl.h b/src/managerimpl.h index 35426796f9fa969afe3d62be723feac3c0704096..5a12a3143f4678d17bf4f5de4722cfe5ef829d2f 100644 --- a/src/managerimpl.h +++ b/src/managerimpl.h @@ -289,6 +289,13 @@ class ManagerImpl { */ std::map< std::string, std::string > getAccountDetails(const AccountID& accountID); + /** + * Retrieve details about a given call + * @param callID The account identifier + * @return std::map< std::string, std::string > The call details + */ + std::map< std::string, std::string > getCallDetails(const CallID& callID); + /** * Save the details of an existing account, given the account ID * This will load the configuration map with the given data.