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