aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/groupwise-features
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/groupwise-features')
-rw-r--r--plugins/groupwise-features/Makefile.am10
-rw-r--r--plugins/groupwise-features/camel-gw-listener.c1047
-rw-r--r--plugins/groupwise-features/camel-gw-listener.h59
-rw-r--r--plugins/groupwise-features/groupwise-account-setup.c138
-rw-r--r--plugins/groupwise-features/gw-ui.c457
-rw-r--r--plugins/groupwise-features/gw-ui.h38
-rw-r--r--plugins/groupwise-features/install-shared.c23
-rw-r--r--plugins/groupwise-features/junk-mail-settings.c74
-rw-r--r--plugins/groupwise-features/mail-retract.c86
-rw-r--r--plugins/groupwise-features/mail-send-options.c1
-rw-r--r--plugins/groupwise-features/org-gnome-groupwise-features.eplug.xml154
-rw-r--r--plugins/groupwise-features/process-meeting.c198
-rw-r--r--plugins/groupwise-features/proxy-login.c65
-rw-r--r--plugins/groupwise-features/proxy-login.h2
-rw-r--r--plugins/groupwise-features/proxy.c1
-rw-r--r--plugins/groupwise-features/share-folder-common.c72
-rw-r--r--plugins/groupwise-features/status-track.c109
17 files changed, 2033 insertions, 501 deletions
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 <http://www.gnu.org/licenses/>
+ *
+ *
+ * Authors:
+ * Sivaiah Nallagatla <snallagatla@novell.com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "camel-gw-listener.h"
+#include <string.h>
+#include <camel/camel-i18n.h>
+#include <e-gw-connection.h>
+#include <libedataserverui/e-passwords.h>
+#include "e-util/e-error.h"
+#include <libedataserver/e-account.h>
+#include <libecal/e-cal.h>
+
+/*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 <http://www.gnu.org/licenses/>
+ *
+ *
+ * Authors:
+ * Sivaiah Nallagatla <snallagatla@novell.com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#ifndef CAMEL_GW_LISTENER_H
+#define CAMEL_GW_LISTENER_H
+
+#include <libedataserver/e-account-list.h>
+#include<libedataserver/e-source.h>
+#include<libedataserver/e-source-list.h>
+#include <camel/camel-url.h>
+
+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 <http://www.gnu.org/licenses/>
+ *
+ *
+ * Authors:
+ * Sivaiah Nallagatla <snallagatla@novell.com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#include "camel-gw-listener.h"
+#include <gtk/gtk.h>
+#include "mail/em-config.h"
+#include <gconf/gconf-client.h>
+#include "shell/es-event.h"
+#include <string.h>
+
+#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 <http://www.gnu.org/licenses/>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#include <gtk/gtk.h>
+#include <glib/gi18n.h>
+
+#include <shell/e-shell-view.h>
+#include <shell/e-shell-window.h>
+
+#include <mail/e-mail-reader.h>
+#include <mail/em-folder-tree.h>
+#include <mail/em-folder-tree-model.h>
+
+#include <calendar/gui/e-calendar-view.h>
+#include <calendar/gui/gnome-cal.h>
+
+#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 <http://www.gnu.org/licenses/>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#ifndef GW_UI_HEADER
+#define GW_UI_HEADER
+
+#include <gtk/gtk.h>
+#include <shell/e-shell-view.h>
+
+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 <glib/gi18n.h>
#include <gconf/gconf-client.h>
#include <e-util/e-config.h>
+#include <shell/e-shell.h>
#include <mail/em-config.h>
#include <mail/em-event.h>
-#include <mail/mail-component.h>
#include <camel/camel-mime-message.h>
#include <camel/camel-folder.h>
#include <camel/camel-stream.h>
@@ -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 <stdio.h>
#include <gtk/gtk.h>
-#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 <mail/em-folder-view.h>
+#include <mail/e-mail-reader.h>
+
#include <e-gw-connection.h>
-#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 <config.h>
#endif
-#include <mail/em-popup.h>
-#include <mail/em-folder-view.h>
#include <glib/gi18n-lib.h>
-#include <share-folder.h>
#include <e-gw-connection.h>
#include <camel/camel-store.h>
#include <camel/camel-folder.h>
+
#include <e-util/e-error.h>
-void org_gnome_retract_message (EPlugin *ep, EMPopupTargetSelect *t);
+#include <mail/e-mail-reader.h>
+
+#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 @@
<?xml version="1.0"?>
<e-plugin-list>
<e-plugin id="org.gnome.evolution.groupwise_features" type="shlib" _name="GroupWise Features"
- location="@PLUGINDIR@/liborg-gnome-groupwise-features@SOEXT@">
+ location="@PLUGINDIR@/liborg-gnome-groupwise-features@SOEXT@" load-on-startup="true" system_plugin="true">
+
<author name="Sivaiah Nallagatla" email="snallagatla@novell.com" />
<author name="Vivek Jain" email="jvivek@novell.com" />
<author name="Chenthill Palanisamy" email="pchenthill@novell.com"/>
@@ -11,107 +12,84 @@
<author name="Raghavendran R" email="raghavguru7@gmail.com"/>
<_description>Fine-tune your GroupWise accounts.</_description>
+
<hook class="org.gnome.evolution.mail.config:1.0">
- <group id="org.gnome.evolution.mail.folderConfig" target="folder"
- check= "shared_folder_check"
- commit="shared_folder_commit"
- abort ="shared_folder_abort">
- <item
- type="page"
- path="10.shared"
- label="Shared"
- factory="org_gnome_shared_folder_factory"/>
+ <group id="org.gnome.evolution.mail.folderConfig" target="folder" check= "shared_folder_check" commit="shared_folder_commit" abort ="shared_folder_abort">
+ <item type="page" path="10.shared" label="Shared" factory="org_gnome_shared_folder_factory"/>
</group>
- <group id="org.gnome.evolution.mail.config.accountEditor" target="account"
- check = "send_options_changed"
- commit = "send_options_commit"
- abort = "send_options_abort">
- <item
- type="section"
- path="40.defaults/50.send_options"
- label="Send Options"
- factory="org_gnome_send_options" />
+ <group id="org.gnome.evolution.mail.config.accountEditor" target="account" check = "send_options_changed" commit = "send_options_commit" abort = "send_options_abort">
+ <item type="section" path="40.defaults/50.send_options" label="Send Options" factory="org_gnome_send_options" />
</group>
- </hook>
- <hook class="org.gnome.evolution.mail.events:1.0">
- <event
- target="message"
- id="message.reading"
- type="pass"
- handle="org_gnome_popup_wizard"/>
- </hook>
- <hook class="org.gnome.evolution.mail.popup:1.0">
- <menu id="org.gnome.evolution.mail.foldertree.popup" target="folder" factory = "org_gnome_create_option">
- </menu>
- <menu id="org.gnome.evolution.mail.folderview.popup" target="select" factory = "org_gnome_junk_settings"/>
- <menu id="org.gnome.evolution.mail.folderview.popup" target="select" factory = "org_gnome_track_status"/>
- </hook>
- <hook class="org.gnome.evolution.addressbook.config:1.0">
- <group
- id="com.novell.evolution.addressbook.config.accountEditor" target="source"
- commit="commit_groupwise_addressbook">
- <item
- type="item"
- path="00.general/10.display/00.gw_dummy"
- factory="e_book_groupwise_dummy"/>
+ <group id="org.gnome.evolution.mail.config.accountEditor" target="account" commit = "proxy_commit" abort="proxy_abort">
+ <item type="page" path="60.proxy" factory="org_gnome_proxy"/>
</group>
- <group
- id="com.novell.evolution.addressbook.config.accountEditor" target="source"
- commit="commit_groupwise_addressbook">
- <item
- type="item"
- path="00.general/10.display/00.gw_dummy"
- factory="e_book_groupwise_dummy"/>
+
+ <group target="account" id="org.gnome.evolution.mail.config.accountAssistant">
+ <item type="item_table" path="20.receive_options/30.soapport/50.dummy" factory="org_gnome_groupwise_account_setup"/>
+ </group>
+ <group target="account" id="org.gnome.evolution.mail.config.accountEditor">
+ <item type="item_table" path="20.receive_options/30.soapport/50.dummy" factory="org_gnome_groupwise_account_setup"/>
+ </group>
+ <group target="account" id="org.gnome.evolution.mail.config.accountWizard">
+ <item type="item_table" path="20.receive_options/30.soapport/50.dummy" factory="org_gnome_groupwise_account_setup"/>
</group>
- </hook>
- <hook class="org.gnome.evolution.mail.events:1.0">
- <event
- id="composer.selectsendoption"
- handle="org_gnome_composer_send_options"
- target="composer"
- enable="sendoption"
- />
</hook>
- <hook class="org.gnome.evolution.mail.events:1.0">
- <event
- id="message.replying"
- handle="org_gnome_composer_message_reply"
- target="message"
- enable="reply"
- />
+ <!-- cannot have one hook with two same ui-manager id-s, thus splitting here -->
+ <hook class="org.gnome.evolution.ui:1.0">
+ <ui-manager id="org.gnome.evolution.mail" callback="gw_ui_mail_folder_popup">
+ <popup name="mail-folder-popup">
+ <placeholder name="mail-folder-popup-actions">
+ <menuitem action="gw-new-shared-folder"/>
+ <menuitem action="gw-proxy-login"/>
+ </placeholder>
+ </popup>
+ </ui-manager>
</hook>
- <hook class="org.gnome.evolution.mail.config:1.0">
- <group id="org.gnome.evolution.mail.config.accountEditor"
- target="account" commit = "proxy_commit" abort="proxy_abort">
- <item type="page" path="60.proxy" factory="org_gnome_proxy"/>
- </group>
- </hook>
-
- <hook class="org.gnome.evolution.mail.popup:1.0">
- <menu id="org.gnome.evolution.mail.foldertree.popup" target="folder"
- factory = "org_gnome_create_proxy_login_option">
- </menu>
- </hook>
-
-
- <hook class="org.gnome.evolution.calendar.popup:1.0">
- <menu id="org.gnome.evolution.calendar.view.popup" target="select" factory = "org_gnome_accept">
- </menu>
+ <hook class="org.gnome.evolution.ui:1.0">
+ <ui-manager id="org.gnome.evolution.mail" callback="gw_ui_mail_message_popup">
+ <popup name="mail-message-popup">
+ <placeholder name="mail-message-popup-actions">
+ <separator />
+ <menuitem action="gw-junk-mail-settings"/>
+ <menuitem action="gw-track-message-status"/>
+ <separator />
+ <menuitem action="gw-retract-mail"/>
+ </placeholder>
+ </popup>
+ </ui-manager>
+
+ <ui-manager id="org.gnome.evolution.calendar" callback="gw_ui_calendar_event_popup">
+ <popup name="calendar-event-popup">
+ <placeholder name="event-popup-actions">
+ <menuitem action="gw-meeting-accept"/>
+ <menuitem action="gw-meeting-accept-tentative"/>
+ <menuitem action="gw-meeting-decline"/>
+ <menuitem action="gw-resend-meeting"/>
+ </placeholder>
+ </popup>
+ </ui-manager>
</hook>
- <hook class="org.gnome.evolution.calendar.popup:1.0">
- <menu id="org.gnome.evolution.calendar.view.popup" target="select" factory = "org_gnome_retract_resend">
- </menu>
+ <hook class="org.gnome.evolution.mail.events:1.0">
+ <event target="message" id="message.reading" type="pass" handle="org_gnome_popup_wizard"/>
+ <event id="composer.selectsendoption" handle="org_gnome_composer_send_options" target="composer" enable="sendoption"/>
+ <event id="message.replying" handle="org_gnome_composer_message_reply" target="message" enable="reply"/>
</hook>
- <hook class="org.gnome.evolution.mail.popup:1.0">
- <menu id="org.gnome.evolution.mail.folderview.popup" target="select"
- factory = "org_gnome_retract_message">
- </menu>
+ <hook class="org.gnome.evolution.addressbook.config:1.0">
+ <group id="com.novell.evolution.addressbook.config.accountEditor" target="source" commit="commit_groupwise_addressbook">
+ <item type="item" path="00.general/10.display/00.gw_dummy" factory="e_book_groupwise_dummy"/>
+ </group>
+ <group id="com.novell.evolution.addressbook.config.accountEditor" target="source" commit="commit_groupwise_addressbook">
+ <item type="item" path="00.general/10.display/00.gw_dummy" factory="e_book_groupwise_dummy"/>
+ </group>
</hook>
-
+
+ <hook class="org.gnome.evolution.shell.events:1.0">
+ <event id="upgrade.done" handle="ensure_mandatory_esource_properties" target="upgrade"/>
+ </hook>
</e-plugin>
</e-plugin-list>
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 <string.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
-#include <calendar/gui/e-cal-popup.h>
+#include <libecal/e-cal.h>
+
+#include <e-util/e-error.h>
+
#include <calendar/gui/e-calendar-view.h>
#include <calendar/gui/itip-utils.h>
-#include <e-util/e-error.h>
-#include <libecal/e-cal.h>
+#include <calendar/gui/gnome-cal.h>
+
+#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 <glade/glade.h>
#include <libedataserverui/e-passwords.h>
-#include <mail/mail-component.h>
#include <mail/em-folder-tree.h>
#include <mail/mail-config.h>
#include <mail/em-folder-selector.h>
-#include <mail/em-popup.h>
#include <mail/em-account-editor.h>
#include <camel/camel-url.h>
#include <camel/camel-store.h>
@@ -49,6 +47,8 @@
#include <e-gw-connection.h>
#include <e-gw-message.h>
#include <libedataserverui/e-name-selector.h>
+
+#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 <mail/em-account-editor.h>
#include <mail/em-config.h>
-#include <mail/mail-component.h>
#include <mail/mail-ops.h>
#include <mail/mail-session.h>
#include <libedataserver/e-account.h>
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 <glib/gi18n.h>
#include <e-util/e-config.h>
#include <mail/em-config.h>
-#include <mail/em-popup.h>
#include <mail/em-folder-properties.h>
#include <mail/em-folder-tree.h>
#include <mail/em-folder-selector.h>
#include <mail/mail-mt.h>
-#include <mail/mail-component.h>
#include <mail/mail-config.h>
#include <mail/mail-vfolder.h>
#include <mail/em-vfolder-rule.h>
@@ -48,7 +46,10 @@
#include <e-gw-container.h>
#include <e-gw-connection.h>
#include <glade/glade.h>
+#include <shell/e-shell-sidebar.h>
#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 <time.h>
#include <gtk/gtk.h>
-#include "camel/camel-folder.h"
-#include "camel/camel-mime-utils.h"
-#include "camel/camel-medium.h"
-#include "camel/camel-mime-message.h"
-#include <mail/em-popup.h>
-#include <mail/em-folder-view.h>
+#include <camel/camel-folder.h>
+#include <camel/camel-mime-utils.h>
+#include <camel/camel-medium.h>
+#include <camel/camel-mime-message.h>
+
+#include <mail/e-mail-reader.h>
#include <e-gw-connection.h>
-#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 ("<b>%s</b>", _("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 ("<b>%s</b>", _("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);
}