aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2001-09-29 06:38:53 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-09-29 06:38:53 +0800
commitdf8634ddc8aedeeb471e1e1a6171a8ea102db61d (patch)
tree65b1422d037c7367864ab25a3ccf281b93156e40
parent61e47e195ea3084227b2a986e055bfdb7e18444b (diff)
downloadgsoc2013-evolution-df8634ddc8aedeeb471e1e1a6171a8ea102db61d.tar
gsoc2013-evolution-df8634ddc8aedeeb471e1e1a6171a8ea102db61d.tar.gz
gsoc2013-evolution-df8634ddc8aedeeb471e1e1a6171a8ea102db61d.tar.bz2
gsoc2013-evolution-df8634ddc8aedeeb471e1e1a6171a8ea102db61d.tar.lz
gsoc2013-evolution-df8634ddc8aedeeb471e1e1a6171a8ea102db61d.tar.xz
gsoc2013-evolution-df8634ddc8aedeeb471e1e1a6171a8ea102db61d.tar.zst
gsoc2013-evolution-df8634ddc8aedeeb471e1e1a6171a8ea102db61d.zip
Setup the url_hash and url_equal functions for the local provider.
2001-09-28 Jeffrey Stedfast <fejj@ximian.com> * mail-local.c (mail_local_provider_init): Setup the url_hash and url_equal functions for the local provider. * mail-account-gui.c (mail_account_gui_save): Add code here to check to make sure that the Drafts and Sent folders are pointing to valid urls. This is kinda nasty and only really solves the case where the user changes, say, his imap server or something. Unfortunately we still have the problem where if account A's sent/drafts folders point to account B's store and the user changes the url for account B. * mail-config.c (mail_config_get_account_by_source_url): Use Camel to compare the urls rather than using e_url_equal which does all sorts of funky shit that may not work in every case. svn path=/trunk/; revision=13238
-rw-r--r--mail/ChangeLog17
-rw-r--r--mail/mail-account-gui.c85
-rw-r--r--mail/mail-config.c35
-rw-r--r--mail/mail-local.c2
4 files changed, 110 insertions, 29 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 9b0e82eac5..4d80c8986a 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,20 @@
+2001-09-28 Jeffrey Stedfast <fejj@ximian.com>
+
+ * mail-local.c (mail_local_provider_init): Setup the url_hash and
+ url_equal functions for the local provider.
+
+ * mail-account-gui.c (mail_account_gui_save): Add code here to
+ check to make sure that the Drafts and Sent folders are pointing
+ to valid urls. This is kinda nasty and only really solves the case
+ where the user changes, say, his imap server or
+ something. Unfortunately we still have the problem where if
+ account A's sent/drafts folders point to account B's store and the
+ user changes the url for account B.
+
+ * mail-config.c (mail_config_get_account_by_source_url): Use Camel
+ to compare the urls rather than using e_url_equal which does all
+ sorts of funky shit that may not work in every case.
+
2001-09-28 Dan Winship <danw@ximian.com>
* mail-mt.c (pass_got): Don't call
diff --git a/mail/mail-account-gui.c b/mail/mail-account-gui.c
index c8281be799..3b048bb86c 100644
--- a/mail/mail-account-gui.c
+++ b/mail/mail-account-gui.c
@@ -40,6 +40,8 @@
#include "mail-send-recv.h"
#include "e-msg-composer.h"
+#define d(x)
+
extern char *default_drafts_folder_uri, *default_sent_folder_uri;
static void save_service (MailAccountGuiService *gsvc, GHashTable *extra_conf, MailConfigService *service);
@@ -119,16 +121,16 @@ service_complete (MailAccountGuiService *service, GtkWidget **incomplete)
const CamelProvider *prov = service->provider;
char *text;
GtkWidget *path;
-
+
if (!prov)
return TRUE;
-
+
/* transports don't have a path */
if (service->path)
path = GTK_WIDGET (service->path);
else
path = NULL;
-
+
if (CAMEL_PROVIDER_NEEDS (prov, CAMEL_URL_PART_HOST)) {
text = gtk_entry_get_text (service->hostname);
if (!text || !*text) {
@@ -155,10 +157,10 @@ service_complete (MailAccountGuiService *service, GtkWidget **incomplete)
if (CAMEL_PROVIDER_NEEDS (prov, CAMEL_URL_PART_PATH)) {
if (!path) {
- printf ("aagh, transports aren't supposed to have paths.\n");
+ d(printf ("aagh, transports aren't supposed to have paths.\n"));
return TRUE;
}
-
+
text = gtk_entry_get_text (service->path);
if (!text || !*text) {
if (incomplete)
@@ -375,7 +377,7 @@ source_type_changed (GtkWidget *widget, gpointer user_data)
gtk_widget_hide (GTK_WIDGET (gui->source.use_ssl));
gtk_widget_show (GTK_WIDGET (gui->source.no_ssl));
#endif
-
+
/* auth */
frame = glade_xml_get_widget (gui->xml, "source_auth_frame");
if (provider && CAMEL_PROVIDER_ALLOWS (provider, CAMEL_URL_PART_AUTH)) {
@@ -454,7 +456,7 @@ transport_type_changed (GtkWidget *widget, gpointer user_data)
gtk_widget_hide (GTK_WIDGET (gui->transport.use_ssl));
gtk_widget_show (GTK_WIDGET (gui->transport.no_ssl));
#endif
-
+
/* auth */
if (CAMEL_PROVIDER_ALLOWS (provider, CAMEL_URL_PART_AUTH) &&
!CAMEL_PROVIDER_NEEDS (provider, CAMEL_URL_PART_AUTH))
@@ -917,7 +919,7 @@ struct _ESignatureEditor {
MailAccountGui *gui;
GtkWidget *win;
GtkWidget *control;
-
+
gchar *filename;
gboolean html;
gboolean has_changed;
@@ -934,9 +936,9 @@ enum { REPLY_YES = 0, REPLY_NO, REPLY_CANCEL };
static void
destroy_editor (ESignatureEditor *editor)
{
- gtk_widget_destroy (editor->win);
- g_free (editor->filename);
- g_free (editor);
+ gtk_widget_destroy (editor->win);
+ g_free (editor->filename);
+ g_free (editor);
}
static void
@@ -1212,7 +1214,7 @@ mail_account_gui_new (MailConfigAccount *account)
gtk_widget_set_sensitive (GTK_WIDGET (gui->edit_signature), FALSE);
gui->edit_html_signature = GTK_BUTTON (glade_xml_get_widget (gui->xml, "button_edit_html_signature"));
gtk_widget_set_sensitive (GTK_WIDGET (gui->edit_html_signature), FALSE);
-
+
gtk_signal_connect (GTK_OBJECT (gnome_file_entry_gtk_entry (gui->signature)), "changed", signature_changed, gui);
gtk_signal_connect (GTK_OBJECT (gnome_file_entry_gtk_entry (gui->html_signature)), "changed",
html_signature_changed, gui);
@@ -1590,6 +1592,8 @@ mail_account_gui_save (MailAccountGui *gui)
{
MailConfigAccount *account = gui->account;
const MailConfigAccount *old_account;
+ CamelProvider *provider = NULL;
+ CamelURL *source_url = NULL, *url;
gchar *new_name;
gboolean old_enabled;
@@ -1629,8 +1633,13 @@ mail_account_gui_save (MailAccountGui *gui)
service_destroy (account->source);
account->source = g_new0 (MailConfigService, 1);
save_service (&gui->source, gui->extra_config, account->source);
- if (account->source && account->source->url && old_enabled)
- account->source->enabled = TRUE;
+ if (account->source && account->source->url) {
+ provider = camel_session_get_provider (session, account->source->url, NULL);
+ source_url = provider ? camel_url_new (account->source->url, NULL) : NULL;
+
+ if (old_enabled)
+ account->source->enabled = TRUE;
+ }
account->source->auto_check = gtk_toggle_button_get_active (gui->source_auto_check);
if (account->source->auto_check)
account->source->auto_check_time = gtk_spin_button_get_value_as_int (gui->source_auto_check_min);
@@ -1639,14 +1648,46 @@ mail_account_gui_save (MailAccountGui *gui)
account->transport = g_new0 (MailConfigService, 1);
save_service (&gui->transport, NULL, account->transport);
- g_free (account->drafts_folder_name);
- account->drafts_folder_name = g_strdup (gui->drafts_folder.name);
- g_free (account->drafts_folder_uri);
- account->drafts_folder_uri = g_strdup (gui->drafts_folder.uri);
- g_free (account->sent_folder_name);
- account->sent_folder_name = g_strdup (gui->sent_folder.name);
- g_free (account->sent_folder_uri);
- account->sent_folder_uri = g_strdup (gui->sent_folder.uri);
+ /* Check to make sure that the Drafts folder uri is "valid" before assigning it */
+ url = source_url ? camel_url_new (gui->drafts_folder.uri, NULL) : NULL;
+ if (mail_config_get_account_by_source_url (gui->drafts_folder.uri) ||
+ (url && provider->url_equal (source_url, url))) {
+ g_free (account->drafts_folder_name);
+ account->drafts_folder_name = g_strdup (gui->drafts_folder.name);
+ g_free (account->drafts_folder_uri);
+ account->drafts_folder_uri = g_strdup (gui->drafts_folder.uri);
+ } else {
+ /* assign defaults - the uri is unknown to us (probably pointed to an old source url) */
+ g_free (account->drafts_folder_name);
+ account->drafts_folder_name = g_strdup (strrchr (default_drafts_folder_uri, '/') + 1);
+ g_free (account->drafts_folder_uri);
+ account->drafts_folder_uri = g_strdup (default_drafts_folder_uri);
+ }
+
+ if (url)
+ camel_url_free (url);
+
+ /* Check to make sure that the Sent folder uri is "valid" before assigning it */
+ url = camel_url_new (gui->drafts_folder.uri, NULL);
+ if (mail_config_get_account_by_source_url (gui->sent_folder.uri) ||
+ (url && provider->url_equal (source_url, url))) {
+ g_free (account->sent_folder_name);
+ account->sent_folder_name = g_strdup (gui->sent_folder.name);
+ g_free (account->sent_folder_uri);
+ account->sent_folder_uri = g_strdup (gui->sent_folder.uri);
+ } else {
+ /* assign defaults - the uri is unknown to us (probably pointed to an old source url) */
+ g_free (account->sent_folder_name);
+ account->sent_folder_name = g_strdup (strrchr (default_sent_folder_uri, '/') + 1);
+ g_free (account->sent_folder_uri);
+ account->sent_folder_uri = g_strdup (default_sent_folder_uri);
+ }
+
+ if (url)
+ camel_url_free (url);
+
+ if (source_url)
+ camel_url_free (source_url);
g_free (account->pgp_key);
account->pgp_key = e_utf8_gtk_entry_get_text (gui->pgp_key);
diff --git a/mail/mail-config.c b/mail/mail-config.c
index fbdded27c6..512a760034 100644
--- a/mail/mail-config.c
+++ b/mail/mail-config.c
@@ -1422,22 +1422,43 @@ const MailConfigAccount *
mail_config_get_account_by_source_url (const char *source_url)
{
const MailConfigAccount *account;
+ CamelProvider *provider;
+ CamelURL *source;
GSList *l;
-
+
g_return_val_if_fail (source_url != NULL, NULL);
-
+
+ provider = camel_session_get_provider (session, source_url, NULL);
+ if (!provider)
+ return NULL;
+
+ source = camel_url_new (source_url, NULL);
+ if (!source)
+ return NULL;
+
l = config->accounts;
while (l) {
account = l->data;
- if (account
- && account->source
- && account->source->url
- && e_url_equal (account->source->url, source_url))
- return account;
+
+ if (account && account->source && account->source->url) {
+ CamelURL *url;
+
+ url = camel_url_new (account->source->url, NULL);
+ if (url && provider->url_equal (url, source)) {
+ camel_url_free (url);
+ camel_url_free (source);
+ return account;
+ }
+
+ if (url)
+ camel_url_free (url);
+ }
l = l->next;
}
+ camel_url_free (source);
+
return NULL;
}
diff --git a/mail/mail-local.c b/mail/mail-local.c
index e0e2c8792c..6af58a87e2 100644
--- a/mail/mail-local.c
+++ b/mail/mail-local.c
@@ -908,6 +908,8 @@ mail_local_provider_init (void)
local_provider.object_types[CAMEL_PROVIDER_STORE] = MAIL_LOCAL_STORE_TYPE;
local_provider.service_cache = g_hash_table_new (non_hash, non_equal);
+ local_provider.url_hash = non_hash;
+ local_provider.url_equal = non_equal;
camel_session_register_provider (session, &local_provider);
}