Re: [evolution-patches] Exchange : Fix for 309420
- From: Sarfraaz Ahmed <asarfraaz novell com>
- To: Patches List <evolution-patches lists ximian com>
- Subject: Re: [evolution-patches] Exchange : Fix for 309420
- Date: Mon, 22 Aug 2005 17:55:10 +0530
Updated the patches with the ChangeLogs now. Please review.
-- Sarfraaz
On Sat, 2005-08-20 at 17:50 +0530, Sarfraaz Ahmed wrote:
> Hi,
>
> These 3 patches are one each for evolution/plugins, e-d-s and exchange.
> Please review.
>
> Thanks
> -- Sarfraaz
> _______________________________________________
> evolution-patches mailing list
> evolution-patches lists ximian com
> http://lists.ximian.com/mailman/listinfo/evolution-patches
Index: storage/exchange-account.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/exchange/storage/exchange-account.c,v
retrieving revision 1.12
diff -u -p -u -p -r1.12 exchange-account.c
--- storage/exchange-account.c 17 Aug 2005 11:39:40 -0000 1.12
+++ storage/exchange-account.c 22 Aug 2005 11:29:27 -0000
@@ -39,6 +39,10 @@
#include "e2k-uri.h"
#include "e2k-utils.h"
#include "exchange-hierarchy-foreign.h"
+
+/* This is an ugly hack to avoid API break */
+/* Added for get_authtype */
+#include "exchange-esource.h"
#include <libedataserverui/e-passwords.h>
#include <libgnome/gnome-util.h>
@@ -907,6 +911,7 @@ get_password (ExchangeAccount *account,
// SURF : if (exchange_component_is_interactive (global_exchange_component)) {
if (!password) {
+ /*
char *prompt;
prompt = g_strdup_printf (_("Enter password for %s"),
@@ -925,6 +930,7 @@ get_password (ExchangeAccount *account,
account->priv->account->source->save_passwd = remember;
}
g_free (prompt);
+ */
}
else if (!account->priv->account->source->save_passwd) {
/* get_password returns the password cached but user has not
@@ -1415,7 +1421,7 @@ exchange_account_connect (ExchangeAccoun
}
account->priv->connecting = TRUE;
- g_mutex_unlock (account->priv->connect_lock);
+ //g_mutex_unlock (account->priv->connect_lock);
if (account->priv->windows_domain)
user_name = g_strdup_printf ("%s\\%s", account->priv->windows_domain, account->priv->username);
@@ -1431,12 +1437,18 @@ exchange_account_connect (ExchangeAccoun
e2k_autoconfig_set_gc_server (ac, account->priv->ad_server,
account->priv->ad_limit);
+ if (!pword)
+ return NULL;
try_password_again:
if (!pword) {
+/*
if (!get_password (account, ac, *info_result)) {
account->priv->connecting = FALSE;
return NULL;
}
+*/
+ } else {
+ e2k_autoconfig_set_password (ac, g_strdup (pword));
}
try_connect_again:
@@ -1632,6 +1644,7 @@ exchange_account_connect (ExchangeAccoun
G_CALLBACK (context_redirect), account);
g_signal_emit (account, signals[CONNECTED], 0, account->priv->ctx);
+ g_mutex_unlock (account->priv->connect_lock);
return account->priv->ctx;
}
@@ -1984,6 +1997,20 @@ exchange_account_folder_size_get_model (
return exchange_folder_size_get_model (account->priv->fsize);
}
+
+char *
+exchange_account_get_authtype (ExchangeAccount *account)
+{
+ g_return_val_if_fail (EXCHANGE_IS_ACCOUNT (account), NULL);
+
+ if (account->priv->auth_pref == E2K_AUTOCONFIG_USE_BASIC)
+ return g_strdup ("Basic");
+ else if (account->priv->auth_pref == E2K_AUTOCONFIG_USE_NTLM)
+ return g_strdup ("NTLM");
+
+ return NULL;
+}
+
/**
* exchange_account_new:
Index: storage/exchange-esource.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/exchange/storage/exchange-esource.c,v
retrieving revision 1.4
diff -u -p -u -p -r1.4 exchange-esource.c
--- storage/exchange-esource.c 16 Aug 2005 12:28:39 -0000 1.4
+++ storage/exchange-esource.c 22 Aug 2005 11:29:27 -0000
@@ -45,12 +45,12 @@ add_folder_esource (ExchangeAccount *acc
GConfClient *client;
gboolean is_contacts_folder = TRUE, group_new = FALSE, source_new = FALSE;
const char *offline = NULL;
+ char *username, *authtype;
int mode;
ESourceList *source_list = NULL;
gboolean offline_flag;
client = gconf_client_get_default ();
- offline_flag = is_offline ();
if (folder_type == EXCHANGE_CONTACTS_FOLDER) {
source_list = e_source_list_new_for_gconf ( client,
@@ -74,6 +74,8 @@ add_folder_esource (ExchangeAccount *acc
}
exchange_account_is_offline_sync_set (account, &mode);
+ username = exchange_account_get_username (account);
+ authtype = exchange_account_get_authtype (account);
if ((source_group = e_source_list_peek_group_by_name (source_list,
account->account_name)) == NULL) {
@@ -98,6 +100,14 @@ add_folder_esource (ExchangeAccount *acc
*/
e_source_set_property (source, "offline_sync", "1");
}
+ e_source_set_property (source, "username", username);
+ e_source_set_property (source, "auth-domain", "Exchange");
+ if (authtype)
+ e_source_set_property (source, "auth-type", authtype);
+ if (is_contacts_folder)
+ e_source_set_property (source, "auth", "plain/password");
+ else
+ e_source_set_property (source, "auth", "1");
e_source_group_add_source (source_group, source, -1);
e_source_list_sync (source_list, NULL);
group_new = source_new = TRUE;
@@ -116,6 +126,14 @@ add_folder_esource (ExchangeAccount *acc
if (mode == OFFLINE_MODE)
e_source_set_property (source, "offline_sync", "1");
+ e_source_set_property (source, "username", username);
+ e_source_set_property (source, "auth-domain", "Exchange");
+ if (authtype)
+ e_source_set_property (source, "auth-type", authtype);
+ if (is_contacts_folder)
+ e_source_set_property (source, "auth", "plain/password");
+ else
+ e_source_set_property (source, "auth", "1");
e_source_group_add_source (source_group, source, -1);
source_new = TRUE;
e_source_list_sync (source_list, NULL);
@@ -130,6 +148,7 @@ add_folder_esource (ExchangeAccount *acc
}
}
+ offline_flag = is_offline ();
if (source && !is_contacts_folder) {
/* Select the folder created */
Index: storage/exchange-esource.h
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/exchange/storage/exchange-esource.h,v
retrieving revision 1.1
diff -u -p -u -p -r1.1 exchange-esource.h
--- storage/exchange-esource.h 21 Jul 2005 14:45:57 -0000 1.1
+++ storage/exchange-esource.h 22 Aug 2005 11:29:27 -0000
@@ -22,6 +22,9 @@ extern "C" {
void add_folder_esource (ExchangeAccount *account, FolderType folder_type, const char *folder_name, const char *physical_uri);
void remove_folder_esource (ExchangeAccount *account, FolderType folder_type, const char *physical_uri);
+/* Remove this ugly hack by moving this to exchange-account.h */
+char * exchange_account_get_authtype (ExchangeAccount *account);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
Index: exchange-account-setup.c
===================================================================
RCS file: /cvs/gnome/evolution/plugins/exchange-operations/exchange-account-setup.c,v
retrieving revision 1.16
diff -u -p -u -p -r1.16 exchange-account-setup.c
--- exchange-account-setup.c 25 Jul 2005 07:13:47 -0000 1.16
+++ exchange-account-setup.c 22 Aug 2005 10:03:00 -0000
@@ -157,12 +157,7 @@ btn_fsize_clicked (GtkButton *button, gp
GtkListStore *model;
GSList *acclist;
- acclist = exchange_config_listener_get_accounts (exchange_global_config_listener);
-
- /* FIXME: For now, we have only one account in the list.
- Find a way to handle multiple accounts.
- */
- account = acclist->data;
+ account = exchange_operations_get_exchange_account ();
model = exchange_account_folder_size_get_model (account);
if (model)
@@ -684,13 +679,9 @@ org_gnome_exchange_check_options(EPlugin
static void
set_oof_info ()
{
- GSList *accounts, *acc;
- ExchangeAccount *account = NULL;
+ ExchangeAccount *account;
- accounts = exchange_config_listener_get_accounts (exchange_global_config_listener);
- for (acc = accounts; acc; acc = acc->next) {
- account = acc->data;
- }
+ account = exchange_operations_get_exchange_account ();
if (!exchange_oof_set (account, oof_data->state, oof_data->message)) {
Index: exchange-config-listener.c
===================================================================
RCS file: /cvs/gnome/evolution/plugins/exchange-operations/exchange-config-listener.c,v
retrieving revision 1.11
diff -u -p -u -p -r1.11 exchange-config-listener.c
--- exchange-config-listener.c 16 Aug 2005 12:30:41 -0000 1.11
+++ exchange-config-listener.c 22 Aug 2005 10:03:01 -0000
@@ -92,7 +92,6 @@ static gboolean exchange_camel_urls_is_e
const gchar *url2);
static void remove_selected_non_offline_esources (ExchangeAccount *account,
const char *gconf_key);
-
static void
class_init (GObjectClass *object_class)
{
@@ -290,6 +289,8 @@ add_account_esources (ExchangeAccount *a
e_source_set_property (source, "offline_sync", "1");
if (username)
e_source_set_property (source, "username", username);
+ e_source_set_property (source, "auth", "1");
+ e_source_set_property (source, "auth-domain", "Exchange");
e_source_group_add_source (contacts_source_group,
source, -1);
g_object_unref (source);
@@ -302,6 +303,8 @@ add_account_esources (ExchangeAccount *a
e_source_set_property (source, "offline_sync", "1");
if (username)
e_source_set_property (source, "username", username);
+ e_source_set_property (source, "auth", "1");
+ e_source_set_property (source, "auth-domain", "Exchange");
e_source_group_add_source (cal_source_group,
source, -1);
#if 0
@@ -329,6 +332,8 @@ add_account_esources (ExchangeAccount *a
e_source_set_property (source, "offline_sync", "1");
if (username)
e_source_set_property (source, "username", username);
+ e_source_set_property (source, "auth", "1");
+ e_source_set_property (source, "auth-domain", "Exchange");
e_source_group_add_source (tasks_source_group,
source, -1);
#if 0
@@ -468,6 +473,58 @@ add_sources (ExchangeAccount *account)
}
static void
+migrate_account_esource (ExchangeAccount *account,
+ FolderType folder_type)
+{
+ ESourceGroup *group;
+ ESource *source = NULL;
+ GSList *groups;
+ GSList *sources;
+ gboolean found_group;
+ const char *user_name = exchange_account_get_username (account);
+ GConfClient *client;
+ ESourceList *source_list = NULL;
+
+ if (!user_name)
+ return;
+
+ client = gconf_client_get_default ();
+
+ if (folder_type == EXCHANGE_CONTACTS_FOLDER)
+ source_list = e_source_list_new_for_gconf ( client,
+ CONF_KEY_CONTACTS);
+ else if (folder_type == EXCHANGE_CALENDAR_FOLDER)
+ source_list = e_source_list_new_for_gconf ( client,
+ CONF_KEY_CAL);
+ else if (folder_type == EXCHANGE_TASKS_FOLDER)
+ source_list = e_source_list_new_for_gconf ( client,
+ CONF_KEY_TASKS);
+
+ groups = e_source_list_peek_groups (source_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_name (group), account->account_name) == 0
+ &&
+ strcmp (e_source_group_peek_base_uri (group), EXCHANGE_URI_PREFIX) == 0) {
+ 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, "username", user_name);
+ e_source_list_sync (source_list, NULL);
+ found_group = TRUE;
+ break;
+ }
+ }
+ }
+ g_object_unref (source_list);
+ g_object_unref (client);
+}
+static void
remove_account_esource (ExchangeAccount *account,
FolderType folder_type)
{
@@ -565,6 +622,14 @@ remove_account_esource (ExchangeAccount
}
static void
+migrate_account_esources (ExchangeAccount *account)
+{
+ migrate_account_esource (account, EXCHANGE_CALENDAR_FOLDER);
+ migrate_account_esource (account, EXCHANGE_TASKS_FOLDER);
+ migrate_account_esource (account, EXCHANGE_CONTACTS_FOLDER);
+}
+
+static void
remove_account_esources (ExchangeAccount *account)
{
/* Remove ESources for all the folders in all the components */
@@ -574,6 +639,27 @@ remove_account_esources (ExchangeAccount
remove_account_esource (account, EXCHANGE_CONTACTS_FOLDER);
}
+ExchangeAccountResult
+exchange_config_listener_authenticate (ExchangeConfigListener *ex_conf_listener, ExchangeAccount *account)
+{
+ ExchangeConfigListenerPrivate *priv;
+ ExchangeAccountResult result;
+ char *key, *password, *title;
+
+ g_return_val_if_fail (EXCHANGE_IS_CONFIG_LISTENER (ex_conf_listener), EXCHANGE_ACCOUNT_CONFIG_ERROR);
+ priv = ex_conf_listener->priv;
+
+ key = camel_url_to_string (priv->configured_uri, CAMEL_URL_HIDE_PASSWORD | CAMEL_URL_HIDE_PARAMS);
+ password = e_passwords_get_password ("Exchange", key);
+ if (!password) {
+ title = g_strdup_printf (_("Enter Password for %s"), account->name);
+ password = e_passwords_ask_password (title, "Exchange", key, title, E_PASSWORDS_REMEMBER_SESSION|E_PASSWORDS_SECRET , &remember, NULL);
+ }
+ exchange_account_connect (exchange_account, password, &result);
+
+ return result;
+}
+
static void
account_added (EAccountList *account_list, EAccount *account)
{
@@ -581,6 +667,7 @@ account_added (EAccountList *account_lis
ExchangeAccount *exchange_account;
ExchangeAccountResult result;
gint is_offline;
+ char *key;
if (!is_active_exchange_account (account))
return;
@@ -617,6 +704,7 @@ account_added (EAccountList *account_lis
g_signal_emit (config_listener, signals[EXCHANGE_ACCOUNT_CREATED], 0,
exchange_account);
+ migrate_account_esources (exchange_account);
/* add_sources (exchange_account); */
exchange_config_listener_get_offline_status (config_listener, &is_offline);
@@ -625,7 +713,7 @@ account_added (EAccountList *account_lis
remove_selected_non_offline_esources (exchange_account, CONF_KEY_TASKS);
}
- exchange_account_connect (exchange_account, NULL, &result);
+ result = exchange_config_listener_authenticate (exchange_account);
if (result != EXCHANGE_ACCOUNT_CONNECT_SUCCESS)
exchange_operations_report_error (exchange_account, result);
}
Index: exchange-operations.c
===================================================================
RCS file: /cvs/gnome/evolution/plugins/exchange-operations/exchange-operations.c,v
retrieving revision 1.10
diff -u -p -u -p -r1.10 exchange-operations.c
--- exchange-operations.c 8 Aug 2005 05:54:26 -0000 1.10
+++ exchange-operations.c 22 Aug 2005 10:03:01 -0000
@@ -188,10 +188,20 @@ exchange_operations_get_exchange_account
acclist = exchange_config_listener_get_accounts (exchange_global_config_listener);
/* FIXME: Need to be changed for handling multiple accounts */
- if (acclist)
+ if (acclist) {
account = acclist->data;
- return account;
+ if (exchange_account_get_context (account))
+ return account;
+ else {
+ /* Try authenticating */
+ exchange_config_listener_authenticate(exchange_global_config_listener, account)
+ if (exchange_account_get_context (account))
+ return account;
+ }
+ }
+
+ return NULL;
}
void
Index: addressbook/e-book-backend-exchange.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/addressbook/e-book-backend-exchange.c,v
retrieving revision 1.38
diff -u -p -u -p -r1.38 e-book-backend-exchange.c
--- addressbook/e-book-backend-exchange.c 19 Aug 2005 07:25:38 -0000 1.38
+++ addressbook/e-book-backend-exchange.c 22 Aug 2005 09:59:16 -0000
@@ -770,15 +770,18 @@ proppatch_categories (PropMapping *prop_
GPtrArray *prop_array = NULL;
categories_list = e_contact_get (new_contact, E_CONTACT_CATEGORY_LIST);
+
+ /* Dont sent a NULL array to the server */
+ if (!categories_list)
+ return;
+
prop_array = g_ptr_array_new ();
for (l = categories_list; l; l = g_list_next (l)) {
g_ptr_array_add (prop_array, g_strdup (l->data));
}
- if (categories_list) {
- e2k_properties_set_string_array (props, prop_mapping->prop_name, prop_array);
- }
+ e2k_properties_set_string_array (props, prop_mapping->prop_name, prop_array);
}
static void
@@ -2099,7 +2102,7 @@ e_book_backend_exchange_get_contact (EBo
static EBookBackendSyncStatus
-e_book_backend_exchange_authenticate_user (EBookBackendSync *backend,
+e_book_backend_exchange_authenticate_user (EBookBackend *backend,
EDataBook *book,
guint32 opid,
const char *user,
@@ -2108,6 +2111,8 @@ e_book_backend_exchange_authenticate_use
{
EBookBackendExchange *be = E_BOOK_BACKEND_EXCHANGE (backend);
EBookBackendExchangePrivate *bepriv = be->priv;
+ ExchangeAccountResult result;
+ ExchangeAccount *account;
d(printf("ebbe_authenticate_user(%p, %p, %s, %s, %s)\n", backend, book, user, password, auth_method));
@@ -2120,7 +2125,12 @@ e_book_backend_exchange_authenticate_use
return GNOME_Evolution_Addressbook_Success;
case GNOME_Evolution_Addressbook_MODE_REMOTE:
-
+
+ account = exchange_component_get_account_for_uri (global_exchange_component, NULL);
+ if (exchange_account_get_context (account))
+ exchange_account_connect (account, password, &result);
+ if (!bepriv->connected);
+ e_book_backend_exchange_connect (be);
if (e_book_backend_cache_is_populated (bepriv->cache)) {
if (bepriv->is_writable)
g_thread_create ((GThreadFunc) update_cache,
@@ -2130,14 +2140,35 @@ e_book_backend_exchange_authenticate_use
/* for personal books we always cache*/
g_thread_create ((GThreadFunc) build_cache, be, FALSE, NULL);
}
+ e_data_book_respond_authenticate_user (book, opid, GNOME_Evolution_Addressbook_Success);
return GNOME_Evolution_Addressbook_Success;
default:
break;
}
+ e_data_book_respond_authenticate_user (book, opid, GNOME_Evolution_Addressbook_Success);
return GNOME_Evolution_Addressbook_Success;
}
+static void
+e_book_backend_exchange_get_supported_auth_methods (EBookBackend *backend,
+ EDataBook *book,
+ guint32 opid)
+{
+ GList *auth_methods = NULL;
+ char *auth_method;
+
+ d(printf ("ebbe_get_supported_auth_methods (%p, %p)\n", backend, book));
+
+ auth_method = g_strdup_printf ("plain/password");
+ auth_methods = g_list_append (auth_methods, auth_method);
+ e_data_book_respond_get_supported_auth_methods (book, opid,
+ GNOME_Evolution_Addressbook_Success,
+ auth_methods);
+
+ g_free (auth_method);
+ g_list_free (auth_methods);
+}
static EBookBackendSyncStatus
e_book_backend_exchange_get_supported_fields (EBookBackendSync *backend,
@@ -2236,9 +2267,7 @@ e_book_backend_exchange_load_source (EBo
return GNOME_Evolution_Addressbook_Success;
}
- status = e_book_backend_exchange_connect (be);
- if (status != GNOME_Evolution_Addressbook_Success)
- return status;
+ e_book_backend_set_is_loaded (E_BOOK_BACKEND (be), TRUE);
if (e_book_backend_cache_is_populated (bepriv->cache)) {
if (bepriv->is_writable)
@@ -2250,7 +2279,7 @@ e_book_backend_exchange_load_source (EBo
g_thread_create ((GThreadFunc) build_cache, be, FALSE, NULL);
}
- return status;
+ return GNOME_Evolution_Addressbook_Success;
}
static EBookBackendSyncStatus
@@ -2311,9 +2340,10 @@ e_book_backend_exchange_set_mode (EBookB
{
EBookBackendExchange *be = E_BOOK_BACKEND_EXCHANGE (backend);
EBookBackendExchangePrivate *bepriv = be->priv;
+ ExchangeAccount *account;
bepriv->mode = mode;
- if (e_book_backend_is_loaded (backend)) {
+ /* if (e_book_backend_is_loaded (backend)) { */
if (mode == GNOME_Evolution_Addressbook_MODE_LOCAL) {
e_book_backend_set_is_writable (backend, FALSE);
e_book_backend_notify_writable (backend, FALSE);
@@ -2323,10 +2353,11 @@ e_book_backend_exchange_set_mode (EBookB
e_book_backend_set_is_writable (backend, bepriv->is_writable);
e_book_backend_notify_writable (backend, bepriv->is_writable);
e_book_backend_notify_connection_status (backend, TRUE);
- /* FIXME :
- e_book_backend_notify_auth_required (backend); */
+ account = exchange_component_get_account_for_uri (global_exchange_component, NULL);
+ if (!exchange_account_get_context (account))
+ e_book_backend_notify_auth_required (backend);
}
- }
+/* } */
}
/**
@@ -2422,6 +2453,9 @@ e_book_backend_exchange_class_init (EBoo
backend_class->stop_book_view = e_book_backend_exchange_stop_book_view;
backend_class->cancel_operation = e_book_backend_exchange_cancel_operation;
backend_class->set_mode = e_book_backend_exchange_set_mode;
+ backend_class->get_supported_auth_methods = e_book_backend_exchange_get_supported_auth_methods;
+ backend_class->authenticate_user = e_book_backend_exchange_authenticate_user;
+
sync_class->remove_sync = e_book_backend_exchange_remove;
sync_class->create_contact_sync = e_book_backend_exchange_create_contact;
sync_class->remove_contacts_sync = e_book_backend_exchange_remove_contacts;
@@ -2429,7 +2463,6 @@ e_book_backend_exchange_class_init (EBoo
sync_class->get_contact_sync = e_book_backend_exchange_get_contact;
sync_class->get_contact_list_sync = e_book_backend_exchange_get_contact_list;
sync_class->get_changes_sync = e_book_backend_exchange_get_changes;
- sync_class->authenticate_user_sync = e_book_backend_exchange_authenticate_user;
sync_class->get_supported_fields_sync = e_book_backend_exchange_get_supported_fields;
sync_class->get_required_fields_sync = e_book_backend_exchange_get_required_fields;
Index: calendar/e-cal-backend-exchange.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/calendar/e-cal-backend-exchange.c,v
retrieving revision 1.39
diff -u -p -u -p -r1.39 e-cal-backend-exchange.c
--- calendar/e-cal-backend-exchange.c 17 Aug 2005 07:17:49 -0000 1.39
+++ calendar/e-cal-backend-exchange.c 22 Aug 2005 09:59:18 -0000
@@ -57,6 +57,8 @@ struct ECalBackendExchangePrivate {
char *lastmod;
char *local_attachment_store;
guint save_timeout_id;
+ GMutex *set_lock;
+ GMutex *open_lock;
/* Timezones */
GHashTable *timezones;
@@ -67,7 +69,7 @@ struct ECalBackendExchangePrivate {
#define PARENT_TYPE E_TYPE_CAL_BACKEND_SYNC
static GObjectClass *parent_class = NULL;
-#define d(x)
+#define d(x) (x)
static ECalBackendSyncStatus
is_read_only (ECalBackendSync *backend, EDataCal *cal, gboolean *read_only)
@@ -285,6 +287,8 @@ open_calendar (ECalBackendSync *backend,
ECalBackendExchange *cbex = E_CAL_BACKEND_EXCHANGE (backend);
const char *uristr;
ExchangeHierarchy *hier;
+ ExchangeAccount *act;
+ ExchangeAccountResult acresult;
const char *prop = PR_ACCESS;
E2kHTTPStatus status;
E2kResult *results;
@@ -296,6 +300,8 @@ open_calendar (ECalBackendSync *backend,
uristr = e_cal_backend_get_uri (E_CAL_BACKEND (backend));
+ g_mutex_lock (cbex->priv->open_lock);
+
if (cbex->priv->mode == CAL_MODE_LOCAL) {
ESource *source;
const char *display_contents = NULL;
@@ -307,27 +313,40 @@ open_calendar (ECalBackendSync *backend,
display_contents = e_source_get_property (source, "offline_sync");
if (!display_contents || !g_str_equal (display_contents, "1")) {
+ g_mutex_unlock (cbex->priv->open_lock);
return GNOME_Evolution_Calendar_RepositoryOffline;
}
euri = e2k_uri_new (uristr);
load_cache (cbex, euri);
e2k_uri_free (euri);
+ g_mutex_unlock (cbex->priv->open_lock);
return GNOME_Evolution_Calendar_Success;
}
/* Make sure we have an open connection */
+ /* This steals the ExchangeAccount from ExchangeComponent */
+ act = exchange_component_get_account_for_uri (global_exchange_component, NULL);
+ if (!exchange_account_get_context (act))
+ exchange_account_connect (act, password, &acresult);
+
cbex->account = exchange_component_get_account_for_uri (global_exchange_component, uristr);
- if (!cbex->account)
+ if (!cbex->account) {
+ g_mutex_unlock (cbex->priv->open_lock);
return GNOME_Evolution_Calendar_PermissionDenied;
- if (!exchange_account_get_context (cbex->account))
+ }
+
+ if (!exchange_account_get_context (cbex->account)) {
+ g_mutex_unlock (cbex->priv->open_lock);
return GNOME_Evolution_Calendar_RepositoryOffline;
+ }
cbex->folder = exchange_account_get_folder (cbex->account, uristr);
if (!cbex->folder) {
/* FIXME: theoretically we should create it if
* only_if_exists is FALSE.
*/
+ g_mutex_unlock (cbex->priv->open_lock);
return GNOME_Evolution_Calendar_NoSuchCal;
}
g_object_ref (cbex->folder);
@@ -349,13 +368,17 @@ open_calendar (ECalBackendSync *backend,
access = atoi (prop);
}
- if (!(access & MAPI_ACCESS_READ))
+ if (!(access & MAPI_ACCESS_READ)) {
+ g_mutex_unlock (cbex->priv->open_lock);
return GNOME_Evolution_Calendar_PermissionDenied;
+ }
cbex->priv->read_only = ((access & MAPI_ACCESS_CREATE_CONTENTS) == 0);
load_cache (cbex, euri);
+ g_mutex_unlock (cbex->priv->open_lock);
+
return GNOME_Evolution_Calendar_Success;
}
@@ -1056,24 +1079,32 @@ set_mode (ECalBackend *backend, CalMode
cal_mode_to_corba (mode));
}
+ g_mutex_lock (priv->set_lock);
+
switch (mode) {
case CAL_MODE_REMOTE:
/* Change status to be online now */
/* Should we check for access rights before setting this ? */
d(printf ("set mode to online\n"));
+ account = exchange_component_get_account_for_uri (global_exchange_component, NULL);
+ if (!exchange_account_get_context (account))
+ e_cal_backend_notify_auth_required(backend);
+ e_cal_backend_notify_mode (backend,
+ GNOME_Evolution_Calendar_CalListener_MODE_SET,
+ GNOME_Evolution_Calendar_MODE_REMOTE);
+
uristr = e_cal_backend_get_uri (E_CAL_BACKEND (backend));
account = exchange_component_get_account_for_uri (global_exchange_component, uristr);
- if (!account)
+ if (!account) {
+ g_mutex_unlock (priv->set_lock);
return;
+ }
cbex->folder = exchange_account_get_folder (account, uristr);
/* FIXME : Test if available for read already */
priv->read_only = FALSE;
exchange_account_set_online (account);
priv->mode = CAL_MODE_REMOTE;
- e_cal_backend_notify_mode (backend,
- GNOME_Evolution_Calendar_CalListener_MODE_SET,
- GNOME_Evolution_Calendar_MODE_REMOTE);
/* FIXME : Check if online and check if authentication
is needed */
break;
@@ -1082,8 +1113,10 @@ set_mode (ECalBackend *backend, CalMode
d(printf ("set mode to offline\n"));
uristr = e_cal_backend_get_uri (E_CAL_BACKEND (backend));
account = exchange_component_get_account_for_uri (global_exchange_component, uristr);
- if (!account)
+ if (!account) {
+ g_mutex_unlock (priv->set_lock);
return;
+ }
cbex->folder = exchange_account_get_folder (account, uristr);
priv->mode = CAL_MODE_LOCAL;
priv->read_only = TRUE;
@@ -1098,6 +1131,7 @@ set_mode (ECalBackend *backend, CalMode
backend, GNOME_Evolution_Calendar_CalListener_MODE_NOT_SUPPORTED,
cal_mode_to_corba (mode));
}
+ g_mutex_unlock (priv->set_lock);
}
static ECalBackendSyncStatus
@@ -1624,6 +1658,11 @@ init (ECalBackendExchange *cbex)
cbex->priv->timezones = g_hash_table_new_full (
g_str_hash, g_str_equal,
g_free, (GDestroyNotify)icaltimezone_free);
+
+ cbex->priv->set_lock = g_mutex_new ();
+ cbex->priv->open_lock = g_mutex_new ();
+
+ e_cal_backend_sync_set_lock (E_CAL_BACKEND_SYNC (cbex), TRUE);
}
static void
@@ -1649,6 +1688,16 @@ finalize (GObject *object)
g_free (cbex->priv->lastmod);
g_hash_table_destroy (cbex->priv->timezones);
+
+ if (cbex->priv->set_lock) {
+ g_mutex_free (cbex->priv->set_lock);
+ cbex->priv->set_lock = NULL;
+ }
+
+ if (cbex->priv->open_lock) {
+ g_mutex_free (cbex->priv->open_lock);
+ cbex->priv->open_lock = NULL;
+ }
g_free (cbex->priv);
Index: camel/camel-exchange-provider.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/camel/camel-exchange-provider.c,v
retrieving revision 1.25
diff -u -p -u -p -r1.25 camel-exchange-provider.c
--- camel/camel-exchange-provider.c 17 Aug 2005 10:15:55 -0000 1.25
+++ camel/camel-exchange-provider.c 22 Aug 2005 09:59:18 -0000
@@ -67,6 +67,9 @@ CamelProviderConfEntry exchange_conf_ent
N_("Check new messages for Junk contents"), "0" },
{ CAMEL_PROVIDER_CONF_CHECKBOX, "filter_junk_inbox", "filter_junk",
N_("Only check for Junk messages in the Inbox folder"), "0" },
+ { CAMEL_PROVIDER_CONF_HIDDEN, "auth-domain", NULL,
+ NULL, "Exchange" },
+
{ CAMEL_PROVIDER_CONF_SECTION_END },
{ CAMEL_PROVIDER_CONF_END }
};
@@ -82,7 +85,7 @@ static CamelProvider exchange_provider =
CAMEL_PROVIDER_IS_REMOTE | CAMEL_PROVIDER_IS_SOURCE |
CAMEL_PROVIDER_IS_STORAGE | CAMEL_PROVIDER_IS_EXTERNAL,
- CAMEL_URL_NEED_USER | CAMEL_URL_HIDDEN_AUTH,
+ CAMEL_URL_NEED_USER | CAMEL_URL_HIDDEN_AUTH,
exchange_conf_entries
Index: camel/camel-exchange-store.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/camel/camel-exchange-store.c,v
retrieving revision 1.22
diff -u -p -u -p -r1.22 camel-exchange-store.c
--- camel/camel-exchange-store.c 19 Aug 2005 15:36:28 -0000 1.22
+++ camel/camel-exchange-store.c 22 Aug 2005 09:59:18 -0000
@@ -334,11 +334,28 @@ e_filename_make_safe (gchar *string)
}
}
+static void
+camel_exchange_get_password (CamelService *service, CamelException *ex)
+{
+ CamelSession *session = camel_service_get_session (service);
+ char *prompt;
+
+ if (!service->url->passwd) {
+ prompt = g_strdup_printf ("Enter password for %s %s", service->url->user, service->url->host);
+
+ service->url->passwd = camel_session_get_password (session,
+ service, "Exchange", prompt, "password", CAMEL_SESSION_PASSWORD_SECRET, ex);
+ g_free (prompt);
+ }
+}
+
static gboolean
exchange_connect (CamelService *service, CamelException *ex)
{
CamelExchangeStore *exch = CAMEL_EXCHANGE_STORE (service);
char *real_user, *socket_path;
+ const char *camel_pass;
+ guint32 connect_status;
if (exch->stub)
return TRUE;
@@ -358,9 +375,12 @@ exchange_connect (CamelService *service,
if (!exch->stub)
return FALSE;
+ camel_exchange_get_password (service, ex);
/* Initialize the stub connection */
if (!camel_stub_send (exch->stub, NULL, CAMEL_STUB_CMD_CONNECT,
+ CAMEL_STUB_ARG_STRING, g_strdup (service->url->passwd),
CAMEL_STUB_ARG_RETURN,
+ CAMEL_STUB_ARG_UINT32, &connect_status,
CAMEL_STUB_ARG_END)) {
/* The user cancelled the connection attempt. */
camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL,
Index: mail/mail-stub-exchange.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/mail/mail-stub-exchange.c,v
retrieving revision 1.26
diff -u -p -u -p -r1.26 mail-stub-exchange.c
--- mail/mail-stub-exchange.c 19 Aug 2005 16:32:19 -0000 1.26
+++ mail/mail-stub-exchange.c 22 Aug 2005 09:59:20 -0000
@@ -48,6 +48,7 @@
#define PARENT_TYPE MAIL_TYPE_STUB
static MailStubClass *parent_class = NULL;
+/* FIXME : Have this as part of the appropriate class in 2.5 */
static gulong offline_listener_handler_id;
typedef struct {
@@ -88,7 +89,7 @@ typedef struct {
static void dispose (GObject *);
-static void stub_connect (MailStub *stub);
+static void stub_connect (MailStub *stub, char *pwd);
static void get_folder (MailStub *stub, const char *name, gboolean create,
GPtrArray *uids, GByteArray *flags);
static void get_trash_name (MailStub *stub);
@@ -213,6 +214,7 @@ static void
dispose (GObject *object)
{
MailStubExchange *mse = MAIL_STUB_EXCHANGE (object);
+ ExchangeOfflineListener *ex_offline_listener = NULL;
if (mse->folders_by_name) {
g_hash_table_destroy (mse->folders_by_name);
@@ -2758,8 +2760,45 @@ is_subscribed_folder (MailStub *stub, co
}
static void
-stub_connect (MailStub *stub)
+stub_connect (MailStub *stub, char *pwd)
{
+ MailStubExchange *mse = MAIL_STUB_EXCHANGE (stub);
+ ExchangeAccount *account;
+ ExchangeAccountResult result;
+ E2kContext *ctx;
+ guint32 retval = 0; /* 0 is a failure case */
+ const char *uri;
+ int mode;
+ struct connect_data *cd;
+
+ account = mse->account;
+ ctx = exchange_account_get_context (account);
+ if (!ctx) {
+ ctx = exchange_account_connect (account, pwd, &result);
+ }
+
+ if (ctx)
+ retval = 1;
+ else
+ goto end;
+
+ exchange_component_is_offline (global_exchange_component, &mode);
+
+ if (mode == ONLINE_MODE) {
+ mse->ctx = ctx;
+ g_object_ref (mse->ctx);
+
+ mse->mail_submission_uri = exchange_account_get_standard_uri (account, "sendmsg");
+ uri = exchange_account_get_standard_uri (account, "inbox");
+ mse->inbox = exchange_account_get_folder (account, uri);
+ uri = exchange_account_get_standard_uri (account, "deleteditems");
+ mse->deleted_items = exchange_account_get_folder (account, uri);
+ }
+end:
+ mail_stub_return_data (stub, CAMEL_STUB_RETVAL_RESPONSE,
+ CAMEL_STUB_ARG_UINT32, retval,
+ CAMEL_STUB_ARG_END);
+
mail_stub_return_ok (stub);
}
@@ -2828,6 +2867,7 @@ mail_stub_exchange_new (ExchangeAccount
const char *uri;
int mode;
+ printf ("mail_stub created\n");
stub = g_object_new (MAIL_TYPE_STUB_EXCHANGE, NULL);
g_object_ref (stub);
mail_stub_construct (stub, cmd_fd, status_fd);
@@ -2835,6 +2875,7 @@ mail_stub_exchange_new (ExchangeAccount
mse = (MailStubExchange *)stub;
mse->account = account;
+/*
if (mode == ONLINE_MODE) {
mse->ctx = exchange_account_get_context (account);
g_object_ref (mse->ctx);
@@ -2845,11 +2886,11 @@ mail_stub_exchange_new (ExchangeAccount
uri = exchange_account_get_standard_uri (account, "deleteditems");
mse->deleted_items = exchange_account_get_folder (account, uri);
}
+*/
offline_listener_handler_id = g_signal_connect (G_OBJECT (global_exchange_component),
"linestatus-changed",
G_CALLBACK (linestatus_listener), mse);
-
return stub;
}
Index: mail/mail-stub-listener.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/mail/mail-stub-listener.c,v
retrieving revision 1.3
diff -u -p -u -p -r1.3 mail-stub-listener.c
--- mail/mail-stub-listener.c 14 Jun 2005 13:12:43 -0000 1.3
+++ mail/mail-stub-listener.c 22 Aug 2005 09:59:20 -0000
@@ -100,6 +100,7 @@ new_connection (GIOChannel *source, GIOC
return TRUE;
}
+ printf ("mail got a new connection from camel\n");
g_signal_emit (listener, signals[NEW_CONNECTION], 0,
listener->cmd_fd, fd);
listener->cmd_fd = -1;
Index: mail/mail-stub.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/mail/mail-stub.c,v
retrieving revision 1.9
diff -u -p -u -p -r1.9 mail-stub.c
--- mail/mail-stub.c 25 Jul 2005 11:03:17 -0000 1.9
+++ mail/mail-stub.c 22 Aug 2005 09:59:20 -0000
@@ -94,9 +94,15 @@ connection_handler (GIOChannel *source,
switch (command) {
case CAMEL_STUB_CMD_CONNECT:
{
+ char *pwd
d(printf("CONNECT\n"));
g_object_ref (stub);
- MS_CLASS (stub)->connect (stub);
+ if (!mail_stub_read_args (stub,
+ CAMEL_STUB_ARG_STRING, &pwd,
+ CAMEL_STUB_ARG_END))
+ goto comm_fail;
+ MS_CLASS (stub)->connect (stub, pwd);
+ g_free (pwd);
break;
}
Index: mail/mail-stub.h
===================================================================
RCS file: /cvs/gnome/evolution-exchange/mail/mail-stub.h,v
retrieving revision 1.4
diff -u -p -u -p -r1.4 mail-stub.h
--- mail/mail-stub.h 28 Jun 2005 09:20:46 -0000 1.4
+++ mail/mail-stub.h 22 Aug 2005 09:59:21 -0000
@@ -34,7 +34,7 @@ struct _MailStubClass {
GObjectClass parent_class;
/* methods */
- void (*connect) (MailStub *);
+ void (*connect) (MailStub *, char *pwd);
void (*get_folder) (MailStub *, const char *name,
gboolean create, GPtrArray *uids,
GByteArray *flags);
Index: storage/exchange-component.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/storage/exchange-component.c,v
retrieving revision 1.16
diff -u -p -u -p -r1.16 exchange-component.c
--- storage/exchange-component.c 19 Aug 2005 16:32:20 -0000 1.16
+++ storage/exchange-component.c 22 Aug 2005 09:59:21 -0000
@@ -41,13 +41,17 @@
#include "exchange-migrate.h"
-#define d(x)
+#define d(x) (x)
#define PARENT_TYPE bonobo_object_get_type ()
static BonoboObjectClass *parent_class = NULL;
static gboolean idle_do_interactive (gpointer user_data);
static void exchange_component_update_accounts (ExchangeComponent *component,
gboolean status);
+static void ex_migrate_esources (const CORBA_short major,
+ const CORBA_short minor,
+ const CORBA_short revision,
+ ExchangeAccount *account);
static guint linestatus_signal_id;
@@ -172,6 +176,8 @@ impl_upgradeFromVersion (PortableServer_
exchange_migrate(major, minor, revision,
base_directory, account->account_filename);
+
+ ex_migrate_esources (major, minor, revision, account);
}
}
@@ -275,6 +281,19 @@ impl_setLineStatus (PortableServer_Serva
}
static void
+ex_migrate_esources (const CORBA_short major,
+ const CORBA_short minor,
+ const CORBA_short revision,
+ ExchangeAccount *account)
+{
+
+ if ((major == 1) || ((major == 2) && (minor <= 3)))
+ {
+ migrate_esources (account);
+ }
+}
+
+static void
exchange_component_update_accounts (ExchangeComponent *component,
gboolean status)
{
@@ -308,12 +327,15 @@ new_connection (MailStubListener *listen
goto end;
}
+ mse = mail_stub_exchange_new (account, cmd_fd, status_fd);
+/*
if (exchange_account_connect (account, NULL, &result))
mse = mail_stub_exchange_new (account, cmd_fd, status_fd);
else {
close (cmd_fd);
close (status_fd);
}
+*/
end:
g_object_unref (account);
}
Index: storage/exchange-config-listener.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/storage/exchange-config-listener.c,v
retrieving revision 1.28
diff -u -p -u -p -r1.28 exchange-config-listener.c
--- storage/exchange-config-listener.c 16 Aug 2005 12:34:04 -0000 1.28
+++ storage/exchange-config-listener.c 22 Aug 2005 09:59:21 -0000
@@ -338,6 +338,82 @@ remove_account_esources (ExchangeAccount
remove_account_esource (account, EXCHANGE_CONTACTS_FOLDER);
}
+static void
+migrate_account_esource (EAccount *account,
+ FolderType folder_type)
+{
+ ESourceGroup *group;
+ ESource *source = NULL;
+ GSList *groups;
+ GSList *sources;
+ gboolean found_group;
+ const char *user_name, *authtype;
+ GConfClient *client;
+ ESourceList *source_list = NULL;
+ E2kUri *e2kuri;
+
+ e2kuri = e2k_uri_new (account->source->url);
+ if (!e2kuri)
+ return;
+ user_name = e2kuri->user;
+ authtype = e2kuri->authmech;
+
+ if (!user_name)
+ return;
+ printf ("authtype = %s\n", authtype);
+ printf ("migrating esources\n");
+ client = gconf_client_get_default ();
+
+ if (folder_type == EXCHANGE_CONTACTS_FOLDER)
+ source_list = e_source_list_new_for_gconf ( client,
+ CONF_KEY_CONTACTS);
+ else if (folder_type == EXCHANGE_CALENDAR_FOLDER)
+ source_list = e_source_list_new_for_gconf ( client,
+ CONF_KEY_CAL);
+ else if (folder_type == EXCHANGE_TASKS_FOLDER)
+ source_list = e_source_list_new_for_gconf ( client,
+ CONF_KEY_TASKS);
+
+ groups = e_source_list_peek_groups (source_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_name (group), account->name) == 0
+ &&
+ strcmp (e_source_group_peek_base_uri (group), EXCHANGE_URI_PREFIX) == 0) {
+ sources = e_source_group_peek_sources (group);
+
+ found_group = TRUE;
+ for( ; sources != NULL; sources = g_slist_next (sources)) {
+ source = E_SOURCE (sources->data);
+
+ e_source_set_property (source, "username", user_name);
+ e_source_set_property (source, "auth-domain", "Exchange");
+ if (authtype)
+ e_source_set_property (source, "auth-type", authtype);
+ if (folder_type == EXCHANGE_CONTACTS_FOLDER)
+ e_source_set_property (source, "auth", "plain/password");
+ else
+ e_source_set_property (source, "auth", "1");
+ e_source_list_sync (source_list, NULL);
+ printf ("migrated the esources for %s\n", e_source_get_uri (source));
+ }
+ }
+ }
+ g_object_unref (source_list);
+ g_object_unref (client);
+}
+
+void
+migrate_esources (EAccount *account)
+{
+ migrate_account_esource (account, EXCHANGE_CALENDAR_FOLDER);
+ migrate_account_esource (account, EXCHANGE_TASKS_FOLDER);
+ migrate_account_esource (account, EXCHANGE_CONTACTS_FOLDER);
+}
+
static void
account_added (EAccountList *account_list, EAccount *account)
{
@@ -373,7 +449,9 @@ account_added (EAccountList *account_lis
g_signal_emit (config_listener, signals[EXCHANGE_ACCOUNT_CREATED], 0,
exchange_account);
- exchange_account_connect (exchange_account, NULL, &result);
+ migrate_esources (account);
+ printf ("configred uri : %s\n", account->source->url);
+ /* exchange_account_connect (exchange_account, NULL, &result); */
}
struct account_update_data {
Index: storage/exchange-config-listener.h
===================================================================
RCS file: /cvs/gnome/evolution-exchange/storage/exchange-config-listener.h,v
retrieving revision 1.7
diff -u -p -u -p -r1.7 exchange-config-listener.h
--- storage/exchange-config-listener.h 10 Jun 2005 11:35:34 -0000 1.7
+++ storage/exchange-config-listener.h 22 Aug 2005 09:59:21 -0000
@@ -57,7 +57,7 @@ GSList *exchange_config_
void add_folder_esource (ExchangeAccount *account, FolderType folder_type, const char *folder_name, const char *physical_uri);
void remove_folder_esource (ExchangeAccount *account, FolderType folder_type, const char *physical_uri);
-
+void migrate_esources (EAccount *account);
#ifdef __cplusplus
}
#endif /* __cplusplus */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]