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