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