diff options
Diffstat (limited to 'plugins/groupwise-features/proxy.c')
-rw-r--r-- | plugins/groupwise-features/proxy.c | 54 |
1 files changed, 48 insertions, 6 deletions
diff --git a/plugins/groupwise-features/proxy.c b/plugins/groupwise-features/proxy.c index db16d4f502..3828a8ab2a 100644 --- a/plugins/groupwise-features/proxy.c +++ b/plugins/groupwise-features/proxy.c @@ -54,11 +54,13 @@ #include <mail/em-config.h> #include <mail/mail-component.h> #include <mail/mail-ops.h> +#include <mail/mail-session.h> #include <e-util/e-account.h> #include <e-util/e-account-list.h> #include <e-util/e-icon-factory.h> #include <camel/camel-url.h> +#include <camel/camel-offline-store.h> #include <libedataserverui/e-passwords.h> #include <libedataserverui/e-name-selector.h> #include <proxy.h> @@ -73,6 +75,8 @@ static GObjectClass *parent_class = NULL; +static int proxy_page_changed_cb (GtkNotebook *notebook, GtkNotebookPage *page, int num, EAccount *account); + struct _proxyDialogPrivate { /* Glade XML data for the Add/Edit Proxy dialog*/ GladeXML *xml; @@ -525,12 +529,13 @@ proxy_abort (GtkWidget *button, EConfigHookItemFactoryData *data) account = target_account->account; prd = g_object_get_data ((GObject *)account, "prd"); - if (prd == NULL) + if (!prd || !prd->priv || !prd->priv->proxy_list) return; g_object_unref (prd); prd = NULL; } + void proxy_commit (GtkWidget *button, EConfigHookItemFactoryData *data) { @@ -640,9 +645,18 @@ org_gnome_proxy (EPlugin *epl, EConfigHookItemFactoryData *data) GtkButton *addProxy, *removeProxy, *editProxy; proxyDialog *prd; proxyDialogPrivate *priv; + CamelOfflineStore *store; + CamelException ex; + int pag_num; target_account = (EMConfigTargetAccount *)data->config->target; account = target_account->account; + + if (!(store = (CamelOfflineStore *) camel_session_get_service (session, e_account_get_string(account, E_ACCOUNT_SOURCE_URL), CAMEL_PROVIDER_STORE, &ex))) { + camel_exception_clear (&ex); + return NULL; + } + if (g_strrstr (e_account_get_string(account, E_ACCOUNT_SOURCE_URL), "groupwise://")) { prd = proxy_dialog_new (); @@ -650,7 +664,7 @@ org_gnome_proxy (EPlugin *epl, EConfigHookItemFactoryData *data) priv = prd->priv; priv->xml_tab = glade_xml_new (EVOLUTION_GLADEDIR "/proxy-listing.glade", "proxy_vbox", NULL); - if (account->enabled) { + if (account->enabled && (store->state == CAMEL_OFFLINE_STORE_NETWORK_AVAIL)) { priv->tab_dialog = GTK_WIDGET (glade_xml_get_widget (priv->xml_tab, "proxy_vbox")); priv->tree = GTK_TREE_VIEW (glade_xml_get_widget (priv->xml_tab, "proxy_access_list")); priv->store = gtk_tree_store_new (2, @@ -670,9 +684,11 @@ org_gnome_proxy (EPlugin *epl, EConfigHookItemFactoryData *data) prd->cnc = proxy_get_cnc(account); priv->proxy_list = NULL; - if (e_gw_connection_get_proxy_access_list(prd->cnc, &priv->proxy_list)!= E_GW_CONNECTION_STATUS_OK) - return NULL; - proxy_update_tree_view (account); + } else if (account->enabled){ + GtkWidget *label; + priv->tab_dialog = gtk_vbox_new (TRUE, 10); + label = gtk_label_new (_("The Proxy tab will be available only when the account is online.")); + gtk_box_pack_start ((GtkBox *)priv->tab_dialog, label, TRUE, TRUE, 10); } else { GtkWidget *label; priv->tab_dialog = gtk_vbox_new (TRUE, 10); @@ -681,22 +697,48 @@ org_gnome_proxy (EPlugin *epl, EConfigHookItemFactoryData *data) } gtk_notebook_append_page ((GtkNotebook *)(data->parent), (GtkWidget *)priv->tab_dialog, gtk_label_new("Proxy")); + g_signal_connect ((GtkNotebook *)(data->parent), "switch-page", G_CALLBACK (proxy_page_changed_cb), account); + pag_num = gtk_notebook_page_num ((GtkNotebook *)(data->parent), (GtkWidget *)priv->tab_dialog); + g_object_set_data ((GObject *) account, "proxy_tab_num", pag_num); gtk_widget_show_all (priv->tab_dialog); } else if (!g_strrstr (e_account_get_string(account, E_ACCOUNT_SOURCE_URL), "groupwise://")) { prd = g_object_get_data ((GObject *) account, "prd"); if (prd) { priv = prd->priv; - int pag_num; + if (priv) { pag_num = gtk_notebook_page_num ( (GtkNotebook *)(data->parent), (GtkWidget *) priv->tab_dialog); gtk_notebook_remove_page ( (GtkNotebook *)(data->parent), pag_num); } } } + + camel_object_unref (store); return NULL; } +static int +proxy_page_changed_cb (GtkNotebook *notebook, GtkNotebookPage *page, int num, EAccount *account) +{ + proxyDialog *prd; + proxyDialogPrivate *priv; + + prd = g_object_get_data ((GObject *) account, "prd"); + + if (!prd || !prd->priv) + return; + + priv = prd->priv; + + if (num == g_object_get_data ((GObject *) account, "proxy_tab_num") && account->enabled) { + if (e_gw_connection_get_proxy_access_list(prd->cnc, &priv->proxy_list)!= E_GW_CONNECTION_STATUS_OK) + return NULL; + proxy_update_tree_view (account); + } + return TRUE; +} + static void proxy_cancel(GtkWidget *button, EAccount *account) { |