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