aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Leach <jleach@ximian.com>2001-07-07 06:33:07 +0800
committerJacob Leach <jleach@src.gnome.org>2001-07-07 06:33:07 +0800
commitb1279f80c667fd2304fee2a8ed66c3e038722dfd (patch)
tree616ea336c61a69bc570c798a9b9cdbad4186cf69
parent2caec09b47fe3d60677c8e4439b78abd6cf7888e (diff)
downloadgsoc2013-evolution-b1279f80c667fd2304fee2a8ed66c3e038722dfd.tar
gsoc2013-evolution-b1279f80c667fd2304fee2a8ed66c3e038722dfd.tar.gz
gsoc2013-evolution-b1279f80c667fd2304fee2a8ed66c3e038722dfd.tar.bz2
gsoc2013-evolution-b1279f80c667fd2304fee2a8ed66c3e038722dfd.tar.lz
gsoc2013-evolution-b1279f80c667fd2304fee2a8ed66c3e038722dfd.tar.xz
gsoc2013-evolution-b1279f80c667fd2304fee2a8ed66c3e038722dfd.tar.zst
gsoc2013-evolution-b1279f80c667fd2304fee2a8ed66c3e038722dfd.zip
[Fix bug #1100, default account is stored strangely]
2001-07-06 Jason Leach <jleach@ximian.com> [Fix bug #1100, default account is stored strangely] * mail-config.c (mail_config_get_default_account_num): New function, returns the integer of the position of the default account, used to save which account is the default to the config db. (mail_config_write): Save the default account number here in "/Mail/Accounts/default_account". (config_read): Load in which is the default here. svn path=/trunk/; revision=10873
-rw-r--r--mail/ChangeLog12
-rw-r--r--mail/mail-config.c55
2 files changed, 50 insertions, 17 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 4a14acfeaa..e0149b20dc 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,15 @@
+2001-07-06 Jason Leach <jleach@ximian.com>
+
+ [Fix bug #1100, default account is stored strangely]
+
+ * mail-config.c (mail_config_get_default_account_num): New
+ function, returns the integer of the position of the default
+ account, used to save which account is the default to the config
+ db.
+ (mail_config_write): Save the default account number here in
+ "/Mail/Accounts/default_account".
+ (config_read): Load in which is the default here.
+
2001-07-06 Larry Ewing <lewing@ximian.com>
* mail-callbacks.c (composer_send_cb): add a NULL check since that
diff --git a/mail/mail-config.c b/mail/mail-config.c
index d0b473172f..0596cf23f6 100644
--- a/mail/mail-config.c
+++ b/mail/mail-config.c
@@ -89,6 +89,7 @@ static MailConfig *config = NULL;
/* Prototypes */
static void config_read (void);
+static gint mail_config_get_default_account_num (void);
/* Identity */
MailConfigIdentity *
@@ -270,14 +271,16 @@ mail_config_clear (void)
static void
config_read (void)
{
- gint len, i;
- gboolean have_default = FALSE;
-
+ gint len, i, default_num;
+
mail_config_clear ();
len = bonobo_config_get_long_with_default (config->db,
"/Mail/Accounts/num", 0, NULL);
+ default_num = bonobo_config_get_long_with_default (config->db,
+ "/Mail/Accounts/default_account", 0, NULL);
+
for (i = 0; i < len; i++) {
MailConfigAccount *account;
MailConfigIdentity *id;
@@ -289,13 +292,11 @@ config_read (void)
path = g_strdup_printf ("/Mail/Accounts/account_name_%d", i);
account->name = bonobo_config_get_string (config->db, path, NULL);
g_free (path);
- path = g_strdup_printf ("/Mail/Accounts/account_is_default_%d", i);
- account->default_account = bonobo_config_get_boolean
- (config->db, path, NULL) && !have_default;
-
- if (account->default_account)
- have_default = TRUE;
- g_free (path);
+
+ if (default_num == i)
+ account->default_account = TRUE;
+ else
+ account->default_account = FALSE;
path = g_strdup_printf ("/Mail/Accounts/account_drafts_folder_name_%d", i);
val = bonobo_config_get_string (config->db, path, NULL);
@@ -548,7 +549,7 @@ void
mail_config_write (void)
{
CORBA_Environment ev;
- gint len, i;
+ gint len, i, default_num;
/* Accounts */
@@ -563,7 +564,13 @@ mail_config_write (void)
Bonobo_ConfigDatabase_sync (config->db, &ev);
len = g_slist_length (config->accounts);
- bonobo_config_set_long (config->db, "/Mail/Accounts/num", len, NULL);
+ bonobo_config_set_long (config->db,
+ "/Mail/Accounts/num", len, NULL);
+
+ default_num = mail_config_get_default_account_num ();
+ bonobo_config_set_long (config->db,
+ "/Mail/Accounts/default_account", default_num, NULL);
+
for (i = 0; i < len; i++) {
MailConfigAccount *account;
gchar *path;
@@ -575,11 +582,6 @@ mail_config_write (void)
bonobo_config_set_string (config->db, path, account->name, NULL);
g_free (path);
- path = g_strdup_printf ("/Mail/Accounts/account_is_default_%d", i);
- bonobo_config_set_boolean (config->db, path,
- account->default_account, NULL);
- g_free (path);
-
path = g_strdup_printf ("/Mail/Accounts/account_drafts_folder_name_%d", i);
bonobo_config_set_string (config->db, path,
account->drafts_folder_name, NULL);
@@ -1341,6 +1343,25 @@ mail_config_remove_account (MailConfigAccount *account)
return config->accounts;
}
+static gint
+mail_config_get_default_account_num (void)
+{
+ int i = 0;
+ GSList *node = config->accounts;
+
+ while (node) {
+ MailConfigAccount *account = node->data;
+
+ if (account->default_account)
+ return i;
+
+ i++;
+ node = node->next;
+ }
+
+ return 0;
+}
+
void
mail_config_set_default_account (const MailConfigAccount *account)
{