diff --git a/sflphone-client-gnome/src/actions.c b/sflphone-client-gnome/src/actions.c index 5c7ba8e6a422f71da09e829801fbfbc811390790..1291e941e626e0fce708a8de0a2d3878a9969455 100644 --- a/sflphone-client-gnome/src/actions.c +++ b/sflphone-client-gnome/src/actions.c @@ -313,35 +313,38 @@ void sflphone_fill_account_list (void) sflphone_fill_codec_list (); } -gboolean sflphone_init (GError **error) +gboolean sflphone_init() { - if (!dbus_connect (error)) - return FALSE; - if (!dbus_register (getpid (), "Gtk+ Client", error)) + if (!dbus_connect ()) { + + main_window_error_message (_ ("Unable to connect to the SFLphone server.\nMake sure the daemon is running.")); return FALSE; + } else { + dbus_register (getpid(), "Gtk+ Client"); - // Init icons factory - init_icon_factory (); + // Init icons factory + init_icon_factory (); - current_calls = calltab_init (FALSE, CURRENT_CALLS); - contacts = calltab_init (TRUE, CONTACTS); - history = calltab_init (TRUE, HISTORY); + current_calls = calltab_init (FALSE, CURRENT_CALLS); + contacts = calltab_init (TRUE, CONTACTS); + history = calltab_init (TRUE, HISTORY); - account_list_init (); - codec_capabilities_load (); - conferencelist_init (); + account_list_init (); + codec_capabilities_load (); + conferencelist_init (); - // Fetch the configured accounts - sflphone_fill_account_list (); + // Fetch the configured accounts + sflphone_fill_account_list (); - // Fetch the ip2ip profile - sflphone_fill_ip2ip_profile(); + // Fetch the ip2ip profile + sflphone_fill_ip2ip_profile(); - // Fetch the conference list - // sflphone_fill_conference_list(); + // Fetch the conference list + // sflphone_fill_conference_list(); - return TRUE; + return TRUE; + } } void sflphone_fill_ip2ip_profile (void) diff --git a/sflphone-client-gnome/src/codeclist.c b/sflphone-client-gnome/src/codeclist.c index 61d389eb663953538a263bc2530f2ce1848d8a0e..d6fcadb3c910296f2e32b715a04c9c6598afa6ee 100644 --- a/sflphone-client-gnome/src/codeclist.c +++ b/sflphone-client-gnome/src/codeclist.c @@ -82,16 +82,14 @@ void codec_capabilities_load (void) // This is a global list inherited by all accounts codecs = (gchar**) dbus_codec_list (); - if (codecs != NULL) { - // Add the codecs in the list - for (pl=codecs; *codecs; codecs++) { - - codec_t *c; - payload = atoi (*codecs); - specs = (gchar **) dbus_codec_details (payload); - codec_create_new_with_specs (payload, specs, TRUE, &c); - g_queue_push_tail (codecsCapabilities, (gpointer*) c); - } + // Add the codecs in the list + for (pl=codecs; *codecs; codecs++) { + + codec_t *c; + payload = atoi (*codecs); + specs = (gchar **) dbus_codec_details (payload); + codec_create_new_with_specs (payload, specs, TRUE, &c); + g_queue_push_tail (codecsCapabilities, (gpointer*) c); } // If we didn't load any codecs, problem ... @@ -100,7 +98,7 @@ void codec_capabilities_load (void) // Error message ERROR ("No audio codecs found"); dbus_unregister (getpid()); - exit (1); + exit (0); } } diff --git a/sflphone-client-gnome/src/dbus/dbus.c b/sflphone-client-gnome/src/dbus/dbus.c index df9f73ad67c058d95a3d76a55c5e6b7ad70c6911..1583b92eb089f3db4871031f08a1c97817113482 100644 --- a/sflphone-client-gnome/src/dbus/dbus.c +++ b/sflphone-client-gnome/src/dbus/dbus.c @@ -511,17 +511,23 @@ error_alert (DBusGProxy *proxy UNUSED, int errCode, void * foo UNUSED) } gboolean -dbus_connect (GError **error) +dbus_connect() { + + GError *error = NULL; connection = NULL; instanceProxy = NULL; g_type_init(); - connection = dbus_g_bus_get (DBUS_BUS_SESSION, error); + connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); - if (connection == NULL) + 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") */ @@ -539,7 +545,11 @@ dbus_connect (GError **error) callManagerProxy = dbus_g_proxy_new_for_name (connection, "org.sflphone.SFLphone", "/org/sflphone/SFLphone/CallManager", "org.sflphone.SFLphone.CallManager"); - g_assert (callManagerProxy != NULL); + + if (callManagerProxy == NULL) { + ERROR ("Failed to get proxy to CallManagers"); + return FALSE; + } DEBUG ("DBus connected to CallManager"); /* STRING STRING STRING Marshaller */ @@ -677,7 +687,11 @@ dbus_connect (GError **error) configurationManagerProxy = dbus_g_proxy_new_for_name (connection, "org.sflphone.SFLphone", "/org/sflphone/SFLphone/ConfigurationManager", "org.sflphone.SFLphone.ConfigurationManager"); - g_assert (configurationManagerProxy != NULL); + + if (!configurationManagerProxy) { + ERROR ("Failed to get proxy to ConfigurationManager"); + return FALSE; + } DEBUG ("DBus connected to ConfigurationManager"); dbus_g_proxy_add_signal (configurationManagerProxy, "accountsChanged", @@ -1157,10 +1171,18 @@ dbus_start_tone (const int start, const guint type) } } -gboolean -dbus_register (int pid, gchar *name, GError **error) +void +dbus_register (int pid, gchar * name) { - return org_sflphone_SFLphone_Instance_register (instanceProxy, pid, name, error); + GError *error = NULL; + + org_sflphone_SFLphone_Instance_register (instanceProxy, pid, name, &error); + + if (error) { + ERROR ("Failed to call register() on instanceProxy: %s", + error->message); + g_error_free (error); + } } void @@ -1852,7 +1874,7 @@ dbus_get_addressbook_list (void) { GError *error = NULL; - gchar** array = NULL; + gchar** array; org_sflphone_SFLphone_ConfigurationManager_get_addressbook_list ( configurationManagerProxy, &array, &error); diff --git a/sflphone-client-gnome/src/dbus/dbus.h b/sflphone-client-gnome/src/dbus/dbus.h index 877842ab3347f3e0517e58667c8fe10fd45d3f3c..1389918066cc51259c79f3defb5bc13e8da2a137 100644 --- a/sflphone-client-gnome/src/dbus/dbus.h +++ b/sflphone-client-gnome/src/dbus/dbus.h @@ -50,7 +50,7 @@ * Try to connect to DBus services * @return TRUE if connection succeeded, FALSE otherwise */ -gboolean dbus_connect (GError **error); +gboolean dbus_connect (); /** * Unreferences the proxies @@ -417,9 +417,8 @@ void dbus_start_tone (const int start , const guint type); * Manage the instances of clients connected to the server * @param pid The pid of the processus client * @param name The string description of the client. Here : GTK+ Client - * @param error return location for a GError or NULL */ -gboolean dbus_register (int pid, gchar * name, GError **error); +void dbus_register (int pid, gchar * name); /** * Instance - Send unregistration request to dbus services diff --git a/sflphone-client-gnome/src/main.c b/sflphone-client-gnome/src/main.c index b34930234b7c30f7fef2684aa565f89e673ca584..b3b6b2ebb150358b78c2e8184bfd0ec63eb3a978 100644 --- a/sflphone-client-gnome/src/main.c +++ b/sflphone-client-gnome/src/main.c @@ -47,7 +47,6 @@ int main (int argc, char *argv[]) { - GError *error = NULL; // Handle logging int i; @@ -90,56 +89,42 @@ main (int argc, char *argv[]) GNOME_PROGRAM_STANDARD_PROPERTIES, NULL) ; - if (!sflphone_init (&error)) { - gchar *markup; + if (sflphone_init ()) { - ERROR (error->message); - markup = g_markup_printf_escaped ( - _ ("Unable to initialize.\nMake sure the daemon is running.\nError: %s"), - error->message); + if (eel_gconf_get_integer (SHOW_STATUSICON)) + show_status_icon (); - main_window_error_message (markup); + create_main_window (); - g_free (markup); - g_error_free (error); + if (eel_gconf_get_integer (SHOW_STATUSICON) && eel_gconf_get_integer (START_HIDDEN)) { + gtk_widget_hide (GTK_WIDGET (get_main_window())); + set_minimized (TRUE); + } - goto OUT; - } - - if (eel_gconf_get_integer (SHOW_STATUSICON)) - show_status_icon (); - - create_main_window (); - - if (eel_gconf_get_integer (SHOW_STATUSICON) && eel_gconf_get_integer (START_HIDDEN)) { - gtk_widget_hide (GTK_WIDGET (get_main_window())); - set_minimized (TRUE); - } + status_bar_display_account (); - status_bar_display_account (); + // Load the history + sflphone_fill_history (); - // Load the history - sflphone_fill_history (); + // Get the active calls and conferences at startup + sflphone_fill_call_list (); + sflphone_fill_conference_list (); - // Get the active calls and conferences at startup - sflphone_fill_call_list (); - sflphone_fill_conference_list (); + // Update the GUI + update_actions (); - // Update the GUI - update_actions (); + shortcuts_initialize_bindings(); - shortcuts_initialize_bindings(); + /* start the main loop */ + gtk_main (); + } - /* start the main loop */ - gtk_main (); + gdk_threads_leave (); shortcuts_destroy_bindings(); -OUT: - gdk_threads_leave (); - - return error != NULL; + return 0; } /** @mainpage SFLphone GTK+ Client Documentation