From 16cd6b901325ce9315ce9345488754a26157201c Mon Sep 17 00:00:00 2001 From: Emmanuel Milou <manu@manu-eeepc.(none)> Date: Sun, 7 Jun 2009 11:59:34 -0400 Subject: [PATCH] [#1214] Handle call timestamps properlier --- sflphone-client-gnome/src/actions.c | 29 +- sflphone-client-gnome/src/callable_obj.c | 78 +- sflphone-client-gnome/src/callable_obj.h | 14 +- sflphone-client-gnome/src/contacts/calltree.c | 4 +- sflphone-client-gnome/src/dbus/dbus.c | 2028 +++++++++-------- 5 files changed, 1098 insertions(+), 1055 deletions(-) diff --git a/sflphone-client-gnome/src/actions.c b/sflphone-client-gnome/src/actions.c index df5beb00af..5a15cd84a3 100644 --- a/sflphone-client-gnome/src/actions.c +++ b/sflphone-client-gnome/src/actions.c @@ -273,22 +273,20 @@ sflphone_hang_up() case CALL_STATE_RECORD: dbus_hang_up (selectedCall); selectedCall->_state = CALL_STATE_DIALING; - //(void) time(&selectedCall->_stop); + set_timestamp (&selectedCall->_time_stop); break; case CALL_STATE_FAILURE: dbus_hang_up (selectedCall); selectedCall->_state = CALL_STATE_DIALING; - //selectedCall->_stop = 0; break; case CALL_STATE_INCOMING: dbus_refuse (selectedCall); selectedCall->_state = CALL_STATE_DIALING; - //selectedCall->_stop = 0; DEBUG("from sflphone_hang_up : "); stop_notification(); break; case CALL_STATE_TRANSFERT: dbus_hang_up (selectedCall); - //(void) time(&selectedCall->_stop); + set_timestamp (&selectedCall->_time_stop); break; default: WARN("Should not happen in sflphone_hang_up()!"); @@ -322,7 +320,7 @@ sflphone_pick_up() break; case CALL_STATE_TRANSFERT: dbus_transfert (selectedCall); - //(void) time(&selectedCall->_stop); + set_timestamp (&selectedCall->_time_stop); break; case CALL_STATE_CURRENT: case CALL_STATE_RECORD: @@ -411,8 +409,8 @@ sflphone_busy( callable_obj_t * c ) void sflphone_current( callable_obj_t * c ) { - //if( c->_state != CALL_STATE_HOLD ) - //(void) time(&c->_start); + if( c->_state != CALL_STATE_HOLD ) + set_timestamp (&c->_time_start); c->_state = CALL_STATE_CURRENT; calltree_update_call(current_calls,c); update_menus(); @@ -421,8 +419,8 @@ sflphone_current( callable_obj_t * c ) void sflphone_record( callable_obj_t * c ) { - //if( c->_state != CALL_STATE_HOLD ) - // (void) time(&c->_start); + if( c->_state != CALL_STATE_HOLD ) + set_timestamp (&c->_time_start); c->_state = CALL_STATE_RECORD; calltree_update_call(current_calls,c); update_menus(); @@ -610,7 +608,7 @@ sflphone_keypad( guint keyval, gchar * key) { case 65307: /* ESCAPE */ dbus_hang_up(c); - //(void) time(&c->_stop); + set_timestamp (&c->_time_stop); calltree_update_call( history , c ); break; default: @@ -650,7 +648,7 @@ sflphone_keypad( guint keyval, gchar * key) case 65293: /* ENTER */ case 65421: /* ENTER numpad */ dbus_transfert(c); - //(void) time(&c->_stop); + set_timestamp (&c->_time_stop); break; case 65307: /* ESCAPE */ sflphone_unset_transfert(c); @@ -936,6 +934,8 @@ void sflphone_fill_history (void) gpointer key, value; callable_obj_t *history_entry; + DEBUG ("Loading history ..."); + entries = dbus_get_history (); if (entries) { @@ -961,18 +961,21 @@ void sflphone_save_history (void) GHashTable *result = NULL; gchar *key, *value; + DEBUG ("Saving history ..."); + result = g_hash_table_new(NULL, g_str_equal); items = history->callQueue; size = calllist_get_size (history); for (i=0; i<size; i++) { - current = g_queue_peek_nth (items, i); if (current) { value = serialize_history_entry (current); - key = current->_time_start; + g_print ("before %i\n", current->_time_start); + key = convert_timestamp_to_gchar (current->_time_start); + g_print ("after %s\n", key); g_hash_table_replace(result, (gpointer) key, (gpointer) value); } diff --git a/sflphone-client-gnome/src/callable_obj.c b/sflphone-client-gnome/src/callable_obj.c index 1c8c23d1c0..4dc8d9f85d 100644 --- a/sflphone-client-gnome/src/callable_obj.c +++ b/sflphone-client-gnome/src/callable_obj.c @@ -83,8 +83,8 @@ void create_new_call (callable_type_t type, call_state_t state, gchar* callID , obj->_peer_name = g_strdup (peer_name); obj->_peer_number = g_strdup (peer_number); obj->_peer_info = g_strdup (get_peer_info (peer_name, peer_number)); - obj->_time_start = "0"; - obj->_time_stop = "0"; + set_timestamp (&(obj->_time_start)); + set_timestamp (&(obj->_time_stop)); if (g_strcasecmp (callID, "") == 0) call_id = generate_call_id (); @@ -125,7 +125,7 @@ void create_new_call_from_details (const gchar *call_id, GHashTable *details, ca void create_history_entry_from_serialized_form (gchar *timestamp, gchar *details, callable_obj_t **call) { - gchar *peer_name, *peer_number, *accountID, *duration; + gchar *peer_name, *peer_number, *accountID, *time_stop; callable_obj_t *new_call; history_state_t history_state; char *ptr; @@ -149,7 +149,7 @@ void create_history_entry_from_serialized_form (gchar *timestamp, gchar *details peer_name = ptr; break; case 3: - duration = ptr; + time_stop = ptr; break; default: break; @@ -161,8 +161,8 @@ void create_history_entry_from_serialized_form (gchar *timestamp, gchar *details create_new_call (HISTORY_ENTRY, CALL_STATE_DIALING, "", "", peer_name, peer_number, &new_call); new_call->_history_state = history_state; - new_call->_time_start = timestamp; - new_call->_time_stop = duration; + new_call->_time_start = convert_gchar_to_timestamp (timestamp); + new_call->_time_stop = convert_gchar_to_timestamp (time_stop); *call = new_call; } @@ -214,20 +214,22 @@ history_state_t get_history_state_from_id (gchar *indice){ return state; } -gchar* calcul_call_duration (gchar *start, gchar *end) +gchar* get_call_duration (callable_obj_t *obj) { + gchar *res; - int duration, istop, istart; + int duration; + time_t start, end; - if( g_strcasecmp (start, end) == 0 ) - return g_markup_printf_escaped("<small>Missed call</small>"); + start = obj->_time_start; + end = obj->_time_stop; + + g_print ("start = %i - end = %i\n", start, end); - g_print ("%s\n", end); - istop = atoi (end); - istart = atoi (start); - g_print ("%i\n", istart); - duration = istop - istart; + if (start == end) + return g_markup_printf_escaped("<small>Duration:</small> none"); + duration = (int)end - (int)start; if( duration / 60 == 0 ) { @@ -249,19 +251,25 @@ gchar* calcul_call_duration (gchar *start, gchar *end) gchar* serialize_history_entry (callable_obj_t *entry) { + // "0|514-276-5468|Savoir-faire Linux|144562458" for instance + gchar* result; gchar* separator = "|"; - gchar* history_state; + gchar* history_state, *timestamp; + // Need the string form for the history state history_state = get_history_id_from_state (entry->_history_state); - // "0|514-276-5468|Savoir-faire Linux|144562458" for instance - result = g_strconcat (history_state, "|", entry->_peer_number, "|", entry->_peer_name, "|", entry->_time_stop, NULL); + // and the timestamps + timestamp = convert_timestamp_to_gchar (entry->_time_stop); + + result = g_strconcat (history_state, "|", entry->_peer_number, "|", entry->_peer_name, "|", timestamp, NULL); return result; } gchar* get_history_id_from_state (history_state_t state) { + // Refer to history_state_t enum in callable_obj.h switch (state) { case MISSED: @@ -281,11 +289,33 @@ gchar* get_formatted_start_timestamp (callable_obj_t *obj) time_t lt; unsigned char str[100]; - lt = (time_t) atoi (obj->_time_start); - ptr = gmtime(<); + if (obj) + { + lt = obj->_time_start; + ptr = gmtime(<); + + // result function of the current locale + strftime((char *)str, 100, "%c", (const struct tm *)ptr); + return g_markup_printf_escaped("\n%s\n" , str); + } + return ""; +} - // result function of the current locale - strftime((char *)str, 100, "%c", - (const struct tm *)ptr); - return g_markup_printf_escaped("\n%s\n" , str); +void set_timestamp (time_t *timestamp) +{ + time_t tmp; + + // Set to the current value + (void) time(&tmp); + *timestamp=tmp; +} + +gchar* convert_timestamp_to_gchar (time_t timestamp) +{ + return g_markup_printf_escaped ("%i", (int)timestamp); +} + +time_t convert_gchar_to_timestamp (gchar *timestamp) +{ + return (time_t) atoi (timestamp); } diff --git a/sflphone-client-gnome/src/callable_obj.h b/sflphone-client-gnome/src/callable_obj.h index 363011cc54..26bc8e1933 100644 --- a/sflphone-client-gnome/src/callable_obj.h +++ b/sflphone-client-gnome/src/callable_obj.h @@ -23,6 +23,7 @@ #include <gtk/gtk.h> #include <glib/gprintf.h> #include <stdlib.h> +#include <time.h> /** * @enum history_state @@ -86,8 +87,8 @@ typedef struct { call_state_t _state; // The state of the call gchar* _callID; // The call ID gchar* _accountID; // The account the call is made with - gchar* _time_start; // The timestamp the call was initiating - gchar* _time_stop; // The timestamp the call was over + time_t _time_start; // The timestamp the call was initiating + time_t _time_stop; // The timestamp the call was over history_state_t _history_state; // The history state if necessary /** @@ -156,7 +157,7 @@ gchar* get_peer_info (gchar*, gchar*); history_state_t get_history_state_from_id (gchar *indice); -gchar* calcul_call_duration (gchar *start, gchar *end); +gchar* get_call_duration (callable_obj_t *obj); gchar* serialize_history_entry (callable_obj_t *entry); @@ -164,4 +165,11 @@ gchar* get_history_id_from_state (history_state_t state); gchar* get_formatted_start_timestamp (callable_obj_t *obj); +void set_timestamp (time_t*); + +gchar* convert_timestamp_to_gchar (time_t); + +time_t convert_gchar_to_timestamp (gchar*); + + #endif diff --git a/sflphone-client-gnome/src/contacts/calltree.c b/sflphone-client-gnome/src/contacts/calltree.c index 3e9cfe271a..3964ff6dce 100644 --- a/sflphone-client-gnome/src/contacts/calltree.c +++ b/sflphone-client-gnome/src/contacts/calltree.c @@ -388,7 +388,7 @@ calltree_update_call (calltab_t* tab, callable_obj_t * c) break; } date = get_formatted_start_timestamp (c); - duration = calcul_call_duration (c->_time_start, c->_time_stop); + duration = get_call_duration (c); duration = g_strconcat( date , duration , NULL); description = g_strconcat( description , duration, NULL); } @@ -481,7 +481,7 @@ calltree_add_call (calltab_t* tab, callable_obj_t * c) WARN("History - Should not happen!"); } date = get_formatted_start_timestamp (c); - duration = calcul_call_duration (c->_time_start, c->_time_stop); + duration = get_call_duration (c); duration = g_strconcat( date , duration , NULL); description = g_strconcat( description , duration, NULL); } diff --git a/sflphone-client-gnome/src/dbus/dbus.c b/sflphone-client-gnome/src/dbus/dbus.c index 8561f2bc0f..6d72471ac6 100644 --- a/sflphone-client-gnome/src/dbus/dbus.c +++ b/sflphone-client-gnome/src/dbus/dbus.c @@ -39,15 +39,15 @@ DBusGProxy * callManagerProxy; DBusGProxy * configurationManagerProxy; DBusGProxy * instanceProxy; -static void + static void incoming_call_cb (DBusGProxy *proxy UNUSED, - const gchar* accountID, - const gchar* callID, - const gchar* from, - void * foo UNUSED ) + const gchar* accountID, + const gchar* callID, + const gchar* from, + void * foo UNUSED ) { DEBUG ("Incoming call! %s",callID); - + callable_obj_t * c; gchar *peer_name, *peer_number; // We receive the from field under a formatted way. We want to extract the number and the name of the caller @@ -58,320 +58,322 @@ incoming_call_cb (DBusGProxy *proxy UNUSED, #if GTK_CHECK_VERSION(2,10,0) status_tray_icon_blink( TRUE ); #endif + + set_timestamp (&c->_time_start); notify_incoming_call (c); sflphone_incoming_call (c); } -static void + static void curent_selected_codec (DBusGProxy *proxy UNUSED, - const gchar* callID, - const gchar* codecName, - void * foo UNUSED ) + const gchar* callID, + const gchar* codecName, + void * foo UNUSED ) { - DEBUG ("%s codec decided for call %s",codecName,callID); - sflphone_display_selected_codec (codecName); + DEBUG ("%s codec decided for call %s",codecName,callID); + sflphone_display_selected_codec (codecName); } -static void + static void volume_changed_cb (DBusGProxy *proxy UNUSED, - const gchar* device, - const gdouble value, - void * foo UNUSED ) + const gchar* device, + const gdouble value, + void * foo UNUSED ) { - DEBUG ("Volume of %s changed to %f.",device, value); - set_slider(device, value); + DEBUG ("Volume of %s changed to %f.",device, value); + set_slider(device, value); } -static void + static void voice_mail_cb (DBusGProxy *proxy UNUSED, - const gchar* accountID, - const guint nb, - void * foo UNUSED ) + const gchar* accountID, + const guint nb, + void * foo UNUSED ) { - DEBUG ("%d Voice mail waiting!",nb); - sflphone_notify_voice_mail (accountID , nb); + DEBUG ("%d Voice mail waiting!",nb); + sflphone_notify_voice_mail (accountID , nb); } -static void + static void incoming_message_cb (DBusGProxy *proxy UNUSED, - const gchar* accountID UNUSED, - const gchar* msg, - void * foo UNUSED ) + const gchar* accountID UNUSED, + const gchar* msg, + void * foo UNUSED ) { - DEBUG ("Message %s!",msg); + DEBUG ("Message %s!",msg); } -static void + static void call_state_cb (DBusGProxy *proxy UNUSED, - const gchar* callID, - const gchar* state, - void * foo UNUSED ) + const gchar* callID, + const gchar* state, + void * foo UNUSED ) { - DEBUG ("Call %s state %s",callID, state); - callable_obj_t * c = calllist_get(current_calls, callID); - if(c) - { - if ( strcmp(state, "HUNGUP") == 0 ) - { - if(c->_state==CALL_STATE_CURRENT) - { - // peer hung up, the conversation was established, so _start has been initialized with the current time value - DEBUG("call state current"); - // TODO (void) time(&c->_); - calltree_update_call( history, c ); - } - stop_notification(); - sflphone_hung_up (c); - calltree_update_call( history, c ); - } - else if ( strcmp(state, "UNHOLD_CURRENT") == 0 ) - { - sflphone_current (c); - } - else if ( strcmp(state, "UNHOLD_RECORD") == 0 ) - { - sflphone_record (c); - } - else if ( strcmp(state, "HOLD") == 0 ) - { - sflphone_hold (c); - } - else if ( strcmp(state, "RINGING") == 0 ) - { - sflphone_ringing (c); - } - else if ( strcmp(state, "CURRENT") == 0 ) - { - sflphone_current (c); - } - else if ( strcmp(state, "FAILURE") == 0 ) + DEBUG ("Call %s state %s",callID, state); + callable_obj_t * c = calllist_get(current_calls, callID); + if(c) { - sflphone_fail (c); - } - else if ( strcmp(state, "BUSY") == 0 ) - { - sflphone_busy (c); + if ( strcmp(state, "HUNGUP") == 0 ) + { + if(c->_state==CALL_STATE_CURRENT) + { + // peer hung up, the conversation was established, so _start has been initialized with the current time value + DEBUG("call state current"); + set_timestamp (&c->_time_start); + calltree_update_call( history, c ); + } + stop_notification(); + sflphone_hung_up (c); + calltree_update_call( history, c ); + } + else if ( strcmp(state, "UNHOLD_CURRENT") == 0 ) + { + sflphone_current (c); + } + else if ( strcmp(state, "UNHOLD_RECORD") == 0 ) + { + sflphone_record (c); + } + else if ( strcmp(state, "HOLD") == 0 ) + { + sflphone_hold (c); + } + else if ( strcmp(state, "RINGING") == 0 ) + { + sflphone_ringing (c); + } + else if ( strcmp(state, "CURRENT") == 0 ) + { + sflphone_current (c); + } + else if ( strcmp(state, "FAILURE") == 0 ) + { + sflphone_fail (c); + } + else if ( strcmp(state, "BUSY") == 0 ) + { + sflphone_busy (c); + } } - } - else - { - // 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 ) + else { - callable_obj_t *new_call; - GHashTable *call_details; + // 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 ) + { + callable_obj_t *new_call; + GHashTable *call_details; - DEBUG ("New ringing call! accountID: %s", callID); + DEBUG ("New ringing call! accountID: %s", 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); + // 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); + // Restore the callID to be synchronous with the daemon + new_call->_callID = g_strdup(callID); - sflphone_incoming_call (new_call); + sflphone_incoming_call (new_call); + } } - } } -static void + static void accounts_changed_cb (DBusGProxy *proxy UNUSED, - void * foo UNUSED ) + void * foo UNUSED ) { - DEBUG ("Accounts changed"); - sflphone_fill_account_list(TRUE); - config_window_fill_account_list(); + DEBUG ("Accounts changed"); + sflphone_fill_account_list(TRUE); + config_window_fill_account_list(); - // Update the status bar in case something happened - // Should fix ticket #1215 - status_bar_display_account(); + // Update the status bar in case something happened + // Should fix ticket #1215 + status_bar_display_account(); } -static void + static void transfer_succeded_cb (DBusGProxy *proxy UNUSED, - void * foo UNUSED ) + void * foo UNUSED ) { - DEBUG ("Transfer succeded\n"); - sflphone_display_transfer_status("Transfer successfull\n"); + DEBUG ("Transfer succeded\n"); + sflphone_display_transfer_status("Transfer successfull\n"); } -static void + static void transfer_failed_cb (DBusGProxy *proxy UNUSED, - void * foo UNUSED ) + void * foo UNUSED ) { - DEBUG ("Transfer failed\n"); - sflphone_display_transfer_status("Transfer failed\n"); + DEBUG ("Transfer failed\n"); + sflphone_display_transfer_status("Transfer failed\n"); } -static void + static void error_alert(DBusGProxy *proxy UNUSED, - int errCode, - void * foo UNUSED ) + int errCode, + void * foo UNUSED ) { - ERROR ("Error notifying : (%i)", errCode); - sflphone_throw_exception( errCode ); + ERROR ("Error notifying : (%i)", errCode); + sflphone_throw_exception( errCode ); } -gboolean + gboolean dbus_connect () { - GError *error = NULL; - connection = NULL; - instanceProxy = NULL; + GError *error = NULL; + connection = NULL; + instanceProxy = NULL; - g_type_init (); + g_type_init (); - connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); + connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); - if (error) - { - ERROR ("Failed to open connection to bus: %s", + if (error) + { + ERROR ("Failed to open connection to bus: %s", error->message); - g_error_free (error); - return FALSE; - } - - /* Create a proxy object for the "bus driver" (name "org.freedesktop.DBus") */ - - - instanceProxy = dbus_g_proxy_new_for_name (connection, - "org.sflphone.SFLphone", - "/org/sflphone/SFLphone/Instance", - "org.sflphone.SFLphone.Instance"); - /* - instanceProxy = dbus_g_proxy_new_for_name_owner (connection, - "org.sflphone.SFLphone", - "/org/sflphone/SFLphone/Instance", - "org.sflphone.SFLphone.Instance", - &error); - */ - - if (instanceProxy==NULL) - { - ERROR ("Failed to get proxy to Instance"); - return FALSE; - } - - - DEBUG ("DBus connected to Instance"); - - - callManagerProxy = dbus_g_proxy_new_for_name (connection, - "org.sflphone.SFLphone", - "/org/sflphone/SFLphone/CallManager", - "org.sflphone.SFLphone.CallManager"); - - /* - callManagerProxy = dbus_g_proxy_new_for_name_owner (connection, - "org.sflphone.SFLphone", - "/org/sflphone/SFLphone/CallManager", - "org.sflphone.SFLphone.CallManager", - &error); - */ - if (callManagerProxy==NULL) - { - ERROR ("Failed to get proxy to CallManagers"); - return FALSE; - } - - DEBUG ("DBus connected to CallManager"); - /* Incoming call */ - dbus_g_object_register_marshaller(g_cclosure_user_marshal_VOID__STRING_STRING_STRING, - G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); - dbus_g_proxy_add_signal (callManagerProxy, - "incomingCall", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); - dbus_g_proxy_connect_signal (callManagerProxy, - "incomingCall", G_CALLBACK(incoming_call_cb), NULL, NULL); - - /* Current codec */ - dbus_g_object_register_marshaller(g_cclosure_user_marshal_VOID__STRING_STRING_STRING, - G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); - dbus_g_proxy_add_signal (callManagerProxy, - "currentSelectedCodec", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); - dbus_g_proxy_connect_signal (callManagerProxy, - "currentSelectedCodec", G_CALLBACK(curent_selected_codec), NULL, NULL); - - /* Register a marshaller for STRING,STRING */ - dbus_g_object_register_marshaller(g_cclosure_user_marshal_VOID__STRING_STRING, - G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); - dbus_g_proxy_add_signal (callManagerProxy, - "callStateChanged", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); - dbus_g_proxy_connect_signal (callManagerProxy, - "callStateChanged", G_CALLBACK(call_state_cb), NULL, NULL); - - dbus_g_object_register_marshaller(g_cclosure_user_marshal_VOID__STRING_INT, - G_TYPE_NONE, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INVALID); - dbus_g_proxy_add_signal (callManagerProxy, - "voiceMailNotify", G_TYPE_STRING, G_TYPE_INT, G_TYPE_INVALID); - dbus_g_proxy_connect_signal (callManagerProxy, - "voiceMailNotify", G_CALLBACK(voice_mail_cb), NULL, NULL); - - dbus_g_proxy_add_signal (callManagerProxy, - "incomingMessage", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); - dbus_g_proxy_connect_signal (callManagerProxy, - "incomingMessage", G_CALLBACK(incoming_message_cb), NULL, NULL); - - dbus_g_object_register_marshaller(g_cclosure_user_marshal_VOID__STRING_DOUBLE, - G_TYPE_NONE, G_TYPE_STRING, G_TYPE_DOUBLE, G_TYPE_INVALID); - dbus_g_proxy_add_signal (callManagerProxy, - "volumeChanged", G_TYPE_STRING, G_TYPE_DOUBLE, G_TYPE_INVALID); - dbus_g_proxy_connect_signal (callManagerProxy, - "volumeChanged", G_CALLBACK(volume_changed_cb), NULL, NULL); - - dbus_g_proxy_add_signal (callManagerProxy, - "transferSucceded", G_TYPE_INVALID); - dbus_g_proxy_connect_signal (callManagerProxy, - "transferSucceded", G_CALLBACK(transfer_succeded_cb), NULL, NULL); - - dbus_g_proxy_add_signal (callManagerProxy, - "transferFailed", G_TYPE_INVALID); - dbus_g_proxy_connect_signal (callManagerProxy, - "transferFailed", G_CALLBACK(transfer_failed_cb), NULL, NULL); - - - configurationManagerProxy = dbus_g_proxy_new_for_name (connection, - "org.sflphone.SFLphone", - "/org/sflphone/SFLphone/ConfigurationManager", - "org.sflphone.SFLphone.ConfigurationManager"); - - - /* - configurationManagerProxy = dbus_g_proxy_new_for_name_owner (connection, - "org.sflphone.SFLphone", - "/org/sflphone/SFLphone/ConfigurationManager", - "org.sflphone.SFLphone.ConfigurationManager", - &error); - */ - if (!configurationManagerProxy) - { - ERROR ("Failed to get proxy to ConfigurationManager"); - return FALSE; - } - DEBUG ("DBus connected to ConfigurationManager"); - dbus_g_proxy_add_signal (configurationManagerProxy, - "accountsChanged", G_TYPE_INVALID); - dbus_g_proxy_connect_signal (configurationManagerProxy, - "accountsChanged", G_CALLBACK(accounts_changed_cb), NULL, NULL); - - dbus_g_object_register_marshaller(g_cclosure_user_marshal_VOID__INT, - G_TYPE_NONE, G_TYPE_INT , G_TYPE_INVALID); - dbus_g_proxy_add_signal (configurationManagerProxy, - "errorAlert", G_TYPE_INT , G_TYPE_INVALID); - dbus_g_proxy_connect_signal (configurationManagerProxy, - "errorAlert", G_CALLBACK(error_alert), NULL, NULL); - return TRUE; -} - -void + g_error_free (error); + return FALSE; + } + + /* Create a proxy object for the "bus driver" (name "org.freedesktop.DBus") */ + + + instanceProxy = dbus_g_proxy_new_for_name (connection, + "org.sflphone.SFLphone", + "/org/sflphone/SFLphone/Instance", + "org.sflphone.SFLphone.Instance"); + /* + instanceProxy = dbus_g_proxy_new_for_name_owner (connection, + "org.sflphone.SFLphone", + "/org/sflphone/SFLphone/Instance", + "org.sflphone.SFLphone.Instance", + &error); + */ + + if (instanceProxy==NULL) + { + ERROR ("Failed to get proxy to Instance"); + return FALSE; + } + + + DEBUG ("DBus connected to Instance"); + + + callManagerProxy = dbus_g_proxy_new_for_name (connection, + "org.sflphone.SFLphone", + "/org/sflphone/SFLphone/CallManager", + "org.sflphone.SFLphone.CallManager"); + + /* + callManagerProxy = dbus_g_proxy_new_for_name_owner (connection, + "org.sflphone.SFLphone", + "/org/sflphone/SFLphone/CallManager", + "org.sflphone.SFLphone.CallManager", + &error); + */ + if (callManagerProxy==NULL) + { + ERROR ("Failed to get proxy to CallManagers"); + return FALSE; + } + + DEBUG ("DBus connected to CallManager"); + /* Incoming call */ + dbus_g_object_register_marshaller(g_cclosure_user_marshal_VOID__STRING_STRING_STRING, + G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_proxy_add_signal (callManagerProxy, + "incomingCall", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_proxy_connect_signal (callManagerProxy, + "incomingCall", G_CALLBACK(incoming_call_cb), NULL, NULL); + + /* Current codec */ + dbus_g_object_register_marshaller(g_cclosure_user_marshal_VOID__STRING_STRING_STRING, + G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_proxy_add_signal (callManagerProxy, + "currentSelectedCodec", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_proxy_connect_signal (callManagerProxy, + "currentSelectedCodec", G_CALLBACK(curent_selected_codec), NULL, NULL); + + /* Register a marshaller for STRING,STRING */ + dbus_g_object_register_marshaller(g_cclosure_user_marshal_VOID__STRING_STRING, + G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_proxy_add_signal (callManagerProxy, + "callStateChanged", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_proxy_connect_signal (callManagerProxy, + "callStateChanged", G_CALLBACK(call_state_cb), NULL, NULL); + + dbus_g_object_register_marshaller(g_cclosure_user_marshal_VOID__STRING_INT, + G_TYPE_NONE, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INVALID); + dbus_g_proxy_add_signal (callManagerProxy, + "voiceMailNotify", G_TYPE_STRING, G_TYPE_INT, G_TYPE_INVALID); + dbus_g_proxy_connect_signal (callManagerProxy, + "voiceMailNotify", G_CALLBACK(voice_mail_cb), NULL, NULL); + + dbus_g_proxy_add_signal (callManagerProxy, + "incomingMessage", G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_proxy_connect_signal (callManagerProxy, + "incomingMessage", G_CALLBACK(incoming_message_cb), NULL, NULL); + + dbus_g_object_register_marshaller(g_cclosure_user_marshal_VOID__STRING_DOUBLE, + G_TYPE_NONE, G_TYPE_STRING, G_TYPE_DOUBLE, G_TYPE_INVALID); + dbus_g_proxy_add_signal (callManagerProxy, + "volumeChanged", G_TYPE_STRING, G_TYPE_DOUBLE, G_TYPE_INVALID); + dbus_g_proxy_connect_signal (callManagerProxy, + "volumeChanged", G_CALLBACK(volume_changed_cb), NULL, NULL); + + dbus_g_proxy_add_signal (callManagerProxy, + "transferSucceded", G_TYPE_INVALID); + dbus_g_proxy_connect_signal (callManagerProxy, + "transferSucceded", G_CALLBACK(transfer_succeded_cb), NULL, NULL); + + dbus_g_proxy_add_signal (callManagerProxy, + "transferFailed", G_TYPE_INVALID); + dbus_g_proxy_connect_signal (callManagerProxy, + "transferFailed", G_CALLBACK(transfer_failed_cb), NULL, NULL); + + + configurationManagerProxy = dbus_g_proxy_new_for_name (connection, + "org.sflphone.SFLphone", + "/org/sflphone/SFLphone/ConfigurationManager", + "org.sflphone.SFLphone.ConfigurationManager"); + + + /* + configurationManagerProxy = dbus_g_proxy_new_for_name_owner (connection, + "org.sflphone.SFLphone", + "/org/sflphone/SFLphone/ConfigurationManager", + "org.sflphone.SFLphone.ConfigurationManager", + &error); + */ + if (!configurationManagerProxy) + { + ERROR ("Failed to get proxy to ConfigurationManager"); + return FALSE; + } + DEBUG ("DBus connected to ConfigurationManager"); + dbus_g_proxy_add_signal (configurationManagerProxy, + "accountsChanged", G_TYPE_INVALID); + dbus_g_proxy_connect_signal (configurationManagerProxy, + "accountsChanged", G_CALLBACK(accounts_changed_cb), NULL, NULL); + + dbus_g_object_register_marshaller(g_cclosure_user_marshal_VOID__INT, + G_TYPE_NONE, G_TYPE_INT , G_TYPE_INVALID); + dbus_g_proxy_add_signal (configurationManagerProxy, + "errorAlert", G_TYPE_INT , G_TYPE_INVALID); + dbus_g_proxy_connect_signal (configurationManagerProxy, + "errorAlert", G_CALLBACK(error_alert), NULL, NULL); + return TRUE; +} + + void dbus_clean () { g_object_unref (callManagerProxy); @@ -380,102 +382,102 @@ dbus_clean () } -void + void dbus_hold (const callable_obj_t * c) { - GError *error = NULL; - org_sflphone_SFLphone_CallManager_hold ( callManagerProxy, c->_callID, &error); - if (error) - { - ERROR ("Failed to call hold() on CallManager: %s", + GError *error = NULL; + org_sflphone_SFLphone_CallManager_hold ( callManagerProxy, c->_callID, &error); + if (error) + { + ERROR ("Failed to call hold() on CallManager: %s", error->message); - g_error_free (error); - } + g_error_free (error); + } } -void + void dbus_unhold (const callable_obj_t * c) { - GError *error = NULL; - org_sflphone_SFLphone_CallManager_unhold ( callManagerProxy, c->_callID, &error); - if (error) - { - ERROR ("Failed to call unhold() on CallManager: %s", + GError *error = NULL; + org_sflphone_SFLphone_CallManager_unhold ( callManagerProxy, c->_callID, &error); + if (error) + { + ERROR ("Failed to call unhold() on CallManager: %s", error->message); - g_error_free (error); - } + g_error_free (error); + } } -void + void dbus_hang_up (const callable_obj_t * c) { - GError *error = NULL; - org_sflphone_SFLphone_CallManager_hang_up ( callManagerProxy, c->_callID, &error); - if (error) - { - ERROR ("Failed to call hang_up() on CallManager: %s", + GError *error = NULL; + org_sflphone_SFLphone_CallManager_hang_up ( callManagerProxy, c->_callID, &error); + if (error) + { + ERROR ("Failed to call hang_up() on CallManager: %s", error->message); - g_error_free (error); - } + g_error_free (error); + } } -void + void dbus_transfert (const callable_obj_t * c) { - GError *error = NULL; - org_sflphone_SFLphone_CallManager_transfert ( callManagerProxy, c->_callID, c->_peer_number, &error); - if (error) - { - ERROR ("Failed to call transfert() on CallManager: %s", + GError *error = NULL; + org_sflphone_SFLphone_CallManager_transfert ( callManagerProxy, c->_callID, c->_peer_number, &error); + if (error) + { + ERROR ("Failed to call transfert() on CallManager: %s", error->message); - g_error_free (error); - } + g_error_free (error); + } } -void + void dbus_accept (const callable_obj_t * c) { #if GTK_CHECK_VERSION(2,10,0) - status_tray_icon_blink( FALSE ); + status_tray_icon_blink( FALSE ); #endif - GError *error = NULL; - org_sflphone_SFLphone_CallManager_accept ( callManagerProxy, c->_callID, &error); - if (error) - { - ERROR ("Failed to call accept(%s) on CallManager: %s", c->_callID, + GError *error = NULL; + org_sflphone_SFLphone_CallManager_accept ( callManagerProxy, c->_callID, &error); + if (error) + { + ERROR ("Failed to call accept(%s) on CallManager: %s", c->_callID, (error->message == NULL ? g_quark_to_string(error->domain): error->message)); - g_error_free (error); - } + g_error_free (error); + } } -void + void dbus_refuse (const callable_obj_t * c) { #if GTK_CHECK_VERSION(2,10,0) - status_tray_icon_blink( FALSE ); + status_tray_icon_blink( FALSE ); #endif - GError *error = NULL; - org_sflphone_SFLphone_CallManager_refuse ( callManagerProxy, c->_callID, &error); - if (error) - { - ERROR ("Failed to call refuse() on CallManager: %s", + GError *error = NULL; + org_sflphone_SFLphone_CallManager_refuse ( callManagerProxy, c->_callID, &error); + if (error) + { + ERROR ("Failed to call refuse() on CallManager: %s", error->message); - g_error_free (error); - } + g_error_free (error); + } } -void + void dbus_place_call (const callable_obj_t * c) { - GError *error = NULL; - org_sflphone_SFLphone_CallManager_place_call ( callManagerProxy, c->_accountID, c->_callID, c->_peer_number, &error); - if (error) - { - ERROR ("Failed to call placeCall() on CallManager: %s", + GError *error = NULL; + org_sflphone_SFLphone_CallManager_place_call ( callManagerProxy, c->_accountID, c->_callID, c->_peer_number, &error); + if (error) + { + ERROR ("Failed to call placeCall() on CallManager: %s", error->message); - g_error_free (error); - } + g_error_free (error); + } } gchar** dbus_account_list() @@ -486,13 +488,13 @@ gchar** dbus_account_list() if(!org_sflphone_SFLphone_ConfigurationManager_get_account_list ( configurationManagerProxy, &array, &error)) { if(error->domain == DBUS_GERROR && error->code == DBUS_GERROR_REMOTE_EXCEPTION) - { + { ERROR ("Caught remote method (get_account_list) exception %s: %s", dbus_g_error_get_name(error), error->message); - } + } else - { + { ERROR("Error while calling get_account_list: %s", error->message); - } + } g_error_free (error); return NULL; } @@ -511,13 +513,13 @@ GHashTable* dbus_account_details(gchar * accountID) if(!org_sflphone_SFLphone_ConfigurationManager_get_account_details( configurationManagerProxy, accountID, &details, &error)) { if(error->domain == DBUS_GERROR && error->code == DBUS_GERROR_REMOTE_EXCEPTION) - { + { ERROR ("Caught remote method (get_account_details) exception %s: %s", dbus_g_error_get_name(error), error->message); - } + } else - { + { ERROR("Error while calling get_account_details: %s", error->message); - } + } g_error_free (error); return NULL; } @@ -526,228 +528,228 @@ GHashTable* dbus_account_details(gchar * accountID) } } -void + void dbus_send_register ( gchar* accountID , const guint expire) { - GError *error = NULL; - org_sflphone_SFLphone_ConfigurationManager_send_register ( configurationManagerProxy, accountID, expire ,&error); - if (error) - { - ERROR ("Failed to call send_register() on ConfigurationManager: %s", + GError *error = NULL; + org_sflphone_SFLphone_ConfigurationManager_send_register ( configurationManagerProxy, accountID, expire ,&error); + if (error) + { + ERROR ("Failed to call send_register() on ConfigurationManager: %s", error->message); - g_error_free (error); - } + g_error_free (error); + } } -void + void dbus_remove_account(gchar * accountID) { - GError *error = NULL; - org_sflphone_SFLphone_ConfigurationManager_remove_account ( - configurationManagerProxy, - accountID, - &error); - if (error) - { - ERROR ("Failed to call remove_account() on ConfigurationManager: %s", - error->message); - g_error_free (error); - } + GError *error = NULL; + org_sflphone_SFLphone_ConfigurationManager_remove_account ( + configurationManagerProxy, + accountID, + &error); + if (error) + { + ERROR ("Failed to call remove_account() on ConfigurationManager: %s", + error->message); + g_error_free (error); + } } -void + void dbus_set_account_details(account_t *a) { - GError *error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_account_details ( - configurationManagerProxy, - a->accountID, - a->properties, - &error); - if (error) - { - ERROR ("Failed to call set_account_details() on ConfigurationManager: %s", + GError *error = NULL; + org_sflphone_SFLphone_ConfigurationManager_set_account_details ( + configurationManagerProxy, + a->accountID, + a->properties, + &error); + if (error) + { + ERROR ("Failed to call set_account_details() on ConfigurationManager: %s", error->message); - g_error_free (error); - } + g_error_free (error); + } } -gchar* + gchar* dbus_add_account(account_t *a) { - gchar* accountId; - GError *error = NULL; - org_sflphone_SFLphone_ConfigurationManager_add_account ( - configurationManagerProxy, - a->properties, - &accountId, - &error); - if (error) - { - ERROR ("Failed to call add_account() on ConfigurationManager: %s", + gchar* accountId; + GError *error = NULL; + org_sflphone_SFLphone_ConfigurationManager_add_account ( + configurationManagerProxy, + a->properties, + &accountId, + &error); + if (error) + { + ERROR ("Failed to call add_account() on ConfigurationManager: %s", error->message); - g_error_free (error); - } - return accountId; + g_error_free (error); + } + return accountId; } -void + void dbus_set_volume(const gchar * device, gdouble value) { - GError *error = NULL; - org_sflphone_SFLphone_CallManager_set_volume( - callManagerProxy, - device, - value, - &error); + GError *error = NULL; + org_sflphone_SFLphone_CallManager_set_volume( + callManagerProxy, + device, + value, + &error); - if (error) - { - ERROR ("Failed to call set_volume() on callManagerProxy: %s", + if (error) + { + ERROR ("Failed to call set_volume() on callManagerProxy: %s", error->message); - g_error_free (error); - } + g_error_free (error); + } } -gdouble + gdouble dbus_get_volume(const gchar * device) { - gdouble value; - GError *error = NULL; + gdouble value; + GError *error = NULL; - org_sflphone_SFLphone_CallManager_get_volume( - callManagerProxy, - device, - &value, - &error); + org_sflphone_SFLphone_CallManager_get_volume( + callManagerProxy, + device, + &value, + &error); - if (error) - { - ERROR ("Failed to call get_volume() on callManagerProxy: %s", + if (error) + { + ERROR ("Failed to call get_volume() on callManagerProxy: %s", error->message); - g_error_free (error); - } - return value; + g_error_free (error); + } + return value; } -void + void dbus_play_dtmf(const gchar * key) { - GError *error = NULL; + GError *error = NULL; - org_sflphone_SFLphone_CallManager_play_dt_mf( - callManagerProxy, - key, - &error); + org_sflphone_SFLphone_CallManager_play_dt_mf( + callManagerProxy, + key, + &error); - if (error) - { - ERROR ("Failed to call playDTMF() on callManagerProxy: %s", + if (error) + { + ERROR ("Failed to call playDTMF() on callManagerProxy: %s", error->message); - g_error_free (error); - } + g_error_free (error); + } } -void + void dbus_start_tone(const int start , const guint type ) { - GError *error = NULL; + GError *error = NULL; - org_sflphone_SFLphone_CallManager_start_tone( - callManagerProxy, - start, - type, - &error); + org_sflphone_SFLphone_CallManager_start_tone( + callManagerProxy, + start, + type, + &error); - if (error) - { - ERROR ("Failed to call startTone() on callManagerProxy: %s", + if (error) + { + ERROR ("Failed to call startTone() on callManagerProxy: %s", error->message); - g_error_free (error); - } + g_error_free (error); + } } -void + void dbus_register(int pid, gchar * name) { - GError *error = NULL; + GError *error = NULL; - org_sflphone_SFLphone_Instance_register( - instanceProxy, - pid, - name, - &error); + org_sflphone_SFLphone_Instance_register( + instanceProxy, + pid, + name, + &error); - if (error) - { - ERROR ("Failed to call register() on instanceProxy: %s", + if (error) + { + ERROR ("Failed to call register() on instanceProxy: %s", error->message); - g_error_free (error); - } + g_error_free (error); + } } -void + void dbus_unregister(int pid) { - GError *error = NULL; + GError *error = NULL; - org_sflphone_SFLphone_Instance_unregister( - instanceProxy, - pid, - &error); + org_sflphone_SFLphone_Instance_unregister( + instanceProxy, + pid, + &error); - if (error) - { - ERROR ("Failed to call unregister() on instanceProxy: %s", + if (error) + { + ERROR ("Failed to call unregister() on instanceProxy: %s", error->message); - g_error_free (error); - } + g_error_free (error); + } } -gchar** + gchar** dbus_codec_list() { - GError *error = NULL; - gchar** array; - org_sflphone_SFLphone_ConfigurationManager_get_codec_list ( - configurationManagerProxy, - &array, - &error); + GError *error = NULL; + gchar** array; + org_sflphone_SFLphone_ConfigurationManager_get_codec_list ( + configurationManagerProxy, + &array, + &error); - if (error) - { - ERROR ("Failed to call get_codec_list() on ConfigurationManager: %s", - error->message); - g_error_free (error); - } - return array; + if (error) + { + ERROR ("Failed to call get_codec_list() on ConfigurationManager: %s", + error->message); + g_error_free (error); + } + return array; } -gchar** + gchar** dbus_codec_details( int payload ) { - GError *error = NULL; - gchar ** array; - org_sflphone_SFLphone_ConfigurationManager_get_codec_details ( - configurationManagerProxy, - payload, - &array, - &error); - - if (error) - { - ERROR ("Failed to call get_codec_details() on ConfigurationManager: %s", - error->message); - g_error_free (error); - } - return array; + GError *error = NULL; + gchar ** array; + org_sflphone_SFLphone_ConfigurationManager_get_codec_details ( + configurationManagerProxy, + payload, + &array, + &error); + + if (error) + { + ERROR ("Failed to call get_codec_details() on ConfigurationManager: %s", + error->message); + g_error_free (error); + } + return array; } -gchar* + gchar* dbus_get_current_codec_name(const callable_obj_t * c) { @@ -757,10 +759,10 @@ dbus_get_current_codec_name(const callable_obj_t * c) GError* error = NULL; org_sflphone_SFLphone_CallManager_get_current_codec_name ( - callManagerProxy, - c->_callID, - &codecName, - &error); + callManagerProxy, + c->_callID, + &codecName, + &error); if(error) { g_error_free(error); @@ -773,119 +775,119 @@ dbus_get_current_codec_name(const callable_obj_t * c) -gchar** + gchar** dbus_get_active_codec_list() { - gchar ** array; - GError *error = NULL; - org_sflphone_SFLphone_ConfigurationManager_get_active_codec_list ( - configurationManagerProxy, - &array, - &error); + gchar ** array; + GError *error = NULL; + org_sflphone_SFLphone_ConfigurationManager_get_active_codec_list ( + configurationManagerProxy, + &array, + &error); - if (error) - { - ERROR ("Failed to call get_active_codec_list() on ConfigurationManager: %s", - error->message); - g_error_free (error); - } - return array; + if (error) + { + ERROR ("Failed to call get_active_codec_list() on ConfigurationManager: %s", + error->message); + g_error_free (error); + } + return array; } -void + void dbus_set_active_codec_list(const gchar** list) { - GError *error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_active_codec_list ( - configurationManagerProxy, - list, - &error); + GError *error = NULL; + org_sflphone_SFLphone_ConfigurationManager_set_active_codec_list ( + configurationManagerProxy, + list, + &error); - if (error) - { - ERROR ("Failed to call set_active_codec_list() on ConfigurationManager: %s", - error->message); - g_error_free (error); - } + if (error) + { + ERROR ("Failed to call set_active_codec_list() on ConfigurationManager: %s", + error->message); + g_error_free (error); + } } /** * Get a list of input supported audio plugins */ -gchar** + gchar** dbus_get_input_audio_plugin_list() { - gchar** array; - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_get_input_audio_plugin_list( - configurationManagerProxy, - &array, - &error); - if(error) - { - ERROR("Failed to call get_input_audio_plugin_list() on ConfigurationManager: %s", error->message); - g_error_free(error); - } - return array; + gchar** array; + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_get_input_audio_plugin_list( + configurationManagerProxy, + &array, + &error); + if(error) + { + ERROR("Failed to call get_input_audio_plugin_list() on ConfigurationManager: %s", error->message); + g_error_free(error); + } + return array; } /** * Get a list of output supported audio plugins */ -gchar** + gchar** dbus_get_output_audio_plugin_list() { - gchar** array; - GError* error = NULL; - - if(!org_sflphone_SFLphone_ConfigurationManager_get_output_audio_plugin_list( configurationManagerProxy, &array, &error)) - { - if(error->domain == DBUS_GERROR && error->code == DBUS_GERROR_REMOTE_EXCEPTION) - { - ERROR ("Caught remote method (get_output_audio_plugin_list) exception %s: %s", dbus_g_error_get_name(error), error->message); - } - else - { - ERROR("Error while calling get_out_audio_plugin_list: %s", error->message); - } - g_error_free (error); - return NULL; - } - else{ - return array; - } -} - -void + gchar** array; + GError* error = NULL; + + if(!org_sflphone_SFLphone_ConfigurationManager_get_output_audio_plugin_list( configurationManagerProxy, &array, &error)) + { + if(error->domain == DBUS_GERROR && error->code == DBUS_GERROR_REMOTE_EXCEPTION) + { + ERROR ("Caught remote method (get_output_audio_plugin_list) exception %s: %s", dbus_g_error_get_name(error), error->message); + } + else + { + ERROR("Error while calling get_out_audio_plugin_list: %s", error->message); + } + g_error_free (error); + return NULL; + } + else{ + return array; + } +} + + void dbus_set_input_audio_plugin(gchar* audioPlugin) { - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_input_audio_plugin( - configurationManagerProxy, - audioPlugin, - &error); - if(error) - { - ERROR("Failed to call set_input_audio_plugin() on ConfigurationManager: %s", error->message); - g_error_free(error); - } + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_set_input_audio_plugin( + configurationManagerProxy, + audioPlugin, + &error); + if(error) + { + ERROR("Failed to call set_input_audio_plugin() on ConfigurationManager: %s", error->message); + g_error_free(error); + } } -void + void dbus_set_output_audio_plugin(gchar* audioPlugin) { - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_output_audio_plugin( - configurationManagerProxy, - audioPlugin, - &error); - if(error) - { - ERROR("Failed to call set_output_audio_plugin() on ConfigurationManager: %s", error->message); - g_error_free(error); - } + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_set_output_audio_plugin( + configurationManagerProxy, + audioPlugin, + &error); + if(error) + { + ERROR("Failed to call set_output_audio_plugin() on ConfigurationManager: %s", error->message); + g_error_free(error); + } } /** @@ -893,491 +895,491 @@ dbus_set_output_audio_plugin(gchar* audioPlugin) */ gchar** dbus_get_audio_output_device_list() { - gchar** array; - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_get_audio_output_device_list( - configurationManagerProxy, - &array, - &error); - if(error) - { - ERROR("Failed to call get_audio_output_device_list() on ConfigurationManager: %s", error->message); - g_error_free(error); - } - return array; + gchar** array; + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_get_audio_output_device_list( + configurationManagerProxy, + &array, + &error); + if(error) + { + ERROR("Failed to call get_audio_output_device_list() on ConfigurationManager: %s", error->message); + g_error_free(error); + } + return array; } /** * Set audio output device from its index */ -void + void dbus_set_audio_output_device(const int index) { - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_audio_output_device( - configurationManagerProxy, - index, - &error); - if(error) - { - ERROR("Failed to call set_audio_output_device() on ConfigurationManager: %s", error->message); - g_error_free(error); - } + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_set_audio_output_device( + configurationManagerProxy, + index, + &error); + if(error) + { + ERROR("Failed to call set_audio_output_device() on ConfigurationManager: %s", error->message); + g_error_free(error); + } } /** * Get all input devices index supported by current audio manager */ -gchar** + gchar** dbus_get_audio_input_device_list() { - gchar** array; - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_get_audio_input_device_list( - configurationManagerProxy, - &array, - &error); - if(error) - { - ERROR("Failed to call get_audio_input_device_list() on ConfigurationManager: %s", error->message); - g_error_free(error); - } - return array; + gchar** array; + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_get_audio_input_device_list( + configurationManagerProxy, + &array, + &error); + if(error) + { + ERROR("Failed to call get_audio_input_device_list() on ConfigurationManager: %s", error->message); + g_error_free(error); + } + return array; } /** * Set audio input device from its index */ -void + void dbus_set_audio_input_device(const int index) { - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_audio_input_device( - configurationManagerProxy, - index, - &error); - if(error) - { - ERROR("Failed to call set_audio_input_device() on ConfigurationManager: %s", error->message); - g_error_free(error); - } + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_set_audio_input_device( + configurationManagerProxy, + index, + &error); + if(error) + { + ERROR("Failed to call set_audio_input_device() on ConfigurationManager: %s", error->message); + g_error_free(error); + } } /** * Get output device index and input device index */ -gchar** + gchar** dbus_get_current_audio_devices_index() { - gchar** array; - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_get_current_audio_devices_index( - configurationManagerProxy, - &array, - &error); - if(error) - { - ERROR("Failed to call get_current_audio_devices_index() on ConfigurationManager: %s", error->message); - g_error_free(error); - } - return array; + gchar** array; + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_get_current_audio_devices_index( + configurationManagerProxy, + &array, + &error); + if(error) + { + ERROR("Failed to call get_current_audio_devices_index() on ConfigurationManager: %s", error->message); + g_error_free(error); + } + return array; } /** * Get index */ -int + int dbus_get_audio_device_index(const gchar *name) { - int index; - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_get_audio_device_index( - configurationManagerProxy, - name, - &index, - &error); - if(error) - { - ERROR("Failed to call get_audio_device_index() on ConfigurationManager: %s", error->message); - g_error_free(error); - } - return index; + int index; + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_get_audio_device_index( + configurationManagerProxy, + name, + &index, + &error); + if(error) + { + ERROR("Failed to call get_audio_device_index() on ConfigurationManager: %s", error->message); + g_error_free(error); + } + return index; } /** * Get audio plugin */ -gchar* + gchar* dbus_get_current_audio_output_plugin() { - gchar* plugin=""; - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_get_current_audio_output_plugin( - configurationManagerProxy, - &plugin, - &error); - if(error) - { - ERROR("Failed to call get_current_audio_output_plugin() on ConfigurationManager: %s", error->message); - g_error_free(error); - } - return plugin; + gchar* plugin=""; + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_get_current_audio_output_plugin( + configurationManagerProxy, + &plugin, + &error); + if(error) + { + ERROR("Failed to call get_current_audio_output_plugin() on ConfigurationManager: %s", error->message); + g_error_free(error); + } + return plugin; } -gchar* + gchar* dbus_get_ringtone_choice() { - gchar* tone; - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_get_ringtone_choice( - configurationManagerProxy, - &tone, - &error); - if(error) - { - g_error_free(error); - } - return tone; + gchar* tone; + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_get_ringtone_choice( + configurationManagerProxy, + &tone, + &error); + if(error) + { + g_error_free(error); + } + return tone; } -void + void dbus_set_ringtone_choice( const gchar* tone ) { - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_ringtone_choice( - configurationManagerProxy, - tone, - &error); - if(error) - { - g_error_free(error); - } + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_set_ringtone_choice( + configurationManagerProxy, + tone, + &error); + if(error) + { + g_error_free(error); + } } -int + int dbus_is_ringtone_enabled() { - int res; - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_is_ringtone_enabled( - configurationManagerProxy, - &res, - &error); - if(error) - { - g_error_free(error); - } - return res; + int res; + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_is_ringtone_enabled( + configurationManagerProxy, + &res, + &error); + if(error) + { + g_error_free(error); + } + return res; } -void + void dbus_ringtone_enabled() { - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_ringtone_enabled( - configurationManagerProxy, - &error); - if(error) - { - g_error_free(error); - } + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_ringtone_enabled( + configurationManagerProxy, + &error); + if(error) + { + g_error_free(error); + } } -int + int dbus_is_iax2_enabled() { - int res; - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_is_iax2_enabled( - configurationManagerProxy, - &res, - &error); - if(error) - { - g_error_free(error); - } - return res; + int res; + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_is_iax2_enabled( + configurationManagerProxy, + &res, + &error); + if(error) + { + g_error_free(error); + } + return res; } -int + int dbus_get_dialpad() { - int state; - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_get_dialpad( - configurationManagerProxy, - &state, - &error); - if(error) - { - g_error_free(error); - } - return state; + int state; + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_get_dialpad( + configurationManagerProxy, + &state, + &error); + if(error) + { + g_error_free(error); + } + return state; } -void + void dbus_set_dialpad( ) { - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_dialpad( - configurationManagerProxy, - &error); - if(error) - { - g_error_free(error); - } + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_set_dialpad( + configurationManagerProxy, + &error); + if(error) + { + g_error_free(error); + } } -int + int dbus_get_searchbar() { - int state; - GError* error = NULL; - if(!org_sflphone_SFLphone_ConfigurationManager_get_searchbar( configurationManagerProxy, &state, &error)) + int state; + GError* error = NULL; + if(!org_sflphone_SFLphone_ConfigurationManager_get_searchbar( configurationManagerProxy, &state, &error)) { if(error->domain == DBUS_GERROR && error->code == DBUS_GERROR_REMOTE_EXCEPTION) - { + { ERROR ("Caught remote method (get_searchbar) exception %s: %s", dbus_g_error_get_name(error), error->message); - } + } else - { + { ERROR("Error while calling get_searchbar: %s", error->message); - } + } g_error_free (error); return -1; } - else + else { - return state; + return state; } } -void + void dbus_set_searchbar( ) { - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_searchbar( - configurationManagerProxy, - &error); - if(error) - { - g_error_free(error); - } + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_set_searchbar( + configurationManagerProxy, + &error); + if(error) + { + g_error_free(error); + } } -int + int dbus_get_volume_controls() { - int state; - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_get_volume_controls( - configurationManagerProxy, - &state, - &error); - if(error) - { - g_error_free(error); - } - return state; + int state; + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_get_volume_controls( + configurationManagerProxy, + &state, + &error); + if(error) + { + g_error_free(error); + } + return state; } -void + void dbus_set_volume_controls( ) { - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_volume_controls( - configurationManagerProxy, - &error); - if(error) - { - g_error_free(error); - } + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_set_volume_controls( + configurationManagerProxy, + &error); + if(error) + { + g_error_free(error); + } } -void + void dbus_set_record(const callable_obj_t * c) { - DEBUG("calling dbus_set_record on CallManager"); - DEBUG("CallID : %s", c->_callID); - GError* error = NULL; - org_sflphone_SFLphone_CallManager_set_recording ( - callManagerProxy, - c->_callID, - &error); - if(error) - { - g_error_free(error); - } + DEBUG("calling dbus_set_record on CallManager"); + DEBUG("CallID : %s", c->_callID); + GError* error = NULL; + org_sflphone_SFLphone_CallManager_set_recording ( + callManagerProxy, + c->_callID, + &error); + if(error) + { + g_error_free(error); + } } -gboolean + gboolean dbus_get_is_recording(const callable_obj_t * c) { - DEBUG("calling dbus_get_is_recording on CallManager"); - GError* error = NULL; - gboolean isRecording; - org_sflphone_SFLphone_CallManager_get_is_recording ( - callManagerProxy, - c->_callID, - &isRecording, - &error); - if(error) - { - g_error_free(error); - } - //DEBUG("RECORDING: %i",isRecording); - return isRecording; -} - -void + DEBUG("calling dbus_get_is_recording on CallManager"); + GError* error = NULL; + gboolean isRecording; + org_sflphone_SFLphone_CallManager_get_is_recording ( + callManagerProxy, + c->_callID, + &isRecording, + &error); + if(error) + { + g_error_free(error); + } + //DEBUG("RECORDING: %i",isRecording); + return isRecording; +} + + void dbus_set_record_path(const gchar* path) { - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_record_path ( - configurationManagerProxy, - path, - &error); - if(error) - { - g_error_free(error); - } + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_set_record_path ( + configurationManagerProxy, + path, + &error); + if(error) + { + g_error_free(error); + } } gchar* dbus_get_record_path(void) { - GError* error = NULL; - gchar *path; - org_sflphone_SFLphone_ConfigurationManager_get_record_path ( - configurationManagerProxy, - &path, - &error); - if(error) - { - g_error_free(error); - } - return path; + GError* error = NULL; + gchar *path; + org_sflphone_SFLphone_ConfigurationManager_get_record_path ( + configurationManagerProxy, + &path, + &error); + if(error) + { + g_error_free(error); + } + return path; } -void + void dbus_set_max_calls( const guint calls ) { - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_max_calls( - configurationManagerProxy, - calls, - &error); - if(error) - { - g_error_free(error); - } + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_set_max_calls( + configurationManagerProxy, + calls, + &error); + if(error) + { + g_error_free(error); + } } -guint + guint dbus_get_max_calls( void ) { - GError* error = NULL; - gint calls; - org_sflphone_SFLphone_ConfigurationManager_get_max_calls( - configurationManagerProxy, - &calls, - &error); - if(error) - { - g_error_free(error); - } - return (guint)calls; + GError* error = NULL; + gint calls; + org_sflphone_SFLphone_ConfigurationManager_get_max_calls( + configurationManagerProxy, + &calls, + &error); + if(error) + { + g_error_free(error); + } + return (guint)calls; } -void + void dbus_start_hidden( void ) { - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_start_hidden( - configurationManagerProxy, - &error); - if(error) - { - g_error_free(error); - } + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_start_hidden( + configurationManagerProxy, + &error); + if(error) + { + g_error_free(error); + } } -int + int dbus_is_start_hidden( void ) { - GError* error = NULL; - int state; - org_sflphone_SFLphone_ConfigurationManager_is_start_hidden( - configurationManagerProxy, - &state, - &error); - if(error) - { - g_error_free(error); - } - return state; + GError* error = NULL; + int state; + org_sflphone_SFLphone_ConfigurationManager_is_start_hidden( + configurationManagerProxy, + &state, + &error); + if(error) + { + g_error_free(error); + } + return state; } -int + int dbus_popup_mode( void ) { - GError* error = NULL; - int state; - org_sflphone_SFLphone_ConfigurationManager_popup_mode( - configurationManagerProxy, - &state, - &error); - if(error) - { - g_error_free(error); - } - return state; + GError* error = NULL; + int state; + org_sflphone_SFLphone_ConfigurationManager_popup_mode( + configurationManagerProxy, + &state, + &error); + if(error) + { + g_error_free(error); + } + return state; } -void + void dbus_switch_popup_mode( void ) { - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_switch_popup_mode( - configurationManagerProxy, - &error); - if(error) - { - g_error_free(error); - } + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_switch_popup_mode( + configurationManagerProxy, + &error); + if(error) + { + g_error_free(error); + } } -void + void dbus_set_notify( void ) { - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_notify( - configurationManagerProxy, - &error); - if(error) - { - g_error_free(error); - } + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_set_notify( + configurationManagerProxy, + &error); + if(error) + { + g_error_free(error); + } } -guint + guint dbus_get_notify( void ) { - gint level; - GError* error = NULL; - if( !org_sflphone_SFLphone_ConfigurationManager_get_notify( configurationManagerProxy,&level, &error) ) + gint level; + GError* error = NULL; + if( !org_sflphone_SFLphone_ConfigurationManager_get_notify( configurationManagerProxy,&level, &error) ) { if(error->domain == DBUS_GERROR && error->code == DBUS_GERROR_REMOTE_EXCEPTION) - { + { ERROR ("Caught remote method (get_notify) exception %s: %s", dbus_g_error_get_name(error), error->message); - } + } else - { + { ERROR ("Error while calling get_notify: %s", error->message); - } + } g_error_free (error); return 0; } @@ -1387,150 +1389,150 @@ dbus_get_notify( void ) } -void + void dbus_set_mail_notify( void ) { - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_mail_notify( - configurationManagerProxy, - &error); - if(error) - { - g_error_free(error); - } + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_set_mail_notify( + configurationManagerProxy, + &error); + if(error) + { + g_error_free(error); + } } -guint + guint dbus_get_mail_notify( void ) { - gint level; - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_get_mail_notify( - configurationManagerProxy, - &level, - &error); - if(error) - { - ERROR("Error calling dbus_get_mail_notif_level"); - g_error_free(error); - } + gint level; + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_get_mail_notify( + configurationManagerProxy, + &level, + &error); + if(error) + { + ERROR("Error calling dbus_get_mail_notif_level"); + g_error_free(error); + } - return (guint)level; + return (guint)level; } -void + void dbus_set_audio_manager( int api ) { - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_audio_manager( - configurationManagerProxy, - api, - &error); - if(error) - { - g_error_free(error); - } + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_set_audio_manager( + configurationManagerProxy, + api, + &error); + if(error) + { + g_error_free(error); + } } -int + int dbus_get_audio_manager( void ) { - int api; - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_get_audio_manager( - configurationManagerProxy, - &api, - &error); - if(error) - { - ERROR("Error calling dbus_get_audio_manager"); - g_error_free(error); - } + int api; + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_get_audio_manager( + configurationManagerProxy, + &api, + &error); + if(error) + { + ERROR("Error calling dbus_get_audio_manager"); + g_error_free(error); + } - return api; + return api; } -void + void dbus_set_pulse_app_volume_control( void ) { - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_pulse_app_volume_control( - configurationManagerProxy, - &error); - if(error) - { - g_error_free(error); - } + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_set_pulse_app_volume_control( + configurationManagerProxy, + &error); + if(error) + { + g_error_free(error); + } } -int + int dbus_get_pulse_app_volume_control( void ) { - int state; - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_get_pulse_app_volume_control( - configurationManagerProxy, - &state, - &error); - return state; + int state; + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_get_pulse_app_volume_control( + configurationManagerProxy, + &state, + &error); + return state; } -void + void dbus_set_sip_port( const guint portNum ) { - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_sip_port( - configurationManagerProxy, - portNum, - &error); - if(error) - { - g_error_free(error); - } + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_set_sip_port( + configurationManagerProxy, + portNum, + &error); + if(error) + { + g_error_free(error); + } } -guint + guint dbus_get_sip_port( void ) { - GError* error = NULL; - gint portNum; - org_sflphone_SFLphone_ConfigurationManager_get_sip_port( - configurationManagerProxy, - &portNum, - &error); - if(error) - { - g_error_free(error); - } - return (guint)portNum; + GError* error = NULL; + gint portNum; + org_sflphone_SFLphone_ConfigurationManager_get_sip_port( + configurationManagerProxy, + &portNum, + &error); + if(error) + { + g_error_free(error); + } + return (guint)portNum; } gchar* dbus_get_stun_server (void) { - GError* error = NULL; - gchar* server; - org_sflphone_SFLphone_ConfigurationManager_get_stun_server( - configurationManagerProxy, - &server, - &error); - if(error) - { - g_error_free(error); - } - return server; + GError* error = NULL; + gchar* server; + org_sflphone_SFLphone_ConfigurationManager_get_stun_server( + configurationManagerProxy, + &server, + &error); + if(error) + { + g_error_free(error); + } + return server; } void dbus_set_stun_server( gchar* server) { - GError* error = NULL; - org_sflphone_SFLphone_ConfigurationManager_set_stun_server( - configurationManagerProxy, - server, - &error); - if(error) - { - g_error_free(error); - } + GError* error = NULL; + org_sflphone_SFLphone_ConfigurationManager_set_stun_server( + configurationManagerProxy, + server, + &error); + if(error) + { + g_error_free(error); + } } gint dbus_stun_is_enabled (void) @@ -1538,14 +1540,14 @@ gint dbus_stun_is_enabled (void) GError* error = NULL; gint stun; org_sflphone_SFLphone_ConfigurationManager_is_stun_enabled( - configurationManagerProxy, - &stun, - &error); - if(error) - { - g_error_free(error); - } - return stun; + configurationManagerProxy, + &stun, + &error); + if(error) + { + g_error_free(error); + } + return stun; } void dbus_enable_stun (void) @@ -1553,12 +1555,12 @@ void dbus_enable_stun (void) GError* error = NULL; org_sflphone_SFLphone_ConfigurationManager_enable_stun( - configurationManagerProxy, - &error); - if(error) - { - g_error_free(error); - } + configurationManagerProxy, + &error); + if(error) + { + g_error_free(error); + } } GHashTable* dbus_get_addressbook_settings (void) { -- GitLab