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