* sync with main changes of 2002-10-04
[claws.git] / src / account.c
index 751def2d27c59ad785ab61605651f325b6dc7c34..37f84e2b9a4dd1b84b6c9aef263390a17bc069c3 100644 (file)
@@ -141,7 +141,7 @@ void account_read_config_all(void)
        /* read config data from file */
        cur_account = NULL;
        for (cur = ac_label_list; cur != NULL; cur = cur->next) {
-               ac_prefs = g_new0(PrefsAccount, 1);
+               ac_prefs = prefs_account_new();
                prefs_account_read_config(ac_prefs, (gchar *)cur->data);
                account_list = g_list_append(account_list, ac_prefs);
                if (ac_prefs->is_default)
@@ -169,6 +169,33 @@ void account_save_config_all(void)
        prefs_account_save_config_all(account_list);
 }
 
+/*
+ * account_find_all_from_address:
+ * @ac_list: initial list of accounts. NULL to create a new one.
+ * Accounts found in the @address will be appended to this list.
+ * @address: Email address string.
+ *
+ * Find all the mail (not news) accounts within the specified address.
+ *
+ * Return value: the original accounts list with the found accounts appended.
+ */
+GList *account_find_all_from_address(GList *ac_list, const gchar *address)
+{
+       GList *cur;
+       PrefsAccount *ac;
+
+       if (address == NULL)
+               return ac_list;
+
+       for (cur = account_list; cur != NULL; cur = cur->next) {
+               ac = (PrefsAccount *)cur->data;
+               if (ac->protocol != A_NNTP && ac->address &&
+                   strcasestr(address, ac->address) != NULL)
+                       ac_list = g_list_append(ac_list, ac);
+       }
+       return ac_list;
+}
+       
 PrefsAccount *account_find_from_smtp_server(const gchar *address,
                                            const gchar *smtp_server)
 {
@@ -227,33 +254,29 @@ PrefsAccount *account_find_from_id(gint id)
        return NULL;
 }
 
-/*
- * account_find_all_from_address:
- * @ac_list: initial list of accounts. NULL to create a new one.
- * Accounts found in the @address will be appended to this list.
- * @address: Email address string.
- *
- * Find all the mail (not news) accounts within the specified address.
- *
- * Return value: the original accounts list with the found accounts appended.
- */
-GList *account_find_all_from_address(GList *ac_list, const gchar *address)
+PrefsAccount *account_find_from_item(FolderItem *item)
 {
-       GList *cur;
        PrefsAccount *ac;
 
-       if (address == NULL)
-               return ac_list;
-
-       for (cur = account_list; cur != NULL; cur = cur->next) {
-               ac = (PrefsAccount *)cur->data;
-               if (ac->protocol != A_NNTP && ac->address &&
-                   strcasestr(address, ac->address) != NULL)
-                       ac_list = g_list_append(ac_list, ac);
+       g_return_val_if_fail(item != NULL, NULL);
+
+       ac = item->account;
+       if (!ac) {
+               FolderItem *cur_item = item->parent;
+               while (cur_item != NULL) {
+                       if (cur_item->account && cur_item->apply_sub) {
+                               ac = cur_item->account;
+                               break;
+                       }                               
+                       cur_item = cur_item->parent;
+               }
        }
-       return ac_list;
+       if (!ac)
+               ac = item->folder->account;
+
+       return ac;
 }
-       
+
 void account_set_menu(void)
 {
        main_window_set_account_menu(account_list);
@@ -645,7 +668,7 @@ static void account_edit_prefs(void)
            ac_prefs->folder && strcmp2(ac_name, ac_prefs->account_name) != 0) {
                folder_set_name(FOLDER(ac_prefs->folder),
                                ac_prefs->account_name);
-               folderview_rescan_all();
+               folderview_set_all();
        }
 
        account_clist_set();
@@ -669,6 +692,8 @@ static gboolean account_delete_references_func(GNode *node, gpointer data)
        item->prefs->enable_default_account = FALSE;
        item->prefs->default_account = 0;
        prefs_folder_item_save_config(item);
+
+       return FALSE;
 }
 
 static void account_delete(void)
@@ -690,7 +715,7 @@ static void account_delete(void)
        ac_prefs = gtk_clist_get_row_data(clist, row);
        if (ac_prefs->folder) {
                folder_destroy(FOLDER(ac_prefs->folder));
-               folderview_rescan_all();
+               folderview_set_all();
        }
        account_destroy(ac_prefs);
        account_clist_set();