aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/exchange-operations/exchange-account-setup.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/exchange-operations/exchange-account-setup.c')
-rw-r--r--plugins/exchange-operations/exchange-account-setup.c67
1 files changed, 64 insertions, 3 deletions
diff --git a/plugins/exchange-operations/exchange-account-setup.c b/plugins/exchange-operations/exchange-account-setup.c
index 275a214b90..5b3d0b9653 100644
--- a/plugins/exchange-operations/exchange-account-setup.c
+++ b/plugins/exchange-operations/exchange-account-setup.c
@@ -181,6 +181,7 @@ org_gnome_exchange_settings(EPlugin *epl, EConfigHookItemFactoryData *data)
const char *source_url;
char *message = NULL, *txt = NULL, *oof_message;
gboolean oof_state = FALSE;
+ gint offline_status;
GtkVBox *vbox_settings;
@@ -234,6 +235,14 @@ org_gnome_exchange_settings(EPlugin *epl, EConfigHookItemFactoryData *data)
account = exchange_operations_get_exchange_account ();
+ exchange_config_listener_get_offline_status (exchange_global_config_listener,
+ &offline_status);
+ if (offline_status == OFFLINE_MODE) {
+ e_error_run (NULL, ERROR_DOMAIN ":exchange-settings-offline", NULL);
+
+ return NULL;
+ }
+
oof_data = g_new0 (OOFData, 1);
oof_data->state = FALSE;
@@ -613,6 +622,30 @@ mailbox_editor_entry_changed (GtkWidget *entry, EConfig *config)
update_mailbox_param_in_url (target->account, E_ACCOUNT_TRANSPORT_URL, mailbox);
}
+static void
+want_mailbox_toggled (GtkWidget *toggle, EConfig *config)
+{
+ GtkWidget *entry;
+
+ g_return_if_fail (toggle != NULL);
+ g_return_if_fail (config != NULL);
+
+ entry = g_object_get_data (G_OBJECT (toggle), "mailbox-entry");
+ if (entry) {
+ gboolean is_active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (toggle));
+ EMConfigTargetAccount *target;
+ const char *mailbox;
+
+ gtk_widget_set_sensitive (entry, is_active);
+
+ target = (EMConfigTargetAccount *)config->target;
+ mailbox = gtk_entry_get_text (GTK_ENTRY (entry));
+
+ update_mailbox_param_in_url (target->account, E_ACCOUNT_SOURCE_URL, is_active ? mailbox : NULL);
+ update_mailbox_param_in_url (target->account, E_ACCOUNT_TRANSPORT_URL, is_active ? mailbox : NULL);
+ }
+}
+
static char *
construct_owa_url (CamelURL *url)
{
@@ -645,8 +678,8 @@ org_gnome_exchange_owa_url(EPlugin *epl, EConfigHookItemFactoryData *data)
{
EMConfigTargetAccount *target_account;
const char *source_url;
- char *owa_url = NULL, *mailbox_name;
- GtkWidget *owa_entry, *mailbox_entry;
+ char *owa_url = NULL, *mailbox_name, *username;
+ GtkWidget *owa_entry, *mailbox_entry, *want_mailbox_check;
CamelURL *url;
int row;
GtkWidget *hbox, *label, *button;
@@ -679,6 +712,7 @@ org_gnome_exchange_owa_url(EPlugin *epl, EConfigHookItemFactoryData *data)
owa_url = g_strdup (camel_url_get_param(url, "owa_url"));
mailbox_name = g_strdup (camel_url_get_param (url, "mailbox"));
+ username = g_strdup (url->user);
/* if the host is null, then user+other info is dropped silently, force it to be kept */
if (url->host == NULL) {
@@ -740,6 +774,19 @@ org_gnome_exchange_owa_url(EPlugin *epl, EConfigHookItemFactoryData *data)
owa_editor_entry_changed (owa_entry, data->config);
row++;
+ want_mailbox_check = gtk_check_button_new_with_mnemonic (_("S_pecify the mailbox name"));
+ gtk_widget_show (want_mailbox_check);
+ gtk_table_attach (GTK_TABLE (data->parent), want_mailbox_check, 1, 2, row, row+1, GTK_FILL, GTK_FILL, 0, 0);
+ if (!username || !*username || !mailbox_name || !*mailbox_name ||
+ g_ascii_strcasecmp (username, mailbox_name) == 0 ||
+ (strchr (username, '/') && g_ascii_strcasecmp (strchr (username, '/') + 1, mailbox_name) == 0)) {
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (want_mailbox_check), FALSE);
+ } else {
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (want_mailbox_check), TRUE);
+ }
+ g_signal_connect (want_mailbox_check, "toggled", G_CALLBACK (want_mailbox_toggled), data->config);
+
+ row++;
label = gtk_label_new_with_mnemonic (_("_Mailbox:"));
gtk_widget_show (label);
@@ -750,14 +797,18 @@ org_gnome_exchange_owa_url(EPlugin *epl, EConfigHookItemFactoryData *data)
gtk_label_set_mnemonic_widget (GTK_LABEL (label), mailbox_entry);
+ gtk_widget_set_sensitive (mailbox_entry, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (want_mailbox_check)));
+
g_signal_connect (mailbox_entry, "changed", G_CALLBACK (mailbox_editor_entry_changed), data->config);
g_object_set_data (G_OBJECT (button), "mailbox-entry", mailbox_entry);
+ g_object_set_data (G_OBJECT (want_mailbox_check), "mailbox-entry", mailbox_entry);
gtk_table_attach (GTK_TABLE (data->parent), label, 0, 1, row, row+1, 0, 0, 0, 0);
gtk_table_attach (GTK_TABLE (data->parent), mailbox_entry, 1, 2, row, row+1, GTK_FILL|GTK_EXPAND, GTK_FILL, 0, 0);
g_free (owa_url);
g_free (mailbox_name);
+ g_free (username);
return hbox;
}
@@ -815,7 +866,8 @@ destroy_oof_data (void)
{
if (oof_data->message)
g_free (oof_data->message);
- g_free (oof_data);
+ if (oof_data)
+ g_free (oof_data);
}
void
@@ -824,6 +876,7 @@ org_gnome_exchange_commit (EPlugin *epl, EConfigHookItemFactoryData *data)
EMConfigTargetAccount *target_account;
const char *source_url;
CamelURL *url;
+ gint offline_status;
target_account = (EMConfigTargetAccount *)data->config->target;
source_url = e_account_get_string (target_account->account, E_ACCOUNT_SOURCE_URL);
@@ -844,6 +897,14 @@ org_gnome_exchange_commit (EPlugin *epl, EConfigHookItemFactoryData *data)
}
camel_url_free (url);
+
+ exchange_config_listener_get_offline_status (exchange_global_config_listener,
+ &offline_status);
+
+ if (offline_status == OFFLINE_MODE) {
+ return;
+ }
+
/* Set oof data in exchange account */
set_oof_info ();
destroy_oof_data ();