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