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