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