/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2012 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 1999-2015 Hiroyuki Yamamoto and the Claws Mail team
*
* 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
#ifdef HAVE_CONFIG_H
# include "config.h"
+#include "claws-features.h"
#endif
#include "defs.h"
#include "manual.h"
#include "filtering.h"
#include "prefs_actions.h"
+#include "hooks.h"
+#include "passwordstore.h"
enum {
ACCOUNT_IS_DEFAULT,
gpointer data);
static void account_size_allocate_cb(GtkWidget *widget,
GtkAllocation *allocation);
-#ifndef MAEMO
static gboolean account_key_pressed (GtkWidget *widget,
GdkEventKey *event,
gpointer data);
-#endif
static gboolean account_search_func_cb (GtkTreeModel *model, gint column,
const gchar *key, GtkTreeIter *iter,
gpointer search_data);
while (fgets(buf, sizeof(buf), fp) != NULL) {
if (!strncmp(buf, "[Account: ", 10)) {
strretchomp(buf);
- memmove(buf, buf + 1, strlen(buf));
+ memmove(buf, buf + 1, sizeof(buf) - 1);
buf[strlen(buf) - 1] = '\0';
debug_print("Found label: %s\n", buf);
ac_label_list = g_slist_append(ac_label_list,
return account_list;
}
+void account_edit_focus(void)
+{
+ if (edit_account.window == NULL) {
+ return;
+ }
+ manage_window_set_transient(GTK_WINDOW(edit_account.window));
+ gtk_widget_grab_focus(edit_account.close_btn);
+ gtk_widget_show(edit_account.window);
+ gtk_window_set_modal(GTK_WINDOW(edit_account.window), TRUE);
+ manage_window_focus_in(edit_account.window, NULL, NULL);
+}
+
void account_edit_open(gpointer a, gpointer b)
{
inc_lock();
if (compose_get_compose_list()) {
alertpanel_error(_("Some composing windows are open.\n"
"Please close all the composing "
- "windows before editing the accounts."));
+ "windows before editing accounts."));
inc_unlock();
return;
}
account_list_view_set();
- manage_window_set_transient(GTK_WINDOW(edit_account.window));
- gtk_widget_grab_focus(edit_account.close_btn);
- gtk_widget_show(edit_account.window);
- gtk_window_set_modal(GTK_WINDOW(edit_account.window), TRUE);
- manage_window_focus_in(edit_account.window, NULL, NULL);
+ account_edit_focus();
}
void account_add(void)
if (!ac_prefs) return;
+ account_edit_focus();
+
account_list = g_list_append(account_list, ac_prefs);
if (ac_prefs->is_default)
cm_return_if_fail(ac_prefs != NULL);
+ if (compose_get_compose_list()) {
+ alertpanel_error(_("Some composing windows are open.\n"
+ "Please close all the composing "
+ "windows before editing accounts."));
+ return;
+ }
+
prev_default = ac_prefs->is_default;
Xstrdup_a(ac_name, ac_prefs->account_name ? ac_prefs->account_name : "",
return);
prefs_account_open(ac_prefs, &account_dirty);
+ account_edit_focus();
+
if (account_dirty) {
if (!prev_default && ac_prefs->is_default)
account_set_as_default(ac_prefs);
folder_unref_account_all(ac_prefs);
- prefs_account_free(ac_prefs);
account_list = g_list_remove(account_list, ac_prefs);
if (cur_account == ac_prefs) cur_account = NULL;
gtk_window_set_title (GTK_WINDOW (window), _("Edit accounts"));
g_signal_connect (G_OBJECT (window), "delete_event",
G_CALLBACK (account_delete_event), NULL);
-#ifdef MAEMO
- maemo_connect_key_press_to_mainwindow(GTK_WINDOW(window));
-#else
g_signal_connect (G_OBJECT (window), "key_press_event",
G_CALLBACK (account_key_pressed), NULL);
-#endif
MANAGE_WINDOW_SIGNALS_CONNECT (window);
gtk_widget_realize(window);
edit_account.window = window;
edit_account.list_view = list_view;
edit_account.close_btn = close_btn;
-#ifdef MAEMO
- maemo_window_full_screen_if_needed(GTK_WINDOW(edit_account.window));
-#endif
}
static void account_edit_prefs(GtkWidget *widget, gpointer data)
GINT_TO_POINTER(ac_prefs->account_id));
}
+ gchar *uid = g_strdup_printf("%d", ac_prefs->account_id);
+ passwd_store_delete_block(PWS_ACCOUNT, uid);
+ g_free(uid);
+
debug_print("Removing filter rules relative to this account...\n");
for(cur = filtering_rules ; cur != NULL ;) {
FilteringProp * prop = (FilteringProp *) cur->data;
account_edit_close(NULL, NULL);
return TRUE;
}
-#ifndef MAEMO
+
static gboolean account_key_pressed(GtkWidget *widget, GdkEventKey *event,
gpointer data)
{
account_edit_close(NULL, NULL);
return FALSE;
}
-#endif
static gboolean account_search_func_cb (GtkTreeModel *model, gint column, const gchar *key,
GtkTreeIter *iter, gpointer search_data)
#ifdef USE_GNUTLS
protocol = ac_prefs->protocol == A_POP3 ?
(ac_prefs->ssl_pop == SSL_TUNNEL ?
- "POP3 (SSL)" :
+ "POP (SSL/TLS)" :
ac_prefs->ssl_pop == SSL_STARTTLS ?
- "POP3 (TLS)" : "POP3") :
+ "POP (STARTTLS)" : "POP") :
ac_prefs->protocol == A_IMAP4 ?
(ac_prefs->ssl_imap == SSL_TUNNEL ?
- "IMAP4 (SSL)" :
+ "IMAP (SSL/TLS)" :
ac_prefs->ssl_imap == SSL_STARTTLS ?
- "IMAP4 (TLS)" : "IMAP4") :
+ "IMAP (STARTTLS)" : "IMAP") :
ac_prefs->protocol == A_NNTP ?
(ac_prefs->ssl_nntp == SSL_TUNNEL ?
- "NNTP (SSL)" : "NNTP") :
+ "NNTP (SSL/TLS)" : "NNTP") :
ac_prefs->protocol == A_LOCAL ? "Local" :
ac_prefs->protocol == A_NONE ? "SMTP" : "-";
#else
- protocol = ac_prefs->protocol == A_POP3 ? "POP3" :
- ac_prefs->protocol == A_IMAP4 ? "IMAP4" :
+ protocol = ac_prefs->protocol == A_POP3 ? "POP" :
+ ac_prefs->protocol == A_IMAP4 ? "IMAP" :
ac_prefs->protocol == A_LOCAL ? "Local" :
ac_prefs->protocol == A_NNTP ? "NNTP" :
ac_prefs->protocol == A_NONE ? "SMTP" : "-";
GtkTreeIter iter;
if (!gtk_tree_model_iter_nth_child(model, &iter, NULL, row)) {
- g_warning("%s(%d) - no iter found???\n", __FILE__, __LINE__);
+ g_warning("%s(%d) - no iter found???", __FILE__, __LINE__);
continue;
}
/* 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);
-
+ else if (folder_has_parent_of_type(msginfo->folder, F_QUEUE) ||
+ folder_has_parent_of_type(msginfo->folder, F_OUTBOX) ||
+ folder_has_parent_of_type(msginfo->folder, F_DRAFT)) {
+ gchar from[BUFFSIZE];
+ if (!procheader_get_header_from_msginfo
+ (msginfo, from, sizeof from, "From:")) {
+ gchar *buf = from + strlen("From:");
+ extract_address(buf);
+ account = account_find_from_address(buf, FALSE);
+ }
+ }
/* select account by to: and cc: header if enabled */
if (reply_autosel) {
gchar * field = NULL;
int fieldno = 0;
for (field = msginfo->to; fieldno++ < 2; field = msginfo->cc) {
if (!account && field) {
- gchar *to = NULL;
- if (!strchr(field, ',')) {
- Xstrdup_a(to, field, return NULL);
- extract_address(to);
- account = account_find_from_address(to, FALSE);
- } else {
- gchar **split = g_strsplit(field, ",", -1);
- int i = -1;
+ gchar *f = g_strdup(field);
+ if (f) {
+ gchar *cur = f;
+ gchar *next = NULL;
+ gchar *to = NULL;
do {
- i++;
- if (!split[i])
- break;
- Xstrdup_a(to, split[i], return NULL);
+ next = strchr_with_skip_quote(cur, '"', ',');
+ if (next)
+ (*next) = 0;
+ Xstrdup_a(to, cur, return NULL);
extract_address(to);
account = account_find_from_address(to, FALSE);
+ if (next)
+ cur = next + 1;
+ else
+ break;
} while (!account);
- g_strfreev(split);
+ g_free(f);
}
}
}
"activatable", TRUE,
NULL);
column = gtk_tree_view_column_new_with_attributes
- (Q_("Accounts List Get Column Name|G"), renderer,
+ (C_("Accounts List Get Column Name", "G"), renderer,
"active", ACCOUNT_ENABLE_GET_ALL,
NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(list_view), column);
if (account->sig_type == SIG_FILE) {
if (!is_file_or_fifo_exist(account->sig_path)) {
- g_warning("can't open signature file: %s\n",
+ g_warning("can't open signature file: '%s'",
account->sig_path);
return NULL;
}
{
return cur_account;
}
+
+gboolean password_get(const gchar *user,
+ const gchar *server,
+ const gchar *protocol,
+ guint16 port,
+ gchar **password)
+{
+ PasswordRequest req;
+
+ /* all have to be set */
+ cm_return_val_if_fail(user != NULL, FALSE);
+ cm_return_val_if_fail(server != NULL, FALSE);
+ cm_return_val_if_fail(protocol != NULL, FALSE);
+ cm_return_val_if_fail(port != 0, FALSE);
+
+ req.user = user;
+ req.server = server;
+ req.protocol = protocol;
+ req.port = port;
+
+ if (hooks_invoke(PASSWORD_GET_HOOKLIST, &req)) {
+ *password = req.password;
+ return TRUE;
+ }
+ return FALSE;
+}