#include "gtkutils.h"
#include "utils.h"
#include "alertpanel.h"
+#include "procheader.h"
typedef enum
{
Folder *folder;
if (ac_prefs->protocol == A_IMAP4) {
- folder = folder_new(F_IMAP, ac_prefs->account_name,
+ folder = folder_new(folder_get_class_from_string("imap"), ac_prefs->account_name,
ac_prefs->recv_server);
} else {
- folder = folder_new(F_NEWS, ac_prefs->account_name,
+ folder = folder_new(folder_get_class_from_string("news"), ac_prefs->account_name,
ac_prefs->nntp_server);
}
ac_prefs->folder = REMOTE_FOLDER(folder);
folder_add(folder);
if (ac_prefs->protocol == A_IMAP4)
- folder->create_tree(folder);
+ folder->class->create_tree(folder);
folderview_set_all();
}
}
Folder *folder;
if (ap->protocol == A_IMAP4) {
- folder = folder_new(F_IMAP, ap->account_name,
+ folder = folder_new(folder_get_class_from_string("imap"), ap->account_name,
ap->recv_server);
} else {
- folder = folder_new(F_NEWS, ap->account_name,
+ folder = folder_new(folder_get_class_from_string("news"), ap->account_name,
ap->nntp_server);
}
ap->folder = REMOTE_FOLDER(folder);
folder_add(folder);
if (ap->protocol == A_IMAP4)
- folder->create_tree(folder);
+ folder->class->create_tree(folder);
}
}
}
row++)
account_list = g_list_append(account_list, ac_prefs);
}
+
+/*!
+ *\brief finds the PrefsAccounts which should be used to answer a mail
+ *
+ *\param msginfo The message to be answered
+ *\param reply_autosel Indicates whether reply account autoselection is on
+ *
+ *\return PrefsAccount * the correct account, NULL if not found
+ */
+PrefsAccount *account_get_reply_account(MsgInfo *msginfo, gboolean reply_autosel)
+{
+ PrefsAccount *account = NULL;
+ /* select the account set in folderitem's property (if enabled) */
+ if (msginfo->folder->prefs && msginfo->folder->prefs->enable_default_account)
+ account = account_find_from_id(msginfo->folder->prefs->default_account);
+
+ /* select the account for the whole folder (IMAP / NNTP) */
+ if (!account)
+ /* FIXME: this is not right, because folder may be nested. we should
+ * ascend the tree until we find a parent with proper account
+ * information */
+ account = msginfo->folder->folder->account;
+
+ /* select account by to: and cc: header if enabled */
+ if (reply_autosel) {
+ if (!account && msginfo->to) {
+ gchar *to;
+ Xstrdup_a(to, msginfo->to, return NULL);
+ extract_address(to);
+ account = account_find_from_address(to);
+ }
+ if (!account) {
+ gchar cc[BUFFSIZE];
+ if (!get_header_from_msginfo(msginfo, cc, sizeof(cc), "CC:")) { /* Found a CC header */
+ extract_address(cc);
+ account = account_find_from_address(cc);
+ }
+ }
+ }
+
+ /* select current account */
+ if (!account) account = cur_account;
+
+ return account;
+}