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