aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-config.c
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@helixcode.com>2001-01-09 11:31:31 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-01-09 11:31:31 +0800
commita2d998fe1391733fa472f2c142891d31fd81f958 (patch)
treec554cd3852b61c3166b749097c0be976974526d8 /mail/mail-config.c
parent20b3bc147ce1de0fe2708236c7915df96d275634 (diff)
downloadgsoc2013-evolution-a2d998fe1391733fa472f2c142891d31fd81f958.tar
gsoc2013-evolution-a2d998fe1391733fa472f2c142891d31fd81f958.tar.gz
gsoc2013-evolution-a2d998fe1391733fa472f2c142891d31fd81f958.tar.bz2
gsoc2013-evolution-a2d998fe1391733fa472f2c142891d31fd81f958.tar.lz
gsoc2013-evolution-a2d998fe1391733fa472f2c142891d31fd81f958.tar.xz
gsoc2013-evolution-a2d998fe1391733fa472f2c142891d31fd81f958.tar.zst
gsoc2013-evolution-a2d998fe1391733fa472f2c142891d31fd81f958.zip
Brand spankin' new config druid, editor, and manager.
2001-01-08 Jeffrey Stedfast <fejj@helixcode.com> * Makefile.am: * component-factory.c: * folder-browser-factory.c: * folder-browser.c: * mail-accounts.[c,h]: * mail-account-editor.[c,h]: * mail-callbacks.c: * mail-config.[c,h]: * mail-config-druid.[c,h]: * mail-config-druid.glade: * mail-display.c: * mail-format.c: * mail-tools.c: Brand spankin' new config druid, editor, and manager. svn path=/trunk/; revision=7313
Diffstat (limited to 'mail/mail-config.c')
-rw-r--r--mail/mail-config.c589
1 files changed, 358 insertions, 231 deletions
diff --git a/mail/mail-config.c b/mail/mail-config.c
index a9dfe99928..f67d2c7578 100644
--- a/mail/mail-config.c
+++ b/mail/mail-config.c
@@ -1,28 +1,23 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* mail-config.c: Mail configuration dialogs/wizard. */
-
-/*
- * Authors:
- * Dan Winship <danw@helixcode.com>
- * Jeffrey Stedfast <fejj@helixcode.com>
- * JP Rosevear <jpr@helixcode.com>
+/*
+ * Authors: Jeffrey Stedfast <fejj@helixcode.com>
+ *
+ * Copyright 2001 Helix Code, Inc. (www.helixcode.com)
*
- * Copyright 2000 Helix Code, Inc. (http://www.helixcode.com)
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA
*/
#include <config.h>
@@ -37,20 +32,18 @@
#include "e-util/e-html-utils.h"
#include "mail.h"
#include "mail-config.h"
+#include "mail-ops.h"
-typedef struct
-{
+typedef struct {
gboolean configured;
- GSList *ids;
- GSList *sources;
- GSList *news;
- MailConfigService *transport;
-
gboolean thread_list;
gboolean view_source;
gint paned_size;
gboolean send_html;
gint seen_timeout;
+
+ GSList *accounts;
+ GSList *news;
} MailConfig;
static const char GCONFPATH[] = "/apps/Evolution/Mail";
@@ -59,21 +52,22 @@ static MailConfig *config = NULL;
/* Prototypes */
static void config_read (void);
-/* Identity struct */
+/* Identity */
MailConfigIdentity *
-identity_copy (MailConfigIdentity *id)
+identity_copy (const MailConfigIdentity *id)
{
- MailConfigIdentity *newid;
+ MailConfigIdentity *new;
- g_return_val_if_fail (id, NULL);
+ g_return_val_if_fail (id != NULL, NULL);
- newid = g_new0 (MailConfigIdentity, 1);
- newid->name = g_strdup (id->name);
- newid->address = g_strdup (id->address);
- newid->org = g_strdup (id->org);
- newid->sig = g_strdup (id->sig);
+ new = g_new0 (MailConfigIdentity, 1);
+ new->name = g_strdup (id->name);
+ new->address = g_strdup (id->address);
+ new->reply_to = g_strdup (id->reply_to);
+ new->organization = g_strdup (id->organization);
+ new->signature = g_strdup (id->signature);
- return newid;
+ return new;
}
void
@@ -84,32 +78,28 @@ identity_destroy (MailConfigIdentity *id)
g_free (id->name);
g_free (id->address);
- g_free (id->org);
- g_free (id->sig);
+ g_free (id->reply_to);
+ g_free (id->organization);
+ g_free (id->signature);
g_free (id);
}
-void
-identity_destroy_each (gpointer item, gpointer data)
-{
- identity_destroy ((MailConfigIdentity *)item);
-}
-
-/* Service struct */
+/* Service */
MailConfigService *
-service_copy (MailConfigService *source)
+service_copy (const MailConfigService *source)
{
- MailConfigService *newsource;
+ MailConfigService *new;
- g_return_val_if_fail (source, NULL);
+ g_return_val_if_fail (source != NULL, NULL);
- newsource = g_new0 (MailConfigService, 1);
- newsource->url = g_strdup (source->url);
- newsource->keep_on_server = source->keep_on_server;
- newsource->remember_password = source->remember_password;
+ new = g_new0 (MailConfigService, 1);
+ new->url = g_strdup (source->url);
+ new->keep_on_server = source->keep_on_server;
+ new->save_passwd = source->save_passwd;
+ new->use_ssl = source->use_ssl;
- return newsource;
+ return new;
}
void
@@ -117,7 +107,7 @@ service_destroy (MailConfigService *source)
{
if (!source)
return;
-
+
g_free (source->url);
g_free (source);
@@ -129,6 +119,46 @@ service_destroy_each (gpointer item, gpointer data)
service_destroy ((MailConfigService *)item);
}
+/* Account */
+MailConfigAccount *
+account_copy (const MailConfigAccount *account)
+{
+ MailConfigAccount *new;
+
+ g_return_val_if_fail (account != NULL, NULL);
+
+ new = g_new0 (MailConfigAccount, 1);
+ new->name = g_strdup (account->name);
+ new->default_account = account->default_account;
+
+ new->id = identity_copy (account->id);
+ new->source = service_copy (account->source);
+ new->transport = service_copy (account->transport);
+
+ return new;
+}
+
+void
+account_destroy (MailConfigAccount *account)
+{
+ if (!account)
+ return;
+
+ g_free (account->name);
+
+ identity_destroy (account->id);
+ service_destroy (account->source);
+ service_destroy (account->transport);
+
+ g_free (account);
+}
+
+void
+account_destroy_each (gpointer item, gpointer data)
+{
+ account_destroy ((MailConfigAccount *)item);
+}
+
/* Config struct routines */
void
mail_config_init (void)
@@ -137,11 +167,6 @@ mail_config_init (void)
return;
config = g_new0 (MailConfig, 1);
-
- config->ids = NULL;
- config->sources = NULL;
- config->transport = NULL;
-
config_read ();
}
@@ -151,26 +176,20 @@ mail_config_clear (void)
if (!config)
return;
- if (config->ids) {
- g_slist_foreach (config->ids, identity_destroy_each, NULL);
- g_slist_free (config->ids);
- config->ids = NULL;
- }
-
- if (config->sources) {
- g_slist_foreach (config->sources, service_destroy_each, NULL);
- g_slist_free (config->sources);
- config->sources = NULL;
+ if (config->accounts) {
+ g_slist_foreach (config->accounts, account_destroy_each, NULL);
+ g_slist_free (config->accounts);
+ config->accounts = NULL;
}
- service_destroy (config->transport);
- config->transport = NULL;
-
if (config->news) {
g_slist_foreach (config->news, service_destroy_each, NULL);
g_slist_free (config->news);
config->news = NULL;
}
+
+ /* overkill? */
+ memset (config, 0, sizeof (MailConfig));
}
static void
@@ -178,66 +197,79 @@ config_read (void)
{
gchar *str;
gint len, i;
+ gboolean have_default = FALSE;
mail_config_clear ();
-
+
/* Configured */
str = g_strdup_printf ("=%s/config/General=/General/configured", evolution_dir);
config->configured = gnome_config_get_bool (str);
g_free (str);
- /* Identities */
- str = g_strdup_printf ("=%s/config/Mail=/Identities/", evolution_dir);
+ /* Accounts */
+ str = g_strdup_printf ("=%s/config/Mail=/Accounts/", evolution_dir);
gnome_config_push_prefix (str);
g_free (str);
-
+
len = gnome_config_get_int ("num");
for (i = 0; i < len; i++) {
+ MailConfigAccount *account;
MailConfigIdentity *id;
+ MailConfigService *source;
+ MailConfigService *transport;
gchar *path;
- id = g_new0 (MailConfigIdentity, 1);
-
- path = g_strdup_printf ("name_%d", i);
+ account = g_new0 (MailConfigAccount, 1);
+ path = g_strdup_printf ("account_name_%d", i);
+ account->name = gnome_config_get_string (path);
+ g_free (path);
+ path = g_strdup_printf ("account_is_default_%d", i);
+ account->default_account = gnome_config_get_bool (path) && !have_default;
+ if (account->default_account)
+ have_default = TRUE;
+ g_free (path);
+
+ /* get the identity info */
+ id = g_new0 (MailConfigIdentity, 1);
+ path = g_strdup_printf ("identity_name_%d", i);
id->name = gnome_config_get_string (path);
g_free (path);
- path = g_strdup_printf ("address_%d", i);
+ path = g_strdup_printf ("identity_replyto_%d", i);
+ id->reply_to = gnome_config_get_string (path);
+ g_free (path);
+ path = g_strdup_printf ("identity_address_%d", i);
id->address = gnome_config_get_string (path);
g_free (path);
- path = g_strdup_printf ("org_%d", i);
- id->org = gnome_config_get_string (path);
+ path = g_strdup_printf ("identity_organization_%d", i);
+ id->organization = gnome_config_get_string (path);
g_free (path);
- path = g_strdup_printf ("sig_%d", i);
- id->sig = gnome_config_get_string (path);
+ path = g_strdup_printf ("identity_signature_%d", i);
+ id->signature = gnome_config_get_string (path);
g_free (path);
-
- config->ids = g_slist_append (config->ids, id);
- }
- gnome_config_pop_prefix ();
-
- /* Sources */
- str = g_strdup_printf ("=%s/config/Mail=/Sources/", evolution_dir);
- gnome_config_push_prefix (str);
- g_free (str);
-
- len = gnome_config_get_int ("num");
- for (i = 0; i < len; i++) {
- MailConfigService *s;
- gchar *path;
-
- s = g_new0 (MailConfigService, 1);
- path = g_strdup_printf ("url_%d", i);
- s->url = gnome_config_get_string (path);
+ /* get the source */
+ source = g_new0 (MailConfigService, 1);
+ path = g_strdup_printf ("source_url_%d", i);
+ source->url = gnome_config_get_string (path);
g_free (path);
- path = g_strdup_printf ("keep_on_server_%d", i);
- s->keep_on_server = gnome_config_get_bool (path);
+ path = g_strdup_printf ("source_keep_on_server_%d", i);
+ source->keep_on_server = gnome_config_get_bool (path);
g_free (path);
- path = g_strdup_printf ("remember_password_%d", i);
- s->remember_password = gnome_config_get_bool (path);
+ path = g_strdup_printf ("source_save_passwd_%d", i);
+ source->save_passwd = gnome_config_get_bool (path);
g_free (path);
- config->sources = g_slist_append (config->sources, s);
+ /* get the transport */
+ transport = g_new0 (MailConfigService, 1);
+ path = g_strdup_printf ("transport_url_%d", i);
+ transport->url = gnome_config_get_string (path);
+ g_free (path);
+
+ account->id = id;
+ account->source = source;
+ account->transport = transport;
+
+ config->accounts = g_slist_append (config->accounts, account);
}
gnome_config_pop_prefix ();
@@ -245,53 +277,46 @@ config_read (void)
str = g_strdup_printf ("=%s/config/News=/Sources/", evolution_dir);
gnome_config_push_prefix (str);
g_free (str);
-
+
len = gnome_config_get_int ("num");
for (i = 0; i < len; i++) {
MailConfigService *n;
gchar *path;
n = g_new0 (MailConfigService, 1);
-
+
path = g_strdup_printf ("url_%d", i);
n->url = gnome_config_get_string (path);
g_free (path);
-
+
config->news = g_slist_append (config->news, n);
}
gnome_config_pop_prefix ();
- /* Transport */
- config->transport = g_new0 (MailConfigService, 1);
- str = g_strdup_printf ("=%s/config/Mail=/Transport/url",
- evolution_dir);
- config->transport->url = gnome_config_get_string (str);
- g_free (str);
-
/* Format */
str = g_strdup_printf ("=%s/config/Mail=/Format/send_html",
evolution_dir);
config->send_html = gnome_config_get_bool (str);
g_free (str);
-
+
/* Mark as seen timeout */
str = g_strdup_printf ("=%s/config/Mail=/Display/seen_timeout=1500",
evolution_dir);
config->seen_timeout = gnome_config_get_int (str);
g_free (str);
-
+
/* Show Messages Threaded */
str = g_strdup_printf ("=%s/config/Mail=/Display/thread_list",
evolution_dir);
config->thread_list = gnome_config_get_bool (str);
g_free (str);
-
+
/* Size of vpaned in mail view */
str = g_strdup_printf ("=%s/config/Mail=/Display/paned_size=200",
evolution_dir);
config->paned_size = gnome_config_get_int (str);
g_free (str);
-
+
gnome_config_sync ();
}
@@ -300,7 +325,7 @@ mail_config_write (void)
{
gchar *str;
gint len, i;
-
+
/* Configured switch */
str = g_strdup_printf ("=%s/config/General=/General/configured",
evolution_dir);
@@ -308,96 +333,90 @@ mail_config_write (void)
gnome_config_set_bool (str, config->configured);
g_free (str);
- /* Identities */
- str = g_strdup_printf ("=%s/config/Mail=/Identities/", evolution_dir);
+ /* Accounts */
+ str = g_strdup_printf ("=%s/config/Mail=/Accounts/", evolution_dir);
gnome_config_push_prefix (str);
g_free (str);
-
- len = g_slist_length (config->ids);
+
+ len = g_slist_length (config->accounts);
gnome_config_set_int ("num", len);
for (i = 0; i < len; i++) {
- MailConfigIdentity *id;
+ MailConfigAccount *account;
gchar *path;
- id = (MailConfigIdentity *)g_slist_nth_data (config->ids, i);
+ account = g_slist_nth_data (config->accounts, i);
- path = g_strdup_printf ("name_%d", i);
- gnome_config_set_string (path, id->name);
+ /* account info */
+ path = g_strdup_printf ("account_name_%d", i);
+ gnome_config_set_string (path, account->name);
g_free (path);
- path = g_strdup_printf ("address_%d", i);
- gnome_config_set_string (path, id->address);
+ path = g_strdup_printf ("account_is_default_%d", i);
+ gnome_config_set_bool (path, account->default_account);
g_free (path);
- path = g_strdup_printf ("org_%d", i);
- gnome_config_set_string (path, id->org);
+
+ /* identity info */
+ path = g_strdup_printf ("identity_name_%d", i);
+ gnome_config_set_string (path, account->id->name);
g_free (path);
- path = g_strdup_printf ("sig_%d", i);
- gnome_config_set_string (path, id->sig);
+ path = g_strdup_printf ("identity_address_%d", i);
+ gnome_config_set_string (path, account->id->address);
+ g_free (path);
+ path = g_strdup_printf ("identity_organization_%d", i);
+ gnome_config_set_string (path, account->id->organization);
+ g_free (path);
+ path = g_strdup_printf ("identity_signature_%d", i);
+ gnome_config_set_string (path, account->id->signature);
g_free (path);
- }
- gnome_config_pop_prefix ();
-
- /* Sources */
- str = g_strdup_printf ("=%s/config/Mail=/Sources/", evolution_dir);
- gnome_config_push_prefix (str);
- g_free (str);
-
- len = g_slist_length (config->sources);
- gnome_config_set_int ("num", len);
- for (i=0; i<len; i++) {
- MailConfigService *s;
- gchar *path;
-
- s = (MailConfigService *)g_slist_nth_data (config->sources, i);
- path = g_strdup_printf ("url_%d", i);
- gnome_config_set_string (path, s->url);
+ /* source info */
+ path = g_strdup_printf ("source_url_%d", i);
+ gnome_config_set_string (path, account->source->url);
g_free (path);
- path = g_strdup_printf ("keep_on_server_%d", i);
- gnome_config_set_bool (path, s->keep_on_server);
+ path = g_strdup_printf ("source_keep_on_server_%d", i);
+ gnome_config_set_bool (path, account->source->keep_on_server);
g_free (path);
- path = g_strdup_printf ("remember_password_%d", i);
- gnome_config_set_bool (path, s->remember_password);
+ path = g_strdup_printf ("source_save_passwd_%d", i);
+ gnome_config_set_bool (path, account->source->save_passwd);
+ g_free (path);
+
+ /* transport info */
+ path = g_strdup_printf ("transport_url_%d", i);
+ gnome_config_set_string (path, account->transport->url);
g_free (path);
}
gnome_config_pop_prefix ();
-
+
/* News */
str = g_strdup_printf ("=%s/config/News=/Sources/", evolution_dir);
gnome_config_push_prefix (str);
g_free (str);
-
+
len = g_slist_length (config->news);
gnome_config_set_int ("num", len);
- for (i=0; i<len; i++) {
+ for (i = 0; i < len; i++) {
MailConfigService *n;
gchar *path;
- n = (MailConfigService *)g_slist_nth_data (config->news, i);
+ n = g_slist_nth_data (config->news, i);
path = g_strdup_printf ("url_%d", i);
gnome_config_set_string (path, n->url);
g_free (path);
}
gnome_config_pop_prefix ();
-
- /* Transport */
- str = g_strdup_printf ("=%s/config/Mail=/Transport/url",
- evolution_dir);
- gnome_config_set_string (str, config->transport->url);
- g_free (str);
/* Mark as seen timeout */
str = g_strdup_printf ("=%s/config/Mail=/Display/seen_timeout",
evolution_dir);
gnome_config_set_int (str, config->seen_timeout);
g_free (str);
-
+
/* Format */
str = g_strdup_printf ("=%s/config/Mail=/Format/send_html",
evolution_dir);
gnome_config_set_bool (str, config->send_html);
g_free (str);
-
+
gnome_config_sync ();
}
@@ -407,27 +426,29 @@ mail_config_write_on_exit (void)
gchar *str;
GSList *sources;
MailConfigService *s;
-
+
/* Show Messages Threaded */
str = g_strdup_printf ("=%s/config/Mail=/Display/thread_list",
evolution_dir);
gnome_config_set_bool (str, config->thread_list);
g_free (str);
-
+
/* Size of vpaned in mail view */
str = g_strdup_printf ("=%s/config/Mail=/Display/paned_size",
evolution_dir);
gnome_config_set_int (str, config->paned_size);
g_free (str);
-
+
/* Passwords */
gnome_config_private_clean_section ("/Evolution/Passwords");
- for (sources = config->sources; sources; sources = sources->next) {
+ sources = mail_config_get_sources ();
+ for ( ; sources; sources = sources->next) {
s = sources->data;
- if (s->remember_password)
+ if (s->save_passwd)
mail_session_remember_password (s->url);
}
-
+ g_slist_free (sources);
+
gnome_config_sync ();
}
@@ -439,23 +460,23 @@ mail_config_is_configured (void)
}
gboolean
-mail_config_thread_list (void)
+mail_config_get_thread_list (void)
{
return config->thread_list;
}
-gboolean
-mail_config_view_source (void)
-{
- return config->view_source;
-}
-
void
mail_config_set_thread_list (gboolean value)
{
config->thread_list = value;
}
+gboolean
+mail_config_get_view_source (void)
+{
+ return config->view_source;
+}
+
void
mail_config_set_view_source (gboolean value)
{
@@ -463,7 +484,7 @@ mail_config_set_view_source (gboolean value)
}
gint
-mail_config_paned_size (void)
+mail_config_get_paned_size (void)
{
return config->paned_size;
}
@@ -475,7 +496,7 @@ mail_config_set_paned_size (gint value)
}
gboolean
-mail_config_send_html (void)
+mail_config_get_send_html (void)
{
return config->send_html;
}
@@ -487,7 +508,7 @@ mail_config_set_send_html (gboolean send_html)
}
gint
-mail_config_mark_as_seen_timeout (void)
+mail_config_get_mark_as_seen_timeout (void)
{
return config->seen_timeout;
}
@@ -498,68 +519,94 @@ mail_config_set_mark_as_seen_timeout (gint timeout)
config->seen_timeout = timeout;
}
-MailConfigIdentity *
-mail_config_get_default_identity (void)
+const MailConfigAccount *
+mail_config_get_default_account (void)
{
- if (!config->ids)
+ const MailConfigAccount *account;
+ GSList *l;
+
+ if (!config->accounts)
return NULL;
- return (MailConfigIdentity *)config->ids->data;
+ /* find the default account */
+ l = config->accounts;
+ while (l) {
+ account = l->data;
+ if (account->default_account)
+ return account;
+ l = l->next;
+ }
+
+ /* non are marked as default so return the first one */
+ return (MailConfigAccount *)config->accounts->data;
}
-GSList *
-mail_config_get_identities (void)
+const GSList *
+mail_config_get_accounts (void)
{
- return config->ids;
+ return config->accounts;
}
void
-mail_config_add_identity (MailConfigIdentity *id)
+mail_config_add_account (MailConfigAccount *account)
{
- MailConfigIdentity *new_id = identity_copy (id);
-
- config->ids = g_slist_append (config->ids, new_id);
-}
-
-MailConfigService *
-mail_config_get_default_source (void)
-{
- if (!config->sources)
- return NULL;
+ if (account->default_account) {
+ /* Un-defaultify other accounts */
+ GSList *node = config->accounts;
+
+ while (node) {
+ MailConfigAccount *acnt = node->data;
+
+ acnt->default_account = FALSE;
+
+ node = node->next;
+ }
+ }
- return (MailConfigService *)config->sources->data;
-}
-
-GSList *
-mail_config_get_sources (void)
-{
- return config->sources;
+ config->accounts = g_slist_append (config->accounts, account);
}
void
-mail_config_add_source (MailConfigService *source)
+mail_config_set_default_account (const MailConfigAccount *account)
{
- MailConfigService *new_source = service_copy (source);
+ GSList *node = config->accounts;
+
+ while (node) {
+ MailConfigAccount *acnt = node->data;
+
+ acnt->default_account = FALSE;
+
+ node = node->next;
+ }
- config->sources = g_slist_append (config->sources, new_source);
+ ((MailConfigAccount *) account)->default_account = TRUE;
}
-MailConfigService *
-mail_config_get_transport (void)
+const MailConfigIdentity *
+mail_config_get_default_identity (void)
{
- return config->transport;
+ const MailConfigAccount *account;
+
+ account = mail_config_get_default_account ();
+ if (account)
+ return account->id;
+ else
+ return NULL;
}
-void
-mail_config_set_transport (MailConfigService *transport)
+const MailConfigService *
+mail_config_get_default_transport (void)
{
- if (config->transport)
- service_destroy (config->transport);
-
- config->transport = transport;
+ const MailConfigAccount *account;
+
+ account = mail_config_get_default_account ();
+ if (account)
+ return account->transport;
+ else
+ return NULL;
}
-MailConfigService *
+const MailConfigService *
mail_config_get_default_news (void)
{
if (!config->news)
@@ -568,7 +615,7 @@ mail_config_get_default_news (void)
return (MailConfigService *)config->news->data;
}
-GSList *
+const GSList *
mail_config_get_news (void)
{
return config->news;
@@ -577,24 +624,104 @@ mail_config_get_news (void)
void
mail_config_add_news (MailConfigService *news)
{
- MailConfigService *new_news = service_copy (news);
+ config->news = g_slist_append (config->news, news);
+}
- config->news = g_slist_append (config->news, new_news);
+GSList *
+mail_config_get_sources (void)
+{
+ const GSList *accounts;
+ GSList *sources = NULL;
+
+ accounts = mail_config_get_accounts ();
+ while (accounts) {
+ const MailConfigAccount *account = accounts->data;
+
+ if (account->source)
+ sources = g_slist_append (sources, account->source);
+
+ accounts = accounts->next;
+ }
+
+ return sources;
}
char *
-mail_config_folder_to_cachename(CamelFolder *folder, const char *prefix)
+mail_config_folder_to_cachename (CamelFolder *folder, const char *prefix)
{
char *url, *filename;
- url = camel_url_to_string(CAMEL_SERVICE(folder->parent_store)->url, FALSE);
+ url = camel_url_to_string (CAMEL_SERVICE (folder->parent_store)->url, FALSE);
e_filename_make_safe (url);
- filename = g_strdup_printf("%s/config/%s%s", evolution_dir, prefix, url);
- g_free(url);
+ filename = g_strdup_printf ("%s/config/%s%s", evolution_dir, prefix, url);
+ g_free (url);
+
return filename;
}
+/* Async service-checking/authtype-lookup code. */
+
+typedef struct {
+ char *url;
+ CamelProviderType type;
+ GList **authtypes;
+ gboolean success;
+} check_service_input_t;
+static char *
+describe_check_service (gpointer in_data, gboolean gerund)
+{
+ if (gerund)
+ return g_strdup (_("Connecting to server"));
+ else
+ return g_strdup (_("Connect to server"));
+}
+static void
+do_check_service (gpointer in_data, gpointer op_data, CamelException *ex)
+{
+ check_service_input_t *input = in_data;
+ CamelService *service;
+
+ if (input->authtypes) {
+ service = camel_session_get_service (
+ session, input->url, input->type, ex);
+ if (!service)
+ return;
+ *input->authtypes = camel_service_query_auth_types (service, ex);
+ } else {
+ service = camel_session_get_service_connected (
+ session, input->url, input->type, ex);
+ }
+ if (service)
+ camel_object_unref (CAMEL_OBJECT (service));
+ if (!camel_exception_is_set (ex))
+ input->success = TRUE;
+}
+
+static const mail_operation_spec op_check_service = {
+ describe_check_service,
+ 0,
+ NULL,
+ do_check_service,
+ NULL
+};
+
+gboolean
+mail_config_check_service (CamelURL *url, CamelProviderType type, GList **authtypes)
+{
+ check_service_input_t input;
+
+ input.url = camel_url_to_string (url, TRUE);
+ input.type = type;
+ input.authtypes = authtypes;
+ input.success = FALSE;
+
+ mail_operation_queue (&op_check_service, &input, FALSE);
+ mail_operation_wait_for_finish ();
+ g_free (input.url);
+
+ return input.success;
+}