aboutsummaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorShreyas Srinivasan <sshreyas@novell.com>2005-12-22 10:12:34 +0800
committerShreyas Srinivasan <shres@src.gnome.org>2005-12-22 10:12:34 +0800
commit87a09855fa42b43e11769b39c89336660f3467e7 (patch)
tree8e2880c7b49f68d3e2c4b54101e5731f1a64bab6 /shell
parent3de1a0bf0ef4a1db6664cb51bfc33eeba0e56c9e (diff)
downloadgsoc2013-evolution-87a09855fa42b43e11769b39c89336660f3467e7.tar
gsoc2013-evolution-87a09855fa42b43e11769b39c89336660f3467e7.tar.gz
gsoc2013-evolution-87a09855fa42b43e11769b39c89336660f3467e7.tar.bz2
gsoc2013-evolution-87a09855fa42b43e11769b39c89336660f3467e7.tar.lz
gsoc2013-evolution-87a09855fa42b43e11769b39c89336660f3467e7.tar.xz
gsoc2013-evolution-87a09855fa42b43e11769b39c89336660f3467e7.tar.zst
gsoc2013-evolution-87a09855fa42b43e11769b39c89336660f3467e7.zip
Evolution is now Network Aware, the day of complete awareness beckons, The
2005-12-22 Shreyas Srinivasan <sshreyas@novell.com> * Evolution is now Network Aware, the day of complete awareness beckons, The machines are taking over... * Network Manager support for evolution svn path=/trunk/; revision=30926
Diffstat (limited to 'shell')
-rw-r--r--shell/ChangeLog30
-rw-r--r--shell/Evolution-Component.idl7
-rw-r--r--shell/Makefile.am10
-rw-r--r--shell/e-shell-nm-glib.c77
-rw-r--r--shell/e-shell-nm.c116
-rw-r--r--shell/e-shell-window-commands.c4
-rw-r--r--shell/e-shell-window.c17
-rw-r--r--shell/e-shell.c24
-rw-r--r--shell/e-shell.h4
9 files changed, 272 insertions, 17 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog
index 206ce41681..cd5e5ac61a 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -1,3 +1,33 @@
+2005-12-22 Shreyas Srinivasan <sshreyas@novell.com>
+
+ * Network Manager Support for shell
+
+ * Evolution-Component.idl (setLineStatus): Add enum ShellState
+ which can represent network down rather than just a boolean.
+
+ * e-shell-nm.c: Add new file handles offline/ online signals
+ generated by the Network Manager using the native dbus interface.
+
+ * e-shell-nm-glib.c: Add new file handles offline/ online signals
+ generated by the Network Manager using the glib interface.
+
+ * Makefile.am: Add e-shell-nm.c or e-shell-nm-glib.c to the list
+ of files built into evolution_sources depending on how evolution
+ is configured.
+
+ * e-shell-window_commands.c: Use new changed signature of
+ e_shell_go_offline.
+
+ * e-shell-window.c (setup_status_bar): Initialise the dbus
+ connection.
+
+ * e-shell.c (set_line_status): Handle network down triggered
+ Force_offline. New signatures for e_shell_go_offline and
+ e_shell_go_online.
+
+ * e-shell.h: New function signatures for e_shell_go_offline and
+ e_shell_go_online.
+
2005-12-21 Not Zed <NotZed@Ximian.com>
* e-shell-view.c (impl_ShellView_setTitle): take a component id
diff --git a/shell/Evolution-Component.idl b/shell/Evolution-Component.idl
index a64efebe42..e0c486a630 100644
--- a/shell/Evolution-Component.idl
+++ b/shell/Evolution-Component.idl
@@ -28,6 +28,11 @@ module Evolution {
CREATABLE_OBJECT,
CREATABLE_FOLDER
};
+ enum ShellState {
+ USER_OFFLINE,
+ FORCED_OFFLINE,
+ USER_ONLINE
+ };
/* A type of item that the component can create when asked by the user,
e.g. a mail message or an appointment. */
@@ -124,7 +129,7 @@ module Evolution {
/* Set the online status of the component asynchronously */
- void setLineStatus(in boolean online, in Listener listener);
+ void setLineStatus(in ShellState shell_state, in Listener listener);
};
};
diff --git a/shell/Makefile.am b/shell/Makefile.am
index 1082df8ed0..b1bbce14c6 100644
--- a/shell/Makefile.am
+++ b/shell/Makefile.am
@@ -48,6 +48,13 @@ $(IDL_GENERATED_H): $(IDLS)
$(IDL_GENERATED_C): $(IDL_GENERATED_H)
+if NM_SUPPORT_GLIB
+NM_SUPPORT_FILES = e-shell-nm-glib.c
+else
+if NM_SUPPORT
+NM_SUPPORT_FILES = e-shell-nm.c
+endif
+endif
# Data Server CORBA stuff
DATASERVER_IDL_GENERATED_H = \
@@ -112,6 +119,7 @@ libeshell_la_LIBADD = \
evolution_SOURCES = \
$(DATASERVER_IDL_GENERATED) \
+ $(NM_SUPPORT_FILES) \
e-component-registry.c \
e-component-registry.h \
e-config-upgrade.c \
@@ -139,7 +147,7 @@ evolution_SOURCES = \
e-sidebar.h \
es-event.c \
es-menu.c \
- main.c
+ main.c
evolution_LDADD = \
libeshell.la \
diff --git a/shell/e-shell-nm-glib.c b/shell/e-shell-nm-glib.c
new file mode 100644
index 0000000000..0922f737ed
--- /dev/null
+++ b/shell/e-shell-nm-glib.c
@@ -0,0 +1,77 @@
+/*
+ * Shreyas Srinivasan <sshreyas@novell.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * (C) Copyright 2005 Novell, Inc.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <NetworkManager/libnm_glib.h>
+#include <e-shell-window.h>
+
+
+static void e_shell_glib_network_monitor (libnm_glib_ctx *ctx, gpointer user_data)
+{
+ libnm_glib_state state;
+ EShellLineStatus line_status;
+ EShellWindow *window = E_SHELL_WINDOW (user_data);
+ EShell *shell = e_shell_window_peek_shell (window);
+ GNOME_Evolution_ShellState shell_state;
+
+ g_return_if_fail (ctx != NULL);
+
+ state = libnm_glib_get_network_state (ctx);
+ line_status = e_shell_get_line_status (shell);
+
+ if (line_status == E_SHELL_LINE_STATUS_ONLINE && state == LIBNM_NO_NETWORK_CONNECTION) {
+ shell_state = GNOME_Evolution_FORCED_OFFLINE;
+ e_shell_go_offline (shell, window, shell_state);
+ } else if (line_status == E_SHELL_LINE_STATUS_OFFLINE && state == LIBNM_ACTIVE_NETWORK_CONNECTION) {
+ shell_state = GNOME_Evolution_USER_ONLINE;
+ e_shell_go_online (shell, window, shell_state);
+ } else
+ return LIBNM_INVALID_CONTEXT;
+
+ return FALSE;
+}
+
+
+int e_shell_nm_glib_initialise (EShellWindow *window )
+{
+ libnm_glib_ctx *ctx;
+ guint id;
+
+ ctx = libnm_glib_init ();
+ if (!ctx)
+ {
+ fprintf (stderr, "Could not initialize libnm.\n");
+ return FALSE;
+ }
+
+ id = libnm_glib_register_callback (ctx, e_shell_glib_network_monitor, window, NULL);
+ libnm_glib_unregister_callback (ctx, id);
+
+ id = libnm_glib_register_callback (ctx, e_shell_glib_network_monitor, window, NULL);
+
+ return TRUE;
+}
diff --git a/shell/e-shell-nm.c b/shell/e-shell-nm.c
new file mode 100644
index 0000000000..1ce00eb594
--- /dev/null
+++ b/shell/e-shell-nm.c
@@ -0,0 +1,116 @@
+/*
+ * Shreyas Srinivasan <sshreyas@novell.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * (C) Copyright 2005 Novell, Inc.
+ */
+
+#define DBUS_API_SUBJECT_TO_CHANGE 1
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <glib.h>
+#include <e-shell-window.h>
+#include <Evolution.h>
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib-lowlevel.h>
+#include <dbus/dbus-glib.h>
+#include <NetworkManager/NetworkManager.h>
+
+int shell_dbus_initialize (EShellWindow *window);
+
+enum _ShellLineStatus {
+ E_SHELL_LINE_DOWN,
+ E_SHELL_LINE_UP
+};
+
+
+typedef enum _ShellLineStatus ShellLineStatus;
+
+static DBusHandlerResult e_shell_network_monitor (DBusConnection *connection G_GNUC_UNUSED,
+ DBusMessage *message,
+ void* user_data)
+{
+ DBusError error;
+ const char *object;
+ ShellLineStatus status;
+ EShellWindow *window = E_SHELL_WINDOW (user_data);
+ EShell *shell = e_shell_window_peek_shell ((EShellWindow *) user_data);
+ GNOME_Evolution_ShellState shell_state;
+ EShellLineStatus line_status;
+
+ dbus_error_init (&error);
+ object = dbus_message_get_path (message);
+
+ if (dbus_message_is_signal (message, NM_DBUS_INTERFACE, "DeviceNoLongerActive"))
+ status = E_SHELL_LINE_DOWN;
+ else if (dbus_message_is_signal (message, NM_DBUS_INTERFACE, "DeviceNowActive"))
+ status = E_SHELL_LINE_UP;
+ else
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
+
+ if (!dbus_message_get_args (message, &error, DBUS_TYPE_OBJECT_PATH,
+ &object, DBUS_TYPE_INVALID))
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
+ 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_OFFLINE && status == E_SHELL_LINE_UP) {
+ shell_state = GNOME_Evolution_USER_ONLINE;
+ e_shell_go_online (shell, window, shell_state);
+ }
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+}
+
+int e_shell_dbus_initialise (EShellWindow *window)
+{
+ DBusConnection *connection;
+ DBusError error;
+
+ g_type_init ();
+
+ dbus_error_init (&error);
+ connection = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
+ if (connection == NULL) {
+ dbus_error_free (&error);
+ return FALSE;
+ }
+
+ dbus_connection_setup_with_g_main (connection, NULL);
+
+ if (!dbus_connection_add_filter (connection, e_shell_network_monitor, window, NULL))
+ return FALSE;
+
+ dbus_bus_add_match (connection,
+ "type='signal',"
+ "interface='" NM_DBUS_INTERFACE "',"
+ "sender='" NM_DBUS_SERVICE "',"
+ "path='" NM_DBUS_PATH "'", &error);
+ if (dbus_error_is_set (&error)) {
+ dbus_error_free (&error);
+ return FALSE;
+ }
+
+ return TRUE;
+}
diff --git a/shell/e-shell-window-commands.c b/shell/e-shell-window-commands.c
index fc6b482b72..581066491f 100644
--- a/shell/e-shell-window-commands.c
+++ b/shell/e-shell-window-commands.c
@@ -640,7 +640,7 @@ command_work_offline (BonoboUIComponent *uih,
EShellWindow *window,
const char *path)
{
- e_shell_go_offline (e_shell_window_peek_shell (window), window);
+ e_shell_go_offline (e_shell_window_peek_shell (window), window, GNOME_Evolution_USER_OFFLINE);
}
static void
@@ -648,7 +648,7 @@ command_work_online (BonoboUIComponent *uih,
EShellWindow *window,
const char *path)
{
- e_shell_go_online (e_shell_window_peek_shell (window), window);
+ e_shell_go_online (e_shell_window_peek_shell (window), window, GNOME_Evolution_USER_ONLINE);
}
static void
diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c
index a0f70c7ccf..af9ece83de 100644
--- a/shell/e-shell-window.c
+++ b/shell/e-shell-window.c
@@ -449,10 +449,10 @@ offline_toggle_clicked_callback (GtkButton *button,
switch (e_shell_get_line_status (priv->shell)) {
case E_SHELL_LINE_STATUS_ONLINE:
- e_shell_go_offline (priv->shell, window);
+ e_shell_go_offline (priv->shell, window, GNOME_Evolution_USER_OFFLINE);
break;
case E_SHELL_LINE_STATUS_OFFLINE:
- e_shell_go_online (priv->shell, window);
+ e_shell_go_online (priv->shell, window, GNOME_Evolution_USER_ONLINE);
break;
default:
g_assert_not_reached ();
@@ -583,6 +583,16 @@ setup_statusbar_notebook (EShellWindow *window)
}
static void
+setup_nm_support (EShellWindow *window)
+{
+ #ifdef NM_SUPPORT_GLIB
+ e_shell_nm_glib_initialise (window);
+ #elif NM_SUPPORT
+ e_shell_dbus_initialise (window);
+ #endif
+}
+
+static void
setup_status_bar (EShellWindow *window)
{
EShellWindowPrivate *priv;
@@ -594,6 +604,9 @@ setup_status_bar (EShellWindow *window)
if(gconf_client_get_bool (gconf_client_get_default(),"/apps/evolution/shell/view_defaults/statusbar_visible",NULL))
gtk_widget_show (priv->status_bar);
+ /* setup dbus interface here*/
+ setup_nm_support (window);
+
setup_offline_toggle (window);
setup_menu_hint_label (window);
setup_statusbar_notebook (window);
diff --git a/shell/e-shell.c b/shell/e-shell.c
index 433baa9ccf..4fac50f646 100644
--- a/shell/e-shell.c
+++ b/shell/e-shell.c
@@ -311,9 +311,9 @@ impl_Shell_setLineStatus (PortableServer_Servant servant,
e_passwords_set_online(online);
if (online)
- e_shell_go_online (shell, NULL);
+ e_shell_go_online (shell, NULL, GNOME_Evolution_USER_ONLINE);
else
- e_shell_go_offline (shell, NULL);
+ e_shell_go_offline (shell, NULL, GNOME_Evolution_USER_OFFLINE);
}
static GNOME_Evolution_Component
@@ -707,7 +707,7 @@ e_shell_construct (EShell *shell,
e_passwords_set_online(start_online);
if (start_online)
- e_shell_go_online (shell, NULL);
+ e_shell_go_online (shell, NULL, GNOME_Evolution_USER_ONLINE);
return E_SHELL_CONSTRUCT_RESULT_OK;
}
@@ -1117,15 +1117,21 @@ set_line_status_complete(EvolutionListener *el, void *data)
}
static void
-set_line_status(EShell *shell, gboolean status)
+set_line_status(EShell *shell, GNOME_Evolution_ShellState shell_state)
{
EShellPrivate *priv;
GSList *component_infos;
GSList *p;
CORBA_Environment ev;
GConfClient *client;
+ gboolean status;
priv = shell->priv;
+
+ if (shell_state == GNOME_Evolution_FORCED_OFFLINE || shell_state == GNOME_Evolution_USER_OFFLINE)
+ status = FALSE;
+ else
+ status = TRUE;
if ((status && priv->line_status == E_SHELL_LINE_STATUS_ONLINE)
|| (!status && priv->line_status != E_SHELL_LINE_STATUS_ONLINE))
@@ -1150,7 +1156,7 @@ set_line_status(EShell *shell, gboolean status)
CORBA_exception_init (&ev);
- GNOME_Evolution_Component_setLineStatus(info->iface, status, bonobo_object_corba_objref((BonoboObject *)priv->line_status_listener), &ev);
+ GNOME_Evolution_Component_setLineStatus(info->iface, shell_state, bonobo_object_corba_objref((BonoboObject *)priv->line_status_listener), &ev);
if (ev._major == CORBA_NO_EXCEPTION)
priv->line_status_pending++;
@@ -1171,14 +1177,14 @@ set_line_status(EShell *shell, gboolean status)
**/
void
e_shell_go_offline (EShell *shell,
- EShellWindow *action_window)
+ EShellWindow *action_window, GNOME_Evolution_ShellState shell_state)
{
g_return_if_fail (shell != NULL);
g_return_if_fail (E_IS_SHELL (shell));
g_return_if_fail (action_window != NULL);
g_return_if_fail (action_window == NULL || E_IS_SHELL_WINDOW (action_window));
- set_line_status(shell, FALSE);
+ set_line_status(shell, shell_state);
}
/**
@@ -1190,13 +1196,13 @@ e_shell_go_offline (EShell *shell,
**/
void
e_shell_go_online (EShell *shell,
- EShellWindow *action_window)
+ EShellWindow *action_window, GNOME_Evolution_ShellState shell_state)
{
g_return_if_fail (shell != NULL);
g_return_if_fail (E_IS_SHELL (shell));
g_return_if_fail (action_window == NULL || E_IS_SHELL_WINDOW (action_window));
- set_line_status(shell, TRUE);
+ set_line_status(shell, shell_state);
}
void
diff --git a/shell/e-shell.h b/shell/e-shell.h
index 873b7f8a80..d9561f09ec 100644
--- a/shell/e-shell.h
+++ b/shell/e-shell.h
@@ -119,9 +119,9 @@ void e_shell_close_all_windows (EShell *shell);
EShellLineStatus e_shell_get_line_status (EShell *shell);
void e_shell_go_offline (EShell *shell,
- EShellWindow *action_window);
+ EShellWindow *action_window, GNOME_Evolution_ShellState shell_state);
void e_shell_go_online (EShell *shell,
- EShellWindow *action_window);
+ EShellWindow *action_window, GNOME_Evolution_ShellState shell_state);
void e_shell_send_receive (EShell *shell);