/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2001 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2002 Hiroyuki Yamamoto
*
* 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
#include "utils.h"
#include "alertpanel.h"
-#include "pixmaps/mark.xpm"
-#include "pixmaps/checkbox_on.xpm"
-#include "pixmaps/checkbox_off.xpm"
-
typedef enum
{
COL_DEFAULT = 0,
gint column,
GdkEvent *event,
gpointer data);
+static void account_row_moved (GtkCList *clist,
+ gint source_row,
+ gint dest_row);
static void account_key_pressed (GtkWidget *widget,
GdkEventKey *event,
gpointer data);
gchar buf[PREFSBUFSIZE];
PrefsAccount *ac_prefs;
- debug_print(_("Reading all config for each account...\n"));
+ debug_print("Reading all config for each account...\n");
rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, ACCOUNT_RC, NULL);
- if ((fp = fopen(rcpath, "r")) == NULL) {
+ if ((fp = fopen(rcpath, "rb")) == NULL) {
if (ENOENT != errno) FILE_OP_ERROR(rcpath, "fopen");
g_free(rcpath);
return;
strretchomp(buf);
memmove(buf, buf + 1, strlen(buf));
buf[strlen(buf) - 1] = '\0';
- debug_print(_("Found label: %s\n"), buf);
+ debug_print("Found label: %s\n", buf);
ac_label_list = g_slist_append(ac_label_list,
g_strdup(buf));
}
/* 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)
for (cur = account_list; cur != NULL; cur = cur->next) {
ac = (PrefsAccount *)cur->data;
if (ac->protocol != A_NNTP && ac->address &&
- strcasestr(address, ac->address))
+ strcasestr(address, ac->address) != NULL)
return ac;
}
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)
+{
+ 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;
+}
+
void account_set_menu(void)
{
main_window_set_account_menu(account_list);
return;
}
- debug_print(_("Opening account edit window...\n"));
+ debug_print("Opening account edit window...\n");
if (!edit_account.window)
account_edit_create();
}
}
+FolderItem *account_get_special_folder(PrefsAccount *ac_prefs,
+ SpecialFolderItemType type)
+{
+ FolderItem *item = NULL;
+
+ g_return_val_if_fail(ac_prefs != NULL, NULL);
+
+ if (type == F_OUTBOX) {
+ if (ac_prefs->set_sent_folder && ac_prefs->sent_folder) {
+ item = folder_find_item_from_identifier
+ (ac_prefs->sent_folder);
+ }
+ if (!item) {
+ if (ac_prefs->folder)
+ item = FOLDER(ac_prefs->folder)->outbox;
+ if (!item)
+ item = folder_get_default_outbox();
+ }
+ } else if (type == F_DRAFT) {
+ if (ac_prefs->set_draft_folder && ac_prefs->draft_folder) {
+ item = folder_find_item_from_identifier
+ (ac_prefs->draft_folder);
+ }
+ if (!item) {
+ if (ac_prefs->folder)
+ item = FOLDER(ac_prefs->folder)->draft;
+ if (!item)
+ item = folder_get_default_draft();
+ }
+ } else if (type == F_QUEUE) {
+ if (ac_prefs->folder)
+ item = FOLDER(ac_prefs->folder)->queue;
+ if (!item)
+ item = folder_get_default_queue();
+ } else if (type == F_TRASH) {
+ if (ac_prefs->set_trash_folder && ac_prefs->trash_folder) {
+ item = folder_find_item_from_identifier
+ (ac_prefs->trash_folder);
+ }
+ if (!item) {
+ if (ac_prefs->folder)
+ item = FOLDER(ac_prefs->folder)->trash;
+ if (!item)
+ item = folder_get_default_trash();
+ }
+ }
+
+ return item;
+}
+
void account_destroy(PrefsAccount *ac_prefs)
{
g_return_if_fail(ac_prefs != NULL);
GtkWidget *hbbox;
GtkWidget *close_btn;
- debug_print(_("Creating account edit window...\n"));
+ debug_print("Creating account edit window...\n");
window = gtk_window_new (GTK_WINDOW_DIALOG);
gtk_widget_set_usize (window, 500, 320);
GTK_SIGNAL_FUNC (account_delete_event), NULL);
gtk_signal_connect (GTK_OBJECT (window), "key_press_event",
GTK_SIGNAL_FUNC (account_key_pressed), NULL);
- gtk_signal_connect (GTK_OBJECT (window), "focus_in_event",
- GTK_SIGNAL_FUNC (manage_window_focus_in), NULL);
- gtk_signal_connect (GTK_OBJECT (window), "focus_out_event",
- GTK_SIGNAL_FUNC (manage_window_focus_out), NULL);
+ MANAGE_WINDOW_SIGNALS_CONNECT (window);
gtk_widget_realize(window);
vbox = gtk_vbox_new (FALSE, 10);
gtk_signal_connect (GTK_OBJECT (clist), "select_row",
GTK_SIGNAL_FUNC (account_selected), NULL);
+ gtk_signal_connect (GTK_OBJECT (clist), "row_move",
+ GTK_SIGNAL_FUNC (account_row_moved), NULL);
vbox2 = gtk_vbox_new (FALSE, 0);
gtk_widget_show (vbox2);
row = GPOINTER_TO_INT(clist->selection->data);
ac_prefs = gtk_clist_get_row_data(clist, row);
prev_default = ac_prefs->is_default;
- Xstrdup_a(ac_name, ac_prefs->account_name, return);
+ Xstrdup_a(ac_name, ac_prefs->account_name ? ac_prefs->account_name : "",
+ return);
prefs_account_open(ac_prefs);
account_set_as_default(ac_prefs);
if ((ac_prefs->protocol == A_IMAP4 || ac_prefs->protocol == A_NNTP) &&
- ac_prefs->folder && strcmp(ac_name, ac_prefs->account_name) != 0) {
+ ac_prefs->folder && strcmp2(ac_name, ac_prefs->account_name) != 0) {
folder_set_name(FOLDER(ac_prefs->folder),
ac_prefs->account_name);
- folderview_update_all();
+ folderview_set_all();
}
account_clist_set();
ac_prefs = gtk_clist_get_row_data(clist, row);
if (ac_prefs->folder) {
folder_destroy(FOLDER(ac_prefs->folder));
- folderview_update_all();
+ folderview_set_all();
}
account_destroy(ac_prefs);
account_clist_set();
- debug_print(_("Removing deleted account references for all the folders...\n"));
+ debug_print("Removing deleted account references for all the folders...\n");
list = folder_get_list();
for (; list != NULL; list = list->next) {
folder = FOLDER(list->data);
if (!clist->selection) return;
row = GPOINTER_TO_INT(clist->selection->data);
- if (row > 0) {
+ if (row > 0)
gtk_clist_row_move(clist, row, row - 1);
- account_list_set();
- }
}
static void account_down(void)
if (!clist->selection) return;
row = GPOINTER_TO_INT(clist->selection->data);
- if (row < clist->rows - 1) {
+ if (row < clist->rows - 1)
gtk_clist_row_move(clist, row, row + 1);
- account_list_set();
- }
}
static void account_set_default(void)
PrefsAccount *ac;
ac = gtk_clist_get_row_data(clist, row);
- if (ac->protocol == A_POP3 || ac->protocol == A_APOP) {
+ if (ac->protocol == A_POP3 || ac->protocol == A_APOP ||
+ ac->protocol == A_IMAP4 || ac->protocol == A_NNTP ||
+ ac->protocol == A_LOCAL) {
ac->recv_at_getall ^= TRUE;
account_clist_set_row(ac, row);
}
}
}
+static void account_row_moved(GtkCList *clist, gint source_row, gint dest_row)
+{
+ account_list_set();
+ if (gtk_clist_row_is_visible(clist, dest_row) != GTK_VISIBILITY_FULL) {
+ gtk_clist_moveto(clist, dest_row, -1,
+ source_row < dest_row ? 1.0 : 0.0, 0.0);
+ }
+}
+
static void account_key_pressed(GtkWidget *widget, GdkEventKey *event,
gpointer data)
{
text[COL_NAME] = ac_prefs->account_name;
#if USE_SSL
text[COL_PROTOCOL] = ac_prefs->protocol == A_POP3 ?
- (ac_prefs->ssl_pop ? "POP3 (SSL)" : "POP3") :
+ (ac_prefs->ssl_pop == SSL_TUNNEL ?
+ "POP3 (SSL)" :
+ ac_prefs->ssl_pop == SSL_STARTTLS ?
+ "POP3 (TLS)" : "POP3") :
ac_prefs->protocol == A_APOP ?
- (ac_prefs->ssl_pop ?
- "POP3 (APOP, SSL)" : "POP3 (APOP)") :
+ (ac_prefs->ssl_pop == SSL_TUNNEL ?
+ "POP3 (APOP, SSL)" :
+ ac_prefs->ssl_pop == SSL_STARTTLS ?
+ "POP3 (APOP, TLS)" : "POP3 (APOP)") :
ac_prefs->protocol == A_IMAP4 ?
- (ac_prefs->ssl_imap ? "IMAP4 (SSL)" : "IMAP4") :
- ac_prefs->protocol == A_LOCAL ? "Local" :
- ac_prefs->protocol == A_NNTP ? "NNTP" : "";
+ (ac_prefs->ssl_imap == SSL_TUNNEL ?
+ "IMAP4 (SSL)" :
+ ac_prefs->ssl_imap == SSL_STARTTLS ?
+ "IMAP4 (TLS)" : "IMAP4") :
+ ac_prefs->protocol == A_NNTP ?
+ (ac_prefs->ssl_nntp == SSL_TUNNEL ?
+ "NNTP (SSL)" : "NNTP") :
+ "";
#else
text[COL_PROTOCOL] = ac_prefs->protocol == A_POP3 ? "POP3" :
ac_prefs->protocol == A_APOP ? "POP3 (APOP)" :
gtk_clist_set_text(clist, row, COL_SERVER, text[COL_SERVER]);
}
- has_getallbox = (ac_prefs->protocol == A_POP3 ||
- ac_prefs->protocol == A_APOP);
+ has_getallbox = (ac_prefs->protocol == A_POP3 ||
+ ac_prefs->protocol == A_APOP ||
+ ac_prefs->protocol == A_IMAP4 ||
+ ac_prefs->protocol == A_NNTP ||
+ ac_prefs->protocol == A_LOCAL);
getall = has_getallbox && ac_prefs->recv_at_getall;
if (ac_prefs->is_default)
{
GtkCList *clist = GTK_CLIST(edit_account.clist);
GList *cur;
- gint prev_row;
+ gint row = -1, prev_row = -1;
if (clist->selection)
prev_row = GPOINTER_TO_INT(clist->selection->data);
- else
- prev_row = -1;
gtk_clist_freeze(clist);
gtk_clist_clear(clist);
for (cur = account_list; cur != NULL; cur = cur->next) {
- gint row;
-
row = account_clist_set_row((PrefsAccount *)cur->data, -1);
if ((PrefsAccount *)cur->data == cur_account) {
gtk_clist_select_row(clist, row, -1);
}
if (prev_row >= 0) {
- gtk_clist_select_row(clist, prev_row, -1);
- gtkut_clist_set_focus_row(clist, prev_row);
- gtk_clist_moveto(clist, prev_row, 0, 0.5, 0);
+ row = prev_row;
+ gtk_clist_select_row(clist, row, -1);
+ gtkut_clist_set_focus_row(clist, row);
}
+ if (row >= 0 &&
+ gtk_clist_row_is_visible(clist, row) != GTK_VISIBILITY_FULL)
+ gtk_clist_moveto(clist, row, -1, 0.5, 0);
+
gtk_clist_thaw(clist);
}