aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/exchange-account-setup/ChangeLog18
-rw-r--r--plugins/exchange-account-setup/exchange-account-setup.c237
-rw-r--r--plugins/exchange-account-setup/exchange-ask-password.c137
-rw-r--r--plugins/exchange-account-setup/org-gnome-exchange-account-setup.eplug.in18
4 files changed, 281 insertions, 129 deletions
diff --git a/plugins/exchange-account-setup/ChangeLog b/plugins/exchange-account-setup/ChangeLog
index 6437f2a67d..40ae5c72ee 100644
--- a/plugins/exchange-account-setup/ChangeLog
+++ b/plugins/exchange-account-setup/ChangeLog
@@ -1,3 +1,21 @@
+2005-01-18 Sushma Rai <rsushma@novell.com>
+
+ * org-gnome-exchange-account-setup.eplug.in: Moved two account
+ editor plugins unser same hook class.
+
+ * exchange-ask-password.c: Reorganized the code.
+ Used accessor functions to read and set EAccount values.
+ Removed editor specific factory function add_owa_entry_to_editor()
+ from here.
+
+ * exchange-account-setup.c: Reorganized the code.
+ Moved add_owa_entry_to_editor() and it's sub functions into this file.
+ (org_gnome_exchange_account_setup): Reading source url and transport
+ url values stored in gconf and filling up the EAccount structure.
+ This fixes the problem of page check failure, as improper source url
+ and transport url values, as we don't read host name in the editor.
+ (org_gnome_exchange_set_url): Similar.
+
2005-01-17 Sushma Rai <rsushma@novell.com>
* Makefile.am: Linking to camel libs. Fixes plugin loading problem
diff --git a/plugins/exchange-account-setup/exchange-account-setup.c b/plugins/exchange-account-setup/exchange-account-setup.c
index f7ba1984f0..0a4f820910 100644
--- a/plugins/exchange-account-setup/exchange-account-setup.c
+++ b/plugins/exchange-account-setup/exchange-account-setup.c
@@ -24,17 +24,39 @@
* DEALINGS IN THE SOFTWARE.
*/
+#include <string.h>
#include <libgnome/gnome-i18n.h>
#include <glade/glade.h>
#include <gtk/gtk.h>
#include <gtk/gtkdialog.h>
+#include <gconf/gconf-client.h>
+#include <libedataserver/e-source.h>
#include "mail/em-account-editor.h"
#include "mail/em-config.h"
#include "e-util/e-account.h"
+#include "e-util/e-account-list.h"
int e_plugin_lib_enable (EPluginLib *ep, int enable);
+void exchange_account_setup_commit (EPlugin *epl, EConfigHookItemFactoryData *data);
GtkWidget* org_gnome_exchange_account_setup (EPlugin *epl, EConfigHookItemFactoryData *data);
+GtkWidget *org_gnome_exchange_set_url(EPlugin *epl, EConfigHookItemFactoryData *data);
+
+#if 0
+int
+e_plugin_lib_enable (EPluginLib *ep, int enable)
+{
+ if (enable) {
+ }
+ return 0;
+}
+#endif
+
+void
+exchange_account_setup_commit (EPlugin *epl, EConfigHookItemFactoryData *data)
+{
+ return;
+}
static void
oof_get()
@@ -161,14 +183,12 @@ construct_oof_editor (EConfigHookItemFactoryData *data)
editor_notebook = (GtkNotebook *) glade_xml_get_widget (parent_xml,
"account_editor_notebook");
- if (!editor_notebook) {
+ if (!editor_notebook)
return NULL;
- }
oof_page = create_page ();
- if (!oof_page) {
+ if (!oof_page)
return NULL;
- }
page_label = gtk_label_new (_("Exchange Settings"));
@@ -177,38 +197,207 @@ construct_oof_editor (EConfigHookItemFactoryData *data)
return oof_page;
}
-#if 0
-int
-e_plugin_lib_enable (EPluginLib *ep, int enable)
+GtkWidget *
+org_gnome_exchange_account_setup (EPlugin *epl, EConfigHookItemFactoryData *data)
{
- if (enable) {
+ EMConfigTargetAccount *target_account;
+ GtkWidget *oof_page = NULL;
+ const char *account_url=NULL, *source_url=NULL, *temp_url=NULL;
+ char *exchange_url = NULL;
+ GConfClient *client;
+ EAccountList *account_list;
+ const char *uid;
+ EAccount *gconf_account;
+
+ target_account = (EMConfigTargetAccount *)data->config->target;
+
+ client = gconf_client_get_default ();
+ account_list = e_account_list_new (client);
+ if (account_list) {
+ uid = g_strdup (target_account->account->uid);
+ if (uid) {
+ gconf_account = e_account_list_find (account_list,
+ E_ACCOUNT_FIND_UID,
+ uid);
+ if (gconf_account) {
+ temp_url = e_account_get_string (gconf_account,
+ E_ACCOUNT_SOURCE_URL);
+ if (temp_url)
+ e_account_set_string (
+ target_account->account,
+ E_ACCOUNT_SOURCE_URL,
+ temp_url);
+ temp_url = NULL;
+
+ temp_url = e_account_get_string (
+ gconf_account,
+ E_ACCOUNT_TRANSPORT_URL);
+ if (temp_url)
+ e_account_set_string (
+ target_account->account,
+ E_ACCOUNT_TRANSPORT_URL,
+ temp_url);
+ }
+ g_free (uid);
+ }
+ g_object_unref (account_list);
}
- return 0;
+ else {
+ /* FIXME */
+ }
+ g_object_unref (client);
+
+ source_url = e_account_get_string (target_account->account,
+ E_ACCOUNT_SOURCE_URL);
+ account_url = g_strdup (source_url);
+ exchange_url = g_strrstr (account_url, "exchange");
+ g_free (account_url);
+
+ if (exchange_url) {
+ if (data->old)
+ return data->old;
+
+ oof_page = construct_oof_editor (data);
+ }
+ return oof_page;
}
-#endif
+static void
+owa_editor_entry_changed (GtkWidget *entry, void *data)
+{
+ GtkWidget *button = data;
+ char *owa_entry_text = NULL;
+
+ /* FIXME: return owa_entry_text instead of making it global */
+ owa_entry_text = gtk_entry_get_text (GTK_ENTRY (entry));
+ if (owa_entry_text)
+ gtk_widget_set_sensitive (button, TRUE);
+}
+
+static GtkWidget *
+add_owa_entry_to_editor (GtkWidget *parent, EConfig *config,
+ EMConfigTargetAccount *target_account)
+{
+ GtkWidget *section, *owa_entry;
+ GtkWidget *hbox, *label;
+
+ section = gtk_vbox_new (FALSE, 0);
+ gtk_widget_show (section);
+ gtk_box_pack_start (GTK_BOX (parent), section, FALSE, FALSE, 0);
+
+ hbox = gtk_hbox_new (FALSE, 6);
+ gtk_widget_show(hbox);
+ gtk_box_pack_start (GTK_BOX (section), hbox, FALSE, FALSE, 0);
+ label = gtk_label_new_with_mnemonic(_("_Url:"));
+ gtk_widget_show (label);
+
+ owa_entry = gtk_entry_new ();
+ gtk_widget_show (owa_entry);
+
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), owa_entry, TRUE, TRUE, 0);
+
+ g_signal_connect (owa_entry, "changed",
+ G_CALLBACK(owa_editor_entry_changed), NULL);
+ /* FIXME - gconf handling*/
+ return section; /* FIXME: return entry */
+
+#if 0
+ GtkWidget *table;
+ GladeXML *gui;
+ GValue rows = { 0, };
+ GValue cols = { 0, };
+ gint n_rows, n_cols;
+ gui = glade_xml_new (EVOLUTION_GLADEDIR "/mail-config.glade",
+ "table4", NULL);
+ table = glade_xml_get_widget (gui, "table4");
+
+
+ g_value_init (&rows, G_TYPE_INT);
+ g_value_init (&cols, G_TYPE_INT);
+ g_object_get_property (G_OBJECT (table), "n-rows", &rows);
+ g_object_get_property (G_OBJECT (table), "n-columns", &cols);
+ n_rows = g_value_get_int (&rows);
+ n_cols = g_value_get_int (&cols);
+ printf ("NO OF COLUMES = %d ROWS = %d \n", n_cols, n_rows);
+
+ if (owa_entry_text)
+ gtk_entry_set_text (owa_entry, owa_entry_text);
+
+ gtk_table_attach (GTK_TABLE (table), label, 0, n_cols-1, n_rows, n_rows+1, GTK_FILL, GTK_FILL, 0, 0);
+ gtk_table_attach (GTK_TABLE (table), owa_entry, n_cols-1, n_cols, n_rows, n_rows+1, GTK_FILL, GTK_FILL, 0, 0);
+
+ gtk_widget_show (table);
+ return table;
+
+#endif
+ /* FIXME: Proper placing of the widget */
+}
GtkWidget *
-org_gnome_exchange_account_setup(EPlugin *epl, EConfigHookItemFactoryData *data)
+org_gnome_exchange_set_url (EPlugin *epl, EConfigHookItemFactoryData *data)
{
EMConfigTargetAccount *target_account;
- GtkWidget *oof_page;
- char *account_url = NULL, *exchange_url = NULL;
-
+ EConfig *config;
+ char *account_url=NULL, *exchange_url = NULL;
+ const char *source_url, *temp_url;
+ GtkWidget *owa_entry = NULL, *parent;
+ GConfClient *client;
+ EAccountList *account_list;
+ const char *uid;
+ EAccount *gconf_account;
+
+ config = data->config;
target_account = (EMConfigTargetAccount *)data->config->target;
- account_url = g_strdup (target_account->account->source->url);
+
+ client = gconf_client_get_default ();
+ account_list = e_account_list_new (client);
+ if (account_list) {
+ uid = g_strdup (target_account->account->uid);
+ if (uid) {
+ gconf_account = e_account_list_find (account_list,
+ E_ACCOUNT_FIND_UID,
+ uid);
+ if (gconf_account) {
+ temp_url = e_account_get_string (
+ gconf_account,
+ E_ACCOUNT_SOURCE_URL);
+ e_account_set_string (target_account->account,
+ E_ACCOUNT_SOURCE_URL,
+ temp_url);
+ temp_url = NULL;
+
+ temp_url = e_account_get_string (gconf_account,
+ E_ACCOUNT_TRANSPORT_URL);
+ e_account_set_string (target_account->account,
+ E_ACCOUNT_TRANSPORT_URL,
+ temp_url);
+ }
+ g_free (uid);
+ }
+ g_object_unref (account_list);
+ }
+ g_object_unref (client);
+
+ source_url = e_account_get_string (target_account->account, E_ACCOUNT_SOURCE_URL);
+ account_url = g_strdup (source_url);
exchange_url = g_strrstr (account_url, "exchange");
g_free (account_url);
- if (exchange_url) {
- printf ("org_gnome_exchange_account_setup\n");
- if (data->old) {
- printf ("return with old data \n");
+ if (exchange_url) {
+ if (data->old)
return data->old;
- }
- oof_page = construct_oof_editor (data);
- return oof_page;
+
+ /*
+ parent = gtk_widget_get_toplevel (GTK_WIDGET (data->parent));
+ if (!GTK_WIDGET_TOPLEVEL (parent))
+ parent = NULL;
+ */
+
+ parent = data->parent;
+ owa_entry = add_owa_entry_to_editor(parent, config, target_account);
+ gtk_box_pack_start (GTK_BOX (parent), owa_entry, FALSE, FALSE, 0);
+ gtk_widget_show (parent);
}
- else
- return NULL;
+ return owa_entry;
}
diff --git a/plugins/exchange-account-setup/exchange-ask-password.c b/plugins/exchange-account-setup/exchange-ask-password.c
index eadab0438c..5f1d6b283e 100644
--- a/plugins/exchange-account-setup/exchange-ask-password.c
+++ b/plugins/exchange-account-setup/exchange-ask-password.c
@@ -38,9 +38,8 @@
#include "e-util/e-config.h"
int e_plugin_lib_enable (EPluginLib *ep, int enable);
-
+void exchange_options_commit (EPlugin *epl, EConfigHookItemFactoryData *data);
GtkWidget *org_gnome_exchange_read_url(EPlugin *epl, EConfigHookItemFactoryData *data);
-GtkWidget *org_gnome_exchange_set_url(EPlugin *epl, EConfigHookItemFactoryData *data);
char *owa_entry_text = NULL;
@@ -50,6 +49,19 @@ typedef struct {
CamelProviderValidateUserFunc *validate_user;
}CamelProviderValidate;
+int
+e_plugin_lib_enable (EPluginLib *ep, int enable)
+{
+ if (enable) {
+ }
+ return 0;
+}
+
+void
+exchange_options_commit (EPlugin *epl, EConfigHookItemFactoryData *data)
+{
+ return;
+}
static gboolean
validate_exchange_user (void *data)
@@ -59,20 +71,24 @@ validate_exchange_user (void *data)
CamelURL *url=NULL;
CamelProvider *provider = NULL;
gboolean valid = TRUE;
- char *account_url, *url_string;
+ char *account_url, *url_string;
+ const char *source_url;
static int count = 0;
if (count)
return valid;
- account_url = g_strdup (target_account->account->source->url);
- url = camel_url_new_with_base (NULL, account_url);
+ source_url = e_account_get_string (target_account->account,
+ E_ACCOUNT_SOURCE_URL);
+ account_url = g_strdup (source_url);
provider = camel_provider_get (account_url, NULL);
- g_free (account_url);
+ g_free (account_url); account_url = NULL;
if (!provider) {
return FALSE; /* This should never happen */
}
+ url = camel_url_new_with_base (NULL, account_url);
+
validate = provider->priv;
if (validate)
validate->validate_user (url, owa_entry_text, NULL);
@@ -82,8 +98,12 @@ validate_exchange_user (void *data)
if (valid) {
count ++;
url_string = camel_url_to_string (url, 0);
- target_account->account->source->url = url_string;
+ e_account_set_string (target_account->account,
+ E_ACCOUNT_SOURCE_URL, url_string);
+ e_account_set_string (target_account->account,
+ E_ACCOUNT_TRANSPORT_URL, url_string);
}
+ camel_url_free (url);
return valid;
}
@@ -105,7 +125,9 @@ owa_entry_changed (GtkWidget *entry, void *data)
}
static GtkWidget *
-add_owa_entry (GtkWidget *parent, EConfig *config, EMConfigTargetAccount *target_account)
+add_owa_entry (GtkWidget *parent,
+ EConfig *config,
+ EMConfigTargetAccount *target_account)
{
GtkWidget *section, *owa_entry;
GtkWidget *hbox, *button, *label;
@@ -115,7 +137,7 @@ add_owa_entry (GtkWidget *parent, EConfig *config, EMConfigTargetAccount *target
gtk_box_pack_start (GTK_BOX (parent), section, FALSE, FALSE, 0);
hbox = gtk_hbox_new (FALSE, 6);
- gtk_widget_show(hbox);
+ gtk_widget_show (hbox);
gtk_box_pack_start (GTK_BOX (section), hbox, FALSE, FALSE, 0);
label = gtk_label_new_with_mnemonic(_("_Url:"));
gtk_widget_show (label);
@@ -129,109 +151,38 @@ add_owa_entry (GtkWidget *parent, EConfig *config, EMConfigTargetAccount *target
gtk_box_pack_start (GTK_BOX (hbox), owa_entry, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
- g_signal_connect (owa_entry, "changed", G_CALLBACK(owa_entry_changed), button);
- g_signal_connect (button, "clicked", G_CALLBACK(ok_button_clicked), target_account);
+ g_signal_connect (owa_entry, "changed",
+ G_CALLBACK (owa_entry_changed), button);
+ g_signal_connect (button, "clicked",
+ G_CALLBACK (ok_button_clicked), target_account);
return section; /* FIXME: return entry */
}
-static GtkWidget *
-add_owa_entry_to_editor (GtkWidget *parent, EConfig *config, EMConfigTargetAccount *target_account)
-{
- GtkWidget *section, *owa_entry;
- GtkWidget *hbox, *label;
-
- section = gtk_vbox_new (FALSE, 0);
- gtk_widget_show (section);
- gtk_box_pack_start (GTK_BOX (parent), section, FALSE, FALSE, 0);
-
- hbox = gtk_hbox_new (FALSE, 6);
- gtk_widget_show(hbox);
- gtk_box_pack_start (GTK_BOX (section), hbox, FALSE, FALSE, 0);
- label = gtk_label_new_with_mnemonic(_("_Url:"));
- gtk_widget_show (label);
- owa_entry = gtk_entry_new ();
- if (owa_entry_text)
- gtk_entry_set_text (owa_entry, owa_entry_text);
- gtk_widget_show (owa_entry);
-
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (hbox), owa_entry, TRUE, TRUE, 0);
-
- g_signal_connect (owa_entry, "changed", G_CALLBACK(owa_entry_changed), NULL); /* FIXME - gconf handling*/
- return section; /* FIXME: return entry */
- /* FIXME: Proper placing of the widget */
-}
-
-int
-e_plugin_lib_enable (EPluginLib *ep, int enable)
-{
- if (enable) {
- }
- return 0;
-}
-
GtkWidget *
org_gnome_exchange_read_url(EPlugin *epl, EConfigHookItemFactoryData *data)
{
EMConfigTargetAccount *target_account;
EConfig *config;
- char *account_url = NULL, *exchange_url = NULL, *temp_url;
- GtkWidget *owa_entry, *parent;
- CamelURL *url=NULL;
-
- target_account = (EMConfigTargetAccount *)data->config->target;
- account_url = g_strdup (target_account->account->source->url);
- exchange_url = g_strrstr (account_url, "exchange");
- config = data->config;
-
- if (exchange_url) {
- printf ("org_gnome_exchange_read_url \n");
- if (data->old) {
- return data->old;
- }
-
- /* hack for making page check work when host is not there */
- url = camel_url_new_with_base (NULL, account_url);
- if (url->host == NULL) {
- url->host = g_strdup("localhost");
- /* FIXME: extract host name from url and use it*/
- temp_url = camel_url_to_string (url, 0);
- target_account->account->source->url = g_strdup(temp_url);
- g_free (temp_url);
- }
-
- parent = data->parent;
- owa_entry = add_owa_entry(parent, config, target_account);
- g_free (account_url);
- return owa_entry;
- }
- else {
- g_free (account_url);
- return NULL;
- }
-}
-
-GtkWidget *
-org_gnome_exchange_set_url(EPlugin *epl, EConfigHookItemFactoryData *data)
-{
- EMConfigTargetAccount *target_account;
- EConfig *config;
char *account_url = NULL, *exchange_url = NULL;
+ const char *source_url;
GtkWidget *owa_entry = NULL, *parent;
+ config = data->config;
target_account = (EMConfigTargetAccount *)data->config->target;
- account_url = g_strdup (target_account->account->source->url);
+
+ source_url = e_account_get_string (target_account->account,
+ E_ACCOUNT_SOURCE_URL);
+ account_url = g_strdup (source_url);
exchange_url = g_strrstr (account_url, "exchange");
- config = data->config;
+ g_free (account_url);
if (exchange_url) {
- if (data->old)
+ if (data->old)
return data->old;
parent = data->parent;
- owa_entry = add_owa_entry_to_editor(parent, config, target_account);
+ owa_entry = add_owa_entry (parent, config, target_account);
}
- g_free (account_url);
return owa_entry;
}
diff --git a/plugins/exchange-account-setup/org-gnome-exchange-account-setup.eplug.in b/plugins/exchange-account-setup/org-gnome-exchange-account-setup.eplug.in
index 13deba4b56..d08277f65b 100644
--- a/plugins/exchange-account-setup/org-gnome-exchange-account-setup.eplug.in
+++ b/plugins/exchange-account-setup/org-gnome-exchange-account-setup.eplug.in
@@ -16,6 +16,12 @@
path="40.oof"
label="Exchange Settings"
factory="org_gnome_exchange_account_setup"/>
+ <item type="section"
+ path="10.receive/10.config"
+ label="OWA Url"/>
+ <item type="item"
+ path="10.receive/10.config/00.owa"
+ factory="org_gnome_exchange_set_url"/>
</group>
</hook>
@@ -32,17 +38,5 @@
</group>
</hook>
- <hook class="org.gnome.evolution.mail.config:1.0">
- <group
- target="account"
- id="org.gnome.evolution.mail.config.accountEditor">
- <item type="section"
- path="10.receive/10.config"
- label="OWA Url"/>
- <item type="item"
- path="10.receive/10.config/00.owa"
- factory="org_gnome_exchange_set_url"/>
- </group>
- </hook>
</e-plugin>
</e-plugin-list>