[evolution-activesync] Migrate eplugin to 3.4.
- From: Srinivasa Ragavan <sragavan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-activesync] Migrate eplugin to 3.4.
- Date: Fri, 27 Apr 2012 07:02:51 +0000 (UTC)
commit 2f699283390df828ad3a351423ef494e4cc2c17c
Author: Srinivasa Ragavan <sragavan gnome org>
Date: Fri Apr 27 12:30:44 2012 +0530
Migrate eplugin to 3.4.
eplugin/Makefile.am | 2 +-
eplugin/activesync-account-setup.c | 285 ++++++++++++++++++++++-
eplugin/eas-account-listener.c | 1 -
eplugin/org-gnome-exchange-activesync.eplug.xml | 6 +-
4 files changed, 288 insertions(+), 6 deletions(-)
---
diff --git a/eplugin/Makefile.am b/eplugin/Makefile.am
index 19a045b..0b1192b 100644
--- a/eplugin/Makefile.am
+++ b/eplugin/Makefile.am
@@ -27,7 +27,7 @@ liborg_gnome_exchange_activesync_la_CPPFLAGS = \
$(EVOLUTION_MAIL_CFLAGS) \
$(LDAP_CFLAGS) \
$(SYNCEVOLUTION_DBUS_CFLAGS) \
- -I$(top_srcdir)/libeasaccount/src -I$(top_srcdir)/libeasclient
+ -I$(top_srcdir)/libeasaccount/src -I$(top_srcdir)/libeasclient -I$(top_srcdir)/camel
liborg_gnome_exchange_activesync_la_SOURCES = \
diff --git a/eplugin/activesync-account-setup.c b/eplugin/activesync-account-setup.c
index 8935c35..09d3f66 100644
--- a/eplugin/activesync-account-setup.c
+++ b/eplugin/activesync-account-setup.c
@@ -26,7 +26,6 @@
#include <libedataserver/e-account.h>
#include <libedataserver/eds-version.h>
-#include "e-util/e-alert-dialog.h"
#include <string.h>
#include <unistd.h>
@@ -49,14 +48,23 @@
#define MODIFIED_ACCT account
#endif
+#if EDS_CHECK_VERSION (3,3,90)
+#include "camel-eas-settings.h"
+#endif
+
static EasAccountListener *config_listener = NULL;
GtkWidget *org_gnome_exchange_server_url(EPlugin *epl, EConfigHookItemFactoryData *data);
gboolean org_gnome_exchange_check_options(EPlugin *epl, EConfigHookPageCheckData *data);
+#if EDS_CHECK_VERSION (3,3,90)
+void org_gnome_exchange_commit (EPlugin *epl, EMConfigTargetSettings *target_account);
+#else
void org_gnome_exchange_commit (EPlugin *epl, EMConfigTargetAccount *target_account);
+#endif
#define EVOLUTION_ACCOUNT_URL_FORMAT "eas://%s/;account_uid=%s;passwd_exp_warn_period=7;ad_limit=500;check_all;owa_url=%s"
+#if !EDS_CHECK_VERSION (3,3,90)
static void
update_url_account (EAccount *account, e_account_item_t item, const gchar *surl)
{
@@ -83,7 +91,40 @@ update_url_account (EAccount *account, e_account_item_t item, const gchar *surl)
}
+#endif
+
+#if EDS_CHECK_VERSION(3,3,90)
+static void
+url_entry_changed(GtkWidget *entry, EConfig *config)
+{
+ gchar *uri;
+ EMConfigTargetSettings *target = (EMConfigTargetSettings *)config->target;
+
+ uri = g_strdup (gtk_entry_get_text((GtkEntry *)entry));
+
+ g_strstrip (uri);
+
+ if (uri && uri[0]) {
+ const char *address = target->email_address;
+ GConfClient *client = gconf_client_get_default ();
+ char *key;
+
+ key = g_strdup_printf ("/apps/activesyncd/accounts/%s/serverUri", address);
+ gconf_client_set_string (client, key, uri, NULL);
+ g_free (key);
+ g_object_unref (client);
+ camel_eas_settings_set_owaurl ((CamelEasSettings *) target->storage_settings, uri);
+ camel_eas_settings_set_owaurl ((CamelEasSettings *)target->transport_settings, uri);
+
+ camel_eas_settings_set_account_uid ((CamelEasSettings *)target->storage_settings, address);
+ camel_eas_settings_set_account_uid ((CamelEasSettings *)target->transport_settings, address);
+
+ }
+
+ g_free (uri);
+}
+#else
static void
url_entry_changed(GtkWidget *entry, EConfig *config)
{
@@ -113,7 +154,34 @@ url_entry_changed(GtkWidget *entry, EConfig *config)
g_free (uri);
}
+#endif
+#if EDS_CHECK_VERSION(3,3,90)
+static void
+username_entry_changed (GtkWidget *entry, EConfig *config)
+{
+ gchar *name;
+ EMConfigTargetSettings *target = (EMConfigTargetSettings *)config->target;
+
+ name = g_strdup (gtk_entry_get_text((GtkEntry *)entry));
+
+ g_strstrip (name);
+
+ if (name && name[0]) {
+ const char *address = target->email_address;
+ GConfClient *client = gconf_client_get_default ();
+ char *key;
+
+ key = g_strdup_printf ("/apps/activesyncd/accounts/%s/username", address);
+ gconf_client_set_string (client, key, name, NULL);
+ g_free (key);
+ g_object_unref (client);
+ }
+
+ g_free (name);
+
+}
+#else
static void
username_entry_changed (GtkWidget *entry, EConfig *config)
{
@@ -139,7 +207,60 @@ username_entry_changed (GtkWidget *entry, EConfig *config)
g_free (name);
}
+#endif
+
+#if EDS_CHECK_VERSION(3,3,90)
+static void
+discover_server_url (GtkWidget *button, EConfig *config)
+{
+ EMConfigTargetSettings *target = (EMConfigTargetSettings *)config->target;
+ EasEmailHandler *handler;
+ GError *error = NULL;
+ const char *address;
+ gchar *uri = NULL;
+ char *username, *key;
+ GtkWidget *entry = (GtkWidget *) g_object_get_data ((GObject *) button, "url-entry");
+ GConfClient *client = gconf_client_get_default();
+
+ address = target->email_address;
+
+ handler = eas_mail_handler_new(address, &error);
+ if (error) {
+ g_warning ("Unable to create mailHandler. We don't support auto-discover: %s\n", error->message);
+ g_error_free (error);
+ gtk_widget_set_sensitive (button, FALSE);
+ return;
+ }
+ key = g_strdup_printf ("/apps/activesyncd/accounts/%s/username", address);
+ username = gconf_client_get_string (client, key, NULL);
+ if (!username || !*username || strcmp (username, address) == 0) {
+ g_free (username);
+ username = NULL;
+ }
+ g_object_unref (client);
+ eas_mail_handler_autodiscover(
+ handler,
+ address,
+ username,
+ &uri,
+ NULL,
+ &error);
+
+ if (!error && uri && *uri)
+ gtk_entry_set_text ((GtkEntry *) entry, uri);
+
+ camel_eas_settings_set_owaurl ((CamelEasSettings *)target->storage_settings, uri);
+ camel_eas_settings_set_owaurl ((CamelEasSettings *)target->transport_settings, uri);
+
+ camel_eas_settings_set_account_uid ((CamelEasSettings *)target->storage_settings, address);
+ camel_eas_settings_set_account_uid ((CamelEasSettings *)target->transport_settings, address);
+
+ g_free (key);
+ g_free (username);
+ g_object_unref (handler);
+}
+#else
static void
discover_server_url (GtkWidget *button, EConfig *config)
{
@@ -190,7 +311,113 @@ discover_server_url (GtkWidget *button, EConfig *config)
g_free (username);
g_object_unref (handler);
}
+#endif
+#if EDS_CHECK_VERSION(3,3,90)
+GtkWidget *
+org_gnome_exchange_server_url(EPlugin *epl, EConfigHookItemFactoryData *data)
+{
+ EMConfigTargetSettings *target_account;
+ const gchar *source_url;
+ gchar *server_url = NULL, *username, *key;
+ const char *address;
+ GtkWidget *url_entry, *username_entry;
+ gint row;
+ GtkWidget *hbox, *label, *button;
+ GConfClient *client = gconf_client_get_default();
+ EasEmailHandler* handler;
+ GError *error = NULL;
+ CamelSettings *settings;
+ CamelEasSettings *eas_settings;
+ CamelNetworkSettings *network_settings;
+
+ target_account = (EMConfigTargetSettings *)data->config->target;
+ settings = target_account->storage_settings;
+
+ if (!CAMEL_IS_EWS_SETTINGS (settings)) {
+ if (data->old
+ && (label = g_object_get_data((GObject *)data->old, "authenticate-label")))
+ gtk_widget_destroy(label);
+
+ return NULL;
+ }
+
+
+ if (data->old) {
+ return data->old;
+ }
+
+ eas_settings = CAMEL_EAS_SETTINGS (settings);
+ network_settings = CAMEL_NETWORK_SETTINGS (settings);
+
+
+ address = target_account->email_address;
+
+ key = g_strdup_printf ("/apps/activesyncd/accounts/%s/username", address);
+
+ username = gconf_client_get_string (client, key, NULL);
+
+ if (!username || !*username) {
+ gconf_client_set_string (client, key, address, NULL);
+ username = g_strdup (address);
+ }
+ g_free (key);
+
+ key = g_strdup_printf ("/apps/activesyncd/accounts/%s/serverUri", address);
+ server_url = gconf_client_get_string (client, key, NULL);
+ g_object_unref (client);
+ g_free (key);
+
+ g_object_get (data->parent, "n-rows", &row, NULL);
+
+ label = gtk_label_new_with_mnemonic (_("User_name:"));
+ gtk_widget_show (label);
+
+ username_entry = gtk_entry_new ();
+ gtk_widget_show (username_entry);
+ if (username)
+ gtk_entry_set_text (GTK_ENTRY (username_entry), username);
+
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), username_entry);
+
+ g_signal_connect (username_entry, "changed", G_CALLBACK (username_entry_changed), data->config);
+
+ gtk_table_attach (GTK_TABLE (data->parent), label, 0, 1, row, row+1, 0, 0, 0, 0);
+ gtk_table_attach (GTK_TABLE (data->parent), username_entry, 1, 2, row, row+1, GTK_FILL|GTK_EXPAND, GTK_FILL, 0, 0);
+
+ row++;
+
+ hbox = gtk_hbox_new (FALSE, 6);
+ label = gtk_label_new_with_mnemonic(_("_Server URL:"));
+ gtk_widget_show(label);
+
+ url_entry = gtk_entry_new();
+
+ gtk_label_set_mnemonic_widget((GtkLabel *)label, url_entry);
+
+ button = gtk_button_new_with_mnemonic (_("_Auto Detect"));
+
+ gtk_box_pack_start (GTK_BOX (hbox), url_entry, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
+ gtk_widget_show_all(hbox);
+
+ gtk_table_attach (GTK_TABLE (data->parent), label, 0, 1, row, row+1, 0, 0, 0, 0);
+ gtk_table_attach (GTK_TABLE (data->parent), hbox, 1, 2, row, row+1, GTK_FILL|GTK_EXPAND, GTK_FILL, 0, 0);
+
+ g_signal_connect (url_entry, "changed", G_CALLBACK(url_entry_changed), data->config);
+
+ if (server_url)
+ gtk_entry_set_text(GTK_ENTRY (url_entry), server_url);
+ g_object_set_data ((GObject *)button, "url-entry", (gpointer) url_entry);
+ g_signal_connect (button, "clicked", G_CALLBACK(discover_server_url), data->config);
+
+
+ g_free (server_url);
+ g_free (username);
+
+ return hbox;
+}
+#else
/* used by editor and assistant - same code */
GtkWidget *
org_gnome_exchange_server_url(EPlugin *epl, EConfigHookItemFactoryData *data)
@@ -311,7 +538,47 @@ org_gnome_exchange_server_url(EPlugin *epl, EConfigHookItemFactoryData *data)
return hbox;
}
+#endif
+
+#if EDS_CHECK_VERSION (3,3,90)
+gboolean
+org_gnome_exchange_check_options(EPlugin *epl, EConfigHookPageCheckData *data)
+{
+ EMConfigTargetSettings *target = (EMConfigTargetSettings *)(data->config->target);
+ CamelEasSettings *eas_settings;
+ gint status = TRUE;
+
+ if (!CAMEL_IS_EWS_SETTINGS (target->storage_settings))
+ return TRUE;
+
+ eas_settings = CAMEL_EAS_SETTINGS (target->storage_settings);
+
+ if (data->pageid == NULL ||
+ strcmp (data->pageid, "10.receive") == 0 ||
+ strcmp (data->pageid, "20.receive_options") == 0) {
+ char *url;
+ char *key;
+ const char *address = target->email_address;
+ GConfClient *client = gconf_client_get_default ();
+
+ key = g_strdup_printf ("/apps/activesyncd/accounts/%s/serverUri", address);
+ url = gconf_client_get_string (client, key, NULL);
+ g_object_unref (client);
+ g_free (key);
+
+ /* Note: we only care about exchange url's, we WILL get called on all other url's too. */
+ if ((!url|| !*url)
+ && strcmp(target->storage_protocol, "eas") == 0) {
+ status = FALSE;
+ }
+
+ g_free (url);
+ }
+
+ return status;
+}
+#else
gboolean
org_gnome_exchange_check_options(EPlugin *epl, EConfigHookPageCheckData *data)
{
@@ -350,7 +617,22 @@ org_gnome_exchange_check_options(EPlugin *epl, EConfigHookPageCheckData *data)
return status;
}
+#endif
+#if EDS_CHECK_VERSION (3,3,90)
+void
+org_gnome_exchange_commit (EPlugin *epl, EMConfigTargetSettings *target_account)
+{
+ if (!CAMEL_IS_EAS_SETTINGS (target_account->storage_settings))
+ return;
+
+ /* Verify the storage and transport settings are shared. */
+ g_warn_if_fail (
+ target_account->storage_settings ==
+ target_account->transport_settings);
+
+}
+#else
void
org_gnome_exchange_commit (EPlugin *epl, EMConfigTargetAccount *target_account)
{
@@ -377,6 +659,7 @@ org_gnome_exchange_commit (EPlugin *epl, EMConfigTargetAccount *target_account)
return;
}
+#endif
static void
free_eas_account_listener ( void )
diff --git a/eplugin/eas-account-listener.c b/eplugin/eas-account-listener.c
index 31ec3e5..c816839 100644
--- a/eplugin/eas-account-listener.c
+++ b/eplugin/eas-account-listener.c
@@ -27,7 +27,6 @@
#include <string.h>
#include <glib/gi18n.h>
#include <camel/camel.h>
-#include "e-util/e-alert-dialog.h"
#include <libedataserver/e-account.h>
#include <libecal/e-cal.h>
#include <shell/e-shell.h>
diff --git a/eplugin/org-gnome-exchange-activesync.eplug.xml b/eplugin/org-gnome-exchange-activesync.eplug.xml
index 5922e66..a046519 100644
--- a/eplugin/org-gnome-exchange-activesync.eplug.xml
+++ b/eplugin/org-gnome-exchange-activesync.eplug.xml
@@ -11,15 +11,15 @@
<_description>Exchange Activesync plugin for Evolution.</_description>
<hook class="org.gnome.evolution.mail.config:1.0">
- <group target="account" id="org.gnome.evolution.mail.config.accountEditor" check="org_gnome_exchange_check_options" commit="org_gnome_exchange_commit">
+ <group target="settings" id="org.gnome.evolution.mail.config.accountEditor" check="org_gnome_exchange_check_options" commit="org_gnome_exchange_commit">
<item type="item_table" path="10.receive/10.config/20.eas" factory="org_gnome_exchange_server_url"/>
</group>
- <group target="account" id="org.gnome.evolution.mail.config.accountAssistant" check="org_gnome_exchange_check_options">
+ <group target="settings" id="org.gnome.evolution.mail.config.accountAssistant" check="org_gnome_exchange_check_options">
<item type="item_table" path="10.receive/10.config/20.eas" factory="org_gnome_exchange_server_url"/>
</group>
- <group target="account" id="org.gnome.evolution.mail.config.accountWizard" check="org_gnome_exchange_check_options">
+ <group target="settings" id="org.gnome.evolution.mail.config.accountWizard" check="org_gnome_exchange_check_options">
<item type="item_table" path="10.receive/10.config/20.eas" factory="org_gnome_exchange_server_url"/>
</group>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]