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