Commit eb3f8dd2 authored by Julien Bonjean's avatar Julien Bonjean
Browse files

[#2916] Added toggle pick up and toggle hold actions

parent 3fa2d53f
......@@ -42,6 +42,39 @@ static GHashTable* shortcutsMap;
* Callbacks
*/
static void
toggle_pick_up_hang_up_callback ()
{
callable_obj_t * selectedCall = calltab_get_selected_call (active_calltree);
conference_obj_t * selectedConf = calltab_get_selected_conf (active_calltree);
g_print("toggle_pick_up_hang_up_callback\n");
if (selectedCall)
{
switch (selectedCall->_state)
{
case CALL_STATE_DIALING:
case CALL_STATE_INCOMING:
case CALL_STATE_TRANSFERT:
sflphone_pick_up ();
break;
case CALL_STATE_HOLD:
case CALL_STATE_CURRENT:
case CALL_STATE_RECORD:
case CALL_STATE_RINGING:
sflphone_hang_up ();
break;
}
}
else if (selectedConf)
{
dbus_hang_up_conference (selectedConf);
}
else
sflphone_pick_up ();
}
static void
pick_up_callback ()
{
......@@ -54,6 +87,33 @@ hang_up_callback ()
sflphone_hang_up ();
}
static void
toggle_hold_callback ()
{
callable_obj_t * selectedCall = calltab_get_selected_call (current_calls);
conference_obj_t * selectedConf = calltab_get_selected_conf (active_calltree);
if (selectedCall)
{
switch (selectedCall->_state)
{
case CALL_STATE_CURRENT:
case CALL_STATE_RECORD:
g_print("on hold\n");
sflphone_on_hold();
break;
case CALL_STATE_HOLD:
g_print("off hold\n");
sflphone_off_hold();
break;
}
}
else if (selectedConf)
dbus_hold_conference (selectedConf);
else
ERROR("Should not happen");
}
static void
popup_window_callback ()
{
......@@ -84,6 +144,12 @@ get_action_callback (const gchar* action)
if (strcmp (action, "popup_window") == 0)
return popup_window_callback;
if (strcmp (action, "toggle_pick_up_hang_up") == 0)
return toggle_pick_up_hang_up_callback;
if (strcmp (action, "toggle_hold") == 0)
return toggle_hold_callback;
return default_callback;
}
......@@ -226,24 +292,24 @@ initialize_accelerators_list ()
}
static void
update_bindings_data(const guint index, const guint code)
update_bindings_data (const guint index, const guint code)
{
// we need to be sure this code is not already affected
// to another action
int i = 0;
while (accelerators_list[i].action != NULL)
{
if(accelerators_list[i].value == code)
{
// disable old binding
accelerators_list[i].value = 0;
// update config table
g_hash_table_replace (shortcutsMap,
g_strdup (accelerators_list[i].action), GINT_TO_POINTER (0));
}
i++;
}
// we need to be sure this code is not already affected
// to another action
int i = 0;
while (accelerators_list[i].action != NULL)
{
if (accelerators_list[i].value == code)
{
// disable old binding
accelerators_list[i].value = 0;
// update config table
g_hash_table_replace (shortcutsMap, g_strdup (
accelerators_list[i].action), GINT_TO_POINTER (0));
}
i++;
}
// store new value
accelerators_list[index].value = code;
......@@ -268,7 +334,7 @@ shortcuts_update_bindings (const guint index, const guint code)
remove_bindings ();
// update data
update_bindings_data(index, code);
update_bindings_data (index, code);
// recreate all bindings
create_bindings ();
......
......@@ -50,6 +50,12 @@ pick_up_callback ();
static void
hang_up_callback ();
static void
toggle_pick_up_hang_up_callback ();
static void
toggle_hold_callback ();
static void
initialize_binding (const gchar* action, const guint code);
......
......@@ -33,6 +33,8 @@ ConfigurationManager::ConfigurationManager(DBus::Connection& connection) :
shortcutsKeys.push_back("pick_up");
shortcutsKeys.push_back("hang_up");
shortcutsKeys.push_back("popup_window");
shortcutsKeys.push_back("toggle_pick_up_hang_up");
shortcutsKeys.push_back("toggle_hold");
}
std::map<std::string, std::string> ConfigurationManager::getAccountDetails(
......
......@@ -727,7 +727,7 @@ bool ManagerImpl::refuseCall (const CallID& id) {
// AudioLayer* audiolayer = getAudioDriver();
if (nbCalls <= 1) {
_debug (" hangupCall: stop audio stream, ther is only %i call(s) remaining", nbCalls);
_debug (" refuseCall: stop audio stream, ther is only %i call(s) remaining", nbCalls);
AudioLayer* audiolayer = getAudioDriver();
audiolayer->stopStream();
......@@ -744,7 +744,7 @@ bool ManagerImpl::refuseCall (const CallID& id) {
accountid = getAccountFromCall(id);
if (accountid == AccountNULL) {
_debug ("! Manager OffHold Call: Call doesn't exists");
_debug ("! Manager refuseCall: Call doesn't exists");
return false;
}
......
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