Commit e6efe174 authored by Emmanuel Milou's avatar Emmanuel Milou

Add a DBus call to fetch the call details from a call ID - Ticket #928

parent 68241e8a
......@@ -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);
......
......@@ -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 *);
......
......@@ -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;
}
......@@ -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
......@@ -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
......
......@@ -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;
}
......@@ -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.
......
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