Commit 2fb856e0 authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

[#1312] Implement getCallList D-BUS method

parent 5f1fe552
......@@ -884,6 +884,31 @@ sflphone_fill_codec_list()
}
}
void sflphone_fill_call_list (void)
{
gchar** calls = (gchar**)dbus_get_call_list();
gchar** pl;
GHashTable *call_details;
call_t *c;
gchar *callID;
for(pl=calls; *calls; calls++)
{
c = g_new0(call_t, 1);
callID = (gchar*)(*calls);
call_details = dbus_get_call_details(callID);
create_new_call_from_details (callID, call_details, &c);
c->callID = g_strdup(callID);
// Add it to the list
DEBUG ("Add call retrieved from server side: %s\n", c->callID);
calllist_add (current_calls, c);
// Update the GUI
calltree_add_call (current_calls, c);
}
}
void format_phone_number (gchar **number) {
gchar *_number;
......
......@@ -152,6 +152,8 @@ void sflphone_place_call ( call_t * c );
*/
void sflphone_fill_account_list(gboolean toolbarInitialized);
void sflphone_fill_call_list (void);
/**
* Set an account as current. The current account is to one used to place calls with by default
* The current account is the first in the account list ( index 0 )
......
......@@ -89,6 +89,8 @@ void create_new_call (gchar *to, gchar *from, call_state_t state, gchar *account
call->_start = 0;
call->_stop = 0;
DEBUG ()
call_id = g_new0(gchar, 30);
g_sprintf(call_id, "%d", rand());
call->callID = g_strdup (call_id);
......@@ -98,15 +100,29 @@ void create_new_call (gchar *to, gchar *from, call_state_t state, gchar *account
void create_new_call_from_details (const gchar *call_id, GHashTable *details, call_t **call)
{
gchar *from, *to, *accountID;
gchar *from, *to, *accountID, *state_str;
call_t *new_call;
call_state_t state;
// 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);
state_str = g_hash_table_lookup (details, "CALL_STATE");
if (g_strcasecmp (state_str, "CURRENT") == 0)
state = CALL_STATE_CURRENT;
else if (g_strcasecmp (state_str, "HOLD") == 0)
state = CALL_STATE_HOLD;
else if (g_strcasecmp (state_str, "BUSY") == 0)
state = CALL_STATE_BUSY;
else
state = CALL_STATE_FAILURE;
create_new_call (from, from, CALL_STATE_DIALING, accountID, &new_call);
create_new_call (from, from, state, accountID, &new_call);
*call = new_call;
}
......
......@@ -110,4 +110,10 @@ calllist_clean_history();
void
calllist_remove_from_history( call_t* c);
/**
* Initialize a non-empty call list
*/
void
calllist_set_list (calltab_t* tab, gchar **call_list);
#endif
......@@ -479,6 +479,18 @@ calltree_add_call (calltab_t* tab, call_t * c)
case CALL_STATE_RINGING:
pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/ring.svg", NULL);
break;
case CALL_STATE_CURRENT:
// If the call has been initiated by a another client and, when we start, it is already current
pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/current.svg", NULL);
break;
case CALL_STATE_HOLD:
// If the call has been initiated by a another client and, when we start, it is already current
pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/hold.svg", NULL);
break;
case CALL_STATE_FAILURE:
// If the call has been initiated by a another client and, when we start, it is already current
pixbuf = gdk_pixbuf_new_from_file(ICONS_DIR "/fail.svg", NULL);
break;
default:
WARN("Update calltree add - Should not happen!");
}
......
......@@ -67,6 +67,10 @@
<arg type="a{ss}" name="infos" direction="out"/>
</method>
<method name="getCallList">
<arg type="as" name="list" direction="out"/>
</method>
<method name="getCurrentCallID">
<arg type="s" name="callID" direction="out"/>
</method>
......
......@@ -1623,6 +1623,20 @@ GHashTable* dbus_get_call_details (const gchar *callID)
return details;
}
gchar** dbus_get_call_list (void)
{
GError *error = NULL;
gchar **list = NULL;
org_sflphone_SFLphone_CallManager_get_call_list (callManagerProxy, &list, &error);
if (error){
ERROR ("Error calling org_sflphone_SFLphone_CallManager_get_call_list");
g_error_free (error);
}
return list;
}
void dbus_set_accounts_order (const gchar* order) {
GError *error = NULL;
......
......@@ -481,6 +481,8 @@ gboolean dbus_get_is_recording(const call_t *);
GHashTable* dbus_get_call_details (const gchar* callID);
gchar** dbus_get_call_list (void);
void dbus_set_accounts_order (const gchar* order);
#endif
......@@ -100,10 +100,13 @@ There is NO WARRANTY, to the extent permitted by law.\n\n");
}
#endif
status_bar_display_account();
status_bar_display_account();
/* start the main loop */
gtk_main();
// Get the active calls at startup
sflphone_fill_call_list ();
/* start the main loop */
gtk_main();
}
// Cleanly stop logging
......
......@@ -82,6 +82,32 @@ Call::getState()
return _callState;
}
std::string
Call::getStateStr (CallState state)
{
std::string state_str;
switch (state) {
case Active:
state_str = "CURRENT";
break;
case Hold:
state_str = "HOLD";
break;
case Busy:
state_str = "BUSY";
break;
case Refused:
case Error:
case Inactive:
default:
state_str = "FAILURE";
break;
}
return state_str;
}
const std::string&
Call::getLocalIp()
{
......
......@@ -139,6 +139,8 @@ class Call{
* @return CallState The call state
*/
CallState getState();
std::string getStateStr (CallState state);
void setCallConfiguration (Call::CallConfiguration callConfig) { _callConfig = callConfig; }
......
......@@ -67,6 +67,10 @@
<arg type="a{ss}" name="infos" direction="out"/>
</method>
<method name="getCallList">
<arg type="as" name="list" direction="out"/>
</method>
<method name="getCurrentCallID">
<arg type="s" name="callID" direction="out"/>
</method>
......
......@@ -146,6 +146,12 @@ CallManager::getCallDetails( const std::string& callID )
return Manager::instance().getCallDetails (callID);
}
std::vector< std::string >
CallManager::getCallList (void)
{
return Manager::instance().getCallList();
}
std::string
CallManager::getCurrentCallID( )
{
......
......@@ -51,7 +51,10 @@ public:
void setRecording( const std::string& callID );
bool getIsRecording(const std::string& callID);
std::string getCurrentCodecName(const std::string& callID);
std::map< std::string, std::string > getCallDetails( const std::string& callID );
std::vector< std::string > getCallList (void);
std::string getCurrentCallID( );
void playDTMF( const std::string& key );
void startTone( const int32_t& start, const int32_t& type );
......
......@@ -2840,6 +2840,7 @@ std::map< std::string, std::string > ManagerImpl::getCallDetails(const CallID& c
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 ()));
call_details.insert (std::pair<std::string, std::string> ("CALL_STATE", call->getStateStr (call->getState())));
}
else
{
......@@ -2847,7 +2848,24 @@ std::map< std::string, std::string > ManagerImpl::getCallDetails(const CallID& c
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"));
call_details.insert (std::pair<std::string, std::string> ("CALL_STATE", "FAILURE"));
}
return call_details;
}
std::vector< std::string >
ManagerImpl::getCallList (void)
{
std::vector< std::string > v;
int i;
CallAccountMap::iterator iter = _callAccountMap.begin ();
while (iter != _callAccountMap.end ()) {
v.push_back(iter->first.data());
iter++;
}
return v;
}
......@@ -301,6 +301,12 @@ class ManagerImpl {
*/
std::map< std::string, std::string > getCallDetails(const CallID& callID);
/**
* Get call list
* @return std::vector<std::string> A list of call IDs
*/
std::vector< std::string > getCallList (void);
/**
* Save the details of an existing account, given the account ID
* This will load the configuration map with the given data.
......
Supports Markdown
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