evolution r36781 - branches/EXCHANGE_MAPI_BRANCH/plugins/exchange-mapi
- From: msuman svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution r36781 - branches/EXCHANGE_MAPI_BRANCH/plugins/exchange-mapi
- Date: Thu, 13 Nov 2008 08:25:59 +0000 (UTC)
Author: msuman
Date: Thu Nov 13 08:25:59 2008
New Revision: 36781
URL: http://svn.gnome.org/viewvc/evolution?rev=36781&view=rev
Log:
MAPI Account setup plugin - cleanup - part 1.
Added:
branches/EXCHANGE_MAPI_BRANCH/plugins/exchange-mapi/exchange-mapi-account-listener.c
branches/EXCHANGE_MAPI_BRANCH/plugins/exchange-mapi/exchange-mapi-account-listener.h
Removed:
branches/EXCHANGE_MAPI_BRANCH/plugins/exchange-mapi/exchange-account-listener.c
branches/EXCHANGE_MAPI_BRANCH/plugins/exchange-mapi/exchange-account-listener.h
Modified:
branches/EXCHANGE_MAPI_BRANCH/plugins/exchange-mapi/ChangeLog
branches/EXCHANGE_MAPI_BRANCH/plugins/exchange-mapi/Makefile.am
branches/EXCHANGE_MAPI_BRANCH/plugins/exchange-mapi/exchange-mapi-account-setup.c
branches/EXCHANGE_MAPI_BRANCH/plugins/exchange-mapi/exchange-mapi-account-setup.h
branches/EXCHANGE_MAPI_BRANCH/plugins/exchange-mapi/org-gnome-exchange-mapi.eplug.xml
Modified: branches/EXCHANGE_MAPI_BRANCH/plugins/exchange-mapi/Makefile.am
==============================================================================
--- branches/EXCHANGE_MAPI_BRANCH/plugins/exchange-mapi/Makefile.am (original)
+++ branches/EXCHANGE_MAPI_BRANCH/plugins/exchange-mapi/Makefile.am Thu Nov 13 08:25:59 2008
@@ -22,8 +22,8 @@
liborg_gnome_exchange_mapi_la_SOURCES = \
exchange-mapi-account-setup.c \
exchange-mapi-account-setup.h \
- exchange-account-listener.c \
- exchange-account-listener.h
+ exchange-mapi-account-listener.c \
+ exchange-mapi-account-listener.h
liborg_gnome_exchange_mapi_la_LIBADD = \
$(top_builddir)/e-util/libeutil.la \
@@ -39,9 +39,6 @@
liborg_gnome_exchange_mapi_la_LDFLAGS = -module -avoid-version -lmapi $(NO_UNDEFINED)
liborg_gnome_exchange_mapi_la_CFLAGS = -I/usr/local/samba/include/
-#error_DATA = org-gnome-exchange-operations.error
-#errordir = $(privdatadir)/errors
-
EXTRA_DIST = \
org-gnome-exchange-mapi.eplug.xml
Added: branches/EXCHANGE_MAPI_BRANCH/plugins/exchange-mapi/exchange-mapi-account-listener.c
==============================================================================
--- (empty file)
+++ branches/EXCHANGE_MAPI_BRANCH/plugins/exchange-mapi/exchange-mapi-account-listener.c Thu Nov 13 08:25:59 2008
@@ -0,0 +1,852 @@
+/*
+ * 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:
+ * Srinivasa Ragavan <sragavan novell com>
+ * Suman Manjunath <msuman novell com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "exchange-mapi-account-listener.h"
+#include "exchange-mapi-account-setup.h"
+#include <string.h>
+#include <camel/camel-i18n.h>
+#include <libedataserverui/e-passwords.h>
+#include "e-util/e-error.h"
+#include <libedataserver/e-account.h>
+#include <libecal/e-cal.h>
+#include <libedataserver/e-account-list.h>
+#include <libedataserver/e-source.h>
+#include <libedataserver/e-source-list.h>
+#include <camel/camel-url.h>
+
+#include <libmapi/libmapi.h>
+
+
+/* FIXME: The mapi should not be needed in the include statement.
+LIMBAPI_CFLAGS or something is going wrong */
+
+#include <mapi/exchange-mapi-folder.h>
+#include <mapi/exchange-mapi-connection.h>
+#include <mapi/exchange-mapi-utils.h>
+
+#define d(x) x
+
+struct _ExchangeMAPIAccountListenerPrivate {
+ GConfClient *gconf_client;
+ /* we get notification about mail account changes from this object */
+ EAccountList *account_list;
+};
+
+typedef struct _ExchangeMAPIAccountInfo ExchangeMAPIAccountInfo;
+
+/* stores some info about all currently existing mapi accounts */
+struct _ExchangeMAPIAccountInfo {
+ char *uid;
+ char *name;
+ char *source_url;
+};
+
+/* list of ExchangeMAPIAccountInfo structures */
+static GList *mapi_accounts = NULL;
+
+#define PARENT_TYPE G_TYPE_OBJECT
+
+static GObjectClass *parent_class = NULL;
+
+static void
+dispose (GObject *object)
+{
+ ExchangeMAPIAccountListener *config_listener = EXCHANGE_MAPI_ACCOUNT_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)
+{
+ ExchangeMAPIAccountListener *config_listener = EXCHANGE_MAPI_ACCOUNT_LISTENER (object);
+ GList *list;
+
+ if (config_listener->priv) {
+ g_free (config_listener->priv);
+ }
+
+ for (list = g_list_first (mapi_accounts); list ; list = g_list_next (list)) {
+ ExchangeMAPIAccountInfo *info = (ExchangeMAPIAccountInfo *)(list->data);
+ if (info) {
+ g_free (info->uid);
+ g_free (info->name);
+ g_free (info->source_url);
+ g_free (info);
+ }
+ }
+
+ g_list_free (mapi_accounts);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
+exchange_mapi_account_listener_class_init (ExchangeMAPIAccountListenerClass *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
+exchange_mapi_account_listener_init (ExchangeMAPIAccountListener *config_listener, ExchangeMAPIAccountListenerClass *class)
+{
+ config_listener->priv = g_new0 (ExchangeMAPIAccountListenerPrivate, 1);
+}
+
+
+static GSList *folders_list = NULL;
+
+GSList *
+exchange_mapi_account_listener_peek_folder_list (void)
+{
+ if (!folders_list)
+ folders_list = exchange_mapi_peek_folder_list ();
+
+ return folders_list;
+}
+
+void
+exchange_mapi_account_listener_get_folder_list (void)
+{
+ if (folders_list)
+ return;
+
+ folders_list = exchange_mapi_peek_folder_list ();
+}
+
+void
+exchange_mapi_account_listener_free_folder_list (void)
+{
+ exchange_mapi_folder_list_free ();
+ folders_list = NULL;
+}
+
+/*determines whehter the passed in account is exchange or not by looking at source url */
+
+static gboolean
+is_mapi_account (EAccount *account)
+{
+ return (account->source->url && (g_ascii_strncasecmp (account->source->url, MAPI_URI_PREFIX, MAPI_PREFIX_LENGTH) == 0));
+}
+
+/* looks up for an existing exchange account info in the mapi_accounts list based on uid */
+
+static ExchangeMAPIAccountInfo*
+lookup_account_info (const char *key)
+{
+ GList *list;
+
+ g_return_val_if_fail (key != NULL, NULL);
+
+ for (list = g_list_first (mapi_accounts); list; list = g_list_next (list)) {
+ ExchangeMAPIAccountInfo *info = (ExchangeMAPIAccountInfo *)(list->data);
+ if (g_ascii_strcasecmp (info->uid, key) == 0)
+ return info;
+ }
+
+ return NULL;
+}
+
+#define CALENDAR_SOURCES "/apps/evolution/calendar/sources"
+#define TASK_SOURCES "/apps/evolution/tasks/sources"
+#define JOURNAL_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_JOURNALS "/apps/evolution/calendar/memos/selected_memos"
+
+#define ITIP_MESSAGE_HANDLING "/apps/evolution/itip/delete_processed"
+
+static void
+add_cal_esource (EAccount *account, GSList *folders, ExchangeMAPIFolderType folder_type, CamelURL *url)
+{
+ ESourceList *source_list = NULL;
+ ESourceGroup *group = NULL;
+ const gchar *conf_key = NULL, *source_selection_key = NULL;
+ GSList *temp_list = NULL;
+ GConfClient* client;
+ GSList *ids, *temp ;
+ gchar *base_uri = NULL;
+
+ if (folder_type == MAPI_FOLDER_TYPE_APPOINTMENT) {
+ conf_key = CALENDAR_SOURCES;
+ source_selection_key = SELECTED_CALENDARS;
+ } else if (folder_type == MAPI_FOLDER_TYPE_TASK) {
+ conf_key = TASK_SOURCES;
+ source_selection_key = SELECTED_TASKS;
+ } else if (folder_type == MAPI_FOLDER_TYPE_MEMO) {
+ conf_key = JOURNAL_SOURCES;
+ source_selection_key = SELECTED_JOURNALS;
+ } else {
+ g_warning ("%s(%d): %s: Unknown ExchangeMAPIFolderType\n", __FILE__, __LINE__, __PRETTY_FUNCTION__);
+ return;
+ }
+
+ client = gconf_client_get_default ();
+ gconf_client_set_bool (client, ITIP_MESSAGE_HANDLING, TRUE, NULL);
+ source_list = e_source_list_new_for_gconf (client, conf_key);
+ base_uri = g_strdup_printf ("%s%s %s/", MAPI_URI_PREFIX, url->user, url->host);
+ group = e_source_group_new (account->name, base_uri);
+ g_free (base_uri);
+ e_source_group_set_property (group, "create_source", "yes");
+ e_source_group_set_property (group, "username", url->user);
+ e_source_group_set_property (group, "host", url->host);
+ e_source_group_set_property (group, "profile", camel_url_get_param (url, "profile"));
+ e_source_group_set_property (group, "domain", camel_url_get_param (url, "domain"));
+
+ /* We set these because on new folder creation - these are required. */
+ e_source_group_set_property (group, "acl-user-name", account->id->name);
+ e_source_group_set_property (group, "acl-user-email", account->id->address);
+ e_source_group_set_property (group, "acl-owner-name", account->id->name);
+ e_source_group_set_property (group, "acl-owner-email", account->id->address);
+
+ for (temp_list = folders; temp_list != NULL; temp_list = g_slist_next (temp_list)) {
+ ExchangeMAPIFolder *folder = temp_list->data;
+ ESource *source = NULL;
+ gchar *relative_uri = NULL, *fid = NULL;
+
+ if (folder->container_class != folder_type)
+ continue;
+
+ fid = exchange_mapi_util_mapi_id_to_string (folder->folder_id);
+ relative_uri = g_strconcat (";", fid, NULL);
+ source = e_source_new (folder->folder_name, relative_uri);
+ e_source_set_property (source, "auth", "1");
+ e_source_set_property (source, "auth-domain", EXCHANGE_MAPI_PASSWORD_COMPONENT);
+ e_source_set_property (source, "auth-type", "plain/password");
+ e_source_set_property (source, "username", url->user);
+ e_source_set_property (source, "host", url->host);
+ e_source_set_property (source, "profile", camel_url_get_param (url, "profile"));
+ e_source_set_property (source, "domain", camel_url_get_param (url, "domain"));
+ e_source_set_property (source, "folder-id", fid);
+ e_source_set_property (source, "offline_sync",
+ camel_url_get_param (url, "offline_sync") ? "1" : "0");
+
+ if (folder->is_default)
+ e_source_set_property (source, "delete", "no");
+
+ if (folder->parent_folder_id) {
+ gchar *tmp = exchange_mapi_util_mapi_id_to_string (folder->parent_folder_id);
+ e_source_set_property (source, "parent-fid", tmp);
+ g_free (tmp);
+ }
+
+ e_source_set_property (source, "acl-user-name", account->id->name);
+ e_source_set_property (source, "acl-user-email", account->id->address);
+ /* FIXME: this would change after foreign folders/delegation is implemented */
+ e_source_set_property (source, "acl-owner-name", account->id->name);
+ e_source_set_property (source, "acl-owner-email", account->id->address);
+
+ e_source_group_add_source (group, source, -1);
+
+ if (source_selection_key && folder->is_default) {
+ 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);
+
+ for (temp = ids; temp != NULL; temp = g_slist_next (temp))
+ g_free (temp->data);
+
+ g_slist_free (ids);
+ }
+
+ g_object_unref (source);
+ g_free (relative_uri);
+ g_free (fid);
+ }
+
+ if (!e_source_list_add_group (source_list, group, -1))
+ return;
+
+ if (!e_source_list_sync (source_list, NULL))
+ return;
+
+ g_object_unref (group);
+ g_object_unref (source_list);
+ g_object_unref (client);
+}
+
+static void
+remove_cal_esource (EAccount *existing_account_info, ExchangeMAPIFolderType folder_type, CamelURL *url)
+{
+ ESourceList *list;
+ const gchar *conf_key = NULL, *source_selection_key = NULL;
+ GSList *groups;
+ gboolean found_group;
+ GConfClient* client;
+ GSList *ids;
+ GSList *node_tobe_deleted;
+ gchar *base_uri;
+
+ if (folder_type == MAPI_FOLDER_TYPE_APPOINTMENT) {
+ conf_key = CALENDAR_SOURCES;
+ source_selection_key = SELECTED_CALENDARS;
+ } else if (folder_type == MAPI_FOLDER_TYPE_TASK) {
+ conf_key = TASK_SOURCES;
+ source_selection_key = SELECTED_TASKS;
+ } else if (folder_type == MAPI_FOLDER_TYPE_MEMO) {
+ conf_key = JOURNAL_SOURCES;
+ source_selection_key = SELECTED_JOURNALS;
+ } else {
+ g_warning ("%s(%d): %s: Unknown ExchangeMAPIFolderType\n", __FILE__, __LINE__, __PRETTY_FUNCTION__);
+ return;
+ }
+
+ client = gconf_client_get_default();
+ gconf_client_set_bool (client, ITIP_MESSAGE_HANDLING, FALSE, NULL);
+ list = e_source_list_new_for_gconf (client, conf_key);
+ groups = e_source_list_peek_groups (list);
+
+ base_uri = g_strdup_printf ("mapi://%s %s/", url->user, url->host);
+
+ 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), existing_account_info->name) == 0 &&
+ strcmp (e_source_group_peek_base_uri (group), 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 (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_free (base_uri);
+ g_object_unref (list);
+ g_object_unref (client);
+}
+
+static void
+modify_cal_esource (EAccount *account, ExchangeMAPIFolderType folder_type, CamelURL *url, ExchangeMAPIAccountInfo *existing_account_info)
+{
+ ESourceList *list;
+ GSList *groups;
+ gboolean found_group;
+ GConfClient* client;
+ const gchar *conf_key = NULL;
+ gchar *base_uri;
+
+ if (folder_type == MAPI_FOLDER_TYPE_APPOINTMENT) {
+ conf_key = CALENDAR_SOURCES;
+ } else if (folder_type == MAPI_FOLDER_TYPE_TASK) {
+ conf_key = TASK_SOURCES;
+ } else if (folder_type == MAPI_FOLDER_TYPE_MEMO) {
+ conf_key = JOURNAL_SOURCES;
+ } else {
+ g_warning ("%s(%d): %s: Unknown ExchangeMAPIFolderType\n", __FILE__, __LINE__, __PRETTY_FUNCTION__);
+ return;
+ }
+
+ client = gconf_client_get_default();
+ list = e_source_list_new_for_gconf (client, conf_key);
+ groups = e_source_list_peek_groups (list);
+
+ base_uri = g_strdup_printf ("mapi://%s %s/", url->user, url->host);
+
+ 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), existing_account_info->name) == 0 &&
+ strcmp (e_source_group_peek_base_uri (group), base_uri) == 0) {
+ found_group = TRUE;
+ e_source_group_set_name (group, account->name);
+ e_source_list_sync (list, NULL);
+ }
+ }
+
+ g_free (base_uri);
+ g_object_unref (list);
+ g_object_unref (client);
+}
+
+/* add sources for calendar and tasks if the account added is exchange account
+ adds the new account info to mapi_accounts list */
+
+static void
+add_calendar_sources (EAccount *account, GSList *folders, ExchangeMAPIAccountInfo *info)
+{
+ CamelURL *url;
+
+ url = camel_url_new (info->source_url, NULL);
+
+ if (url) {
+ add_cal_esource (account, folders, MAPI_FOLDER_TYPE_APPOINTMENT, url);
+ add_cal_esource (account, folders, MAPI_FOLDER_TYPE_TASK, url);
+ add_cal_esource (account, folders, MAPI_FOLDER_TYPE_MEMO, url);
+ }
+
+ camel_url_free (url);
+}
+
+/* removes calendar and tasks sources if the account removed is exchange account
+ removes the the account info from mapi_account list */
+
+static void
+remove_calendar_sources (EAccount *account, ExchangeMAPIAccountInfo *info)
+{
+ CamelURL *url;
+
+ url = camel_url_new (info->source_url, NULL);
+
+ if (url) {
+ remove_cal_esource (account, MAPI_FOLDER_TYPE_APPOINTMENT, url);
+ remove_cal_esource (account, MAPI_FOLDER_TYPE_TASK, url);
+ remove_cal_esource (account, MAPI_FOLDER_TYPE_MEMO, url);
+ }
+
+ camel_url_free (url);
+}
+
+/* This is called only when the source-group name is to be changed */
+static void
+modify_calendar_sources (EAccount *account, ExchangeMAPIAccountInfo *existing_account_info)
+{
+ CamelURL *url;
+
+ url = camel_url_new (account->source->url, NULL);
+
+ if (url) {
+ modify_cal_esource (account, MAPI_FOLDER_TYPE_APPOINTMENT, url, existing_account_info);
+ modify_cal_esource (account, MAPI_FOLDER_TYPE_TASK, url, existing_account_info);
+ modify_cal_esource (account, MAPI_FOLDER_TYPE_MEMO, url, existing_account_info);
+ }
+
+ camel_url_free (url);
+}
+
+static gboolean
+add_addressbook_sources (EAccount *account, GSList *folders)
+{
+ CamelURL *url;
+ ESourceList *list;
+ ESourceGroup *group;
+ ESource *source;
+ char *base_uri;
+ GSList *temp_list;
+ GConfClient* client;
+
+ url = camel_url_new (account->source->url, NULL);
+ if (url == NULL) {
+ return FALSE;
+ }
+
+ base_uri = g_strdup_printf ("mapi://%s %s/", url->user, url->host);
+ 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);
+ e_source_group_set_property (group, "user", url->user);
+ e_source_group_set_property (group, "host", url->host);
+ e_source_group_set_property (group, "profile", camel_url_get_param (url, "profile"));
+ e_source_group_set_property (group, "domain", camel_url_get_param (url, "domain"));
+
+ for (temp_list = folders; temp_list != NULL; temp_list = g_slist_next (temp_list)) {
+ ExchangeMAPIFolder *folder = temp_list->data;
+ char *tmp = NULL;
+ if (folder->container_class != MAPI_FOLDER_TYPE_CONTACT)
+ continue;
+
+ source = e_source_new (folder->folder_name, g_strconcat (";",folder->folder_name, NULL));
+ e_source_set_property (source, "auth", "plain/password");
+ e_source_set_property (source, "auth-domain", EXCHANGE_MAPI_PASSWORD_COMPONENT);
+ e_source_set_property(source, "user", url->user);
+ e_source_set_property(source, "host", url->host);
+ e_source_set_property(source, "profile", camel_url_get_param (url, "profile"));
+ e_source_set_property(source, "domain", camel_url_get_param (url, "domain"));
+ tmp = exchange_mapi_util_mapi_id_to_string (folder->folder_id);
+ e_source_set_property(source, "folder-id", tmp);
+ g_free (tmp);
+ e_source_set_property (source, "offline_sync",
+ camel_url_get_param (url, "offline_sync") ? "1" : "0");
+ e_source_set_property (source, "completion", "true");
+ e_source_group_add_source (group, source, -1);
+ g_object_unref (source);
+ }
+
+ //Add GAL
+ {
+ char *uri;
+ uri = g_strdup_printf("galldap://%s %s/;Global Address List", url->user, url->host);
+ source = e_source_new_with_absolute_uri ("Global Address List", uri);
+// source = e_source_new ("Global Address List", g_strconcat (";","Global Address List" , NULL));
+ e_source_set_property (source, "auth", "plain/password");
+ e_source_set_property (source, "auth-domain", "GALLDAP");
+ e_source_set_property(source, "user", url->user);
+ e_source_set_property(source, "host", camel_url_get_param (url, "ad_server"));
+ e_source_set_property(source, "view-limit", camel_url_get_param (url, "ad_limit"));
+ e_source_set_property(source, "profile", camel_url_get_param (url, "profile"));
+ e_source_set_property(source, "domain", camel_url_get_param (url, "domain"));
+// e_source_set_property (source, "offline_sync",
+// camel_url_get_param (url, "offline_sync") ? "1" : "0");
+ e_source_set_property(source, "offline_sync", "1");
+ e_source_set_property (source, "completion", "true");
+ 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);
+
+ return TRUE;
+}
+
+static void
+remove_addressbook_sources (ExchangeMAPIAccountInfo *existing_account_info)
+{
+ ESourceList *list;
+ ESourceGroup *group;
+ GSList *groups;
+ gboolean found_group;
+ CamelURL *url;
+ char *base_uri;
+ GConfClient *client;
+
+ url = camel_url_new (existing_account_info->source_url, NULL);
+ if (url == NULL) {
+ return;
+ }
+
+ base_uri = g_strdup_printf ("mapi://%s %s/", url->user, url->host);
+ 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
+modify_addressbook_sources (EAccount *account, ExchangeMAPIAccountInfo *existing_account_info)
+{
+ CamelURL *url;
+ ESourceList *list;
+ ESourceGroup *group;
+ GSList *groups;
+ gboolean found_group;
+ char *old_base_uri;
+ GConfClient *client;
+
+ url = camel_url_new (existing_account_info->source_url, NULL);
+ if (url == NULL)
+ return;
+
+ old_base_uri = g_strdup_printf ("mapi://%s %s/", url->user, url->host);
+ camel_url_free (url);
+
+ client = gconf_client_get_default ();
+ list = e_source_list_new_for_gconf (client, "/apps/evolution/addressbook/sources");
+ groups = e_source_list_peek_groups (list);
+
+ 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;
+ e_source_group_set_name (group, account->name);
+ e_source_list_sync (list, NULL);
+ }
+ }
+
+ g_free (old_base_uri);
+ g_object_unref (list);
+ g_object_unref (client);
+}
+
+static void
+account_added (EAccountList *account_listener, EAccount *account)
+{
+ ExchangeMAPIAccountInfo *info;
+
+ d(g_print("account added\n"));
+ if (!is_mapi_account (account))
+ return;
+
+ info = g_new0 (ExchangeMAPIAccountInfo, 1);
+ info->uid = g_strdup (account->uid);
+ info->name = g_strdup (account->name);
+ info->source_url = g_strdup (account->source->url);
+
+ /* Fetch the folders into a global list for future use.*/
+ exchange_mapi_account_listener_get_folder_list ();
+
+ add_addressbook_sources (account, folders_list);
+ add_calendar_sources (account, folders_list, info);
+ /*FIXME: Maybe the folders_list above should be freed */
+
+ mapi_accounts = g_list_append (mapi_accounts, info);
+}
+
+static void
+account_removed (EAccountList *account_listener, EAccount *account)
+{
+ ExchangeMAPIAccountInfo *info;
+ CamelURL *url;
+
+ d(g_print("Account removed\n"));
+ if (!is_mapi_account (account))
+ return;
+
+ info = lookup_account_info (account->uid);
+ if (info == NULL)
+ return;
+
+ exchange_mapi_account_listener_get_folder_list ();
+
+ /* This foo needs a lotta work.. at present, using this to remove calendar sources */
+
+ remove_addressbook_sources (info);
+ remove_calendar_sources (account, info);
+
+ mapi_accounts = g_list_remove (mapi_accounts, info);
+ url = camel_url_new (info->source_url, NULL);
+ if (url != NULL) {
+ const char *profile = camel_url_get_param (url, "profile");
+ exchange_mapi_delete_profile (profile);
+ camel_url_free (url);
+ }
+
+ g_free (info->uid);
+ g_free (info->name);
+ g_free (info->source_url);
+ g_free (info);
+}
+
+#define CMP(parm) strcmp(camel_url_get_param(old_url, parm), camel_url_get_param(new_url, parm))
+
+static void
+account_changed (EAccountList *account_listener, EAccount *account)
+{
+ gboolean bis_mapi_account;
+ CamelURL *old_url, *new_url;
+ ExchangeMAPIAccountInfo *existing_account_info;
+
+ d(g_print("account changed\n"));
+ bis_mapi_account = is_mapi_account (account);
+
+ existing_account_info = lookup_account_info (account->uid);
+
+ exchange_mapi_account_listener_get_folder_list ();
+
+ if (existing_account_info == NULL && bis_mapi_account) {
+ if (!account->enabled)
+ return;
+
+ /* some account of other type is changed to MAPI */
+ account_added (account_listener, account);
+ } else if (existing_account_info != NULL && !bis_mapi_account) {
+ /*MAPI account is changed to some other type */
+ account_removed (account_listener, account);
+ } else if (existing_account_info != NULL && bis_mapi_account) {
+ gboolean bnew = FALSE;
+ gboolean modified = FALSE;
+ if (!account->enabled) {
+ remove_addressbook_sources (existing_account_info);
+ remove_calendar_sources (account, existing_account_info);
+ return;
+ }
+
+ /* some info of mapi account is changed . update the sources with new info if required */
+ old_url = camel_url_new (existing_account_info->source_url, NULL);
+ new_url = camel_url_new (account->source->url, NULL);
+
+ if (CMP("domain") || strcmp (old_url->user, new_url->user)|| strcmp (old_url->host, new_url->host)) {
+ /* Need to recreate the profile */
+ char *password, *key;
+ gboolean status;
+
+ key = camel_url_to_string (new_url, CAMEL_URL_HIDE_PASSWORD | CAMEL_URL_HIDE_PARAMS);
+ password = e_passwords_get_password (EXCHANGE_MAPI_PASSWORD_COMPONENT, key);
+ if (!password) {
+ gboolean remember = FALSE;
+ gchar *title;
+
+ title = g_strdup_printf (_("Enter Password for %s"), new_url->user);
+ password = e_passwords_ask_password (title, EXCHANGE_MAPI_PASSWORD_COMPONENT, key, title,
+ E_PASSWORDS_REMEMBER_FOREVER|E_PASSWORDS_SECRET,
+ &remember, NULL);
+ g_free (title);
+
+ if (!password) {
+ g_free (key);
+ g_warning ("Password canceled");
+ return;
+ }
+ }
+ g_free (key);
+ status = exchange_mapi_create_profile (new_url->user, password, camel_url_get_param (new_url, "domain"), new_url->host);
+ if (!status) {
+ //FIXME: Give a warning and forget password.
+ g_warning ("Unable to create profile");
+ return;
+ }
+
+ bnew = TRUE;
+ }
+
+ if (!bnew && strcmp (existing_account_info->name, account->name)) {
+ /* just the source group names have to be modified.. no sweat.. */
+ modify_addressbook_sources (account, existing_account_info);
+ modify_calendar_sources (account, existing_account_info);
+ modified = TRUE;
+ } else {
+ remove_addressbook_sources (existing_account_info);
+ remove_calendar_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);
+ if (bnew || !modified) {
+ /* Free the old folderlist and get a new one */
+ exchange_mapi_account_listener_free_folder_list ();
+ exchange_mapi_account_listener_peek_folder_list ();
+ add_addressbook_sources (account, folders_list);
+ add_calendar_sources (account, folders_list, existing_account_info);
+ }
+
+ //FIXME: Update the profile about domain/server/user
+ camel_url_free (old_url);
+ camel_url_free (new_url);
+ }
+}
+
+static void
+exchange_mapi_account_listener_construct (ExchangeMAPIAccountListener *config_listener)
+{
+ EIterator *iter;
+ EAccount *account;
+ ExchangeMAPIAccountInfo *info ;
+
+ 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_mapi_account (account) && account->enabled) {
+
+ info = g_new0 (ExchangeMAPIAccountInfo, 1);
+ info->uid = g_strdup (account->uid);
+ info->name = g_strdup (account->name);
+ info->source_url = g_strdup (account->source->url);
+ mapi_accounts = g_list_append (mapi_accounts, info);
+
+ }
+
+ }
+
+ g_print ("MAPI listener is constructed \n");
+
+ 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
+exchange_mapi_account_listener_get_type (void)
+{
+ static GType exchange_mapi_account_listener_type = 0;
+
+ if (!exchange_mapi_account_listener_type) {
+ static GTypeInfo info = {
+ sizeof (ExchangeMAPIAccountListenerClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) exchange_mapi_account_listener_class_init,
+ NULL, NULL,
+ sizeof (ExchangeMAPIAccountListener),
+ 0,
+ (GInstanceInitFunc) exchange_mapi_account_listener_init
+ };
+ exchange_mapi_account_listener_type = g_type_register_static (PARENT_TYPE, "ExchangeMAPIAccountListener", &info, 0);
+ }
+
+ return exchange_mapi_account_listener_type;
+}
+
+ExchangeMAPIAccountListener *
+exchange_mapi_account_listener_new ()
+{
+ ExchangeMAPIAccountListener *config_listener;
+
+ config_listener = g_object_new (EXCHANGE_MAPI_ACCOUNT_LISTENER_TYPE, NULL);
+ config_listener->priv->gconf_client = gconf_client_get_default();
+
+ exchange_mapi_account_listener_construct (config_listener);
+
+ return config_listener;
+}
Added: branches/EXCHANGE_MAPI_BRANCH/plugins/exchange-mapi/exchange-mapi-account-listener.h
==============================================================================
--- (empty file)
+++ branches/EXCHANGE_MAPI_BRANCH/plugins/exchange-mapi/exchange-mapi-account-listener.h Thu Nov 13 08:25:59 2008
@@ -0,0 +1,58 @@
+/*
+ * 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:
+ * Srinivasa Ragavan <sragavan novell com>
+ *
+ * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
+ *
+ */
+
+#ifndef EXCHANGE_MAPI_ACCOUNT_LISTENER_H
+#define EXCHANGE_MAPI_ACCOUNT_LISTENER_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define EXCHANGE_MAPI_ACCOUNT_LISTENER_TYPE (exchange_mapi_account_listener_get_type ())
+#define EXCHANGE_MAPI_ACCOUNT_LISTENER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EXCHANGE_MAPI_ACCOUNT_LISTENER_TYPE, ExchangeMAPIAccountListener))
+#define EXCHANGE_MAPI_ACCOUNT_LISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EXCHANGE_MAPI_ACCOUNT_LISTENER_TYPE, ExchangeMAPIAccountListenerClass))
+#define EXCHANGE_IS_ACCOUNT_LISTENER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EXCHANGE_MAPI_ACCOUNT_LISTENER_TYPE))
+#define EXCHANGE_IS_ACCOUNT_LISTENER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EXCHANGE_MAPI_ACCOUNT_LISTENER_TYPE))
+
+typedef struct _ExchangeMAPIAccountListener ExchangeMAPIAccountListener;
+typedef struct _ExchangeMAPIAccountListenerClass ExchangeMAPIAccountListenerClass;
+typedef struct _ExchangeMAPIAccountListenerPrivate ExchangeMAPIAccountListenerPrivate;
+
+struct _ExchangeMAPIAccountListener {
+ GObject parent;
+ ExchangeMAPIAccountListenerPrivate *priv;
+};
+
+struct _ExchangeMAPIAccountListenerClass {
+ GObjectClass parent_class;
+};
+
+GType exchange_mapi_account_listener_get_type (void);
+ExchangeMAPIAccountListener * exchange_mapi_account_listener_new (void);
+GSList * exchange_mapi_account_listener_peek_folder_list (void);
+void exchange_mapi_account_listener_get_folder_list (void);
+void exchange_mapi_account_listener_free_folder_list (void);
+
+G_END_DECLS
+
+#endif /* EXCHANGE_MAPI_ACCOUNT_LISTENER_H */
Modified: branches/EXCHANGE_MAPI_BRANCH/plugins/exchange-mapi/exchange-mapi-account-setup.c
==============================================================================
--- branches/EXCHANGE_MAPI_BRANCH/plugins/exchange-mapi/exchange-mapi-account-setup.c (original)
+++ branches/EXCHANGE_MAPI_BRANCH/plugins/exchange-mapi/exchange-mapi-account-setup.c Thu Nov 13 08:25:59 2008
@@ -42,7 +42,7 @@
#include "mail/em-account-editor.h"
#include "mail/em-config.h"
#include "exchange-mapi-account-setup.h"
-#include "exchange-account-listener.h"
+#include "exchange-mapi-account-listener.h"
#include <addressbook/gui/widgets/eab-config.h>
#include <calendar/gui/e-cal-config.h>
#include <mapi/exchange-mapi-folder.h>
@@ -70,14 +70,7 @@
void exchange_mapi_cal_commit (EPlugin *epl, EConfigTarget *target);
-#define DEFAULT_PROF_PATH ".evolution/mapi-profiles.ldb"
-
-/* This definition should be in-sync with those in exchange-account-listener.c and camel-mapi-store.c */
-#define E_PASSWORD_COMPONENT "ExchangeMAPI"
-
-static void validate_credentials (GtkWidget *widget, EConfig *config);
-
-static ExchangeAccountListener *config_listener = NULL;
+static ExchangeMAPIAccountListener *config_listener = NULL;
static void
free_mapi_listener ( void )
@@ -88,10 +81,10 @@
int
e_plugin_lib_enable (EPluginLib *ep, int enable)
{
- g_print ("Loading Exchange MAPI Plugin \n");
+ g_debug ("Loading Exchange MAPI Plugin \n");
if (!config_listener) {
- config_listener = exchange_account_listener_new ();
+ config_listener = exchange_mapi_account_listener_new ();
g_atexit ( free_mapi_listener );
}
@@ -121,11 +114,12 @@
goto cleanup;
}
+ g_debug ("Deleting profile %s ", profile);
retval = DeleteProfile(profile);
if (retval != MAPI_E_SUCCESS) {
mapi_errstr("DeleteProfile", GetLastError());
goto cleanup;
- }
+ }
exchange_mapi_connection_close ();
result = TRUE;
@@ -145,7 +139,6 @@
gchar *profname = NULL, *profpath = NULL;
struct mapi_session *session = NULL;
-
d(g_print ("Create profile with %s %s (****) %s %s\n", username, password, domain, server));
profpath = g_build_filename (g_get_home_dir(), DEFAULT_PROF_PATH, NULL);
@@ -189,13 +182,17 @@
mapi_profile_add_string_attr(profname, "method", "0x409");
/* Login now */
- d(printf("Logging into the server \n"));
+ d(g_print("Logging into the server... "));
retval = MapiLogonProvider(&session, profname, NULL, PROVIDER_ID_NSPI);
if (retval != MAPI_E_SUCCESS) {
mapi_errstr("MapiLogonProvider", GetLastError());
+ g_debug ("Deleting profile %s ", profname);
+ retval = DeleteProfile(profname);
+ if (retval != MAPI_E_SUCCESS)
+ mapi_errstr("DeleteProfile", GetLastError());
goto cleanup;
}
- d(printf("Login succeeded: Yeh \n"));
+ d(g_print("succeeded \n"));
retval = ProcessNetworkProfile(session, username, NULL, NULL);
if (retval != MAPI_E_SUCCESS) {
@@ -214,141 +211,110 @@
exchange_mapi_connection_close ();
/* Initialize a global connection */
- //FIXME: Dont get the password from profile
if (exchange_mapi_connection_new (profname, password)) {
result = TRUE;
- exchange_account_listener_get_folder_list ();
+ exchange_mapi_account_listener_get_folder_list ();
}
cleanup:
+ if (!result)
+ MAPIUninitialize ();
+
g_free (profname);
g_free (profpath);
- return TRUE;
+ return result;
}
+
static void
validate_credentials (GtkWidget *widget, EConfig *config)
{
- EMConfigTargetAccount *target_account = (EMConfigTargetAccount *)config->target;
- const gchar *source_url = NULL;
+ EMConfigTargetAccount *target_account = (EMConfigTargetAccount *)(config->target);
CamelURL *url = NULL;
- gchar *key = NULL;
- gchar *password = NULL;
- const gchar *domain_name = NULL;
- const gchar *id_name = NULL;
- gchar *at = NULL;
- gchar *user = NULL;
- gboolean status;
-
- source_url = e_account_get_string (target_account->account, E_ACCOUNT_SOURCE_URL);
-
- url = camel_url_new(source_url, NULL);
- if (url && url->user == NULL) {
- id_name = e_account_get_string (target_account->account, E_ACCOUNT_ID_ADDRESS);
- if (id_name && *id_name) {
- at = strchr(id_name, '@');
- user = g_alloca(at-id_name+1);
- memcpy(user, id_name, at-id_name);
- user[at-id_name] = 0;
- camel_url_set_user (url, user);
- g_free (user);
- user = NULL;
- }
- }
+ gchar *key = NULL, *password = NULL;
- domain_name = camel_url_get_param (url, "domain");
-
+ url = camel_url_new (e_account_get_string (target_account->account, E_ACCOUNT_SOURCE_URL), NULL);
key = camel_url_to_string (url, CAMEL_URL_HIDE_PASSWORD | CAMEL_URL_HIDE_PARAMS);
- password = e_passwords_get_password (E_PASSWORD_COMPONENT, key);
+ password = e_passwords_get_password (EXCHANGE_MAPI_PASSWORD_COMPONENT, key);
if (!password) {
gboolean remember = FALSE;
gchar *title;
-
+
title = g_strdup_printf (_("Enter Password for %s"), url->user);
- password = e_passwords_ask_password (title, E_PASSWORD_COMPONENT, key, title,
+ password = e_passwords_ask_password (title, EXCHANGE_MAPI_PASSWORD_COMPONENT, key, title,
E_PASSWORDS_REMEMBER_FOREVER|E_PASSWORDS_SECRET,
&remember, NULL);
g_free (title);
+ }
- if (!password) {
- g_free (key);
- camel_url_free (url);
- return;
+ if (password) {
+ const gchar *domain_name = camel_url_get_param (url, "domain");
+ gboolean status = exchange_mapi_create_profile (url->user, password, domain_name, url->host);
+ if (status) {
+ /* Things are successful */
+ gchar *profname = NULL, *uri = NULL;
+
+ profname = g_strdup_printf("%s %s", url->user, domain_name);
+ camel_url_set_param(url, "profile", profname);
+ g_free (profname);
+
+ uri = camel_url_to_string(url, 0);
+ e_account_set_string(target_account->account, E_ACCOUNT_SOURCE_URL, uri);
+ g_free (uri);
+ } else {
+ e_passwords_forget_password (EXCHANGE_MAPI_PASSWORD_COMPONENT, key);
+ /* FIXME: Run an error dialog here */
}
- }
- /* Yah, we have the username, password, domain and server. Lets create everything. */
-
- status = exchange_mapi_create_profile (url->user, password, domain_name, url->host);
-
- if (status) {
- /* Things are successful.*/
- char *profname = g_strdup_printf("%s %s", url->user, domain_name);
- char *uri;
-
- camel_url_set_param(url, "profile", profname);
- uri = camel_url_to_string(url, 0);
- e_account_set_string(target_account->account, E_ACCOUNT_SOURCE_URL, uri);
-
- g_free (uri);
- g_free (profname);
- } else {
- e_passwords_forget_password (E_PASSWORD_COMPONENT, key);
}
- g_free (key);
g_free (password);
+ g_free (key);
camel_url_free (url);
}
static void
domain_entry_changed(GtkWidget *entry, EConfig *config)
{
- const char *domain = NULL;
+ EMConfigTargetAccount *target = (EMConfigTargetAccount *)(config->target);
CamelURL *url = NULL;
- char *url_string;
- EMConfigTargetAccount *target = (EMConfigTargetAccount *)config->target;
+ const char *domain = NULL;
+ char *url_string = NULL;
- url = camel_url_new(e_account_get_string(target->account, E_ACCOUNT_SOURCE_URL), NULL);
+ url = camel_url_new (e_account_get_string(target->account, E_ACCOUNT_SOURCE_URL), NULL);
+ domain = gtk_entry_get_text (GTK_ENTRY(entry));
- domain = gtk_entry_get_text((GtkEntry *)entry);
if (domain && domain[0])
- camel_url_set_param(url, "domain", domain);
+ camel_url_set_param (url, "domain", domain);
else
- camel_url_set_param(url, "domain", NULL);
+ camel_url_set_param (url, "domain", NULL);
- url_string = camel_url_to_string(url, 0);
- e_account_set_string(target->account, E_ACCOUNT_SOURCE_URL, url_string);
+ url_string = camel_url_to_string (url, 0);
+ e_account_set_string (target->account, E_ACCOUNT_SOURCE_URL, url_string);
+ g_free (url_string);
- g_free(url_string);
camel_url_free (url);
}
-
GtkWidget *
org_gnome_exchange_mapi_account_setup (EPlugin *epl, EConfigHookItemFactoryData *data)
{
EMConfigTargetAccount *target_account;
CamelURL *url;
- const char *source_url;
GtkWidget *hbox = NULL;
target_account = (EMConfigTargetAccount *)data->config->target;
- source_url = e_account_get_string(target_account->account, E_ACCOUNT_SOURCE_URL);
- url = camel_url_new(source_url, NULL);
+ url = camel_url_new(e_account_get_string(target_account->account, E_ACCOUNT_SOURCE_URL), NULL);
- if (url == NULL)
- return NULL;
+ g_return_val_if_fail (url != NULL, NULL);
if (!g_ascii_strcasecmp (url->protocol, "mapi")) {
- d(printf("%s(%d):%s:Creating Widgets for MAPI Setup \n", __FILE__, __LINE__, __PRETTY_FUNCTION__);)
GtkWidget *label;
GtkWidget *domain_name;
GtkWidget *auth_button;
- const char *domain;
- int row = ((GtkTable *)data->parent)->nrows;
+ int row = ((GtkTable *)data->parent)->nrows;
- /* Domain name & Authenticate Button*/
+ /* Domain name & Authenticate Button */
hbox = gtk_hbox_new (FALSE, 6);
label = gtk_label_new_with_mnemonic (_("_Domain name:"));
gtk_widget_show (label);
@@ -360,20 +326,13 @@
auth_button = gtk_button_new_with_mnemonic (_("_Authenticate"));
gtk_box_pack_start (GTK_BOX (hbox), auth_button, FALSE, FALSE, 0);
+ g_signal_connect(GTK_OBJECT(auth_button), "clicked", G_CALLBACK(validate_credentials), data->config);
gtk_table_attach (GTK_TABLE (data->parent), label, 0, 1, row, row+1, 0, 0, 0, 0);
gtk_widget_show_all (GTK_WIDGET (hbox));
gtk_table_attach (GTK_TABLE (data->parent), GTK_WIDGET (hbox), 1, 2, row, row+1, GTK_FILL|GTK_EXPAND, GTK_FILL, 0, 0);
-
- gtk_signal_connect(GTK_OBJECT(auth_button), "clicked", GTK_SIGNAL_FUNC(validate_credentials), data->config);
-
- domain = camel_url_get_param (url, "domain");
- if (domain)
- gtk_entry_set_text (domain_name, domain);
}
- d(printf("%s(%d):%s:Called for URL->Protocol : %s \n", __FILE__, __LINE__, __PRETTY_FUNCTION__, url->protocol);)
-
camel_url_free (url);
return GTK_WIDGET (hbox);
}
@@ -381,14 +340,12 @@
gboolean
org_gnome_exchange_mapi_check_options(EPlugin *epl, EConfigHookPageCheckData *data)
{
- EMConfigTargetAccount *target = (EMConfigTargetAccount *)data->config->target;
- int status = FALSE;
-
- if (data->pageid != NULL && g_strcasecmp (data->pageid, "10.receive") == 0) {
- CamelURL *url = NULL;
+ EMConfigTargetAccount *target = (EMConfigTargetAccount *)(data->config->target);
+ gboolean status = FALSE;
- url = camel_url_new (e_account_get_string(target->account, E_ACCOUNT_SOURCE_URL), NULL);
- if (url && url->protocol && !g_ascii_strcasecmp (url->protocol, "mapi")) {
+ if (data->pageid != NULL && g_ascii_strcasecmp (data->pageid, "10.receive") == 0) {
+ CamelURL *url = camel_url_new (e_account_get_string(target->account, E_ACCOUNT_SOURCE_URL), NULL);
+ if (url && url->protocol && g_ascii_strcasecmp (url->protocol, "mapi") == 0) {
const gchar *prof = NULL;
/* We assume that if the profile is set, then the setting is valid. */
@@ -396,15 +353,14 @@
if (prof && *prof)
status = TRUE;
- } else
- status = TRUE;
-
+ }
if (url)
camel_url_free(url);
+ }
+
+ /* FIXME: don't know why we should always return TRUE */
+ return TRUE;
- } else
- return TRUE;
-
return status;
}
@@ -469,7 +425,7 @@
gtk_tree_store_set (ts, &iter, 0, node, -1);
while (tmp) {
ExchangeMAPIFolder *folder = tmp->data;
- printf("%s\n", folder->folder_name);
+ g_print("%s\n", folder->folder_name);
add_to_store (ts, folder);
tmp = tmp->next;
}
@@ -504,7 +460,7 @@
GtkTreeStore *ts;
GtkTreeViewColumn *tvc;
const char *acc;
- GSList *folders = exchange_account_listener_peek_folder_list ();
+ GSList *folders = exchange_mapi_account_listener_peek_folder_list ();
uri_text = e_source_get_uri (source);
if (uri_text && g_ascii_strncasecmp (uri_text, "mapi", 4)) {
@@ -591,7 +547,7 @@
ESourceGroup *grp;
uri_text = e_source_get_uri (source);
- if (uri_text && g_ascii_strncasecmp (uri_text, "mapi", 4))
+ if (uri_text && g_ascii_strncasecmp (uri_text, MAPI_URI_PREFIX, MAPI_PREFIX_LENGTH))
return;
//FIXME: Offline handling
@@ -599,10 +555,10 @@
exchange_mapi_util_mapi_id_from_string (sfid, &pfid);
fid = exchange_mapi_create_folder (olFolderContacts, pfid, e_source_peek_name (source));
- printf("Created %016llX\n", fid);
+ g_print("Created %016llX\n", fid);
grp = e_source_peek_group (source);
e_source_set_property (source, "auth", "plain/password");
- e_source_set_property (source, "auth-domain", E_PASSWORD_COMPONENT);
+ e_source_set_property (source, "auth-domain", EXCHANGE_MAPI_PASSWORD_COMPONENT);
e_source_set_property(source, "user", e_source_group_get_property (grp, "user"));
e_source_set_property(source, "host", e_source_group_get_property (grp, "host"));
e_source_set_property(source, "profile", e_source_group_get_property (grp, "profile"));
@@ -627,7 +583,7 @@
ESource *source = t->source;
char *uri_text = e_source_get_uri (source);
- if (!uri_text || g_ascii_strncasecmp (uri_text, "mapi://", 7))
+ if (!uri_text || g_ascii_strncasecmp (uri_text, MAPI_URI_PREFIX, MAPI_PREFIX_LENGTH))
return FALSE;
g_free (uri_text);
@@ -651,7 +607,7 @@
uint32_t type;
char *uri_text = e_source_get_uri (source);
- if (!uri_text || g_ascii_strncasecmp (uri_text, "mapi://", 7))
+ if (!uri_text || g_ascii_strncasecmp (uri_text, MAPI_URI_PREFIX, MAPI_PREFIX_LENGTH))
return;
g_free (uri_text);
@@ -683,7 +639,7 @@
g_free (sfid);
e_source_set_property (source, "auth", "1");
- e_source_set_property (source, "auth-domain", E_PASSWORD_COMPONENT);
+ e_source_set_property (source, "auth-domain", EXCHANGE_MAPI_PASSWORD_COMPONENT);
e_source_set_property (source, "auth-type", "plain/password");
group = e_source_peek_group (source);
Modified: branches/EXCHANGE_MAPI_BRANCH/plugins/exchange-mapi/exchange-mapi-account-setup.h
==============================================================================
--- branches/EXCHANGE_MAPI_BRANCH/plugins/exchange-mapi/exchange-mapi-account-setup.h (original)
+++ branches/EXCHANGE_MAPI_BRANCH/plugins/exchange-mapi/exchange-mapi-account-setup.h Thu Nov 13 08:25:59 2008
@@ -21,6 +21,15 @@
*
*/
+
+/* This definition should be in-sync with the definition in camel-mapi-store.c */
+#define EXCHANGE_MAPI_PASSWORD_COMPONENT "ExchangeMAPI"
+
+#define DEFAULT_PROF_PATH ".evolution/mapi-profiles.ldb"
+
+#define MAPI_URI_PREFIX "mapi://"
+#define MAPI_PREFIX_LENGTH 7
+
gboolean
exchange_mapi_create_profile(const char *username, const char *password, const char *domain, const char *server);
Modified: branches/EXCHANGE_MAPI_BRANCH/plugins/exchange-mapi/org-gnome-exchange-mapi.eplug.xml
==============================================================================
--- branches/EXCHANGE_MAPI_BRANCH/plugins/exchange-mapi/org-gnome-exchange-mapi.eplug.xml (original)
+++ branches/EXCHANGE_MAPI_BRANCH/plugins/exchange-mapi/org-gnome-exchange-mapi.eplug.xml Thu Nov 13 08:25:59 2008
@@ -15,7 +15,7 @@
check="org_gnome_exchange_mapi_check_options">
<item
type="item_table"
- path="10.receive/10.config/30.mapi"
+ path="10.receive/20.config/30.mapi"
factory="org_gnome_exchange_mapi_account_setup"/>
</group>
</hook>
@@ -26,7 +26,7 @@
check="org_gnome_exchange_mapi_check_options">
<item
type="item_table"
- path="10.receive/10.config/30.mapi"
+ path="10.receive/20.config/30.mapi"
factory="org_gnome_exchange_mapi_account_setup"/>
</group>
</hook>
@@ -38,7 +38,7 @@
commit="org_gnome_exchange_mapi_commit">
<item
type="item_table"
- path="10.receive/10.config/30.mapi"
+ path="10.receive/20.config/30.mapi"
factory="org_gnome_exchange_mapi_account_setup"/>
</group>
</hook>
@@ -62,7 +62,7 @@
commit="exchange_mapi_cal_commit">
<item
type="item_table"
- path="00.general/00.source/40.pcalendar"
+ path="00.general/10.source/40.pcalendar"
factory="exchange_mapi_create"/>
</group>
</hook>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]