aboutsummaryrefslogtreecommitdiffstats
path: root/shell/e-shell-nm.c
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@src.gnome.org>2008-08-23 23:36:32 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2008-08-23 23:36:32 +0800
commitfd6cd9e3a6dc06f9b8e44ec13ac881ebd6793e6e (patch)
treee97b9ea12c3007cee5933246893d18a63461ce3a /shell/e-shell-nm.c
parent036bb44de80f86a9fa5d92ce9e8848332f2a9cd2 (diff)
downloadgsoc2013-evolution-fd6cd9e3a6dc06f9b8e44ec13ac881ebd6793e6e.tar
gsoc2013-evolution-fd6cd9e3a6dc06f9b8e44ec13ac881ebd6793e6e.tar.gz
gsoc2013-evolution-fd6cd9e3a6dc06f9b8e44ec13ac881ebd6793e6e.tar.bz2
gsoc2013-evolution-fd6cd9e3a6dc06f9b8e44ec13ac881ebd6793e6e.tar.lz
gsoc2013-evolution-fd6cd9e3a6dc06f9b8e44ec13ac881ebd6793e6e.tar.xz
gsoc2013-evolution-fd6cd9e3a6dc06f9b8e44ec13ac881ebd6793e6e.tar.zst
gsoc2013-evolution-fd6cd9e3a6dc06f9b8e44ec13ac881ebd6793e6e.zip
Progress update:
- Discard libnm-glib method of monitoring network connectivity. - Decided to make EShell a singleton GObject after all. Makes the design cleaner, despite having to pass a singleton instance around. - Make the switcher button style persistent. svn path=/branches/kill-bonobo/; revision=36043
Diffstat (limited to 'shell/e-shell-nm.c')
-rw-r--r--shell/e-shell-nm.c79
1 files changed, 22 insertions, 57 deletions
diff --git a/shell/e-shell-nm.c b/shell/e-shell-nm.c
index e6a9c2930e..83bc8ac627 100644
--- a/shell/e-shell-nm.c
+++ b/shell/e-shell-nm.c
@@ -28,33 +28,21 @@
#include <stdio.h>
#include <string.h>
#include <glib.h>
-#include <e-shell-window.h>
-#include <Evolution.h>
+#include <e-shell.h>
#include <dbus/dbus.h>
#include <dbus/dbus-glib-lowlevel.h>
#include <dbus/dbus-glib.h>
#include <NetworkManager/NetworkManager.h>
-typedef enum _ShellLineStatus {
- E_SHELL_LINE_DOWN,
- E_SHELL_LINE_UP
-} ShellLineStatus;
-
-
-static gboolean init_dbus (EShellWindow *window);
-
-static DBusConnection *dbus_connection = NULL;
+static DBusConnection *dbus_connection;
+/* Forward Declaration */
+gboolean e_shell_dbus_initialize (EShell *shell);
static gboolean
-reinit_dbus (gpointer user_data)
+reinit_dbus (EShell *shell)
{
- if (init_dbus (user_data))
- return FALSE;
-
- /* keep trying to re-establish dbus connection */
-
- return TRUE;
+ return !e_shell_dbus_initialize (shell);
}
static DBusHandlerResult
@@ -62,18 +50,10 @@ e_shell_network_monitor (DBusConnection *connection G_GNUC_UNUSED,
DBusMessage *message, void *user_data)
{
DBusError error;
- const char *object;
- ShellLineStatus status;
- EShellWindow *window = NULL;
- EShell *shell = NULL;
- GNOME_Evolution_ShellState shell_state;
+ const gchar *object;
+ EShell *shell = user_data;
EShellLineStatus line_status;
-
- if (!user_data || !E_IS_SHELL_WINDOW (user_data))
- return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-
- window = E_SHELL_WINDOW (user_data);
- shell = e_shell_window_peek_shell (window);
+ gboolean device_active;
dbus_error_init (&error);
object = dbus_message_get_path (message);
@@ -83,15 +63,15 @@ e_shell_network_monitor (DBusConnection *connection G_GNUC_UNUSED,
dbus_connection_unref (dbus_connection);
dbus_connection = NULL;
- g_timeout_add (3000, reinit_dbus, window);
+ g_timeout_add (3000, (GSourceFunc) reinit_dbus, shell);
return DBUS_HANDLER_RESULT_HANDLED;
}
if (dbus_message_is_signal (message, NM_DBUS_INTERFACE, "DeviceNoLongerActive"))
- status = E_SHELL_LINE_DOWN;
+ device_active = FALSE;
else if (dbus_message_is_signal (message, NM_DBUS_INTERFACE, "DeviceNowActive"))
- status = E_SHELL_LINE_UP;
+ device_active = TRUE;
else
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
@@ -101,22 +81,21 @@ e_shell_network_monitor (DBusConnection *connection G_GNUC_UNUSED,
line_status = e_shell_get_line_status (shell);
- if (line_status == E_SHELL_LINE_STATUS_ONLINE && status == E_SHELL_LINE_DOWN) {
- shell_state = GNOME_Evolution_FORCED_OFFLINE;
- e_shell_go_offline (shell, window, shell_state);
- } else if (line_status == E_SHELL_LINE_STATUS_FORCED_OFFLINE && status == E_SHELL_LINE_UP) {
- shell_state = GNOME_Evolution_USER_ONLINE;
- e_shell_go_online (shell, window, shell_state);
- }
+ if (line_status == E_SHELL_LINE_STATUS_ONLINE && !device_active)
+ e_shell_set_line_status (shell, E_SHELL_LINE_STATUS_FORCED_OFFLINE);
+ else if (line_status == E_SHELL_LINE_STATUS_FORCED_OFFLINE && device_active)
+ e_shell_set_line_status (shell, E_SHELL_LINE_STATUS_ONLINE);
return DBUS_HANDLER_RESULT_HANDLED;
}
-static gboolean
-init_dbus (EShellWindow *window)
+gboolean
+e_shell_dbus_initialize (EShell *shell)
{
DBusError error;
+ g_return_val_if_fail (E_IS_SHELL (shell), FALSE);
+
if (dbus_connection != NULL)
return TRUE;
@@ -130,7 +109,7 @@ init_dbus (EShellWindow *window)
dbus_connection_setup_with_g_main (dbus_connection, NULL);
dbus_connection_set_exit_on_disconnect (dbus_connection, FALSE);
- if (!dbus_connection_add_filter (dbus_connection, e_shell_network_monitor, window, NULL))
+ if (!dbus_connection_add_filter (dbus_connection, e_shell_network_monitor, shell, NULL))
goto exception;
dbus_bus_add_match (dbus_connection,
@@ -145,24 +124,10 @@ init_dbus (EShellWindow *window)
return TRUE;
- exception:
+exception:
dbus_connection_unref (dbus_connection);
dbus_connection = NULL;
return FALSE;
}
-
-int e_shell_dbus_initialise (EShellWindow *window)
-{
- g_type_init ();
-
- return init_dbus (window);
-}
-
-void e_shell_dbus_dispose (EShellWindow *window)
-{
- //FIXME
- return;
-}
-