From ffe9df88b271e52aa8934762e73ed70b01464a60 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Tue, 22 Sep 2009 18:44:48 +0200 Subject: GN-bug #593617 - GroupWise plugins are not built --- configure.ac | 5 +- modules/calendar/e-cal-shell-content.c | 51 +- plugins/groupwise-account-setup/ChangeLog | 211 ---- plugins/groupwise-account-setup/Makefile.am | 34 - .../groupwise-account-setup/camel-gw-listener.c | 1047 -------------------- .../groupwise-account-setup/camel-gw-listener.h | 59 -- .../groupwise-account-setup.c | 138 --- .../org-gnome-gw-account-setup.eplug.xml | 34 - plugins/groupwise-features/Makefile.am | 10 +- plugins/groupwise-features/camel-gw-listener.c | 1047 ++++++++++++++++++++ plugins/groupwise-features/camel-gw-listener.h | 59 ++ .../groupwise-features/groupwise-account-setup.c | 138 +++ plugins/groupwise-features/gw-ui.c | 457 +++++++++ plugins/groupwise-features/gw-ui.h | 38 + plugins/groupwise-features/install-shared.c | 23 +- plugins/groupwise-features/junk-mail-settings.c | 74 +- plugins/groupwise-features/mail-retract.c | 86 +- plugins/groupwise-features/mail-send-options.c | 1 - .../org-gnome-groupwise-features.eplug.xml | 154 ++- plugins/groupwise-features/process-meeting.c | 198 +--- plugins/groupwise-features/proxy-login.c | 65 +- plugins/groupwise-features/proxy-login.h | 2 - plugins/groupwise-features/proxy.c | 1 - plugins/groupwise-features/share-folder-common.c | 72 +- plugins/groupwise-features/status-track.c | 109 +- po/POTFILES.in | 3 +- po/POTFILES.skip | 1 + ui/evolution-calendars.ui | 2 + 28 files changed, 2089 insertions(+), 2030 deletions(-) delete mode 100644 plugins/groupwise-account-setup/ChangeLog delete mode 100644 plugins/groupwise-account-setup/Makefile.am delete mode 100644 plugins/groupwise-account-setup/camel-gw-listener.c delete mode 100644 plugins/groupwise-account-setup/camel-gw-listener.h delete mode 100644 plugins/groupwise-account-setup/groupwise-account-setup.c delete mode 100644 plugins/groupwise-account-setup/org-gnome-gw-account-setup.eplug.xml create mode 100644 plugins/groupwise-features/camel-gw-listener.c create mode 100644 plugins/groupwise-features/camel-gw-listener.h create mode 100644 plugins/groupwise-features/groupwise-account-setup.c create mode 100644 plugins/groupwise-features/gw-ui.c create mode 100644 plugins/groupwise-features/gw-ui.h diff --git a/configure.ac b/configure.ac index 5ba9b0235c..12ef0d34f1 100644 --- a/configure.ac +++ b/configure.ac @@ -1746,7 +1746,7 @@ AC_ARG_ENABLE([plugins], [enable_plugins="$enableval"],[enable_plugins=all]) dnl Add any new plugins here -plugins_base_always="calendar-file calendar-http $CALENDAR_WEATHER itip-formatter plugin-manager default-source addressbook-file startup-wizard mark-all-read groupwise-features groupwise-account-setup publish-calendar caldav imap-features google-account-setup webdav-account-setup" +plugins_base_always="calendar-file calendar-http $CALENDAR_WEATHER itip-formatter plugin-manager default-source addressbook-file startup-wizard mark-all-read groupwise-features publish-calendar caldav imap-features google-account-setup webdav-account-setup" plugins_base="$plugins_base_always $SA_JUNK_PLUGIN $BF_JUNK_PLUGIN $EXCHANGE_PLUGIN" all_plugins_base="$plugins_base_always sa-junk-plugin bogo-junk-plugin exchange-operations" @@ -1784,7 +1784,7 @@ xexperimental) esac dnl Temporary KILL-BONOBO hack -for broken_plugin in exchange-operations groupwise-features +for broken_plugin in exchange-operations do if echo ${plugins_enabled} | grep "$broken_plugin" > /dev/null then @@ -2033,7 +2033,6 @@ plugins/exchange-operations/Makefile plugins/external-editor/Makefile plugins/face/Makefile plugins/google-account-setup/Makefile -plugins/groupwise-account-setup/Makefile plugins/groupwise-features/Makefile plugins/hula-account-setup/Makefile plugins/imap-features/Makefile diff --git a/modules/calendar/e-cal-shell-content.c b/modules/calendar/e-cal-shell-content.c index 8821a7fe07..689b5cf22a 100644 --- a/modules/calendar/e-cal-shell-content.c +++ b/modules/calendar/e-cal-shell-content.c @@ -57,7 +57,10 @@ struct _ECalShellContentPrivate { }; enum { - PROP_0 + PROP_0, + PROP_CALENDAR, + PROP_TASK_TABLE, + PROP_MEMO_TABLE }; /* Used to indicate who has the focus within the calendar view. */ @@ -226,6 +229,21 @@ cal_shell_content_get_property (GObject *object, GParamSpec *pspec) { switch (property_id) { + case PROP_CALENDAR: + g_value_set_object ( + value, e_cal_shell_content_get_calendar ( + E_CAL_SHELL_CONTENT (object))); + return; + case PROP_TASK_TABLE: + g_value_set_object ( + value, e_cal_shell_content_get_task_table ( + E_CAL_SHELL_CONTENT (object))); + return; + case PROP_MEMO_TABLE: + g_value_set_object ( + value, e_cal_shell_content_get_memo_table ( + E_CAL_SHELL_CONTENT (object))); + return; } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); @@ -505,6 +523,37 @@ cal_shell_content_class_init (ECalShellContentClass *class) widget_class = GTK_WIDGET_CLASS (class); widget_class->map = cal_shell_content_map; + + g_object_class_install_property ( + object_class, + PROP_CALENDAR, + g_param_spec_object ( + "calendar", + NULL, + NULL, + GNOME_TYPE_CALENDAR, + G_PARAM_READABLE)); + + g_object_class_install_property ( + object_class, + PROP_TASK_TABLE, + g_param_spec_object ( + "task-table", + NULL, + NULL, + E_TYPE_CALENDAR_TABLE, + G_PARAM_READABLE)); + + g_object_class_install_property ( + object_class, + PROP_MEMO_TABLE, + g_param_spec_object ( + "memo-table", + NULL, + NULL, + E_TYPE_MEMO_TABLE, + G_PARAM_READABLE)); + } static void diff --git a/plugins/groupwise-account-setup/ChangeLog b/plugins/groupwise-account-setup/ChangeLog deleted file mode 100644 index cde1135294..0000000000 --- a/plugins/groupwise-account-setup/ChangeLog +++ /dev/null @@ -1,211 +0,0 @@ -2009-01-29 Bharath Acharya - - ** Fix for bug #470474 (bugzilla.novell.com) - - * groupwise-account-setup.c (set_esource_props): a corruption. Cleanup - unused strings. - -2008-11-11 Suman Manjunath - - ** Fix for bug #440646 (bugzilla.novell.com) - - * camel-gw-listener.c (add_proxy_sources): Set the ESource color-spec - for proxy accounts in the correct format. - -2008-09-25 Philip Withnall - - ** Fix for bug #553148 - - * org-gnome-gw-account-setup.eplug.xml: Standardise "GroupWise" - usage in translatable strings. - -2008-09-02 Sankar P - -License Changes - - * camel-gw-listener.c: - -2008-08-27 Sankar P - -License Changes - - * camel-gw-listener.h: - * groupwise-account-setup.c: - -2008-07-31 Matthew Barnes - - ** Fixes part of bug #545568 - - * org-gnome-gw-account-setup.eplug.xml: - Add "system_plugin=true" so it's not shown in the Plugin Manager. - This plugin is not designed to be disabled by the user. - -2008-04-30 Chenthill Palanisamy - - ** Fixes #358644 (bnc) - Retracted groupwise appointments should disappear as soon as they are - retracted. - - * camel-gw-listener.c: (add_esource), (modify_esource), - (add_calendar_tasks_sources), (add_proxy_sources), (account_added), - (account_changed): - * groupwise-account-setup.c: (is_groupwise_account), - (set_esource_props), (ensure_mandatory_esource_properties): - * org-gnome-gw-account-setup.eplug.xml: - -2007-10-26 Kjartan Maraas - - * camel-gw-listener.c: (camel_gw_listener_new): - ANSIfication of function declaration. - -2007-08-23 Milan Crha - - ** Fix for bug #308636 - - * camel-gw-listener.c: (add_esource): - Set "create_source=yes" property to source group based on new parameter - and always set property "delete=no" to new source. - * camel-gw-listener.c: , (add_calendar_tasks_sources), - (add_proxy_sources): Uses add_source. - -2007-05-25 Matthew Barnes - - * camel-gw-listener.c (remove_esource), (modify_esource): - Don't assume the relative URI is non-NULL (#427232). - -2007-04-01 Matthew Barnes - - ** Fixes part of bug #373116 - - * camel-gw-listener.c (add_esource): - Use the new ESource color API. - -2007-02-09 Sankar P - - * camel-gw-listener.c: (add_esource), (remove_esource), - (add_proxy_sources): Picks a random color for proxy calendars, - Checks the Memo/Notes component for proxies - -2006-12-03 Harish Krishnaswamy - - * plugins/groupwise-account-setup/camel-gw-listener.c: - (add_esource), (add_calendar_tasks_sources), - (get_addressbook_names_from_server), (add_proxy_sources), - (prune_proxies), (camel_gw_listener_construct): - Add code to prune dead proxy entries (so they are executed - regardless of which component gets loaded first). Clean up - the existing code, fix leaks and ensure new proxy calendars - have their (different) color set. - -2006-09-19 Kjartan Maraas - - * org-gnome-gw-account-setup.eplug.xml: Mark description for - translation. - -2006-09-18 Matthew Barnes - - * camel-gw-listener.c: (finalize) - Chain up to parent's finalize() method. - -2006-07-22 Chenthill Palanisamy - - * camel-gw-listener.c: (add_calendar_tasks_sources), - (remove_calendar_tasks_sources), (add_proxy_sources), - (account_changed): Added support Gw notes. - -2006-04-19 Harish Krishnaswamy - - * camel-gw-listener.c: (add_esource): - Add default color to the GW source created. - Fixes #167102 (bugzilla.novell.com). - -2006-03-11 Sushma Rai - - * camel-gw-listener.c (get_addressbook_names_from_server): If use_ssl - parameter is found use https, otherwise use http. - Asking for password thrice on failure. Also freeing password key. - (account_changed): Checking for NULL old ssl paramter. Fixes a crash. - -2006-01-06 Simon Zheng - - * camel-gw-listener.c: - * camel-gw-listener.h: - use libedataserver/e-account-list.h instead of e-util/e-account-list.h. - use libedataserver/e-account.h instead of e-util/e-account.h. - -2005-12-21 Chenthill Palanisamy - - Committing for Sushma Rai - - Fixes #320119 - * camel-gw-listener.c: (add_addressbook_sources): Skip the - Novell System Addressbook which is a personal addressbook - returned from the server. - -2005-12-12 Harish Krishnaswamy - - * Makefile.am: Fix make-clean issues. - -2005-11-24 Sushma Rai - - * camel-gw-listener.c (add_addressbook_sources): Checking if the - frequent contacts folder is read from the server, and if not - displaying the warning message to user, asking to use some other - GroupWise mail clinet to get it created. - -2005-11-09 Parthasarathi Susarla - - * camel-gw-listener.c (get_addressbook_names_from_server): - check if string (eg. use_ssl) are NULL before strcmp(). - prevents a violation. - -2005-09-28 Sushma Rai - - * camel-gw-listener.c (add_addressbook_sources): Removed name - comparison and using writable property, to find the system - address book, while marking for offline usage. - -2005-09-16 Vivek Jain - - * camel-gw-listener.c:(get_addressbook_names_from_server) - uncache the password if it could not authenticate, else since we - remember it always it kept getting wrong one - use 'flags' variable which served no purpose till now - **Fixes #313078 - -2005-08-23 Not Zed - - * groupwise-account-setup.c (org_gnome_groupwise_account_setup): - def9ine before defining. - - * camel-gw-listener.c (account_added): fix warning. - -2005-07-27 Sankar P - - * camel-gw-listener.c (get_addressbook_names_from_server) : - Added code to get the password from the cache, instead of asking the user twice. - and also freeing the password that was leaking before. - Fixes #310353 - -2005-07-23 Sushma Rai - - * camel-gw-listener.c (add_addressbook_sources): marking - "Novell GroupWise Address Book" for offline usage by default. This is - needed as we now reply from cache always. - -2005-07-13 Tor Lillqvist - - * org-gnome-gw-account-setup.eplug.xml: Use SOEXT. - -2005-07-12 Vivek Jain - - * Makefile.am: included missing header file - -2005-07-12 Vivek Jain - - have a ChangeLog and transfer the changelog entry from the main - ChangeLog - (2005-07-10 Shreyas Srinivasan ) - * groupwise-account-setup/*: Make the - camel-groupwise-listener load on startup. (new plugin) - diff --git a/plugins/groupwise-account-setup/Makefile.am b/plugins/groupwise-account-setup/Makefile.am deleted file mode 100644 index ddf3161f8b..0000000000 --- a/plugins/groupwise-account-setup/Makefile.am +++ /dev/null @@ -1,34 +0,0 @@ -AM_CPPFLAGS = \ - -I$(top_srcdir) \ - $(EVOLUTION_MAIL_CFLAGS) \ - $(EVOLUTION_CALENDAR_CFLAGS) \ - $(EVOLUTION_ADDRESSBOOK_CFLAGS) \ - $(CAMEL_GROUPWISE_CFLAGS) \ - -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" - -@EVO_PLUGIN_RULE@ - -plugin_DATA = org-gnome-gw-account-setup.eplug -plugin_LTLIBRARIES = liborg-gnome-gw-account-setup.la - -liborg_gnome_gw_account_setup_la_SOURCES = \ - camel-gw-listener.c \ - camel-gw-listener.h \ - groupwise-account-setup.c - -liborg_gnome_gw_account_setup_la_LDFLAGS = -module -avoid-version $(NO_UNDEFINED) - -liborg_gnome_gw_account_setup_la_LIBADD= \ - $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/widgets/misc/libemiscwidgets.la \ - $(top_builddir)/filter/libfilter.la \ - $(EVOLUTION_CALENDAR_LIBS) \ - $(EVOLUTION_MAIL_LIBS) \ - $(CAMEL_GROUPWISE_LIBS) - -EXTRA_DIST = org-gnome-gw-account-setup.eplug.xml - -BUILT_SOURCES = $(plugin_DATA) -CLEANFILES = $(BUILT_SOURCES) - --include $(top_srcdir)/git.mk diff --git a/plugins/groupwise-account-setup/camel-gw-listener.c b/plugins/groupwise-account-setup/camel-gw-listener.c deleted file mode 100644 index 72b810feea..0000000000 --- a/plugins/groupwise-account-setup/camel-gw-listener.c +++ /dev/null @@ -1,1047 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - * - * Authors: - * Sivaiah Nallagatla - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "camel-gw-listener.h" -#include -#include -#include -#include -#include "e-util/e-error.h" -#include -#include - -/*stores some info about all currently existing groupwise accounts - list of GwAccountInfo structures */ - -static GList *groupwise_accounts = NULL; - -struct _CamelGwListenerPrivate { - GConfClient *gconf_client; - /* we get notification about mail account changes form this object */ - EAccountList *account_list; -}; - -struct _GwAccountInfo { - gchar *uid; - gchar *name; - gchar *source_url; - gboolean auto_check; - guint auto_check_time; -}; - -typedef struct _GwAccountInfo GwAccountInfo; - -#define GROUPWISE_URI_PREFIX "groupwise://" -#define GROUPWISE_PREFIX_LENGTH 12 - -#define PARENT_TYPE G_TYPE_OBJECT - -static GObjectClass *parent_class = NULL; - -static void dispose (GObject *object); -static void finalize (GObject *object); - -static void -camel_gw_listener_class_init (CamelGwListenerClass *class) -{ - GObjectClass *object_class; - - parent_class = g_type_class_ref (PARENT_TYPE); - object_class = G_OBJECT_CLASS (class); - - /* virtual method override */ - object_class->dispose = dispose; - object_class->finalize = finalize; -} - -static void -camel_gw_listener_init (CamelGwListener *config_listener, CamelGwListenerClass *class) -{ - config_listener->priv = g_new0 (CamelGwListenerPrivate, 1); -} - -static void -dispose (GObject *object) -{ - CamelGwListener *config_listener = CAMEL_GW_LISTENER (object); - - g_object_unref (config_listener->priv->gconf_client); - g_object_unref (config_listener->priv->account_list); - - G_OBJECT_CLASS (parent_class)->dispose (object); -} - -static void -finalize (GObject *object) -{ - CamelGwListener *config_listener = CAMEL_GW_LISTENER (object); - GList *list; - GwAccountInfo *info; - - if (config_listener->priv) { - g_free (config_listener->priv); - } - - for ( list = g_list_first (groupwise_accounts); list; list = g_list_next (list) ) { - - info = (GwAccountInfo *) (list->data); - - if (info) { - - g_free (info->uid); - g_free (info->name); - g_free (info->source_url); - g_free (info); - } - } - - g_list_free (groupwise_accounts); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -/*determines whehter the passed in account is groupwise or not by looking at source url */ - -static gboolean -is_groupwise_account (EAccount *account) -{ - if (account->source->url != NULL) { - return (strncmp (account->source->url, GROUPWISE_URI_PREFIX, GROUPWISE_PREFIX_LENGTH ) == 0); - } else { - return FALSE; - } -} - -/* looks up for an existing groupwise account info in the groupwise_accounts list based on uid */ - -static GwAccountInfo* -lookup_account_info (const gchar *key) -{ - GList *list; - GwAccountInfo *info; - gint found = 0; - - if (!key) - return NULL; - - info = NULL; - - for (list = g_list_first (groupwise_accounts); list; list = g_list_next (list)) { - info = (GwAccountInfo *) (list->data); - found = (strcmp (info->uid, key) == 0); - if (found) - break; - } - if (found) - return info; - return NULL; -} - -#define CALENDAR_SOURCES "/apps/evolution/calendar/sources" -#define TASKS_SOURCES "/apps/evolution/tasks/sources" -#define NOTES_SOURCES "/apps/evolution/memos/sources" -#define SELECTED_CALENDARS "/apps/evolution/calendar/display/selected_calendars" -#define SELECTED_TASKS "/apps/evolution/calendar/tasks/selected_tasks" -#define SELECTED_NOTES "/apps/evolution/calendar/memos/selected_memos" - -static void -add_esource (const gchar *conf_key, GwAccountInfo *info, const gchar *source_name, CamelURL *url, const gchar * parent_id_name, gboolean can_create) -{ - ESourceList *source_list; - ESourceGroup *group; - ESource *source; - GConfClient* client; - GSList *ids, *temp; - const gchar *source_selection_key; - gchar *relative_uri; - const gchar *soap_port; - const gchar * use_ssl; - const gchar *poa_address; - const gchar *offline_sync; - const gchar *group_name; - - poa_address = url->host; - if (!poa_address || strlen (poa_address) ==0) - return; - - group_name = info->name; - - soap_port = camel_url_get_param (url, "soap_port"); - - if (!soap_port || strlen (soap_port) == 0) - soap_port = "7191"; - - use_ssl = camel_url_get_param (url, "use_ssl"); - - offline_sync = camel_url_get_param (url, "offline_sync"); - - client = gconf_client_get_default(); - source_list = e_source_list_new_for_gconf (client, conf_key); - group = e_source_group_new (group_name, GROUPWISE_URI_PREFIX); - - if (!e_source_list_add_group (source_list, group, -1)) - return; - - if (!can_create) - e_source_group_set_property (group, "create_source", "no"); - - relative_uri = g_strdup_printf ("%s@%s/", url->user, poa_address); - source = e_source_new (source_name, relative_uri); - e_source_set_property (source, "auth", "1"); - e_source_set_property (source, "username", url->user); - e_source_set_property (source, "port", camel_url_get_param (url, "soap_port")); - e_source_set_property (source, "auth-domain", "Groupwise"); - e_source_set_property (source, "use_ssl", use_ssl); - - if (info->auto_check) { - gchar *str = g_strdup_printf ("%d", info->auto_check_time); - - e_source_set_property (source, "refresh", str); - g_free (str); - } else - e_source_set_property (source, "refresh", NULL); - - e_source_set_property (source, "offline_sync", offline_sync ? "1" : "0" ); - e_source_set_property (source, "delete", "no"); - if (parent_id_name) { - e_source_set_property (source, "parent_id_name", parent_id_name); - e_source_set_color_spec (source, camel_url_get_param (url, "color")); - } else - e_source_set_color_spec (source, "#EEBC60"); - e_source_group_add_source (group, source, -1); - e_source_list_sync (source_list, NULL); - - if (!strcmp (conf_key, CALENDAR_SOURCES)) - source_selection_key = SELECTED_CALENDARS; - else if (!strcmp (conf_key, TASKS_SOURCES)) - source_selection_key = SELECTED_TASKS; - else if (!strcmp (conf_key, NOTES_SOURCES)) - source_selection_key = SELECTED_NOTES; - else - source_selection_key = NULL; - - if (source_selection_key) { - ids = gconf_client_get_list (client, source_selection_key , GCONF_VALUE_STRING, NULL); - ids = g_slist_append (ids, g_strdup (e_source_peek_uid (source))); - gconf_client_set_list (client, source_selection_key, GCONF_VALUE_STRING, ids, NULL); - temp = ids; - - for (; temp != NULL; temp = g_slist_next (temp)) - g_free (temp->data); - - g_slist_free (ids); - } - - g_object_unref (source); - g_object_unref (group); - g_object_unref (source_list); - g_object_unref (client); - g_free (relative_uri); -} - -static void -remove_esource (const gchar *conf_key, const gchar *group_name, gchar * source_name, const gchar * relative_uri) -{ - ESourceList *list; - GSList *groups; - gboolean found_group; - GConfClient* client; - GSList *ids; - GSList *node_tobe_deleted; - const gchar *source_selection_key; - - client = gconf_client_get_default(); - list = e_source_list_new_for_gconf (client, conf_key); - groups = e_source_list_peek_groups (list); - - found_group = FALSE; - - for (; groups != NULL && !found_group; groups = g_slist_next (groups)) { - ESourceGroup *group = E_SOURCE_GROUP (groups->data); - - if (strcmp (e_source_group_peek_name (group), group_name) == 0 && - strcmp (e_source_group_peek_base_uri (group), GROUPWISE_URI_PREFIX ) == 0) { - GSList *sources = e_source_group_peek_sources (group); - - for (; sources != NULL; sources = g_slist_next (sources)) { - ESource *source = E_SOURCE (sources->data); - const gchar *source_relative_uri; - - source_relative_uri = e_source_peek_relative_uri (source); - if (source_relative_uri == NULL) - continue; - if (strcmp (source_relative_uri, relative_uri) == 0) { - - if (!strcmp (conf_key, CALENDAR_SOURCES)) - source_selection_key = SELECTED_CALENDARS; - else if (!strcmp (conf_key, TASKS_SOURCES)) - source_selection_key = SELECTED_TASKS; - else if (!strcmp (conf_key, NOTES_SOURCES)) - source_selection_key = SELECTED_NOTES; - else source_selection_key = NULL; - if (source_selection_key) { - ids = gconf_client_get_list (client, source_selection_key , - GCONF_VALUE_STRING, NULL); - node_tobe_deleted = g_slist_find_custom (ids, e_source_peek_uid (source), (GCompareFunc) strcmp); - if (node_tobe_deleted) { - g_free (node_tobe_deleted->data); - ids = g_slist_delete_link (ids, node_tobe_deleted); - } - gconf_client_set_list (client, source_selection_key, - GCONF_VALUE_STRING, ids, NULL); - - } - e_source_list_remove_group (list, group); - e_source_list_sync (list, NULL); - found_group = TRUE; - break; - - } - } - - } - - } - - g_object_unref (list); - g_object_unref (client); - -} - -/* looks up for e-source with having same info as old_account_info and changes its values passed in new values */ - -static void -modify_esource (const gchar * conf_key, GwAccountInfo *old_account_info, EAccount *a, CamelURL *new_url) -{ - ESourceList *list; - GSList *groups; - gchar *old_relative_uri; - CamelURL *url; - gboolean found_group; - GConfClient* client; - const gchar *poa_address; - const gchar *new_poa_address; - const gchar * new_group_name = a->name; - - url = camel_url_new (old_account_info->source_url, NULL); - poa_address = url->host; - if (!poa_address || strlen (poa_address) ==0) - return; - new_poa_address = new_url->host; - - old_relative_uri = g_strdup_printf ("%s@%s/", url->user, poa_address); - client = gconf_client_get_default (); - list = e_source_list_new_for_gconf (client, conf_key); - groups = e_source_list_peek_groups (list); - - found_group = FALSE; - - for (; groups != NULL && !found_group; groups = g_slist_next (groups)) { - ESourceGroup *group = E_SOURCE_GROUP (groups->data); - - if (strcmp (e_source_group_peek_name (group), old_account_info->name) == 0 && - strcmp (e_source_group_peek_base_uri (group), GROUPWISE_URI_PREFIX) == 0) { - GSList *sources = e_source_group_peek_sources (group); - - for (; sources != NULL; sources = g_slist_next (sources)) { - ESource *source = E_SOURCE (sources->data); - const gchar *source_relative_uri; - - source_relative_uri = e_source_peek_relative_uri (source); - if (source_relative_uri == NULL) - continue; - if (strcmp (source_relative_uri, old_relative_uri) == 0) { - gchar *new_relative_uri; - - new_relative_uri = g_strdup_printf ("%s@%s/", new_url->user, new_poa_address); - e_source_group_set_name (group, new_group_name); - e_source_set_relative_uri (source, new_relative_uri); - e_source_set_property (source, "username", new_url->user); - e_source_set_property (source, "port", camel_url_get_param (new_url,"soap_port")); - e_source_set_property (source, "use_ssl", camel_url_get_param (url, "use_ssl")); - e_source_set_property (source, "offline_sync", camel_url_get_param (url, "offline_sync") ? "1" : "0"); - - if (a->source->auto_check) { - gchar *str = g_strdup_printf ("%d", a->source->auto_check_time); - - e_source_set_property (source, "refresh", str); - g_free (str); - } else - e_source_set_property (source, "refresh", NULL); - - e_source_list_sync (list, NULL); - found_group = TRUE; - g_free (new_relative_uri); - break; - } - } - } - } - - g_object_unref (list); - g_object_unref (client); - camel_url_free (url); - g_free (old_relative_uri); - -} -/* add sources for calendar and tasks if the account added is groupwise account - adds the new account info to groupwise_accounts list */ - -static void -add_calendar_tasks_sources (GwAccountInfo *info) -{ - CamelURL *url; - - url = camel_url_new (info->source_url, NULL); - add_esource ("/apps/evolution/calendar/sources", info, _("Calendar"), url, NULL, FALSE); - add_esource ("/apps/evolution/tasks/sources", info, _("Tasks"), url, NULL, FALSE); - add_esource ("/apps/evolution/memos/sources", info, _("Notes"), url, NULL, TRUE); - - camel_url_free (url); - -} - -/* removes calendar and tasks sources if the account removed is groupwise account - removes the the account info from groupwise_account list */ - -static void -remove_calendar_tasks_sources (GwAccountInfo *info) -{ - CamelURL *url; - gchar *relative_uri; - const gchar *soap_port; - const gchar *poa_address; - - url = camel_url_new (info->source_url, NULL); - - poa_address = url->host; - if (!poa_address || strlen (poa_address) ==0) - return; - - soap_port = camel_url_get_param (url, "soap_port"); - if (!soap_port || strlen (soap_port) == 0) - soap_port = "7191"; - - relative_uri = g_strdup_printf ("%s@%s/", url->user, poa_address); - remove_esource ("/apps/evolution/calendar/sources", info->name, _("Calendar"), relative_uri); - remove_esource ("/apps/evolution/tasks/sources", info->name, _("Checklist"), relative_uri); - remove_esource ("/apps/evolution/memos/sources", info->name, _("Notes"), relative_uri); - - camel_url_free (url); - g_free (relative_uri); - -} - -static GList* -get_addressbook_names_from_server (gchar *source_url) -{ - gchar *key; - EGwConnection *cnc; - gchar *password; - GList *book_list = NULL; - gint status, count = 0; - const gchar *soap_port; - CamelURL *url; - gboolean remember; - gchar *failed_auth = NULL; - gchar *prompt; - gchar *password_prompt; - gchar *uri; - const gchar *use_ssl; - const gchar *poa_address; - guint32 flags = E_PASSWORDS_REMEMBER_FOREVER|E_PASSWORDS_SECRET; - - url = camel_url_new (source_url, NULL); - if (url == NULL) { - return NULL; - } - poa_address = url->host; - if (!poa_address || strlen (poa_address) ==0) - return NULL; - - soap_port = camel_url_get_param (url, "soap_port"); - if (!soap_port || strlen (soap_port) == 0) - soap_port = "7191"; - use_ssl = camel_url_get_param (url, "use_ssl"); - - key = g_strdup_printf ("groupwise://%s@%s/", url->user, poa_address); - - if (use_ssl && g_str_equal (use_ssl, "always")) - uri = g_strdup_printf ("https://%s:%s/soap", poa_address, soap_port); - else - uri = g_strdup_printf ("http://%s:%s/soap", poa_address, soap_port); - - cnc = NULL; - - do { - count ++; - /*we have to uncache the password before prompting again*/ - if (failed_auth) { - e_passwords_forget_password ("Groupwise", key); - password = NULL; - } - - password = e_passwords_get_password ("Groupwise", key); - if (!password) { - password_prompt = g_strdup_printf (_("Enter password for %s (user %s)"), - poa_address, url->user); - prompt = g_strconcat (failed_auth ? failed_auth : "", password_prompt, NULL); - g_free (password_prompt); - password = e_passwords_ask_password (prompt, "Groupwise", key, prompt, - flags, &remember, - NULL); - g_free (prompt); - - if (!password) - break; - } - - cnc = e_gw_connection_new (uri, url->user, password); - g_free (password); - if (!E_IS_GW_CONNECTION(cnc)) { - if (count == 3) - break; - } - - failed_auth = _("Failed to authenticate.\n"); - flags |= E_PASSWORDS_REPROMPT; - } while (cnc == NULL); - - g_free (key); - - if (E_IS_GW_CONNECTION(cnc)) { - book_list = NULL; - status = e_gw_connection_get_address_book_list (cnc, &book_list); - if (status == E_GW_CONNECTION_STATUS_OK) - return book_list; - } - - /*FIXME: This error message should be relocated to addressbook and should reflect - * that it actually failed to get the addressbooks*/ - e_error_run (NULL, "mail:gw-accountsetup-error", poa_address, NULL); - return NULL; -} - -static void -add_proxy_sources (GwAccountInfo *info, const gchar *parent_name) -{ - CamelURL *url; - gchar *color; - - url = camel_url_new (info->source_url, NULL); - - color = g_strdup_printf ("#%06X", g_random_int_range (0x100000, 0xffffaa)); - /* The above range is chosen so that the colors are neither too light nor too dark - and appealing in all the themes */ - - camel_url_set_param (url, "color", color); - - add_esource ("/apps/evolution/calendar/sources", info, _("Calendar"), url, parent_name, FALSE); - add_esource ("/apps/evolution/tasks/sources", info, _("Tasks"), url, parent_name, FALSE); - add_esource ("/apps/evolution/memos/sources", info, _("Notes"), url, parent_name, TRUE); - - g_free (color); - camel_url_free (url); -} - -static gboolean -add_addressbook_sources (EAccount *account) -{ - CamelURL *url; - ESourceList *list; - ESourceGroup *group; - ESource *source; - gchar *base_uri; - const gchar *soap_port; - GList *books_list, *temp_list; - GConfClient* client; - const gchar * use_ssl; - const gchar *poa_address; - gboolean is_frequent_contacts = FALSE, is_writable = FALSE; - - url = camel_url_new (account->source->url, NULL); - if (url == NULL) { - return FALSE; - } - - poa_address = url->host; - if (!poa_address || strlen (poa_address) ==0) - return FALSE; - - soap_port = camel_url_get_param (url, "soap_port"); - if (!soap_port || strlen (soap_port) == 0) - soap_port = "7191"; - use_ssl = camel_url_get_param (url, "use_ssl"); - base_uri = g_strdup_printf ("groupwise://%s@%s", url->user, poa_address); - client = gconf_client_get_default (); - list = e_source_list_new_for_gconf (client, "/apps/evolution/addressbook/sources" ); - group = e_source_group_new (account->name, base_uri); - books_list = get_addressbook_names_from_server (account->source->url); - temp_list = books_list; - if (!temp_list) - return FALSE; - for (; temp_list != NULL; temp_list = g_list_next (temp_list)) { - const gchar *book_name = e_gw_container_get_name (E_GW_CONTAINER(temp_list->data)); - /* is_writable is set to TRUE if the book has isPersonal property, - * by e_gw_connection_get_address_book_list() - */ - is_writable = e_gw_container_get_is_writable (E_GW_CONTAINER(temp_list->data)); - if (is_writable && - !g_ascii_strncasecmp (book_name, "Novell GroupWise Address Book", strlen (book_name))) { - /* This is a hack to not to show multiple groupwise system address books - * if they are the personal address books with the name of system address book - * See http://bugzilla.gnome.org/show_bug.cgi?id=320119 - * and http://bugzilla.gnome.org/show_bug.cgi?id=309511 - */ - continue; - } - - if (!is_frequent_contacts) - is_frequent_contacts = e_gw_container_get_is_frequent_contacts (E_GW_CONTAINER (temp_list->data)); - source = e_source_new (book_name, g_strconcat (";",book_name, NULL)); - e_source_set_property (source, "auth", "plain/password"); - e_source_set_property (source, "auth-domain", "Groupwise"); - e_source_set_property (source, "port", soap_port); - e_source_set_property(source, "user", url->user); - /* mark system address book for offline usage */ - /* FIXME: add isPersonal flag to container and use that isFrequentContact - * properties, instead of using writable to distinguish between the - * system address book and other address books. - */ - if (!is_writable) - e_source_set_property (source, "offline_sync", "1"); - else - e_source_set_property (source, "offline_sync", - camel_url_get_param (url, "offline_sync") ? "1" : "0"); - if (!is_writable) - e_source_set_property (source, "completion", "true"); - if (is_frequent_contacts) - e_source_set_property (source, "completion", "true"); - e_source_set_property (source, "use_ssl", use_ssl); - e_source_group_add_source (group, source, -1); - g_object_unref (source); - } - e_source_list_add_group (list, group, -1); - e_source_list_sync (list, NULL); - g_object_unref (group); - g_object_unref (list); - g_object_unref (client); - g_free (base_uri); - - if (!is_frequent_contacts) { - /* display warning message */ - e_error_run (NULL, "addressbook:gw-book-list-init", NULL); - } - return TRUE; -} - -static void -modify_addressbook_sources ( EAccount *account, GwAccountInfo *existing_account_info ) -{ - CamelURL *url; - ESourceList *list; - ESourceGroup *group; - GSList *groups; - gboolean found_group; - gboolean delete_group; - gchar *old_base_uri; - gchar *new_base_uri; - const gchar *soap_port; - const gchar *use_ssl; - GSList *sources; - ESource *source; - GConfClient *client; - const gchar *poa_address; - - url = camel_url_new (existing_account_info->source_url, NULL); - if (url == NULL) { - return; - } - - poa_address = url->host; - if (!poa_address || strlen (poa_address) ==0) - return; - - old_base_uri = g_strdup_printf ("groupwise://%s@%s", url->user, poa_address); - camel_url_free (url); - - url = camel_url_new (account->source->url, NULL); - if (url == NULL) - return; - poa_address = url->host; - if (!poa_address || strlen (poa_address) ==0) - return; - new_base_uri = g_strdup_printf ("groupwise://%s@%s", url->user, poa_address); - soap_port = camel_url_get_param (url, "soap_port"); - if (!soap_port || strlen (soap_port) == 0) - soap_port = "7191"; - use_ssl = camel_url_get_param (url, "use_ssl"); - - client = gconf_client_get_default (); - list = e_source_list_new_for_gconf (client, "/apps/evolution/addressbook/sources" ); - groups = e_source_list_peek_groups (list); - delete_group = FALSE; - if (strcmp (old_base_uri, new_base_uri) != 0) - delete_group = TRUE; - group = NULL; - found_group = FALSE; - for (; groups != NULL && !found_group; groups = g_slist_next (groups)) { - - group = E_SOURCE_GROUP (groups->data); - if ( strcmp ( e_source_group_peek_base_uri(group), old_base_uri) == 0 && strcmp (e_source_group_peek_name (group), existing_account_info->name) == 0) { - found_group = TRUE; - if (!delete_group) { - e_source_group_set_name (group, account->name); - sources = e_source_group_peek_sources (group); - for (; sources != NULL; sources = g_slist_next (sources)) { - source = E_SOURCE (sources->data); - e_source_set_property (source, "port", soap_port); - e_source_set_property (source, "use_ssl", use_ssl); - } - - e_source_list_sync (list, NULL); - } - - } - } - if (found_group && delete_group) { - e_source_list_remove_group (list, group); - e_source_list_sync (list, NULL); - g_object_unref (list); - list = NULL; - add_addressbook_sources (account); - } - g_free (old_base_uri); - if (list) - g_object_unref (list); - camel_url_free (url); - g_object_unref (client); - -} - -static void -remove_addressbook_sources (GwAccountInfo *existing_account_info) -{ - ESourceList *list; - ESourceGroup *group; - GSList *groups; - gboolean found_group; - CamelURL *url; - gchar *base_uri; - const gchar *soap_port; - GConfClient *client; - const gchar *poa_address; - - url = camel_url_new (existing_account_info->source_url, NULL); - if (url == NULL) { - return; - } - - poa_address = url->host; - if (!poa_address || strlen (poa_address) ==0) - return; - - soap_port = camel_url_get_param (url, "soap_port"); - if (!soap_port || strlen (soap_port) == 0) - soap_port = "7191"; - base_uri = g_strdup_printf ("groupwise://%s@%s", url->user, poa_address); - client = gconf_client_get_default (); - list = e_source_list_new_for_gconf (client, "/apps/evolution/addressbook/sources" ); - groups = e_source_list_peek_groups (list); - - found_group = FALSE; - - for (; groups != NULL && !found_group; groups = g_slist_next (groups)) { - - group = E_SOURCE_GROUP (groups->data); - if ( strcmp ( e_source_group_peek_base_uri (group), base_uri) == 0 && strcmp (e_source_group_peek_name (group), existing_account_info->name) == 0) { - - e_source_list_remove_group (list, group); - e_source_list_sync (list, NULL); - found_group = TRUE; - - } - } - g_object_unref (list); - g_object_unref (client); - g_free (base_uri); - camel_url_free (url); - -} - -static void -account_added (EAccountList *account_listener, EAccount *account) -{ - - GwAccountInfo *info; - EAccount *parent; - gboolean status; - CamelURL *parent_url; - - if (!is_groupwise_account (account)) - return; - - info = g_new0 (GwAccountInfo, 1); - info->uid = g_strdup (account->uid); - info->name = g_strdup (account->name); - info->source_url = g_strdup (account->source->url); - info->auto_check = account->source->auto_check; - info->auto_check_time = account->source->auto_check_time; - if (account->parent_uid) { - parent = (EAccount *)e_account_list_find (account_listener, E_ACCOUNT_FIND_UID, account->parent_uid); - - if (!parent) - return; - - parent_url = camel_url_new (e_account_get_string(parent, E_ACCOUNT_SOURCE_URL), NULL); - add_proxy_sources (info, parent_url->user); - } else { - status = add_addressbook_sources (account); - - if (status) - add_calendar_tasks_sources (info); - } - groupwise_accounts = g_list_append (groupwise_accounts, info); -} - -static void -account_removed (EAccountList *account_listener, EAccount *account) -{ - GwAccountInfo *info; - - if (!is_groupwise_account (account)) - return; - - info = lookup_account_info (account->uid); - if (info == NULL) - return; - - remove_calendar_tasks_sources (info); - remove_addressbook_sources (info); - groupwise_accounts = g_list_remove (groupwise_accounts, info); - g_free (info->uid); - g_free (info->name); - g_free (info->source_url); - g_free (info); -} - -static void -account_changed (EAccountList *account_listener, EAccount *account) -{ - gboolean is_gw_account; - CamelURL *old_url, *new_url; - const gchar *old_soap_port, *new_soap_port; - GwAccountInfo *existing_account_info; - const gchar *old_use_ssl, *new_use_ssl; - const gchar *old_poa_address, *new_poa_address; - - is_gw_account = is_groupwise_account (account); - - existing_account_info = lookup_account_info (account->uid); - - if (existing_account_info == NULL && is_gw_account) { - - if (!account->enabled) - return; - - /* some account of other type is changed to Groupwise */ - account_added (account_listener, account); - - } else if ( existing_account_info != NULL && !is_gw_account) { - - /*Groupwise account is changed to some other type */ - remove_calendar_tasks_sources (existing_account_info); - remove_addressbook_sources (existing_account_info); - groupwise_accounts = g_list_remove (groupwise_accounts, existing_account_info); - g_free (existing_account_info->uid); - g_free (existing_account_info->name); - g_free (existing_account_info->source_url); - g_free (existing_account_info); - - } else if ( existing_account_info != NULL && is_gw_account ) { - - if (!account->enabled) { - account_removed (account_listener, account); - return; - } - - /* some info of groupwise account is changed . update the sources with new info if required */ - old_url = camel_url_new (existing_account_info->source_url, NULL); - old_poa_address = old_url->host; - old_soap_port = camel_url_get_param (old_url, "soap_port"); - old_use_ssl = camel_url_get_param (old_url, "use_ssl"); - new_url = camel_url_new (account->source->url, NULL); - new_poa_address = new_url->host; - - if (!new_poa_address || strlen (new_poa_address) ==0) - return; - - new_soap_port = camel_url_get_param (new_url, "soap_port"); - - if (!new_soap_port || strlen (new_soap_port) == 0) - new_soap_port = "7191"; - - new_use_ssl = camel_url_get_param (new_url, "use_ssl"); - - if ((old_poa_address && strcmp (old_poa_address, new_poa_address)) - || (old_soap_port && strcmp (old_soap_port, new_soap_port)) - || strcmp (old_url->user, new_url->user) - || (!old_use_ssl) - || strcmp (old_use_ssl, new_use_ssl)) { - - account_removed (account_listener, account); - account_added (account_listener, account); - } else if (strcmp (existing_account_info->name, account->name)) { - - modify_esource ("/apps/evolution/calendar/sources", existing_account_info, account, new_url); - modify_esource ("/apps/evolution/tasks/sources", existing_account_info, account, new_url); - modify_esource ("/apps/evolution/memos/sources", existing_account_info, account, new_url); - modify_addressbook_sources (account, existing_account_info); - - } - - g_free (existing_account_info->name); - g_free (existing_account_info->source_url); - existing_account_info->name = g_strdup (account->name); - existing_account_info->source_url = g_strdup (account->source->url); - camel_url_free (old_url); - camel_url_free (new_url); - } -} - -static void -prune_proxies (void) { - - GConfClient *client = gconf_client_get_default (); - EAccountList *account_list; - ESourceList *sources; - ESourceGroup *group; - GSList *groups, *e_sources, *l, *p; - ESource *source; - GError *err = NULL; - const gchar *parent_id_name = NULL; - gint i; - ECalSourceType types [] = { E_CAL_SOURCE_TYPE_EVENT, - E_CAL_SOURCE_TYPE_TODO, - E_CAL_SOURCE_TYPE_JOURNAL - }; - - account_list = e_account_list_new (client); - /* Is this being leaked */ - g_object_unref (client); - - e_account_list_prune_proxies (account_list); - - for (i=0; i<3; i++) { - if (e_cal_get_sources (&sources, types[i], &err)) { - /* peek groupwise id and prune for proxies. */ - groups = e_source_list_peek_groups (sources); - for (l = groups; l != NULL;) { - group = (ESourceGroup *) l->data; - l = l->next; - if (!strcmp (e_source_group_peek_base_uri (group), "groupwise://")) { - e_sources = e_source_group_peek_sources (group); - for (p = e_sources; p != NULL; p = p->next) { - source = (ESource *)p->data; - parent_id_name = e_source_get_property (source, "parent_id_name"); - if (parent_id_name) { - e_source_group_remove_source (group, source); - e_source_list_remove_group (sources, group); - } - } - } - } - e_source_list_sync (sources, NULL); - } - } - -} -static void -camel_gw_listener_construct (CamelGwListener *config_listener) -{ - EIterator *iter; - EAccount *account; - GwAccountInfo *info; - - prune_proxies (); - - config_listener->priv->account_list = e_account_list_new (config_listener->priv->gconf_client); - - for ( iter = e_list_get_iterator (E_LIST ( config_listener->priv->account_list) ); e_iterator_is_valid (iter); e_iterator_next (iter) ) { - - account = E_ACCOUNT (e_iterator_get (iter)); - - if ( is_groupwise_account (account) && account->enabled) { - - info = g_new0 (GwAccountInfo, 1); - info->uid = g_strdup (account->uid); - info->name = g_strdup (account->name); - info->source_url = g_strdup (account->source->url); - groupwise_accounts = g_list_append (groupwise_accounts, info); - - } - - } - - g_signal_connect (config_listener->priv->account_list, "account_added", G_CALLBACK (account_added), NULL); - g_signal_connect (config_listener->priv->account_list, "account_changed", G_CALLBACK (account_changed), NULL); - g_signal_connect (config_listener->priv->account_list, "account_removed", G_CALLBACK (account_removed), NULL); -} - -GType -camel_gw_listener_get_type (void) -{ - static GType camel_gw_listener_type = 0; - - if (!camel_gw_listener_type) { - static GTypeInfo info = { - sizeof (CamelGwListenerClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) camel_gw_listener_class_init, - NULL, NULL, - sizeof (CamelGwListener), - 0, - (GInstanceInitFunc) camel_gw_listener_init - }; - camel_gw_listener_type = g_type_register_static (PARENT_TYPE, "CamelGwListener", &info, 0); - } - - return camel_gw_listener_type; -} - -CamelGwListener* -camel_gw_listener_new (void) -{ - CamelGwListener *config_listener; - - config_listener = g_object_new (CAMEL_TYPE_GW_LISTENER, NULL); - config_listener->priv->gconf_client = gconf_client_get_default(); - - camel_gw_listener_construct (config_listener); - - return config_listener; -} diff --git a/plugins/groupwise-account-setup/camel-gw-listener.h b/plugins/groupwise-account-setup/camel-gw-listener.h deleted file mode 100644 index 1c4cedbe5a..0000000000 --- a/plugins/groupwise-account-setup/camel-gw-listener.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - * - * Authors: - * Sivaiah Nallagatla - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifndef CAMEL_GW_LISTENER_H -#define CAMEL_GW_LISTENER_H - -#include -#include -#include -#include - -G_BEGIN_DECLS - -#define CAMEL_TYPE_GW_LISTENER (camel_gw_listener_get_type ()) -#define CAMEL_GW_LISTENER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAMEL_TYPE_GW_LISTENER, CamelGwListener)) -#define CAMEL_GW_LISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CAMEL_TYPE_GW_LISTENER, CamelGWListenerClass)) -#define CAMEL_IS_GWLISTENER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CAMEL_TYPE_GW_LISTENER)) -#define CAMEL_IS_GW_LISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), CAMEL_TYPE_GW_LISTENER)) - -typedef struct _CamelGwListener CamelGwListener; -typedef struct _CamelGwListenerClass CamelGwListenerClass; -typedef struct _CamelGwListenerPrivate CamelGwListenerPrivate; - -struct _CamelGwListener { - GObject parent; - - CamelGwListenerPrivate *priv; -}; - -struct _CamelGwListenerClass { - GObjectClass parent_class; -}; - -GType camel_gw_listener_get_type (void); -CamelGwListener *camel_gw_listener_new (void); - -G_END_DECLS - -#endif diff --git a/plugins/groupwise-account-setup/groupwise-account-setup.c b/plugins/groupwise-account-setup/groupwise-account-setup.c deleted file mode 100644 index 0872a9c2a7..0000000000 --- a/plugins/groupwise-account-setup/groupwise-account-setup.c +++ /dev/null @@ -1,138 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see - * - * - * Authors: - * Sivaiah Nallagatla - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#include "camel-gw-listener.h" -#include -#include "mail/em-config.h" -#include -#include "shell/es-event.h" -#include - -#define GROUPWISE_BASE_URI "groupwise://" - -static CamelGwListener *config_listener = NULL; - -gint e_plugin_lib_enable (EPlugin *ep, gint enable); -GtkWidget* org_gnome_gw_account_setup(struct _EPlugin *epl, struct _EConfigHookItemFactoryData *data); -void ensure_mandatory_esource_properties (EPlugin *ep, ESEventTargetUpgrade *target); - -static gboolean -is_groupwise_account (EAccount *account) -{ - if (account->source->url != NULL) { - return g_str_has_prefix (account->source->url, GROUPWISE_BASE_URI); - } else { - return FALSE; - } -} - -static void -set_esource_props (const gchar *path, EAccount *a, GConfClient *client, const gchar *name) -{ - ESourceList *list; - GSList *groups; - - list = e_source_list_new_for_gconf (client, path); - groups = e_source_list_peek_groups (list); - - for (; groups != NULL; groups = g_slist_next (groups)) { - ESourceGroup *group = E_SOURCE_GROUP (groups->data); - - if (strcmp (e_source_group_peek_name (group), name) == 0 && - strcmp (e_source_group_peek_base_uri (group), GROUPWISE_BASE_URI) == 0) { - GSList *sources = e_source_group_peek_sources (group); - - for (; sources != NULL; sources = g_slist_next (sources)) { - ESource *source = E_SOURCE (sources->data); - - if (a->source->auto_check) { - gchar *str = g_strdup_printf ("%d",a->source->auto_check_time); - - e_source_set_property (source, "refresh", str); - g_free (str); - } else - e_source_set_property (source, "refresh", NULL); - break; - } - } - } - e_source_list_sync (list, NULL); - - g_object_unref (list); -} - -void -ensure_mandatory_esource_properties (EPlugin *ep, ESEventTargetUpgrade *target) -{ - GConfClient* client; - EAccountList *al; - EIterator *it; - - client = gconf_client_get_default(); - al = e_account_list_new (client); - - for (it = e_list_get_iterator((EList *)al); - e_iterator_is_valid(it); - e_iterator_next(it)) { - EAccount *a; - - a = (EAccount *) e_iterator_get(it); - if (!a->enabled || !is_groupwise_account (a)) - continue; - set_esource_props ("/apps/evolution/calendar/sources", a, client, a->name); - set_esource_props ("/apps/evolution/tasks/sources", a, client, a->name); - set_esource_props ("/apps/evolution/memos/sources", a, client, a->name); - } - g_object_unref (al); - g_object_unref (client); -} - -static void -free_groupwise_listener ( void ) -{ - g_object_unref (config_listener); -} - -gint -e_plugin_lib_enable (EPlugin *ep, gint enable) -{ - if (!config_listener) { - config_listener = camel_gw_listener_new (); - g_atexit ( free_groupwise_listener ); - } - - return 0; -} - -GtkWidget * org_gnome_groupwise_account_setup(struct _EPlugin *epl, struct _EConfigHookItemFactoryData *data); - -GtkWidget * -org_gnome_groupwise_account_setup(struct _EPlugin *epl, struct _EConfigHookItemFactoryData *data) -{ - if (data->old) - return data->old; - /* FIXME, with new soap camel provider we don't need extra settings in receiving options page, Remove them - from camel-groupwise-provider.c once soap provider is ready and add any groupwise sepcific settings like "add contacts automatically to Frequent contacts folder" here*/ - - return NULL; -} diff --git a/plugins/groupwise-account-setup/org-gnome-gw-account-setup.eplug.xml b/plugins/groupwise-account-setup/org-gnome-gw-account-setup.eplug.xml deleted file mode 100644 index f99606f8a4..0000000000 --- a/plugins/groupwise-account-setup/org-gnome-gw-account-setup.eplug.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - <_description>Add Novell GroupWise support to Evolution. - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugins/groupwise-features/Makefile.am b/plugins/groupwise-features/Makefile.am index 20fd6bf812..1b3a5eb73a 100644 --- a/plugins/groupwise-features/Makefile.am +++ b/plugins/groupwise-features/Makefile.am @@ -12,6 +12,7 @@ AM_CPPFLAGS = \ $(EVOLUTION_CALENDAR_CFLAGS) \ $(EVOLUTION_ADDRESSBOOK_CFLAGS) \ $(CAMEL_GROUPWISE_CFLAGS) \ + $(GNOME_PLATFORM_CFLAGS) \ -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ -DEVOLUTION_IMAGESDIR=\""$(imagesdir)"\" @@ -21,6 +22,8 @@ plugin_DATA = org-gnome-groupwise-features.eplug org-gnome-compose-send-options. plugin_LTLIBRARIES = liborg-gnome-groupwise-features.la liborg_gnome_groupwise_features_la_SOURCES = \ + gw-ui.h \ + gw-ui.c \ share-folder-common.c \ share-folder.c \ share-folder.h \ @@ -38,13 +41,18 @@ liborg_gnome_groupwise_features_la_SOURCES = \ proxy-login.h \ proxy-login.c \ process-meeting.c \ - mail-retract.c + mail-retract.c \ + camel-gw-listener.c \ + camel-gw-listener.h \ + groupwise-account-setup.c liborg_gnome_groupwise_features_la_LIBADD= \ $(top_builddir)/e-util/libeutil.la \ + $(top_builddir)/shell/libeshell.la \ $(top_builddir)/calendar/gui/libevolution-calendar.la \ $(top_builddir)/widgets/misc/libemiscwidgets.la \ $(top_builddir)/filter/libfilter.la \ + $(top_builddir)/mail/libevolution-mail.la \ $(EVOLUTION_CALENDAR_LIBS) \ $(EVOLUTION_MAIL_LIBS) \ $(CAMEL_GROUPWISE_LIBS) diff --git a/plugins/groupwise-features/camel-gw-listener.c b/plugins/groupwise-features/camel-gw-listener.c new file mode 100644 index 0000000000..72b810feea --- /dev/null +++ b/plugins/groupwise-features/camel-gw-listener.c @@ -0,0 +1,1047 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see + * + * + * Authors: + * Sivaiah Nallagatla + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "camel-gw-listener.h" +#include +#include +#include +#include +#include "e-util/e-error.h" +#include +#include + +/*stores some info about all currently existing groupwise accounts + list of GwAccountInfo structures */ + +static GList *groupwise_accounts = NULL; + +struct _CamelGwListenerPrivate { + GConfClient *gconf_client; + /* we get notification about mail account changes form this object */ + EAccountList *account_list; +}; + +struct _GwAccountInfo { + gchar *uid; + gchar *name; + gchar *source_url; + gboolean auto_check; + guint auto_check_time; +}; + +typedef struct _GwAccountInfo GwAccountInfo; + +#define GROUPWISE_URI_PREFIX "groupwise://" +#define GROUPWISE_PREFIX_LENGTH 12 + +#define PARENT_TYPE G_TYPE_OBJECT + +static GObjectClass *parent_class = NULL; + +static void dispose (GObject *object); +static void finalize (GObject *object); + +static void +camel_gw_listener_class_init (CamelGwListenerClass *class) +{ + GObjectClass *object_class; + + parent_class = g_type_class_ref (PARENT_TYPE); + object_class = G_OBJECT_CLASS (class); + + /* virtual method override */ + object_class->dispose = dispose; + object_class->finalize = finalize; +} + +static void +camel_gw_listener_init (CamelGwListener *config_listener, CamelGwListenerClass *class) +{ + config_listener->priv = g_new0 (CamelGwListenerPrivate, 1); +} + +static void +dispose (GObject *object) +{ + CamelGwListener *config_listener = CAMEL_GW_LISTENER (object); + + g_object_unref (config_listener->priv->gconf_client); + g_object_unref (config_listener->priv->account_list); + + G_OBJECT_CLASS (parent_class)->dispose (object); +} + +static void +finalize (GObject *object) +{ + CamelGwListener *config_listener = CAMEL_GW_LISTENER (object); + GList *list; + GwAccountInfo *info; + + if (config_listener->priv) { + g_free (config_listener->priv); + } + + for ( list = g_list_first (groupwise_accounts); list; list = g_list_next (list) ) { + + info = (GwAccountInfo *) (list->data); + + if (info) { + + g_free (info->uid); + g_free (info->name); + g_free (info->source_url); + g_free (info); + } + } + + g_list_free (groupwise_accounts); + + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +/*determines whehter the passed in account is groupwise or not by looking at source url */ + +static gboolean +is_groupwise_account (EAccount *account) +{ + if (account->source->url != NULL) { + return (strncmp (account->source->url, GROUPWISE_URI_PREFIX, GROUPWISE_PREFIX_LENGTH ) == 0); + } else { + return FALSE; + } +} + +/* looks up for an existing groupwise account info in the groupwise_accounts list based on uid */ + +static GwAccountInfo* +lookup_account_info (const gchar *key) +{ + GList *list; + GwAccountInfo *info; + gint found = 0; + + if (!key) + return NULL; + + info = NULL; + + for (list = g_list_first (groupwise_accounts); list; list = g_list_next (list)) { + info = (GwAccountInfo *) (list->data); + found = (strcmp (info->uid, key) == 0); + if (found) + break; + } + if (found) + return info; + return NULL; +} + +#define CALENDAR_SOURCES "/apps/evolution/calendar/sources" +#define TASKS_SOURCES "/apps/evolution/tasks/sources" +#define NOTES_SOURCES "/apps/evolution/memos/sources" +#define SELECTED_CALENDARS "/apps/evolution/calendar/display/selected_calendars" +#define SELECTED_TASKS "/apps/evolution/calendar/tasks/selected_tasks" +#define SELECTED_NOTES "/apps/evolution/calendar/memos/selected_memos" + +static void +add_esource (const gchar *conf_key, GwAccountInfo *info, const gchar *source_name, CamelURL *url, const gchar * parent_id_name, gboolean can_create) +{ + ESourceList *source_list; + ESourceGroup *group; + ESource *source; + GConfClient* client; + GSList *ids, *temp; + const gchar *source_selection_key; + gchar *relative_uri; + const gchar *soap_port; + const gchar * use_ssl; + const gchar *poa_address; + const gchar *offline_sync; + const gchar *group_name; + + poa_address = url->host; + if (!poa_address || strlen (poa_address) ==0) + return; + + group_name = info->name; + + soap_port = camel_url_get_param (url, "soap_port"); + + if (!soap_port || strlen (soap_port) == 0) + soap_port = "7191"; + + use_ssl = camel_url_get_param (url, "use_ssl"); + + offline_sync = camel_url_get_param (url, "offline_sync"); + + client = gconf_client_get_default(); + source_list = e_source_list_new_for_gconf (client, conf_key); + group = e_source_group_new (group_name, GROUPWISE_URI_PREFIX); + + if (!e_source_list_add_group (source_list, group, -1)) + return; + + if (!can_create) + e_source_group_set_property (group, "create_source", "no"); + + relative_uri = g_strdup_printf ("%s@%s/", url->user, poa_address); + source = e_source_new (source_name, relative_uri); + e_source_set_property (source, "auth", "1"); + e_source_set_property (source, "username", url->user); + e_source_set_property (source, "port", camel_url_get_param (url, "soap_port")); + e_source_set_property (source, "auth-domain", "Groupwise"); + e_source_set_property (source, "use_ssl", use_ssl); + + if (info->auto_check) { + gchar *str = g_strdup_printf ("%d", info->auto_check_time); + + e_source_set_property (source, "refresh", str); + g_free (str); + } else + e_source_set_property (source, "refresh", NULL); + + e_source_set_property (source, "offline_sync", offline_sync ? "1" : "0" ); + e_source_set_property (source, "delete", "no"); + if (parent_id_name) { + e_source_set_property (source, "parent_id_name", parent_id_name); + e_source_set_color_spec (source, camel_url_get_param (url, "color")); + } else + e_source_set_color_spec (source, "#EEBC60"); + e_source_group_add_source (group, source, -1); + e_source_list_sync (source_list, NULL); + + if (!strcmp (conf_key, CALENDAR_SOURCES)) + source_selection_key = SELECTED_CALENDARS; + else if (!strcmp (conf_key, TASKS_SOURCES)) + source_selection_key = SELECTED_TASKS; + else if (!strcmp (conf_key, NOTES_SOURCES)) + source_selection_key = SELECTED_NOTES; + else + source_selection_key = NULL; + + if (source_selection_key) { + ids = gconf_client_get_list (client, source_selection_key , GCONF_VALUE_STRING, NULL); + ids = g_slist_append (ids, g_strdup (e_source_peek_uid (source))); + gconf_client_set_list (client, source_selection_key, GCONF_VALUE_STRING, ids, NULL); + temp = ids; + + for (; temp != NULL; temp = g_slist_next (temp)) + g_free (temp->data); + + g_slist_free (ids); + } + + g_object_unref (source); + g_object_unref (group); + g_object_unref (source_list); + g_object_unref (client); + g_free (relative_uri); +} + +static void +remove_esource (const gchar *conf_key, const gchar *group_name, gchar * source_name, const gchar * relative_uri) +{ + ESourceList *list; + GSList *groups; + gboolean found_group; + GConfClient* client; + GSList *ids; + GSList *node_tobe_deleted; + const gchar *source_selection_key; + + client = gconf_client_get_default(); + list = e_source_list_new_for_gconf (client, conf_key); + groups = e_source_list_peek_groups (list); + + found_group = FALSE; + + for (; groups != NULL && !found_group; groups = g_slist_next (groups)) { + ESourceGroup *group = E_SOURCE_GROUP (groups->data); + + if (strcmp (e_source_group_peek_name (group), group_name) == 0 && + strcmp (e_source_group_peek_base_uri (group), GROUPWISE_URI_PREFIX ) == 0) { + GSList *sources = e_source_group_peek_sources (group); + + for (; sources != NULL; sources = g_slist_next (sources)) { + ESource *source = E_SOURCE (sources->data); + const gchar *source_relative_uri; + + source_relative_uri = e_source_peek_relative_uri (source); + if (source_relative_uri == NULL) + continue; + if (strcmp (source_relative_uri, relative_uri) == 0) { + + if (!strcmp (conf_key, CALENDAR_SOURCES)) + source_selection_key = SELECTED_CALENDARS; + else if (!strcmp (conf_key, TASKS_SOURCES)) + source_selection_key = SELECTED_TASKS; + else if (!strcmp (conf_key, NOTES_SOURCES)) + source_selection_key = SELECTED_NOTES; + else source_selection_key = NULL; + if (source_selection_key) { + ids = gconf_client_get_list (client, source_selection_key , + GCONF_VALUE_STRING, NULL); + node_tobe_deleted = g_slist_find_custom (ids, e_source_peek_uid (source), (GCompareFunc) strcmp); + if (node_tobe_deleted) { + g_free (node_tobe_deleted->data); + ids = g_slist_delete_link (ids, node_tobe_deleted); + } + gconf_client_set_list (client, source_selection_key, + GCONF_VALUE_STRING, ids, NULL); + + } + e_source_list_remove_group (list, group); + e_source_list_sync (list, NULL); + found_group = TRUE; + break; + + } + } + + } + + } + + g_object_unref (list); + g_object_unref (client); + +} + +/* looks up for e-source with having same info as old_account_info and changes its values passed in new values */ + +static void +modify_esource (const gchar * conf_key, GwAccountInfo *old_account_info, EAccount *a, CamelURL *new_url) +{ + ESourceList *list; + GSList *groups; + gchar *old_relative_uri; + CamelURL *url; + gboolean found_group; + GConfClient* client; + const gchar *poa_address; + const gchar *new_poa_address; + const gchar * new_group_name = a->name; + + url = camel_url_new (old_account_info->source_url, NULL); + poa_address = url->host; + if (!poa_address || strlen (poa_address) ==0) + return; + new_poa_address = new_url->host; + + old_relative_uri = g_strdup_printf ("%s@%s/", url->user, poa_address); + client = gconf_client_get_default (); + list = e_source_list_new_for_gconf (client, conf_key); + groups = e_source_list_peek_groups (list); + + found_group = FALSE; + + for (; groups != NULL && !found_group; groups = g_slist_next (groups)) { + ESourceGroup *group = E_SOURCE_GROUP (groups->data); + + if (strcmp (e_source_group_peek_name (group), old_account_info->name) == 0 && + strcmp (e_source_group_peek_base_uri (group), GROUPWISE_URI_PREFIX) == 0) { + GSList *sources = e_source_group_peek_sources (group); + + for (; sources != NULL; sources = g_slist_next (sources)) { + ESource *source = E_SOURCE (sources->data); + const gchar *source_relative_uri; + + source_relative_uri = e_source_peek_relative_uri (source); + if (source_relative_uri == NULL) + continue; + if (strcmp (source_relative_uri, old_relative_uri) == 0) { + gchar *new_relative_uri; + + new_relative_uri = g_strdup_printf ("%s@%s/", new_url->user, new_poa_address); + e_source_group_set_name (group, new_group_name); + e_source_set_relative_uri (source, new_relative_uri); + e_source_set_property (source, "username", new_url->user); + e_source_set_property (source, "port", camel_url_get_param (new_url,"soap_port")); + e_source_set_property (source, "use_ssl", camel_url_get_param (url, "use_ssl")); + e_source_set_property (source, "offline_sync", camel_url_get_param (url, "offline_sync") ? "1" : "0"); + + if (a->source->auto_check) { + gchar *str = g_strdup_printf ("%d", a->source->auto_check_time); + + e_source_set_property (source, "refresh", str); + g_free (str); + } else + e_source_set_property (source, "refresh", NULL); + + e_source_list_sync (list, NULL); + found_group = TRUE; + g_free (new_relative_uri); + break; + } + } + } + } + + g_object_unref (list); + g_object_unref (client); + camel_url_free (url); + g_free (old_relative_uri); + +} +/* add sources for calendar and tasks if the account added is groupwise account + adds the new account info to groupwise_accounts list */ + +static void +add_calendar_tasks_sources (GwAccountInfo *info) +{ + CamelURL *url; + + url = camel_url_new (info->source_url, NULL); + add_esource ("/apps/evolution/calendar/sources", info, _("Calendar"), url, NULL, FALSE); + add_esource ("/apps/evolution/tasks/sources", info, _("Tasks"), url, NULL, FALSE); + add_esource ("/apps/evolution/memos/sources", info, _("Notes"), url, NULL, TRUE); + + camel_url_free (url); + +} + +/* removes calendar and tasks sources if the account removed is groupwise account + removes the the account info from groupwise_account list */ + +static void +remove_calendar_tasks_sources (GwAccountInfo *info) +{ + CamelURL *url; + gchar *relative_uri; + const gchar *soap_port; + const gchar *poa_address; + + url = camel_url_new (info->source_url, NULL); + + poa_address = url->host; + if (!poa_address || strlen (poa_address) ==0) + return; + + soap_port = camel_url_get_param (url, "soap_port"); + if (!soap_port || strlen (soap_port) == 0) + soap_port = "7191"; + + relative_uri = g_strdup_printf ("%s@%s/", url->user, poa_address); + remove_esource ("/apps/evolution/calendar/sources", info->name, _("Calendar"), relative_uri); + remove_esource ("/apps/evolution/tasks/sources", info->name, _("Checklist"), relative_uri); + remove_esource ("/apps/evolution/memos/sources", info->name, _("Notes"), relative_uri); + + camel_url_free (url); + g_free (relative_uri); + +} + +static GList* +get_addressbook_names_from_server (gchar *source_url) +{ + gchar *key; + EGwConnection *cnc; + gchar *password; + GList *book_list = NULL; + gint status, count = 0; + const gchar *soap_port; + CamelURL *url; + gboolean remember; + gchar *failed_auth = NULL; + gchar *prompt; + gchar *password_prompt; + gchar *uri; + const gchar *use_ssl; + const gchar *poa_address; + guint32 flags = E_PASSWORDS_REMEMBER_FOREVER|E_PASSWORDS_SECRET; + + url = camel_url_new (source_url, NULL); + if (url == NULL) { + return NULL; + } + poa_address = url->host; + if (!poa_address || strlen (poa_address) ==0) + return NULL; + + soap_port = camel_url_get_param (url, "soap_port"); + if (!soap_port || strlen (soap_port) == 0) + soap_port = "7191"; + use_ssl = camel_url_get_param (url, "use_ssl"); + + key = g_strdup_printf ("groupwise://%s@%s/", url->user, poa_address); + + if (use_ssl && g_str_equal (use_ssl, "always")) + uri = g_strdup_printf ("https://%s:%s/soap", poa_address, soap_port); + else + uri = g_strdup_printf ("http://%s:%s/soap", poa_address, soap_port); + + cnc = NULL; + + do { + count ++; + /*we have to uncache the password before prompting again*/ + if (failed_auth) { + e_passwords_forget_password ("Groupwise", key); + password = NULL; + } + + password = e_passwords_get_password ("Groupwise", key); + if (!password) { + password_prompt = g_strdup_printf (_("Enter password for %s (user %s)"), + poa_address, url->user); + prompt = g_strconcat (failed_auth ? failed_auth : "", password_prompt, NULL); + g_free (password_prompt); + password = e_passwords_ask_password (prompt, "Groupwise", key, prompt, + flags, &remember, + NULL); + g_free (prompt); + + if (!password) + break; + } + + cnc = e_gw_connection_new (uri, url->user, password); + g_free (password); + if (!E_IS_GW_CONNECTION(cnc)) { + if (count == 3) + break; + } + + failed_auth = _("Failed to authenticate.\n"); + flags |= E_PASSWORDS_REPROMPT; + } while (cnc == NULL); + + g_free (key); + + if (E_IS_GW_CONNECTION(cnc)) { + book_list = NULL; + status = e_gw_connection_get_address_book_list (cnc, &book_list); + if (status == E_GW_CONNECTION_STATUS_OK) + return book_list; + } + + /*FIXME: This error message should be relocated to addressbook and should reflect + * that it actually failed to get the addressbooks*/ + e_error_run (NULL, "mail:gw-accountsetup-error", poa_address, NULL); + return NULL; +} + +static void +add_proxy_sources (GwAccountInfo *info, const gchar *parent_name) +{ + CamelURL *url; + gchar *color; + + url = camel_url_new (info->source_url, NULL); + + color = g_strdup_printf ("#%06X", g_random_int_range (0x100000, 0xffffaa)); + /* The above range is chosen so that the colors are neither too light nor too dark + and appealing in all the themes */ + + camel_url_set_param (url, "color", color); + + add_esource ("/apps/evolution/calendar/sources", info, _("Calendar"), url, parent_name, FALSE); + add_esource ("/apps/evolution/tasks/sources", info, _("Tasks"), url, parent_name, FALSE); + add_esource ("/apps/evolution/memos/sources", info, _("Notes"), url, parent_name, TRUE); + + g_free (color); + camel_url_free (url); +} + +static gboolean +add_addressbook_sources (EAccount *account) +{ + CamelURL *url; + ESourceList *list; + ESourceGroup *group; + ESource *source; + gchar *base_uri; + const gchar *soap_port; + GList *books_list, *temp_list; + GConfClient* client; + const gchar * use_ssl; + const gchar *poa_address; + gboolean is_frequent_contacts = FALSE, is_writable = FALSE; + + url = camel_url_new (account->source->url, NULL); + if (url == NULL) { + return FALSE; + } + + poa_address = url->host; + if (!poa_address || strlen (poa_address) ==0) + return FALSE; + + soap_port = camel_url_get_param (url, "soap_port"); + if (!soap_port || strlen (soap_port) == 0) + soap_port = "7191"; + use_ssl = camel_url_get_param (url, "use_ssl"); + base_uri = g_strdup_printf ("groupwise://%s@%s", url->user, poa_address); + client = gconf_client_get_default (); + list = e_source_list_new_for_gconf (client, "/apps/evolution/addressbook/sources" ); + group = e_source_group_new (account->name, base_uri); + books_list = get_addressbook_names_from_server (account->source->url); + temp_list = books_list; + if (!temp_list) + return FALSE; + for (; temp_list != NULL; temp_list = g_list_next (temp_list)) { + const gchar *book_name = e_gw_container_get_name (E_GW_CONTAINER(temp_list->data)); + /* is_writable is set to TRUE if the book has isPersonal property, + * by e_gw_connection_get_address_book_list() + */ + is_writable = e_gw_container_get_is_writable (E_GW_CONTAINER(temp_list->data)); + if (is_writable && + !g_ascii_strncasecmp (book_name, "Novell GroupWise Address Book", strlen (book_name))) { + /* This is a hack to not to show multiple groupwise system address books + * if they are the personal address books with the name of system address book + * See http://bugzilla.gnome.org/show_bug.cgi?id=320119 + * and http://bugzilla.gnome.org/show_bug.cgi?id=309511 + */ + continue; + } + + if (!is_frequent_contacts) + is_frequent_contacts = e_gw_container_get_is_frequent_contacts (E_GW_CONTAINER (temp_list->data)); + source = e_source_new (book_name, g_strconcat (";",book_name, NULL)); + e_source_set_property (source, "auth", "plain/password"); + e_source_set_property (source, "auth-domain", "Groupwise"); + e_source_set_property (source, "port", soap_port); + e_source_set_property(source, "user", url->user); + /* mark system address book for offline usage */ + /* FIXME: add isPersonal flag to container and use that isFrequentContact + * properties, instead of using writable to distinguish between the + * system address book and other address books. + */ + if (!is_writable) + e_source_set_property (source, "offline_sync", "1"); + else + e_source_set_property (source, "offline_sync", + camel_url_get_param (url, "offline_sync") ? "1" : "0"); + if (!is_writable) + e_source_set_property (source, "completion", "true"); + if (is_frequent_contacts) + e_source_set_property (source, "completion", "true"); + e_source_set_property (source, "use_ssl", use_ssl); + e_source_group_add_source (group, source, -1); + g_object_unref (source); + } + e_source_list_add_group (list, group, -1); + e_source_list_sync (list, NULL); + g_object_unref (group); + g_object_unref (list); + g_object_unref (client); + g_free (base_uri); + + if (!is_frequent_contacts) { + /* display warning message */ + e_error_run (NULL, "addressbook:gw-book-list-init", NULL); + } + return TRUE; +} + +static void +modify_addressbook_sources ( EAccount *account, GwAccountInfo *existing_account_info ) +{ + CamelURL *url; + ESourceList *list; + ESourceGroup *group; + GSList *groups; + gboolean found_group; + gboolean delete_group; + gchar *old_base_uri; + gchar *new_base_uri; + const gchar *soap_port; + const gchar *use_ssl; + GSList *sources; + ESource *source; + GConfClient *client; + const gchar *poa_address; + + url = camel_url_new (existing_account_info->source_url, NULL); + if (url == NULL) { + return; + } + + poa_address = url->host; + if (!poa_address || strlen (poa_address) ==0) + return; + + old_base_uri = g_strdup_printf ("groupwise://%s@%s", url->user, poa_address); + camel_url_free (url); + + url = camel_url_new (account->source->url, NULL); + if (url == NULL) + return; + poa_address = url->host; + if (!poa_address || strlen (poa_address) ==0) + return; + new_base_uri = g_strdup_printf ("groupwise://%s@%s", url->user, poa_address); + soap_port = camel_url_get_param (url, "soap_port"); + if (!soap_port || strlen (soap_port) == 0) + soap_port = "7191"; + use_ssl = camel_url_get_param (url, "use_ssl"); + + client = gconf_client_get_default (); + list = e_source_list_new_for_gconf (client, "/apps/evolution/addressbook/sources" ); + groups = e_source_list_peek_groups (list); + delete_group = FALSE; + if (strcmp (old_base_uri, new_base_uri) != 0) + delete_group = TRUE; + group = NULL; + found_group = FALSE; + for (; groups != NULL && !found_group; groups = g_slist_next (groups)) { + + group = E_SOURCE_GROUP (groups->data); + if ( strcmp ( e_source_group_peek_base_uri(group), old_base_uri) == 0 && strcmp (e_source_group_peek_name (group), existing_account_info->name) == 0) { + found_group = TRUE; + if (!delete_group) { + e_source_group_set_name (group, account->name); + sources = e_source_group_peek_sources (group); + for (; sources != NULL; sources = g_slist_next (sources)) { + source = E_SOURCE (sources->data); + e_source_set_property (source, "port", soap_port); + e_source_set_property (source, "use_ssl", use_ssl); + } + + e_source_list_sync (list, NULL); + } + + } + } + if (found_group && delete_group) { + e_source_list_remove_group (list, group); + e_source_list_sync (list, NULL); + g_object_unref (list); + list = NULL; + add_addressbook_sources (account); + } + g_free (old_base_uri); + if (list) + g_object_unref (list); + camel_url_free (url); + g_object_unref (client); + +} + +static void +remove_addressbook_sources (GwAccountInfo *existing_account_info) +{ + ESourceList *list; + ESourceGroup *group; + GSList *groups; + gboolean found_group; + CamelURL *url; + gchar *base_uri; + const gchar *soap_port; + GConfClient *client; + const gchar *poa_address; + + url = camel_url_new (existing_account_info->source_url, NULL); + if (url == NULL) { + return; + } + + poa_address = url->host; + if (!poa_address || strlen (poa_address) ==0) + return; + + soap_port = camel_url_get_param (url, "soap_port"); + if (!soap_port || strlen (soap_port) == 0) + soap_port = "7191"; + base_uri = g_strdup_printf ("groupwise://%s@%s", url->user, poa_address); + client = gconf_client_get_default (); + list = e_source_list_new_for_gconf (client, "/apps/evolution/addressbook/sources" ); + groups = e_source_list_peek_groups (list); + + found_group = FALSE; + + for (; groups != NULL && !found_group; groups = g_slist_next (groups)) { + + group = E_SOURCE_GROUP (groups->data); + if ( strcmp ( e_source_group_peek_base_uri (group), base_uri) == 0 && strcmp (e_source_group_peek_name (group), existing_account_info->name) == 0) { + + e_source_list_remove_group (list, group); + e_source_list_sync (list, NULL); + found_group = TRUE; + + } + } + g_object_unref (list); + g_object_unref (client); + g_free (base_uri); + camel_url_free (url); + +} + +static void +account_added (EAccountList *account_listener, EAccount *account) +{ + + GwAccountInfo *info; + EAccount *parent; + gboolean status; + CamelURL *parent_url; + + if (!is_groupwise_account (account)) + return; + + info = g_new0 (GwAccountInfo, 1); + info->uid = g_strdup (account->uid); + info->name = g_strdup (account->name); + info->source_url = g_strdup (account->source->url); + info->auto_check = account->source->auto_check; + info->auto_check_time = account->source->auto_check_time; + if (account->parent_uid) { + parent = (EAccount *)e_account_list_find (account_listener, E_ACCOUNT_FIND_UID, account->parent_uid); + + if (!parent) + return; + + parent_url = camel_url_new (e_account_get_string(parent, E_ACCOUNT_SOURCE_URL), NULL); + add_proxy_sources (info, parent_url->user); + } else { + status = add_addressbook_sources (account); + + if (status) + add_calendar_tasks_sources (info); + } + groupwise_accounts = g_list_append (groupwise_accounts, info); +} + +static void +account_removed (EAccountList *account_listener, EAccount *account) +{ + GwAccountInfo *info; + + if (!is_groupwise_account (account)) + return; + + info = lookup_account_info (account->uid); + if (info == NULL) + return; + + remove_calendar_tasks_sources (info); + remove_addressbook_sources (info); + groupwise_accounts = g_list_remove (groupwise_accounts, info); + g_free (info->uid); + g_free (info->name); + g_free (info->source_url); + g_free (info); +} + +static void +account_changed (EAccountList *account_listener, EAccount *account) +{ + gboolean is_gw_account; + CamelURL *old_url, *new_url; + const gchar *old_soap_port, *new_soap_port; + GwAccountInfo *existing_account_info; + const gchar *old_use_ssl, *new_use_ssl; + const gchar *old_poa_address, *new_poa_address; + + is_gw_account = is_groupwise_account (account); + + existing_account_info = lookup_account_info (account->uid); + + if (existing_account_info == NULL && is_gw_account) { + + if (!account->enabled) + return; + + /* some account of other type is changed to Groupwise */ + account_added (account_listener, account); + + } else if ( existing_account_info != NULL && !is_gw_account) { + + /*Groupwise account is changed to some other type */ + remove_calendar_tasks_sources (existing_account_info); + remove_addressbook_sources (existing_account_info); + groupwise_accounts = g_list_remove (groupwise_accounts, existing_account_info); + g_free (existing_account_info->uid); + g_free (existing_account_info->name); + g_free (existing_account_info->source_url); + g_free (existing_account_info); + + } else if ( existing_account_info != NULL && is_gw_account ) { + + if (!account->enabled) { + account_removed (account_listener, account); + return; + } + + /* some info of groupwise account is changed . update the sources with new info if required */ + old_url = camel_url_new (existing_account_info->source_url, NULL); + old_poa_address = old_url->host; + old_soap_port = camel_url_get_param (old_url, "soap_port"); + old_use_ssl = camel_url_get_param (old_url, "use_ssl"); + new_url = camel_url_new (account->source->url, NULL); + new_poa_address = new_url->host; + + if (!new_poa_address || strlen (new_poa_address) ==0) + return; + + new_soap_port = camel_url_get_param (new_url, "soap_port"); + + if (!new_soap_port || strlen (new_soap_port) == 0) + new_soap_port = "7191"; + + new_use_ssl = camel_url_get_param (new_url, "use_ssl"); + + if ((old_poa_address && strcmp (old_poa_address, new_poa_address)) + || (old_soap_port && strcmp (old_soap_port, new_soap_port)) + || strcmp (old_url->user, new_url->user) + || (!old_use_ssl) + || strcmp (old_use_ssl, new_use_ssl)) { + + account_removed (account_listener, account); + account_added (account_listener, account); + } else if (strcmp (existing_account_info->name, account->name)) { + + modify_esource ("/apps/evolution/calendar/sources", existing_account_info, account, new_url); + modify_esource ("/apps/evolution/tasks/sources", existing_account_info, account, new_url); + modify_esource ("/apps/evolution/memos/sources", existing_account_info, account, new_url); + modify_addressbook_sources (account, existing_account_info); + + } + + g_free (existing_account_info->name); + g_free (existing_account_info->source_url); + existing_account_info->name = g_strdup (account->name); + existing_account_info->source_url = g_strdup (account->source->url); + camel_url_free (old_url); + camel_url_free (new_url); + } +} + +static void +prune_proxies (void) { + + GConfClient *client = gconf_client_get_default (); + EAccountList *account_list; + ESourceList *sources; + ESourceGroup *group; + GSList *groups, *e_sources, *l, *p; + ESource *source; + GError *err = NULL; + const gchar *parent_id_name = NULL; + gint i; + ECalSourceType types [] = { E_CAL_SOURCE_TYPE_EVENT, + E_CAL_SOURCE_TYPE_TODO, + E_CAL_SOURCE_TYPE_JOURNAL + }; + + account_list = e_account_list_new (client); + /* Is this being leaked */ + g_object_unref (client); + + e_account_list_prune_proxies (account_list); + + for (i=0; i<3; i++) { + if (e_cal_get_sources (&sources, types[i], &err)) { + /* peek groupwise id and prune for proxies. */ + groups = e_source_list_peek_groups (sources); + for (l = groups; l != NULL;) { + group = (ESourceGroup *) l->data; + l = l->next; + if (!strcmp (e_source_group_peek_base_uri (group), "groupwise://")) { + e_sources = e_source_group_peek_sources (group); + for (p = e_sources; p != NULL; p = p->next) { + source = (ESource *)p->data; + parent_id_name = e_source_get_property (source, "parent_id_name"); + if (parent_id_name) { + e_source_group_remove_source (group, source); + e_source_list_remove_group (sources, group); + } + } + } + } + e_source_list_sync (sources, NULL); + } + } + +} +static void +camel_gw_listener_construct (CamelGwListener *config_listener) +{ + EIterator *iter; + EAccount *account; + GwAccountInfo *info; + + prune_proxies (); + + config_listener->priv->account_list = e_account_list_new (config_listener->priv->gconf_client); + + for ( iter = e_list_get_iterator (E_LIST ( config_listener->priv->account_list) ); e_iterator_is_valid (iter); e_iterator_next (iter) ) { + + account = E_ACCOUNT (e_iterator_get (iter)); + + if ( is_groupwise_account (account) && account->enabled) { + + info = g_new0 (GwAccountInfo, 1); + info->uid = g_strdup (account->uid); + info->name = g_strdup (account->name); + info->source_url = g_strdup (account->source->url); + groupwise_accounts = g_list_append (groupwise_accounts, info); + + } + + } + + g_signal_connect (config_listener->priv->account_list, "account_added", G_CALLBACK (account_added), NULL); + g_signal_connect (config_listener->priv->account_list, "account_changed", G_CALLBACK (account_changed), NULL); + g_signal_connect (config_listener->priv->account_list, "account_removed", G_CALLBACK (account_removed), NULL); +} + +GType +camel_gw_listener_get_type (void) +{ + static GType camel_gw_listener_type = 0; + + if (!camel_gw_listener_type) { + static GTypeInfo info = { + sizeof (CamelGwListenerClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) camel_gw_listener_class_init, + NULL, NULL, + sizeof (CamelGwListener), + 0, + (GInstanceInitFunc) camel_gw_listener_init + }; + camel_gw_listener_type = g_type_register_static (PARENT_TYPE, "CamelGwListener", &info, 0); + } + + return camel_gw_listener_type; +} + +CamelGwListener* +camel_gw_listener_new (void) +{ + CamelGwListener *config_listener; + + config_listener = g_object_new (CAMEL_TYPE_GW_LISTENER, NULL); + config_listener->priv->gconf_client = gconf_client_get_default(); + + camel_gw_listener_construct (config_listener); + + return config_listener; +} diff --git a/plugins/groupwise-features/camel-gw-listener.h b/plugins/groupwise-features/camel-gw-listener.h new file mode 100644 index 0000000000..1c4cedbe5a --- /dev/null +++ b/plugins/groupwise-features/camel-gw-listener.h @@ -0,0 +1,59 @@ +/* + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see + * + * + * Authors: + * Sivaiah Nallagatla + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#ifndef CAMEL_GW_LISTENER_H +#define CAMEL_GW_LISTENER_H + +#include +#include +#include +#include + +G_BEGIN_DECLS + +#define CAMEL_TYPE_GW_LISTENER (camel_gw_listener_get_type ()) +#define CAMEL_GW_LISTENER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAMEL_TYPE_GW_LISTENER, CamelGwListener)) +#define CAMEL_GW_LISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CAMEL_TYPE_GW_LISTENER, CamelGWListenerClass)) +#define CAMEL_IS_GWLISTENER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CAMEL_TYPE_GW_LISTENER)) +#define CAMEL_IS_GW_LISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), CAMEL_TYPE_GW_LISTENER)) + +typedef struct _CamelGwListener CamelGwListener; +typedef struct _CamelGwListenerClass CamelGwListenerClass; +typedef struct _CamelGwListenerPrivate CamelGwListenerPrivate; + +struct _CamelGwListener { + GObject parent; + + CamelGwListenerPrivate *priv; +}; + +struct _CamelGwListenerClass { + GObjectClass parent_class; +}; + +GType camel_gw_listener_get_type (void); +CamelGwListener *camel_gw_listener_new (void); + +G_END_DECLS + +#endif diff --git a/plugins/groupwise-features/groupwise-account-setup.c b/plugins/groupwise-features/groupwise-account-setup.c new file mode 100644 index 0000000000..0872a9c2a7 --- /dev/null +++ b/plugins/groupwise-features/groupwise-account-setup.c @@ -0,0 +1,138 @@ +/* + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see + * + * + * Authors: + * Sivaiah Nallagatla + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#include "camel-gw-listener.h" +#include +#include "mail/em-config.h" +#include +#include "shell/es-event.h" +#include + +#define GROUPWISE_BASE_URI "groupwise://" + +static CamelGwListener *config_listener = NULL; + +gint e_plugin_lib_enable (EPlugin *ep, gint enable); +GtkWidget* org_gnome_gw_account_setup(struct _EPlugin *epl, struct _EConfigHookItemFactoryData *data); +void ensure_mandatory_esource_properties (EPlugin *ep, ESEventTargetUpgrade *target); + +static gboolean +is_groupwise_account (EAccount *account) +{ + if (account->source->url != NULL) { + return g_str_has_prefix (account->source->url, GROUPWISE_BASE_URI); + } else { + return FALSE; + } +} + +static void +set_esource_props (const gchar *path, EAccount *a, GConfClient *client, const gchar *name) +{ + ESourceList *list; + GSList *groups; + + list = e_source_list_new_for_gconf (client, path); + groups = e_source_list_peek_groups (list); + + for (; groups != NULL; groups = g_slist_next (groups)) { + ESourceGroup *group = E_SOURCE_GROUP (groups->data); + + if (strcmp (e_source_group_peek_name (group), name) == 0 && + strcmp (e_source_group_peek_base_uri (group), GROUPWISE_BASE_URI) == 0) { + GSList *sources = e_source_group_peek_sources (group); + + for (; sources != NULL; sources = g_slist_next (sources)) { + ESource *source = E_SOURCE (sources->data); + + if (a->source->auto_check) { + gchar *str = g_strdup_printf ("%d",a->source->auto_check_time); + + e_source_set_property (source, "refresh", str); + g_free (str); + } else + e_source_set_property (source, "refresh", NULL); + break; + } + } + } + e_source_list_sync (list, NULL); + + g_object_unref (list); +} + +void +ensure_mandatory_esource_properties (EPlugin *ep, ESEventTargetUpgrade *target) +{ + GConfClient* client; + EAccountList *al; + EIterator *it; + + client = gconf_client_get_default(); + al = e_account_list_new (client); + + for (it = e_list_get_iterator((EList *)al); + e_iterator_is_valid(it); + e_iterator_next(it)) { + EAccount *a; + + a = (EAccount *) e_iterator_get(it); + if (!a->enabled || !is_groupwise_account (a)) + continue; + set_esource_props ("/apps/evolution/calendar/sources", a, client, a->name); + set_esource_props ("/apps/evolution/tasks/sources", a, client, a->name); + set_esource_props ("/apps/evolution/memos/sources", a, client, a->name); + } + g_object_unref (al); + g_object_unref (client); +} + +static void +free_groupwise_listener ( void ) +{ + g_object_unref (config_listener); +} + +gint +e_plugin_lib_enable (EPlugin *ep, gint enable) +{ + if (!config_listener) { + config_listener = camel_gw_listener_new (); + g_atexit ( free_groupwise_listener ); + } + + return 0; +} + +GtkWidget * org_gnome_groupwise_account_setup(struct _EPlugin *epl, struct _EConfigHookItemFactoryData *data); + +GtkWidget * +org_gnome_groupwise_account_setup(struct _EPlugin *epl, struct _EConfigHookItemFactoryData *data) +{ + if (data->old) + return data->old; + /* FIXME, with new soap camel provider we don't need extra settings in receiving options page, Remove them + from camel-groupwise-provider.c once soap provider is ready and add any groupwise sepcific settings like "add contacts automatically to Frequent contacts folder" here*/ + + return NULL; +} diff --git a/plugins/groupwise-features/gw-ui.c b/plugins/groupwise-features/gw-ui.c new file mode 100644 index 0000000000..f026311841 --- /dev/null +++ b/plugins/groupwise-features/gw-ui.c @@ -0,0 +1,457 @@ +/* + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#include +#include + +#include +#include + +#include +#include +#include + +#include +#include + +#include "gw-ui.h" + +gboolean gw_ui_mail_folder_popup (GtkUIManager *ui_manager, EShellView *shell_view); +gboolean gw_ui_mail_message_popup (GtkUIManager *ui_manager, EShellView *shell_view); +gboolean gw_ui_calendar_event_popup (GtkUIManager *ui_manager, EShellView *shell_view); + +static gboolean +is_in_gw_account (EShellView *shell_view, gboolean *is_on_store, gchar **folder_full_name) +{ + EShellSidebar *shell_sidebar; + EMFolderTree *folder_tree = NULL; + GtkTreeSelection *selection; + GtkTreeModel *model = NULL; + GtkTreeIter iter; + gboolean is_store = FALSE, res; + gchar *uri = NULL; + gchar *full_name = NULL; + + if (folder_full_name) + *folder_full_name = NULL; + + shell_sidebar = e_shell_view_get_shell_sidebar (shell_view); + g_object_get (shell_sidebar, "folder-tree", &folder_tree, NULL); + g_return_val_if_fail (folder_tree != NULL, FALSE); + + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (folder_tree)); + g_return_val_if_fail (selection != NULL, FALSE); + + if (!gtk_tree_selection_get_selected (selection, &model, &iter)) + return FALSE; + + gtk_tree_model_get (model, &iter, + COL_STRING_FULL_NAME, &full_name, + COL_STRING_URI, &uri, + COL_BOOL_IS_STORE, &is_store, + -1); + + res = uri && g_ascii_strncasecmp (uri, "groupwise://", 12) == 0; + + if (is_on_store) + *is_on_store = is_store; + + if (!is_store) { + if (folder_full_name) + *folder_full_name = full_name; + else + g_free (full_name); + + } else { + g_free (full_name); + } + + g_free (uri); + + return res; +} + +static void +visible_actions (GtkActionGroup *action_group, gboolean visible, const GtkActionEntry *entries, guint n_entries) +{ + gint i; + + g_return_if_fail (action_group != NULL); + g_return_if_fail (entries != NULL); + + for (i = 0; i < n_entries; i++) { + GtkAction *action = gtk_action_group_get_action (action_group, entries[i].name); + + g_return_if_fail (action != NULL); + + gtk_action_set_visible (action, visible); + } +} + +static GtkActionEntry mfp_entries[] = { + { "gw-new-shared-folder", + "folder-new", + N_("New _Shared Folder..."), + NULL, + NULL, + G_CALLBACK (gw_new_shared_folder_cb) }, + + { "gw-proxy-login", + NULL, + N_("_Proxy Login..."), + NULL, + NULL, + G_CALLBACK (gw_proxy_login_cb) } +}; + +static void +update_mfp_entries_cb (EShellView *shell_view, gpointer user_data) +{ + GtkActionGroup *action_group; + EShellWindow *shell_window; + gboolean is_on_store = FALSE, visible; + + g_return_if_fail (E_IS_SHELL_VIEW (shell_view)); + + shell_window = e_shell_view_get_shell_window (shell_view); + action_group = e_shell_window_get_action_group (shell_window, "mail"); + + visible = is_in_gw_account (shell_view, &is_on_store, NULL); + visible_actions (action_group, visible, mfp_entries, G_N_ELEMENTS (mfp_entries)); + + if (visible && !is_on_store) { + GtkAction *action = gtk_action_group_get_action (action_group, "gw-proxy-login"); + + g_return_if_fail (action != NULL); + + gtk_action_set_visible (action, FALSE); + } +} + +gboolean +gw_ui_mail_folder_popup (GtkUIManager *ui_manager, EShellView *shell_view) +{ + EShellWindow *shell_window; + GtkActionGroup *action_group; + + shell_window = e_shell_view_get_shell_window (shell_view); + action_group = e_shell_window_get_action_group (shell_window, "mail"); + + gtk_action_group_add_actions ( + action_group, mfp_entries, + G_N_ELEMENTS (mfp_entries), shell_view); + + g_signal_connect (shell_view, "update-actions", G_CALLBACK (update_mfp_entries_cb), NULL); + + return TRUE; +} + +static GtkActionEntry mmp_entries[] = { + { "gw-junk-mail-settings", + NULL, + N_("Junk Mail Settings..."), + NULL, + NULL, + G_CALLBACK (gw_junk_mail_settings_cb) }, + + { "gw-track-message-status", + NULL, + N_("Track Message Status..."), + NULL, + NULL, + G_CALLBACK (gw_track_message_status_cb) }, + { "gw-retract-mail", + NULL, + N_("Retract Mail"), + NULL, + NULL, + G_CALLBACK (gw_retract_mail_cb) } +}; + +static void +update_mmp_entries_cb (EShellView *shell_view, gpointer user_data) +{ + EShellWindow *shell_window; + GtkActionGroup *action_group; + gboolean visible; + gchar *full_name = NULL, *uri = NULL; + guint n_selected = 0; + + g_return_if_fail (E_IS_SHELL_VIEW (shell_view)); + + shell_window = e_shell_view_get_shell_window (shell_view); + action_group = e_shell_window_get_action_group (shell_window, "mail"); + + visible = is_in_gw_account (shell_view, NULL, &full_name); + if (visible) { + EShellContent *shell_content; + EMailReader *reader; + MessageList *message_list; + GPtrArray *selected; + + shell_content = e_shell_view_get_shell_content (shell_view); + + reader = (EMailReader *) (shell_content); + message_list = e_mail_reader_get_message_list (reader); + selected = message_list_get_selected (message_list); + + if (selected) + n_selected = selected->len; + + message_list_free_uids (message_list, selected); + + visible = n_selected > 0; + } + + visible_actions (action_group, visible, mmp_entries, G_N_ELEMENTS (mmp_entries)); + + if (visible) { + GtkAction *action; + gboolean is_sent_items_folder = full_name && g_ascii_strncasecmp (full_name, "Sent Items", 10) == 0; + + action = gtk_action_group_get_action (action_group, "gw-track-message-status"); + g_return_if_fail (action != NULL); + gtk_action_set_visible (action, is_sent_items_folder && n_selected == 1); + + action = gtk_action_group_get_action (action_group, "gw-retract-mail"); + g_return_if_fail (action != NULL); + gtk_action_set_visible (action, is_sent_items_folder && n_selected == 1); + } + + g_free (full_name); + g_free (uri); +} + +gboolean +gw_ui_mail_message_popup (GtkUIManager *ui_manager, EShellView *shell_view) +{ + EShellWindow *shell_window; + GtkActionGroup *action_group; + + shell_window = e_shell_view_get_shell_window (shell_view); + action_group = e_shell_window_get_action_group (shell_window, "mail"); + + gtk_action_group_add_actions ( + action_group, mmp_entries, + G_N_ELEMENTS (mmp_entries), shell_view); + + g_signal_connect (shell_view, "update-actions", G_CALLBACK (update_mmp_entries_cb), NULL); + + return TRUE; +} + +static icalproperty * +get_attendee_prop (icalcomponent *icalcomp, const gchar *address) +{ + icalproperty *prop; + + if (!(address && *address)) + return NULL; + + for (prop = icalcomponent_get_first_property (icalcomp, ICAL_ATTENDEE_PROPERTY); + prop; + prop = icalcomponent_get_next_property (icalcomp, ICAL_ATTENDEE_PROPERTY)) { + const gchar *attendee = icalproperty_get_attendee (prop); + + if (g_str_equal (itip_strip_mailto (attendee), address)) { + return prop; + } + } + + return NULL; +} + +static gboolean +needs_to_accept (icalcomponent *icalcomp, const gchar *user_email) +{ + icalproperty *prop; + icalparameter *param; + icalparameter_partstat status = ICAL_PARTSTAT_NONE; + + prop = get_attendee_prop (icalcomp, user_email); + + /* It might be a mailing list */ + if (!prop) + return TRUE; + param = icalproperty_get_first_parameter (prop, ICAL_PARTSTAT_PARAMETER); + if (param) + status = icalparameter_get_partstat (param); + + if (status == ICAL_PARTSTAT_ACCEPTED || status == ICAL_PARTSTAT_TENTATIVE) + return FALSE; + + return TRUE; +} + +static gboolean +is_meeting_owner (ECalComponent *comp, ECal *client) +{ + ECalComponentOrganizer org; + gchar *email = NULL; + const gchar *strip = NULL; + gboolean ret_val = FALSE; + + if (!(e_cal_component_has_attendees (comp) && + e_cal_get_save_schedules (client))) + return ret_val; + + e_cal_component_get_organizer (comp, &org); + strip = itip_strip_mailto (org.value); + + if (e_cal_get_cal_address (client, &email, NULL) && !g_ascii_strcasecmp (email, strip)) { + ret_val = TRUE; + } + + if (!ret_val) + ret_val = e_account_list_find(itip_addresses_get(), E_ACCOUNT_FIND_ID_ADDRESS, strip) != NULL; + + g_free (email); + return ret_val; +} + +static GtkActionEntry cal_entries[] = { + { "gw-meeting-accept", + GTK_STOCK_APPLY, + N_("Accept"), + NULL, + NULL, + G_CALLBACK (gw_meeting_accept_cb) }, + + { "gw-meeting-accept-tentative", + GTK_STOCK_DIALOG_QUESTION, + N_("Accept Tentatively"), + NULL, + NULL, + G_CALLBACK (gw_meeting_accept_tentative_cb) }, + + { "gw-meeting-decline", + GTK_STOCK_CANCEL, + N_("Decline"), + NULL, + NULL, + G_CALLBACK (gw_meeting_decline_cb) }, + + { "gw-resend-meeting", + GTK_STOCK_EDIT, + N_("Rese_nd Meeting..."), + NULL, + NULL, + G_CALLBACK (gw_resend_meeting_cb) } +}; + +static void +update_cal_entries_cb (EShellView *shell_view, gpointer user_data) +{ + EShellWindow *shell_window; + GtkActionGroup *action_group; + gboolean visible = FALSE, is_unaccepted = FALSE, is_mtg_owner = FALSE; + EShellContent *shell_content; + GnomeCalendar *gcal = NULL; + GnomeCalendarViewType view_type; + ECalendarView *view; + + g_return_if_fail (E_IS_SHELL_VIEW (shell_view)); + + shell_window = e_shell_view_get_shell_window (shell_view); + shell_content = e_shell_view_get_shell_content (shell_view); + + g_object_get (shell_content, "calendar", &gcal, NULL); + + view_type = gnome_calendar_get_view (gcal); + view = gnome_calendar_get_calendar_view (gcal, view_type); + + if (view) { + GList *selected; + + selected = e_calendar_view_get_selected_events (view); + if (selected && selected->data) { + ECalendarViewEvent *event = (ECalendarViewEvent *) selected->data; + const gchar *uri; + + uri = event->comp_data ? e_cal_get_uri (event->comp_data->client) : NULL; + + if (uri && g_ascii_strncasecmp (uri, "groupwise://", 12) == 0) { + visible = e_cal_util_component_has_attendee (event->comp_data->icalcomp); + if (visible) { + ECalComponent *comp; + + comp = e_cal_component_new (); + e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); + + if (e_cal_get_static_capability (event->comp_data->client, CAL_STATIC_CAPABILITY_HAS_UNACCEPTED_MEETING)) { + gchar *user_email; + + user_email = itip_get_comp_attendee (comp, event->comp_data->client); + + is_unaccepted = needs_to_accept (event->comp_data->icalcomp, user_email); + + g_free (user_email); + } + + is_mtg_owner = is_meeting_owner (comp, event->comp_data->client); + + g_object_unref (comp); + } + } + } + + g_list_free (selected); + } + + action_group = e_shell_window_get_action_group (shell_window, "calendar"); + visible_actions (action_group, visible, cal_entries, G_N_ELEMENTS (cal_entries)); + + if (visible && !is_unaccepted) { + GtkAction *action; + + action = gtk_action_group_get_action (action_group, "gw-meeting-accept"); + g_return_if_fail (action != NULL); + gtk_action_set_visible (action, FALSE); + + action = gtk_action_group_get_action (action_group, "gw-meeting-accept-tentative"); + g_return_if_fail (action != NULL); + gtk_action_set_visible (action, FALSE); + } + + if (visible && !is_mtg_owner) { + GtkAction *action; + + action = gtk_action_group_get_action (action_group, "gw-resend-meeting"); + g_return_if_fail (action != NULL); + gtk_action_set_visible (action, FALSE); + } +} + +gboolean +gw_ui_calendar_event_popup (GtkUIManager *ui_manager, EShellView *shell_view) +{ + EShellWindow *shell_window; + GtkActionGroup *action_group; + + shell_window = e_shell_view_get_shell_window (shell_view); + action_group = e_shell_window_get_action_group (shell_window, "calendar"); + + gtk_action_group_add_actions ( + action_group, cal_entries, + G_N_ELEMENTS (cal_entries), shell_view); + + g_signal_connect (shell_view, "update-actions", G_CALLBACK (update_cal_entries_cb), NULL); + + return TRUE; +} diff --git a/plugins/groupwise-features/gw-ui.h b/plugins/groupwise-features/gw-ui.h new file mode 100644 index 0000000000..d8ed509e99 --- /dev/null +++ b/plugins/groupwise-features/gw-ui.h @@ -0,0 +1,38 @@ +/* + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) version 3. + * + * 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with the program; if not, see + * + * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) + * + */ + +#ifndef GW_UI_HEADER +#define GW_UI_HEADER + +#include +#include + +void gw_new_shared_folder_cb (GtkAction *action, EShellView *shell_view); +void gw_proxy_login_cb (GtkAction *action, EShellView *shell_view); + +void gw_junk_mail_settings_cb (GtkAction *action, EShellView *shell_view); +void gw_track_message_status_cb (GtkAction *action, EShellView *shell_view); +void gw_retract_mail_cb (GtkAction *action, EShellView *shell_view); + +void gw_meeting_accept_cb (GtkAction *action, EShellView *shell_view); +void gw_meeting_accept_tentative_cb (GtkAction *action, EShellView *shell_view); +void gw_meeting_decline_cb (GtkAction *action, EShellView *shell_view); +void gw_resend_meeting_cb (GtkAction *action, EShellView *shell_view); + +#endif diff --git a/plugins/groupwise-features/install-shared.c b/plugins/groupwise-features/install-shared.c index a208116f0a..d1edff3e02 100644 --- a/plugins/groupwise-features/install-shared.c +++ b/plugins/groupwise-features/install-shared.c @@ -30,9 +30,9 @@ #include #include #include +#include #include #include -#include #include #include #include @@ -76,6 +76,12 @@ install_folder_response (EMFolderSelector *emfs, gint response, gpointer *data) if (response == GTK_RESPONSE_CANCEL) { gtk_widget_destroy (GTK_WIDGET (emfs)); } else { + CamelSession *session; + EShell *shell; + + shell = e_shell_get_default (); + session = e_shell_settings_get_pointer (e_shell_get_shell_settings (shell), "mail-session"); + model = accept_data->model; item_id = camel_mime_message_get_message_id (accept_data->msg); uri = em_folder_selector_get_selected_uri (emfs); @@ -94,7 +100,7 @@ install_folder_response (EMFolderSelector *emfs, gint response, gpointer *data) parent_name = NULL; } camel_exception_init (&ex); - if (!(store = (CamelStore *) camel_session_get_service (mail_component_peek_session(NULL), uri, CAMEL_PROVIDER_STORE, &ex))) { + if (!(store = (CamelStore *) camel_session_get_service (session, uri, CAMEL_PROVIDER_STORE, &ex))) { camel_exception_clear (&ex); g_strfreev (names); return; @@ -154,23 +160,25 @@ accept_free(gpointer data) static void apply_clicked (GtkAssistant *assistant, CamelMimeMessage *msg) { - EMFolderTreeModel *model; EMFolderTree *folder_tree; GtkWidget *dialog; struct AcceptData *accept_data; gchar *uri; + gpointer parent; + + parent = gtk_widget_get_toplevel (GTK_WIDGET (assistant)); + parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL; accept_data = g_new0(struct AcceptData, 1); - model = mail_component_peek_tree_model (NULL); - folder_tree = (EMFolderTree *) em_folder_tree_new_with_model (model); + folder_tree = (EMFolderTree *) em_folder_tree_new (); - dialog = em_folder_selector_create_new (folder_tree, 0, _("Create folder"), _("Specify where to create the folder:")); + dialog = em_folder_selector_create_new (parent, folder_tree, 0, _("Create folder"), _("Specify where to create the folder:")); uri = em_folder_tree_get_selected_uri(folder_tree); em_folder_selector_set_selected ((EMFolderSelector *) dialog, uri); g_free(uri); accept_data->msg = msg; camel_object_ref(msg); - accept_data->model = model; + accept_data->model = EM_FOLDER_TREE_MODEL (gtk_tree_view_get_model (GTK_TREE_VIEW (folder_tree))); g_object_set_data_full((GObject *)dialog, "accept-data", accept_data, accept_free); g_signal_connect (dialog, "response", G_CALLBACK (install_folder_response), accept_data); g_object_set_data_full((GObject *)dialog, "assistant", assistant, (GDestroyNotify)gtk_widget_destroy); @@ -185,7 +193,6 @@ org_gnome_popup_wizard (EPlugin *ep, EMEventTargetMessage *target) const CamelInternetAddress *from_addr = NULL; const gchar *name; const gchar *email; - GtkWidget *window; CamelMimeMessage *msg = (CamelMimeMessage *) target->message; CamelStreamMem *content; CamelDataWrapper *dw; diff --git a/plugins/groupwise-features/junk-mail-settings.c b/plugins/groupwise-features/junk-mail-settings.c index bfaeee585d..fe82ccb4d5 100644 --- a/plugins/groupwise-features/junk-mail-settings.c +++ b/plugins/groupwise-features/junk-mail-settings.c @@ -29,22 +29,14 @@ #include #include -#include "camel/camel-store.h" -#include "camel/camel-folder.h" -#include "camel/camel-medium.h" -#include "camel/camel-mime-message.h" -#include "mail/em-popup.h" -#include +#include + #include -#include "mail/em-account-editor.h" -#include "libedataserver/e-account.h" -#include "mail/em-config.h" + +#include "gw-ui.h" #include "share-folder.h" #include "junk-settings.h" -void -org_gnome_junk_settings(EPlugin *ep, EMPopupTargetSelect *t); - static void abort_changes (JunkSettings *js) { @@ -65,17 +57,26 @@ junk_dialog_response (GtkWidget *dialog, gint response, JunkSettings *js) } -static void -junk_mail_settings (EPopup *ep, EPopupItem *item, gpointer data) +void +gw_junk_mail_settings_cb (GtkAction *action, EShellView *shell_view) { GtkWidget *dialog ,*w, *notebook, *box; JunkSettings *junk_tab; gint page_count =0; EGwConnection *cnc; gchar *msg; - CamelFolder *folder = (CamelFolder *)data; - CamelStore *store = folder->parent_store; - cnc = get_cnc (store); + EShellContent *shell_content; + EMailReader *reader; + MessageList *message_list; + + shell_content = e_shell_view_get_shell_content (shell_view); + + reader = (EMailReader *) (shell_content); + message_list = e_mail_reader_get_message_list (reader); + g_return_if_fail (message_list != NULL); + g_return_if_fail (message_list->folder != NULL); + + cnc = get_cnc (message_list->folder->parent_store); dialog = gtk_dialog_new_with_buttons (_("Junk Settings"), NULL, @@ -99,7 +100,7 @@ junk_mail_settings (EPopup *ep, EPopupItem *item, gpointer data) w = (GtkWidget *)junk_tab->vbox; gtk_box_pack_start ((GtkBox *) box, w, FALSE, FALSE, 6); - /*We might have to add more options for settings i.e. more pages*/ + /* We might have to add more options for settings i.e. more pages */ while (page_count > 0 ) { notebook = gtk_notebook_new (); gtk_notebook_append_page ((GtkNotebook *)notebook, box, NULL); @@ -112,40 +113,3 @@ junk_mail_settings (EPopup *ep, EPopupItem *item, gpointer data) g_signal_connect (dialog, "response", G_CALLBACK (junk_dialog_response), junk_tab); gtk_widget_show_all (dialog); } - -static EPopupItem popup_items[] = { - { E_POPUP_ITEM, (gchar *) "50.emfv.05", (gchar *) N_("Junk Mail Settings..."), junk_mail_settings, NULL, NULL, 0, EM_POPUP_SELECT_MANY|EM_FOLDER_VIEW_SELECT_LISTONLY} -}; - -static void -popup_free (EPopup *ep, GSList *items, gpointer data) -{ -g_slist_free (items); -} - -void -org_gnome_junk_settings(EPlugin *ep, EMPopupTargetSelect *t) -{ - GSList *menus = NULL; - - gint i = 0; - static gint first = 0; - - if (! g_strrstr (t->uri, "groupwise://")) - return; - - /* for translation*/ - if (!first) { - popup_items[0].label = _(popup_items[0].label); - - } - - first++; - - for (i = 0; i < sizeof (popup_items) / sizeof (popup_items[0]); i++) - menus = g_slist_prepend (menus, &popup_items[i]); - - e_popup_add_items (t->target.popup, menus, NULL, popup_free, t->folder); - -} - diff --git a/plugins/groupwise-features/mail-retract.c b/plugins/groupwise-features/mail-retract.c index 8dd58baeac..9581c0132b 100644 --- a/plugins/groupwise-features/mail-retract.c +++ b/plugins/groupwise-features/mail-retract.c @@ -24,31 +24,61 @@ #include #endif -#include -#include #include -#include #include #include #include + #include -void org_gnome_retract_message (EPlugin *ep, EMPopupTargetSelect *t); +#include + +#include "gw-ui.h" +#include "share-folder.h" -static void retract_mail_settings (EPopup *ep, EPopupItem *item, gpointer data) +static gboolean +get_selected_info (EShellView *shell_view, CamelFolder **folder, gchar **selected_uid) +{ + EShellContent *shell_content; + EMailReader *reader; + MessageList *message_list; + GPtrArray *selected; + + shell_content = e_shell_view_get_shell_content (shell_view); + + reader = (EMailReader *) (shell_content); + message_list = e_mail_reader_get_message_list (reader); + g_return_val_if_fail (message_list != NULL, FALSE); + + selected = message_list_get_selected (message_list); + if (selected && selected->len == 1) { + *folder = message_list->folder; + *selected_uid = g_strdup (g_ptr_array_index (selected, 0)); + } + + message_list_free_uids (message_list, selected); + + return *selected_uid != NULL; +} + +void +gw_retract_mail_cb (GtkAction *action, EShellView *shell_view) { EGwConnection *cnc; - CamelFolder *folder = (CamelFolder *)data; - CamelStore *store = folder->parent_store; - gchar *id; + CamelFolder *folder; + CamelStore *store; + gchar *id = NULL; GtkWidget *confirm_dialog, *confirm_warning; gint n; + g_return_if_fail (get_selected_info (shell_view, &folder, &id)); + g_return_if_fail (folder != NULL); + + store = folder->parent_store; + cnc = get_cnc (store); if (cnc && E_IS_GW_CONNECTION(cnc)) { - id = (gchar *)item->user_data; - confirm_dialog = gtk_dialog_new_with_buttons (_("Message Retract"), NULL, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_YES, GTK_RESPONSE_YES, @@ -79,40 +109,6 @@ static void retract_mail_settings (EPopup *ep, EPopupItem *item, gpointer data) } } } -} - -static EPopupItem popup_items[] = { - { E_POPUP_BAR, (gchar *) "20.emfv.03" }, - { E_POPUP_ITEM, (gchar *) "20.emfv.04", (gchar *) N_("Retract Mail"), retract_mail_settings, NULL, NULL, 0, EM_POPUP_SELECT_ONE|EM_FOLDER_VIEW_SELECT_LISTONLY} -}; - -static void popup_free (EPopup *ep, GSList *items, gpointer data) -{ - g_slist_free (items); -} -void org_gnome_retract_message (EPlugin *ep, EMPopupTargetSelect *t) -{ - GSList *menus = NULL; - GPtrArray *uids; - gint i = 0; - static gint first = 0; - - uids = t->uids; - if (g_strrstr (t->uri, "groupwise://") && !g_ascii_strcasecmp((t->folder)->full_name, "Sent Items")) { - - /* for translation*/ - if (!first) { - popup_items[1].label = _(popup_items[1].label); - popup_items[1].user_data = g_strdup((gchar *) g_ptr_array_index(uids, 0)); - } - - first++; - - for (i = 0; i < sizeof (popup_items) / sizeof (popup_items[0]); i++) - menus = g_slist_prepend (menus, &popup_items[i]); - - e_popup_add_items (t->target.popup, menus, NULL, popup_free, t->folder); - } - return; + g_free (id); } diff --git a/plugins/groupwise-features/mail-send-options.c b/plugins/groupwise-features/mail-send-options.c index 8244088f8a..3b3e8eb8a7 100644 --- a/plugins/groupwise-features/mail-send-options.c +++ b/plugins/groupwise-features/mail-send-options.c @@ -32,7 +32,6 @@ #include "mail-send-options.h" -#include "mail/em-menu.h" #include "mail/em-utils.h" #include "mail/em-event.h" diff --git a/plugins/groupwise-features/org-gnome-groupwise-features.eplug.xml b/plugins/groupwise-features/org-gnome-groupwise-features.eplug.xml index ea4f06a6e7..6ebc98e42c 100644 --- a/plugins/groupwise-features/org-gnome-groupwise-features.eplug.xml +++ b/plugins/groupwise-features/org-gnome-groupwise-features.eplug.xml @@ -1,7 +1,8 @@ + location="@PLUGINDIR@/liborg-gnome-groupwise-features@SOEXT@" load-on-startup="true" system_plugin="true"> + @@ -11,107 +12,84 @@ <_description>Fine-tune your GroupWise accounts. + - - + + - - + + - - - - - - - - - - - - - + + - - + + + + + + + + + - - - - - + + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + - - - + + + + + + + - + + + + diff --git a/plugins/groupwise-features/process-meeting.c b/plugins/groupwise-features/process-meeting.c index 299b19e3b6..7f49d8ab5d 100644 --- a/plugins/groupwise-features/process-meeting.c +++ b/plugins/groupwise-features/process-meeting.c @@ -28,77 +28,21 @@ #include #include #include -#include +#include + +#include + #include #include -#include -#include +#include + +#include "gw-ui.h" typedef struct { ECal *ecal; icalcomponent *icalcomp; } ReceiveData; -ECalendarView *c_view; - -void org_gnome_accept(EPlugin *ep, ECalPopupTargetSelect *target); -void org_gnome_retract_resend (EPlugin *ep, ECalPopupTargetSelect *target); -static void on_accept_meeting (EPopup *ep, EPopupItem *pitem, gpointer data); -static void on_accept_meeting_tentative (EPopup *ep, EPopupItem *pitem, gpointer data); -static void on_decline_meeting (EPopup *ep, EPopupItem *pitem, gpointer data); -static void on_resend_meeting (EPopup *ep, EPopupItem *pitem, gpointer data); - -static EPopupItem popup_items[] = { - { E_POPUP_ITEM, (gchar *) "41.accept", (gchar *) N_("Accept"), on_accept_meeting, NULL, (gchar *) GTK_STOCK_APPLY, 0, E_CAL_POPUP_SELECT_NOTEDITING | E_CAL_POPUP_SELECT_MEETING | E_CAL_POPUP_SELECT_ACCEPTABLE}, - { E_POPUP_ITEM, (gchar *) "42.accept", (gchar *) N_("Accept Tentatively"), on_accept_meeting_tentative, NULL, (gchar *) GTK_STOCK_DIALOG_QUESTION, 0, E_CAL_POPUP_SELECT_NOTEDITING | E_CAL_POPUP_SELECT_MEETING | E_CAL_POPUP_SELECT_ACCEPTABLE}, - { E_POPUP_ITEM, (gchar *) "43.decline", (gchar *) N_("Decline"), on_decline_meeting, NULL, (gchar *) GTK_STOCK_CANCEL, 0, E_CAL_POPUP_SELECT_NOTEDITING | E_CAL_POPUP_SELECT_MEETING} -}; - -static void -popup_free (EPopup *ep, GSList *items, gpointer data) -{ - g_slist_free (items); - items = NULL; -} - -void -org_gnome_accept (EPlugin *ep, ECalPopupTargetSelect *target) -{ - GSList *menus = NULL; - GList *selected; - gint i = 0; - static gint first = 0; - const gchar *uri = NULL; - ECalendarView *cal_view = E_CALENDAR_VIEW (target->target.widget); - - c_view = cal_view; - selected = e_calendar_view_get_selected_events (cal_view); - if (selected) { - ECalendarViewEvent *event = (ECalendarViewEvent *) selected->data; - - uri = e_cal_get_uri (event->comp_data->client); - } else - return; - - if (!uri) - return; - - if (! g_strrstr (uri, "groupwise://")) - return; - - /* for translation*/ - if (!first) { - popup_items[0].label = _(popup_items[0].label); - } - - first++; - - for (i = 0; i < sizeof (popup_items) / sizeof (popup_items[0]); i++) - menus = g_slist_prepend (menus, &popup_items[i]); - - e_popup_add_items (target->target.popup, menus, NULL, popup_free, NULL); -} - static void finalize_receive_data (ReceiveData *r_data) { @@ -258,55 +202,49 @@ process_meeting (ECalendarView *cal_view, icalparameter_partstat status) } } -/*FIXME the data does not give us the ECalendarView object. - we should remove the global c_view variable once we get it from the data*/ -static void -on_accept_meeting (EPopup *ep, EPopupItem *pitem, gpointer data) +static ECalendarView * +get_calendar_view (EShellView *shell_view) { - ECalendarView *cal_view = c_view; + EShellContent *shell_content; + GnomeCalendar *gcal = NULL; + GnomeCalendarViewType view_type; - process_meeting (cal_view, ICAL_PARTSTAT_ACCEPTED); -} -static void -on_accept_meeting_tentative (EPopup *ep, EPopupItem *pitem, gpointer data) -{ - ECalendarView *cal_view = c_view; + g_return_val_if_fail (shell_view != NULL, NULL); - process_meeting (cal_view, ICAL_PARTSTAT_TENTATIVE); -} + shell_content = e_shell_view_get_shell_content (shell_view); -static void -on_decline_meeting (EPopup *ep, EPopupItem *pitem, gpointer data) -{ - ECalendarView *cal_view = c_view; + g_object_get (shell_content, "calendar", &gcal, NULL); - process_meeting (cal_view, ICAL_PARTSTAT_DECLINED); + view_type = gnome_calendar_get_view (gcal); + + return gnome_calendar_get_calendar_view (gcal, view_type); } -static gboolean -is_meeting_owner (ECalComponent *comp, ECal *client) +void +gw_meeting_accept_cb (GtkAction *action, EShellView *shell_view) { - ECalComponentOrganizer org; - gchar *email = NULL; - const gchar *strip = NULL; - gboolean ret_val = FALSE; + ECalendarView *cal_view = get_calendar_view (shell_view); + g_return_if_fail (cal_view != NULL); - if (!(e_cal_component_has_attendees (comp) && - e_cal_get_save_schedules (client))) - return ret_val; + process_meeting (cal_view, ICAL_PARTSTAT_ACCEPTED); +} - e_cal_component_get_organizer (comp, &org); - strip = itip_strip_mailto (org.value); +void +gw_meeting_accept_tentative_cb (GtkAction *action, EShellView *shell_view) +{ + ECalendarView *cal_view = get_calendar_view (shell_view); + g_return_if_fail (cal_view != NULL); - if (e_cal_get_cal_address (client, &email, NULL) && !g_ascii_strcasecmp (email, strip)) { - ret_val = TRUE; - } + process_meeting (cal_view, ICAL_PARTSTAT_TENTATIVE); +} - if (!ret_val) - ret_val = e_account_list_find(itip_addresses_get(), E_ACCOUNT_FIND_ID_ADDRESS, strip) != NULL; +void +gw_meeting_decline_cb (GtkAction *action, EShellView *shell_view) +{ + ECalendarView *cal_view = get_calendar_view (shell_view); + g_return_if_fail (cal_view != NULL); - g_free (email); - return ret_val; + process_meeting (cal_view, ICAL_PARTSTAT_DECLINED); } typedef struct { @@ -315,60 +253,6 @@ typedef struct { CalObjModType mod; } ThreadData; -static EPopupItem retract_popup_items[] = { - { E_POPUP_ITEM, (gchar *) "49.resend", (gchar *) N_("Rese_nd Meeting..."), on_resend_meeting, NULL, (gchar *) GTK_STOCK_EDIT, 0, E_CAL_POPUP_SELECT_NOTEDITING | E_CAL_POPUP_SELECT_MEETING} -}; - -void -org_gnome_retract_resend (EPlugin *ep, ECalPopupTargetSelect *target) -{ - GSList *menus = NULL; - GList *selected; - gint i = 0; - static gint first = 0; - const gchar *uri = NULL; - ECalendarView *cal_view = E_CALENDAR_VIEW (target->target.widget); - ECalComponent *comp = NULL; - ECalendarViewEvent *event = NULL; - - c_view = cal_view; - selected = e_calendar_view_get_selected_events (cal_view); - if (selected) { - event = (ECalendarViewEvent *) selected->data; - - uri = e_cal_get_uri (event->comp_data->client); - } else - return; - - if (!uri) - return; - - if (! g_strrstr (uri, "groupwise://")) - return; - - comp = e_cal_component_new (); - e_cal_component_set_icalcomponent (comp, icalcomponent_new_clone (event->comp_data->icalcomp)); - - if (!is_meeting_owner (comp, event->comp_data->client)) { - g_object_unref (comp); - return; - } - - /* for translation*/ - if (!first) { - retract_popup_items[0].label = _(retract_popup_items[0].label); - } - - first++; - - for (i = 0; i < sizeof (retract_popup_items) / sizeof (retract_popup_items[0]); i++) - menus = g_slist_prepend (menus, &retract_popup_items[i]); - - e_popup_add_items (target->target.popup, menus, NULL, popup_free, NULL); - - g_object_unref (comp); -} - static void add_retract_data (ECalComponent *comp, const gchar *retract_comment, CalObjModType mod) { @@ -474,11 +358,13 @@ object_created_cb (CompEditor *ce, gpointer data) } } -static void -on_resend_meeting (EPopup *ep, EPopupItem *pitem, gpointer data) +void +gw_resend_meeting_cb (GtkAction *action, EShellView *shell_view) { - ECalendarView *cal_view = c_view; GList *selected; + ECalendarView *cal_view = get_calendar_view (shell_view); + + g_return_if_fail (cal_view != NULL); selected = e_calendar_view_get_selected_events (cal_view); if (selected) { diff --git a/plugins/groupwise-features/proxy-login.c b/plugins/groupwise-features/proxy-login.c index 123fc0641b..f230a880d3 100644 --- a/plugins/groupwise-features/proxy-login.c +++ b/plugins/groupwise-features/proxy-login.c @@ -30,11 +30,9 @@ #include #include -#include #include #include #include -#include #include #include #include @@ -49,6 +47,8 @@ #include #include #include + +#include "gw-ui.h" #include "proxy-login.h" #define GW(name) glade_xml_get_widget (priv->xml, name) @@ -375,7 +375,6 @@ proxy_soap_login (gchar *email) static void proxy_login_add_new_store (gchar *uri, CamelStore *store, gpointer user_data) { - MailComponent *component = mail_component_peek (); EAccount *account = user_data; gint permissions = GPOINTER_TO_INT(g_object_get_data ((GObject *)account, "permissions")); @@ -386,7 +385,7 @@ proxy_login_add_new_store (gchar *uri, CamelStore *store, gpointer user_data) store->mode &= !CAMEL_STORE_WRITE; store->flags |= CAMEL_STORE_PROXY; - mail_component_add_store (component, store, account->name); + /*mail_component_add_store (mail_component_peek (), store, account->name);*/ } static void @@ -472,13 +471,36 @@ proxy_login_update_tree (void) } void -org_gnome_proxy_account_login (EPopup *ep, EPopupItem *p, gpointer data) +gw_proxy_login_cb (GtkAction *action, EShellView *shell_view) { - gchar *uri = data; + EShellSidebar *shell_sidebar; + EMFolderTree *folder_tree = NULL; + GtkTreeSelection *selection; + GtkTreeModel *model = NULL; + GtkTreeIter iter; + gboolean is_store = FALSE; + gchar *uri = NULL; proxyLoginPrivate *priv; EGwConnection *cnc; gchar *gladefile; + shell_sidebar = e_shell_view_get_shell_sidebar (shell_view); + g_object_get (shell_sidebar, "folder-tree", &folder_tree, NULL); + g_return_if_fail (folder_tree != NULL); + + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (folder_tree)); + g_return_if_fail (selection != NULL); + + if (!gtk_tree_selection_get_selected (selection, &model, &iter)) + return; + + gtk_tree_model_get (model, &iter, COL_STRING_URI, &uri, COL_BOOL_IS_STORE, &is_store, -1); + + if (!is_store || !uri) { + g_free (uri); + return; + } + /* This pops-up the password dialog in case the User has forgot-passwords explicitly */ cnc = proxy_login_get_cnc (mail_config_get_account_by_source_url (uri), NULL); if (cnc) @@ -504,35 +526,6 @@ org_gnome_proxy_account_login (EPopup *ep, EPopupItem *p, gpointer data) proxy_login_update_tree (); g_signal_connect (GTK_DIALOG (priv->main), "response", G_CALLBACK(proxy_login_cb), NULL); gtk_widget_show (GTK_WIDGET (priv->main)); - } - -static EPopupItem popup_items[] = { -/* To Translators: In this case, Proxy does not mean something like 'HTTP Proxy', but a groupwise - * feature by which one person can send/read mails/appointments using another person's identity - * without knowing his password, for example if that other person is on vacation */ - { E_POPUP_ITEM, (gchar *) "20.emc.04", (gchar *) N_("_Proxy Login..."), org_gnome_proxy_account_login, NULL, NULL, 0, EM_POPUP_FOLDER_STORE } -}; - -static void -popup_free (EPopup *ep, GSList *items, gpointer data) -{ - g_slist_free (items); -} - -void -org_gnome_create_proxy_login_option (EPlugin *ep, EMPopupTargetFolder *t) -{ - EAccount *account; - GSList *menus = NULL; - gint i; - - account = mail_config_get_account_by_source_url (t->uri); - if (g_strrstr (t->uri,"groupwise://") && !account->parent_uid) { - popup_items[0].label = _(popup_items[0].label); - for (i = 0; i < sizeof (popup_items) / sizeof (popup_items[0]); i++) - menus = g_slist_prepend (menus, &popup_items[i]); - e_popup_add_items (t->target.popup, menus, NULL, popup_free, t->uri); - } - return; + g_free (uri); } diff --git a/plugins/groupwise-features/proxy-login.h b/plugins/groupwise-features/proxy-login.h index 47c2b3b901..150684c140 100644 --- a/plugins/groupwise-features/proxy-login.h +++ b/plugins/groupwise-features/proxy-login.h @@ -55,11 +55,9 @@ proxyLogin * proxy_login_new (void); static void proxy_login_cb (GtkDialog *dialog, gint state); static void proxy_login_add_new_store (gchar *uri, CamelStore *store, gpointer user_data); static void proxy_login_setup_tree_view (void); -void org_gnome_proxy_account_login (EPopup *ep, EPopupItem *p, gpointer data); proxyLogin* proxy_dialog_new (void); static void proxy_soap_login (gchar *email); gchar *parse_email_for_name (gchar *email); static void proxy_login_update_tree (void); static void proxy_login_tree_view_changed_cb(GtkDialog *dialog); -void org_gnome_create_proxy_login_option(EPlugin *ep, EMPopupTargetFolder *t); static gint proxy_get_password (EAccount *account, gchar **user_name, gchar **password); diff --git a/plugins/groupwise-features/proxy.c b/plugins/groupwise-features/proxy.c index 91016a6126..a31b49112b 100644 --- a/plugins/groupwise-features/proxy.c +++ b/plugins/groupwise-features/proxy.c @@ -39,7 +39,6 @@ #include #include -#include #include #include #include diff --git a/plugins/groupwise-features/share-folder-common.c b/plugins/groupwise-features/share-folder-common.c index 791a2da541..3856fcc7a3 100644 --- a/plugins/groupwise-features/share-folder-common.c +++ b/plugins/groupwise-features/share-folder-common.c @@ -30,12 +30,10 @@ #include #include #include -#include #include #include #include #include -#include #include #include #include @@ -48,7 +46,10 @@ #include #include #include +#include #include "share-folder.h" +#include "gw-ui.h" + #define d(x) ShareFolder *common = NULL; @@ -61,9 +62,6 @@ struct ShareInfo { }; GtkWidget * org_gnome_shared_folder_factory (EPlugin *ep, EConfigHookItemFactoryData *hook_data); -void org_gnome_create_option(EPlugin *ep, EMPopupTargetFolder *target); -static void create_shared_folder(EPopup *ep, EPopupItem *p, gpointer data); -static void popup_free (EPopup *ep, GSList *items, gpointer data); void shared_folder_commit (EPlugin *ep, EConfigTarget *tget); void shared_folder_abort (EPlugin *ep, EConfigTarget *target); @@ -103,7 +101,7 @@ shared_folder_commit (EPlugin *ep, EConfigTarget *tget) EMConfigTargetFolder *target = (EMConfigTargetFolder *)tget->config->target; CamelFolder *folder = target->folder; CamelStore *store = folder->parent_store; - EMFolderTreeModel *model = mail_component_peek_tree_model (mail_component_peek ()); + EMFolderTreeModel *model = NULL; /*mail_component_peek_tree_model (mail_component_peek ())*/; if (common) { share_folder (common); refresh_folder_tree (model, store); @@ -265,7 +263,7 @@ users_dialog_response(GtkWidget *dialog, gint response, struct ShareInfo *ssi) return; } - if (!(si = g_hash_table_lookup ((ssi->model)->store_hash, store))) { + if (!(si = em_folder_tree_model_lookup_store_info (ssi->model, store))) { g_assert_not_reached (); camel_object_unref (store); return; @@ -336,61 +334,31 @@ new_folder_response (EMFolderSelector *emfs, gint response, EMFolderTreeModel *m } -static EPopupItem popup_items[] = { - { E_POPUP_ITEM, (gchar *) "20.emc.001", (gchar *) N_("New _Shared Folder..."), create_shared_folder, NULL, (gchar *) "folder-new", 0, EM_POPUP_FOLDER_INFERIORS } -}; - -static void -popup_free (EPopup *ep, GSList *items, gpointer data) -{ -g_slist_free (items); -} - void -org_gnome_create_option(EPlugin *ep, EMPopupTargetFolder *t) -{ - GSList *menus = NULL; - gint i = 0; - static gint first = 0; - - if (! g_strrstr (t->uri, "groupwise://")) - return; - - /* for translation*/ - if (!first) { - popup_items[0].label = _(popup_items[0].label); - - } - - first++; - - for (i = 0; i < sizeof (popup_items) / sizeof (popup_items[0]); i++) - menus = g_slist_prepend (menus, &popup_items[i]); - - e_popup_add_items (t->target.popup, menus, NULL, popup_free, NULL); - -} - -static void -create_shared_folder(EPopup *ep, EPopupItem *p, gpointer data) +gw_new_shared_folder_cb (GtkAction *action, EShellView *shell_view) { - - EMFolderTreeModel *model; - EMFolderTree *folder_tree; + EShellSidebar *shell_sidebar; + EMFolderTree *folder_tree = NULL; GtkWidget *dialog; gchar *uri; + gpointer parent; + + parent = e_shell_view_get_shell_window (shell_view); - model = mail_component_peek_tree_model (mail_component_peek ()); - folder_tree = (EMFolderTree *) em_folder_tree_new_with_model (model); + shell_sidebar = e_shell_view_get_shell_sidebar (shell_view); + g_object_get (shell_sidebar, "folder-tree", &folder_tree, NULL); - dialog = em_folder_selector_create_new (folder_tree, 0, _("Create folder"), _("Specify where to create the folder:")); - uri = em_folder_tree_get_selected_uri(folder_tree); - em_folder_selector_set_selected ((EMFolderSelector *) dialog, uri); + dialog = em_folder_selector_create_new (parent, folder_tree, 0, _("Create folder"), _("Specify where to create the folder:")); + uri = em_folder_tree_get_selected_uri (folder_tree); + if (uri != NULL) + em_folder_selector_set_selected ((EMFolderSelector *) dialog, uri); g_free(uri); - g_signal_connect (dialog, "response", G_CALLBACK (new_folder_response), model); + + g_signal_connect (dialog, "response", G_CALLBACK (new_folder_response), gtk_tree_view_get_model (GTK_TREE_VIEW (folder_tree))); gtk_window_set_title (GTK_WINDOW (dialog), "New Shared Folder" ); gtk_widget_show(dialog); + g_object_unref (folder_tree); } GtkWidget * diff --git a/plugins/groupwise-features/status-track.c b/plugins/groupwise-features/status-track.c index 5507568809..e38497823b 100644 --- a/plugins/groupwise-features/status-track.c +++ b/plugins/groupwise-features/status-track.c @@ -32,17 +32,17 @@ #include #include -#include "camel/camel-folder.h" -#include "camel/camel-mime-utils.h" -#include "camel/camel-medium.h" -#include "camel/camel-mime-message.h" -#include -#include +#include +#include +#include +#include + +#include #include -#include "share-folder.h" -void org_gnome_track_status (gpointer ep, EMPopupTargetSelect *t); +#include "gw-ui.h" +#include "share-folder.h" static gchar * format_date (const gchar * value) @@ -57,11 +57,40 @@ format_date (const gchar * value) return str; } -static void -track_status (EPopup *ep, EPopupItem *item, gpointer data) +static CamelMimeMessage * +get_selected_message (EShellView *shell_view, CamelFolder **folder, gchar **selected_uid) { - EMPopupTargetSelect *t = (EMPopupTargetSelect *)data; CamelMimeMessage *msg = NULL; + EShellContent *shell_content; + EMailReader *reader; + MessageList *message_list; + GPtrArray *selected; + + shell_content = e_shell_view_get_shell_content (shell_view); + + reader = (EMailReader *) (shell_content); + message_list = e_mail_reader_get_message_list (reader); + g_return_val_if_fail (message_list != NULL, NULL); + + selected = message_list_get_selected (message_list); + if (selected && selected->len == 1) { + *folder = message_list->folder; + *selected_uid = g_strdup (g_ptr_array_index (selected, 0)); + + msg = camel_folder_get_message (*folder, *selected_uid, NULL); + } + + message_list_free_uids (message_list, selected); + + return msg; +} + +void +gw_track_message_status_cb (GtkAction *action, EShellView *shell_view) +{ + CamelMimeMessage *msg = NULL; + CamelFolder *folder = NULL; + gchar *selected_uid = NULL; const CamelInternetAddress *from; const gchar *namep, *addp; @@ -81,14 +110,15 @@ track_status (EPopup *ep, EPopupItem *item, gpointer data) EGwConnection *cnc; EGwItem *gwitem; - /*Get message*/ - msg = camel_folder_get_message (t->folder, g_ptr_array_index (t->uids, 0), NULL); + /* Get message */ + msg = get_selected_message (shell_view, &folder, &selected_uid); if (!msg) { g_print ("Error!! No message\n"); + g_free (selected_uid); return; } - /*Create the dialog*/ + /* Create the dialog */ d = (GtkDialog *) gtk_dialog_new (); gtk_dialog_add_button (d, GTK_STOCK_OK, GTK_RESPONSE_OK); gtk_window_set_title (GTK_WINDOW (d), _("Message Status")); @@ -104,7 +134,7 @@ track_status (EPopup *ep, EPopupItem *item, gpointer data) gtk_table_set_col_spacings (table ,12); gtk_table_set_row_spacings (table, 6); - /*Subject*/ + /* Subject */ boldmsg = g_strdup_printf ("%s", _("Subject:")); widget = gtk_label_new (boldmsg); g_free (boldmsg); @@ -116,7 +146,7 @@ track_status (EPopup *ep, EPopupItem *item, gpointer data) gtk_table_attach (table, widget , 1, 2, row, row + 1, GTK_FILL, 0, 0, 0); row++; - /*From*/ + /* From */ from = camel_mime_message_get_from (msg); camel_internet_address_get (from, 0, &namep, &addp); boldmsg = g_strdup_printf ("%s", _("From:")); @@ -130,7 +160,7 @@ track_status (EPopup *ep, EPopupItem *item, gpointer data) gtk_table_attach (table, widget , 1, 2, row, row + 1, GTK_FILL, 0, 0, 0); row++; - /*creation date*/ + /* creation date */ time = camel_mime_message_get_date (msg, NULL); time_str = ctime (&time); time_str[strlen(time_str)-1] = '\0' ; @@ -145,22 +175,22 @@ track_status (EPopup *ep, EPopupItem *item, gpointer data) gtk_table_attach (table, widget , 1, 2, row, row + 1, GTK_FILL, 0, 0, 0); row++; - /*spacing*/ + /* spacing */ widget = gtk_label_new (""); gtk_table_attach (table, widget, 0, 1, row, row + 1, GTK_FILL, 0, 0, 0); row++; - /*Table headers*/ + /* Table headers */ row = 0; table = (GtkTable *) gtk_table_new (1, 3, FALSE); gtk_table_set_col_spacings (table ,12); gtk_table_set_row_spacings (table, 6); gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (table), FALSE, TRUE, 0); - cnc = get_cnc (t->folder->parent_store); + cnc = get_cnc (folder->parent_store); if (E_IS_GW_CONNECTION(cnc)) { GSList *recipient_list; - e_gw_connection_get_item (cnc, get_container_id (cnc, "Sent Items"), g_ptr_array_index (t->uids, 0), "distribution recipientStatus", &gwitem); + e_gw_connection_get_item (cnc, get_container_id (cnc, "Sent Items"), selected_uid, "distribution recipientStatus", &gwitem); recipient_list = e_gw_item_get_recipient_list (gwitem); for (;recipient_list != NULL; recipient_list = recipient_list->next) { @@ -225,46 +255,13 @@ track_status (EPopup *ep, EPopupItem *item, gpointer data) } } - /*set size and display the dialog*/ + /* set size and display the dialog */ gtk_widget_set_size_request (GTK_WIDGET (win), 400, 300); gtk_widget_show_all (GTK_WIDGET (d)); if (gtk_dialog_run (d) == GTK_RESPONSE_OK) gtk_widget_destroy (GTK_WIDGET (d)); else gtk_widget_destroy (GTK_WIDGET (d)); -} - -static EPopupItem popup_items[] = { - { E_POPUP_ITEM, (gchar * ) "20.emfv.02", (gchar *) N_("Track Message Status..."), track_status, NULL, NULL, 0, EM_POPUP_SELECT_ONE|EM_FOLDER_VIEW_SELECT_LISTONLY} -}; - -static void -popup_free (EPopup *ep, GSList *items, gpointer data) -{ - g_slist_free (items); -} - -void org_gnome_track_status (gpointer ep, EMPopupTargetSelect *t) -{ - GSList *menus = NULL; - - gint i = 0; - static gint first = 0; - - if (! g_strrstr (t->uri, "groupwise://") || g_ascii_strncasecmp ((t->folder)->full_name, "Sent Items", 10)) - return; - - /* for translation*/ - if (!first) { - popup_items[0].label = _(popup_items[0].label); - - } - - first++; - - for (i = 0; i < sizeof (popup_items) / sizeof (popup_items[0]); i++) - menus = g_slist_prepend (menus, &popup_items[i]); - - e_popup_add_items (t->target.popup, menus, NULL, popup_free, t); + g_free (selected_uid); } diff --git a/po/POTFILES.in b/po/POTFILES.in index bf4ec0ed90..62c654cdfc 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -344,8 +344,7 @@ plugins/face/org-gnome-face.eplug.xml plugins/google-account-setup/google-contacts-source.c plugins/google-account-setup/google-source.c plugins/google-account-setup/org-gnome-evolution-google.eplug.xml -plugins/groupwise-account-setup/camel-gw-listener.c -plugins/groupwise-account-setup/org-gnome-gw-account-setup.eplug.xml +plugins/groupwise-features/camel-gw-listener.c plugins/groupwise-features/install-shared.c plugins/groupwise-features/junk-mail-settings.c plugins/groupwise-features/junk-settings.c diff --git a/po/POTFILES.skip b/po/POTFILES.skip index 5957c69930..73865ab9cc 100644 --- a/po/POTFILES.skip +++ b/po/POTFILES.skip @@ -24,6 +24,7 @@ mail/importers/evolution-outlook-importer.c mail/importers/netscape-importer.c mail/message-tags.glade plugins/exchange-operations/exchange-operations.c +plugins/groupwise-features/groupwise-account-setup.c plugins/ipod-sync/sync.c plugins/mailing-list-actions/org-gnome-mailing-list-actions.xml shell/importer/import.glade diff --git a/ui/evolution-calendars.ui b/ui/evolution-calendars.ui index 29546490f5..f7170656fe 100644 --- a/ui/evolution-calendars.ui +++ b/ui/evolution-calendars.ui @@ -92,6 +92,8 @@ + + -- cgit v1.2.3