2010-01-22 [pawel] 3.7.4cvs8
[claws.git] / src / prefs_account.c
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2009 Hiroyuki Yamamoto and the Claws Mail team
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  * 
18  */
19
20 #ifdef HAVE_CONFIG_H
21 #  include "config.h"
22 #endif
23
24 #include "defs.h"
25
26 #include <glib.h>
27 #include <glib/gi18n.h>
28 #include <gtk/gtk.h>
29 #include <gdk/gdkkeysyms.h>
30 #include <gtk/filesel.h>
31 #include <stdio.h>
32 #include <sys/types.h>
33 #include <sys/stat.h>
34 #include <string.h>
35 #include <stdlib.h>
36 #include <ctype.h>
37 #include "gtkcmoptionmenu.h"
38 #include "main.h"
39 #include "prefs_gtk.h"
40 #include "prefs_account.h"
41 #include "prefs_common.h"
42 #include "prefs_customheader.h"
43 #include "account.h"
44 #include "mainwindow.h"
45 #include "manage_window.h"
46 #include "foldersel.h"
47 #include "inc.h"
48 #include "menu.h"
49 #include "gtkutils.h"
50 #include "utils.h"
51 #include "alertpanel.h"
52 #include "colorlabel.h"
53 #include "smtp.h"
54 #include "imap.h"
55 #include "remotefolder.h"
56 #include "base64.h"
57 #include "combobox.h"
58 #include "setup.h"
59 #include "quote_fmt.h"
60 #include "hooks.h"
61 #include "inputdialog.h"
62 #include "ssl_certificate.h"
63
64 static gboolean cancelled;
65 static gboolean new_account;
66
67 static PrefsAccount tmp_ac_prefs;
68
69 static GtkWidget *sigfile_radiobtn;
70 static GtkWidget *sigcmd_radiobtn;
71 static GtkWidget *entry_sigpath;
72 static GtkWidget *signature_browse_button;
73 static GtkWidget *signature_edit_button;
74
75 #ifdef USE_GNUTLS
76 static GtkWidget *entry_in_cert_file;
77 static GtkWidget *entry_out_cert_file;
78 static GtkWidget *in_ssl_cert_browse_button;
79 static GtkWidget *out_ssl_cert_browse_button;
80 #endif
81
82 static GSList *prefs_pages = NULL;
83
84 typedef struct BasicPage
85 {
86     PrefsPage page;
87
88     GtkWidget *vbox;
89
90         GtkWidget *acname_entry;
91         GtkWidget *default_checkbtn;
92
93         GtkWidget *name_entry;
94         GtkWidget *addr_entry;
95         GtkWidget *org_entry;
96
97         GtkWidget *serv_frame;
98         GtkWidget *serv_table;
99         gpointer *protocol_optmenu;
100         GtkWidget *recvserv_label;
101         GtkWidget *smtpserv_label;
102         GtkWidget *nntpserv_label;
103         GtkWidget *localmbox_label;
104         GtkWidget *mailcmd_label;
105         GtkWidget *recvserv_entry;
106         GtkWidget *smtpserv_entry;
107         GtkWidget *nntpserv_entry;
108         GtkWidget *nntpauth_checkbtn;
109         GtkWidget *nntpauth_onconnect_checkbtn;
110         GtkWidget *localmbox_entry;
111         GtkWidget *mailcmd_checkbtn;
112         GtkWidget *mailcmd_entry;
113         GtkWidget *uid_label;
114         GtkWidget *pass_label;
115         GtkWidget *uid_entry;
116         GtkWidget *pass_entry;
117 } BasicPage;
118
119 typedef struct ReceivePage
120 {
121     PrefsPage page;
122
123     GtkWidget *vbox;
124
125         GtkWidget *pop3_frame;
126         GtkWidget *use_apop_checkbtn;
127         GtkWidget *rmmail_checkbtn;
128         GtkWidget *leave_time_spinbtn;
129         GtkWidget *leave_hour_spinbtn;
130         GtkWidget *size_limit_checkbtn;
131         GtkWidget *size_limit_spinbtn;
132         GtkWidget *inbox_label;
133         GtkWidget *inbox_entry;
134         GtkWidget *inbox_btn;
135
136         GtkWidget *local_frame;
137         GtkWidget *local_inbox_label;
138         GtkWidget *local_inbox_entry;
139         GtkWidget *local_inbox_btn;
140
141         GtkWidget *filter_on_recv_checkbtn;
142         GtkWidget *filterhook_on_recv_checkbtn;
143         GtkWidget *recvatgetall_checkbtn;
144         
145         GtkWidget *imap_frame;
146         GtkWidget *imap_auth_type_optmenu;
147         GtkWidget *imapdir_label;
148         GtkWidget *imapdir_entry;
149         GtkWidget *subsonly_checkbtn;
150         GtkWidget *low_bandwidth_checkbtn;
151         GtkWidget *imap_use_trash_checkbtn;
152
153         GtkWidget *frame_maxarticle;
154         GtkWidget *maxarticle_label;
155         GtkWidget *maxarticle_spinbtn;
156         GtkObject *maxarticle_spinbtn_adj;
157 } ReceivePage;
158
159 typedef struct SendPage
160 {
161     PrefsPage page;
162
163     GtkWidget *vbox;
164
165         GtkWidget *msgid_checkbtn;
166         GtkWidget *customhdr_checkbtn;
167         GtkWidget *smtp_auth_checkbtn;
168         GtkWidget *smtp_auth_type_optmenu;
169         GtkWidget *smtp_uid_entry;
170         GtkWidget *smtp_pass_entry;
171         GtkWidget *pop_bfr_smtp_checkbtn;
172         GtkWidget *pop_bfr_smtp_tm_spinbtn;
173         GtkWidget *pop_auth_timeout_lbl;
174         GtkWidget *pop_auth_minutes_lbl;
175 } SendPage;
176
177 typedef struct ComposePage
178 {
179     PrefsPage page;
180
181     GtkWidget *vbox;
182
183         GtkWidget *sigfile_radiobtn;
184         GtkWidget *entry_sigpath;
185         GtkWidget *checkbtn_autosig;
186         GtkWidget *entry_sigsep;
187         GtkWidget *autocc_checkbtn;
188         GtkWidget *autocc_entry;
189         GtkWidget *autobcc_checkbtn;
190         GtkWidget *autobcc_entry;
191         GtkWidget *autoreplyto_checkbtn;
192         GtkWidget *autoreplyto_entry;
193 #if USE_ENCHANT
194         GtkWidget *checkbtn_enable_default_dictionary;
195         GtkWidget *combo_default_dictionary;
196         GtkWidget *checkbtn_enable_default_alt_dictionary;
197         GtkWidget *combo_default_alt_dictionary;
198 #endif
199 } ComposePage;
200
201 typedef struct TemplatesPage
202 {
203     PrefsPage page;
204
205     GtkWidget *vbox;
206
207         GtkWidget *checkbtn_compose_with_format;
208         GtkWidget *compose_subject_format;
209         GtkWidget *compose_body_format;
210         GtkWidget *checkbtn_reply_with_format;
211         GtkWidget *reply_quotemark;
212         GtkWidget *reply_body_format;
213         GtkWidget *checkbtn_forward_with_format;
214         GtkWidget *forward_quotemark;
215         GtkWidget *forward_body_format;
216 } TemplatesPage;
217
218 typedef struct PrivacyPage
219 {
220     PrefsPage page;
221
222     GtkWidget *vbox;
223
224         GtkWidget *default_privacy_system;
225         GtkWidget *default_encrypt_checkbtn;
226         GtkWidget *default_encrypt_reply_checkbtn;
227         GtkWidget *default_sign_checkbtn;
228         GtkWidget *default_sign_reply_checkbtn;
229         GtkWidget *save_clear_text_checkbtn;
230         GtkWidget *encrypt_to_self_checkbtn;
231 } PrivacyPage;
232
233 typedef struct SSLPage
234 {
235     PrefsPage page;
236
237     GtkWidget *vbox;
238
239         GtkWidget *pop_frame;
240         GtkWidget *pop_nossl_radiobtn;
241         GtkWidget *pop_ssltunnel_radiobtn;
242         GtkWidget *pop_starttls_radiobtn;
243
244         GtkWidget *imap_frame;
245         GtkWidget *imap_nossl_radiobtn;
246         GtkWidget *imap_ssltunnel_radiobtn;
247         GtkWidget *imap_starttls_radiobtn;
248
249         GtkWidget *nntp_frame;
250         GtkWidget *nntp_nossl_radiobtn;
251         GtkWidget *nntp_ssltunnel_radiobtn;
252
253         GtkWidget *send_frame;
254         GtkWidget *smtp_nossl_radiobtn;
255         GtkWidget *smtp_ssltunnel_radiobtn;
256         GtkWidget *smtp_starttls_radiobtn;
257
258         GtkWidget *entry_in_cert_file;
259         GtkWidget *entry_in_cert_pass;
260         GtkWidget *entry_out_cert_file;
261         GtkWidget *entry_out_cert_pass;
262
263         GtkWidget *use_nonblocking_ssl_checkbtn;
264 } SSLPage;
265
266 typedef struct AdvancedPage
267 {
268     PrefsPage page;
269
270     GtkWidget *vbox;
271
272         GtkWidget *smtpport_checkbtn;
273         GtkWidget *smtpport_spinbtn;
274         GtkWidget *popport_hbox;
275         GtkWidget *popport_checkbtn;
276         GtkWidget *popport_spinbtn;
277         GtkWidget *imapport_hbox;
278         GtkWidget *imapport_checkbtn;
279         GtkWidget *imapport_spinbtn;
280         GtkWidget *nntpport_hbox;
281         GtkWidget *nntpport_checkbtn;
282         GtkWidget *nntpport_spinbtn;
283         GtkWidget *domain_checkbtn;
284         GtkWidget *domain_entry;
285         GtkWidget *msgid_with_addr_checkbtn;
286         GtkWidget *crosspost_checkbtn;
287         GtkWidget *crosspost_colormenu;
288
289 #ifndef G_OS_WIN32
290         GtkWidget *tunnelcmd_checkbtn;
291         GtkWidget *tunnelcmd_entry;
292 #endif
293
294         GtkWidget *sent_folder_checkbtn;
295         GtkWidget *sent_folder_entry;
296         GtkWidget *queue_folder_checkbtn;
297         GtkWidget *queue_folder_entry;
298         GtkWidget *draft_folder_checkbtn;
299         GtkWidget *draft_folder_entry;
300         GtkWidget *trash_folder_checkbtn;
301         GtkWidget *trash_folder_entry;
302 } AdvancedPage;
303
304 static BasicPage basic_page;
305 static ReceivePage receive_page;
306 static SendPage send_page;
307 static ComposePage compose_page;
308 static TemplatesPage templates_page;
309 static PrivacyPage privacy_page;
310 #ifdef USE_GNUTLS
311 static SSLPage ssl_page;
312 #endif
313 static AdvancedPage advanced_page;
314
315 struct BasicProtocol {
316         GtkWidget *combobox;
317         GtkWidget *label;
318         GtkWidget *descrlabel;
319         GtkWidget *no_imap_warn_icon;
320         GtkWidget *no_imap_warn_label;
321 };
322
323 static char *protocol_names[] = {
324         N_("POP3"),
325         NULL,           /* APOP, deprecated */
326         NULL,           /* RPOP, deprecated */
327         N_("IMAP4"),
328         N_("News (NNTP)"),
329         N_("Local mbox file"),
330         N_("None (SMTP only)")
331 };
332
333 static void prefs_account_protocol_set_data_from_optmenu(PrefParam *pparam);
334 static void prefs_account_protocol_set_optmenu          (PrefParam *pparam);
335 static void prefs_account_protocol_changed              (GtkComboBox *combobox,
336                                                         gpointer data);
337
338 static void prefs_account_set_string_from_combobox (PrefParam *pparam);
339 static void prefs_account_set_privacy_combobox_from_string (PrefParam *pparam);
340
341 static void prefs_account_imap_auth_type_set_data_from_optmenu
342                                                         (PrefParam *pparam);
343 static void prefs_account_imap_auth_type_set_optmenu    (PrefParam *pparam);
344 static void prefs_account_smtp_auth_type_set_data_from_optmenu
345                                                         (PrefParam *pparam);
346 static void prefs_account_smtp_auth_type_set_optmenu    (PrefParam *pparam);
347
348 static void prefs_account_enum_set_data_from_radiobtn   (PrefParam *pparam);
349 static void prefs_account_enum_set_radiobtn             (PrefParam *pparam);
350
351 static void crosspost_color_toggled(void);
352 static void prefs_account_crosspost_set_data_from_colormenu(PrefParam *pparam);
353 static void prefs_account_crosspost_set_colormenu(PrefParam *pparam);
354
355 static void prefs_account_nntpauth_toggled(GtkToggleButton *button,
356                                            gpointer user_data);
357 static void prefs_account_mailcmd_toggled(GtkToggleButton *button,
358                                           gpointer user_data);
359 static void prefs_account_filter_on_recv_toggled(GtkToggleButton *button,
360                                           gpointer user_data);
361
362 #if USE_ENCHANT
363 static void prefs_account_compose_default_dictionary_set_string_from_optmenu
364                                                         (PrefParam *pparam);
365 static void prefs_account_compose_default_dictionary_set_optmenu_from_string
366                                                         (PrefParam *pparam);
367 #endif
368
369 static gchar *privacy_prefs;
370
371 static PrefParam basic_param[] = {
372         {"account_name", NULL, &tmp_ac_prefs.account_name, P_STRING,
373          &basic_page.acname_entry, prefs_set_data_from_entry, prefs_set_entry},
374
375         {"is_default", "FALSE", &tmp_ac_prefs.is_default, P_BOOL,
376          &basic_page.default_checkbtn,
377          prefs_set_data_from_toggle, prefs_set_toggle},
378
379         {"name", NULL, &tmp_ac_prefs.name, P_STRING,
380          &basic_page.name_entry, prefs_set_data_from_entry, prefs_set_entry},
381
382         {"address", NULL, &tmp_ac_prefs.address, P_STRING,
383          &basic_page.addr_entry, prefs_set_data_from_entry, prefs_set_entry},
384
385         {"organization", NULL, &tmp_ac_prefs.organization, P_STRING,
386          &basic_page.org_entry, prefs_set_data_from_entry, prefs_set_entry},
387
388         {"protocol", NULL, &tmp_ac_prefs.protocol, P_ENUM,
389          (GtkWidget **)&basic_page.protocol_optmenu,
390          prefs_account_protocol_set_data_from_optmenu,
391          prefs_account_protocol_set_optmenu},
392
393         {"receive_server", NULL, &tmp_ac_prefs.recv_server, P_STRING,
394          &basic_page.recvserv_entry, prefs_set_data_from_entry, prefs_set_entry},
395
396         {"smtp_server", NULL, &tmp_ac_prefs.smtp_server, P_STRING,
397          &basic_page.smtpserv_entry, prefs_set_data_from_entry, prefs_set_entry},
398
399         {"nntp_server", NULL, &tmp_ac_prefs.nntp_server, P_STRING,
400          &basic_page.nntpserv_entry, prefs_set_data_from_entry, prefs_set_entry},
401
402         {"local_mbox", "/var/mail", &tmp_ac_prefs.local_mbox, P_STRING,
403          &basic_page.localmbox_entry, prefs_set_data_from_entry, prefs_set_entry},
404
405         {"use_mail_command", "FALSE", &tmp_ac_prefs.use_mail_command, P_BOOL,
406          &basic_page.mailcmd_checkbtn, prefs_set_data_from_toggle, prefs_set_toggle},
407
408         {"mail_command", DEFAULT_SENDMAIL_CMD, &tmp_ac_prefs.mail_command, P_STRING,
409          &basic_page.mailcmd_entry, prefs_set_data_from_entry, prefs_set_entry},
410
411         {"use_nntp_auth", "FALSE", &tmp_ac_prefs.use_nntp_auth, P_BOOL,
412          &basic_page.nntpauth_checkbtn,
413          prefs_set_data_from_toggle, prefs_set_toggle},
414         
415         {"use_nntp_auth_onconnect", "FALSE", &tmp_ac_prefs.use_nntp_auth_onconnect, P_BOOL,
416          &basic_page.nntpauth_onconnect_checkbtn,
417          prefs_set_data_from_toggle, prefs_set_toggle},
418
419         {"user_id", "ENV_USER", &tmp_ac_prefs.userid, P_STRING,
420          &basic_page.uid_entry, prefs_set_data_from_entry, prefs_set_entry},
421
422         {"password", NULL, &tmp_ac_prefs.passwd, P_PASSWORD,
423          &basic_page.pass_entry, prefs_set_data_from_entry, prefs_set_entry},
424
425         {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
426 };
427
428 static PrefParam receive_param[] = {
429         {"use_apop_auth", "FALSE", &tmp_ac_prefs.use_apop_auth, P_BOOL,
430          &receive_page.use_apop_checkbtn,
431          prefs_set_data_from_toggle, prefs_set_toggle},
432
433         {"remove_mail", "TRUE", &tmp_ac_prefs.rmmail, P_BOOL,
434          &receive_page.rmmail_checkbtn,
435          prefs_set_data_from_toggle, prefs_set_toggle},
436
437 #ifndef GENERIC_UMPC
438         {"message_leave_time", "7", &tmp_ac_prefs.msg_leave_time, P_INT,
439          &receive_page.leave_time_spinbtn,
440          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
441 #else
442         {"message_leave_time", "30", &tmp_ac_prefs.msg_leave_time, P_INT,
443          &receive_page.leave_time_spinbtn,
444          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
445 #endif
446         {"message_leave_hour", "0", &tmp_ac_prefs.msg_leave_hour, P_INT,
447          &receive_page.leave_hour_spinbtn,
448          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
449
450         {"enable_size_limit", "FALSE", &tmp_ac_prefs.enable_size_limit, P_BOOL,
451          &receive_page.size_limit_checkbtn,
452          prefs_set_data_from_toggle, prefs_set_toggle},
453         {"size_limit", "1024", &tmp_ac_prefs.size_limit, P_INT,
454          &receive_page.size_limit_spinbtn,
455          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
456
457         {"filter_on_receive", "TRUE", &tmp_ac_prefs.filter_on_recv, P_BOOL,
458          &receive_page.filter_on_recv_checkbtn,
459          prefs_set_data_from_toggle, prefs_set_toggle},
460
461         {"filterhook_on_receive", "TRUE", &tmp_ac_prefs.filterhook_on_recv, P_BOOL,
462          &receive_page.filterhook_on_recv_checkbtn,
463          prefs_set_data_from_toggle, prefs_set_toggle},
464
465         {"imap_auth_method", "0", &tmp_ac_prefs.imap_auth_type, P_ENUM,
466          &receive_page.imap_auth_type_optmenu,
467          prefs_account_imap_auth_type_set_data_from_optmenu,
468          prefs_account_imap_auth_type_set_optmenu},
469
470         {"receive_at_get_all", "TRUE", &tmp_ac_prefs.recv_at_getall, P_BOOL,
471          &receive_page.recvatgetall_checkbtn,
472          prefs_set_data_from_toggle, prefs_set_toggle},
473
474         {"max_news_articles", "300", &tmp_ac_prefs.max_articles, P_INT,
475          &receive_page.maxarticle_spinbtn,
476          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
477
478         {"inbox", "#mh/Mailbox/inbox", &tmp_ac_prefs.inbox, P_STRING,
479          &receive_page.inbox_entry, prefs_set_data_from_entry, prefs_set_entry},
480
481         {"local_inbox", "#mh/Mailbox/inbox", &tmp_ac_prefs.local_inbox, P_STRING,
482          &receive_page.local_inbox_entry, prefs_set_data_from_entry, prefs_set_entry},
483
484         {"imap_directory", NULL, &tmp_ac_prefs.imap_dir, P_STRING,
485          &receive_page.imapdir_entry, prefs_set_data_from_entry, prefs_set_entry},
486
487         {"imap_subsonly", "TRUE", &tmp_ac_prefs.imap_subsonly, P_BOOL,
488          &receive_page.subsonly_checkbtn,
489          prefs_set_data_from_toggle, prefs_set_toggle},
490
491         {"low_bandwidth", "FALSE", &tmp_ac_prefs.low_bandwidth, P_BOOL,
492          &receive_page.low_bandwidth_checkbtn,
493          prefs_set_data_from_toggle, prefs_set_toggle},
494
495         {"imap_use_trash", "TRUE", &tmp_ac_prefs.imap_use_trash, P_BOOL,
496          &receive_page.imap_use_trash_checkbtn,
497          prefs_set_data_from_toggle, prefs_set_toggle},
498
499         {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
500 };
501
502 static PrefParam send_param[] = {
503         {"generate_msgid", "TRUE", &tmp_ac_prefs.gen_msgid, P_BOOL,
504          &send_page.msgid_checkbtn,
505          prefs_set_data_from_toggle, prefs_set_toggle},
506
507         {"add_custom_header", "FALSE", &tmp_ac_prefs.add_customhdr, P_BOOL,
508          &send_page.customhdr_checkbtn,
509          prefs_set_data_from_toggle, prefs_set_toggle},
510
511         {"use_smtp_auth", "FALSE", &tmp_ac_prefs.use_smtp_auth, P_BOOL,
512          &send_page.smtp_auth_checkbtn,
513          prefs_set_data_from_toggle, prefs_set_toggle},
514
515         {"smtp_auth_method", "0", &tmp_ac_prefs.smtp_auth_type, P_ENUM,
516          &send_page.smtp_auth_type_optmenu,
517          prefs_account_smtp_auth_type_set_data_from_optmenu,
518          prefs_account_smtp_auth_type_set_optmenu},
519
520         {"smtp_user_id", NULL, &tmp_ac_prefs.smtp_userid, P_STRING,
521          &send_page.smtp_uid_entry, prefs_set_data_from_entry, prefs_set_entry},
522         {"smtp_password", NULL, &tmp_ac_prefs.smtp_passwd, P_PASSWORD,
523          &send_page.smtp_pass_entry, prefs_set_data_from_entry, prefs_set_entry},
524
525         {"pop_before_smtp", "FALSE", &tmp_ac_prefs.pop_before_smtp, P_BOOL,
526          &send_page.pop_bfr_smtp_checkbtn,
527          prefs_set_data_from_toggle, prefs_set_toggle},
528
529         {"pop_before_smtp_timeout", "5", &tmp_ac_prefs.pop_before_smtp_timeout, P_INT,
530          &send_page.pop_bfr_smtp_tm_spinbtn,
531          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
532
533         {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
534 };
535
536 static PrefParam compose_param[] = {
537         {"signature_type", "0", &tmp_ac_prefs.sig_type, P_ENUM,
538          &compose_page.sigfile_radiobtn,
539          prefs_account_enum_set_data_from_radiobtn,
540          prefs_account_enum_set_radiobtn},
541         {"signature_path", "~" G_DIR_SEPARATOR_S DEFAULT_SIGNATURE,
542          &tmp_ac_prefs.sig_path, P_STRING, &compose_page.entry_sigpath,
543          prefs_set_data_from_entry, prefs_set_entry},
544
545         {"auto_signature", "TRUE", &tmp_ac_prefs.auto_sig, P_BOOL,
546          &compose_page.checkbtn_autosig,
547          prefs_set_data_from_toggle, prefs_set_toggle},
548          
549         {"signature_separator", "-- ", &tmp_ac_prefs.sig_sep, P_STRING,
550          &compose_page.entry_sigsep, 
551          prefs_set_data_from_entry, prefs_set_entry},
552
553         {"set_autocc", "FALSE", &tmp_ac_prefs.set_autocc, P_BOOL,
554          &compose_page.autocc_checkbtn,
555          prefs_set_data_from_toggle, prefs_set_toggle},
556
557         {"auto_cc", NULL, &tmp_ac_prefs.auto_cc, P_STRING,
558          &compose_page.autocc_entry,
559          prefs_set_data_from_entry, prefs_set_entry},
560
561         {"set_autobcc", "FALSE", &tmp_ac_prefs.set_autobcc, P_BOOL,
562          &compose_page.autobcc_checkbtn,
563          prefs_set_data_from_toggle, prefs_set_toggle},
564
565         {"auto_bcc", NULL, &tmp_ac_prefs.auto_bcc, P_STRING,
566          &compose_page.autobcc_entry,
567          prefs_set_data_from_entry, prefs_set_entry},
568
569         {"set_autoreplyto", "FALSE", &tmp_ac_prefs.set_autoreplyto, P_BOOL,
570          &compose_page.autoreplyto_checkbtn,
571          prefs_set_data_from_toggle, prefs_set_toggle},
572
573         {"auto_replyto", NULL, &tmp_ac_prefs.auto_replyto, P_STRING,
574          &compose_page.autoreplyto_entry,
575          prefs_set_data_from_entry, prefs_set_entry},
576
577 #if USE_ENCHANT
578         {"enable_default_dictionary", "", &tmp_ac_prefs.enable_default_dictionary, P_BOOL,
579          &compose_page.checkbtn_enable_default_dictionary,
580          prefs_set_data_from_toggle, prefs_set_toggle},
581
582         {"default_dictionary", NULL, &tmp_ac_prefs.default_dictionary, P_STRING,
583          &compose_page.combo_default_dictionary,
584          prefs_account_compose_default_dictionary_set_string_from_optmenu,
585          prefs_account_compose_default_dictionary_set_optmenu_from_string},
586
587         {"enable_default_alt_dictionary", "", &tmp_ac_prefs.enable_default_alt_dictionary, P_BOOL,
588          &compose_page.checkbtn_enable_default_alt_dictionary,
589          prefs_set_data_from_toggle, prefs_set_toggle},
590
591         {"default_alt_dictionary", NULL, &tmp_ac_prefs.default_alt_dictionary, P_STRING,
592          &compose_page.combo_default_alt_dictionary,
593          prefs_account_compose_default_dictionary_set_string_from_optmenu,
594          prefs_account_compose_default_dictionary_set_optmenu_from_string},
595 #else
596         {"enable_default_dictionary", "", &tmp_ac_prefs.enable_default_dictionary, P_BOOL,
597          NULL, NULL, NULL},
598
599         {"default_dictionary", NULL, &tmp_ac_prefs.default_dictionary, P_STRING,
600          NULL, NULL, NULL},
601
602         {"enable_default_alt_dictionary", "", &tmp_ac_prefs.enable_default_alt_dictionary, P_BOOL,
603          NULL, NULL, NULL},
604
605         {"default_alt_dictionary", NULL, &tmp_ac_prefs.default_alt_dictionary, P_STRING,
606          NULL, NULL, NULL},
607 #endif   
608
609         {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
610 };
611
612 static PrefParam templates_param[] = {
613         {"compose_with_format", "FALSE", &tmp_ac_prefs.compose_with_format, P_BOOL,
614          &templates_page.checkbtn_compose_with_format,
615          prefs_set_data_from_toggle, prefs_set_toggle},
616
617         {"compose_subject_format", NULL, &tmp_ac_prefs.compose_subject_format, P_STRING,
618          &templates_page.compose_subject_format,
619          prefs_set_escaped_data_from_entry, prefs_set_entry_from_escaped},
620
621         {"compose_body_format", NULL, &tmp_ac_prefs.compose_body_format, P_STRING,
622          &templates_page.compose_body_format,
623          prefs_set_escaped_data_from_text, prefs_set_text_from_escaped},
624
625         {"reply_with_format", "FALSE", &tmp_ac_prefs.reply_with_format, P_BOOL,
626          &templates_page.checkbtn_reply_with_format,
627          prefs_set_data_from_toggle, prefs_set_toggle},
628
629         {"reply_quotemark", NULL, &tmp_ac_prefs.reply_quotemark, P_STRING,
630          &templates_page.reply_quotemark,
631          prefs_set_data_from_entry, prefs_set_entry_from_escaped},
632
633         {"reply_body_format", NULL, &tmp_ac_prefs.reply_body_format, P_STRING,
634          &templates_page.reply_body_format,
635          prefs_set_escaped_data_from_text, prefs_set_text_from_escaped},
636
637         {"forward_with_format", "FALSE", &tmp_ac_prefs.forward_with_format, P_BOOL,
638          &templates_page.checkbtn_forward_with_format,
639          prefs_set_data_from_toggle, prefs_set_toggle},
640
641         {"forward_quotemark", NULL, &tmp_ac_prefs.forward_quotemark, P_STRING,
642          &templates_page.forward_quotemark,
643          prefs_set_data_from_entry, prefs_set_entry_from_escaped},
644
645         {"forward_body_format", NULL, &tmp_ac_prefs.forward_body_format, P_STRING,
646          &templates_page.forward_body_format,
647          prefs_set_escaped_data_from_text, prefs_set_text_from_escaped},
648
649         {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
650 };
651
652 static PrefParam privacy_param[] = {
653         {"default_privacy_system", "", &tmp_ac_prefs.default_privacy_system, P_STRING,
654          &privacy_page.default_privacy_system,
655          prefs_account_set_string_from_combobox,
656          prefs_account_set_privacy_combobox_from_string},
657
658         {"default_encrypt", "FALSE", &tmp_ac_prefs.default_encrypt, P_BOOL,
659          &privacy_page.default_encrypt_checkbtn,
660          prefs_set_data_from_toggle, prefs_set_toggle},
661
662         {"default_encrypt_reply", "TRUE", &tmp_ac_prefs.default_encrypt_reply, P_BOOL,
663          &privacy_page.default_encrypt_reply_checkbtn,
664          prefs_set_data_from_toggle, prefs_set_toggle},
665
666         {"default_sign", "FALSE", &tmp_ac_prefs.default_sign, P_BOOL,
667          &privacy_page.default_sign_checkbtn,
668          prefs_set_data_from_toggle, prefs_set_toggle},
669
670         {"default_sign_reply", "TRUE", &tmp_ac_prefs.default_sign_reply, P_BOOL,
671          &privacy_page.default_sign_reply_checkbtn,
672          prefs_set_data_from_toggle, prefs_set_toggle},
673
674         {"save_clear_text", "FALSE", &tmp_ac_prefs.save_encrypted_as_clear_text, P_BOOL,
675          &privacy_page.save_clear_text_checkbtn,
676          prefs_set_data_from_toggle, prefs_set_toggle},
677
678         {"encrypt_to_self", "FALSE", &tmp_ac_prefs.encrypt_to_self, P_BOOL,
679          &privacy_page.encrypt_to_self_checkbtn,
680          prefs_set_data_from_toggle, prefs_set_toggle},
681
682         {"privacy_prefs", "", &privacy_prefs, P_STRING,
683          NULL, NULL, NULL},
684
685         {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
686 };
687
688 static PrefParam ssl_param[] = {
689 #ifdef USE_GNUTLS
690         {"ssl_pop", "0", &tmp_ac_prefs.ssl_pop, P_ENUM,
691          &ssl_page.pop_nossl_radiobtn,
692          prefs_account_enum_set_data_from_radiobtn,
693          prefs_account_enum_set_radiobtn},
694
695         {"ssl_imap", "0", &tmp_ac_prefs.ssl_imap, P_ENUM,
696          &ssl_page.imap_nossl_radiobtn,
697          prefs_account_enum_set_data_from_radiobtn,
698          prefs_account_enum_set_radiobtn},
699
700         {"ssl_nntp", "0", &tmp_ac_prefs.ssl_nntp, P_ENUM,
701          &ssl_page.nntp_nossl_radiobtn,
702          prefs_account_enum_set_data_from_radiobtn,
703          prefs_account_enum_set_radiobtn},
704
705         {"ssl_smtp", "0", &tmp_ac_prefs.ssl_smtp, P_ENUM,
706          &ssl_page.smtp_nossl_radiobtn,
707          prefs_account_enum_set_data_from_radiobtn,
708          prefs_account_enum_set_radiobtn},
709
710         {"use_nonblocking_ssl", "1", &tmp_ac_prefs.use_nonblocking_ssl, P_BOOL,
711          &ssl_page.use_nonblocking_ssl_checkbtn,
712          prefs_set_data_from_toggle, prefs_set_toggle},
713
714         {"in_ssl_client_cert_file", "", &tmp_ac_prefs.in_ssl_client_cert_file, P_STRING,
715          &ssl_page.entry_in_cert_file, prefs_set_data_from_entry, prefs_set_entry},
716
717         {"in_ssl_client_cert_pass", "", &tmp_ac_prefs.in_ssl_client_cert_pass, P_PASSWORD,
718          &ssl_page.entry_in_cert_pass, prefs_set_data_from_entry, prefs_set_entry},
719
720         {"out_ssl_client_cert_file", "", &tmp_ac_prefs.out_ssl_client_cert_file, P_STRING,
721          &ssl_page.entry_out_cert_file, prefs_set_data_from_entry, prefs_set_entry},
722
723         {"out_ssl_client_cert_pass", "", &tmp_ac_prefs.out_ssl_client_cert_pass, P_PASSWORD,
724          &ssl_page.entry_out_cert_pass, prefs_set_data_from_entry, prefs_set_entry},
725 #else
726         {"ssl_pop", "0", &tmp_ac_prefs.ssl_pop, P_ENUM,
727          NULL, NULL, NULL},
728
729         {"ssl_imap", "0", &tmp_ac_prefs.ssl_imap, P_ENUM,
730          NULL, NULL, NULL},
731
732         {"ssl_nntp", "0", &tmp_ac_prefs.ssl_nntp, P_ENUM,
733          NULL, NULL, NULL},
734
735         {"ssl_smtp", "0", &tmp_ac_prefs.ssl_smtp, P_ENUM,
736          NULL, NULL, NULL},
737
738         {"in_ssl_client_cert_file", "", &tmp_ac_prefs.in_ssl_client_cert_file, P_STRING,
739          NULL, NULL, NULL},
740
741         {"in_ssl_client_cert_pass", "", &tmp_ac_prefs.in_ssl_client_cert_pass, P_PASSWORD,
742          NULL, NULL, NULL},
743
744         {"out_ssl_client_cert_file", "", &tmp_ac_prefs.out_ssl_client_cert_file, P_STRING,
745          NULL, NULL, NULL},
746
747         {"out_ssl_client_cert_pass", "", &tmp_ac_prefs.out_ssl_client_cert_pass, P_PASSWORD,
748          NULL, NULL, NULL},
749
750         {"use_nonblocking_ssl", "1", &tmp_ac_prefs.use_nonblocking_ssl, P_BOOL,
751          NULL, NULL, NULL},
752 #endif /* USE_GNUTLS */
753
754         {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
755 };
756
757 static PrefParam advanced_param[] = {
758         {"set_smtpport", "FALSE", &tmp_ac_prefs.set_smtpport, P_BOOL,
759          &advanced_page.smtpport_checkbtn,
760          prefs_set_data_from_toggle, prefs_set_toggle},
761
762         {"smtp_port", "25", &tmp_ac_prefs.smtpport, P_USHORT,
763          &advanced_page.smtpport_spinbtn,
764          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
765
766         {"set_popport", "FALSE", &tmp_ac_prefs.set_popport, P_BOOL,
767          &advanced_page.popport_checkbtn,
768          prefs_set_data_from_toggle, prefs_set_toggle},
769
770         {"pop_port", "110", &tmp_ac_prefs.popport, P_USHORT,
771          &advanced_page.popport_spinbtn,
772          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
773
774         {"set_imapport", "FALSE", &tmp_ac_prefs.set_imapport, P_BOOL,
775          &advanced_page.imapport_checkbtn,
776          prefs_set_data_from_toggle, prefs_set_toggle},
777
778         {"imap_port", "143", &tmp_ac_prefs.imapport, P_USHORT,
779          &advanced_page.imapport_spinbtn,
780          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
781
782         {"set_nntpport", "FALSE", &tmp_ac_prefs.set_nntpport, P_BOOL,
783          &advanced_page.nntpport_checkbtn,
784          prefs_set_data_from_toggle, prefs_set_toggle},
785
786         {"nntp_port", "119", &tmp_ac_prefs.nntpport, P_USHORT,
787          &advanced_page.nntpport_spinbtn,
788          prefs_set_data_from_spinbtn, prefs_set_spinbtn},
789
790         {"set_domain", "FALSE", &tmp_ac_prefs.set_domain, P_BOOL,
791          &advanced_page.domain_checkbtn,
792          prefs_set_data_from_toggle, prefs_set_toggle},
793
794         {"domain", NULL, &tmp_ac_prefs.domain, P_STRING,
795          &advanced_page.domain_entry,
796          prefs_set_data_from_entry, prefs_set_entry},
797
798         {"msgid_with_addr", "FALSE", &tmp_ac_prefs.msgid_with_addr, P_BOOL,
799          &advanced_page.msgid_with_addr_checkbtn,
800          prefs_set_data_from_toggle, prefs_set_toggle},
801 #ifndef G_OS_WIN32
802         {"set_tunnelcmd", "FALSE", &tmp_ac_prefs.set_tunnelcmd, P_BOOL,
803          &advanced_page.tunnelcmd_checkbtn,
804          prefs_set_data_from_toggle, prefs_set_toggle},
805
806         {"tunnelcmd", NULL, &tmp_ac_prefs.tunnelcmd, P_STRING,
807          &advanced_page.tunnelcmd_entry,
808          prefs_set_data_from_entry, prefs_set_entry},
809 #endif
810         {"mark_crosspost_read", "FALSE", &tmp_ac_prefs.mark_crosspost_read, P_BOOL,
811          &advanced_page.crosspost_checkbtn,
812          prefs_set_data_from_toggle, prefs_set_toggle},
813
814         {"crosspost_color", NULL, &tmp_ac_prefs.crosspost_col, P_ENUM,
815          &advanced_page.crosspost_colormenu,
816          prefs_account_crosspost_set_data_from_colormenu,
817          prefs_account_crosspost_set_colormenu},
818
819         {"set_sent_folder", "FALSE", &tmp_ac_prefs.set_sent_folder, P_BOOL,
820          &advanced_page.sent_folder_checkbtn,
821          prefs_set_data_from_toggle, prefs_set_toggle},
822         {"sent_folder", NULL, &tmp_ac_prefs.sent_folder, P_STRING,
823          &advanced_page.sent_folder_entry,
824          prefs_set_data_from_entry, prefs_set_entry},
825
826         {"set_queue_folder", "FALSE", &tmp_ac_prefs.set_queue_folder, P_BOOL,
827          &advanced_page.queue_folder_checkbtn,
828          prefs_set_data_from_toggle, prefs_set_toggle},
829         {"queue_folder", NULL, &tmp_ac_prefs.queue_folder, P_STRING,
830          &advanced_page.queue_folder_entry,
831          prefs_set_data_from_entry, prefs_set_entry},
832
833         {"set_draft_folder", "FALSE", &tmp_ac_prefs.set_draft_folder, P_BOOL,
834          &advanced_page.draft_folder_checkbtn,
835          prefs_set_data_from_toggle, prefs_set_toggle},
836         {"draft_folder", NULL, &tmp_ac_prefs.draft_folder, P_STRING,
837          &advanced_page.draft_folder_entry,
838          prefs_set_data_from_entry, prefs_set_entry},
839
840         {"set_trash_folder", "FALSE", &tmp_ac_prefs.set_trash_folder, P_BOOL,
841          &advanced_page.trash_folder_checkbtn,
842          prefs_set_data_from_toggle, prefs_set_toggle},
843         {"trash_folder", NULL, &tmp_ac_prefs.trash_folder, P_STRING,
844          &advanced_page.trash_folder_entry,
845          prefs_set_data_from_entry, prefs_set_entry},
846
847         {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
848 };
849
850 static gint prefs_account_get_new_id            (void);
851
852 static void prefs_account_select_folder_cb      (GtkWidget      *widget,
853                                                  gpointer        data);
854
855 static void prefs_account_sigfile_radiobtn_cb   (GtkWidget      *widget,
856                                                  gpointer        data);
857
858 static void prefs_account_sigcmd_radiobtn_cb    (GtkWidget      *widget,
859                                                  gpointer        data);
860
861 static void prefs_account_signature_browse_cb   (GtkWidget      *widget,
862                                                  gpointer        data);
863 #ifdef USE_GNUTLS
864 static void prefs_account_in_cert_browse_cb     (GtkWidget      *widget,
865                                                  gpointer        data);
866
867 static void prefs_account_out_cert_browse_cb    (GtkWidget      *widget,
868                                                  gpointer        data);
869 #endif
870 static void prefs_account_signature_edit_cb     (GtkWidget      *widget,
871                                                  gpointer        data);
872
873 static void pop_bfr_smtp_tm_set_sens            (GtkWidget      *widget,
874                                                  gpointer        data);
875
876 static void prefs_account_edit_custom_header    (void);
877
878
879 #define COMBOBOX_PRIVACY_PLUGIN_ID 3
880
881 /* Enable/disable necessary preference widgets based on current privacy
882  * system choice. */
883 static void privacy_system_activated(GtkWidget *combobox)
884 {
885         const gchar *system_id;
886         gboolean privacy_enabled = FALSE;
887         gint privacy_enabled_int;
888         GtkTreeIter iter;
889         GtkListStore *menu = GTK_LIST_STORE(gtk_combo_box_get_model(
890                                 GTK_COMBO_BOX(combobox)));
891
892         gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combobox), &iter);
893
894         gtk_tree_model_get(GTK_TREE_MODEL(menu), &iter,
895                         COMBOBOX_PRIVACY_PLUGIN_ID, &system_id,
896                         COMBOBOX_DATA, &privacy_enabled_int,
897                         -1);
898         
899         privacy_enabled = strcmp(system_id, "");
900
901         if( privacy_enabled_int == 0 )
902                 privacy_enabled = FALSE;
903
904         gtk_widget_set_sensitive (privacy_page.save_clear_text_checkbtn, 
905                 !gtk_toggle_button_get_active(
906                                 GTK_TOGGLE_BUTTON(privacy_page.encrypt_to_self_checkbtn)));
907 }
908
909 /* Populate the privacy system choice combobox with valid choices */
910 static void update_privacy_system_menu() {
911         GtkListStore *menu;
912         GtkTreeIter iter;
913         GSList *system_ids, *cur;
914
915         menu = GTK_LIST_STORE(gtk_combo_box_get_model(
916                         GTK_COMBO_BOX(privacy_page.default_privacy_system)));
917
918         /* First add "None", as that one is always available. :) */
919         gtk_list_store_append(menu, &iter);
920         gtk_list_store_set(menu, &iter,
921                         COMBOBOX_TEXT, _("None"),
922                         COMBOBOX_DATA, 0,
923                         COMBOBOX_SENS, TRUE,
924                         COMBOBOX_PRIVACY_PLUGIN_ID, "",
925                         -1);
926
927         /* Now go through list of available privacy systems and add an entry
928          * for each. */
929         system_ids = privacy_get_system_ids();
930         for (cur = system_ids; cur != NULL; cur = g_slist_next(cur)) {
931                 gchar *id = (gchar *) cur->data;
932                 const gchar *name;
933                 
934                 name = privacy_system_get_name(id);
935                 gtk_list_store_append(menu, &iter);
936                 gtk_list_store_set(menu, &iter,
937                                 COMBOBOX_TEXT, name,
938                                 COMBOBOX_DATA, 1,
939                                 COMBOBOX_SENS, TRUE,
940                                 COMBOBOX_PRIVACY_PLUGIN_ID, id,
941                                 -1);
942         }
943 }
944
945 #define TABLE_YPAD 2
946
947 static void basic_create_widget_func(PrefsPage * _page,
948                                            GtkWindow * window,
949                                            gpointer data)
950 {
951         BasicPage *page = (BasicPage *) _page;
952         PrefsAccount *ac_prefs = (PrefsAccount *) data;
953
954         GtkWidget *vbox1;
955         GtkWidget *hbox;
956         GtkWidget *label;
957         GtkWidget *acname_entry;
958         GtkWidget *default_checkbtn;
959         GtkWidget *frame1;
960         GtkWidget *table1;
961         GtkWidget *name_entry;
962         GtkWidget *addr_entry;
963         GtkWidget *org_entry;
964
965         GtkWidget *serv_frame;
966         GtkWidget *vbox2;
967         GtkWidget *optmenubox;
968         GtkWidget *optmenu;
969         GtkWidget *optlabel;
970         GtkWidget *no_imap_warn_icon;
971         GtkWidget *no_imap_warn_label;
972         GtkWidget *serv_table;
973         GtkWidget *recvserv_label;
974         GtkWidget *smtpserv_label;
975         GtkWidget *nntpserv_label;
976         GtkWidget *localmbox_label;
977         GtkWidget *mailcmd_label;
978         GtkWidget *recvserv_entry;
979         GtkWidget *smtpserv_entry;
980         GtkWidget *nntpserv_entry;
981         GtkWidget *nntpauth_checkbtn;
982         GtkWidget *nntpauth_onconnect_checkbtn;
983         GtkWidget *localmbox_entry;
984         GtkWidget *mailcmd_checkbtn;
985         GtkWidget *mailcmd_entry;
986         GtkWidget *uid_label;
987         GtkWidget *pass_label;
988         GtkWidget *uid_entry;
989         GtkWidget *pass_entry;
990         GtkListStore *menu;
991         GtkTreeIter iter;
992
993         struct BasicProtocol *protocol_optmenu;
994         gint i;
995
996         vbox1 = gtk_vbox_new (FALSE, VSPACING);
997         gtk_widget_show (vbox1);
998         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
999
1000         hbox = gtk_hbox_new (FALSE, 8);
1001         gtk_widget_show (hbox);
1002         gtk_box_pack_start (GTK_BOX (vbox1), hbox, FALSE, FALSE, 0);
1003
1004         label = gtk_label_new (_("Name of account"));
1005         gtk_widget_show (label);
1006         gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1007
1008         acname_entry = gtk_entry_new ();
1009         gtk_widget_show (acname_entry);
1010         gtk_widget_set_size_request (acname_entry, DEFAULT_ENTRY_WIDTH, -1);
1011         gtk_box_pack_start (GTK_BOX (hbox), acname_entry, TRUE, TRUE, 0);
1012
1013         default_checkbtn = gtk_check_button_new_with_label (_("Set as default"));
1014         gtk_widget_show (default_checkbtn);
1015 #ifndef GENERIC_UMPC
1016         gtk_box_pack_end (GTK_BOX (hbox), default_checkbtn, TRUE, FALSE, 0);
1017 #else
1018         gtk_box_pack_start (GTK_BOX (vbox1), default_checkbtn, FALSE, FALSE, 0);
1019         
1020 #endif
1021         PACK_FRAME (vbox1, frame1, _("Personal information"));
1022
1023         table1 = gtk_table_new (3, 2, FALSE);
1024         gtk_widget_show (table1);
1025         gtk_container_add (GTK_CONTAINER (frame1), table1);
1026         gtk_container_set_border_width (GTK_CONTAINER (table1), 8);
1027         gtk_table_set_row_spacings (GTK_TABLE (table1), VSPACING_NARROW);
1028         gtk_table_set_col_spacings (GTK_TABLE (table1), 8);
1029
1030         label = gtk_label_new (_("Full name"));
1031         gtk_widget_show (label);
1032         gtk_table_attach (GTK_TABLE (table1), label, 0, 1, 0, 1,
1033                           GTK_FILL, 0, 0, 0);
1034         gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
1035
1036         label = gtk_label_new (_("Mail address"));
1037         gtk_widget_show (label);
1038         gtk_table_attach (GTK_TABLE (table1), label, 0, 1, 1, 2,
1039                           GTK_FILL, 0, 0, 0);
1040         gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
1041
1042         label = gtk_label_new (_("Organization"));
1043         gtk_widget_show (label);
1044         gtk_table_attach (GTK_TABLE (table1), label, 0, 1, 2, 3,
1045                           GTK_FILL, 0, 0, 0);
1046         gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
1047
1048         name_entry = gtk_entry_new ();
1049         gtk_widget_show (name_entry);
1050         gtk_table_attach (GTK_TABLE (table1), name_entry, 1, 2, 0, 1,
1051                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1052                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1053
1054         addr_entry = gtk_entry_new ();
1055         gtk_widget_show (addr_entry);
1056         gtk_table_attach (GTK_TABLE (table1), addr_entry, 1, 2, 1, 2,
1057                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1058                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1059
1060         org_entry = gtk_entry_new ();
1061         gtk_widget_show (org_entry);
1062         gtk_table_attach (GTK_TABLE (table1), org_entry, 1, 2, 2, 3,
1063                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1064                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1065
1066         vbox2 = gtkut_get_options_frame(vbox1, &serv_frame, _("Server information"));
1067
1068         hbox = gtk_hbox_new (FALSE, 8);
1069         gtk_widget_show (hbox);
1070         gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
1071
1072         label = gtk_label_new (_("Protocol"));
1073         gtk_widget_show (label);
1074         gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1075
1076         /* Create GtkHBox for protocol combobox and label */
1077         optmenubox = gtk_hbox_new(FALSE, 20);
1078         gtk_widget_show(optmenubox);
1079         gtk_box_pack_start (GTK_BOX (hbox), optmenubox, FALSE, FALSE, 0);
1080
1081         /* Create and populate the combobox */
1082         optmenu = gtkut_sc_combobox_create(NULL, FALSE);
1083         gtk_box_pack_start(GTK_BOX (optmenubox), optmenu, FALSE, FALSE, 0);
1084
1085         menu = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(optmenu)));
1086         for( i = 0; i < NUM_RECV_PROTOCOLS; i++ )
1087                 if( protocol_names[i] != NULL )
1088                         COMBOBOX_ADD (menu, _(protocol_names[i]), i);
1089
1090         g_signal_connect(G_OBJECT(optmenu), "changed",
1091                         G_CALLBACK(prefs_account_protocol_changed), NULL);
1092
1093         /* Create protocol label, empty for now */
1094         optlabel = gtk_label_new("");
1095         gtk_label_set_use_markup(GTK_LABEL(optlabel), TRUE);
1096         gtk_label_set_justify(GTK_LABEL(optlabel), GTK_JUSTIFY_CENTER);
1097         gtk_box_pack_start(GTK_BOX (optmenubox), optlabel, FALSE, FALSE, 0);
1098
1099         no_imap_warn_icon = gtk_image_new_from_stock
1100                         (GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_SMALL_TOOLBAR);
1101         no_imap_warn_label = gtk_label_new(_("<span weight=\"bold\">Warning: this version of Claws Mail\n"
1102                           "has been built without IMAP and News support.</span>"));
1103         gtk_label_set_use_markup(GTK_LABEL(no_imap_warn_label), TRUE);
1104
1105         gtk_box_pack_start(GTK_BOX (optmenubox), no_imap_warn_icon, FALSE, FALSE, 0);
1106         gtk_box_pack_start(GTK_BOX (optmenubox), no_imap_warn_label, FALSE, FALSE, 0);
1107         /* Set up a struct to store pointers to necessary widgets */
1108         protocol_optmenu = g_new(struct BasicProtocol, 1);
1109         protocol_optmenu->combobox = optmenu;
1110         protocol_optmenu->label = optlabel;
1111         protocol_optmenu->descrlabel = label;
1112         protocol_optmenu->no_imap_warn_icon = no_imap_warn_icon;
1113         protocol_optmenu->no_imap_warn_label = no_imap_warn_label;
1114
1115         serv_table = gtk_table_new (6, 4, FALSE);
1116         gtk_widget_show (serv_table);
1117         gtk_box_pack_start (GTK_BOX (vbox2), serv_table, FALSE, FALSE, 0);
1118         gtk_table_set_row_spacings (GTK_TABLE (serv_table), VSPACING_NARROW);
1119         gtk_table_set_row_spacing (GTK_TABLE (serv_table), 3, 0);
1120         gtk_table_set_col_spacings (GTK_TABLE (serv_table), 8);
1121
1122         nntpserv_entry = gtk_entry_new ();
1123         gtk_widget_show (nntpserv_entry);
1124         gtk_table_attach (GTK_TABLE (serv_table), nntpserv_entry, 1, 4, 0, 1,
1125                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1126                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1127 /*      gtk_table_set_row_spacing (GTK_TABLE (serv_table), 0, 0); */
1128
1129         nntpauth_checkbtn = gtk_check_button_new_with_label
1130                 (_("This server requires authentication"));
1131         gtk_widget_show (nntpauth_checkbtn);
1132         
1133         gtk_table_attach (GTK_TABLE (serv_table), nntpauth_checkbtn, 0, 2, 6, 7,
1134                           GTK_FILL, 0, 0, 0);
1135
1136         nntpauth_onconnect_checkbtn = gtk_check_button_new_with_label
1137                 (_("Authenticate on connect"));
1138         gtk_widget_show (nntpauth_onconnect_checkbtn);
1139
1140         gtk_table_attach (GTK_TABLE (serv_table), nntpauth_onconnect_checkbtn, 2, 4, 6, 7,
1141                           GTK_FILL, 0, 0, 0);
1142
1143         recvserv_entry = gtk_entry_new ();
1144         gtk_widget_show (recvserv_entry);
1145         gtk_table_attach (GTK_TABLE (serv_table), recvserv_entry, 1, 4, 2, 3,
1146                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1147                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1148
1149         localmbox_entry = gtk_entry_new ();
1150         gtk_widget_show (localmbox_entry);
1151         gtk_table_attach (GTK_TABLE (serv_table), localmbox_entry, 1, 4, 3, 4,
1152                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1153                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1154
1155         smtpserv_entry = gtk_entry_new ();
1156         gtk_widget_show (smtpserv_entry);
1157         gtk_table_attach (GTK_TABLE (serv_table), smtpserv_entry, 1, 4, 4, 5,
1158                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1159                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1160
1161         mailcmd_entry = gtk_entry_new ();
1162         gtk_widget_show (mailcmd_entry);
1163         gtk_table_attach (GTK_TABLE (serv_table), mailcmd_entry, 1, 4, 6, 7,
1164                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1165                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1166
1167         uid_entry = gtk_entry_new ();
1168         gtk_widget_show (uid_entry);
1169         gtk_widget_set_size_request (uid_entry, DEFAULT_ENTRY_WIDTH, -1);
1170         pass_entry = gtk_entry_new ();
1171         gtk_widget_show (pass_entry);
1172         gtk_widget_set_size_request (pass_entry, DEFAULT_ENTRY_WIDTH, -1);
1173 #ifndef GENERIC_UMPC
1174         gtk_table_attach (GTK_TABLE (serv_table), uid_entry, 1, 2, 7, 8,
1175                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1176                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1177
1178         gtk_table_attach (GTK_TABLE (serv_table), pass_entry, 3, 4, 7, 8,
1179                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1180                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1181 #else
1182         gtk_table_attach (GTK_TABLE (serv_table), uid_entry, 1, 4, 7, 8,
1183                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1184                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1185         gtk_table_attach (GTK_TABLE (serv_table), pass_entry, 1, 4, 8, 9,
1186                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1187                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1188 #endif
1189         gtk_entry_set_visibility (GTK_ENTRY (pass_entry), FALSE);
1190 #ifdef MAEMO
1191         hildon_gtk_entry_set_input_mode(GTK_ENTRY(pass_entry), 
1192                 HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
1193 #endif
1194
1195         nntpserv_label = gtk_label_new (_("News server"));
1196         gtk_widget_show (nntpserv_label);
1197         gtk_table_attach (GTK_TABLE (serv_table), nntpserv_label, 0, 1, 0, 1,
1198                           GTK_FILL, 0, 0, 0);
1199         gtk_misc_set_alignment (GTK_MISC (nntpserv_label), 1, 0.5);
1200
1201         recvserv_label = gtk_label_new (_("Server for receiving"));
1202         gtk_widget_show (recvserv_label);
1203         gtk_table_attach (GTK_TABLE (serv_table), recvserv_label, 0, 1, 2, 3,
1204                           GTK_FILL, 0, 0, 0);
1205         gtk_misc_set_alignment (GTK_MISC (recvserv_label), 1, 0.5);
1206
1207         localmbox_label = gtk_label_new (_("Local mailbox"));
1208         gtk_widget_show (localmbox_label);
1209         gtk_table_attach (GTK_TABLE (serv_table), localmbox_label, 0, 1, 3, 4,
1210                           GTK_FILL, 0, 0, 0);
1211         gtk_misc_set_alignment (GTK_MISC (localmbox_label), 1, 0.5);
1212 /*      gtk_table_set_row_spacing (GTK_TABLE (serv_table), 2, 0); */
1213
1214         smtpserv_label = gtk_label_new (_("SMTP server (send)"));
1215         gtk_widget_show (smtpserv_label);
1216         gtk_table_attach (GTK_TABLE (serv_table), smtpserv_label, 0, 1, 4, 5,
1217                           GTK_FILL, 0, 0, 0);
1218         gtk_misc_set_alignment (GTK_MISC (smtpserv_label), 1, 0.5);
1219 /*      gtk_table_set_row_spacing (GTK_TABLE (serv_table), 2, 0); */
1220
1221         mailcmd_checkbtn = gtk_check_button_new_with_label
1222                 (_("Use mail command rather than SMTP server"));
1223         gtk_widget_show (mailcmd_checkbtn);
1224         gtk_table_attach (GTK_TABLE (serv_table), mailcmd_checkbtn, 0, 4, 5, 6,
1225                           GTK_EXPAND | GTK_FILL,
1226                           0, 0, TABLE_YPAD);
1227         g_signal_connect(G_OBJECT(mailcmd_checkbtn), "toggled",
1228                          G_CALLBACK(prefs_account_mailcmd_toggled),
1229                          NULL);
1230
1231         mailcmd_label = gtk_label_new (_("command to send mails"));
1232         gtk_widget_show (mailcmd_label);
1233         gtk_table_attach (GTK_TABLE (serv_table), mailcmd_label, 0, 1, 6, 7,
1234                           GTK_FILL, 0, 0, 0);
1235         gtk_misc_set_alignment (GTK_MISC (mailcmd_label), 1, 0.5);
1236 /*      gtk_table_set_row_spacing (GTK_TABLE (serv_table), 2, 0); */
1237
1238         uid_label = gtk_label_new (_("User ID"));
1239         gtk_widget_show (uid_label);
1240         gtk_table_attach (GTK_TABLE (serv_table), uid_label, 0, 1, 7, 8,
1241                           GTK_FILL, 0, 0, 0);
1242         gtk_misc_set_alignment (GTK_MISC (uid_label), 1, 0.5);
1243
1244         pass_label = gtk_label_new (_("Password"));
1245         gtk_widget_show (pass_label);
1246 #ifndef GENERIC_UMPC
1247         gtk_table_attach (GTK_TABLE (serv_table), pass_label, 2, 3, 7, 8,
1248                           0, 0, 0, 0);
1249 #else
1250         gtk_misc_set_alignment (GTK_MISC (pass_label), 1, 0.5);
1251         gtk_table_attach (GTK_TABLE (serv_table), pass_label, 0, 1, 8, 9,
1252                           GTK_FILL, 0, 0, 0);
1253 #endif
1254         SET_TOGGLE_SENSITIVITY (nntpauth_checkbtn, uid_label);
1255         SET_TOGGLE_SENSITIVITY (nntpauth_checkbtn, pass_label);
1256         SET_TOGGLE_SENSITIVITY (nntpauth_checkbtn, uid_entry);
1257         SET_TOGGLE_SENSITIVITY (nntpauth_checkbtn, pass_entry);
1258         SET_TOGGLE_SENSITIVITY (nntpauth_checkbtn, nntpauth_onconnect_checkbtn);
1259
1260         page->acname_entry   = acname_entry;
1261         page->default_checkbtn = default_checkbtn;
1262
1263         page->name_entry = name_entry;
1264         page->addr_entry = addr_entry;
1265         page->org_entry  = org_entry;
1266
1267         page->serv_frame       = serv_frame;
1268         page->serv_table       = serv_table;
1269         page->protocol_optmenu = (gpointer)protocol_optmenu;
1270         page->recvserv_label   = recvserv_label;
1271         page->recvserv_entry   = recvserv_entry;
1272         page->smtpserv_label   = smtpserv_label;
1273         page->smtpserv_entry   = smtpserv_entry;
1274         page->nntpserv_label   = nntpserv_label;
1275         page->nntpserv_entry   = nntpserv_entry;
1276         page->nntpauth_checkbtn  = nntpauth_checkbtn;
1277         page->nntpauth_onconnect_checkbtn  = nntpauth_onconnect_checkbtn;
1278         page->localmbox_label   = localmbox_label;
1279         page->localmbox_entry   = localmbox_entry;
1280         page->mailcmd_checkbtn   = mailcmd_checkbtn;
1281         page->mailcmd_label   = mailcmd_label;
1282         page->mailcmd_entry   = mailcmd_entry;
1283         page->uid_label        = uid_label;
1284         page->pass_label       = pass_label;
1285         page->uid_entry        = uid_entry;
1286         page->pass_entry       = pass_entry;
1287
1288         if (new_account) {
1289                 PrefsAccount *def_ac;
1290                 gchar *buf;
1291
1292                 prefs_set_dialog_to_default(basic_param);
1293                 buf = g_strdup_printf(_("Account%d"), ac_prefs->account_id);
1294                 gtk_entry_set_text(GTK_ENTRY(basic_page.acname_entry), buf);
1295                 g_free(buf);
1296                 def_ac = account_get_default();
1297                 if (def_ac) {
1298                         FolderItem *item = folder_get_default_inbox_for_class(F_MH);
1299                         gtk_entry_set_text(GTK_ENTRY(basic_page.name_entry),
1300                                            def_ac->name ? def_ac->name : "");
1301                         gtk_entry_set_text(GTK_ENTRY(basic_page.addr_entry),
1302                                            def_ac->address ? def_ac->address : "");
1303                         gtk_entry_set_text(GTK_ENTRY(basic_page.org_entry),
1304                                            def_ac->organization ? def_ac->organization : "");
1305                         if (!item) {
1306                                 item = folder_get_default_inbox();
1307                         }
1308                         if (item) {
1309                                 gchar *id = folder_item_get_identifier(item);
1310                                 gtk_entry_set_text(GTK_ENTRY(receive_page.inbox_entry),
1311                                         id);
1312                                 gtk_entry_set_text(GTK_ENTRY(receive_page.local_inbox_entry),
1313                                         id);
1314                                 g_free(id);
1315                         }
1316                 }
1317         } else
1318                 prefs_set_dialog(basic_param);
1319
1320         page->vbox = vbox1;
1321
1322         page->page.widget = vbox1;
1323 }
1324
1325 static void receive_create_widget_func(PrefsPage * _page,
1326                                            GtkWindow * window,
1327                                            gpointer data)
1328 {
1329         ReceivePage *page = (ReceivePage *) _page;
1330         PrefsAccount *ac_prefs = (PrefsAccount *) data;
1331
1332         GtkWidget *vbox1;
1333         GtkWidget *frame1;
1334         GtkWidget *vbox2;
1335         GtkWidget *use_apop_checkbtn;
1336         GtkWidget *rmmail_checkbtn;
1337         GtkWidget *hbox_spc;
1338         GtkWidget *leave_time_label;
1339         GtkWidget *leave_time_spinbtn;
1340         GtkWidget *leave_hour_label;
1341         GtkWidget *leave_hour_spinbtn;
1342         GtkWidget *hbox1;
1343         GtkWidget *size_limit_checkbtn;
1344         GtkWidget *size_limit_spinbtn;
1345         GtkWidget *label;
1346         GtkWidget *filter_on_recv_checkbtn;
1347         GtkWidget *filterhook_on_recv_checkbtn;
1348         GtkWidget *vbox3;
1349         GtkWidget *inbox_label;
1350         GtkWidget *inbox_entry;
1351         GtkWidget *inbox_btn;
1352         GtkWidget *imap_frame;
1353         GtkWidget *imapdir_label;
1354         GtkWidget *imapdir_entry;
1355         GtkWidget *subsonly_checkbtn;
1356         GtkWidget *low_bandwidth_checkbtn;
1357         GtkWidget *imap_use_trash_checkbtn;
1358         GtkWidget *local_frame;
1359         GtkWidget *local_vbox;
1360         GtkWidget *local_hbox;
1361         GtkWidget *local_inbox_label;
1362         GtkWidget *local_inbox_entry;
1363         GtkWidget *local_inbox_btn;
1364
1365         GtkWidget *optmenu;
1366         GtkListStore *menu;
1367         GtkTreeIter iter;
1368         GtkWidget *recvatgetall_checkbtn;
1369
1370         GtkWidget *hbox2;
1371         GtkWidget *frame2;
1372         GtkWidget *maxarticle_label;
1373         GtkWidget *maxarticle_spinbtn;
1374         GtkObject *maxarticle_spinbtn_adj;
1375         CLAWS_TIP_DECL();
1376
1377         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1378         gtk_widget_show (vbox1);
1379         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1380
1381         local_vbox = gtkut_get_options_frame(vbox1, &local_frame, _("Local"));
1382
1383         local_hbox = gtk_hbox_new (FALSE, 8);
1384         gtk_widget_show (local_hbox);
1385         gtk_box_pack_start (GTK_BOX (local_vbox), local_hbox, FALSE, FALSE, 0);
1386
1387         local_inbox_label = gtk_label_new (_("Default Inbox"));
1388         gtk_widget_show (local_inbox_label);
1389         gtk_box_pack_start (GTK_BOX (local_hbox), local_inbox_label, FALSE, FALSE, 0);
1390
1391         local_inbox_entry = gtk_entry_new ();
1392         gtk_widget_show (local_inbox_entry);
1393         CLAWS_SET_TIP(local_inbox_entry,
1394                              _("Unfiltered messages will be stored in this folder"));
1395         gtk_widget_set_size_request (local_inbox_entry, DEFAULT_ENTRY_WIDTH, -1);
1396         gtk_box_pack_start (GTK_BOX (local_hbox), local_inbox_entry, TRUE, TRUE, 0);
1397
1398         local_inbox_btn = gtkut_get_browse_file_btn(_("Bro_wse"));
1399         gtk_widget_show (local_inbox_btn);
1400         CLAWS_SET_TIP(local_inbox_btn,
1401                              _("Unfiltered messages will be stored in this folder"));
1402         gtk_box_pack_start (GTK_BOX (local_hbox), local_inbox_btn, FALSE, FALSE, 0);
1403         g_signal_connect (G_OBJECT (local_inbox_btn), "clicked",
1404                           G_CALLBACK (prefs_account_select_folder_cb),
1405                           local_inbox_entry);
1406
1407         vbox2 = gtkut_get_options_frame(vbox1, &frame1, _("POP3"));
1408         PACK_CHECK_BUTTON (vbox2, use_apop_checkbtn,
1409                            _("Use secure authentication (APOP)"));
1410
1411         PACK_CHECK_BUTTON (vbox2, rmmail_checkbtn,
1412                            _("Remove messages on server when received"));
1413
1414         hbox1 = gtk_hbox_new (FALSE, 8);
1415         gtk_widget_show (hbox1);
1416         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
1417
1418         hbox_spc = gtk_hbox_new (FALSE, 0);
1419         gtk_widget_show (hbox_spc);
1420         gtk_box_pack_start (GTK_BOX (hbox1), hbox_spc, FALSE, FALSE, 0);
1421         gtk_widget_set_size_request (hbox_spc, 12, -1);
1422
1423         leave_time_label = gtk_label_new (_("Remove after"));
1424         gtk_widget_show (leave_time_label);
1425         gtk_box_pack_start (GTK_BOX (hbox1), leave_time_label, FALSE, FALSE, 0);
1426
1427         leave_time_spinbtn = gtk_spin_button_new_with_range(0, 365, 1);
1428         gtk_widget_show (leave_time_spinbtn);
1429         CLAWS_SET_TIP(leave_time_spinbtn,
1430                              _("0 days and 0 hours : remove immediately"));
1431         gtk_box_pack_start (GTK_BOX (hbox1), leave_time_spinbtn, FALSE, FALSE, 0);
1432
1433         leave_time_label = gtk_label_new (_("days"));
1434         gtk_widget_show (leave_time_label);
1435         gtk_box_pack_start (GTK_BOX (hbox1), leave_time_label, FALSE, FALSE, 0);
1436
1437         leave_hour_spinbtn = gtk_spin_button_new_with_range(0, 23, 1);
1438         gtk_widget_show (leave_hour_spinbtn);
1439         CLAWS_SET_TIP(leave_hour_spinbtn,
1440                              _("0 days and 0 hours : remove immediately"));
1441         gtk_box_pack_start (GTK_BOX (hbox1), leave_hour_spinbtn, FALSE, FALSE, 0);
1442
1443         leave_hour_label = gtk_label_new (_("hours"));
1444         gtk_widget_show (leave_hour_label);
1445         gtk_box_pack_start (GTK_BOX (hbox1), leave_hour_label, FALSE, FALSE, 0);
1446
1447         SET_TOGGLE_SENSITIVITY (rmmail_checkbtn, hbox1);
1448
1449         hbox1 = gtk_hbox_new (FALSE, 8);
1450         gtk_widget_show (hbox1);
1451         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
1452
1453         PACK_CHECK_BUTTON (hbox1, size_limit_checkbtn, _("Receive size limit"));
1454
1455         CLAWS_SET_TIP(size_limit_checkbtn,
1456                              _("Messages over this limit will be partially retrieved. "
1457                                "When selecting them you will be able to download them fully "
1458                                "or delete them."));
1459
1460         size_limit_spinbtn = gtk_spin_button_new_with_range(0, 100000, 1);
1461         gtk_widget_show (size_limit_spinbtn);
1462         gtk_box_pack_start (GTK_BOX (hbox1), size_limit_spinbtn, FALSE, FALSE, 0);
1463
1464         label = gtk_label_new (_("KB"));
1465         gtk_widget_show (label);
1466         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
1467
1468         SET_TOGGLE_SENSITIVITY (size_limit_checkbtn, size_limit_spinbtn);
1469
1470         PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1471
1472         hbox1 = gtk_hbox_new (FALSE, 8);
1473         gtk_widget_show (hbox1);
1474         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
1475
1476         inbox_label = gtk_label_new (_("Default Inbox"));
1477         gtk_widget_show (inbox_label);
1478         gtk_box_pack_start (GTK_BOX (hbox1), inbox_label, FALSE, FALSE, 0);
1479
1480         inbox_entry = gtk_entry_new ();
1481         gtk_widget_show (inbox_entry);
1482         CLAWS_SET_TIP(inbox_entry,
1483                              _("Unfiltered messages will be stored in this folder"));
1484         gtk_widget_set_size_request (inbox_entry, DEFAULT_ENTRY_WIDTH, -1);
1485         gtk_box_pack_start (GTK_BOX (hbox1), inbox_entry, TRUE, TRUE, 0);
1486
1487         inbox_btn = gtkut_get_browse_file_btn(_("Bro_wse"));
1488         gtk_widget_show (inbox_btn);
1489         CLAWS_SET_TIP(inbox_btn,
1490                              _("Unfiltered messages will be stored in this folder"));
1491         gtk_box_pack_start (GTK_BOX (hbox1), inbox_btn, FALSE, FALSE, 0);
1492         g_signal_connect (G_OBJECT (inbox_btn), "clicked",
1493                           G_CALLBACK (prefs_account_select_folder_cb),
1494                           inbox_entry);
1495
1496         vbox2 = gtkut_get_options_frame(vbox1, &frame2, _("NNTP"));
1497
1498         hbox2 = gtk_hbox_new (FALSE, 8);
1499         gtk_widget_show (hbox2);
1500         gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, FALSE, 0);
1501
1502         maxarticle_label = gtk_label_new
1503                 (_("Maximum number of articles to download"));
1504         gtk_widget_show (maxarticle_label);
1505         gtk_box_pack_start (GTK_BOX (hbox2), maxarticle_label, FALSE, FALSE, 0);
1506
1507         maxarticle_spinbtn_adj =
1508                 gtk_adjustment_new (300, 0, 10000, 10, 100, 0);
1509         maxarticle_spinbtn = gtk_spin_button_new
1510                 (GTK_ADJUSTMENT (maxarticle_spinbtn_adj), 10, 0);
1511         gtk_widget_show (maxarticle_spinbtn);
1512         CLAWS_SET_TIP(maxarticle_spinbtn,
1513                              _("unlimited if 0 is specified"));
1514         gtk_box_pack_start (GTK_BOX (hbox2), maxarticle_spinbtn,
1515                             FALSE, FALSE, 0);
1516         gtk_widget_set_size_request (maxarticle_spinbtn, 64, -1);
1517         gtk_spin_button_set_numeric
1518                 (GTK_SPIN_BUTTON (maxarticle_spinbtn), TRUE);
1519
1520         vbox2 = gtkut_get_options_frame(vbox1, &imap_frame, _("IMAP4"));
1521
1522         hbox1 = gtk_hbox_new (FALSE, 8);
1523         gtk_widget_show (hbox1);
1524         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
1525
1526         label = gtk_label_new (_("Authentication method"));
1527         gtk_widget_show (label);
1528         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
1529
1530
1531         optmenu = gtkut_sc_combobox_create(NULL, FALSE);
1532         menu = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(optmenu)));
1533         gtk_widget_show (optmenu);
1534         gtk_box_pack_start (GTK_BOX (hbox1), optmenu, FALSE, FALSE, 0);
1535
1536         COMBOBOX_ADD (menu, _("Automatic"), 0);
1537         COMBOBOX_ADD (menu, NULL, 0);
1538         COMBOBOX_ADD (menu, "LOGIN", IMAP_AUTH_LOGIN);
1539         COMBOBOX_ADD (menu, "CRAM-MD5", IMAP_AUTH_CRAM_MD5);
1540         COMBOBOX_ADD (menu, "ANONYMOUS", IMAP_AUTH_ANON);
1541         COMBOBOX_ADD (menu, "GSSAPI", IMAP_AUTH_GSSAPI);
1542         COMBOBOX_ADD (menu, "DIGEST-MD5", IMAP_AUTH_DIGEST_MD5);
1543
1544         hbox1 = gtk_hbox_new (FALSE, 8);
1545         gtk_widget_show (hbox1);
1546         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 4);
1547
1548         imapdir_label = gtk_label_new (_("IMAP server directory"));
1549         gtk_widget_show (imapdir_label);
1550         gtk_box_pack_start (GTK_BOX (hbox1), imapdir_label, FALSE, FALSE, 0);
1551
1552         imapdir_label = gtk_label_new(_("(usually empty)"));
1553         gtk_widget_show (imapdir_label);
1554         gtkut_widget_set_small_font_size (imapdir_label);
1555         gtk_box_pack_start (GTK_BOX (hbox1), imapdir_label, FALSE, FALSE, 0);
1556
1557         imapdir_entry = gtk_entry_new();
1558         gtk_widget_show (imapdir_entry);
1559         gtk_box_pack_start (GTK_BOX (hbox1), imapdir_entry, FALSE, FALSE, 0);
1560
1561         hbox1 = gtk_hbox_new (FALSE, 8);
1562         gtk_widget_show (hbox1);
1563         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 4);
1564
1565         PACK_CHECK_BUTTON (hbox1, subsonly_checkbtn,
1566                            _("Show subscribed folders only"));
1567
1568         hbox1 = gtk_hbox_new (FALSE, 8);
1569         gtk_widget_show (hbox1);
1570         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 4);
1571
1572         PACK_CHECK_BUTTON (hbox1, low_bandwidth_checkbtn,
1573                            _("Bandwidth-efficient mode (prevents retrieving remote tags)"));
1574         CLAWS_SET_TIP(low_bandwidth_checkbtn,
1575                              _("This mode uses less bandwidth, but can be slower with some servers."));
1576
1577         hbox1 = gtk_hbox_new (FALSE, 8);
1578         gtk_widget_show (hbox1);
1579         gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 4);
1580
1581         PACK_CHECK_BUTTON (hbox1, imap_use_trash_checkbtn,
1582                            _("Move deleted mails to trash and expunge immediately"));
1583         CLAWS_SET_TIP(imap_use_trash_checkbtn,
1584                              _("Moves deleted mails to trash instead of using the \\Deleted flag without expunging."));
1585
1586         PACK_CHECK_BUTTON (vbox1, filter_on_recv_checkbtn,
1587                            _("Filter messages on receiving"));
1588
1589         g_signal_connect(G_OBJECT(filter_on_recv_checkbtn), "toggled",
1590                          G_CALLBACK(prefs_account_filter_on_recv_toggled),
1591                          NULL);
1592
1593         PACK_CHECK_BUTTON (vbox1, filterhook_on_recv_checkbtn,
1594                            _("Allow filtering using plugins on receiving"));
1595
1596         PACK_CHECK_BUTTON
1597                 (vbox1, recvatgetall_checkbtn,
1598                  _("'Get Mail' checks for new messages on this account"));
1599
1600         page->pop3_frame               = frame1;
1601         page->use_apop_checkbtn          = use_apop_checkbtn;
1602         page->rmmail_checkbtn            = rmmail_checkbtn;
1603         page->leave_time_spinbtn         = leave_time_spinbtn;
1604         page->leave_hour_spinbtn         = leave_hour_spinbtn;
1605         page->size_limit_checkbtn        = size_limit_checkbtn;
1606         page->size_limit_spinbtn         = size_limit_spinbtn;
1607         page->filter_on_recv_checkbtn    = filter_on_recv_checkbtn;
1608         page->filterhook_on_recv_checkbtn = filterhook_on_recv_checkbtn;
1609         page->inbox_label              = inbox_label;
1610         page->inbox_entry              = inbox_entry;
1611         page->inbox_btn                = inbox_btn;
1612
1613         page->imap_frame               = imap_frame;
1614         page->imap_auth_type_optmenu   = optmenu;
1615
1616         page->imapdir_label             = imapdir_label;
1617         page->imapdir_entry             = imapdir_entry;
1618         page->subsonly_checkbtn         = subsonly_checkbtn;
1619         page->low_bandwidth_checkbtn    = low_bandwidth_checkbtn;
1620         page->imap_use_trash_checkbtn   = imap_use_trash_checkbtn;
1621         page->local_frame               = local_frame;
1622         page->local_inbox_label = local_inbox_label;
1623         page->local_inbox_entry = local_inbox_entry;
1624         page->local_inbox_btn           = local_inbox_btn;
1625
1626         page->recvatgetall_checkbtn      = recvatgetall_checkbtn;
1627
1628         page->frame_maxarticle  = frame2;
1629         page->maxarticle_spinbtn        = maxarticle_spinbtn;
1630         page->maxarticle_spinbtn_adj    = maxarticle_spinbtn_adj;
1631
1632         tmp_ac_prefs = *ac_prefs;
1633
1634         if (new_account) {
1635                 prefs_set_dialog_to_default(receive_param);
1636         } else
1637                 prefs_set_dialog(receive_param);
1638
1639         page->vbox = vbox1;
1640
1641         page->page.widget = vbox1;
1642 }
1643
1644 static void send_create_widget_func(PrefsPage * _page,
1645                                            GtkWindow * window,
1646                                            gpointer data)
1647 {
1648         SendPage *page = (SendPage *) _page;
1649         PrefsAccount *ac_prefs = (PrefsAccount *) data;
1650
1651         GtkWidget *vbox1;
1652         GtkWidget *vbox2;
1653         GtkWidget *frame;
1654         GtkWidget *msgid_checkbtn;
1655         GtkWidget *hbox;
1656         GtkWidget *customhdr_checkbtn;
1657         GtkWidget *customhdr_edit_btn;
1658         GtkWidget *vbox3;
1659         GtkWidget *smtp_auth_checkbtn;
1660         GtkWidget *optmenu;
1661         GtkListStore *menu;
1662         GtkTreeIter iter;
1663         GtkWidget *vbox4;
1664         GtkWidget *hbox_spc;
1665         GtkWidget *label;
1666         GtkWidget *smtp_uid_entry;
1667         GtkWidget *smtp_pass_entry;
1668         GtkWidget *vbox_spc;
1669         GtkWidget *pop_bfr_smtp_checkbtn;
1670         GtkWidget *pop_bfr_smtp_tm_spinbtn;
1671         GtkWidget *pop_auth_timeout_lbl;
1672         GtkWidget *pop_auth_minutes_lbl;
1673
1674         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1675         gtk_widget_show (vbox1);
1676         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1677
1678         vbox2 = gtkut_get_options_frame(vbox1, &frame, _("Header"));
1679
1680         PACK_CHECK_BUTTON (vbox2, msgid_checkbtn, _("Generate Message-ID"));
1681
1682         hbox = gtk_hbox_new (FALSE, 12);
1683         gtk_widget_show (hbox);
1684         gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
1685
1686         PACK_CHECK_BUTTON (hbox, customhdr_checkbtn,
1687                            _("Add user-defined header"));
1688
1689         customhdr_edit_btn = gtk_button_new_from_stock (GTK_STOCK_EDIT);
1690         gtk_widget_show (customhdr_edit_btn);
1691         gtk_box_pack_start (GTK_BOX (hbox), customhdr_edit_btn,
1692                             FALSE, FALSE, 0);
1693         g_signal_connect (G_OBJECT (customhdr_edit_btn), "clicked",
1694                           G_CALLBACK (prefs_account_edit_custom_header),
1695                           NULL);
1696
1697         SET_TOGGLE_SENSITIVITY (customhdr_checkbtn, customhdr_edit_btn);
1698
1699         vbox3 = gtkut_get_options_frame(vbox1, &frame, _("Authentication"));
1700
1701         PACK_CHECK_BUTTON (vbox3, smtp_auth_checkbtn,
1702                 _("SMTP Authentication (SMTP AUTH)"));
1703
1704         vbox4 = gtk_vbox_new (FALSE, 0);
1705         gtk_widget_show (vbox4);
1706         gtk_box_pack_start (GTK_BOX (vbox3), vbox4, FALSE, FALSE, 0);
1707
1708         hbox = gtk_hbox_new (FALSE, 8);
1709         gtk_widget_show (hbox);
1710         gtk_box_pack_start (GTK_BOX (vbox4), hbox, FALSE, FALSE, 0);
1711
1712         hbox_spc = gtk_hbox_new (FALSE, 0);
1713         gtk_widget_show (hbox_spc);
1714         gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1715         gtk_widget_set_size_request (hbox_spc, 12, -1);
1716
1717         label = gtk_label_new (_("Authentication method"));
1718         gtk_widget_show (label);
1719         gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1720
1721         optmenu = gtkut_sc_combobox_create(NULL, FALSE);
1722         menu = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(optmenu)));
1723         gtk_widget_show (optmenu);
1724         gtk_box_pack_start (GTK_BOX (hbox), optmenu, FALSE, FALSE, 0);
1725
1726         COMBOBOX_ADD (menu, _("Automatic"), 0);
1727         COMBOBOX_ADD (menu, NULL, 0);
1728         COMBOBOX_ADD (menu, "PLAIN", SMTPAUTH_PLAIN);
1729         COMBOBOX_ADD (menu, "LOGIN", SMTPAUTH_LOGIN);
1730         COMBOBOX_ADD (menu, "CRAM-MD5", SMTPAUTH_CRAM_MD5);
1731         COMBOBOX_ADD (menu, "DIGEST-MD5", SMTPAUTH_DIGEST_MD5);
1732         gtk_list_store_set(menu, &iter, COMBOBOX_SENS, FALSE, -1);
1733
1734         PACK_VSPACER(vbox4, vbox_spc, VSPACING_NARROW_2);
1735
1736         hbox = gtk_hbox_new (FALSE, 8);
1737         gtk_widget_show (hbox);
1738         gtk_box_pack_start (GTK_BOX (vbox4), hbox, FALSE, FALSE, 0);
1739
1740         hbox_spc = gtk_hbox_new (FALSE, 0);
1741         gtk_widget_show (hbox_spc);
1742         gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1743         gtk_widget_set_size_request (hbox_spc, 12, -1);
1744
1745         label = gtk_label_new (_("User ID"));
1746         gtk_widget_show (label);
1747         gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1748
1749         smtp_uid_entry = gtk_entry_new ();
1750         gtk_widget_show (smtp_uid_entry);
1751         gtk_widget_set_size_request (smtp_uid_entry, DEFAULT_ENTRY_WIDTH, -1);
1752         gtk_box_pack_start (GTK_BOX (hbox), smtp_uid_entry, TRUE, TRUE, 0);
1753
1754 #ifdef GENERIC_UMPC
1755         PACK_VSPACER(vbox4, vbox_spc, VSPACING_NARROW_2);
1756         hbox = gtk_hbox_new (FALSE, 8);
1757         gtk_widget_show (hbox);
1758         gtk_box_pack_start (GTK_BOX (vbox4), hbox, FALSE, FALSE, 0);
1759
1760         hbox_spc = gtk_hbox_new (FALSE, 0);
1761         gtk_widget_show (hbox_spc);
1762         gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1763         gtk_widget_set_size_request (hbox_spc, 12, -1);
1764 #endif
1765         label = gtk_label_new (_("Password"));
1766         gtk_widget_show (label);
1767         gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1768
1769         smtp_pass_entry = gtk_entry_new ();
1770         gtk_widget_show (smtp_pass_entry);
1771         gtk_widget_set_size_request (smtp_pass_entry, DEFAULT_ENTRY_WIDTH, -1);
1772         gtk_box_pack_start (GTK_BOX (hbox), smtp_pass_entry, TRUE, TRUE, 0);
1773
1774         gtk_entry_set_visibility (GTK_ENTRY (smtp_pass_entry), FALSE);
1775 #ifdef MAEMO
1776         hildon_gtk_entry_set_input_mode(GTK_ENTRY(smtp_pass_entry), 
1777                 HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
1778 #endif
1779         PACK_VSPACER(vbox4, vbox_spc, VSPACING_NARROW_2);
1780
1781         hbox = gtk_hbox_new (FALSE, 8);
1782         gtk_widget_show (hbox);
1783         gtk_box_pack_start (GTK_BOX (vbox4), hbox, FALSE, FALSE, 0);
1784
1785         hbox_spc = gtk_hbox_new (FALSE, 0);
1786         gtk_widget_show (hbox_spc);
1787         gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1788         gtk_widget_set_size_request (hbox_spc, 12, -1);
1789
1790         label = gtk_label_new
1791                 (_("If you leave these entries empty, the same "
1792                    "user ID and password as receiving will be used."));
1793         gtk_widget_show (label);
1794         gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1795         gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
1796         gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
1797         gtkut_widget_set_small_font_size (label);
1798
1799         SET_TOGGLE_SENSITIVITY (smtp_auth_checkbtn, vbox4);
1800
1801         PACK_CHECK_BUTTON (vbox3, pop_bfr_smtp_checkbtn,
1802                 _("Authenticate with POP3 before sending"));
1803         
1804         g_signal_connect (G_OBJECT (pop_bfr_smtp_checkbtn), "clicked",
1805                           G_CALLBACK (pop_bfr_smtp_tm_set_sens),
1806                           NULL);
1807
1808         hbox = gtk_hbox_new (FALSE, 8);
1809         gtk_widget_show (hbox);
1810         gtk_box_pack_start (GTK_BOX (vbox3), hbox, FALSE, FALSE, 0);
1811
1812         hbox_spc = gtk_hbox_new (FALSE, 0);
1813         gtk_widget_show (hbox_spc);
1814         gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1815         gtk_widget_set_size_request (hbox_spc, 12, -1);
1816
1817         pop_auth_timeout_lbl = gtk_label_new(_("POP authentication timeout: "));
1818         gtk_widget_show (pop_auth_timeout_lbl);
1819         gtk_box_pack_start (GTK_BOX (hbox), pop_auth_timeout_lbl, FALSE, FALSE, 0);
1820
1821         pop_bfr_smtp_tm_spinbtn = gtk_spin_button_new_with_range(0, 1440, 1);
1822         gtk_widget_show (pop_bfr_smtp_tm_spinbtn);
1823         gtk_box_pack_start (GTK_BOX (hbox), pop_bfr_smtp_tm_spinbtn, FALSE, FALSE, 0);
1824
1825         pop_auth_minutes_lbl = gtk_label_new(_("minutes"));
1826         gtk_widget_show (pop_auth_minutes_lbl);
1827         gtk_box_pack_start (GTK_BOX (hbox), pop_auth_minutes_lbl, FALSE, FALSE, 0);
1828         
1829         page->msgid_checkbtn     = msgid_checkbtn;
1830         page->customhdr_checkbtn = customhdr_checkbtn;
1831
1832         page->smtp_auth_checkbtn       = smtp_auth_checkbtn;
1833         page->smtp_auth_type_optmenu = optmenu;
1834         page->smtp_uid_entry         = smtp_uid_entry;
1835         page->smtp_pass_entry        = smtp_pass_entry;
1836         page->pop_bfr_smtp_checkbtn    = pop_bfr_smtp_checkbtn;
1837         page->pop_bfr_smtp_tm_spinbtn  = pop_bfr_smtp_tm_spinbtn;
1838         page->pop_auth_timeout_lbl   = pop_auth_timeout_lbl;
1839         page->pop_auth_minutes_lbl   = pop_auth_minutes_lbl;
1840
1841         tmp_ac_prefs = *ac_prefs;
1842
1843         if (new_account) {
1844                 prefs_set_dialog_to_default(send_param);
1845         } else
1846                 prefs_set_dialog(send_param);
1847
1848         pop_bfr_smtp_tm_set_sens (NULL, NULL);
1849
1850         page->vbox = vbox1;
1851
1852         page->page.widget = vbox1;
1853 }
1854         
1855 static void compose_create_widget_func(PrefsPage * _page,
1856                                            GtkWindow * window,
1857                                            gpointer data)
1858 {
1859         ComposePage *page = (ComposePage *) _page;
1860         PrefsAccount *ac_prefs = (PrefsAccount *) data;
1861
1862         GtkWidget *vbox1;
1863         GtkWidget *sig_hbox;
1864         GtkWidget *hbox1;
1865         GtkWidget *hbox2;
1866         GtkWidget *frame_sig;
1867         GtkWidget *vbox_sig;
1868         GtkWidget *label_sigpath;
1869         GtkWidget *checkbtn_autosig;
1870         GtkWidget *label_sigsep;
1871         GtkWidget *entry_sigsep;
1872         GtkWidget *frame;
1873         GtkWidget *table;
1874         GtkWidget *autocc_checkbtn;
1875         GtkWidget *autocc_entry;
1876         GtkWidget *autobcc_checkbtn;
1877         GtkWidget *autobcc_entry;
1878         GtkWidget *autoreplyto_checkbtn;
1879         GtkWidget *autoreplyto_entry;
1880 #if USE_ENCHANT
1881         GtkWidget *frame_dict;
1882         GtkWidget *table_dict;
1883         GtkWidget *checkbtn_enable_default_dictionary = NULL;
1884         GtkWidget *combo_default_dictionary = NULL;
1885         GtkWidget *checkbtn_enable_default_alt_dictionary = NULL;
1886         GtkWidget *combo_default_alt_dictionary = NULL;
1887 #endif
1888
1889         vbox1 = gtk_vbox_new (FALSE, VSPACING);
1890         gtk_widget_show (vbox1);
1891         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1892
1893         vbox_sig = gtkut_get_options_frame(vbox1, &frame_sig, _("Signature"));
1894
1895         PACK_CHECK_BUTTON (vbox_sig, checkbtn_autosig,
1896                            _("Automatically insert signature"));
1897
1898         hbox1 = gtk_hbox_new (FALSE, 8);
1899         gtk_widget_show (hbox1);
1900         gtk_box_pack_start (GTK_BOX (vbox_sig), hbox1, TRUE, TRUE, 0);
1901         label_sigsep = gtk_label_new (_("Signature separator"));
1902         gtk_widget_show (label_sigsep);
1903         gtk_box_pack_start (GTK_BOX (hbox1), label_sigsep, FALSE, FALSE, 0);
1904
1905         entry_sigsep = gtk_entry_new ();
1906         gtk_widget_show (entry_sigsep);
1907         gtk_box_pack_start (GTK_BOX (hbox1), entry_sigsep, FALSE, FALSE, 0);
1908
1909         gtk_widget_set_size_request (entry_sigsep, 64, -1);
1910
1911         sig_hbox = gtk_hbox_new (FALSE, 8);
1912         gtk_widget_show (sig_hbox);
1913         gtk_box_pack_start (GTK_BOX (vbox_sig), sig_hbox, FALSE, FALSE, 0);
1914
1915         sigfile_radiobtn = gtk_radio_button_new_with_label (NULL, _("File"));
1916         gtk_widget_show (sigfile_radiobtn);
1917         gtk_box_pack_start (GTK_BOX (sig_hbox), sigfile_radiobtn,
1918                             FALSE, FALSE, 0);
1919         g_object_set_data (G_OBJECT (sigfile_radiobtn),
1920                            MENU_VAL_ID,
1921                            GINT_TO_POINTER (SIG_FILE));
1922         g_signal_connect(G_OBJECT(sigfile_radiobtn), "clicked",
1923                          G_CALLBACK(prefs_account_sigfile_radiobtn_cb), NULL);
1924
1925         sigcmd_radiobtn = gtk_radio_button_new_with_label_from_widget
1926                 (GTK_RADIO_BUTTON(sigfile_radiobtn), _("Command output"));
1927         gtk_widget_show (sigcmd_radiobtn);
1928         gtk_box_pack_start (GTK_BOX (sig_hbox), sigcmd_radiobtn,
1929                             FALSE, FALSE, 0);
1930         g_object_set_data (G_OBJECT (sigcmd_radiobtn),
1931                            MENU_VAL_ID,
1932                            GINT_TO_POINTER (SIG_COMMAND));
1933         g_signal_connect(G_OBJECT(sigcmd_radiobtn), "clicked",
1934                          G_CALLBACK(prefs_account_sigcmd_radiobtn_cb), NULL);
1935
1936         hbox2 = gtk_hbox_new (FALSE, 8);
1937         gtk_widget_show (hbox2);
1938         gtk_box_pack_start (GTK_BOX (vbox_sig), hbox2, TRUE, TRUE, 0);
1939         label_sigpath = gtk_label_new (_("Signature"));
1940         gtk_widget_show (label_sigpath);
1941         gtk_box_pack_start (GTK_BOX (hbox2), label_sigpath, FALSE, FALSE, 0);
1942
1943         entry_sigpath = gtk_entry_new ();
1944         gtk_widget_show (entry_sigpath);
1945         gtk_box_pack_start (GTK_BOX (hbox2), entry_sigpath, TRUE, TRUE, 0);
1946
1947         signature_browse_button = gtkut_get_browse_file_btn(_("Bro_wse"));
1948         gtk_widget_show (signature_browse_button);
1949         gtk_box_pack_start (GTK_BOX (hbox2), signature_browse_button, FALSE, FALSE, 0);
1950         g_signal_connect(G_OBJECT(signature_browse_button), "clicked",
1951                          G_CALLBACK(prefs_account_signature_browse_cb), NULL);
1952
1953         signature_edit_button = gtk_button_new_from_stock (GTK_STOCK_EDIT);
1954         gtk_widget_show (signature_edit_button);
1955         gtk_box_pack_start (GTK_BOX (hbox2), signature_edit_button, FALSE, FALSE, 0);
1956         g_signal_connect(G_OBJECT(signature_edit_button), "clicked",
1957                          G_CALLBACK(prefs_account_signature_edit_cb), entry_sigpath);
1958
1959         PACK_FRAME (vbox1, frame, _("Automatically set the following addresses"));
1960
1961         table =  gtk_table_new (3, 2, FALSE);
1962         gtk_widget_show (table);
1963         gtk_container_add (GTK_CONTAINER (frame), table);
1964         gtk_container_set_border_width (GTK_CONTAINER (table), 8);
1965         gtk_table_set_row_spacings (GTK_TABLE (table), VSPACING_NARROW_2);
1966         gtk_table_set_col_spacings (GTK_TABLE (table), 8);
1967
1968         autocc_checkbtn = gtk_check_button_new_with_label (_("Cc"));
1969         gtk_widget_show (autocc_checkbtn);
1970         gtk_table_attach (GTK_TABLE (table), autocc_checkbtn, 0, 1, 0, 1,
1971                           GTK_FILL, 0, 0, 0);
1972
1973         autocc_entry = gtk_entry_new ();
1974         gtk_widget_show (autocc_entry);
1975         gtk_table_attach (GTK_TABLE (table), autocc_entry, 1, 2, 0, 1,
1976                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1977                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1978
1979         SET_TOGGLE_SENSITIVITY (autocc_checkbtn, autocc_entry);
1980
1981         autobcc_checkbtn = gtk_check_button_new_with_label (_("Bcc"));
1982         gtk_widget_show (autobcc_checkbtn);
1983         gtk_table_attach (GTK_TABLE (table), autobcc_checkbtn, 0, 1, 1, 2,
1984                           GTK_FILL, 0, 0, 0);
1985
1986         autobcc_entry = gtk_entry_new ();
1987         gtk_widget_show (autobcc_entry);
1988         gtk_table_attach (GTK_TABLE (table), autobcc_entry, 1, 2, 1, 2,
1989                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1990                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1991
1992         SET_TOGGLE_SENSITIVITY (autobcc_checkbtn, autobcc_entry);
1993
1994         autoreplyto_checkbtn = gtk_check_button_new_with_label (_("Reply-To"));
1995         gtk_widget_show (autoreplyto_checkbtn);
1996         gtk_table_attach (GTK_TABLE (table), autoreplyto_checkbtn, 0, 1, 2, 3,
1997                           GTK_FILL, 0, 0, 0);
1998
1999         autoreplyto_entry = gtk_entry_new ();
2000         gtk_widget_show (autoreplyto_entry);
2001         gtk_table_attach (GTK_TABLE (table), autoreplyto_entry, 1, 2, 2, 3,
2002                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
2003                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
2004
2005         SET_TOGGLE_SENSITIVITY (autoreplyto_checkbtn, autoreplyto_entry);
2006
2007 #if USE_ENCHANT
2008         PACK_FRAME (vbox1, frame_dict, _("Spell check dictionaries"));
2009
2010         table_dict =  gtk_table_new (2, 2, FALSE);
2011         gtk_widget_show (table_dict);
2012         gtk_container_add (GTK_CONTAINER (frame_dict), table_dict);
2013         gtk_container_set_border_width (GTK_CONTAINER (table_dict), 8);
2014         gtk_table_set_row_spacings (GTK_TABLE (table_dict), VSPACING_NARROW_2);
2015         gtk_table_set_col_spacings (GTK_TABLE (table_dict), 8);
2016
2017         /* Default dictionary */
2018         checkbtn_enable_default_dictionary = gtk_check_button_new_with_label(_("Default dictionary"));
2019         gtk_table_attach(GTK_TABLE(table_dict), checkbtn_enable_default_dictionary, 0, 1,
2020                         0, 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
2021         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_default_dictionary),
2022                         tmp_ac_prefs.enable_default_dictionary);
2023
2024         combo_default_dictionary = gtkaspell_dictionary_combo_new(TRUE);
2025         gtk_table_attach(GTK_TABLE(table_dict), combo_default_dictionary, 1, 2,
2026                         0, 1, GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
2027
2028         SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_dictionary, combo_default_dictionary);
2029
2030         /* Default dictionary */
2031         checkbtn_enable_default_alt_dictionary = gtk_check_button_new_with_label(_("Default alternate dictionary"));
2032         gtk_table_attach(GTK_TABLE(table_dict), checkbtn_enable_default_alt_dictionary, 0, 1,
2033                         1, 2, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
2034         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_default_alt_dictionary),
2035                         tmp_ac_prefs.enable_default_alt_dictionary);
2036
2037         combo_default_alt_dictionary = gtkaspell_dictionary_combo_new(FALSE);
2038         gtk_table_attach(GTK_TABLE(table_dict), combo_default_alt_dictionary, 1, 2,
2039                         1, 2, GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
2040
2041         SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_alt_dictionary, combo_default_alt_dictionary);
2042
2043         gtk_widget_show_all(table_dict);
2044 #endif
2045
2046         page->sigfile_radiobtn = sigfile_radiobtn;
2047         page->entry_sigpath      = entry_sigpath;
2048         page->checkbtn_autosig   = checkbtn_autosig;
2049         page->entry_sigsep       = entry_sigsep;
2050
2051         page->autocc_checkbtn      = autocc_checkbtn;
2052         page->autocc_entry       = autocc_entry;
2053         page->autobcc_checkbtn     = autobcc_checkbtn;
2054         page->autobcc_entry      = autobcc_entry;
2055         page->autoreplyto_checkbtn = autoreplyto_checkbtn;
2056         page->autoreplyto_entry  = autoreplyto_entry;
2057 #ifdef USE_ENCHANT
2058         page->checkbtn_enable_default_dictionary = checkbtn_enable_default_dictionary;
2059         page->combo_default_dictionary = combo_default_dictionary;
2060         page->checkbtn_enable_default_alt_dictionary = checkbtn_enable_default_alt_dictionary;
2061         page->combo_default_alt_dictionary = combo_default_alt_dictionary;
2062 #endif
2063
2064 #ifdef USE_ENCHANT
2065         /* reset gtkaspell menus */
2066         if (compose_page.combo_default_dictionary != NULL) {
2067                 gtk_combo_box_set_model(GTK_COMBO_BOX(compose_page.combo_default_dictionary),
2068                                         gtkaspell_dictionary_store_new());
2069                 gtk_combo_box_set_model(GTK_COMBO_BOX(compose_page.combo_default_alt_dictionary),
2070                                         gtkaspell_dictionary_store_new_with_refresh(
2071                                                 FALSE));
2072         }
2073 #endif
2074
2075         tmp_ac_prefs = *ac_prefs;
2076
2077         if (new_account) {
2078                 prefs_set_dialog_to_default(compose_param);
2079         } else
2080                 prefs_set_dialog(compose_param);
2081
2082         page->vbox = vbox1;
2083
2084         page->page.widget = vbox1;
2085 }
2086         
2087 static void templates_create_widget_func(PrefsPage * _page,
2088                                            GtkWindow * window,
2089                                            gpointer data)
2090 {
2091         TemplatesPage *page = (TemplatesPage *) _page;
2092         PrefsAccount *ac_prefs = (PrefsAccount *) data;
2093         GtkWidget *vbox;
2094         GtkWidget *vbox2;
2095         GtkWidget *notebook;
2096
2097         vbox = gtk_vbox_new(FALSE, 0);
2098         gtk_widget_show(vbox);
2099         
2100         notebook = gtk_notebook_new();
2101         gtk_widget_show(notebook);
2102         gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0);
2103
2104         /* compose format */
2105         vbox2 = gtk_vbox_new (FALSE, VSPACING);
2106         gtk_widget_show (vbox2);
2107         gtk_container_set_border_width (GTK_CONTAINER (vbox2), VBOX_BORDER);
2108
2109         quotefmt_create_new_msg_fmt_widgets(
2110                                 window,
2111                                 vbox2,
2112                                 &page->checkbtn_compose_with_format,
2113                                 NULL,
2114                                 &page->compose_subject_format,
2115                                 &page->compose_body_format,
2116                                 FALSE, NULL);
2117         gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox2, gtk_label_new(_("Compose")));
2118
2119         /* reply format */      
2120         vbox2 = gtk_vbox_new (FALSE, VSPACING);
2121         gtk_widget_show (vbox2);
2122         gtk_container_set_border_width (GTK_CONTAINER (vbox2), VBOX_BORDER);
2123         
2124         quotefmt_create_reply_fmt_widgets(
2125                                 window,
2126                                 vbox2,
2127                                 &page->checkbtn_reply_with_format,
2128                                 NULL,
2129                                 &page->reply_quotemark,
2130                                 &page->reply_body_format,
2131                                 FALSE, NULL);
2132         gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox2, gtk_label_new(_("Reply")));
2133
2134         /* forward format */    
2135         vbox2 = gtk_vbox_new (FALSE, VSPACING);
2136         gtk_widget_show (vbox2);
2137         gtk_container_set_border_width (GTK_CONTAINER (vbox2), VBOX_BORDER);
2138
2139         quotefmt_create_forward_fmt_widgets(
2140                                 window,
2141                                 vbox2,
2142                                 &page->checkbtn_forward_with_format,
2143                                 NULL,
2144                                 &page->forward_quotemark,
2145                                 &page->forward_body_format,
2146                                 FALSE, NULL);
2147         gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox2, gtk_label_new(_("Forward")));
2148
2149         quotefmt_add_info_button(window, vbox);
2150
2151         tmp_ac_prefs = *ac_prefs;
2152
2153         if (new_account) {
2154                 prefs_set_dialog_to_default(templates_param);
2155         } else
2156                 prefs_set_dialog(templates_param);
2157
2158         page->vbox = vbox;
2159
2160         page->page.widget = vbox;
2161 }
2162
2163 static void privacy_create_widget_func(PrefsPage * _page,
2164                                            GtkWindow * window,
2165                                            gpointer data)
2166 {
2167         PrivacyPage *page = (PrivacyPage *) _page;
2168         PrefsAccount *ac_prefs = (PrefsAccount *) data;
2169
2170         GtkWidget *vbox1;
2171         GtkWidget *vbox2;
2172         GtkWidget *hbox1;
2173         GtkWidget *label;
2174         GtkWidget *default_privacy_system;
2175         GtkListStore *menu;
2176         GtkCellRenderer *rend;
2177         GtkWidget *default_encrypt_checkbtn;
2178         GtkWidget *default_encrypt_reply_checkbtn;
2179         GtkWidget *default_sign_checkbtn;
2180         GtkWidget *default_sign_reply_checkbtn;
2181         GtkWidget *save_clear_text_checkbtn;
2182         GtkWidget *encrypt_to_self_checkbtn;
2183
2184         vbox1 = gtk_vbox_new (FALSE, VSPACING);
2185         gtk_widget_show (vbox1);
2186         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2187
2188         vbox2 = gtk_vbox_new (FALSE, 0);
2189         gtk_widget_show (vbox2);
2190         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
2191
2192         hbox1 = gtk_hbox_new(FALSE, 8);
2193         gtk_widget_show (hbox1);
2194         gtk_container_add (GTK_CONTAINER(vbox2), hbox1);
2195
2196         label = gtk_label_new(_("Default privacy system"));
2197         gtk_widget_show(label);
2198         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2199
2200         /* Can't use gtkut_sc_combobox_create() here, because model for this
2201          * combobox needs an extra string column to store privacy plugin id. */
2202         menu = gtk_list_store_new(4,
2203                         G_TYPE_STRING,
2204                         G_TYPE_INT,
2205                         G_TYPE_BOOLEAN,
2206                         G_TYPE_STRING); /* This is where we store the privacy plugin id. */
2207         default_privacy_system = gtk_combo_box_new_with_model(GTK_TREE_MODEL(menu));
2208
2209         rend = gtk_cell_renderer_text_new();
2210         gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(default_privacy_system), rend, TRUE);
2211         gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(default_privacy_system), rend,
2212                         "text", COMBOBOX_TEXT,
2213                         "sensitive", COMBOBOX_SENS,
2214                         NULL);
2215         gtk_combo_box_set_focus_on_click(GTK_COMBO_BOX(default_privacy_system), FALSE);
2216
2217         gtk_widget_show (default_privacy_system);
2218         gtk_box_pack_start (GTK_BOX(hbox1), default_privacy_system, FALSE, TRUE, 0);
2219
2220         g_signal_connect(G_OBJECT(default_privacy_system), "changed",
2221                          G_CALLBACK(privacy_system_activated),
2222                          NULL);
2223
2224         PACK_CHECK_BUTTON (vbox2, default_sign_checkbtn,
2225                            _("Always sign messages"));
2226         PACK_CHECK_BUTTON (vbox2, default_encrypt_checkbtn,
2227                            _("Always encrypt messages"));
2228         PACK_CHECK_BUTTON (vbox2, default_sign_reply_checkbtn,
2229                            _("Always sign messages when replying to a "
2230                              "signed message"));
2231         PACK_CHECK_BUTTON (vbox2, default_encrypt_reply_checkbtn,
2232                            _("Always encrypt messages when replying to an "
2233                              "encrypted message"));
2234         PACK_CHECK_BUTTON (vbox2, encrypt_to_self_checkbtn,
2235                            _("Encrypt sent messages with your own key in addition to recipient's"));
2236         PACK_CHECK_BUTTON (vbox2, save_clear_text_checkbtn,
2237                            _("Save sent encrypted messages as clear text"));
2238
2239         SET_TOGGLE_SENSITIVITY_REVERSE(encrypt_to_self_checkbtn, save_clear_text_checkbtn);
2240         SET_TOGGLE_SENSITIVITY_REVERSE(save_clear_text_checkbtn, encrypt_to_self_checkbtn);
2241
2242         page->default_privacy_system = default_privacy_system;
2243         page->default_encrypt_checkbtn = default_encrypt_checkbtn;
2244         page->default_encrypt_reply_checkbtn = default_encrypt_reply_checkbtn;
2245         page->default_sign_reply_checkbtn = default_sign_reply_checkbtn;
2246         page->default_sign_checkbtn    = default_sign_checkbtn;
2247         page->save_clear_text_checkbtn = save_clear_text_checkbtn;
2248         page->encrypt_to_self_checkbtn = encrypt_to_self_checkbtn;
2249
2250         update_privacy_system_menu();
2251
2252         tmp_ac_prefs = *ac_prefs;
2253
2254         if (new_account) {
2255                 prefs_set_dialog_to_default(privacy_param);
2256         } else
2257                 prefs_set_dialog(privacy_param);
2258
2259         page->vbox = vbox1;
2260
2261         page->page.widget = vbox1;
2262 }
2263         
2264 #ifdef USE_GNUTLS
2265
2266 #define CREATE_RADIO_BUTTON(box, btn, btn_p, label, data)               \
2267 {                                                                       \
2268         btn = gtk_radio_button_new_with_label_from_widget               \
2269                 (GTK_RADIO_BUTTON (btn_p), label);                      \
2270         gtk_widget_show (btn);                                          \
2271         gtk_box_pack_start (GTK_BOX (box), btn, FALSE, FALSE, 0);       \
2272         g_object_set_data (G_OBJECT (btn),                              \
2273                            MENU_VAL_ID,                                 \
2274                            GINT_TO_POINTER (data));                     \
2275 }
2276
2277 #define CREATE_RADIO_BUTTONS(box,                                       \
2278                              btn1, btn1_label, btn1_data,               \
2279                              btn2, btn2_label, btn2_data,               \
2280                              btn3, btn3_label, btn3_data)               \
2281 {                                                                       \
2282         btn1 = gtk_radio_button_new_with_label(NULL, btn1_label);       \
2283         gtk_widget_show (btn1);                                         \
2284         gtk_box_pack_start (GTK_BOX (box), btn1, FALSE, FALSE, 0);      \
2285         g_object_set_data (G_OBJECT (btn1),                             \
2286                            MENU_VAL_ID,                                 \
2287                            GINT_TO_POINTER (btn1_data));                \
2288                                                                         \
2289         CREATE_RADIO_BUTTON(box, btn2, btn1, btn2_label, btn2_data);    \
2290         CREATE_RADIO_BUTTON(box, btn3, btn1, btn3_label, btn3_data);    \
2291 }
2292
2293 static void ssl_create_widget_func(PrefsPage * _page,
2294                                            GtkWindow * window,
2295                                            gpointer data)
2296 {
2297         SSLPage *page = (SSLPage *) _page;
2298         PrefsAccount *ac_prefs = (PrefsAccount *) data;
2299
2300         GtkWidget *vbox1;
2301
2302         GtkWidget *pop_frame;
2303         GtkWidget *vbox2;
2304         GtkWidget *pop_nossl_radiobtn;
2305         GtkWidget *pop_ssltunnel_radiobtn;
2306         GtkWidget *pop_starttls_radiobtn;
2307
2308         GtkWidget *imap_frame;
2309         GtkWidget *vbox3;
2310         GtkWidget *imap_nossl_radiobtn;
2311         GtkWidget *imap_ssltunnel_radiobtn;
2312         GtkWidget *imap_starttls_radiobtn;
2313
2314         GtkWidget *nntp_frame;
2315         GtkWidget *vbox4;
2316         GtkWidget *nntp_nossl_radiobtn;
2317         GtkWidget *nntp_ssltunnel_radiobtn;
2318
2319         GtkWidget *send_frame;
2320         GtkWidget *vbox5;
2321         GtkWidget *smtp_nossl_radiobtn;
2322         GtkWidget *smtp_ssltunnel_radiobtn;
2323         GtkWidget *smtp_starttls_radiobtn;
2324
2325         GtkWidget *cert_frame;
2326         GtkWidget *cert_table;
2327         GtkWidget *entry_in_cert_pass;
2328         GtkWidget *entry_out_cert_pass;
2329
2330         GtkWidget *vbox7;
2331         GtkWidget *use_nonblocking_ssl_checkbtn;
2332         GtkWidget *hbox;
2333         GtkWidget *hbox_spc;
2334         GtkWidget *label;
2335         CLAWS_TIP_DECL();
2336
2337         vbox1 = gtk_vbox_new (FALSE, VSPACING);
2338         gtk_widget_show (vbox1);
2339         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2340
2341         vbox2 = gtkut_get_options_frame(vbox1, &pop_frame, _("POP3"));
2342
2343         CREATE_RADIO_BUTTONS(vbox2,
2344                              pop_nossl_radiobtn,
2345                              _("Don't use SSL"),
2346                              SSL_NONE,
2347                              pop_ssltunnel_radiobtn,
2348                              _("Use SSL for POP3 connection"),
2349                              SSL_TUNNEL,
2350                              pop_starttls_radiobtn,
2351                              _("Use STARTTLS command to start SSL session"),
2352                              SSL_STARTTLS);
2353         
2354         vbox3 = gtkut_get_options_frame(vbox1, &imap_frame, _("IMAP4"));
2355
2356         CREATE_RADIO_BUTTONS(vbox3,
2357                              imap_nossl_radiobtn,
2358                              _("Don't use SSL"),
2359                              SSL_NONE,
2360                              imap_ssltunnel_radiobtn,
2361                              _("Use SSL for IMAP4 connection"),
2362                              SSL_TUNNEL,
2363                              imap_starttls_radiobtn,
2364                              _("Use STARTTLS command to start SSL session"),
2365                              SSL_STARTTLS);
2366
2367         vbox4 = gtkut_get_options_frame(vbox1, &nntp_frame, _("NNTP"));
2368
2369         nntp_nossl_radiobtn =
2370                 gtk_radio_button_new_with_label (NULL, _("Don't use SSL"));
2371         gtk_widget_show (nntp_nossl_radiobtn);
2372         gtk_box_pack_start (GTK_BOX (vbox4), nntp_nossl_radiobtn,
2373                             FALSE, FALSE, 0);
2374         g_object_set_data (G_OBJECT (nntp_nossl_radiobtn),
2375                            MENU_VAL_ID,
2376                            GINT_TO_POINTER (SSL_NONE));
2377
2378         CREATE_RADIO_BUTTON(vbox4, nntp_ssltunnel_radiobtn, nntp_nossl_radiobtn,
2379                             _("Use SSL for NNTP connection"), SSL_TUNNEL);
2380
2381         vbox5 = gtkut_get_options_frame(vbox1, &send_frame, _("Send (SMTP)"));
2382
2383         CREATE_RADIO_BUTTONS(vbox5,
2384                              smtp_nossl_radiobtn,
2385                              _("Don't use SSL (but, if necessary, use STARTTLS)"),
2386                              SSL_NONE,
2387                              smtp_ssltunnel_radiobtn,
2388                              _("Use SSL for SMTP connection"),
2389                              SSL_TUNNEL,
2390                              smtp_starttls_radiobtn,
2391                              _("Use STARTTLS command to start SSL session"),
2392                              SSL_STARTTLS);
2393
2394         PACK_FRAME(vbox1, cert_frame, _("Client certificates"));
2395
2396         cert_table = gtk_table_new(4,3, FALSE);
2397         gtk_container_add(GTK_CONTAINER(cert_frame), cert_table);
2398         gtk_container_set_border_width(GTK_CONTAINER(cert_table), 8);
2399         gtk_table_set_row_spacings(GTK_TABLE(cert_table), VSPACING_NARROW_2);
2400         gtk_table_set_col_spacings(GTK_TABLE(cert_table), 8);
2401         
2402         label = gtk_label_new(_("Certificate for receiving"));
2403         gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
2404         entry_in_cert_file = gtk_entry_new();
2405         in_ssl_cert_browse_button = gtkut_get_browse_file_btn(_("Browse"));
2406         CLAWS_SET_TIP(label,
2407                              _("Client certificate file as a PKCS12 or PEM file"));
2408         CLAWS_SET_TIP(entry_in_cert_file,
2409                              _("Client certificate file as a PKCS12 or PEM file"));     
2410         gtk_table_attach(GTK_TABLE(cert_table), label, 0, 1, 0, 1, GTK_FILL, 0, 0, 0);
2411         gtk_table_attach(GTK_TABLE(cert_table), entry_in_cert_file, 1, 2, 0, 1,
2412                          GTK_EXPAND|GTK_FILL, 0, 0, 0);
2413         gtk_table_attach(GTK_TABLE(cert_table), in_ssl_cert_browse_button, 2, 3, 0, 1,
2414                          GTK_FILL, 0, 0, 0);
2415
2416         label = gtk_label_new(_("Password"));
2417         gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
2418         entry_in_cert_pass = gtk_entry_new();
2419         gtk_entry_set_visibility(GTK_ENTRY(entry_in_cert_pass), FALSE);
2420         gtk_table_attach(GTK_TABLE(cert_table), label, 0, 1, 1, 2, GTK_FILL, 0, 0, 0);
2421         gtk_table_attach(GTK_TABLE(cert_table), entry_in_cert_pass, 1, 2, 1, 2,
2422                          GTK_FILL, 0, 0, 0);
2423
2424         label = gtk_label_new(_("Certificate for sending"));
2425         gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
2426         entry_out_cert_file = gtk_entry_new();
2427         out_ssl_cert_browse_button = gtkut_get_browse_file_btn(_("Browse"));
2428         CLAWS_SET_TIP(label,
2429                              _("Client certificate file as a PKCS12 or PEM file"));
2430         CLAWS_SET_TIP(entry_out_cert_file,
2431                              _("Client certificate file as a PKCS12 or PEM file"));
2432         gtk_table_attach(GTK_TABLE(cert_table), label, 0, 1, 2, 3, GTK_FILL, 0, 0, 0);
2433         gtk_table_attach(GTK_TABLE(cert_table), entry_out_cert_file, 1, 2, 2, 3,
2434                          GTK_EXPAND|GTK_FILL, 0, 0, 0);
2435         gtk_table_attach(GTK_TABLE(cert_table), out_ssl_cert_browse_button, 2, 3, 2, 3,
2436                          GTK_FILL, 0, 0, 0);
2437
2438         label = gtk_label_new(_("Password"));
2439         gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
2440         entry_out_cert_pass = gtk_entry_new();
2441         gtk_entry_set_visibility(GTK_ENTRY(entry_out_cert_pass), FALSE);
2442         gtk_table_attach(GTK_TABLE(cert_table), label, 0, 1, 3, 4, GTK_FILL, 0, 0, 0);
2443         gtk_table_attach(GTK_TABLE(cert_table), entry_out_cert_pass, 1, 2, 3, 4,
2444                          GTK_FILL, 0, 0, 0);
2445         gtk_widget_show_all(cert_table);
2446
2447         g_signal_connect(G_OBJECT(in_ssl_cert_browse_button), "clicked",
2448                          G_CALLBACK(prefs_account_in_cert_browse_cb), NULL);
2449         g_signal_connect(G_OBJECT(out_ssl_cert_browse_button), "clicked",
2450                          G_CALLBACK(prefs_account_out_cert_browse_cb), NULL);
2451         
2452         vbox7 = gtk_vbox_new (FALSE, 0);
2453         gtk_widget_show (vbox7);
2454         gtk_box_pack_start (GTK_BOX (vbox1), vbox7, FALSE, FALSE, 0);
2455
2456         PACK_CHECK_BUTTON(vbox7, use_nonblocking_ssl_checkbtn,
2457                           _("Use non-blocking SSL"));
2458
2459         hbox = gtk_hbox_new (FALSE, 0);
2460         gtk_widget_show (hbox);
2461         gtk_box_pack_start (GTK_BOX (vbox7), hbox, FALSE, FALSE, 0);
2462
2463         hbox_spc = gtk_hbox_new (FALSE, 0);
2464         gtk_widget_show (hbox_spc);
2465         gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
2466         gtk_widget_set_size_request (hbox_spc, 16, -1);
2467
2468         label = gtk_label_new
2469                 (_("Turn this off if you have SSL connection problems"));
2470         gtk_widget_show (label);
2471         gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
2472         gtkut_widget_set_small_font_size (label);
2473
2474         page->pop_frame               = pop_frame;
2475         page->pop_nossl_radiobtn      = pop_nossl_radiobtn;
2476         page->pop_ssltunnel_radiobtn  = pop_ssltunnel_radiobtn;
2477         page->pop_starttls_radiobtn   = pop_starttls_radiobtn;
2478
2479         page->imap_frame              = imap_frame;
2480         page->imap_nossl_radiobtn     = imap_nossl_radiobtn;
2481         page->imap_ssltunnel_radiobtn = imap_ssltunnel_radiobtn;
2482         page->imap_starttls_radiobtn  = imap_starttls_radiobtn;
2483
2484         page->nntp_frame              = nntp_frame;
2485         page->nntp_nossl_radiobtn     = nntp_nossl_radiobtn;
2486         page->nntp_ssltunnel_radiobtn = nntp_ssltunnel_radiobtn;
2487
2488         page->send_frame              = send_frame;
2489         page->smtp_nossl_radiobtn     = smtp_nossl_radiobtn;
2490         page->smtp_ssltunnel_radiobtn = smtp_ssltunnel_radiobtn;
2491         page->smtp_starttls_radiobtn  = smtp_starttls_radiobtn;
2492
2493         page->entry_in_cert_file      = entry_in_cert_file;
2494         page->entry_in_cert_pass      = entry_in_cert_pass;
2495         page->entry_out_cert_file     = entry_out_cert_file;
2496         page->entry_out_cert_pass     = entry_out_cert_pass;
2497
2498         page->use_nonblocking_ssl_checkbtn = use_nonblocking_ssl_checkbtn;
2499
2500         tmp_ac_prefs = *ac_prefs;
2501
2502         if (new_account) {
2503                 prefs_set_dialog_to_default(ssl_param);
2504         } else
2505                 prefs_set_dialog(ssl_param);
2506
2507         page->vbox = vbox1;
2508
2509         page->page.widget = vbox1;
2510 }
2511
2512 #undef CREATE_RADIO_BUTTONS
2513 #undef CREATE_RADIO_BUTTON
2514 #endif /* USE_GNUTLS */
2515         
2516 static void advanced_create_widget_func(PrefsPage * _page,
2517                                            GtkWindow * window,
2518                                            gpointer data)
2519 {
2520         AdvancedPage *page = (AdvancedPage *) _page;
2521         PrefsAccount *ac_prefs = (PrefsAccount *) data;
2522
2523         GtkWidget *vbox1;
2524         GtkWidget *vbox2;
2525         GtkWidget *hbox1;
2526         GtkWidget *checkbtn_smtpport;
2527         GtkWidget *spinbtn_smtpport;
2528         GtkWidget *hbox_popport;
2529         GtkWidget *checkbtn_popport;
2530         GtkWidget *spinbtn_popport;
2531         GtkWidget *hbox_imapport;
2532         GtkWidget *checkbtn_imapport;
2533         GtkWidget *spinbtn_imapport;
2534         GtkWidget *hbox_nntpport;
2535         GtkWidget *checkbtn_nntpport;
2536         GtkWidget *spinbtn_nntpport;
2537         GtkWidget *checkbtn_domain;
2538         GtkWidget *entry_domain;
2539         gchar *tip_domain;
2540         GtkWidget *checkbtn_msgid_with_addr;
2541         GtkWidget *checkbtn_crosspost;
2542         GtkWidget *colormenu_crosspost;
2543         GtkWidget *menu;
2544 #ifndef G_OS_WIN32
2545         GtkWidget *checkbtn_tunnelcmd;
2546         GtkWidget *entry_tunnelcmd;
2547 #endif
2548         GtkWidget *folder_frame;
2549         GtkWidget *vbox3;
2550         GtkWidget *table;
2551         GtkWidget *sent_folder_checkbtn;
2552         GtkWidget *sent_folder_entry;
2553         GtkWidget *queue_folder_checkbtn;
2554         GtkWidget *queue_folder_entry;
2555         GtkWidget *draft_folder_checkbtn;
2556         GtkWidget *draft_folder_entry;
2557         GtkWidget *trash_folder_checkbtn;
2558         GtkWidget *trash_folder_entry;
2559         CLAWS_TIP_DECL();
2560         GtkSizeGroup *size_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
2561 #define PACK_HBOX(hbox) \
2562         { \
2563         hbox = gtk_hbox_new (FALSE, 8); \
2564         gtk_widget_show (hbox); \
2565         gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0); \
2566         }
2567
2568 #define PACK_PORT_SPINBTN(box, spinbtn) \
2569         { \
2570         spinbtn = gtk_spin_button_new_with_range(0, 65535, 1); \
2571         gtk_widget_show (spinbtn); \
2572         gtk_box_pack_start (GTK_BOX (box), spinbtn, FALSE, FALSE, 0); \
2573         }
2574
2575         vbox1 = gtk_vbox_new (FALSE, VSPACING);
2576         gtk_widget_show (vbox1);
2577         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2578
2579         vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW_2);
2580         gtk_widget_show (vbox2);
2581         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
2582
2583         PACK_HBOX (hbox1);
2584         PACK_CHECK_BUTTON (hbox1, checkbtn_smtpport, _("SMTP port"));
2585         PACK_PORT_SPINBTN (hbox1, spinbtn_smtpport);
2586         SET_TOGGLE_SENSITIVITY (checkbtn_smtpport, spinbtn_smtpport);
2587         gtk_size_group_add_widget(size_group, checkbtn_smtpport);
2588         
2589         PACK_HBOX (hbox_popport);
2590         PACK_CHECK_BUTTON (hbox_popport, checkbtn_popport,
2591                            _("POP3 port"));
2592         PACK_PORT_SPINBTN (hbox_popport, spinbtn_popport);
2593         SET_TOGGLE_SENSITIVITY (checkbtn_popport, spinbtn_popport);
2594         gtk_size_group_add_widget(size_group, checkbtn_popport);
2595
2596         PACK_HBOX (hbox_imapport);
2597         PACK_CHECK_BUTTON (hbox_imapport, checkbtn_imapport,
2598                            _("IMAP4 port"));
2599         PACK_PORT_SPINBTN (hbox_imapport, spinbtn_imapport);
2600         SET_TOGGLE_SENSITIVITY (checkbtn_imapport, spinbtn_imapport);
2601         gtk_size_group_add_widget(size_group, checkbtn_imapport);
2602
2603         PACK_HBOX (hbox_nntpport);
2604         PACK_CHECK_BUTTON (hbox_nntpport, checkbtn_nntpport,
2605                            _("NNTP port"));
2606         PACK_PORT_SPINBTN (hbox_nntpport, spinbtn_nntpport);
2607         SET_TOGGLE_SENSITIVITY (checkbtn_nntpport, spinbtn_nntpport);
2608         gtk_size_group_add_widget(size_group, checkbtn_nntpport);
2609
2610         PACK_HBOX (hbox1);
2611         PACK_CHECK_BUTTON (hbox1, checkbtn_domain, _("Domain name"));
2612         gtk_size_group_add_widget(size_group, checkbtn_domain); 
2613
2614         tip_domain = _("The domain name will be used in the generated "
2615                         "Message-ID, and when connecting to SMTP servers.");
2616
2617         CLAWS_SET_TIP(checkbtn_domain, tip_domain);
2618
2619         entry_domain = gtk_entry_new ();
2620         gtk_widget_show (entry_domain);
2621         gtk_box_pack_start (GTK_BOX (hbox1), entry_domain, TRUE, TRUE, 0);
2622         SET_TOGGLE_SENSITIVITY (checkbtn_domain, entry_domain);
2623         CLAWS_SET_TIP(entry_domain, tip_domain);
2624         PACK_HBOX (hbox1);
2625         PACK_CHECK_BUTTON (hbox1, checkbtn_msgid_with_addr,
2626                            _("Send account mail address in Message-ID"));
2627
2628 #ifndef G_OS_WIN32      
2629         PACK_HBOX (hbox1);
2630         PACK_CHECK_BUTTON (hbox1, checkbtn_tunnelcmd,
2631                            _("Use command to communicate with server"));
2632         entry_tunnelcmd = gtk_entry_new ();
2633         gtk_widget_show (entry_tunnelcmd);
2634         gtk_box_pack_start (GTK_BOX (hbox1), entry_tunnelcmd, TRUE, TRUE, 0);
2635         SET_TOGGLE_SENSITIVITY (checkbtn_tunnelcmd, entry_tunnelcmd);
2636 #endif
2637         PACK_HBOX (hbox1);
2638         PACK_CHECK_BUTTON (hbox1, checkbtn_crosspost, 
2639                            _("Mark cross-posted messages as read and color:"));
2640         g_signal_connect (G_OBJECT (checkbtn_crosspost), "toggled",
2641                           G_CALLBACK (crosspost_color_toggled),
2642                           NULL);
2643
2644         colormenu_crosspost = gtk_cmoption_menu_new();
2645         gtk_widget_show (colormenu_crosspost);
2646         gtk_box_pack_start (GTK_BOX (hbox1), colormenu_crosspost, FALSE, FALSE, 0);
2647
2648         menu = colorlabel_create_color_menu();
2649         gtk_cmoption_menu_set_menu (GTK_CMOPTION_MENU(colormenu_crosspost), menu);
2650         SET_TOGGLE_SENSITIVITY(checkbtn_crosspost, colormenu_crosspost);
2651
2652         PACK_HBOX (hbox1);
2653 #undef PACK_HBOX
2654 #undef PACK_PORT_SPINBTN
2655
2656         /* special folder setting (maybe these options are redundant) */
2657
2658         vbox3 = gtkut_get_options_frame(vbox1, &folder_frame, _("Folder"));
2659
2660         table = gtk_table_new (4, 3, FALSE);
2661         gtk_widget_show (table);
2662         gtk_container_add (GTK_CONTAINER (vbox3), table);
2663         gtk_table_set_row_spacings (GTK_TABLE (table), VSPACING_NARROW_2);
2664         gtk_table_set_col_spacings (GTK_TABLE (table), 4);
2665
2666 #define SET_CHECK_BTN_AND_ENTRY(label, checkbtn, entry, n)              \
2667 {                                                                       \
2668         GtkWidget *button;                                              \
2669                                                                         \
2670         checkbtn = gtk_check_button_new_with_label (label);             \
2671         gtk_widget_show (checkbtn);                                     \
2672         gtk_table_attach (GTK_TABLE (table), checkbtn,                  \
2673                           0, 1, n, n + 1, GTK_FILL, 0, 0, 0);           \
2674                                                                         \
2675         entry = gtk_entry_new ();                                       \
2676         gtk_widget_show (entry);                                        \
2677         gtk_table_attach (GTK_TABLE (table), entry, 1, 2, n, n + 1,     \
2678                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,           \
2679                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);    \
2680                                                                         \
2681         button = gtkut_get_browse_file_btn(_("Browse"));                \
2682         gtk_widget_show (button);                                       \
2683         gtk_table_attach (GTK_TABLE (table), button,                    \
2684                           2, 3, n, n + 1, GTK_FILL, 0, 0, 0);           \
2685         g_signal_connect                                                \
2686                 (G_OBJECT (button), "clicked",                  \
2687                  G_CALLBACK (prefs_account_select_folder_cb),           \
2688                  entry);                                                \
2689                                                                         \
2690         SET_TOGGLE_SENSITIVITY (checkbtn, entry);                               \
2691         SET_TOGGLE_SENSITIVITY (checkbtn, button);                      \
2692 }
2693
2694         SET_CHECK_BTN_AND_ENTRY(_("Put sent messages in"),
2695                                 sent_folder_checkbtn, sent_folder_entry, 0);
2696         SET_CHECK_BTN_AND_ENTRY(_("Put queued messages in"),
2697                                 queue_folder_checkbtn, queue_folder_entry, 1);
2698         SET_CHECK_BTN_AND_ENTRY(_("Put draft messages in"),
2699                                 draft_folder_checkbtn, draft_folder_entry, 2);
2700         SET_CHECK_BTN_AND_ENTRY(_("Put deleted messages in"),
2701                                 trash_folder_checkbtn, trash_folder_entry, 3);
2702
2703         page->smtpport_checkbtn = checkbtn_smtpport;
2704         page->smtpport_spinbtn          = spinbtn_smtpport;
2705         page->popport_hbox              = hbox_popport;
2706         page->popport_checkbtn          = checkbtn_popport;
2707         page->popport_spinbtn           = spinbtn_popport;
2708         page->imapport_hbox             = hbox_imapport;
2709         page->imapport_checkbtn = checkbtn_imapport;
2710         page->imapport_spinbtn          = spinbtn_imapport;
2711         page->nntpport_hbox             = hbox_nntpport;
2712         page->nntpport_checkbtn = checkbtn_nntpport;
2713         page->nntpport_spinbtn          = spinbtn_nntpport;
2714         page->domain_checkbtn           = checkbtn_domain;
2715         page->domain_entry              = entry_domain;
2716         page->msgid_with_addr_checkbtn  = checkbtn_msgid_with_addr;
2717         page->crosspost_checkbtn        = checkbtn_crosspost;
2718         page->crosspost_colormenu       = colormenu_crosspost;
2719
2720 #ifndef G_OS_WIN32
2721         page->tunnelcmd_checkbtn        = checkbtn_tunnelcmd;
2722         page->tunnelcmd_entry   = entry_tunnelcmd;
2723 #endif
2724         page->sent_folder_checkbtn  = sent_folder_checkbtn;
2725         page->sent_folder_entry   = sent_folder_entry;
2726         page->queue_folder_checkbtn  = queue_folder_checkbtn;
2727         page->queue_folder_entry   = queue_folder_entry;
2728         page->draft_folder_checkbtn = draft_folder_checkbtn;
2729         page->draft_folder_entry  = draft_folder_entry;
2730         page->trash_folder_checkbtn = trash_folder_checkbtn;
2731         page->trash_folder_entry  = trash_folder_entry;
2732
2733         tmp_ac_prefs = *ac_prefs;
2734
2735         if (new_account) {
2736                 prefs_set_dialog_to_default(advanced_param);
2737         } else
2738                 prefs_set_dialog(advanced_param);
2739
2740         page->vbox = vbox1;
2741
2742         page->page.widget = vbox1;
2743 }
2744         
2745 static gint prefs_basic_apply(void)
2746 {
2747         RecvProtocol protocol;
2748         gchar *old_id = NULL;
2749         gchar *new_id = NULL;
2750         struct BasicProtocol *protocol_optmenu = (struct BasicProtocol *) basic_page.protocol_optmenu;
2751         GtkWidget *optmenu = protocol_optmenu->combobox;
2752
2753         protocol = combobox_get_active_data(GTK_COMBO_BOX(optmenu));
2754
2755         if (*gtk_entry_get_text(GTK_ENTRY(basic_page.acname_entry)) == '\0') {
2756                 alertpanel_error(_("Account name is not entered."));
2757                 return -1;
2758         }
2759         if (*gtk_entry_get_text(GTK_ENTRY(basic_page.addr_entry)) == '\0') {
2760                 alertpanel_error(_("Mail address is not entered."));
2761                 return -1;
2762         }
2763         if (((protocol == A_POP3) || 
2764              (protocol == A_LOCAL && !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(basic_page.mailcmd_checkbtn))) || 
2765              (protocol == A_NONE)) &&
2766            *gtk_entry_get_text(GTK_ENTRY(basic_page.smtpserv_entry)) == '\0') {
2767                 alertpanel_error(_("SMTP server is not entered."));
2768                 return -1;
2769         }
2770         if ((protocol == A_POP3 || protocol == A_IMAP4) &&
2771             *gtk_entry_get_text(GTK_ENTRY(basic_page.uid_entry)) == '\0') {
2772                 alertpanel_error(_("User ID is not entered."));
2773                 return -1;
2774         }
2775         if (protocol == A_POP3 &&
2776             *gtk_entry_get_text(GTK_ENTRY(basic_page.recvserv_entry)) == '\0') {
2777                 alertpanel_error(_("POP3 server is not entered."));
2778                 return -1;
2779         }
2780         if (protocol == A_POP3 || protocol == A_LOCAL) {
2781                 GtkWidget *inbox_entry = (protocol == A_POP3 ? receive_page.inbox_entry : receive_page.local_inbox_entry );
2782                 const gchar *mailbox = gtk_entry_get_text(GTK_ENTRY(inbox_entry));
2783                 FolderItem *inbox =  folder_find_item_from_identifier(mailbox);
2784                 if (!inbox) {
2785                         gchar *id = NULL;
2786                         setup_write_mailbox_path(mainwindow_get_mainwindow(), "Mail");
2787                         id = folder_item_get_identifier(folder_get_default_inbox_for_class(F_MH));
2788                         gtk_entry_set_text(GTK_ENTRY(receive_page.inbox_entry),
2789                                 id);
2790                         gtk_entry_set_text(GTK_ENTRY(receive_page.local_inbox_entry),
2791                                 id);
2792                         g_free(id);
2793                         mailbox = gtk_entry_get_text(GTK_ENTRY(inbox_entry));
2794                         inbox =  folder_find_item_from_identifier(mailbox);
2795                 }
2796                 if (inbox == NULL) {
2797                         alertpanel_error(_("The default Inbox folder doesn't exist."));
2798                         return -1;
2799                 }
2800         }
2801         if (protocol == A_IMAP4 &&
2802             *gtk_entry_get_text(GTK_ENTRY(basic_page.recvserv_entry)) == '\0') {
2803                 alertpanel_error(_("IMAP4 server is not entered."));
2804                 return -1;
2805         }
2806         if (protocol == A_NNTP &&
2807             *gtk_entry_get_text(GTK_ENTRY(basic_page.nntpserv_entry)) == '\0') {
2808                 alertpanel_error(_("NNTP server is not entered."));
2809                 return -1;
2810         }
2811
2812         if (protocol == A_LOCAL &&
2813             *gtk_entry_get_text(GTK_ENTRY(basic_page.localmbox_entry)) == '\0') {
2814                 alertpanel_error(_("local mailbox filename is not entered."));
2815                 return -1;
2816         }
2817
2818         if (protocol == A_LOCAL &&
2819             gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(basic_page.mailcmd_checkbtn)) && *gtk_entry_get_text(GTK_ENTRY(basic_page.mailcmd_entry)) == '\0') {
2820                 alertpanel_error(_("mail command is not entered."));
2821                 return -1;
2822         }
2823         
2824         if (protocol == A_IMAP4 || protocol == A_NNTP) 
2825                 old_id = g_strdup_printf("#%s/%s",
2826                                 protocol == A_IMAP4 ? "imap":"nntp",
2827                                 tmp_ac_prefs.account_name ? tmp_ac_prefs.account_name : "(null)");
2828         
2829         prefs_set_data_from_dialog(basic_param);
2830         
2831         if (protocol == A_IMAP4 || protocol == A_NNTP) {
2832                 new_id = g_strdup_printf("#%s/%s",
2833                                 protocol == A_IMAP4 ? "imap":"nntp",
2834                                 tmp_ac_prefs.account_name);
2835                 if (old_id != NULL && new_id != NULL)
2836                         prefs_filtering_rename_path(old_id, new_id);
2837                 g_free(old_id);
2838                 g_free(new_id);
2839         }
2840         
2841         return 0;
2842 }
2843
2844 static gint prefs_receive_apply(void)
2845 {
2846         prefs_set_data_from_dialog(receive_param);
2847         return 0;
2848 }
2849
2850 static gint prefs_send_apply(void)
2851 {
2852         prefs_set_data_from_dialog(send_param);
2853         return 0;
2854 }
2855
2856 static gint prefs_compose_apply(void)
2857 {
2858         prefs_set_data_from_dialog(compose_param);
2859         return 0;
2860 }
2861
2862 static gint prefs_templates_apply(void)
2863 {
2864         prefs_set_data_from_dialog(templates_param);
2865         return 0;
2866 }
2867
2868 static gint prefs_privacy_apply(void)
2869 {
2870         prefs_set_data_from_dialog(privacy_param);
2871         return 0;
2872 }
2873
2874 #ifdef USE_GNUTLS
2875 static gint prefs_ssl_apply(void)
2876 {
2877         prefs_set_data_from_dialog(ssl_param);
2878         return 0;
2879 }
2880 #endif
2881
2882 static gint prefs_advanced_apply(void)
2883 {
2884         prefs_set_data_from_dialog(advanced_param);
2885         return 0;
2886 }
2887
2888 static void basic_destroy_widget_func(PrefsPage *_page)
2889 {
2890         /* BasicPage *page = (BasicPage *) _page; */
2891 }
2892
2893 static void receive_destroy_widget_func(PrefsPage *_page)
2894 {
2895         /* ReceivePage *page = (ReceivePage *) _page; */
2896 }
2897
2898 static void send_destroy_widget_func(PrefsPage *_page)
2899 {
2900         /* SendPage *page = (SendPage *) _page; */
2901 }
2902
2903 static void compose_destroy_widget_func(PrefsPage *_page)
2904 {
2905         /* ComposePage *page = (ComposePage *) _page; */
2906 }
2907
2908 static void templates_destroy_widget_func(PrefsPage *_page)
2909 {
2910         /* TemplatesPage *page = (TemplatesPage *) _page; */
2911 }
2912
2913 static void privacy_destroy_widget_func(PrefsPage *_page)
2914 {
2915         /* PrivacyPage *page = (PrivacyPage *) _page; */
2916 }
2917
2918 #ifdef USE_GNUTLS
2919 static void ssl_destroy_widget_func(PrefsPage *_page)
2920 {
2921         /* SSLPage *page = (SSLPage *) _page; */
2922 }
2923 #endif
2924
2925 static void advanced_destroy_widget_func(PrefsPage *_page)
2926 {
2927         /* AdvancedPage *page = (AdvancedPage *) _page; */
2928 }
2929
2930 static gboolean basic_can_close_func(PrefsPage *_page)
2931 {       
2932         BasicPage *page = (BasicPage *) _page;
2933
2934         if (!page->page.page_open)
2935                 return TRUE;
2936
2937         return prefs_basic_apply() >= 0;
2938 }
2939
2940 static gboolean receive_can_close_func(PrefsPage *_page)
2941 {       
2942         ReceivePage *page = (ReceivePage *) _page;
2943
2944         if (!page->page.page_open)
2945                 return TRUE;
2946
2947         return prefs_receive_apply() >= 0;
2948 }
2949
2950 static gboolean send_can_close_func(PrefsPage *_page)
2951 {       
2952         SendPage *page = (SendPage *) _page;
2953
2954         if (!page->page.page_open)
2955                 return TRUE;
2956
2957         return prefs_send_apply() >= 0;
2958 }
2959
2960 static gboolean compose_can_close_func(PrefsPage *_page)
2961 {       
2962         ComposePage *page = (ComposePage *) _page;
2963
2964         if (!page->page.page_open)
2965                 return TRUE;
2966
2967         return prefs_compose_apply() >= 0;
2968 }
2969
2970 static gboolean templates_can_close_func(PrefsPage *_page)
2971 {
2972         TemplatesPage *page = (TemplatesPage *) _page;
2973
2974         if (!page->page.page_open)
2975                 return TRUE;
2976
2977         return prefs_templates_apply() >= 0;
2978 }
2979
2980 static gboolean privacy_can_close_func(PrefsPage *_page)
2981 {
2982         PrivacyPage *page = (PrivacyPage *) _page;
2983
2984         if (!page->page.page_open)
2985                 return TRUE;
2986
2987         return prefs_privacy_apply() >= 0;
2988 }
2989
2990 #ifdef USE_GNUTLS
2991 static gboolean ssl_can_close_func(PrefsPage *_page)
2992 {
2993         SSLPage *page = (SSLPage *) _page;
2994
2995         if (!page->page.page_open)
2996                 return TRUE;
2997
2998         return prefs_ssl_apply() >= 0;
2999 }
3000 #endif
3001
3002 static gboolean advanced_can_close_func(PrefsPage *_page)
3003 {
3004         AdvancedPage *page = (AdvancedPage *) _page;
3005
3006         if (!page->page.page_open)
3007                 return TRUE;
3008
3009         return prefs_advanced_apply() >= 0;
3010 }
3011
3012 static void basic_save_func(PrefsPage *_page)
3013 {
3014         BasicPage *page = (BasicPage *) _page;
3015
3016         if (!page->page.page_open)
3017                 return;
3018
3019         if (prefs_basic_apply() >= 0)
3020                 cancelled = FALSE;
3021 }
3022
3023 static void receive_save_func(PrefsPage *_page)
3024 {
3025         ReceivePage *page = (ReceivePage *) _page;
3026
3027         if (!page->page.page_open)
3028                 return;
3029
3030         if (prefs_receive_apply() >= 0)
3031                 cancelled = FALSE;
3032 }
3033
3034 static void send_save_func(PrefsPage *_page)
3035 {
3036         SendPage *page = (SendPage *) _page;
3037
3038         if (!page->page.page_open)
3039                 return;
3040
3041         if (prefs_send_apply() >= 0)
3042                 cancelled = FALSE;
3043 }
3044
3045 static void compose_save_func(PrefsPage *_page)
3046 {
3047         ComposePage *page = (ComposePage *) _page;
3048
3049         if (!page->page.page_open)
3050                 return;
3051
3052         if (prefs_compose_apply() >= 0)
3053                 cancelled = FALSE;
3054 }
3055
3056 static void templates_save_func(PrefsPage *_page)
3057 {
3058         TemplatesPage *page = (TemplatesPage *) _page;
3059
3060         if (!page->page.page_open)
3061                 return;
3062
3063         quotefmt_check_new_msg_formats(tmp_ac_prefs.compose_with_format,
3064                                                                         NULL,
3065                                                                         tmp_ac_prefs.compose_subject_format,
3066                                                                         tmp_ac_prefs.compose_body_format);
3067         quotefmt_check_reply_formats(tmp_ac_prefs.reply_with_format,
3068                                                                         NULL,
3069                                                                         tmp_ac_prefs.reply_quotemark,
3070                                                                         tmp_ac_prefs.reply_body_format);
3071         quotefmt_check_forward_formats(tmp_ac_prefs.forward_with_format,
3072                                                                         NULL,
3073                                                                         tmp_ac_prefs.forward_quotemark,
3074                                                                         tmp_ac_prefs.forward_body_format);
3075         if (prefs_templates_apply() >= 0)
3076                 cancelled = FALSE;
3077 }
3078
3079 static void privacy_save_func(PrefsPage *_page)
3080 {
3081         PrivacyPage *page = (PrivacyPage *) _page;
3082
3083         if (!page->page.page_open)
3084                 return;
3085
3086         if (prefs_privacy_apply() >= 0)
3087                 cancelled = FALSE;
3088 }
3089
3090 #ifdef USE_GNUTLS
3091 static void ssl_save_func(PrefsPage *_page)
3092 {
3093         SSLPage *page = (SSLPage *) _page;
3094
3095         if (!page->page.page_open)
3096                 return;
3097
3098         if (prefs_ssl_apply() >= 0)
3099                 cancelled = FALSE;
3100 }
3101 #endif
3102
3103 static void advanced_save_func(PrefsPage *_page)
3104 {
3105         AdvancedPage *page = (AdvancedPage *) _page;
3106
3107         if (!page->page.page_open)
3108                 return;
3109
3110         if (prefs_advanced_apply() >= 0)
3111                 cancelled = FALSE;
3112 }
3113
3114 static void register_basic_page(void)
3115 {
3116         static gchar *path[3];
3117
3118         path[0] = _("Account");
3119         path[1] = _("Basic");
3120         path[2] = NULL;
3121         
3122         basic_page.page.path = path;
3123         basic_page.page.weight = 1000.0;
3124         basic_page.page.create_widget = basic_create_widget_func;
3125         basic_page.page.destroy_widget = basic_destroy_widget_func;
3126         basic_page.page.save_page = basic_save_func;
3127         basic_page.page.can_close = basic_can_close_func;
3128
3129         prefs_account_register_page((PrefsPage *) &basic_page);
3130 }
3131
3132 static void register_receive_page(void)
3133 {
3134         static gchar *path[3];
3135
3136         path[0] = _("Account");
3137         path[1] = _("Receive");
3138         path[2] = NULL;
3139         
3140         receive_page.page.path = path;
3141         receive_page.page.weight = 1000.0;
3142         receive_page.page.create_widget = receive_create_widget_func;
3143         receive_page.page.destroy_widget = receive_destroy_widget_func;
3144         receive_page.page.save_page = receive_save_func;
3145         receive_page.page.can_close = receive_can_close_func;
3146
3147         prefs_account_register_page((PrefsPage *) &receive_page);
3148 }
3149
3150 static void register_send_page(void)
3151 {
3152         static gchar *path[3];
3153
3154         path[0] = _("Account");
3155         path[1] = _("Send");
3156         path[2] = NULL;
3157         
3158         send_page.page.path = path;
3159         send_page.page.weight = 1000.0;
3160         send_page.page.create_widget = send_create_widget_func;
3161         send_page.page.destroy_widget = send_destroy_widget_func;
3162         send_page.page.save_page = send_save_func;
3163         send_page.page.can_close = send_can_close_func;
3164
3165         prefs_account_register_page((PrefsPage *) &send_page);
3166 }
3167
3168 static void register_compose_page(void)
3169 {
3170         static gchar *path[3];
3171
3172         path[0] = _("Account");
3173         path[1] = _("Compose");
3174         path[2] = NULL;
3175         
3176         compose_page.page.path = path;
3177         compose_page.page.weight = 1000.0;
3178         compose_page.page.create_widget = compose_create_widget_func;
3179         compose_page.page.destroy_widget = compose_destroy_widget_func;
3180         compose_page.page.save_page = compose_save_func;
3181         compose_page.page.can_close = compose_can_close_func;
3182
3183         prefs_account_register_page((PrefsPage *) &compose_page);
3184 }
3185
3186 static void register_templates_page(void)
3187 {
3188         static gchar *path[3];
3189
3190         path[0] = _("Account");
3191         path[1] = _("Templates");
3192         path[2] = NULL;
3193         
3194         templates_page.page.path = path;
3195         templates_page.page.weight = 1000.0;
3196         templates_page.page.create_widget = templates_create_widget_func;
3197         templates_page.page.destroy_widget = templates_destroy_widget_func;
3198         templates_page.page.save_page = templates_save_func;
3199         templates_page.page.can_close = templates_can_close_func;
3200
3201         prefs_account_register_page((PrefsPage *) &templates_page);
3202 }
3203
3204 static void register_privacy_page(void)
3205 {
3206         static gchar *path[3];
3207
3208         path[0] = _("Account");
3209         path[1] = _("Privacy");
3210         path[2] = NULL;
3211         
3212         privacy_page.page.path = path;
3213         privacy_page.page.weight = 1000.0;
3214         privacy_page.page.create_widget = privacy_create_widget_func;
3215         privacy_page.page.destroy_widget = privacy_destroy_widget_func;
3216         privacy_page.page.save_page = privacy_save_func;
3217         privacy_page.page.can_close = privacy_can_close_func;
3218
3219         prefs_account_register_page((PrefsPage *) &privacy_page);
3220 }
3221
3222 #ifdef USE_GNUTLS
3223 static void register_ssl_page(void)
3224 {
3225         static gchar *path[3];
3226
3227         path[0] = _("Account");
3228         path[1] = _("SSL");
3229         path[2] = NULL;
3230         
3231         ssl_page.page.path = path;
3232         ssl_page.page.weight = 1000.0;
3233         ssl_page.page.create_widget = ssl_create_widget_func;
3234         ssl_page.page.destroy_widget = ssl_destroy_widget_func;
3235         ssl_page.page.save_page = ssl_save_func;
3236         ssl_page.page.can_close = ssl_can_close_func;
3237
3238         prefs_account_register_page((PrefsPage *) &ssl_page);
3239 }
3240
3241 static gboolean sslcert_get_client_cert_hook(gpointer source, gpointer data)
3242 {
3243         SSLClientCertHookData *hookdata = (SSLClientCertHookData *)source;
3244         PrefsAccount *account = (PrefsAccount *)hookdata->account;
3245
3246         hookdata->cert_path = NULL;
3247         hookdata->password = NULL;
3248
3249         if (!g_list_find(account_get_list(), account)) {
3250                 g_warning("can't find sock account\n");
3251                 return TRUE;
3252         }
3253         
3254         if (hookdata->is_smtp) {
3255                 if (account->out_ssl_client_cert_file && *account->out_ssl_client_cert_file)
3256                         hookdata->cert_path = account->out_ssl_client_cert_file;
3257                 if (account->out_ssl_client_cert_pass && *account->out_ssl_client_cert_pass)
3258                         hookdata->password = account->out_ssl_client_cert_pass;
3259         } else {
3260                 if (account->in_ssl_client_cert_file && *account->in_ssl_client_cert_file)
3261                         hookdata->cert_path = account->in_ssl_client_cert_file;
3262                 if (account->in_ssl_client_cert_pass && *account->in_ssl_client_cert_pass)
3263                         hookdata->password = account->in_ssl_client_cert_pass;
3264         }
3265         return TRUE;
3266 }
3267
3268 struct GetPassData {
3269         GCond *cond;
3270         GMutex* mutex;
3271         gchar **pass;
3272 };
3273
3274
3275 static gboolean do_get_pass(gpointer data)
3276 {
3277         struct GetPassData *pass_data = (struct GetPassData *)data;
3278         g_mutex_lock(pass_data->mutex);
3279         *(pass_data->pass) = input_dialog_query_password("the PKCS12 client certificate", NULL);
3280         g_cond_signal(pass_data->cond);
3281         g_mutex_unlock(pass_data->mutex);
3282         return FALSE;
3283 }
3284 static gboolean sslcert_get_password(gpointer source, gpointer data)
3285
3286         struct GetPassData pass_data;
3287         /* do complicated stuff to be able to call GTK from the mainloop */
3288         pass_data.cond = g_cond_new();
3289         pass_data.mutex = g_mutex_new();
3290         pass_data.pass = (gchar **)source;
3291
3292         g_mutex_lock(pass_data.mutex);
3293
3294         g_idle_add(do_get_pass, &pass_data);
3295
3296         g_cond_wait(pass_data.cond, pass_data.mutex);
3297         g_cond_free(pass_data.cond);
3298         g_mutex_unlock(pass_data.mutex);
3299         g_mutex_free(pass_data.mutex);
3300
3301         return TRUE;
3302 }
3303 #endif
3304
3305 static void register_advanced_page(void)
3306 {
3307         static gchar *path[3];
3308
3309         path[0] = _("Account");
3310         path[1] = _("Advanced");
3311         path[2] = NULL;
3312         
3313         advanced_page.page.path = path;
3314         advanced_page.page.weight = 1000.0;
3315         advanced_page.page.create_widget = advanced_create_widget_func;
3316         advanced_page.page.destroy_widget = advanced_destroy_widget_func;
3317         advanced_page.page.save_page = advanced_save_func;
3318         advanced_page.page.can_close = advanced_can_close_func;
3319
3320         prefs_account_register_page((PrefsPage *) &advanced_page);
3321 }
3322
3323 void prefs_account_init()
3324 {
3325         register_basic_page();
3326         register_receive_page();
3327         register_send_page();
3328         register_compose_page();
3329         register_templates_page();
3330         register_privacy_page();
3331 #ifdef USE_GNUTLS
3332         register_ssl_page();
3333         hooks_register_hook(SSLCERT_GET_CLIENT_CERT_HOOKLIST, sslcert_get_client_cert_hook, NULL);
3334         hooks_register_hook(SSL_CERT_GET_PASSWORD, sslcert_get_password, NULL);
3335 #endif
3336         register_advanced_page();
3337 }
3338
3339 PrefsAccount *prefs_account_new(void)
3340 {
3341         PrefsAccount *ac_prefs;
3342
3343         ac_prefs = g_new0(PrefsAccount, 1);
3344         memset(&tmp_ac_prefs, 0, sizeof(PrefsAccount));
3345         prefs_set_default(basic_param);
3346         prefs_set_default(receive_param);
3347         prefs_set_default(send_param);
3348         prefs_set_default(compose_param);
3349         prefs_set_default(templates_param);
3350         prefs_set_default(privacy_param);
3351         prefs_set_default(ssl_param);
3352         prefs_set_default(advanced_param);
3353         *ac_prefs = tmp_ac_prefs;
3354         ac_prefs->account_id = prefs_account_get_new_id();
3355
3356         ac_prefs->privacy_prefs = g_hash_table_new(g_str_hash, g_str_equal);
3357
3358         return ac_prefs;
3359 }
3360
3361 void prefs_account_read_config(PrefsAccount *ac_prefs, const gchar *label)
3362 {
3363         const gchar *p = label;
3364         gchar *rcpath;
3365         gint id;
3366         gchar **strv, **cur;
3367
3368         cm_return_if_fail(ac_prefs != NULL);
3369         cm_return_if_fail(label != NULL);
3370
3371         memset(&tmp_ac_prefs, 0, sizeof(PrefsAccount));
3372         tmp_ac_prefs.privacy_prefs = ac_prefs->privacy_prefs;
3373
3374         rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, ACCOUNT_RC, NULL);
3375         prefs_read_config(basic_param, label, rcpath, NULL);
3376         prefs_read_config(receive_param, label, rcpath, NULL);
3377         prefs_read_config(send_param, label, rcpath, NULL);
3378         prefs_read_config(compose_param, label, rcpath, NULL);
3379         prefs_read_config(templates_param, label, rcpath, NULL);
3380         prefs_read_config(privacy_param, label, rcpath, NULL);
3381         prefs_read_config(ssl_param, label, rcpath, NULL);
3382         prefs_read_config(advanced_param, label, rcpath, NULL);
3383         g_free(rcpath);
3384
3385         *ac_prefs = tmp_ac_prefs;
3386         while (*p && !g_ascii_isdigit(*p)) p++;
3387         id = atoi(p);
3388         if (id < 0) g_warning("wrong account id: %d\n", id);
3389         ac_prefs->account_id = id;
3390
3391         if (ac_prefs->protocol == A_APOP) {
3392                 debug_print("converting protocol A_APOP to new prefs.\n");
3393                 ac_prefs->protocol = A_POP3;
3394                 ac_prefs->use_apop_auth = TRUE;
3395         }
3396
3397         if (privacy_prefs != NULL) {
3398                 strv = g_strsplit(privacy_prefs, ",", 0);
3399                 for (cur = strv; *cur != NULL; cur++) {
3400                         gchar *encvalue, *value;
3401
3402                         encvalue = strchr(*cur, '=');
3403                         if (encvalue == NULL)
3404                                 continue;
3405                         encvalue[0] = '\0';
3406                         encvalue++;
3407
3408                         value = g_malloc0(strlen(encvalue));
3409                         if (base64_decode(value, encvalue, strlen(encvalue)) > 0)
3410                                 g_hash_table_insert(ac_prefs->privacy_prefs, g_strdup(*cur), g_strdup(value));
3411                         g_free(value);
3412                 }
3413                 g_strfreev(strv);
3414                 g_free(privacy_prefs);
3415                 privacy_prefs = NULL;
3416         }
3417
3418         prefs_custom_header_read_config(ac_prefs);
3419 }
3420
3421 static void create_privacy_prefs(gpointer key, gpointer _value, gpointer user_data)
3422 {
3423         GString *str = (GString *) user_data;
3424         gchar *encvalue;
3425         gchar *value = (gchar *) _value;
3426
3427         if (str->len > 0)
3428                 g_string_append_c(str, ',');
3429
3430         encvalue = g_malloc0(B64LEN(strlen(value)) + 1);
3431         base64_encode(encvalue, (gchar *) value, strlen(value));
3432         g_string_append_printf(str, "%s=%s", (gchar *) key, encvalue);
3433         g_free(encvalue);
3434 }
3435
3436 #define WRITE_PARAM(PARAM_TABLE) \
3437                 if (prefs_write_param(PARAM_TABLE, pfile->fp) < 0) { \
3438                         g_warning("failed to write configuration to file\n"); \
3439                         prefs_file_close_revert(pfile); \
3440                         g_free(privacy_prefs); \
3441                         privacy_prefs = NULL; \
3442                         return; \
3443                 }
3444
3445 void prefs_account_write_config_all(GList *account_list)
3446 {
3447         GList *cur;
3448         gchar *rcpath;
3449         PrefFile *pfile;
3450
3451         rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, ACCOUNT_RC, NULL);
3452         if ((pfile = prefs_write_open(rcpath)) == NULL) {
3453                 g_free(rcpath);
3454                 return;
3455         }
3456         g_free(rcpath);
3457
3458         for (cur = account_list; cur != NULL; cur = cur->next) {
3459                 GString *str;
3460
3461                 tmp_ac_prefs = *(PrefsAccount *)cur->data;
3462                 if (fprintf(pfile->fp, "[Account: %d]\n",
3463                             tmp_ac_prefs.account_id) <= 0)
3464                         return;
3465
3466                 str = g_string_sized_new(32);
3467                 g_hash_table_foreach(tmp_ac_prefs.privacy_prefs, create_privacy_prefs, str);
3468                 privacy_prefs = str->str;                   
3469                 g_string_free(str, FALSE);
3470
3471                 WRITE_PARAM(basic_param)
3472                 WRITE_PARAM(receive_param)
3473                 WRITE_PARAM(send_param)
3474                 WRITE_PARAM(compose_param)
3475                 WRITE_PARAM(templates_param)
3476                 WRITE_PARAM(privacy_param)
3477                 WRITE_PARAM(ssl_param)
3478                 WRITE_PARAM(advanced_param)
3479
3480                 g_free(privacy_prefs);
3481                 privacy_prefs = NULL;
3482
3483                 if (cur->next) {
3484                         if (fputc('\n', pfile->fp) == EOF) {
3485                                 FILE_OP_ERROR(rcpath, "fputc");
3486                                 prefs_file_close_revert(pfile);
3487                                 return;
3488                         }
3489                 }
3490         }
3491
3492         if (prefs_file_close(pfile) < 0)
3493                 g_warning("failed to write configuration to file\n");
3494 }
3495 #undef WRITE_PARAM
3496
3497 static gboolean free_privacy_prefs(gpointer key, gpointer value, gpointer user_data)
3498 {
3499         g_free(key);
3500         g_free(value);
3501
3502         return TRUE;
3503 }
3504
3505 void prefs_account_free(PrefsAccount *ac_prefs)
3506 {
3507         if (!ac_prefs) return;
3508