diff options
Diffstat (limited to 'shell/e-shell-nm.c')
-rw-r--r-- | shell/e-shell-nm.c | 54 |
1 files changed, 25 insertions, 29 deletions
diff --git a/shell/e-shell-nm.c b/shell/e-shell-nm.c index f51a565486..581e505111 100644 --- a/shell/e-shell-nm.c +++ b/shell/e-shell-nm.c @@ -30,48 +30,40 @@ #include <string.h> #include <glib.h> #include <e-shell.h> -#include <Evolution.h> #include <dbus/dbus.h> #include <dbus/dbus-glib-lowlevel.h> #include <dbus/dbus-glib.h> #include <NetworkManager/NetworkManager.h> -gboolean e_shell_dbus_initialise (EShell *shell); +static DBusConnection *dbus_connection; -static DBusConnection *dbus_connection = NULL; +/* Forward Declaration */ +gboolean e_shell_dbus_initialize (EShell *shell); static gboolean -reinit_dbus (gpointer user_data) +reinit_dbus (EShell *shell) { - EShell *shell = user_data; - - if (e_shell_dbus_initialise (shell)) - return FALSE; - - /* keep trying to re-establish dbus connection */ - - return TRUE; + return !e_shell_dbus_initialize (shell); } static DBusHandlerResult e_shell_network_monitor (DBusConnection *connection G_GNUC_UNUSED, - DBusMessage *message, void *user_data) + DBusMessage *message, + gpointer user_data) { - const char *object; - EShell *shell = user_data; - GNOME_Evolution_ShellState shell_state; - EShellLineStatus line_status; DBusError error = DBUS_ERROR_INIT; + EShell *shell = user_data; + const gchar *path; guint32 state; - object = dbus_message_get_path (message); + path = dbus_message_get_path (message); if (dbus_message_is_signal (message, DBUS_INTERFACE_LOCAL, "Disconnected") && - object && !strcmp (object, DBUS_PATH_LOCAL)) { + path != NULL && strcmp (path, DBUS_PATH_LOCAL) == 0) { dbus_connection_unref (dbus_connection); dbus_connection = NULL; - g_timeout_add_seconds (3, reinit_dbus, shell); + g_timeout_add_seconds (3, (GSourceFunc) reinit_dbus, shell); return DBUS_HANDLER_RESULT_HANDLED; } @@ -89,24 +81,28 @@ e_shell_network_monitor (DBusConnection *connection G_GNUC_UNUSED, return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } - line_status = e_shell_get_line_status (shell); - - if (line_status == E_SHELL_LINE_STATUS_ONLINE && (state == NM_STATE_ASLEEP || state == NM_STATE_DISCONNECTED)) { - shell_state = GNOME_Evolution_FORCED_OFFLINE; - e_shell_set_line_status (shell, shell_state); - } else if (line_status == E_SHELL_LINE_STATUS_FORCED_OFFLINE && state == NM_STATE_CONNECTED) { - shell_state = GNOME_Evolution_USER_ONLINE; - e_shell_set_line_status (shell, shell_state); + switch (state) { + case NM_STATE_CONNECTED: + e_shell_set_network_available (shell, TRUE); + break; + case NM_STATE_ASLEEP: + case NM_STATE_DISCONNECTED: + e_shell_set_network_available (shell, FALSE); + break; + default: + break; } return DBUS_HANDLER_RESULT_HANDLED; } gboolean -e_shell_dbus_initialise (EShell *shell) +e_shell_dbus_initialize (EShell *shell) { DBusError error = DBUS_ERROR_INIT; + g_return_val_if_fail (E_IS_SHELL (shell), FALSE); + if (dbus_connection != NULL) return TRUE; |