diff options
-rw-r--r-- | plugins/exchange-operations/ChangeLog | 10 | ||||
-rw-r--r-- | plugins/exchange-operations/exchange-account-setup.c | 15 | ||||
-rw-r--r-- | plugins/exchange-operations/exchange-config-listener.c | 34 | ||||
-rw-r--r-- | plugins/exchange-operations/exchange-config-listener.h | 3 | ||||
-rw-r--r-- | plugins/exchange-operations/exchange-operations.c | 15 |
5 files changed, 61 insertions, 16 deletions
diff --git a/plugins/exchange-operations/ChangeLog b/plugins/exchange-operations/ChangeLog index 126638570f..b43e6407e7 100644 --- a/plugins/exchange-operations/ChangeLog +++ b/plugins/exchange-operations/ChangeLog @@ -1,3 +1,13 @@ +2005-08-22 Sarfraaz Ahmed <asarfraaz@novell.com> + + * exchange-account-setup.c (btn_fsize_clicked) + (set_oof_info) : Use exchange_operations_get_exchange_account. + * exchange-config-listener.c (exchange_config_listener_authenticate) : + Fetch the password and connect. Added new + * exchange-config-listener.h : Similar. + * exchange-operations.c (exchange_operations_get_exchange_account) : + Try authenticating if account is not found. + 2005-09-12 Praveen Kumar <kpraveen@novell.com> * exchange-config-listener.c diff --git a/plugins/exchange-operations/exchange-account-setup.c b/plugins/exchange-operations/exchange-account-setup.c index 17f3ba343f..ae3f23fd16 100644 --- a/plugins/exchange-operations/exchange-account-setup.c +++ b/plugins/exchange-operations/exchange-account-setup.c @@ -157,12 +157,7 @@ btn_fsize_clicked (GtkButton *button, gpointer data) 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 *epl, EConfigHookPageCheckData *data) 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)) { diff --git a/plugins/exchange-operations/exchange-config-listener.c b/plugins/exchange-operations/exchange-config-listener.c index 13fb9a035b..c634ea25cd 100644 --- a/plugins/exchange-operations/exchange-config-listener.c +++ b/plugins/exchange-operations/exchange-config-listener.c @@ -42,6 +42,7 @@ #include <libedataserver/e-source.h> #include <libedataserver/e-source-list.h> #include <libedataserver/e-source-group.h> +#include <libedataserverui/e-passwords.h> #include <stdlib.h> #include <string.h> @@ -92,7 +93,6 @@ static gboolean exchange_camel_urls_is_equal (const gchar *url1, 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 +290,8 @@ add_account_esources (ExchangeAccount *account, 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 +304,8 @@ add_account_esources (ExchangeAccount *account, 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 +333,8 @@ add_account_esources (ExchangeAccount *account, 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 @@ -574,6 +580,30 @@ remove_account_esources (ExchangeAccount *account) 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; + gboolean remember = FALSE; + CamelURL *camel_url; + + g_return_val_if_fail (EXCHANGE_IS_CONFIG_LISTENER (ex_conf_listener), EXCHANGE_ACCOUNT_CONFIG_ERROR); + priv = ex_conf_listener->priv; + + camel_url = camel_url_new (priv->configured_uri, NULL); + key = camel_url_to_string (camel_url, 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->account_name); + password = e_passwords_ask_password (title, "Exchange", key, title, E_PASSWORDS_REMEMBER_SESSION|E_PASSWORDS_SECRET , &remember, NULL); + } + exchange_account_connect (account, password, &result); + + return result; +} + static void account_added (EAccountList *account_list, EAccount *account) { @@ -625,7 +655,7 @@ account_added (EAccountList *account_list, EAccount *account) remove_selected_non_offline_esources (exchange_account, CONF_KEY_TASKS); } - exchange_account_connect (exchange_account, NULL, &result); + result = exchange_config_listener_authenticate (config_listener, exchange_account); if (result != EXCHANGE_ACCOUNT_CONNECT_SUCCESS) exchange_operations_report_error (exchange_account, result); } diff --git a/plugins/exchange-operations/exchange-config-listener.h b/plugins/exchange-operations/exchange-config-listener.h index 7f137c946b..b44ffadf94 100644 --- a/plugins/exchange-operations/exchange-config-listener.h +++ b/plugins/exchange-operations/exchange-config-listener.h @@ -5,6 +5,7 @@ #define __EXCHANGE_CONFIG_LISTENER_H__ #include <exchange-constants.h> +#include <exchange-account.h> #include "exchange-types.h" #include "e-util/e-account-list.h" @@ -61,6 +62,8 @@ void exchange_config_listener_modify_esource_group_name (ExchangeConfigListener const char *old_name, const char *new_name); +ExchangeAccountResult exchange_config_listener_authenticate (ExchangeConfigListener *excl, + ExchangeAccount *account); #ifdef __cplusplus } diff --git a/plugins/exchange-operations/exchange-operations.c b/plugins/exchange-operations/exchange-operations.c index 23794a079b..b7b8b436e5 100644 --- a/plugins/exchange-operations/exchange-operations.c +++ b/plugins/exchange-operations/exchange-operations.c @@ -184,14 +184,25 @@ ExchangeAccount * exchange_operations_get_exchange_account (void) { ExchangeAccount *account = NULL; + ExchangeAccountResult result; GSList *acclist; 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 */ + result = exchange_config_listener_authenticate(exchange_global_config_listener, account); + if (exchange_account_get_context (account)) + return account; + } + } + + return NULL; } void |