diff options
-rw-r--r-- | ChangeLog | 45 | ||||
-rw-r--r-- | configure.in | 25 | ||||
-rw-r--r-- | mail/ChangeLog | 6 | ||||
-rw-r--r-- | mail/mail-component.c | 32 | ||||
-rw-r--r-- | mail/mail-component.h | 1 | ||||
-rw-r--r-- | shell/ChangeLog | 30 | ||||
-rw-r--r-- | shell/Evolution-Component.idl | 7 | ||||
-rw-r--r-- | shell/Makefile.am | 10 | ||||
-rw-r--r-- | shell/e-shell-nm-glib.c | 77 | ||||
-rw-r--r-- | shell/e-shell-nm.c | 116 | ||||
-rw-r--r-- | shell/e-shell-window-commands.c | 4 | ||||
-rw-r--r-- | shell/e-shell-window.c | 17 | ||||
-rw-r--r-- | shell/e-shell.c | 24 | ||||
-rw-r--r-- | shell/e-shell.h | 4 |
14 files changed, 340 insertions, 58 deletions
@@ -1,42 +1,11 @@ -2004-06-28 Not Zed <NotZed@Ximian.com> - - * e-shell-view.c (impl_ShellView_setTitle): take a component id - argument. - - * e-shell-window.c (component_view_free): release the corba object - properly. - (e_shell_window_set_title): new helper to set the title for the - component. - (switch_view): use the component specific title if available or - fallback to the component name. - -2004-06-25 Not Zed <NotZed@Ximian.com> - - ** See bug #60354. - - * Evolution-Component.idl: createControls -> createView and - ComponentView to keep track of things. - - * Evolution-Shell.idl: return a new type ShellView from - createNewWindow so other parts of the system can access it later. - ShellView so far just lets you set title or switch component, but - could be subclassed later. - - * e-shell.c (impl_Shell_createNewWindow): return a shell view. - - * e-shell-window.c (init_view): create the view from the compnent - first, then get the controls from it separately. - (init): setup the e-shell-view object for the create view - thing. - - * e-shell-view.c (e_shell_view_new): simple bonobo object for - Evolution_ShellView, keep track of the EShellWindow. - - * e-component-view.[ch]: simple bonobo object for - Evolution_ComponentView. Just keep track of the controls. - - patch committed on behalf of Notzed - partha +2005-12-22 Shreyas Srinivasan <sshreyas@novell.com> + + * configure.in: Network Manager Support- Check if dbus, dbus-glib, + nm_glib is present and build Network Manager Support accordingly. + * ChangeLog: Remove spurious duplicate entries which seem to have + been committed accidently. + 2005-12-19 Chenthill Palanisamy <pchenthill@novell.com> committing for David Trowbridge <trowbrds cs colorado edu> diff --git a/configure.in b/configure.in index 56aa2e6bc7..317b5e1700 100644 --- a/configure.in +++ b/configure.in @@ -1143,7 +1143,7 @@ else HAL_REQUIREMENT="" IPOD_SYNC="" fi - + dnl --- Flags for the various libraries we build EVO_SET_COMPILE_FLAGS(CAMEL, camel-provider-$EDS_PACKAGE) @@ -1195,7 +1195,28 @@ AC_SUBST(LIBFILTER_LIBS) dnl --- evolution (shell) flags -EVO_SET_COMPILE_FLAGS(SHELL, libgnome-2.0 libgnomeui-2.0 libbonoboui-2.0 >= $BONOBOUI_REQUIRED libglade-2.0 gnome-vfs-2.0 libgtkhtml-$GTKHTML_PACKAGE >= $GTKHTML_REQUIRED) +NM_SUPPORT_PACKAGES="" + +PKG_CHECK_MODULES(NM, dbus-glib-1 libnm_glib, NM_SUPPORT_GLIB="yes", NM_SUPPORT_GLIB="no") +if test "x$NM_SUPPORT_GLIB" = "xyes"; then + AC_DEFINE(NM_SUPPORT_GLIB, 1, [network manager available]) + NM_SUPPORT_PACKAGES="dbus-1 dbus-glib-1 libnm_glib" +else + PKG_CHECK_MODULES(NM, dbus-glib-1, NM_SUPPORT="yes", NM_SUPPORT="no") + AC_CHECK_HEADER(NetworkManager/NetworkManager.h, [ nm_header="yes" ] ) +if test "x$NM_SUPPORT" = "xyes" -a "x{nm_header}" != "x"; then +dnl if test "x$NM_SUPPORT" = "xyes"; then + AC_DEFINE(NM_SUPPORT, 1, [network manager available]) + NM_SUPPORT_PACKAGES="dbus-1 dbus-glib-1" + fi +fi + +AM_CONDITIONAL(NM_SUPPORT_GLIB, test x$NM_SUPPORT_GLIB = xyes) +AM_CONDITIONAL(NM_SUPPORT, test x$NM_SUPPORT = xyes) + + +EVO_SET_COMPILE_FLAGS(SHELL, libgnome-2.0 libgnomeui-2.0 libbonoboui-2.0 >= $BONOBOUI_REQUIRED libglade-2.0 gnome-vfs-2.0 libgtkhtml-$GTKHTML_PACKAGE >= $GTKHTML_REQUIRED $NM_SUPPORT_PACKAGES) + AC_SUBST(SHELL_CFLAGS) AC_SUBST(SHELL_LIBS) diff --git a/mail/ChangeLog b/mail/ChangeLog index 80f33e7760..d1bc0381b3 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,9 @@ +2005-12-22 Shreyas Srinivasan <sshreyas@novell.com> + + * mail-component.[c,h]: Handle Network Disconnect + sent by the shell. Add function status_check which + handles various Network states. + 2005-12-21 Tor Lillqvist <tml@novell.com> * em-camel-stream.c (em_camel_stream_init) diff --git a/mail/mail-component.c b/mail/mail-component.c index 9a0533f338..96285c997a 100644 --- a/mail/mail-component.c +++ b/mail/mail-component.c @@ -73,6 +73,7 @@ #include <gtk/gtklabel.h> #include <e-util/e-mktemp.h> +#include <Evolution.h> #include <table/e-tree.h> #include <table/e-tree-memory.h> @@ -95,6 +96,9 @@ static void create_local_item_cb(EUserCreatableItemsHandler *handler, const char #define PARENT_TYPE evolution_component_get_type () static BonoboObjectClass *parent_class = NULL; +#define OFFLINE 0 +#define ONLINE 1 + struct _store_info { CamelStore *store; char *name; @@ -973,10 +977,36 @@ setline_check(void *key, void *value, void *data) } } +int +status_check (GNOME_Evolution_ShellState shell_state) +{ + int status; + + switch (shell_state) + { + case GNOME_Evolution_USER_OFFLINE: + status = OFFLINE; + break; + case GNOME_Evolution_FORCED_OFFLINE: + /*Network is down so change network state on the camel session*/ + status = OFFLINE; + /* Cancel all operations as they wont happen anyway cos Network is down*/ + mail_cancel_all (); + camel_session_set_network_state (session, FALSE); + break; + case GNOME_Evolution_USER_ONLINE: + camel_session_set_network_state (session, TRUE); + status = ONLINE; + } + + return status; +} + static void -impl_setLineStatus(PortableServer_Servant servant, CORBA_boolean status, GNOME_Evolution_Listener listener, CORBA_Environment *ev) +impl_setLineStatus(PortableServer_Servant servant, GNOME_Evolution_ShellState shell_state, GNOME_Evolution_Listener listener, CORBA_Environment *ev) { struct _setline_data *sd; + int status = status_check(shell_state); /* This will dis/enable further auto-mail-check action. */ /* FIXME: If send/receive active, wait for it to finish? */ diff --git a/mail/mail-component.h b/mail/mail-component.h index d8e0dbaba4..55cbe34597 100644 --- a/mail/mail-component.h +++ b/mail/mail-component.h @@ -98,4 +98,5 @@ struct _CamelStore *mail_component_peek_local_store (MailComponent *mc); struct _CamelFolder *mail_component_get_folder(MailComponent *mc, enum _mail_component_folder_t id); const char *mail_component_get_folder_uri(MailComponent *mc, enum _mail_component_folder_t id); +int status_check (GNOME_Evolution_ShellState shell_state); #endif /* _MAIL_COMPONENT_H_ */ 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); |