/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2012 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 1999-2013 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
#include "manual.h"
#include "filtering.h"
#include "prefs_actions.h"
+#include "hooks.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)
+{
+ 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)
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)
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);
}
}
}
{
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;
+}