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