2011-01-06 [pawel] 3.7.8cvs33
[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 (
1969                                 prefs_common_translated_header_name("Cc"));
1970         gtk_widget_show (autocc_checkbtn);
1971         gtk_table_attach (GTK_TABLE (table), autocc_checkbtn, 0, 1, 0, 1,
1972                           GTK_FILL, 0, 0, 0);
1973
1974         autocc_entry = gtk_entry_new ();
1975         gtk_widget_show (autocc_entry);
1976         gtk_table_attach (GTK_TABLE (table), autocc_entry, 1, 2, 0, 1,
1977                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1978                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1979
1980         SET_TOGGLE_SENSITIVITY (autocc_checkbtn, autocc_entry);
1981
1982         autobcc_checkbtn = gtk_check_button_new_with_label (
1983                                 prefs_common_translated_header_name("Bcc"));
1984         gtk_widget_show (autobcc_checkbtn);
1985         gtk_table_attach (GTK_TABLE (table), autobcc_checkbtn, 0, 1, 1, 2,
1986                           GTK_FILL, 0, 0, 0);
1987
1988         autobcc_entry = gtk_entry_new ();
1989         gtk_widget_show (autobcc_entry);
1990         gtk_table_attach (GTK_TABLE (table), autobcc_entry, 1, 2, 1, 2,
1991                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1992                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1993
1994         SET_TOGGLE_SENSITIVITY (autobcc_checkbtn, autobcc_entry);
1995
1996         autoreplyto_checkbtn = gtk_check_button_new_with_label (
1997                                 prefs_common_translated_header_name("Reply-To"));
1998         gtk_widget_show (autoreplyto_checkbtn);
1999         gtk_table_attach (GTK_TABLE (table), autoreplyto_checkbtn, 0, 1, 2, 3,
2000                           GTK_FILL, 0, 0, 0);
2001
2002         autoreplyto_entry = gtk_entry_new ();
2003         gtk_widget_show (autoreplyto_entry);
2004         gtk_table_attach (GTK_TABLE (table), autoreplyto_entry, 1, 2, 2, 3,
2005                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,
2006                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
2007
2008         SET_TOGGLE_SENSITIVITY (autoreplyto_checkbtn, autoreplyto_entry);
2009
2010 #if USE_ENCHANT
2011         PACK_FRAME (vbox1, frame_dict, _("Spell check dictionaries"));
2012
2013         table_dict =  gtk_table_new (2, 2, FALSE);
2014         gtk_widget_show (table_dict);
2015         gtk_container_add (GTK_CONTAINER (frame_dict), table_dict);
2016         gtk_container_set_border_width (GTK_CONTAINER (table_dict), 8);
2017         gtk_table_set_row_spacings (GTK_TABLE (table_dict), VSPACING_NARROW_2);
2018         gtk_table_set_col_spacings (GTK_TABLE (table_dict), 8);
2019
2020         /* Default dictionary */
2021         checkbtn_enable_default_dictionary = gtk_check_button_new_with_label(_("Default dictionary"));
2022         gtk_table_attach(GTK_TABLE(table_dict), checkbtn_enable_default_dictionary, 0, 1,
2023                         0, 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
2024         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_default_dictionary),
2025                         tmp_ac_prefs.enable_default_dictionary);
2026
2027         combo_default_dictionary = gtkaspell_dictionary_combo_new(TRUE);
2028         gtk_table_attach(GTK_TABLE(table_dict), combo_default_dictionary, 1, 2,
2029                         0, 1, GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
2030
2031         SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_dictionary, combo_default_dictionary);
2032
2033         /* Default dictionary */
2034         checkbtn_enable_default_alt_dictionary = gtk_check_button_new_with_label(_("Default alternate dictionary"));
2035         gtk_table_attach(GTK_TABLE(table_dict), checkbtn_enable_default_alt_dictionary, 0, 1,
2036                         1, 2, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
2037         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_enable_default_alt_dictionary),
2038                         tmp_ac_prefs.enable_default_alt_dictionary);
2039
2040         combo_default_alt_dictionary = gtkaspell_dictionary_combo_new(FALSE);
2041         gtk_table_attach(GTK_TABLE(table_dict), combo_default_alt_dictionary, 1, 2,
2042                         1, 2, GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
2043
2044         SET_TOGGLE_SENSITIVITY(checkbtn_enable_default_alt_dictionary, combo_default_alt_dictionary);
2045
2046         gtk_widget_show_all(table_dict);
2047 #endif
2048
2049         page->sigfile_radiobtn = sigfile_radiobtn;
2050         page->entry_sigpath      = entry_sigpath;
2051         page->checkbtn_autosig   = checkbtn_autosig;
2052         page->entry_sigsep       = entry_sigsep;
2053
2054         page->autocc_checkbtn      = autocc_checkbtn;
2055         page->autocc_entry       = autocc_entry;
2056         page->autobcc_checkbtn     = autobcc_checkbtn;
2057         page->autobcc_entry      = autobcc_entry;
2058         page->autoreplyto_checkbtn = autoreplyto_checkbtn;
2059         page->autoreplyto_entry  = autoreplyto_entry;
2060 #ifdef USE_ENCHANT
2061         page->checkbtn_enable_default_dictionary = checkbtn_enable_default_dictionary;
2062         page->combo_default_dictionary = combo_default_dictionary;
2063         page->checkbtn_enable_default_alt_dictionary = checkbtn_enable_default_alt_dictionary;
2064         page->combo_default_alt_dictionary = combo_default_alt_dictionary;
2065 #endif
2066
2067 #ifdef USE_ENCHANT
2068         /* reset gtkaspell menus */
2069         if (compose_page.combo_default_dictionary != NULL) {
2070                 gtk_combo_box_set_model(GTK_COMBO_BOX(compose_page.combo_default_dictionary),
2071                                         gtkaspell_dictionary_store_new());
2072                 gtk_combo_box_set_model(GTK_COMBO_BOX(compose_page.combo_default_alt_dictionary),
2073                                         gtkaspell_dictionary_store_new_with_refresh(
2074                                                 FALSE));
2075         }
2076 #endif
2077
2078         tmp_ac_prefs = *ac_prefs;
2079
2080         if (new_account) {
2081                 prefs_set_dialog_to_default(compose_param);
2082         } else
2083                 prefs_set_dialog(compose_param);
2084
2085         page->vbox = vbox1;
2086
2087         page->page.widget = vbox1;
2088 }
2089         
2090 static void templates_create_widget_func(PrefsPage * _page,
2091                                            GtkWindow * window,
2092                                            gpointer data)
2093 {
2094         TemplatesPage *page = (TemplatesPage *) _page;
2095         PrefsAccount *ac_prefs = (PrefsAccount *) data;
2096         GtkWidget *vbox;
2097         GtkWidget *vbox2;
2098         GtkWidget *notebook;
2099
2100         vbox = gtk_vbox_new(FALSE, 0);
2101         gtk_widget_show(vbox);
2102         
2103         notebook = gtk_notebook_new();
2104         gtk_widget_show(notebook);
2105         gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0);
2106
2107         /* compose format */
2108         vbox2 = gtk_vbox_new (FALSE, VSPACING);
2109         gtk_widget_show (vbox2);
2110         gtk_container_set_border_width (GTK_CONTAINER (vbox2), VBOX_BORDER);
2111
2112         quotefmt_create_new_msg_fmt_widgets(
2113                                 window,
2114                                 vbox2,
2115                                 &page->checkbtn_compose_with_format,
2116                                 NULL,
2117                                 &page->compose_subject_format,
2118                                 &page->compose_body_format,
2119                                 TRUE, NULL);
2120         gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox2, gtk_label_new(_("Compose")));
2121
2122         /* reply format */      
2123         vbox2 = gtk_vbox_new (FALSE, VSPACING);
2124         gtk_widget_show (vbox2);
2125         gtk_container_set_border_width (GTK_CONTAINER (vbox2), VBOX_BORDER);
2126         
2127         quotefmt_create_reply_fmt_widgets(
2128                                 window,
2129                                 vbox2,
2130                                 &page->checkbtn_reply_with_format,
2131                                 NULL,
2132                                 &page->reply_quotemark,
2133                                 &page->reply_body_format,
2134                                 TRUE, NULL);
2135         gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox2, gtk_label_new(_("Reply")));
2136
2137         /* forward format */    
2138         vbox2 = gtk_vbox_new (FALSE, VSPACING);
2139         gtk_widget_show (vbox2);
2140         gtk_container_set_border_width (GTK_CONTAINER (vbox2), VBOX_BORDER);
2141
2142         quotefmt_create_forward_fmt_widgets(
2143                                 window,
2144                                 vbox2,
2145                                 &page->checkbtn_forward_with_format,
2146                                 NULL,
2147                                 &page->forward_quotemark,
2148                                 &page->forward_body_format,
2149                                 TRUE, NULL);
2150         gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox2, gtk_label_new(_("Forward")));
2151
2152         tmp_ac_prefs = *ac_prefs;
2153
2154         if (new_account) {
2155                 prefs_set_dialog_to_default(templates_param);
2156         } else
2157                 prefs_set_dialog(templates_param);
2158
2159         page->vbox = vbox;
2160
2161         page->page.widget = vbox;
2162 }
2163
2164 static void privacy_create_widget_func(PrefsPage * _page,
2165                                            GtkWindow * window,
2166                                            gpointer data)
2167 {
2168         PrivacyPage *page = (PrivacyPage *) _page;
2169         PrefsAccount *ac_prefs = (PrefsAccount *) data;
2170
2171         GtkWidget *vbox1;
2172         GtkWidget *vbox2;
2173         GtkWidget *hbox1;
2174         GtkWidget *label;
2175         GtkWidget *default_privacy_system;
2176         GtkListStore *menu;
2177         GtkCellRenderer *rend;
2178         GtkWidget *default_encrypt_checkbtn;
2179         GtkWidget *default_encrypt_reply_checkbtn;
2180         GtkWidget *default_sign_checkbtn;
2181         GtkWidget *default_sign_reply_checkbtn;
2182         GtkWidget *save_clear_text_checkbtn;
2183         GtkWidget *encrypt_to_self_checkbtn;
2184
2185         vbox1 = gtk_vbox_new (FALSE, VSPACING);
2186         gtk_widget_show (vbox1);
2187         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2188
2189         vbox2 = gtk_vbox_new (FALSE, 0);
2190         gtk_widget_show (vbox2);
2191         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
2192
2193         hbox1 = gtk_hbox_new(FALSE, 8);
2194         gtk_widget_show (hbox1);
2195         gtk_container_add (GTK_CONTAINER(vbox2), hbox1);
2196
2197         label = gtk_label_new(_("Default privacy system"));
2198         gtk_widget_show(label);
2199         gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
2200
2201         /* Can't use gtkut_sc_combobox_create() here, because model for this
2202          * combobox needs an extra string column to store privacy plugin id. */
2203         menu = gtk_list_store_new(4,
2204                         G_TYPE_STRING,
2205                         G_TYPE_INT,
2206                         G_TYPE_BOOLEAN,
2207                         G_TYPE_STRING); /* This is where we store the privacy plugin id. */
2208         default_privacy_system = gtk_combo_box_new_with_model(GTK_TREE_MODEL(menu));
2209
2210         rend = gtk_cell_renderer_text_new();
2211         gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(default_privacy_system), rend, TRUE);
2212         gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(default_privacy_system), rend,
2213                         "text", COMBOBOX_TEXT,
2214                         "sensitive", COMBOBOX_SENS,
2215                         NULL);
2216         gtk_combo_box_set_focus_on_click(GTK_COMBO_BOX(default_privacy_system), FALSE);
2217
2218         gtk_widget_show (default_privacy_system);
2219         gtk_box_pack_start (GTK_BOX(hbox1), default_privacy_system, FALSE, TRUE, 0);
2220
2221         g_signal_connect(G_OBJECT(default_privacy_system), "changed",
2222                          G_CALLBACK(privacy_system_activated),
2223                          NULL);
2224
2225         PACK_CHECK_BUTTON (vbox2, default_sign_checkbtn,
2226                            _("Always sign messages"));
2227         PACK_CHECK_BUTTON (vbox2, default_encrypt_checkbtn,
2228                            _("Always encrypt messages"));
2229         PACK_CHECK_BUTTON (vbox2, default_sign_reply_checkbtn,
2230                            _("Always sign messages when replying to a "
2231                              "signed message"));
2232         PACK_CHECK_BUTTON (vbox2, default_encrypt_reply_checkbtn,
2233                            _("Always encrypt messages when replying to an "
2234                              "encrypted message"));
2235         PACK_CHECK_BUTTON (vbox2, encrypt_to_self_checkbtn,
2236                            _("Encrypt sent messages with your own key in addition to recipient's"));
2237         PACK_CHECK_BUTTON (vbox2, save_clear_text_checkbtn,
2238                            _("Save sent encrypted messages as clear text"));
2239
2240         SET_TOGGLE_SENSITIVITY_REVERSE(encrypt_to_self_checkbtn, save_clear_text_checkbtn);
2241         SET_TOGGLE_SENSITIVITY_REVERSE(save_clear_text_checkbtn, encrypt_to_self_checkbtn);
2242
2243         page->default_privacy_system = default_privacy_system;
2244         page->default_encrypt_checkbtn = default_encrypt_checkbtn;
2245         page->default_encrypt_reply_checkbtn = default_encrypt_reply_checkbtn;
2246         page->default_sign_reply_checkbtn = default_sign_reply_checkbtn;
2247         page->default_sign_checkbtn    = default_sign_checkbtn;
2248         page->save_clear_text_checkbtn = save_clear_text_checkbtn;
2249         page->encrypt_to_self_checkbtn = encrypt_to_self_checkbtn;
2250
2251         update_privacy_system_menu();
2252
2253         tmp_ac_prefs = *ac_prefs;
2254
2255         if (new_account) {
2256                 prefs_set_dialog_to_default(privacy_param);
2257         } else
2258                 prefs_set_dialog(privacy_param);
2259
2260         page->vbox = vbox1;
2261
2262         page->page.widget = vbox1;
2263 }
2264         
2265 #ifdef USE_GNUTLS
2266
2267 #define CREATE_RADIO_BUTTON(box, btn, btn_p, label, data)               \
2268 {                                                                       \
2269         btn = gtk_radio_button_new_with_label_from_widget               \
2270                 (GTK_RADIO_BUTTON (btn_p), label);                      \
2271         gtk_widget_show (btn);                                          \
2272         gtk_box_pack_start (GTK_BOX (box), btn, FALSE, FALSE, 0);       \
2273         g_object_set_data (G_OBJECT (btn),                              \
2274                            MENU_VAL_ID,                                 \
2275                            GINT_TO_POINTER (data));                     \
2276 }
2277
2278 #define CREATE_RADIO_BUTTONS(box,                                       \
2279                              btn1, btn1_label, btn1_data,               \
2280                              btn2, btn2_label, btn2_data,               \
2281                              btn3, btn3_label, btn3_data)               \
2282 {                                                                       \
2283         btn1 = gtk_radio_button_new_with_label(NULL, btn1_label);       \
2284         gtk_widget_show (btn1);                                         \
2285         gtk_box_pack_start (GTK_BOX (box), btn1, FALSE, FALSE, 0);      \
2286         g_object_set_data (G_OBJECT (btn1),                             \
2287                            MENU_VAL_ID,                                 \
2288                            GINT_TO_POINTER (btn1_data));                \
2289                                                                         \
2290         CREATE_RADIO_BUTTON(box, btn2, btn1, btn2_label, btn2_data);    \
2291         CREATE_RADIO_BUTTON(box, btn3, btn1, btn3_label, btn3_data);    \
2292 }
2293
2294 static void pop_ssltunnel_toggled(GtkToggleButton *button,
2295                                         gpointer data)
2296 {
2297         gboolean active = gtk_toggle_button_get_active(button);
2298         
2299         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
2300                         advanced_page.popport_checkbtn)) == TRUE)
2301                 return;
2302         gtk_spin_button_set_value(GTK_SPIN_BUTTON(advanced_page.popport_spinbtn),
2303                                   active ? 995 : 110);
2304 }
2305
2306 static void imap_ssltunnel_toggled(GtkToggleButton *button,
2307                                         gpointer data)
2308 {
2309         gboolean active = gtk_toggle_button_get_active(button);
2310         
2311         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
2312                         advanced_page.imapport_checkbtn)) == TRUE)
2313                 return;
2314         gtk_spin_button_set_value(GTK_SPIN_BUTTON(advanced_page.imapport_spinbtn),
2315                                   active ? 993 : 143);
2316 }
2317
2318 static void nntp_ssltunnel_toggled(GtkToggleButton *button,
2319                                         gpointer data)
2320 {
2321         gboolean active = gtk_toggle_button_get_active(button);
2322         
2323         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
2324                         advanced_page.nntpport_checkbtn)) == TRUE)
2325                 return;
2326         gtk_spin_button_set_value(GTK_SPIN_BUTTON(advanced_page.nntpport_spinbtn),
2327                                   active ? 563 : 119);
2328 }       
2329
2330 static void smtp_ssltunnel_toggled(GtkToggleButton *button,
2331                                         gpointer data)
2332 {
2333         gboolean active = gtk_toggle_button_get_active(button);
2334         
2335         if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
2336                         advanced_page.smtpport_checkbtn)) == TRUE)
2337                 return;
2338         gtk_spin_button_set_value(GTK_SPIN_BUTTON(advanced_page.smtpport_spinbtn),
2339                                   active ? 465 : 25);   
2340 }
2341
2342 static void ssl_create_widget_func(PrefsPage * _page,
2343                                            GtkWindow * window,
2344                                            gpointer data)
2345 {
2346         SSLPage *page = (SSLPage *) _page;
2347         PrefsAccount *ac_prefs = (PrefsAccount *) data;
2348
2349         GtkWidget *vbox1;
2350
2351         GtkWidget *pop_frame;
2352         GtkWidget *vbox2;
2353         GtkWidget *pop_nossl_radiobtn;
2354         GtkWidget *pop_ssltunnel_radiobtn;
2355         GtkWidget *pop_starttls_radiobtn;
2356
2357         GtkWidget *imap_frame;
2358         GtkWidget *vbox3;
2359         GtkWidget *imap_nossl_radiobtn;
2360         GtkWidget *imap_ssltunnel_radiobtn;
2361         GtkWidget *imap_starttls_radiobtn;
2362
2363         GtkWidget *nntp_frame;
2364         GtkWidget *vbox4;
2365         GtkWidget *nntp_nossl_radiobtn;
2366         GtkWidget *nntp_ssltunnel_radiobtn;
2367
2368         GtkWidget *send_frame;
2369         GtkWidget *vbox5;
2370         GtkWidget *smtp_nossl_radiobtn;
2371         GtkWidget *smtp_ssltunnel_radiobtn;
2372         GtkWidget *smtp_starttls_radiobtn;
2373
2374         GtkWidget *cert_frame;
2375         GtkWidget *cert_table;
2376         GtkWidget *entry_in_cert_pass;
2377         GtkWidget *entry_out_cert_pass;
2378
2379         GtkWidget *vbox7;
2380         GtkWidget *use_nonblocking_ssl_checkbtn;
2381         GtkWidget *hbox;
2382         GtkWidget *hbox_spc;
2383         GtkWidget *label;
2384         CLAWS_TIP_DECL();
2385
2386         vbox1 = gtk_vbox_new (FALSE, VSPACING);
2387         gtk_widget_show (vbox1);
2388         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2389
2390         vbox2 = gtkut_get_options_frame(vbox1, &pop_frame, _("POP3"));
2391
2392         CREATE_RADIO_BUTTONS(vbox2,
2393                              pop_nossl_radiobtn,
2394                              _("Don't use SSL"),
2395                              SSL_NONE,
2396                              pop_ssltunnel_radiobtn,
2397                              _("Use SSL for POP3 connection"),
2398                              SSL_TUNNEL,
2399                              pop_starttls_radiobtn,
2400                              _("Use STARTTLS command to start SSL session"),
2401                              SSL_STARTTLS);
2402         g_signal_connect(G_OBJECT(pop_ssltunnel_radiobtn), "toggled",
2403                          G_CALLBACK(pop_ssltunnel_toggled), NULL);
2404         
2405         vbox3 = gtkut_get_options_frame(vbox1, &imap_frame, _("IMAP4"));
2406
2407         CREATE_RADIO_BUTTONS(vbox3,
2408                              imap_nossl_radiobtn,
2409                              _("Don't use SSL"),
2410                              SSL_NONE,
2411                              imap_ssltunnel_radiobtn,
2412                              _("Use SSL for IMAP4 connection"),
2413                              SSL_TUNNEL,
2414                              imap_starttls_radiobtn,
2415                              _("Use STARTTLS command to start SSL session"),
2416                              SSL_STARTTLS);
2417         g_signal_connect(G_OBJECT(imap_ssltunnel_radiobtn), "toggled",
2418                          G_CALLBACK(imap_ssltunnel_toggled), NULL);
2419
2420         vbox4 = gtkut_get_options_frame(vbox1, &nntp_frame, _("NNTP"));
2421
2422         nntp_nossl_radiobtn =
2423                 gtk_radio_button_new_with_label (NULL, _("Don't use SSL"));
2424         gtk_widget_show (nntp_nossl_radiobtn);
2425         gtk_box_pack_start (GTK_BOX (vbox4), nntp_nossl_radiobtn,
2426                             FALSE, FALSE, 0);
2427         g_object_set_data (G_OBJECT (nntp_nossl_radiobtn),
2428                            MENU_VAL_ID,
2429                            GINT_TO_POINTER (SSL_NONE));
2430
2431         CREATE_RADIO_BUTTON(vbox4, nntp_ssltunnel_radiobtn, nntp_nossl_radiobtn,
2432                             _("Use SSL for NNTP connection"), SSL_TUNNEL);
2433         g_signal_connect(G_OBJECT(nntp_ssltunnel_radiobtn), "toggled",
2434                          G_CALLBACK(nntp_ssltunnel_toggled), NULL);
2435
2436         vbox5 = gtkut_get_options_frame(vbox1, &send_frame, _("Send (SMTP)"));
2437
2438         CREATE_RADIO_BUTTONS(vbox5,
2439                              smtp_nossl_radiobtn,
2440                              _("Don't use SSL (but, if necessary, use STARTTLS)"),
2441                              SSL_NONE,
2442                              smtp_ssltunnel_radiobtn,
2443                              _("Use SSL for SMTP connection"),
2444                              SSL_TUNNEL,
2445                              smtp_starttls_radiobtn,
2446                              _("Use STARTTLS command to start SSL session"),
2447                              SSL_STARTTLS);
2448         g_signal_connect(G_OBJECT(smtp_ssltunnel_radiobtn), "toggled",
2449                          G_CALLBACK(smtp_ssltunnel_toggled), NULL);
2450
2451         PACK_FRAME(vbox1, cert_frame, _("Client certificates"));
2452
2453         cert_table = gtk_table_new(4,3, FALSE);
2454         gtk_container_add(GTK_CONTAINER(cert_frame), cert_table);
2455         gtk_container_set_border_width(GTK_CONTAINER(cert_table), 8);
2456         gtk_table_set_row_spacings(GTK_TABLE(cert_table), VSPACING_NARROW_2);
2457         gtk_table_set_col_spacings(GTK_TABLE(cert_table), 8);
2458         
2459         label = gtk_label_new(_("Certificate for receiving"));
2460         gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
2461         entry_in_cert_file = gtk_entry_new();
2462         in_ssl_cert_browse_button = gtkut_get_browse_file_btn(_("Browse"));
2463         CLAWS_SET_TIP(label,
2464                              _("Client certificate file as a PKCS12 or PEM file"));
2465         CLAWS_SET_TIP(entry_in_cert_file,
2466                              _("Client certificate file as a PKCS12 or PEM file"));     
2467         gtk_table_attach(GTK_TABLE(cert_table), label, 0, 1, 0, 1, GTK_FILL, 0, 0, 0);
2468         gtk_table_attach(GTK_TABLE(cert_table), entry_in_cert_file, 1, 2, 0, 1,
2469                          GTK_EXPAND|GTK_FILL, 0, 0, 0);
2470         gtk_table_attach(GTK_TABLE(cert_table), in_ssl_cert_browse_button, 2, 3, 0, 1,
2471                          GTK_FILL, 0, 0, 0);
2472
2473         label = gtk_label_new(_("Password"));
2474         gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
2475         entry_in_cert_pass = gtk_entry_new();
2476         gtk_entry_set_visibility(GTK_ENTRY(entry_in_cert_pass), FALSE);
2477         gtk_table_attach(GTK_TABLE(cert_table), label, 0, 1, 1, 2, GTK_FILL, 0, 0, 0);
2478         gtk_table_attach(GTK_TABLE(cert_table), entry_in_cert_pass, 1, 2, 1, 2,
2479                          GTK_FILL, 0, 0, 0);
2480
2481         label = gtk_label_new(_("Certificate for sending"));
2482         gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
2483         entry_out_cert_file = gtk_entry_new();
2484         out_ssl_cert_browse_button = gtkut_get_browse_file_btn(_("Browse"));
2485         CLAWS_SET_TIP(label,
2486                              _("Client certificate file as a PKCS12 or PEM file"));
2487         CLAWS_SET_TIP(entry_out_cert_file,
2488                              _("Client certificate file as a PKCS12 or PEM file"));
2489         gtk_table_attach(GTK_TABLE(cert_table), label, 0, 1, 2, 3, GTK_FILL, 0, 0, 0);
2490         gtk_table_attach(GTK_TABLE(cert_table), entry_out_cert_file, 1, 2, 2, 3,
2491                          GTK_EXPAND|GTK_FILL, 0, 0, 0);
2492         gtk_table_attach(GTK_TABLE(cert_table), out_ssl_cert_browse_button, 2, 3, 2, 3,
2493                          GTK_FILL, 0, 0, 0);
2494
2495         label = gtk_label_new(_("Password"));
2496         gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
2497         entry_out_cert_pass = gtk_entry_new();
2498         gtk_entry_set_visibility(GTK_ENTRY(entry_out_cert_pass), FALSE);
2499         gtk_table_attach(GTK_TABLE(cert_table), label, 0, 1, 3, 4, GTK_FILL, 0, 0, 0);
2500         gtk_table_attach(GTK_TABLE(cert_table), entry_out_cert_pass, 1, 2, 3, 4,
2501                          GTK_FILL, 0, 0, 0);
2502         gtk_widget_show_all(cert_table);
2503
2504         g_signal_connect(G_OBJECT(in_ssl_cert_browse_button), "clicked",
2505                          G_CALLBACK(prefs_account_in_cert_browse_cb), NULL);
2506         g_signal_connect(G_OBJECT(out_ssl_cert_browse_button), "clicked",
2507                          G_CALLBACK(prefs_account_out_cert_browse_cb), NULL);
2508         
2509         vbox7 = gtk_vbox_new (FALSE, 0);
2510         gtk_widget_show (vbox7);
2511         gtk_box_pack_start (GTK_BOX (vbox1), vbox7, FALSE, FALSE, 0);
2512
2513         PACK_CHECK_BUTTON(vbox7, use_nonblocking_ssl_checkbtn,
2514                           _("Use non-blocking SSL"));
2515
2516         hbox = gtk_hbox_new (FALSE, 0);
2517         gtk_widget_show (hbox);
2518         gtk_box_pack_start (GTK_BOX (vbox7), hbox, FALSE, FALSE, 0);
2519
2520         hbox_spc = gtk_hbox_new (FALSE, 0);
2521         gtk_widget_show (hbox_spc);
2522         gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
2523         gtk_widget_set_size_request (hbox_spc, 16, -1);
2524
2525         label = gtk_label_new
2526                 (_("Turn this off if you have SSL connection problems"));
2527         gtk_widget_show (label);
2528         gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
2529         gtkut_widget_set_small_font_size (label);
2530
2531         page->pop_frame               = pop_frame;
2532         page->pop_nossl_radiobtn      = pop_nossl_radiobtn;
2533         page->pop_ssltunnel_radiobtn  = pop_ssltunnel_radiobtn;
2534         page->pop_starttls_radiobtn   = pop_starttls_radiobtn;
2535
2536         page->imap_frame              = imap_frame;
2537         page->imap_nossl_radiobtn     = imap_nossl_radiobtn;
2538         page->imap_ssltunnel_radiobtn = imap_ssltunnel_radiobtn;
2539         page->imap_starttls_radiobtn  = imap_starttls_radiobtn;
2540
2541         page->nntp_frame              = nntp_frame;
2542         page->nntp_nossl_radiobtn     = nntp_nossl_radiobtn;
2543         page->nntp_ssltunnel_radiobtn = nntp_ssltunnel_radiobtn;
2544
2545         page->send_frame              = send_frame;
2546         page->smtp_nossl_radiobtn     = smtp_nossl_radiobtn;
2547         page->smtp_ssltunnel_radiobtn = smtp_ssltunnel_radiobtn;
2548         page->smtp_starttls_radiobtn  = smtp_starttls_radiobtn;
2549
2550         page->entry_in_cert_file      = entry_in_cert_file;
2551         page->entry_in_cert_pass      = entry_in_cert_pass;
2552         page->entry_out_cert_file     = entry_out_cert_file;
2553         page->entry_out_cert_pass     = entry_out_cert_pass;
2554
2555         page->use_nonblocking_ssl_checkbtn = use_nonblocking_ssl_checkbtn;
2556
2557         tmp_ac_prefs = *ac_prefs;
2558
2559         if (new_account) {
2560                 prefs_set_dialog_to_default(ssl_param);
2561         } else
2562                 prefs_set_dialog(ssl_param);
2563
2564         page->vbox = vbox1;
2565
2566         page->page.widget = vbox1;
2567 }
2568
2569 #undef CREATE_RADIO_BUTTONS
2570 #undef CREATE_RADIO_BUTTON
2571 #endif /* USE_GNUTLS */
2572         
2573 static void advanced_create_widget_func(PrefsPage * _page,
2574                                            GtkWindow * window,
2575                                            gpointer data)
2576 {
2577         AdvancedPage *page = (AdvancedPage *) _page;
2578         PrefsAccount *ac_prefs = (PrefsAccount *) data;
2579
2580         GtkWidget *vbox1;
2581         GtkWidget *vbox2;
2582         GtkWidget *hbox1;
2583         GtkWidget *checkbtn_smtpport;
2584         GtkWidget *spinbtn_smtpport;
2585         GtkWidget *hbox_popport;
2586         GtkWidget *checkbtn_popport;
2587         GtkWidget *spinbtn_popport;
2588         GtkWidget *hbox_imapport;
2589         GtkWidget *checkbtn_imapport;
2590         GtkWidget *spinbtn_imapport;
2591         GtkWidget *hbox_nntpport;
2592         GtkWidget *checkbtn_nntpport;
2593         GtkWidget *spinbtn_nntpport;
2594         GtkWidget *checkbtn_domain;
2595         GtkWidget *entry_domain;
2596         gchar *tip_domain;
2597         GtkWidget *checkbtn_msgid_with_addr;
2598         GtkWidget *checkbtn_crosspost;
2599         GtkWidget *colormenu_crosspost;
2600         GtkWidget *menu;
2601 #ifndef G_OS_WIN32
2602         GtkWidget *checkbtn_tunnelcmd;
2603         GtkWidget *entry_tunnelcmd;
2604 #endif
2605         GtkWidget *folder_frame;
2606         GtkWidget *vbox3;
2607         GtkWidget *table;
2608         GtkWidget *sent_folder_checkbtn;
2609         GtkWidget *sent_folder_entry;
2610         GtkWidget *queue_folder_checkbtn;
2611         GtkWidget *queue_folder_entry;
2612         GtkWidget *draft_folder_checkbtn;
2613         GtkWidget *draft_folder_entry;
2614         GtkWidget *trash_folder_checkbtn;
2615         GtkWidget *trash_folder_entry;
2616         CLAWS_TIP_DECL();
2617         GtkSizeGroup *size_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
2618 #define PACK_HBOX(hbox) \
2619         { \
2620         hbox = gtk_hbox_new (FALSE, 8); \
2621         gtk_widget_show (hbox); \
2622         gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0); \
2623         }
2624
2625 #define PACK_PORT_SPINBTN(box, spinbtn) \
2626         { \
2627         spinbtn = gtk_spin_button_new_with_range(0, 65535, 1); \
2628         gtk_widget_show (spinbtn); \
2629         gtk_box_pack_start (GTK_BOX (box), spinbtn, FALSE, FALSE, 0); \
2630         }
2631
2632         vbox1 = gtk_vbox_new (FALSE, VSPACING);
2633         gtk_widget_show (vbox1);
2634         gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
2635
2636         vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW_2);
2637         gtk_widget_show (vbox2);
2638         gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
2639
2640         PACK_HBOX (hbox1);
2641         PACK_CHECK_BUTTON (hbox1, checkbtn_smtpport, _("SMTP port"));
2642         PACK_PORT_SPINBTN (hbox1, spinbtn_smtpport);
2643         SET_TOGGLE_SENSITIVITY (checkbtn_smtpport, spinbtn_smtpport);
2644         gtk_size_group_add_widget(size_group, checkbtn_smtpport);
2645         
2646         PACK_HBOX (hbox_popport);
2647         PACK_CHECK_BUTTON (hbox_popport, checkbtn_popport,
2648                            _("POP3 port"));
2649         PACK_PORT_SPINBTN (hbox_popport, spinbtn_popport);
2650         SET_TOGGLE_SENSITIVITY (checkbtn_popport, spinbtn_popport);
2651         gtk_size_group_add_widget(size_group, checkbtn_popport);
2652
2653         PACK_HBOX (hbox_imapport);
2654         PACK_CHECK_BUTTON (hbox_imapport, checkbtn_imapport,
2655                            _("IMAP4 port"));
2656         PACK_PORT_SPINBTN (hbox_imapport, spinbtn_imapport);
2657         SET_TOGGLE_SENSITIVITY (checkbtn_imapport, spinbtn_imapport);
2658         gtk_size_group_add_widget(size_group, checkbtn_imapport);
2659
2660         PACK_HBOX (hbox_nntpport);
2661         PACK_CHECK_BUTTON (hbox_nntpport, checkbtn_nntpport,
2662                            _("NNTP port"));
2663         PACK_PORT_SPINBTN (hbox_nntpport, spinbtn_nntpport);
2664         SET_TOGGLE_SENSITIVITY (checkbtn_nntpport, spinbtn_nntpport);
2665         gtk_size_group_add_widget(size_group, checkbtn_nntpport);
2666
2667         PACK_HBOX (hbox1);
2668         PACK_CHECK_BUTTON (hbox1, checkbtn_domain, _("Domain name"));
2669         gtk_size_group_add_widget(size_group, checkbtn_domain); 
2670
2671         tip_domain = _("The domain name will be used in the generated "
2672                         "Message-ID, and when connecting to SMTP servers.");
2673
2674         CLAWS_SET_TIP(checkbtn_domain, tip_domain);
2675
2676         entry_domain = gtk_entry_new ();
2677         gtk_widget_show (entry_domain);
2678         gtk_box_pack_start (GTK_BOX (hbox1), entry_domain, TRUE, TRUE, 0);
2679         SET_TOGGLE_SENSITIVITY (checkbtn_domain, entry_domain);
2680         CLAWS_SET_TIP(entry_domain, tip_domain);
2681         PACK_HBOX (hbox1);
2682         PACK_CHECK_BUTTON (hbox1, checkbtn_msgid_with_addr,
2683                            _("Send account mail address in Message-ID"));
2684
2685 #ifndef G_OS_WIN32      
2686         PACK_HBOX (hbox1);
2687         PACK_CHECK_BUTTON (hbox1, checkbtn_tunnelcmd,
2688                            _("Use command to communicate with server"));
2689         entry_tunnelcmd = gtk_entry_new ();
2690         gtk_widget_show (entry_tunnelcmd);
2691         gtk_box_pack_start (GTK_BOX (hbox1), entry_tunnelcmd, TRUE, TRUE, 0);
2692         SET_TOGGLE_SENSITIVITY (checkbtn_tunnelcmd, entry_tunnelcmd);
2693 #endif
2694         PACK_HBOX (hbox1);
2695         PACK_CHECK_BUTTON (hbox1, checkbtn_crosspost, 
2696                            _("Mark cross-posted messages as read and color:"));
2697         g_signal_connect (G_OBJECT (checkbtn_crosspost), "toggled",
2698                           G_CALLBACK (crosspost_color_toggled),
2699                           NULL);
2700
2701         colormenu_crosspost = gtk_cmoption_menu_new();
2702         gtk_widget_show (colormenu_crosspost);
2703         gtk_box_pack_start (GTK_BOX (hbox1), colormenu_crosspost, FALSE, FALSE, 0);
2704
2705         menu = colorlabel_create_color_menu();
2706         gtk_cmoption_menu_set_menu (GTK_CMOPTION_MENU(colormenu_crosspost), menu);
2707         SET_TOGGLE_SENSITIVITY(checkbtn_crosspost, colormenu_crosspost);
2708
2709         PACK_HBOX (hbox1);
2710 #undef PACK_HBOX
2711 #undef PACK_PORT_SPINBTN
2712
2713         /* special folder setting (maybe these options are redundant) */
2714
2715         vbox3 = gtkut_get_options_frame(vbox1, &folder_frame, _("Folder"));
2716
2717         table = gtk_table_new (4, 3, FALSE);
2718         gtk_widget_show (table);
2719         gtk_container_add (GTK_CONTAINER (vbox3), table);
2720         gtk_table_set_row_spacings (GTK_TABLE (table), VSPACING_NARROW_2);
2721         gtk_table_set_col_spacings (GTK_TABLE (table), 4);
2722
2723 #define SET_CHECK_BTN_AND_ENTRY(label, checkbtn, entry, n)              \
2724 {                                                                       \
2725         GtkWidget *button;                                              \
2726                                                                         \
2727         checkbtn = gtk_check_button_new_with_label (label);             \
2728         gtk_widget_show (checkbtn);                                     \
2729         gtk_table_attach (GTK_TABLE (table), checkbtn,                  \
2730                           0, 1, n, n + 1, GTK_FILL, 0, 0, 0);           \
2731                                                                         \
2732         entry = gtk_entry_new ();                                       \
2733         gtk_widget_show (entry);                                        \
2734         gtk_table_attach (GTK_TABLE (table), entry, 1, 2, n, n + 1,     \
2735                           GTK_EXPAND | GTK_SHRINK | GTK_FILL,           \
2736                           GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);    \
2737                                                                         \
2738         button = gtkut_get_browse_file_btn(_("Browse"));                \
2739         gtk_widget_show (button);                                       \
2740         gtk_table_attach (GTK_TABLE (table), button,                    \
2741                           2, 3, n, n + 1, GTK_FILL, 0, 0, 0);           \
2742         g_signal_connect                                                \
2743                 (G_OBJECT (button), "clicked",                  \
2744                  G_CALLBACK (prefs_account_select_folder_cb),           \
2745                  entry);                                                \
2746                                                                         \
2747         SET_TOGGLE_SENSITIVITY (checkbtn, entry);                               \
2748         SET_TOGGLE_SENSITIVITY (checkbtn, button);                      \
2749 }
2750
2751         SET_CHECK_BTN_AND_ENTRY(_("Put sent messages in"),
2752                                 sent_folder_checkbtn, sent_folder_entry, 0);
2753         SET_CHECK_BTN_AND_ENTRY(_("Put queued messages in"),
2754                                 queue_folder_checkbtn, queue_folder_entry, 1);
2755         SET_CHECK_BTN_AND_ENTRY(_("Put draft messages in"),
2756                                 draft_folder_checkbtn, draft_folder_entry, 2);
2757         SET_CHECK_BTN_AND_ENTRY(_("Put deleted messages in"),
2758                                 trash_folder_checkbtn, trash_folder_entry, 3);
2759
2760         page->smtpport_checkbtn = checkbtn_smtpport;
2761         page->smtpport_spinbtn          = spinbtn_smtpport;
2762         page->popport_hbox              = hbox_popport;
2763         page->popport_checkbtn          = checkbtn_popport;
2764         page->popport_spinbtn           = spinbtn_popport;
2765         page->imapport_hbox             = hbox_imapport;
2766         page->imapport_checkbtn = checkbtn_imapport;
2767         page->imapport_spinbtn          = spinbtn_imapport;
2768         page->nntpport_hbox             = hbox_nntpport;
2769         page->nntpport_checkbtn = checkbtn_nntpport;
2770         page->nntpport_spinbtn          = spinbtn_nntpport;
2771         page->domain_checkbtn           = checkbtn_domain;
2772         page->domain_entry              = entry_domain;
2773         page->msgid_with_addr_checkbtn  = checkbtn_msgid_with_addr;
2774         page->crosspost_checkbtn        = checkbtn_crosspost;
2775         page->crosspost_colormenu       = colormenu_crosspost;
2776
2777 #ifndef G_OS_WIN32
2778         page->tunnelcmd_checkbtn        = checkbtn_tunnelcmd;
2779         page->tunnelcmd_entry   = entry_tunnelcmd;
2780 #endif
2781         page->sent_folder_checkbtn  = sent_folder_checkbtn;
2782         page->sent_folder_entry   = sent_folder_entry;
2783         page->queue_folder_checkbtn  = queue_folder_checkbtn;
2784         page->queue_folder_entry   = queue_folder_entry;
2785         page->draft_folder_checkbtn = draft_folder_checkbtn;
2786         page->draft_folder_entry  = draft_folder_entry;
2787         page->trash_folder_checkbtn = trash_folder_checkbtn;
2788         page->trash_folder_entry  = trash_folder_entry;
2789
2790         tmp_ac_prefs = *ac_prefs;
2791
2792         if (new_account) {
2793                 prefs_set_dialog_to_default(advanced_param);
2794         } else
2795                 prefs_set_dialog(advanced_param);
2796
2797         page->vbox = vbox1;
2798
2799         page->page.widget = vbox1;
2800 }
2801         
2802 static gint prefs_basic_apply(void)
2803 {
2804         RecvProtocol protocol;
2805         gchar *old_id = NULL;
2806         gchar *new_id = NULL;
2807         struct BasicProtocol *protocol_optmenu = (struct BasicProtocol *) basic_page.protocol_optmenu;
2808         GtkWidget *optmenu = protocol_optmenu->combobox;
2809
2810         protocol = combobox_get_active_data(GTK_COMBO_BOX(optmenu));
2811
2812         if (*gtk_entry_get_text(GTK_ENTRY(basic_page.acname_entry)) == '\0') {
2813                 alertpanel_error(_("Account name is not entered."));
2814                 return -1;
2815         }
2816         if (*gtk_entry_get_text(GTK_ENTRY(basic_page.addr_entry)) == '\0') {
2817                 alertpanel_error(_("Mail address is not entered."));
2818                 return -1;
2819         }
2820         if (((protocol == A_POP3) || 
2821              (protocol == A_LOCAL && !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(basic_page.mailcmd_checkbtn))) || 
2822              (protocol == A_NONE)) &&
2823            *gtk_entry_get_text(GTK_ENTRY(basic_page.smtpserv_entry)) == '\0') {
2824                 alertpanel_error(_("SMTP server is not entered."));
2825                 return -1;
2826         }
2827         if ((protocol == A_POP3 || protocol == A_IMAP4) &&
2828             *gtk_entry_get_text(GTK_ENTRY(basic_page.uid_entry)) == '\0') {
2829                 alertpanel_error(_("User ID is not entered."));
2830                 return -1;
2831         }
2832         if (protocol == A_POP3 &&
2833             *gtk_entry_get_text(GTK_ENTRY(basic_page.recvserv_entry)) == '\0') {
2834                 alertpanel_error(_("POP3 server is not entered."));
2835                 return -1;
2836         }
2837         if (protocol == A_POP3 || protocol == A_LOCAL) {
2838                 GtkWidget *inbox_entry = (protocol == A_POP3 ? receive_page.inbox_entry : receive_page.local_inbox_entry );
2839                 const gchar *mailbox = gtk_entry_get_text(GTK_ENTRY(inbox_entry));
2840                 FolderItem *inbox =  folder_find_item_from_identifier(mailbox);
2841                 if (!inbox) {
2842                         gchar *id = NULL;
2843                         setup_write_mailbox_path(mainwindow_get_mainwindow(), "Mail");
2844                         id = folder_item_get_identifier(folder_get_default_inbox_for_class(F_MH));
2845                         gtk_entry_set_text(GTK_ENTRY(receive_page.inbox_entry),
2846                                 id);
2847                         gtk_entry_set_text(GTK_ENTRY(receive_page.local_inbox_entry),
2848                                 id);
2849                         g_free(id);
2850                         mailbox = gtk_entry_get_text(GTK_ENTRY(inbox_entry));
2851                         inbox =  folder_find_item_from_identifier(mailbox);
2852                 }
2853                 if (inbox == NULL) {
2854                         alertpanel_error(_("The default Inbox folder doesn't exist."));
2855                         return -1;
2856                 }
2857         }
2858         if (protocol == A_IMAP4 &&
2859             *gtk_entry_get_text(GTK_ENTRY(basic_page.recvserv_entry)) == '\0') {
2860                 alertpanel_error(_("IMAP4 server is not entered."));
2861                 return -1;
2862         }
2863         if (protocol == A_NNTP &&
2864             *gtk_entry_get_text(GTK_ENTRY(basic_page.nntpserv_entry)) == '\0') {
2865                 alertpanel_error(_("NNTP server is not entered."));
2866                 return -1;
2867         }
2868
2869         if (protocol == A_LOCAL &&
2870             *gtk_entry_get_text(GTK_ENTRY(basic_page.localmbox_entry)) == '\0') {
2871                 alertpanel_error(_("local mailbox filename is not entered."));
2872                 return -1;
2873         }
2874
2875         if (protocol == A_LOCAL &&
2876             gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(basic_page.mailcmd_checkbtn)) && *gtk_entry_get_text(GTK_ENTRY(basic_page.mailcmd_entry)) == '\0') {
2877                 alertpanel_error(_("mail command is not entered."));
2878                 return -1;
2879         }
2880         
2881         if (protocol == A_IMAP4 || protocol == A_NNTP) 
2882                 old_id = g_strdup_printf("#%s/%s",
2883                                 protocol == A_IMAP4 ? "imap":"nntp",
2884                                 tmp_ac_prefs.account_name ? tmp_ac_prefs.account_name : "(null)");
2885         
2886         prefs_set_data_from_dialog(basic_param);
2887         
2888         if (protocol == A_IMAP4 || protocol == A_NNTP) {
2889                 new_id = g_strdup_printf("#%s/%s",
2890                                 protocol == A_IMAP4 ? "imap":"nntp",
2891                                 tmp_ac_prefs.account_name);
2892                 if (old_id != NULL && new_id != NULL)
2893                         prefs_filtering_rename_path(old_id, new_id);
2894                 g_free(old_id);
2895                 g_free(new_id);
2896         }
2897         
2898         return 0;
2899 }
2900
2901 static gint prefs_receive_apply(void)
2902 {
2903         prefs_set_data_from_dialog(receive_param);
2904         return 0;
2905 }
2906
2907 static gint prefs_send_apply(void)
2908 {
2909         prefs_set_data_from_dialog(send_param);
2910         return 0;
2911 }
2912
2913 static gint prefs_compose_apply(void)
2914 {
2915         prefs_set_data_from_dialog(compose_param);
2916         return 0;
2917 }
2918
2919 static gint prefs_templates_apply(void)
2920 {
2921         prefs_set_data_from_dialog(templates_param);
2922         return 0;
2923 }
2924
2925 static gint prefs_privacy_apply(void)
2926 {
2927         prefs_set_data_from_dialog(privacy_param);
2928         return 0;
2929 }
2930
2931 #ifdef USE_GNUTLS
2932 static gint prefs_ssl_apply(void)
2933 {
2934         prefs_set_data_from_dialog(ssl_param);
2935         return 0;
2936 }
2937 #endif
2938
2939 static gint prefs_advanced_apply(void)
2940 {
2941         prefs_set_data_from_dialog(advanced_param);
2942         return 0;
2943 }
2944
2945 static void basic_destroy_widget_func(PrefsPage *_page)
2946 {
2947         /* BasicPage *page = (BasicPage *) _page; */
2948 }
2949
2950 static void receive_destroy_widget_func(PrefsPage *_page)
2951 {
2952         /* ReceivePage *page = (ReceivePage *) _page; */
2953 }
2954
2955 static void send_destroy_widget_func(PrefsPage *_page)
2956 {
2957         /* SendPage *page = (SendPage *) _page; */
2958 }
2959
2960 static void compose_destroy_widget_func(PrefsPage *_page)
2961 {
2962         /* ComposePage *page = (ComposePage *) _page; */
2963 }
2964
2965 static void templates_destroy_widget_func(PrefsPage *_page)
2966 {
2967         /* TemplatesPage *page = (TemplatesPage *) _page; */
2968 }
2969
2970 static void privacy_destroy_widget_func(PrefsPage *_page)
2971 {
2972         /* PrivacyPage *page = (PrivacyPage *) _page; */
2973 }
2974
2975 #ifdef USE_GNUTLS
2976 static void ssl_destroy_widget_func(PrefsPage *_page)
2977 {
2978         /* SSLPage *page = (SSLPage *) _page; */
2979 }
2980 #endif
2981
2982 static void advanced_destroy_widget_func(PrefsPage *_page)
2983 {
2984         /* AdvancedPage *page = (AdvancedPage *) _page; */
2985 }
2986
2987 static gboolean basic_can_close_func(PrefsPage *_page)
2988 {       
2989         BasicPage *page = (BasicPage *) _page;
2990
2991         if (!page->page.page_open)
2992                 return TRUE;
2993
2994         return prefs_basic_apply() >= 0;
2995 }
2996
2997 static gboolean receive_can_close_func(PrefsPage *_page)
2998 {       
2999         ReceivePage *page = (ReceivePage *) _page;
3000
3001         if (!page->page.page_open)
3002                 return TRUE;
3003
3004         return prefs_receive_apply() >= 0;
3005 }
3006
3007 static gboolean send_can_close_func(PrefsPage *_page)
3008 {       
3009         SendPage *page = (SendPage *) _page;
3010
3011         if (!page->page.page_open)
3012                 return TRUE;
3013
3014         return prefs_send_apply() >= 0;
3015 }
3016
3017 static gboolean compose_can_close_func(PrefsPage *_page)
3018 {       
3019         ComposePage *page = (ComposePage *) _page;
3020
3021         if (!page->page.page_open)
3022                 return TRUE;
3023
3024         return prefs_compose_apply() >= 0;
3025 }
3026
3027 static gboolean templates_can_close_func(PrefsPage *_page)
3028 {
3029         TemplatesPage *page = (TemplatesPage *) _page;
3030
3031         if (!page->page.page_open)
3032                 return TRUE;
3033
3034         return prefs_templates_apply() >= 0;
3035 }
3036
3037 static gboolean privacy_can_close_func(PrefsPage *_page)
3038 {
3039         PrivacyPage *page = (PrivacyPage *) _page;
3040
3041         if (!page->page.page_open)
3042                 return TRUE;
3043
3044         return prefs_privacy_apply() >= 0;
3045 }
3046
3047 #ifdef USE_GNUTLS
3048 static gboolean ssl_can_close_func(PrefsPage *_page)
3049 {
3050         SSLPage *page = (SSLPage *) _page;
3051
3052         if (!page->page.page_open)
3053                 return TRUE;
3054
3055         return prefs_ssl_apply() >= 0;
3056 }
3057 #endif
3058
3059 static gboolean advanced_can_close_func(PrefsPage *_page)
3060 {
3061         AdvancedPage *page = (AdvancedPage *) _page;
3062
3063         if (!page->page.page_open)
3064                 return TRUE;
3065
3066         return prefs_advanced_apply() >= 0;
3067 }
3068
3069 static void basic_save_func(PrefsPage *_page)
3070 {
3071         BasicPage *page = (BasicPage *) _page;
3072
3073         if (!page->page.page_open)
3074                 return;
3075
3076         if (prefs_basic_apply() >= 0)
3077                 cancelled = FALSE;
3078 }
3079
3080 static void receive_save_func(PrefsPage *_page)
3081 {
3082         ReceivePage *page = (ReceivePage *) _page;
3083
3084         if (!page->page.page_open)
3085                 return;
3086
3087         if (prefs_receive_apply() >= 0)
3088                 cancelled = FALSE;
3089 }
3090
3091 static void send_save_func(PrefsPage *_page)
3092 {
3093         SendPage *page = (SendPage *) _page;
3094
3095         if (!page->page.page_open)
3096                 return;
3097
3098         if (prefs_send_apply() >= 0)
3099                 cancelled = FALSE;
3100 }
3101
3102 static void compose_save_func(PrefsPage *_page)
3103 {
3104         ComposePage *page = (ComposePage *) _page;
3105
3106         if (!page->page.page_open)
3107                 return;
3108
3109         if (prefs_compose_apply() >= 0)
3110                 cancelled = FALSE;
3111 }
3112
3113 static void templates_save_func(PrefsPage *_page)
3114 {
3115         TemplatesPage *page = (TemplatesPage *) _page;
3116
3117         if (!page->page.page_open)
3118                 return;
3119
3120         quotefmt_check_new_msg_formats(tmp_ac_prefs.compose_with_format,
3121                                                                         NULL,
3122                                                                         tmp_ac_prefs.compose_subject_format,
3123                                                                         tmp_ac_prefs.compose_body_format);
3124         quotefmt_check_reply_formats(tmp_ac_prefs.reply_with_format,
3125                                                                         NULL,
3126                                                                         tmp_ac_prefs.reply_quotemark,
3127                                                                         tmp_ac_prefs.reply_body_format);
3128         quotefmt_check_forward_formats(tmp_ac_prefs.forward_with_format,
3129                                                                         NULL,
3130                                                                         tmp_ac_prefs.forward_quotemark,
3131                                                                         tmp_ac_prefs.forward_body_format);
3132         if (prefs_templates_apply() >= 0)
3133                 cancelled = FALSE;
3134 }
3135
3136 static void privacy_save_func(PrefsPage *_page)
3137 {
3138         PrivacyPage *page = (PrivacyPage *) _page;
3139
3140         if (!page->page.page_open)
3141                 return;
3142
3143         if (prefs_privacy_apply() >= 0)
3144                 cancelled = FALSE;
3145 }
3146
3147 #ifdef USE_GNUTLS
3148 static void ssl_save_func(PrefsPage *_page)
3149 {
3150         SSLPage *page = (SSLPage *) _page;
3151
3152         if (!page->page.page_open)
3153                 return;
3154
3155         if (prefs_ssl_apply() >= 0)
3156                 cancelled = FALSE;
3157 }
3158 #endif
3159
3160 static void advanced_save_func(PrefsPage *_page)
3161 {
3162         AdvancedPage *page = (AdvancedPage *) _page;
3163
3164         if (!page->page.page_open)
3165                 return;
3166
3167         if (prefs_advanced_apply() >= 0)
3168                 cancelled = FALSE;
3169 }
3170
3171 static void register_basic_page(void)
3172 {
3173         static gchar *path[3];
3174
3175         path[0] = _("Account");
3176         path[1] = _("Basic");
3177         path[2] = NULL;
3178         
3179         basic_page.page.path = path;
3180         basic_page.page.weight = 1000.0;
3181         basic_page.page.create_widget = basic_create_widget_func;
3182         basic_page.page.destroy_widget = basic_destroy_widget_func;
3183         basic_page.page.save_page = basic_save_func;
3184         basic_page.page.can_close = basic_can_close_func;
3185
3186         prefs_account_register_page((PrefsPage *) &basic_page);
3187 }
3188
3189 static void register_receive_page(void)
3190 {
3191         static gchar *path[3];
3192
3193         path[0] = _("Account");
3194         path[1] = _("Receive");
3195         path[2] = NULL;
3196         
3197         receive_page.page.path = path;
3198         receive_page.page.weight = 1000.0;
3199         receive_page.page.create_widget = receive_create_widget_func;
3200         receive_page.page.destroy_widget = receive_destroy_widget_func;
3201         receive_page.page.save_page = receive_save_func;
3202         receive_page.page.can_close = receive_can_close_func;
3203
3204         prefs_account_register_page((PrefsPage *) &receive_page);
3205 }
3206
3207 static void register_send_page(void)
3208 {
3209         static gchar *path[3];
3210
3211         path[0] = _("Account");
3212         path[1] = _("Send");
3213         path[2] = NULL;
3214         
3215         send_page.page.path = path;
3216         send_page.page.weight = 1000.0;
3217         send_page.page.create_widget = send_create_widget_func;
3218         send_page.page.destroy_widget = send_destroy_widget_func;
3219         send_page.page.save_page = send_save_func;
3220         send_page.page.can_close = send_can_close_func;
3221
3222         prefs_account_register_page((PrefsPage *) &send_page);
3223 }
3224
3225 static void register_compose_page(void)
3226 {
3227         static gchar *path[3];
3228
3229         path[0] = _("Account");
3230         path[1] = _("Compose");
3231         path[2] = NULL;
3232         
3233         compose_page.page.path = path;
3234         compose_page.page.weight = 1000.0;
3235         compose_page.page.create_widget = compose_create_widget_func;
3236         compose_page.page.destroy_widget = compose_destroy_widget_func;
3237         compose_page.page.save_page = compose_save_func;
3238         compose_page.page.can_close = compose_can_close_func;
3239
3240         prefs_account_register_page((PrefsPage *) &compose_page);
3241 }
3242
3243 static void register_templates_page(void)
3244 {
3245         static gchar *path[3];
3246
3247         path[0] = _("Account");
3248         path[1] = _("Templates");
3249         path[2] = NULL;
3250         
3251         templates_page.page.path = path;
3252         templates_page.page.weight = 1000.0;
3253         templates_page.page.create_widget = templates_create_widget_func;
3254         templates_page.page.destroy_widget = templates_destroy_widget_func;
3255         templates_page.page.save_page = templates_save_func;
3256         templates_page.page.can_close = templates_can_close_func;
3257
3258         prefs_account_register_page((PrefsPage *) &templates_page);
3259 }
3260
3261 static void register_privacy_page(void)
3262 {
3263         static gchar *path[3];
3264
3265         path[0] = _("Account");
3266         path[1] = _("Privacy");
3267         path[2] = NULL;
3268         
3269         privacy_page.page.path = path;
3270         privacy_page.page.weight = 1000.0;
3271         privacy_page.page.create_widget = privacy_create_widget_func;
3272         privacy_page.page.destroy_widget = privacy_destroy_widget_func;
3273         privacy_page.page.save_page = privacy_save_func;
3274         privacy_page.page.can_close = privacy_can_close_func;
3275
3276         prefs_account_register_page((PrefsPage *) &privacy_page);
3277 }
3278
3279 #ifdef USE_GNUTLS
3280 static void register_ssl_page(void)
3281 {
3282         static gchar *path[3];
3283
3284         path[0] = _("Account");
3285         path[1] = _("SSL");
3286         path[2] = NULL;
3287         
3288         ssl_page.page.path = path;
3289         ssl_page.page.weight = 1000.0;
3290         ssl_page.page.create_widget = ssl_create_widget_func;
3291         ssl_page.page.destroy_widget = ssl_destroy_widget_func;
3292         ssl_page.page.save_page = ssl_save_func;
3293         ssl_page.page.can_close = ssl_can_close_func;
3294
3295         prefs_account_register_page((PrefsPage *) &ssl_page);
3296 }
3297
3298 static gboolean sslcert_get_client_cert_hook(gpointer source, gpointer data)
3299 {
3300         SSLClientCertHookData *hookdata = (SSLClientCertHookData *)source;
3301         PrefsAccount *account = (PrefsAccount *)hookdata->account;
3302
3303         hookdata->cert_path = NULL;
3304         hookdata->password = NULL;
3305
3306         if (!g_list_find(account_get_list(), account)) {
3307                 g_warning("can't find sock account\n");
3308                 return TRUE;
3309         }
3310         
3311         if (hookdata->is_smtp) {
3312                 if (account->out_ssl_client_cert_file && *account->out_ssl_client_cert_file)
3313                         hookdata->cert_path = account->out_ssl_client_cert_file;
3314                 if (account->out_ssl_client_cert_pass && *account->out_ssl_client_cert_pass)
3315                         hookdata->password = account->out_ssl_client_cert_pass;
3316         } else {
3317                 if (account->in_ssl_client_cert_file && *account->in_ssl_client_cert_file)
3318                         hookdata->cert_path = account->in_ssl_client_cert_file;
3319                 if (account->in_ssl_client_cert_pass && *account->in_ssl_client_cert_pass)
3320                         hookdata->password = account->in_ssl_client_cert_pass;
3321         }
3322         return TRUE;
3323 }
3324
3325 struct GetPassData {
3326         GCond *cond;
3327         GMutex* mutex;
3328         gchar **pass;
3329 };
3330
3331
3332 static gboolean do_get_pass(gpointer data)
3333 {
3334         struct GetPassData *pass_data = (struct GetPassData *)data;
3335         g_mutex_lock(pass_data->mutex);
3336         *(pass_data->pass) = input_dialog_query_password("the PKCS12 client certificate", NULL);
3337         g_cond_signal(pass_data->cond);
3338         g_mutex_unlock(pass_data->mutex);
3339         return FALSE;
3340 }
3341 static gboolean sslcert_get_password(gpointer source, gpointer data)
3342
3343         struct GetPassData pass_data;
3344         /* do complicated stuff to be able to call GTK from the mainloop */
3345         pass_data.cond = g_cond_new();
3346         pass_data.mutex = g_mutex_new();
3347         pass_data.pass = (gchar **)source;
3348
3349         g_mutex_lock(pass_data.mutex);
3350
3351         g_idle_add(do_get_pass, &pass_data);
3352
3353         g_cond_wait(pass_data.cond, pass_data.mutex);
3354         g_cond_free(pass_data.cond);
3355         g_mutex_unlock(pass_data.mutex);
3356         g_mutex_free(pass_data.mutex);
3357
3358         return TRUE;
3359 }
3360 #endif
3361
3362 static void register_advanced_page(void)
3363 {
3364         static gchar *path[3];
3365
3366         path[0] = _("Account");
3367         path[1] = _("Advanced");
3368         path[2] = NULL;
3369         
3370         advanced_page.page.path = path;
3371         advanced_page.page.weight = 1000.0;
3372         advanced_page.page.create_widget = advanced_create_widget_func;
3373         advanced_page.page.destroy_widget = advanced_destroy_widget_func;
3374         advanced_page.page.save_page = advanced_save_func;
3375         advanced_page.page.can_close = advanced_can_close_func;
3376
3377         prefs_account_register_page((PrefsPage *) &advanced_page);
3378 }
3379
3380 void prefs_account_init()
3381 {
3382         register_basic_page();
3383         register_receive_page();
3384         register_send_page();
3385         register_compose_page();
3386         register_templates_page();
3387         register_privacy_page();
3388 #ifdef USE_GNUTLS
3389         register_ssl_page();
3390         hooks_register_hook(SSLCERT_GET_CLIENT_CERT_HOOKLIST, sslcert_get_client_cert_hook, NULL);
3391         hooks_register_hook(SSL_CERT_GET_PASSWORD, sslcert_get_password, NULL);
3392 #endif
3393         register_advanced_page();
3394 }
3395
3396 PrefsAccount *prefs_account_new(void)
3397 {
3398         PrefsAccount *ac_prefs;
3399
3400         ac_prefs = g_new0(PrefsAccount, 1);
3401         memset(&tmp_ac_prefs, 0, sizeof(PrefsAccount));
3402         prefs_set_default(basic_param);
3403         prefs_set_default(receive_param);
3404         prefs_set_default(send_param);
3405         prefs_set_default(compose_param);
3406         prefs_set_default(templates_param);
3407         prefs_set_default(privacy_param);
3408         prefs_set_default(ssl_param);
3409         prefs_set_default(advanced_param);
3410         *ac_prefs = tmp_ac_prefs;
3411         ac_prefs->account_id = prefs_account_get_new_id();
3412
3413         ac_prefs->privacy_prefs = g_hash_table_new(g_str_hash, g_str_equal);
3414
3415         return ac_prefs;
3416 }
3417
3418 void prefs_account_read_config(PrefsAccount *ac_prefs, const gchar *label)
3419 {
3420         const gchar *p = label;
3421         gchar *rcpath;
3422         gint id;
3423         gchar **strv, **cur;
3424
3425         cm_return_if_fail(ac_prefs != NULL);
3426         cm_return_if_fail(label != NULL);
3427
3428         memset(&tmp_ac_prefs, 0, sizeof(PrefsAccount));
3429         tmp_ac_prefs.privacy_prefs = ac_prefs->privacy_prefs;
3430
3431         rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, ACCOUNT_RC, NULL);
3432         prefs_read_config(basic_param, label, rcpath, NULL);
3433         prefs_read_config(receive_param, label, rcpath, NULL);
3434         prefs_read_config(send_param, label, rcpath, NULL);
3435         prefs_read_config(compose_param, label, rcpath, NULL);
3436         prefs_read_config(templates_param, label, rcpath, NULL);
3437         prefs_read_config(privacy_param, label, rcpath, NULL);
3438         prefs_read_config(ssl_param, label, rcpath, NULL);
3439         prefs_read_config(advanced_param, label, rcpath, NULL);
3440         g_free(rcpath);
3441
3442         *ac_prefs = tmp_ac_prefs;
3443         while (*p && !g_ascii_isdigit(*p)) p++;
3444         id = atoi(p);
3445         if (id < 0) g_warning("wrong account id: %d\n", id);
3446         ac_prefs->account_id = id;
3447
3448         if (ac_prefs->protocol == A_APOP) {
3449                 debug_print("converting protocol A_APOP to new prefs.\n");
3450                 ac_prefs->protocol = A_POP3;
3451                 ac_prefs->use_apop_auth = TRUE;
3452         }
3453
3454         if (privacy_prefs != NULL) {
3455                 strv = g_strsplit(privacy_prefs, ",", 0);
3456                 for (cur = strv; *cur != NULL; cur++) {
3457                         gchar *encvalue, *value;
3458
3459                         encvalue = strchr(*cur, '=');
3460                         if (encvalue == NULL)
3461                                 continue;
3462                         encvalue[0] = '\0';
3463                         encvalue++;
3464
3465                         value = g_malloc0(strlen(encvalue));
3466                         if (base64_decode(value, encvalue, strlen(encvalue)) > 0)
3467                                 g_hash_table_insert(ac_prefs->privacy_prefs, g_strdup(*cur), g_strdup(value));
3468                         g_free(value);
3469                 }
3470                 g_strfreev(strv);
3471                 g_free(privacy_prefs);
3472                 privacy_prefs = NULL;
3473         }
3474
3475         prefs_custom_header_read_config(ac_prefs);
3476 }
3477
3478 static void create_privacy_prefs(gpointer key, gpointer _value, gpointer user_data)
3479 {
3480         GString *str = (GString *) user_data;
3481         gchar *encvalue;
3482         gchar *value = (gchar *) _value;
3483
3484         if (str->len > 0)
3485                 g_string_append_c(str, ',');
3486
3487         encvalue = g_malloc0(B64LEN(strlen(value)) + 1);
3488         base64_encode(encvalue, (gchar *) value, strlen(value));
3489         g_string_append_printf(str, "%s=%s", (gchar *) key, encvalue);
3490         g_free(encvalue);
3491 }
3492
3493 #define WRITE_PARAM(PARAM_TABLE) \
3494                 if (prefs_write_param(PARAM_TABLE, pfile->fp) < 0) { \
3495                         g_warning("failed to write configuration to file\n"); \
3496                         prefs_file_close_revert(pfile); \
3497                         g_free(privacy_prefs); \
3498                         privacy_prefs = NULL; \
3499                         return; \
3500                 }
3501
3502 void prefs_account_write_config_all(GList *account_list)