Statistics
| Revision:

root / src / prefs_account.c @ 1

History | View | Annotate | Download (71.7 KB)

1
/*
2
 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3
 * Copyright (C) 1999-2003 Hiroyuki Yamamoto
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 2 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, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
 */
19

    
20
#ifdef HAVE_CONFIG_H
21
#  include "config.h"
22
#endif
23

    
24
#include "defs.h"
25

    
26
#include <gtk/gtk.h>
27
#include <gdk/gdkkeysyms.h>
28
#include <stdio.h>
29
#include <sys/types.h>
30
#include <sys/stat.h>
31
#include <string.h>
32
#include <stdlib.h>
33
#include <ctype.h>
34

    
35
#include "intl.h"
36
#include "main.h"
37
#include "prefs.h"
38
#include "prefs_account.h"
39
#include "prefs_customheader.h"
40
#include "account.h"
41
#include "mainwindow.h"
42
#include "manage_window.h"
43
#include "foldersel.h"
44
#include "inc.h"
45
#include "menu.h"
46
#include "gtkutils.h"
47
#include "utils.h"
48
#include "alertpanel.h"
49
#include "smtp.h"
50
#include "imap.h"
51

    
52
static gboolean cancelled;
53

    
54
static PrefsAccount tmp_ac_prefs;
55

    
56
static PrefsDialog dialog;
57

    
58
static struct Basic {
59
        GtkWidget *acname_entry;
60
        GtkWidget *default_chkbtn;
61

    
62
        GtkWidget *name_entry;
63
        GtkWidget *addr_entry;
64
        GtkWidget *org_entry;
65

    
66
        GtkWidget *serv_frame;
67
        GtkWidget *serv_table;
68
        GtkWidget *protocol_optmenu;
69
        GtkWidget *recvserv_label;
70
        GtkWidget *smtpserv_label;
71
        GtkWidget *nntpserv_label;
72
        GtkWidget *recvserv_entry;
73
        GtkWidget *smtpserv_entry;
74
        GtkWidget *nntpserv_entry;
75
        GtkWidget *nntpauth_chkbtn;
76
        GtkWidget *uid_label;
77
        GtkWidget *pass_label;
78
        GtkWidget *uid_entry;
79
        GtkWidget *pass_entry;
80
} basic;
81

    
82
static struct Receive {
83
        GtkWidget *pop3_frame;
84
        GtkWidget *use_apop_chkbtn;
85
        GtkWidget *rmmail_chkbtn;
86
        GtkWidget *leave_time_entry;
87
        GtkWidget *getall_chkbtn;
88
        GtkWidget *size_limit_chkbtn;
89
        GtkWidget *size_limit_entry;
90
        GtkWidget *filter_on_recv_chkbtn;
91
        GtkWidget *inbox_label;
92
        GtkWidget *inbox_entry;
93
        GtkWidget *inbox_btn;
94

    
95
        GtkWidget *imap_frame;
96
        GtkWidget *imap_auth_type_optmenu;
97

    
98
        GtkWidget *recvatgetall_chkbtn;
99
} receive;
100

    
101
static struct Send {
102
        GtkWidget *date_chkbtn;
103
        GtkWidget *msgid_chkbtn;
104

    
105
        GtkWidget *customhdr_chkbtn;
106

    
107
        GtkWidget *smtp_auth_chkbtn;
108
        GtkWidget *smtp_auth_type_optmenu;
109
        GtkWidget *smtp_uid_entry;
110
        GtkWidget *smtp_pass_entry;
111
        /* GtkWidget *pop_bfr_smtp_chkbtn; */
112
} p_send;
113

    
114
static struct Compose {
115
        GtkWidget *sigfile_radiobtn;
116
        GtkWidget *sigpath_entry;
117

    
118
        GtkWidget *autocc_chkbtn;
119
        GtkWidget *autocc_entry;
120
        GtkWidget *autobcc_chkbtn;
121
        GtkWidget *autobcc_entry;
122
        GtkWidget *autoreplyto_chkbtn;
123
        GtkWidget *autoreplyto_entry;
124
} compose;
125

    
126
#if USE_GPGME
127
static struct Privacy {
128
        GtkWidget *default_encrypt_chkbtn;
129
        GtkWidget *default_sign_chkbtn;
130
        GtkWidget *ascii_armored_chkbtn;
131
        GtkWidget *clearsign_chkbtn;
132
        GtkWidget *defaultkey_radiobtn;
133
        GtkWidget *emailkey_radiobtn;
134
        GtkWidget *customkey_radiobtn;
135
        GtkWidget *customkey_entry;
136
} privacy;
137
#endif /* USE_GPGME */
138

    
139
#if USE_SSL
140
static struct SSLPrefs {
141
        GtkWidget *pop_frame;
142
        GtkWidget *pop_nossl_radiobtn;
143
        GtkWidget *pop_ssltunnel_radiobtn;
144
        GtkWidget *pop_starttls_radiobtn;
145

    
146
        GtkWidget *imap_frame;
147
        GtkWidget *imap_nossl_radiobtn;
148
        GtkWidget *imap_ssltunnel_radiobtn;
149
        GtkWidget *imap_starttls_radiobtn;
150

    
151
        GtkWidget *nntp_frame;
152
        GtkWidget *nntp_nossl_radiobtn;
153
        GtkWidget *nntp_ssltunnel_radiobtn;
154

    
155
        GtkWidget *send_frame;
156
        GtkWidget *smtp_nossl_radiobtn;
157
        GtkWidget *smtp_ssltunnel_radiobtn;
158
        GtkWidget *smtp_starttls_radiobtn;
159

    
160
        GtkWidget *use_nonblocking_ssl_chkbtn;
161
} ssl;
162
#endif /* USE_SSL */
163

    
164
static struct Advanced {
165
        GtkWidget *smtpport_chkbtn;
166
        GtkWidget *smtpport_entry;
167
        GtkWidget *popport_hbox;
168
        GtkWidget *popport_chkbtn;
169
        GtkWidget *popport_entry;
170
        GtkWidget *imapport_hbox;
171
        GtkWidget *imapport_chkbtn;
172
        GtkWidget *imapport_entry;
173
        GtkWidget *nntpport_hbox;
174
        GtkWidget *nntpport_chkbtn;
175
        GtkWidget *nntpport_entry;
176
        GtkWidget *domain_chkbtn;
177
        GtkWidget *domain_entry;
178

    
179
        GtkWidget *imap_frame;
180
        GtkWidget *imapdir_entry;
181

    
182
        GtkWidget *sent_folder_chkbtn;
183
        GtkWidget *sent_folder_entry;
184
        GtkWidget *draft_folder_chkbtn;
185
        GtkWidget *draft_folder_entry;
186
        GtkWidget *trash_folder_chkbtn;
187
        GtkWidget *trash_folder_entry;
188
} advanced;
189

    
190
static void prefs_account_protocol_set_data_from_optmenu(PrefParam *pparam);
191
static void prefs_account_protocol_set_optmenu                (PrefParam *pparam);
192
static void prefs_account_protocol_activated                (GtkMenuItem *menuitem);
193

    
194
static void prefs_account_imap_auth_type_set_data_from_optmenu
195
                                                        (PrefParam *pparam);
196
static void prefs_account_imap_auth_type_set_optmenu        (PrefParam *pparam);
197
static void prefs_account_smtp_auth_type_set_data_from_optmenu
198
                                                        (PrefParam *pparam);
199
static void prefs_account_smtp_auth_type_set_optmenu        (PrefParam *pparam);
200

    
201
static void prefs_account_enum_set_data_from_radiobtn        (PrefParam *pparam);
202
static void prefs_account_enum_set_radiobtn                (PrefParam *pparam);
203

    
204
#if USE_GPGME
205
static void prefs_account_ascii_armored_warning                (GtkWidget *widget);
206
#endif /* USE_GPGME */
207

    
208
static PrefParam param[] = {
209
        /* Basic */
210
        {"account_name", NULL, &tmp_ac_prefs.account_name, P_STRING,
211
         &basic.acname_entry, prefs_set_data_from_entry, prefs_set_entry},
212

    
213
        {"is_default", "FALSE", &tmp_ac_prefs.is_default, P_BOOL,
214
         &basic.default_chkbtn,
215
         prefs_set_data_from_toggle, prefs_set_toggle},
216

    
217
        {"name", NULL, &tmp_ac_prefs.name, P_STRING,
218
         &basic.name_entry, prefs_set_data_from_entry, prefs_set_entry},
219

    
220
        {"address", NULL, &tmp_ac_prefs.address, P_STRING,
221
         &basic.addr_entry, prefs_set_data_from_entry, prefs_set_entry},
222

    
223
        {"organization", NULL, &tmp_ac_prefs.organization, P_STRING,
224
         &basic.org_entry, prefs_set_data_from_entry, prefs_set_entry},
225

    
226
        {"protocol", NULL, &tmp_ac_prefs.protocol, P_ENUM,
227
         &basic.protocol_optmenu,
228
         prefs_account_protocol_set_data_from_optmenu,
229
         prefs_account_protocol_set_optmenu},
230

    
231
        {"receive_server", NULL, &tmp_ac_prefs.recv_server, P_STRING,
232
         &basic.recvserv_entry, prefs_set_data_from_entry, prefs_set_entry},
233

    
234
        {"smtp_server", NULL, &tmp_ac_prefs.smtp_server, P_STRING,
235
         &basic.smtpserv_entry, prefs_set_data_from_entry, prefs_set_entry},
236

    
237
        {"nntp_server", NULL, &tmp_ac_prefs.nntp_server, P_STRING,
238
         &basic.nntpserv_entry, prefs_set_data_from_entry, prefs_set_entry},
239

    
240
        {"use_nntp_auth", "FALSE", &tmp_ac_prefs.use_nntp_auth, P_BOOL,
241
         &basic.nntpauth_chkbtn,
242
         prefs_set_data_from_toggle, prefs_set_toggle},
243

    
244
        {"user_id", "ENV_USER", &tmp_ac_prefs.userid, P_STRING,
245
         &basic.uid_entry, prefs_set_data_from_entry, prefs_set_entry},
246

    
247
        {"password", NULL, &tmp_ac_prefs.passwd, P_STRING,
248
         &basic.pass_entry, prefs_set_data_from_entry, prefs_set_entry},
249

    
250
        {"inbox", "inbox", &tmp_ac_prefs.inbox, P_STRING,
251
         &receive.inbox_entry, prefs_set_data_from_entry, prefs_set_entry},
252

    
253
        /* Receive */
254
        {"use_apop_auth", "FALSE", &tmp_ac_prefs.use_apop_auth, P_BOOL,
255
         &receive.use_apop_chkbtn,
256
         prefs_set_data_from_toggle, prefs_set_toggle},
257

    
258
        {"remove_mail", "TRUE", &tmp_ac_prefs.rmmail, P_BOOL,
259
         &receive.rmmail_chkbtn,
260
         prefs_set_data_from_toggle, prefs_set_toggle},
261

    
262
        {"message_leave_time", "0", &tmp_ac_prefs.msg_leave_time, P_INT,
263
         &receive.leave_time_entry,
264
         prefs_set_data_from_entry, prefs_set_entry},
265

    
266
        {"get_all_mail", "FALSE", &tmp_ac_prefs.getall, P_BOOL,
267
         &receive.getall_chkbtn,
268
         prefs_set_data_from_toggle, prefs_set_toggle},
269

    
270
        {"enable_size_limit", "FALSE", &tmp_ac_prefs.enable_size_limit, P_BOOL,
271
         &receive.size_limit_chkbtn,
272
         prefs_set_data_from_toggle, prefs_set_toggle},
273
        {"size_limit", "1024", &tmp_ac_prefs.size_limit, P_INT,
274
         &receive.size_limit_entry,
275
         prefs_set_data_from_entry, prefs_set_entry},
276

    
277
        {"filter_on_receive", "TRUE", &tmp_ac_prefs.filter_on_recv, P_BOOL,
278
         &receive.filter_on_recv_chkbtn,
279
         prefs_set_data_from_toggle, prefs_set_toggle},
280

    
281
        {"imap_auth_method", "0", &tmp_ac_prefs.imap_auth_type, P_ENUM,
282
         &receive.imap_auth_type_optmenu,
283
         prefs_account_imap_auth_type_set_data_from_optmenu,
284
         prefs_account_imap_auth_type_set_optmenu},
285

    
286
        {"receive_at_get_all", "TRUE", &tmp_ac_prefs.recv_at_getall, P_BOOL,
287
         &receive.recvatgetall_chkbtn,
288
         prefs_set_data_from_toggle, prefs_set_toggle},
289

    
290
        /* Send */
291
        {"add_date", "TRUE", &tmp_ac_prefs.add_date, P_BOOL,
292
         &p_send.date_chkbtn,
293
         prefs_set_data_from_toggle, prefs_set_toggle},
294

    
295
        {"generate_msgid", "TRUE", &tmp_ac_prefs.gen_msgid, P_BOOL,
296
         &p_send.msgid_chkbtn,
297
         prefs_set_data_from_toggle, prefs_set_toggle},
298

    
299
        {"add_custom_header", "FALSE", &tmp_ac_prefs.add_customhdr, P_BOOL,
300
         &p_send.customhdr_chkbtn,
301
         prefs_set_data_from_toggle, prefs_set_toggle},
302

    
303
        {"use_smtp_auth", "FALSE", &tmp_ac_prefs.use_smtp_auth, P_BOOL,
304
         &p_send.smtp_auth_chkbtn,
305
         prefs_set_data_from_toggle, prefs_set_toggle},
306

    
307
        {"smtp_auth_method", "0", &tmp_ac_prefs.smtp_auth_type, P_ENUM,
308
         &p_send.smtp_auth_type_optmenu,
309
         prefs_account_smtp_auth_type_set_data_from_optmenu,
310
         prefs_account_smtp_auth_type_set_optmenu},
311

    
312
        {"smtp_user_id", NULL, &tmp_ac_prefs.smtp_userid, P_STRING,
313
         &p_send.smtp_uid_entry, prefs_set_data_from_entry, prefs_set_entry},
314
        {"smtp_password", NULL, &tmp_ac_prefs.smtp_passwd, P_STRING,
315
         &p_send.smtp_pass_entry, prefs_set_data_from_entry, prefs_set_entry},
316

    
317
        {"pop_before_smtp", "FALSE", &tmp_ac_prefs.pop_before_smtp, P_BOOL,
318
         NULL, NULL, NULL},
319
#if 0
320
         &p_send.pop_bfr_smtp_chkbtn,
321
         prefs_set_data_from_toggle, prefs_set_toggle},
322
#endif
323

    
324
        /* Compose */
325
        {"signature_type", "0", &tmp_ac_prefs.sig_type, P_ENUM,
326
         &compose.sigfile_radiobtn,
327
         prefs_account_enum_set_data_from_radiobtn,
328
         prefs_account_enum_set_radiobtn},
329
        {"signature_path", "~/"DEFAULT_SIGNATURE, &tmp_ac_prefs.sig_path, P_STRING,
330
         &compose.sigpath_entry,
331
         prefs_set_data_from_entry, prefs_set_entry},
332

    
333
        {"set_autocc", "FALSE", &tmp_ac_prefs.set_autocc, P_BOOL,
334
         &compose.autocc_chkbtn,
335
         prefs_set_data_from_toggle, prefs_set_toggle},
336

    
337
        {"auto_cc", NULL, &tmp_ac_prefs.auto_cc, P_STRING,
338
         &compose.autocc_entry,
339
         prefs_set_data_from_entry, prefs_set_entry},
340

    
341
        {"set_autobcc", "FALSE", &tmp_ac_prefs.set_autobcc, P_BOOL,
342
         &compose.autobcc_chkbtn,
343
         prefs_set_data_from_toggle, prefs_set_toggle},
344

    
345
        {"auto_bcc", NULL, &tmp_ac_prefs.auto_bcc, P_STRING,
346
         &compose.autobcc_entry,
347
         prefs_set_data_from_entry, prefs_set_entry},
348

    
349
        {"set_autoreplyto", "FALSE", &tmp_ac_prefs.set_autoreplyto, P_BOOL,
350
         &compose.autoreplyto_chkbtn,
351
         prefs_set_data_from_toggle, prefs_set_toggle},
352

    
353
        {"auto_replyto", NULL, &tmp_ac_prefs.auto_replyto, P_STRING,
354
         &compose.autoreplyto_entry,
355
         prefs_set_data_from_entry, prefs_set_entry},
356

    
357
#if USE_GPGME
358
        /* Privacy */
359
        {"default_encrypt", "FALSE", &tmp_ac_prefs.default_encrypt, P_BOOL,
360
         &privacy.default_encrypt_chkbtn,
361
         prefs_set_data_from_toggle, prefs_set_toggle},
362
        {"default_sign", "FALSE", &tmp_ac_prefs.default_sign, P_BOOL,
363
         &privacy.default_sign_chkbtn,
364
         prefs_set_data_from_toggle, prefs_set_toggle},
365
        {"ascii_armored", "FALSE", &tmp_ac_prefs.ascii_armored, P_BOOL,
366
         &privacy.ascii_armored_chkbtn,
367
         prefs_set_data_from_toggle, prefs_set_toggle},
368
        {"clearsign", "FALSE", &tmp_ac_prefs.clearsign, P_BOOL,
369
         &privacy.clearsign_chkbtn,
370
         prefs_set_data_from_toggle, prefs_set_toggle},
371
        {"sign_key", NULL, &tmp_ac_prefs.sign_key, P_ENUM,
372
         &privacy.defaultkey_radiobtn,
373
         prefs_account_enum_set_data_from_radiobtn,
374
         prefs_account_enum_set_radiobtn},
375
        {"sign_key_id", NULL, &tmp_ac_prefs.sign_key_id, P_STRING,
376
         &privacy.customkey_entry,
377
         prefs_set_data_from_entry, prefs_set_entry},
378
#endif /* USE_GPGME */
379

    
380
#if USE_SSL
381
        /* SSL */
382
        {"ssl_pop", "0", &tmp_ac_prefs.ssl_pop, P_ENUM,
383
         &ssl.pop_nossl_radiobtn,
384
         prefs_account_enum_set_data_from_radiobtn,
385
         prefs_account_enum_set_radiobtn},
386
        {"ssl_imap", "0", &tmp_ac_prefs.ssl_imap, P_ENUM,
387
         &ssl.imap_nossl_radiobtn,
388
         prefs_account_enum_set_data_from_radiobtn,
389
         prefs_account_enum_set_radiobtn},
390
        {"ssl_nntp", "0", &tmp_ac_prefs.ssl_nntp, P_ENUM,
391
         &ssl.nntp_nossl_radiobtn,
392
         prefs_account_enum_set_data_from_radiobtn,
393
         prefs_account_enum_set_radiobtn},
394
        {"ssl_smtp", "0", &tmp_ac_prefs.ssl_smtp, P_ENUM,
395
         &ssl.smtp_nossl_radiobtn,
396
         prefs_account_enum_set_data_from_radiobtn,
397
         prefs_account_enum_set_radiobtn},
398

    
399
        {"use_nonblocking_ssl", "1", &tmp_ac_prefs.use_nonblocking_ssl, P_BOOL,
400
         &ssl.use_nonblocking_ssl_chkbtn,
401
         prefs_set_data_from_toggle, prefs_set_toggle},
402
#endif /* USE_SSL */
403

    
404
        /* Advanced */
405
        {"set_smtpport", "FALSE", &tmp_ac_prefs.set_smtpport, P_BOOL,
406
         &advanced.smtpport_chkbtn,
407
         prefs_set_data_from_toggle, prefs_set_toggle},
408

    
409
        {"smtp_port", "25", &tmp_ac_prefs.smtpport, P_USHORT,
410
         &advanced.smtpport_entry,
411
         prefs_set_data_from_entry, prefs_set_entry},
412

    
413
        {"set_popport", "FALSE", &tmp_ac_prefs.set_popport, P_BOOL,
414
         &advanced.popport_chkbtn,
415
         prefs_set_data_from_toggle, prefs_set_toggle},
416

    
417
        {"pop_port", "110", &tmp_ac_prefs.popport, P_USHORT,
418
         &advanced.popport_entry,
419
         prefs_set_data_from_entry, prefs_set_entry},
420

    
421
        {"set_imapport", "FALSE", &tmp_ac_prefs.set_imapport, P_BOOL,
422
         &advanced.imapport_chkbtn,
423
         prefs_set_data_from_toggle, prefs_set_toggle},
424

    
425
        {"imap_port", "143", &tmp_ac_prefs.imapport, P_USHORT,
426
         &advanced.imapport_entry,
427
         prefs_set_data_from_entry, prefs_set_entry},
428

    
429
        {"set_nntpport", "FALSE", &tmp_ac_prefs.set_nntpport, P_BOOL,
430
         &advanced.nntpport_chkbtn,
431
         prefs_set_data_from_toggle, prefs_set_toggle},
432

    
433
        {"nntp_port", "119", &tmp_ac_prefs.nntpport, P_USHORT,
434
         &advanced.nntpport_entry,
435
         prefs_set_data_from_entry, prefs_set_entry},
436

    
437
        {"set_domain", "FALSE", &tmp_ac_prefs.set_domain, P_BOOL,
438
         &advanced.domain_chkbtn,
439
         prefs_set_data_from_toggle, prefs_set_toggle},
440

    
441
        {"domain", NULL, &tmp_ac_prefs.domain, P_STRING,
442
         &advanced.domain_entry,
443
         prefs_set_data_from_entry, prefs_set_entry},
444

    
445
        {"imap_directory", NULL, &tmp_ac_prefs.imap_dir, P_STRING,
446
         &advanced.imapdir_entry, prefs_set_data_from_entry, prefs_set_entry},
447

    
448
        {"set_sent_folder", "FALSE", &tmp_ac_prefs.set_sent_folder, P_BOOL,
449
         &advanced.sent_folder_chkbtn,
450
         prefs_set_data_from_toggle, prefs_set_toggle},
451
        {"sent_folder", NULL, &tmp_ac_prefs.sent_folder, P_STRING,
452
         &advanced.sent_folder_entry,
453
         prefs_set_data_from_entry, prefs_set_entry},
454

    
455
        {"set_draft_folder", "FALSE", &tmp_ac_prefs.set_draft_folder, P_BOOL,
456
         &advanced.draft_folder_chkbtn,
457
         prefs_set_data_from_toggle, prefs_set_toggle},
458
        {"draft_folder", NULL, &tmp_ac_prefs.draft_folder, P_STRING,
459
         &advanced.draft_folder_entry,
460
         prefs_set_data_from_entry, prefs_set_entry},
461

    
462
        {"set_trash_folder", "FALSE", &tmp_ac_prefs.set_trash_folder, P_BOOL,
463
         &advanced.trash_folder_chkbtn,
464
         prefs_set_data_from_toggle, prefs_set_toggle},
465
        {"trash_folder", NULL, &tmp_ac_prefs.trash_folder, P_STRING,
466
         &advanced.trash_folder_entry,
467
         prefs_set_data_from_entry, prefs_set_entry},
468

    
469
        {NULL, NULL, NULL, P_OTHER, NULL, NULL, NULL}
470
};
471

    
472
static gint prefs_account_get_new_id                (void);
473

    
474
static void prefs_account_create                (void);
475
static void prefs_account_basic_create                (void);
476
static void prefs_account_receive_create        (void);
477
static void prefs_account_send_create                (void);
478
static void prefs_account_compose_create        (void);
479
#if USE_GPGME
480
static void prefs_account_privacy_create        (void);
481
#endif /* USE_GPGME */
482
#if USE_SSL
483
static void prefs_account_ssl_create                (void);
484
#endif /* USE_SSL */
485
static void prefs_account_advanced_create        (void);
486

    
487
static void prefs_account_select_folder_cb        (GtkWidget        *widget,
488
                                                 gpointer         data);
489
static void prefs_account_edit_custom_header        (void);
490

    
491
static gint prefs_account_deleted                (GtkWidget        *widget,
492
                                                 GdkEventAny        *event,
493
                                                 gpointer         data);
494
static gboolean prefs_account_key_pressed        (GtkWidget        *widget,
495
                                                 GdkEventKey        *event,
496
                                                 gpointer         data);
497
static void prefs_account_ok                        (void);
498
static gint prefs_account_apply                        (void);
499
static void prefs_account_cancel                (void);
500

    
501
PrefsAccount *prefs_account_new(void)
502
{
503
        PrefsAccount *ac_prefs;
504

    
505
        ac_prefs = g_new0(PrefsAccount, 1);
506
        memset(&tmp_ac_prefs, 0, sizeof(PrefsAccount));
507
        prefs_set_default(param);
508
        *ac_prefs = tmp_ac_prefs;
509
        ac_prefs->account_id = prefs_account_get_new_id();
510

    
511
        return ac_prefs;
512
}
513

    
514
void prefs_account_read_config(PrefsAccount *ac_prefs, const gchar *label)
515
{
516
        const guchar *p = label;
517
        gint id;
518

    
519
        g_return_if_fail(ac_prefs != NULL);
520
        g_return_if_fail(label != NULL);
521

    
522
        memset(&tmp_ac_prefs, 0, sizeof(PrefsAccount));
523
        prefs_read_config(param, label, ACCOUNT_RC);
524
        *ac_prefs = tmp_ac_prefs;
525
        while (*p && !isdigit(*p)) p++;
526
        id = atoi(p);
527
        if (id < 0) g_warning("wrong account id: %d\n", id);
528
        ac_prefs->account_id = id;
529

    
530
        if (ac_prefs->protocol == A_APOP) {
531
                debug_print("converting protocol A_APOP to new prefs.\n");
532
                ac_prefs->protocol = A_POP3;
533
                ac_prefs->use_apop_auth = TRUE;
534
        }
535

    
536
        prefs_custom_header_read_config(ac_prefs);
537
}
538

    
539
void prefs_account_write_config_all(GList *account_list)
540
{
541
        GList *cur;
542
        gchar *rcpath;
543
        PrefFile *pfile;
544

    
545
        rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, ACCOUNT_RC, NULL);
546
        if ((pfile = prefs_file_open(rcpath)) == NULL) {
547
                g_free(rcpath);
548
                return;
549
        }
550
        g_free(rcpath);
551

    
552
        for (cur = account_list; cur != NULL; cur = cur->next) {
553
                tmp_ac_prefs = *(PrefsAccount *)cur->data;
554
                if (fprintf(pfile->fp, "[Account: %d]\n",
555
                            tmp_ac_prefs.account_id) <= 0 ||
556
                    prefs_file_write_param(pfile, param) < 0) {
557
                        g_warning(_("failed to write configuration to file\n"));
558
                        prefs_file_close_revert(pfile);
559
                        return;
560
                }
561
                if (cur->next) {
562
                        if (fputc('\n', pfile->fp) == EOF) {
563
                                FILE_OP_ERROR(rcpath, "fputc");
564
                                prefs_file_close_revert(pfile);
565
                                return;
566
                        }
567
                }
568
        }
569

    
570
        if (prefs_file_close(pfile) < 0)
571
                g_warning(_("failed to write configuration to file\n"));
572
}
573

    
574
void prefs_account_free(PrefsAccount *ac_prefs)
575
{
576
        if (!ac_prefs) return;
577

    
578
        tmp_ac_prefs = *ac_prefs;
579
        prefs_free(param);
580
}
581

    
582
static gint prefs_account_get_new_id(void)
583
{
584
        GList *ac_list;
585
        PrefsAccount *ac;
586
        static gint last_id = 0;
587

    
588
        for (ac_list = account_get_list(); ac_list != NULL;
589
             ac_list = ac_list->next) {
590
                ac = (PrefsAccount *)ac_list->data;
591
                if (last_id < ac->account_id)
592
                        last_id = ac->account_id;
593
        }
594

    
595
        return last_id + 1;
596
}
597

    
598
PrefsAccount *prefs_account_open(PrefsAccount *ac_prefs)
599
{
600
        gboolean new_account = FALSE;
601

    
602
        debug_print(_("Opening account preferences window...\n"));
603

    
604
        inc_lock();
605

    
606
        cancelled = FALSE;
607

    
608
        if (!ac_prefs) {
609
                ac_prefs = prefs_account_new();
610
                new_account = TRUE;
611
        }
612

    
613
        if (!dialog.window) {
614
                prefs_account_create();
615
        }
616

    
617
        manage_window_set_transient(GTK_WINDOW(dialog.window));
618
        gtk_notebook_set_current_page(GTK_NOTEBOOK(dialog.notebook), 0);
619
        gtk_widget_grab_focus(dialog.ok_btn);
620

    
621
        tmp_ac_prefs = *ac_prefs;
622

    
623
        if (new_account) {
624
                PrefsAccount *def_ac;
625
                gchar *buf;
626

    
627
                prefs_set_dialog_to_default(param);
628
                buf = g_strdup_printf(_("Account%d"), ac_prefs->account_id);
629
                gtk_entry_set_text(GTK_ENTRY(basic.acname_entry), buf);
630
                g_free(buf);
631
                def_ac = account_get_default();
632
                if (def_ac) {
633
                        gtk_entry_set_text(GTK_ENTRY(basic.name_entry),
634
                                           def_ac->name ? def_ac->name : "");
635
                        gtk_entry_set_text(GTK_ENTRY(basic.addr_entry),
636
                                           def_ac->address ? def_ac->address : "");
637
                        gtk_entry_set_text(GTK_ENTRY(basic.org_entry),
638
                                           def_ac->organization ? def_ac->organization : "");
639
                }
640
                menu_set_sensitive_all
641
                        (GTK_MENU_SHELL
642
                                (gtk_option_menu_get_menu
643
                                        (GTK_OPTION_MENU
644
                                                (basic.protocol_optmenu))),
645
                         TRUE);
646
                gtk_window_set_title(GTK_WINDOW(dialog.window),
647
                                     _("Preferences for new account"));
648
                gtk_widget_hide(dialog.apply_btn);
649
        } else {
650
                prefs_set_dialog(param);
651
                gtk_window_set_title(GTK_WINDOW(dialog.window),
652
                                     _("Account preferences"));
653
                gtk_widget_show(dialog.apply_btn);
654
        }
655

    
656
        gtk_widget_show(dialog.window);
657
        gtk_main();
658
        gtk_widget_hide(dialog.window);
659

    
660
        inc_unlock();
661

    
662
        if (cancelled && new_account) {
663
                g_free(ac_prefs);
664
                return NULL;
665
        } else {
666
                *ac_prefs = tmp_ac_prefs;
667
                return ac_prefs;
668
        }
669
}
670

    
671
static void prefs_account_create(void)
672
{
673
        gint page = 0;
674

    
675
        debug_print(_("Creating account preferences window...\n"));
676

    
677
        /* create dialog */
678
        prefs_dialog_create(&dialog);
679
        g_signal_connect(G_OBJECT(dialog.window), "delete_event",
680
                         G_CALLBACK(prefs_account_deleted), NULL);
681
        g_signal_connect(G_OBJECT(dialog.window), "key_press_event",
682
                         G_CALLBACK(prefs_account_key_pressed), NULL);
683
        MANAGE_WINDOW_SIGNALS_CONNECT(dialog.window);
684

    
685
        g_signal_connect(G_OBJECT(dialog.ok_btn), "clicked",
686
                          G_CALLBACK(prefs_account_ok), NULL);
687
        g_signal_connect(G_OBJECT(dialog.apply_btn), "clicked",
688
                         G_CALLBACK(prefs_account_apply), NULL);
689
        g_signal_connect(G_OBJECT(dialog.cancel_btn), "clicked",
690
                         G_CALLBACK(prefs_account_cancel), NULL);
691

    
692
        prefs_account_basic_create();
693
        SET_NOTEBOOK_LABEL(dialog.notebook, _("Basic"), page++);
694
        prefs_account_receive_create();
695
        SET_NOTEBOOK_LABEL(dialog.notebook, _("Receive"), page++);
696
        prefs_account_send_create();
697
        SET_NOTEBOOK_LABEL(dialog.notebook, _("Send"), page++);
698
        prefs_account_compose_create();
699
        SET_NOTEBOOK_LABEL(dialog.notebook, _("Compose"), page++);
700
#if USE_GPGME
701
        prefs_account_privacy_create();
702
        SET_NOTEBOOK_LABEL(dialog.notebook, _("Privacy"), page++);
703
#endif /* USE_GPGME */
704
#if USE_SSL
705
        prefs_account_ssl_create();
706
        SET_NOTEBOOK_LABEL(dialog.notebook, _("SSL"), page++);
707
#endif /* USE_SSL */
708
        prefs_account_advanced_create();
709
        SET_NOTEBOOK_LABEL(dialog.notebook, _("Advanced"), page++);
710
}
711

    
712
#define SET_ACTIVATE(menuitem) \
713
{ \
714
        g_signal_connect(G_OBJECT(menuitem), "activate", \
715
                         G_CALLBACK(prefs_account_protocol_activated), NULL); \
716
}
717

    
718
static void prefs_account_basic_create(void)
719
{
720
        GtkWidget *vbox1;
721
        GtkWidget *hbox;
722
        GtkWidget *label;
723
        GtkWidget *acname_entry;
724
        GtkWidget *default_chkbtn;
725
        GtkWidget *frame1;
726
        GtkWidget *table1;
727
        GtkWidget *name_entry;
728
        GtkWidget *addr_entry;
729
        GtkWidget *org_entry;
730

    
731
        GtkWidget *serv_frame;
732
        GtkWidget *vbox2;
733
        GtkWidget *optmenu;
734
        GtkWidget *optmenu_menu;
735
        GtkWidget *menuitem;
736
        GtkWidget *serv_table;
737
        GtkWidget *recvserv_label;
738
        GtkWidget *smtpserv_label;
739
        GtkWidget *nntpserv_label;
740
        GtkWidget *recvserv_entry;
741
        GtkWidget *smtpserv_entry;
742
        GtkWidget *nntpserv_entry;
743
        GtkWidget *nntpauth_chkbtn;
744
        GtkWidget *uid_label;
745
        GtkWidget *pass_label;
746
        GtkWidget *uid_entry;
747
        GtkWidget *pass_entry;
748

    
749
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
750
        gtk_widget_show (vbox1);
751
        gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
752
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
753

    
754
        hbox = gtk_hbox_new (FALSE, 8);
755
        gtk_widget_show (hbox);
756
        gtk_box_pack_start (GTK_BOX (vbox1), hbox, FALSE, FALSE, 0);
757

    
758
        label = gtk_label_new (_("Name of this account"));
759
        gtk_widget_show (label);
760
        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
761

    
762
        acname_entry = gtk_entry_new ();
763
        gtk_widget_show (acname_entry);
764
        gtk_widget_set_size_request (acname_entry, DEFAULT_ENTRY_WIDTH, -1);
765
        gtk_box_pack_start (GTK_BOX (hbox), acname_entry, TRUE, TRUE, 0);
766

    
767
        default_chkbtn = gtk_check_button_new_with_label (_("Set as default"));
768
        gtk_widget_show (default_chkbtn);
769
        gtk_box_pack_end (GTK_BOX (hbox), default_chkbtn, FALSE, FALSE, 0);
770

    
771
        PACK_FRAME (vbox1, frame1, _("Personal information"));
772

    
773
        table1 = gtk_table_new (3, 2, FALSE);
774
        gtk_widget_show (table1);
775
        gtk_container_add (GTK_CONTAINER (frame1), table1);
776
        gtk_container_set_border_width (GTK_CONTAINER (table1), 8);
777
        gtk_table_set_row_spacings (GTK_TABLE (table1), VSPACING_NARROW);
778
        gtk_table_set_col_spacings (GTK_TABLE (table1), 8);
779

    
780
        label = gtk_label_new (_("Full name"));
781
        gtk_widget_show (label);
782
        gtk_table_attach (GTK_TABLE (table1), label, 0, 1, 0, 1,
783
                          GTK_FILL, 0, 0, 0);
784
        gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
785

    
786
        label = gtk_label_new (_("Mail address"));
787
        gtk_widget_show (label);
788
        gtk_table_attach (GTK_TABLE (table1), label, 0, 1, 1, 2,
789
                          GTK_FILL, 0, 0, 0);
790
        gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
791

    
792
        label = gtk_label_new (_("Organization"));
793
        gtk_widget_show (label);
794
        gtk_table_attach (GTK_TABLE (table1), label, 0, 1, 2, 3,
795
                          GTK_FILL, 0, 0, 0);
796
        gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
797

    
798
        name_entry = gtk_entry_new ();
799
        gtk_widget_show (name_entry);
800
        gtk_table_attach (GTK_TABLE (table1), name_entry, 1, 2, 0, 1,
801
                          GTK_EXPAND | GTK_SHRINK | GTK_FILL,
802
                          GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
803

    
804
        addr_entry = gtk_entry_new ();
805
        gtk_widget_show (addr_entry);
806
        gtk_table_attach (GTK_TABLE (table1), addr_entry, 1, 2, 1, 2,
807
                          GTK_EXPAND | GTK_SHRINK | GTK_FILL,
808
                          GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
809

    
810
        org_entry = gtk_entry_new ();
811
        gtk_widget_show (org_entry);
812
        gtk_table_attach (GTK_TABLE (table1), org_entry, 1, 2, 2, 3,
813
                          GTK_EXPAND | GTK_SHRINK | GTK_FILL,
814
                          GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
815

    
816
        PACK_FRAME (vbox1, serv_frame, _("Server information"));
817

    
818
        vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW);
819
        gtk_widget_show (vbox2);
820
        gtk_container_add (GTK_CONTAINER (serv_frame), vbox2);
821
        gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
822

    
823
        hbox = gtk_hbox_new (FALSE, 8);
824
        gtk_widget_show (hbox);
825
        gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
826

    
827
        label = gtk_label_new (_("Protocol"));
828
        gtk_widget_show (label);
829
        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
830

    
831
        optmenu = gtk_option_menu_new ();
832
        gtk_widget_show (optmenu);
833
        gtk_box_pack_start (GTK_BOX (hbox), optmenu, FALSE, FALSE, 0);
834

    
835
        optmenu_menu = gtk_menu_new ();
836

    
837
        MENUITEM_ADD (optmenu_menu, menuitem, _("POP3"),  A_POP3);
838
        SET_ACTIVATE (menuitem);
839
        MENUITEM_ADD (optmenu_menu, menuitem, _("IMAP4"), A_IMAP4);
840
        SET_ACTIVATE (menuitem);
841
        MENUITEM_ADD (optmenu_menu, menuitem, _("News (NNTP)"), A_NNTP);
842
        SET_ACTIVATE (menuitem);
843
        MENUITEM_ADD (optmenu_menu, menuitem, _("None (local)"), A_LOCAL);
844
        SET_ACTIVATE (menuitem);
845

    
846
        gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu), optmenu_menu);
847

    
848
        serv_table = gtk_table_new (6, 4, FALSE);
849
        gtk_widget_show (serv_table);
850
        gtk_box_pack_start (GTK_BOX (vbox2), serv_table, FALSE, FALSE, 0);
851
        gtk_table_set_row_spacings (GTK_TABLE (serv_table), VSPACING_NARROW);
852
        gtk_table_set_row_spacing (GTK_TABLE (serv_table), 3, 0);
853
        gtk_table_set_col_spacings (GTK_TABLE (serv_table), 8);
854

    
855
        nntpauth_chkbtn = gtk_check_button_new_with_label
856
                (_("This server requires authentication"));
857
        gtk_widget_show (nntpauth_chkbtn);
858
        gtk_table_attach (GTK_TABLE (serv_table), nntpauth_chkbtn, 0, 4, 4, 5,
859
                          GTK_FILL, 0, 0, 0);
860

    
861
        nntpserv_entry = gtk_entry_new ();
862
        gtk_widget_show (nntpserv_entry);
863
        gtk_table_attach (GTK_TABLE (serv_table), nntpserv_entry, 1, 4, 0, 1,
864
                          GTK_EXPAND | GTK_SHRINK | GTK_FILL,
865
                          GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
866
        gtk_table_set_row_spacing (GTK_TABLE (serv_table), 0, 0);
867

    
868
        recvserv_entry = gtk_entry_new ();
869
        gtk_widget_show (recvserv_entry);
870
        gtk_table_attach (GTK_TABLE (serv_table), recvserv_entry, 1, 4, 1, 2,
871
                          GTK_EXPAND | GTK_SHRINK | GTK_FILL,
872
                          GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
873

    
874
        smtpserv_entry = gtk_entry_new ();
875
        gtk_widget_show (smtpserv_entry);
876
        gtk_table_attach (GTK_TABLE (serv_table), smtpserv_entry, 1, 4, 2, 3,
877
                          GTK_EXPAND | GTK_SHRINK | GTK_FILL,
878
                          GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
879

    
880
        uid_entry = gtk_entry_new ();
881
        gtk_widget_show (uid_entry);
882
        gtk_widget_set_size_request (uid_entry, DEFAULT_ENTRY_WIDTH, -1);
883
        gtk_table_attach (GTK_TABLE (serv_table), uid_entry, 1, 2, 5, 6,
884
                          GTK_EXPAND | GTK_SHRINK | GTK_FILL,
885
                          GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
886

    
887
        pass_entry = gtk_entry_new ();
888
        gtk_widget_show (pass_entry);
889
        gtk_widget_set_size_request (pass_entry, DEFAULT_ENTRY_WIDTH, -1);
890
        gtk_table_attach (GTK_TABLE (serv_table), pass_entry, 3, 4, 5, 6,
891
                          GTK_EXPAND | GTK_SHRINK | GTK_FILL,
892
                          GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
893
        gtk_entry_set_visibility (GTK_ENTRY (pass_entry), FALSE);
894

    
895
        nntpserv_label = gtk_label_new (_("News server"));
896
        gtk_widget_show (nntpserv_label);
897
        gtk_table_attach (GTK_TABLE (serv_table), nntpserv_label, 0, 1, 0, 1,
898
                          GTK_FILL, 0, 0, 0);
899
        gtk_misc_set_alignment (GTK_MISC (nntpserv_label), 1, 0.5);
900

    
901
        recvserv_label = gtk_label_new (_("Server for receiving"));
902
        gtk_widget_show (recvserv_label);
903
        gtk_table_attach (GTK_TABLE (serv_table), recvserv_label, 0, 1, 1, 2,
904
                          GTK_FILL, 0, 0, 0);
905
        gtk_misc_set_alignment (GTK_MISC (recvserv_label), 1, 0.5);
906

    
907
        smtpserv_label = gtk_label_new (_("SMTP server (send)"));
908
        gtk_widget_show (smtpserv_label);
909
        gtk_table_attach (GTK_TABLE (serv_table), smtpserv_label, 0, 1, 2, 3,
910
                          GTK_FILL, 0, 0, 0);
911
        gtk_misc_set_alignment (GTK_MISC (smtpserv_label), 1, 0.5);
912
        gtk_table_set_row_spacing (GTK_TABLE (serv_table), 2, 0);
913

    
914
        uid_label = gtk_label_new (_("User ID"));
915
        gtk_widget_show (uid_label);
916
        gtk_table_attach (GTK_TABLE (serv_table), uid_label, 0, 1, 5, 6,
917
                          GTK_FILL, 0, 0, 0);
918
        gtk_misc_set_alignment (GTK_MISC (uid_label), 1, 0.5);
919

    
920
        pass_label = gtk_label_new (_("Password"));
921
        gtk_widget_show (pass_label);
922
        gtk_table_attach (GTK_TABLE (serv_table), pass_label, 2, 3, 5, 6,
923
                          0, 0, 0, 0);
924

    
925
        SET_TOGGLE_SENSITIVITY (nntpauth_chkbtn, uid_label);
926
        SET_TOGGLE_SENSITIVITY (nntpauth_chkbtn, pass_label);
927
        SET_TOGGLE_SENSITIVITY (nntpauth_chkbtn, uid_entry);
928
        SET_TOGGLE_SENSITIVITY (nntpauth_chkbtn, pass_entry);
929

    
930
        basic.acname_entry   = acname_entry;
931
        basic.default_chkbtn = default_chkbtn;
932

    
933
        basic.name_entry = name_entry;
934
        basic.addr_entry = addr_entry;
935
        basic.org_entry  = org_entry;
936

    
937
        basic.serv_frame       = serv_frame;
938
        basic.serv_table       = serv_table;
939
        basic.protocol_optmenu = optmenu;
940
        basic.recvserv_label   = recvserv_label;
941
        basic.recvserv_entry   = recvserv_entry;
942
        basic.smtpserv_label   = smtpserv_label;
943
        basic.smtpserv_entry   = smtpserv_entry;
944
        basic.nntpserv_label   = nntpserv_label;
945
        basic.nntpserv_entry   = nntpserv_entry;
946
        basic.nntpauth_chkbtn  = nntpauth_chkbtn;
947
        basic.uid_label        = uid_label;
948
        basic.pass_label       = pass_label;
949
        basic.uid_entry        = uid_entry;
950
        basic.pass_entry       = pass_entry;
951
}
952

    
953
static void prefs_account_receive_create(void)
954
{
955
        GtkWidget *vbox1;
956
        GtkWidget *frame1;
957
        GtkWidget *vbox2;
958
        GtkWidget *use_apop_chkbtn;
959
        GtkWidget *rmmail_chkbtn;
960
        GtkWidget *hbox_spc;
961
        GtkWidget *leave_time_label;
962
        GtkWidget *leave_time_entry;
963
        GtkWidget *getall_chkbtn;
964
        GtkWidget *hbox1;
965
        GtkWidget *size_limit_chkbtn;
966
        GtkWidget *size_limit_entry;
967
        GtkWidget *label;
968
        GtkWidget *filter_on_recv_chkbtn;
969
        GtkWidget *vbox3;
970
        GtkWidget *inbox_label;
971
        GtkWidget *inbox_entry;
972
        GtkWidget *inbox_btn;
973
        GtkWidget *imap_frame;
974
        GtkWidget *optmenu;
975
        GtkWidget *optmenu_menu;
976
        GtkWidget *menuitem;
977
        GtkWidget *recvatgetall_chkbtn;
978

    
979
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
980
        gtk_widget_show (vbox1);
981
        gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
982
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
983

    
984
        PACK_FRAME (vbox1, frame1, _("POP3"));
985

    
986
        vbox2 = gtk_vbox_new (FALSE, 0);
987
        gtk_widget_show (vbox2);
988
        gtk_container_add (GTK_CONTAINER (frame1), vbox2);
989
        gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
990

    
991
        PACK_CHECK_BUTTON (vbox2, use_apop_chkbtn,
992
                           _("Use secure authentication (APOP)"));
993

    
994
        PACK_CHECK_BUTTON (vbox2, rmmail_chkbtn,
995
                           _("Remove messages on server when received"));
996

    
997
        hbox1 = gtk_hbox_new (FALSE, 8);
998
        gtk_widget_show (hbox1);
999
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
1000

    
1001
        hbox_spc = gtk_hbox_new (FALSE, 0);
1002
        gtk_widget_show (hbox_spc);
1003
        gtk_box_pack_start (GTK_BOX (hbox1), hbox_spc, FALSE, FALSE, 0);
1004
        gtk_widget_set_size_request (hbox_spc, 12, -1);
1005

    
1006
        leave_time_label = gtk_label_new (_("Remove after"));
1007
        gtk_widget_show (leave_time_label);
1008
        gtk_box_pack_start (GTK_BOX (hbox1), leave_time_label, FALSE, FALSE, 0);
1009

    
1010
        leave_time_entry = gtk_entry_new ();
1011
        gtk_widget_show (leave_time_entry);
1012
        gtk_widget_set_size_request (leave_time_entry, 64, -1);
1013
        gtk_box_pack_start (GTK_BOX (hbox1), leave_time_entry, FALSE, FALSE, 0);
1014

    
1015
        leave_time_label = gtk_label_new (_("days"));
1016
        gtk_widget_show (leave_time_label);
1017
        gtk_box_pack_start (GTK_BOX (hbox1), leave_time_label, FALSE, FALSE, 0);
1018

    
1019
        SET_TOGGLE_SENSITIVITY (rmmail_chkbtn, hbox1);
1020

    
1021
        PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1022

    
1023
        hbox1 = gtk_hbox_new (FALSE, 8);
1024
        gtk_widget_show (hbox1);
1025
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
1026

    
1027
        hbox_spc = gtk_hbox_new (FALSE, 0);
1028
        gtk_widget_show (hbox_spc);
1029
        gtk_box_pack_start (GTK_BOX (hbox1), hbox_spc, FALSE, FALSE, 0);
1030
        gtk_widget_set_size_request (hbox_spc, 12, -1);
1031

    
1032
        leave_time_label = gtk_label_new (_("(0 days: remove immediately)"));
1033
        gtk_widget_show (leave_time_label);
1034
        gtk_box_pack_start (GTK_BOX (hbox1), leave_time_label, FALSE, FALSE, 0);
1035

    
1036
        SET_TOGGLE_SENSITIVITY (rmmail_chkbtn, hbox1);
1037

    
1038
        PACK_CHECK_BUTTON (vbox2, getall_chkbtn,
1039
                           _("Download all messages on server"));
1040

    
1041
        hbox1 = gtk_hbox_new (FALSE, 8);
1042
        gtk_widget_show (hbox1);
1043
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
1044

    
1045
        PACK_CHECK_BUTTON (hbox1, size_limit_chkbtn, _("Receive size limit"));
1046

    
1047
        size_limit_entry = gtk_entry_new ();
1048
        gtk_widget_show (size_limit_entry);
1049
        gtk_widget_set_size_request (size_limit_entry, 64, -1);
1050
        gtk_box_pack_start (GTK_BOX (hbox1), size_limit_entry, FALSE, FALSE, 0);
1051

    
1052
        label = gtk_label_new (_("KB"));
1053
        gtk_widget_show (label);
1054
        gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
1055

    
1056
        SET_TOGGLE_SENSITIVITY (size_limit_chkbtn, size_limit_entry);
1057

    
1058
        PACK_CHECK_BUTTON (vbox2, filter_on_recv_chkbtn,
1059
                           _("Filter messages on receiving"));
1060

    
1061
        PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1062

    
1063
        hbox1 = gtk_hbox_new (FALSE, 8);
1064
        gtk_widget_show (hbox1);
1065
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
1066

    
1067
        inbox_label = gtk_label_new (_("Default inbox"));
1068
        gtk_widget_show (inbox_label);
1069
        gtk_box_pack_start (GTK_BOX (hbox1), inbox_label, FALSE, FALSE, 0);
1070

    
1071
        inbox_entry = gtk_entry_new ();
1072
        gtk_widget_show (inbox_entry);
1073
        gtk_widget_set_size_request (inbox_entry, DEFAULT_ENTRY_WIDTH, -1);
1074
        gtk_box_pack_start (GTK_BOX (hbox1), inbox_entry, TRUE, TRUE, 0);
1075

    
1076
        inbox_btn = gtk_button_new_with_label (_(" Select... "));
1077
        gtk_widget_show (inbox_btn);
1078
        gtk_box_pack_start (GTK_BOX (hbox1), inbox_btn, FALSE, FALSE, 0);
1079
        g_signal_connect (G_OBJECT (inbox_btn), "clicked",
1080
                          G_CALLBACK (prefs_account_select_folder_cb),
1081
                          inbox_entry);
1082

    
1083
        PACK_VSPACER(vbox2, vbox3, VSPACING_NARROW_2);
1084

    
1085
        hbox1 = gtk_hbox_new (FALSE, 8);
1086
        gtk_widget_show (hbox1);
1087
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
1088

    
1089
        label = gtk_label_new
1090
                (_("(Unfiltered messages will be stored in this folder)"));
1091
        gtk_widget_show (label);
1092
        gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
1093
        gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
1094

    
1095
        PACK_FRAME (vbox1, imap_frame, _("IMAP4"));
1096

    
1097
        vbox2 = gtk_vbox_new (FALSE, 0);
1098
        gtk_widget_show (vbox2);
1099
        gtk_container_add (GTK_CONTAINER (imap_frame), vbox2);
1100
        gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1101

    
1102
        hbox1 = gtk_hbox_new (FALSE, 8);
1103
        gtk_widget_show (hbox1);
1104
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
1105

    
1106
        label = gtk_label_new (_("Authentication method"));
1107
        gtk_widget_show (label);
1108
        gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
1109

    
1110
        optmenu = gtk_option_menu_new ();
1111
        gtk_widget_show (optmenu);
1112
        gtk_box_pack_start (GTK_BOX (hbox1), optmenu, FALSE, FALSE, 0);
1113

    
1114
        optmenu_menu = gtk_menu_new ();
1115

    
1116
        MENUITEM_ADD (optmenu_menu, menuitem, _("Automatic"), 0);
1117
        MENUITEM_ADD (optmenu_menu, menuitem, "LOGIN", IMAP_AUTH_LOGIN);
1118
        MENUITEM_ADD (optmenu_menu, menuitem, "CRAM-MD5", IMAP_AUTH_CRAM_MD5);
1119

    
1120
        gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu), optmenu_menu);
1121

    
1122
        PACK_CHECK_BUTTON
1123
                (vbox1, recvatgetall_chkbtn,
1124
                 _("`Get all' checks for new messages on this account"));
1125

    
1126
        receive.pop3_frame            = frame1;
1127
        receive.use_apop_chkbtn       = use_apop_chkbtn;
1128
        receive.rmmail_chkbtn         = rmmail_chkbtn;
1129
        receive.leave_time_entry      = leave_time_entry;
1130
        receive.getall_chkbtn         = getall_chkbtn;
1131
        receive.size_limit_chkbtn     = size_limit_chkbtn;
1132
        receive.size_limit_entry      = size_limit_entry;
1133
        receive.filter_on_recv_chkbtn = filter_on_recv_chkbtn;
1134
        receive.inbox_label           = inbox_label;
1135
        receive.inbox_entry           = inbox_entry;
1136
        receive.inbox_btn             = inbox_btn;
1137

    
1138
        receive.imap_frame             = imap_frame;
1139
        receive.imap_auth_type_optmenu = optmenu;
1140

    
1141
        receive.recvatgetall_chkbtn = recvatgetall_chkbtn;
1142
}
1143

    
1144
static void prefs_account_send_create(void)
1145
{
1146
        GtkWidget *vbox1;
1147
        GtkWidget *vbox2;
1148
        GtkWidget *frame;
1149
        GtkWidget *date_chkbtn;
1150
        GtkWidget *msgid_chkbtn;
1151
        GtkWidget *hbox;
1152
        GtkWidget *customhdr_chkbtn;
1153
        GtkWidget *customhdr_edit_btn;
1154
        GtkWidget *vbox3;
1155
        GtkWidget *smtp_auth_chkbtn;
1156
        GtkWidget *optmenu;
1157
        GtkWidget *optmenu_menu;
1158
        GtkWidget *menuitem;
1159
        GtkWidget *vbox4;
1160
        GtkWidget *hbox_spc;
1161
        GtkWidget *label;
1162
        GtkWidget *smtp_uid_entry;
1163
        GtkWidget *smtp_pass_entry;
1164
        GtkWidget *vbox_spc;
1165
        /* GtkWidget *pop_bfr_smtp_chkbtn; */
1166

    
1167
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
1168
        gtk_widget_show (vbox1);
1169
        gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1170
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1171

    
1172
        PACK_FRAME (vbox1, frame, _("Header"));
1173

    
1174
        vbox2 = gtk_vbox_new (FALSE, 0);
1175
        gtk_widget_show (vbox2);
1176
        gtk_container_add (GTK_CONTAINER (frame), vbox2);
1177
        gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1178

    
1179
        PACK_CHECK_BUTTON (vbox2, date_chkbtn, _("Add Date header field"));
1180
        PACK_CHECK_BUTTON (vbox2, msgid_chkbtn, _("Generate Message-ID"));
1181

    
1182
        hbox = gtk_hbox_new (FALSE, 12);
1183
        gtk_widget_show (hbox);
1184
        gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
1185

    
1186
        PACK_CHECK_BUTTON (hbox, customhdr_chkbtn,
1187
                           _("Add user-defined header"));
1188

    
1189
        customhdr_edit_btn = gtk_button_new_with_label (_(" Edit... "));
1190
        gtk_widget_show (customhdr_edit_btn);
1191
        gtk_box_pack_start (GTK_BOX (hbox), customhdr_edit_btn,
1192
                            FALSE, FALSE, 0);
1193
        g_signal_connect (G_OBJECT (customhdr_edit_btn), "clicked",
1194
                          G_CALLBACK (prefs_account_edit_custom_header),
1195
                          NULL);
1196

    
1197
        SET_TOGGLE_SENSITIVITY (customhdr_chkbtn, customhdr_edit_btn);
1198

    
1199
        PACK_FRAME (vbox1, frame, _("Authentication"));
1200

    
1201
        vbox3 = gtk_vbox_new (FALSE, 0);
1202
        gtk_widget_show (vbox3);
1203
        gtk_container_add (GTK_CONTAINER (frame), vbox3);
1204
        gtk_container_set_border_width (GTK_CONTAINER (vbox3), 8);
1205

    
1206
        PACK_CHECK_BUTTON (vbox3, smtp_auth_chkbtn,
1207
                _("SMTP Authentication (SMTP AUTH)"));
1208

    
1209
        vbox4 = gtk_vbox_new (FALSE, 0);
1210
        gtk_widget_show (vbox4);
1211
        gtk_box_pack_start (GTK_BOX (vbox3), vbox4, FALSE, FALSE, 0);
1212

    
1213
        hbox = gtk_hbox_new (FALSE, 8);
1214
        gtk_widget_show (hbox);
1215
        gtk_box_pack_start (GTK_BOX (vbox4), hbox, FALSE, FALSE, 0);
1216

    
1217
        hbox_spc = gtk_hbox_new (FALSE, 0);
1218
        gtk_widget_show (hbox_spc);
1219
        gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1220
        gtk_widget_set_size_request (hbox_spc, 12, -1);
1221

    
1222
        label = gtk_label_new (_("Authentication method"));
1223
        gtk_widget_show (label);
1224
        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1225

    
1226
        optmenu = gtk_option_menu_new ();
1227
        gtk_widget_show (optmenu);
1228
        gtk_box_pack_start (GTK_BOX (hbox), optmenu, FALSE, FALSE, 0);
1229

    
1230
        optmenu_menu = gtk_menu_new ();
1231

    
1232
        MENUITEM_ADD (optmenu_menu, menuitem, _("Automatic"), 0);
1233
        MENUITEM_ADD (optmenu_menu, menuitem, "LOGIN", SMTPAUTH_LOGIN);
1234
        MENUITEM_ADD (optmenu_menu, menuitem, "CRAM-MD5", SMTPAUTH_CRAM_MD5);
1235
        MENUITEM_ADD (optmenu_menu, menuitem, "DIGEST-MD5", SMTPAUTH_DIGEST_MD5);
1236
        gtk_widget_set_sensitive (menuitem, FALSE);
1237

    
1238
        gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu), optmenu_menu);
1239

    
1240
        PACK_VSPACER(vbox4, vbox_spc, VSPACING_NARROW_2);
1241

    
1242
        hbox = gtk_hbox_new (FALSE, 8);
1243
        gtk_widget_show (hbox);
1244
        gtk_box_pack_start (GTK_BOX (vbox4), hbox, FALSE, FALSE, 0);
1245

    
1246
        hbox_spc = gtk_hbox_new (FALSE, 0);
1247
        gtk_widget_show (hbox_spc);
1248
        gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1249
        gtk_widget_set_size_request (hbox_spc, 12, -1);
1250

    
1251
        label = gtk_label_new (_("User ID"));
1252
        gtk_widget_show (label);
1253
        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1254

    
1255
        smtp_uid_entry = gtk_entry_new ();
1256
        gtk_widget_show (smtp_uid_entry);
1257
        gtk_widget_set_size_request (smtp_uid_entry, DEFAULT_ENTRY_WIDTH, -1);
1258
        gtk_box_pack_start (GTK_BOX (hbox), smtp_uid_entry, TRUE, TRUE, 0);
1259

    
1260
        label = gtk_label_new (_("Password"));
1261
        gtk_widget_show (label);
1262
        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1263

    
1264
        smtp_pass_entry = gtk_entry_new ();
1265
        gtk_widget_show (smtp_pass_entry);
1266
        gtk_widget_set_size_request (smtp_pass_entry, DEFAULT_ENTRY_WIDTH, -1);
1267
        gtk_box_pack_start (GTK_BOX (hbox), smtp_pass_entry, TRUE, TRUE, 0);
1268
        gtk_entry_set_visibility (GTK_ENTRY (smtp_pass_entry), FALSE);
1269

    
1270
        PACK_VSPACER(vbox4, vbox_spc, VSPACING_NARROW_2);
1271

    
1272
        hbox = gtk_hbox_new (FALSE, 8);
1273
        gtk_widget_show (hbox);
1274
        gtk_box_pack_start (GTK_BOX (vbox4), hbox, FALSE, FALSE, 0);
1275

    
1276
        hbox_spc = gtk_hbox_new (FALSE, 0);
1277
        gtk_widget_show (hbox_spc);
1278
        gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1279
        gtk_widget_set_size_request (hbox_spc, 12, -1);
1280

    
1281
        label = gtk_label_new
1282
                (_("If you leave these entries empty, the same\n"
1283
                   "user ID and password as receiving will be used."));
1284
        gtk_widget_show (label);
1285
        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1286
        gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
1287

    
1288
        SET_TOGGLE_SENSITIVITY (smtp_auth_chkbtn, vbox4);
1289

    
1290
#if 0
1291
        PACK_CHECK_BUTTON (vbox3, pop_bfr_smtp_chkbtn,
1292
                _("Authenticate with POP3 before sending"));
1293
        gtk_widget_set_sensitive(pop_bfr_smtp_chkbtn, FALSE);
1294
#endif
1295

    
1296
        p_send.date_chkbtn      = date_chkbtn;
1297
        p_send.msgid_chkbtn     = msgid_chkbtn;
1298
        p_send.customhdr_chkbtn = customhdr_chkbtn;
1299

    
1300
        p_send.smtp_auth_chkbtn       = smtp_auth_chkbtn;
1301
        p_send.smtp_auth_type_optmenu = optmenu;
1302
        p_send.smtp_uid_entry         = smtp_uid_entry;
1303
        p_send.smtp_pass_entry        = smtp_pass_entry;
1304
        /* p_send.pop_bfr_smtp_chkbtn    = pop_bfr_smtp_chkbtn; */
1305
}
1306

    
1307
static void prefs_account_compose_create(void)
1308
{
1309
        GtkWidget *vbox1;
1310
        GtkWidget *sig_vbox;
1311
        GtkWidget *sig_hbox;
1312
        GtkWidget *sigfile_radiobtn;
1313
        GtkWidget *sigcmd_radiobtn;
1314
        GtkWidget *sigpath_entry;
1315
        GtkWidget *frame;
1316
        GtkWidget *table;
1317
        GtkWidget *autocc_chkbtn;
1318
        GtkWidget *autocc_entry;
1319
        GtkWidget *autobcc_chkbtn;
1320
        GtkWidget *autobcc_entry;
1321
        GtkWidget *autoreplyto_chkbtn;
1322
        GtkWidget *autoreplyto_entry;
1323

    
1324
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
1325
        gtk_widget_show (vbox1);
1326
        gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1327
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1328

    
1329
        PACK_FRAME (vbox1, frame, _("Signature"));
1330

    
1331
        sig_vbox = gtk_vbox_new (FALSE, VSPACING_NARROW_2);
1332
        gtk_widget_show (sig_vbox);
1333
        gtk_container_add (GTK_CONTAINER (frame), sig_vbox);
1334
        gtk_container_set_border_width (GTK_CONTAINER (sig_vbox), 8);
1335

    
1336
        sig_hbox = gtk_hbox_new (FALSE, 8);
1337
        gtk_widget_show (sig_hbox);
1338
        gtk_box_pack_start (GTK_BOX (sig_vbox), sig_hbox, FALSE, FALSE, 0);
1339

    
1340
        sigfile_radiobtn = gtk_radio_button_new_with_label (NULL, _("File"));
1341
        gtk_widget_show (sigfile_radiobtn);
1342
        gtk_box_pack_start (GTK_BOX (sig_hbox), sigfile_radiobtn,
1343
                            FALSE, FALSE, 0);
1344
        g_object_set_data (G_OBJECT (sigfile_radiobtn), MENU_VAL_ID,
1345
                           GINT_TO_POINTER (SIG_FILE));
1346

    
1347
        sigcmd_radiobtn = gtk_radio_button_new_with_label_from_widget
1348
                (GTK_RADIO_BUTTON(sigfile_radiobtn), _("Command output"));
1349
        gtk_widget_show (sigcmd_radiobtn);
1350
        gtk_box_pack_start (GTK_BOX (sig_hbox), sigcmd_radiobtn,
1351
                            FALSE, FALSE, 0);
1352
        g_object_set_data (G_OBJECT (sigcmd_radiobtn), MENU_VAL_ID,
1353
                           GINT_TO_POINTER (SIG_COMMAND));
1354

    
1355
        sigpath_entry = gtk_entry_new ();
1356
        gtk_widget_show (sigpath_entry);
1357
        gtk_box_pack_start (GTK_BOX (sig_vbox), sigpath_entry, TRUE, TRUE, 0);
1358

    
1359
        PACK_FRAME (vbox1, frame, _("Automatically set the following addresses"));
1360

    
1361
        table =  gtk_table_new (3, 2, FALSE);
1362
        gtk_widget_show (table);
1363
        gtk_container_add (GTK_CONTAINER (frame), table);
1364
        gtk_container_set_border_width (GTK_CONTAINER (table), 8);
1365
        gtk_table_set_row_spacings (GTK_TABLE (table), VSPACING_NARROW_2);
1366
        gtk_table_set_col_spacings (GTK_TABLE (table), 8);
1367

    
1368
        autocc_chkbtn = gtk_check_button_new_with_label (_("Cc"));
1369
        gtk_widget_show (autocc_chkbtn);
1370
        gtk_table_attach (GTK_TABLE (table), autocc_chkbtn, 0, 1, 0, 1,
1371
                          GTK_FILL, 0, 0, 0);
1372

    
1373
        autocc_entry = gtk_entry_new ();
1374
        gtk_widget_show (autocc_entry);
1375
        gtk_table_attach (GTK_TABLE (table), autocc_entry, 1, 2, 0, 1,
1376
                          GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1377
                          GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1378

    
1379
        SET_TOGGLE_SENSITIVITY (autocc_chkbtn, autocc_entry);
1380

    
1381
        autobcc_chkbtn = gtk_check_button_new_with_label (_("Bcc"));
1382
        gtk_widget_show (autobcc_chkbtn);
1383
        gtk_table_attach (GTK_TABLE (table), autobcc_chkbtn, 0, 1, 1, 2,
1384
                          GTK_FILL, 0, 0, 0);
1385

    
1386
        autobcc_entry = gtk_entry_new ();
1387
        gtk_widget_show (autobcc_entry);
1388
        gtk_table_attach (GTK_TABLE (table), autobcc_entry, 1, 2, 1, 2,
1389
                          GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1390
                          GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1391

    
1392
        SET_TOGGLE_SENSITIVITY (autobcc_chkbtn, autobcc_entry);
1393

    
1394
        autoreplyto_chkbtn = gtk_check_button_new_with_label (_("Reply-To"));
1395
        gtk_widget_show (autoreplyto_chkbtn);
1396
        gtk_table_attach (GTK_TABLE (table), autoreplyto_chkbtn, 0, 1, 2, 3,
1397
                          GTK_FILL, 0, 0, 0);
1398

    
1399
        autoreplyto_entry = gtk_entry_new ();
1400
        gtk_widget_show (autoreplyto_entry);
1401
        gtk_table_attach (GTK_TABLE (table), autoreplyto_entry, 1, 2, 2, 3,
1402
                          GTK_EXPAND | GTK_SHRINK | GTK_FILL,
1403
                          GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);
1404

    
1405
        SET_TOGGLE_SENSITIVITY (autoreplyto_chkbtn, autoreplyto_entry);
1406

    
1407

    
1408
        compose.sigfile_radiobtn = sigfile_radiobtn;
1409
        compose.sigpath_entry    = sigpath_entry;
1410

    
1411
        compose.autocc_chkbtn      = autocc_chkbtn;
1412
        compose.autocc_entry       = autocc_entry;
1413
        compose.autobcc_chkbtn     = autobcc_chkbtn;
1414
        compose.autobcc_entry      = autobcc_entry;
1415
        compose.autoreplyto_chkbtn = autoreplyto_chkbtn;
1416
        compose.autoreplyto_entry  = autoreplyto_entry;
1417
}
1418

    
1419
#if USE_GPGME
1420
static void prefs_account_privacy_create(void)
1421
{
1422
        GtkWidget *vbox1;
1423
        GtkWidget *frame1;
1424
        GtkWidget *vbox2;
1425
        GtkWidget *hbox1;
1426
        GtkWidget *label;
1427
        GtkWidget *default_encrypt_chkbtn;
1428
        GtkWidget *default_sign_chkbtn;
1429
        GtkWidget *ascii_armored_chkbtn;
1430
        GtkWidget *clearsign_chkbtn;
1431
        GtkWidget *defaultkey_radiobtn;
1432
        GtkWidget *emailkey_radiobtn;
1433
        GtkWidget *customkey_radiobtn;
1434
        GtkWidget *customkey_entry;
1435

    
1436
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
1437
        gtk_widget_show (vbox1);
1438
        gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1439
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1440

    
1441
        vbox2 = gtk_vbox_new (FALSE, 0);
1442
        gtk_widget_show (vbox2);
1443
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1444

    
1445
        PACK_CHECK_BUTTON (vbox2, default_encrypt_chkbtn,
1446
                           _("Encrypt message by default"));
1447
        PACK_CHECK_BUTTON (vbox2, default_sign_chkbtn,
1448
                           _("Sign message by default"));
1449
        PACK_CHECK_BUTTON (vbox2, ascii_armored_chkbtn,
1450
                           _("Use ASCII-armored format for encryption"));
1451
        PACK_CHECK_BUTTON (vbox2, clearsign_chkbtn,
1452
                           _("Use clear text signature"));
1453
        g_signal_connect (G_OBJECT (ascii_armored_chkbtn), "toggled",
1454
                          G_CALLBACK (prefs_account_ascii_armored_warning),
1455
                          NULL);
1456

    
1457
        PACK_FRAME (vbox1, frame1, _("Sign key"));
1458

    
1459
        vbox2 = gtk_vbox_new (FALSE, 0);
1460
        gtk_widget_show (vbox2);
1461
        gtk_container_add (GTK_CONTAINER (frame1), vbox2);
1462
        gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1463

    
1464
        defaultkey_radiobtn = gtk_radio_button_new_with_label
1465
                (NULL, _("Use default GnuPG key"));
1466
        gtk_widget_show (defaultkey_radiobtn);
1467
        gtk_box_pack_start (GTK_BOX (vbox2), defaultkey_radiobtn,
1468
                            FALSE, FALSE, 0);
1469
        g_object_set_data (G_OBJECT (defaultkey_radiobtn), MENU_VAL_ID,
1470
                           GINT_TO_POINTER (SIGN_KEY_DEFAULT));
1471

    
1472
        emailkey_radiobtn = gtk_radio_button_new_with_label_from_widget
1473
                (GTK_RADIO_BUTTON (defaultkey_radiobtn),
1474
                 _("Select key by your email address"));
1475
        gtk_widget_show (emailkey_radiobtn);
1476
        gtk_box_pack_start (GTK_BOX (vbox2), emailkey_radiobtn,
1477
                            FALSE, FALSE, 0);
1478
        g_object_set_data (G_OBJECT (emailkey_radiobtn), MENU_VAL_ID,
1479
                           GINT_TO_POINTER (SIGN_KEY_BY_FROM));
1480

    
1481
        customkey_radiobtn = gtk_radio_button_new_with_label_from_widget
1482
                (GTK_RADIO_BUTTON (defaultkey_radiobtn),
1483
                 _("Specify key manually"));
1484
        gtk_widget_show (customkey_radiobtn);
1485
        gtk_box_pack_start (GTK_BOX (vbox2), customkey_radiobtn,
1486
                            FALSE, FALSE, 0);
1487
        g_object_set_data (G_OBJECT (customkey_radiobtn), MENU_VAL_ID,
1488
                           GINT_TO_POINTER (SIGN_KEY_CUSTOM));
1489

    
1490
        hbox1 = gtk_hbox_new (FALSE, 8);
1491
        gtk_widget_show (hbox1);
1492
        gtk_box_pack_start (GTK_BOX (vbox2), hbox1, FALSE, FALSE, 0);
1493

    
1494
        label = gtk_label_new ("");
1495
        gtk_widget_show (label);
1496
        gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
1497
        gtk_widget_set_size_request (label, 16, -1);
1498

    
1499
        label = gtk_label_new (_("User or key ID:"));
1500
        gtk_widget_show (label);
1501
        gtk_box_pack_start (GTK_BOX (hbox1), label, FALSE, FALSE, 0);
1502

    
1503
        customkey_entry = gtk_entry_new ();
1504
        gtk_widget_show (customkey_entry);
1505
        gtk_box_pack_start (GTK_BOX (hbox1), customkey_entry,
1506
                            TRUE, TRUE, 0);
1507

    
1508
        SET_TOGGLE_SENSITIVITY (customkey_radiobtn, customkey_entry);
1509

    
1510
        privacy.default_encrypt_chkbtn = default_encrypt_chkbtn;
1511
        privacy.default_sign_chkbtn    = default_sign_chkbtn;
1512
        privacy.ascii_armored_chkbtn   = ascii_armored_chkbtn;
1513
        privacy.clearsign_chkbtn       = clearsign_chkbtn;
1514
        privacy.defaultkey_radiobtn    = defaultkey_radiobtn;
1515
        privacy.emailkey_radiobtn      = emailkey_radiobtn;
1516
        privacy.customkey_radiobtn     = customkey_radiobtn;
1517
        privacy.customkey_entry        = customkey_entry;
1518
}
1519
#endif /* USE_GPGME */
1520

    
1521
#if USE_SSL
1522

    
1523
#define CREATE_RADIO_BUTTON(box, btn, btn_p, label, data)                \
1524
{                                                                        \
1525
        btn = gtk_radio_button_new_with_label_from_widget                \
1526
                (GTK_RADIO_BUTTON (btn_p), label);                        \
1527
        gtk_widget_show (btn);                                                \
1528
        gtk_box_pack_start (GTK_BOX (box), btn, FALSE, FALSE, 0);        \
1529
        g_object_set_data (G_OBJECT (btn), MENU_VAL_ID,                        \
1530
                           GINT_TO_POINTER (data));                        \
1531
}
1532

    
1533
#define CREATE_RADIO_BUTTONS(box,                                        \
1534
                             btn1, btn1_label, btn1_data,                \
1535
                             btn2, btn2_label, btn2_data,                \
1536
                             btn3, btn3_label, btn3_data)                \
1537
{                                                                        \
1538
        btn1 = gtk_radio_button_new_with_label(NULL, btn1_label);        \
1539
        gtk_widget_show (btn1);                                                \
1540
        gtk_box_pack_start (GTK_BOX (box), btn1, FALSE, FALSE, 0);        \
1541
        g_object_set_data (G_OBJECT (btn1), MENU_VAL_ID,                \
1542
                           GINT_TO_POINTER (btn1_data));                \
1543
                                                                        \
1544
        CREATE_RADIO_BUTTON(box, btn2, btn1, btn2_label, btn2_data);        \
1545
        CREATE_RADIO_BUTTON(box, btn3, btn1, btn3_label, btn3_data);        \
1546
}
1547

    
1548
static void prefs_account_ssl_create(void)
1549
{
1550
        GtkWidget *vbox1;
1551

    
1552
        GtkWidget *pop_frame;
1553
        GtkWidget *vbox2;
1554
        GtkWidget *pop_nossl_radiobtn;
1555
        GtkWidget *pop_ssltunnel_radiobtn;
1556
        GtkWidget *pop_starttls_radiobtn;
1557

    
1558
        GtkWidget *imap_frame;
1559
        GtkWidget *vbox3;
1560
        GtkWidget *imap_nossl_radiobtn;
1561
        GtkWidget *imap_ssltunnel_radiobtn;
1562
        GtkWidget *imap_starttls_radiobtn;
1563

    
1564
        GtkWidget *nntp_frame;
1565
        GtkWidget *vbox4;
1566
        GtkWidget *nntp_nossl_radiobtn;
1567
        GtkWidget *nntp_ssltunnel_radiobtn;
1568

    
1569
        GtkWidget *send_frame;
1570
        GtkWidget *vbox5;
1571
        GtkWidget *smtp_nossl_radiobtn;
1572
        GtkWidget *smtp_ssltunnel_radiobtn;
1573
        GtkWidget *smtp_starttls_radiobtn;
1574

    
1575
        GtkWidget *vbox6;
1576
        GtkWidget *use_nonblocking_ssl_chkbtn;
1577
        GtkWidget *hbox;
1578
        GtkWidget *hbox_spc;
1579
        GtkWidget *label;
1580

    
1581
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
1582
        gtk_widget_show (vbox1);
1583
        gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1584
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1585

    
1586
        PACK_FRAME (vbox1, pop_frame, _("POP3"));
1587
        vbox2 = gtk_vbox_new (FALSE, 0);
1588
        gtk_widget_show (vbox2);
1589
        gtk_container_add (GTK_CONTAINER (pop_frame), vbox2);
1590
        gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
1591

    
1592
        CREATE_RADIO_BUTTONS(vbox2,
1593
                             pop_nossl_radiobtn,
1594
                             _("Don't use SSL"),
1595
                             SSL_NONE,
1596
                             pop_ssltunnel_radiobtn,
1597
                             _("Use SSL for POP3 connection"),
1598
                             SSL_TUNNEL,
1599
                             pop_starttls_radiobtn,
1600
                             _("Use STARTTLS command to start SSL session"),
1601
                             SSL_STARTTLS);
1602

    
1603
        PACK_FRAME (vbox1, imap_frame, _("IMAP4"));
1604
        vbox3 = gtk_vbox_new (FALSE, 0);
1605
        gtk_widget_show (vbox3);
1606
        gtk_container_add (GTK_CONTAINER (imap_frame), vbox3);
1607
        gtk_container_set_border_width (GTK_CONTAINER (vbox3), 8);
1608

    
1609
        CREATE_RADIO_BUTTONS(vbox3,
1610
                             imap_nossl_radiobtn,
1611
                             _("Don't use SSL"),
1612
                             SSL_NONE,
1613
                             imap_ssltunnel_radiobtn,
1614
                             _("Use SSL for IMAP4 connection"),
1615
                             SSL_TUNNEL,
1616
                             imap_starttls_radiobtn,
1617
                             _("Use STARTTLS command to start SSL session"),
1618
                             SSL_STARTTLS);
1619

    
1620
        PACK_FRAME (vbox1, nntp_frame, _("NNTP"));
1621
        vbox4 = gtk_vbox_new (FALSE, 0);
1622
        gtk_widget_show (vbox4);
1623
        gtk_container_add (GTK_CONTAINER (nntp_frame), vbox4);
1624
        gtk_container_set_border_width (GTK_CONTAINER (vbox4), 8);
1625

    
1626
        nntp_nossl_radiobtn =
1627
                gtk_radio_button_new_with_label (NULL, _("Don't use SSL"));
1628
        gtk_widget_show (nntp_nossl_radiobtn);
1629
        gtk_box_pack_start (GTK_BOX (vbox4), nntp_nossl_radiobtn,
1630
                            FALSE, FALSE, 0);
1631
        g_object_set_data (G_OBJECT (nntp_nossl_radiobtn), MENU_VAL_ID,
1632
                           GINT_TO_POINTER (SSL_NONE));
1633

    
1634
        CREATE_RADIO_BUTTON(vbox4, nntp_ssltunnel_radiobtn, nntp_nossl_radiobtn,
1635
                            _("Use SSL for NNTP connection"), SSL_TUNNEL);
1636

    
1637
        PACK_FRAME (vbox1, send_frame, _("Send (SMTP)"));
1638
        vbox5 = gtk_vbox_new (FALSE, 0);
1639
        gtk_widget_show (vbox5);
1640
        gtk_container_add (GTK_CONTAINER (send_frame), vbox5);
1641
        gtk_container_set_border_width (GTK_CONTAINER (vbox5), 8);
1642

    
1643
        CREATE_RADIO_BUTTONS(vbox5,
1644
                             smtp_nossl_radiobtn,
1645
                             _("Don't use SSL"),
1646
                             SSL_NONE,
1647
                             smtp_ssltunnel_radiobtn,
1648
                             _("Use SSL for SMTP connection"),
1649
                             SSL_TUNNEL,
1650
                             smtp_starttls_radiobtn,
1651
                             _("Use STARTTLS command to start SSL session"),
1652
                             SSL_STARTTLS);
1653

    
1654
        vbox6 = gtk_vbox_new (FALSE, 0);
1655
        gtk_widget_show (vbox6);
1656
        gtk_box_pack_start (GTK_BOX (vbox1), vbox6, FALSE, FALSE, 0);
1657

    
1658
        PACK_CHECK_BUTTON(vbox6, use_nonblocking_ssl_chkbtn,
1659
                          _("Use non-blocking SSL"));
1660

    
1661
        hbox = gtk_hbox_new (FALSE, 0);
1662
        gtk_widget_show (hbox);
1663
        gtk_box_pack_start (GTK_BOX (vbox6), hbox, FALSE, FALSE, 0);
1664

    
1665
        hbox_spc = gtk_hbox_new (FALSE, 0);
1666
        gtk_widget_show (hbox_spc);
1667
        gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1668
        gtk_widget_set_size_request (hbox_spc, 16, -1);
1669

    
1670
        label = gtk_label_new
1671
                (_("(Turn this off if you have problems in SSL connection)"));
1672
        gtk_widget_show (label);
1673
        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1674

    
1675
        ssl.pop_frame               = pop_frame;
1676
        ssl.pop_nossl_radiobtn      = pop_nossl_radiobtn;
1677
        ssl.pop_ssltunnel_radiobtn  = pop_ssltunnel_radiobtn;
1678
        ssl.pop_starttls_radiobtn   = pop_starttls_radiobtn;
1679

    
1680
        ssl.imap_frame              = imap_frame;
1681
        ssl.imap_nossl_radiobtn     = imap_nossl_radiobtn;
1682
        ssl.imap_ssltunnel_radiobtn = imap_ssltunnel_radiobtn;
1683
        ssl.imap_starttls_radiobtn  = imap_starttls_radiobtn;
1684

    
1685
        ssl.nntp_frame              = nntp_frame;
1686
        ssl.nntp_nossl_radiobtn     = nntp_nossl_radiobtn;
1687
        ssl.nntp_ssltunnel_radiobtn = nntp_ssltunnel_radiobtn;
1688

    
1689
        ssl.send_frame              = send_frame;
1690
        ssl.smtp_nossl_radiobtn     = smtp_nossl_radiobtn;
1691
        ssl.smtp_ssltunnel_radiobtn = smtp_ssltunnel_radiobtn;
1692
        ssl.smtp_starttls_radiobtn  = smtp_starttls_radiobtn;
1693

    
1694
        ssl.use_nonblocking_ssl_chkbtn = use_nonblocking_ssl_chkbtn;
1695
}
1696

    
1697
#undef CREATE_RADIO_BUTTONS
1698
#undef CREATE_RADIO_BUTTON
1699

    
1700
#endif /* USE_SSL */
1701

    
1702
static void prefs_account_advanced_create(void)
1703
{
1704
        GtkWidget *vbox1;
1705
        GtkWidget *vbox2;
1706
        GtkWidget *hbox1;
1707
        GtkWidget *checkbtn_smtpport;
1708
        GtkWidget *entry_smtpport;
1709
        GtkWidget *hbox_popport;
1710
        GtkWidget *checkbtn_popport;
1711
        GtkWidget *entry_popport;
1712
        GtkWidget *hbox_imapport;
1713
        GtkWidget *checkbtn_imapport;
1714
        GtkWidget *entry_imapport;
1715
        GtkWidget *hbox_nntpport;
1716
        GtkWidget *checkbtn_nntpport;
1717
        GtkWidget *entry_nntpport;
1718
        GtkWidget *checkbtn_domain;
1719
        GtkWidget *entry_domain;
1720
        GtkWidget *imap_frame;
1721
        GtkWidget *imapdir_label;
1722
        GtkWidget *imapdir_entry;
1723
        GtkWidget *folder_frame;
1724
        GtkWidget *vbox3;
1725
        GtkWidget *table;
1726
        GtkWidget *sent_folder_chkbtn;
1727
        GtkWidget *sent_folder_entry;
1728
        GtkWidget *draft_folder_chkbtn;
1729
        GtkWidget *draft_folder_entry;
1730
        GtkWidget *trash_folder_chkbtn;
1731
        GtkWidget *trash_folder_entry;
1732

    
1733
#define PACK_HBOX(hbox) \
1734
{ \
1735
        hbox = gtk_hbox_new (FALSE, 8); \
1736
        gtk_widget_show (hbox); \
1737
        gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0); \
1738
}
1739

    
1740
#define PACK_PORT_ENTRY(box, entry) \
1741
{ \
1742
        entry = gtk_entry_new (); \
1743
        gtk_entry_set_max_length (GTK_ENTRY(entry), 5); \
1744
        gtk_widget_show (entry); \
1745
        gtk_box_pack_start (GTK_BOX (box), entry, FALSE, FALSE, 0); \
1746
        gtk_widget_set_size_request (entry, 64, -1); \
1747
}
1748

    
1749
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
1750
        gtk_widget_show (vbox1);
1751
        gtk_container_add (GTK_CONTAINER (dialog.notebook), vbox1);
1752
        gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
1753

    
1754
        vbox2 = gtk_vbox_new (FALSE, VSPACING_NARROW_2);
1755
        gtk_widget_show (vbox2);
1756
        gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, FALSE, 0);
1757

    
1758
        PACK_HBOX (hbox1);
1759
        PACK_CHECK_BUTTON (hbox1, checkbtn_smtpport, _("Specify SMTP port"));
1760
        PACK_PORT_ENTRY (hbox1, entry_smtpport);
1761
        SET_TOGGLE_SENSITIVITY (checkbtn_smtpport, entry_smtpport);
1762

    
1763
        PACK_HBOX (hbox_popport);
1764
        PACK_CHECK_BUTTON (hbox_popport, checkbtn_popport,
1765
                           _("Specify POP3 port"));
1766
        PACK_PORT_ENTRY (hbox_popport, entry_popport);
1767
        SET_TOGGLE_SENSITIVITY (checkbtn_popport, entry_popport);
1768

    
1769
        PACK_HBOX (hbox_imapport);
1770
        PACK_CHECK_BUTTON (hbox_imapport, checkbtn_imapport,
1771
                           _("Specify IMAP4 port"));
1772
        PACK_PORT_ENTRY (hbox_imapport, entry_imapport);
1773
        SET_TOGGLE_SENSITIVITY (checkbtn_imapport, entry_imapport);
1774

    
1775
        PACK_HBOX (hbox_nntpport);
1776
        PACK_CHECK_BUTTON (hbox_nntpport, checkbtn_nntpport,
1777
                           _("Specify NNTP port"));
1778
        PACK_PORT_ENTRY (hbox_nntpport, entry_nntpport);
1779
        SET_TOGGLE_SENSITIVITY (checkbtn_nntpport, entry_nntpport);
1780

    
1781
        PACK_HBOX (hbox1);
1782
        PACK_CHECK_BUTTON (hbox1, checkbtn_domain, _("Specify domain name"));
1783

    
1784
        entry_domain = gtk_entry_new ();
1785
        gtk_widget_show (entry_domain);
1786
        gtk_box_pack_start (GTK_BOX (hbox1), entry_domain, TRUE, TRUE, 0);
1787
        SET_TOGGLE_SENSITIVITY (checkbtn_domain, entry_domain);
1788

    
1789
        PACK_FRAME (vbox1, imap_frame, _("IMAP4"));
1790

    
1791
        vbox3 = gtk_vbox_new (FALSE, VSPACING_NARROW);
1792
        gtk_widget_show (vbox3);
1793
        gtk_container_add (GTK_CONTAINER (imap_frame), vbox3);
1794
        gtk_container_set_border_width (GTK_CONTAINER (vbox3), 8);
1795

    
1796
        hbox1 = gtk_hbox_new (FALSE, 8);
1797
        gtk_widget_show (hbox1);
1798
        gtk_box_pack_start (GTK_BOX (vbox3), hbox1, FALSE, FALSE, 0);
1799

    
1800
        imapdir_label = gtk_label_new (_("IMAP server directory"));
1801
        gtk_widget_show (imapdir_label);
1802
        gtk_box_pack_start (GTK_BOX (hbox1), imapdir_label, FALSE, FALSE, 0);
1803

    
1804
        imapdir_entry = gtk_entry_new();
1805
        gtk_widget_show (imapdir_entry);
1806
        gtk_box_pack_start (GTK_BOX (hbox1), imapdir_entry, TRUE, TRUE, 0);
1807

    
1808
#undef PACK_HBOX
1809
#undef PACK_PORT_ENTRY
1810

    
1811
        /* special folder setting (maybe these options are redundant) */
1812

    
1813
        PACK_FRAME (vbox1, folder_frame, _("Folder"));
1814

    
1815
        vbox3 = gtk_vbox_new (FALSE, 0);
1816
        gtk_widget_show (vbox3);
1817
        gtk_container_add (GTK_CONTAINER (folder_frame), vbox3);
1818
        gtk_container_set_border_width (GTK_CONTAINER (vbox3), 8);
1819

    
1820
        table = gtk_table_new (3, 3, FALSE);
1821
        gtk_widget_show (table);
1822
        gtk_container_add (GTK_CONTAINER (vbox3), table);
1823
        gtk_table_set_row_spacings (GTK_TABLE (table), VSPACING_NARROW_2);
1824
        gtk_table_set_col_spacings (GTK_TABLE (table), 4);
1825

    
1826
#define SET_CHECK_BTN_AND_ENTRY(label, chkbtn, entry, n)                \
1827
{                                                                        \
1828
        GtkWidget *button;                                                \
1829
                                                                        \
1830
        chkbtn = gtk_check_button_new_with_label (label);                \
1831
        gtk_widget_show (chkbtn);                                        \
1832
        gtk_table_attach (GTK_TABLE (table), chkbtn,                        \
1833
                          0, 1, n, n + 1, GTK_FILL, 0, 0, 0);                \
1834
                                                                        \
1835
        entry = gtk_entry_new ();                                        \
1836
        gtk_widget_show (entry);                                        \
1837
        gtk_table_attach (GTK_TABLE (table), entry, 1, 2, n, n + 1,        \
1838
                          GTK_EXPAND | GTK_SHRINK | GTK_FILL,                \
1839
                          GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0);        \
1840
                                                                        \
1841
        button = gtk_button_new_with_label (_(" ... "));                \
1842
        gtk_widget_show (button);                                        \
1843
        gtk_table_attach (GTK_TABLE (table), button,                        \
1844
                          2, 3, n, n + 1, GTK_FILL, 0, 0, 0);                \
1845
        g_signal_connect                                                \
1846
                (G_OBJECT (button), "clicked",                                \
1847
                 G_CALLBACK (prefs_account_select_folder_cb),                \
1848
                 entry);                                                \
1849
                                                                        \
1850
        SET_TOGGLE_SENSITIVITY (chkbtn, entry);                                \
1851
        SET_TOGGLE_SENSITIVITY (chkbtn, button);                        \
1852
}
1853

    
1854
        SET_CHECK_BTN_AND_ENTRY(_("Put sent messages in"),
1855
                                sent_folder_chkbtn, sent_folder_entry, 0);
1856
        SET_CHECK_BTN_AND_ENTRY(_("Put draft messages in"),
1857
                                draft_folder_chkbtn, draft_folder_entry, 1);
1858
        SET_CHECK_BTN_AND_ENTRY(_("Put deleted messages in"),
1859
                                trash_folder_chkbtn, trash_folder_entry, 2);
1860

    
1861
        advanced.smtpport_chkbtn        = checkbtn_smtpport;
1862
        advanced.smtpport_entry                = entry_smtpport;
1863
        advanced.popport_hbox                = hbox_popport;
1864
        advanced.popport_chkbtn                = checkbtn_popport;
1865
        advanced.popport_entry                = entry_popport;
1866
        advanced.imapport_hbox                = hbox_imapport;
1867
        advanced.imapport_chkbtn        = checkbtn_imapport;
1868
        advanced.imapport_entry                = entry_imapport;
1869
        advanced.nntpport_hbox                = hbox_nntpport;
1870
        advanced.nntpport_chkbtn        = checkbtn_nntpport;
1871
        advanced.nntpport_entry                = entry_nntpport;
1872
        advanced.domain_chkbtn                = checkbtn_domain;
1873
        advanced.domain_entry                = entry_domain;
1874

    
1875
        advanced.imap_frame             = imap_frame;
1876
        advanced.imapdir_entry          = imapdir_entry;
1877

    
1878
        advanced.sent_folder_chkbtn  = sent_folder_chkbtn;
1879
        advanced.sent_folder_entry   = sent_folder_entry;
1880
        advanced.draft_folder_chkbtn = draft_folder_chkbtn;
1881
        advanced.draft_folder_entry  = draft_folder_entry;
1882
        advanced.trash_folder_chkbtn = trash_folder_chkbtn;
1883
        advanced.trash_folder_entry  = trash_folder_entry;
1884
}
1885

    
1886
static gint prefs_account_deleted(GtkWidget *widget, GdkEventAny *event,
1887
                                  gpointer data)
1888
{
1889
        prefs_account_cancel();
1890
        return TRUE;
1891
}
1892

    
1893
static gboolean prefs_account_key_pressed(GtkWidget *widget, GdkEventKey *event,
1894
                                          gpointer data)
1895
{
1896
        if (event && event->keyval == GDK_Escape)
1897
                prefs_account_cancel();
1898
        return FALSE;
1899
}
1900

    
1901
static void prefs_account_ok(void)
1902
{
1903
        if (prefs_account_apply() == 0)
1904
                gtk_main_quit();
1905
}
1906

    
1907
static gint prefs_account_apply(void)
1908
{
1909
        RecvProtocol protocol;
1910
        GtkWidget *menu;
1911
        GtkWidget *menuitem;
1912

    
1913
        menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(basic.protocol_optmenu));
1914
        menuitem = gtk_menu_get_active(GTK_MENU(menu));
1915
        protocol = GPOINTER_TO_INT
1916
                (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
1917

    
1918
        if (*gtk_entry_get_text(GTK_ENTRY(basic.acname_entry)) == '\0') {
1919
                alertpanel_error(_("Account name is not entered."));
1920
                return -1;
1921
        }
1922
        if (*gtk_entry_get_text(GTK_ENTRY(basic.addr_entry)) == '\0') {
1923
                alertpanel_error(_("Mail address is not entered."));
1924
                return -1;
1925
        }
1926
        if ((protocol == A_POP3 || protocol == A_LOCAL) &&
1927
            *gtk_entry_get_text(GTK_ENTRY(basic.smtpserv_entry)) == '\0') {
1928
                alertpanel_error(_("SMTP server is not entered."));
1929
                return -1;
1930
        }
1931
        if ((protocol == A_POP3 || protocol == A_IMAP4) &&
1932
            *gtk_entry_get_text(GTK_ENTRY(basic.uid_entry)) == '\0') {
1933
                alertpanel_error(_("User ID is not entered."));
1934
                return -1;
1935
        }
1936
        if (protocol == A_POP3 &&
1937
            *gtk_entry_get_text(GTK_ENTRY(basic.recvserv_entry)) == '\0') {
1938
                alertpanel_error(_("POP3 server is not entered."));
1939
                return -1;
1940
        }
1941
        if (protocol == A_IMAP4 &&
1942
            *gtk_entry_get_text(GTK_ENTRY(basic.recvserv_entry)) == '\0') {
1943
                alertpanel_error(_("IMAP4 server is not entered."));
1944
                return -1;
1945
        }
1946
        if (protocol == A_NNTP &&
1947
            *gtk_entry_get_text(GTK_ENTRY(basic.nntpserv_entry)) == '\0') {
1948
                alertpanel_error(_("NNTP server is not entered."));
1949
                return -1;
1950
        }
1951

    
1952
        prefs_set_data_from_dialog(param);
1953
        return 0;
1954
}
1955

    
1956
static void prefs_account_cancel(void)
1957
{
1958
        cancelled = TRUE;
1959
        gtk_main_quit();
1960
}
1961

    
1962
static void prefs_account_select_folder_cb(GtkWidget *widget, gpointer data)
1963
{
1964
        FolderItem *item;
1965
        gchar *id;
1966

    
1967
        item = foldersel_folder_sel(NULL, FOLDER_SEL_COPY, NULL);
1968
        if (item && item->path) {
1969
                id = folder_item_get_identifier(item);
1970
                if (id) {
1971
                        gtk_entry_set_text(GTK_ENTRY(data), id);
1972
                        g_free(id);
1973
                }
1974
        }
1975
}
1976

    
1977
static void prefs_account_edit_custom_header(void)
1978
{
1979
        prefs_custom_header_open(&tmp_ac_prefs);
1980
}
1981

    
1982
static void prefs_account_enum_set_data_from_radiobtn(PrefParam *pparam)
1983
{
1984
        GtkRadioButton *radiobtn;
1985
        GSList *group;
1986

    
1987
        radiobtn = GTK_RADIO_BUTTON (*pparam->widget);
1988
        group = gtk_radio_button_get_group (radiobtn);
1989
        while (group != NULL) {
1990
                GtkToggleButton *btn = GTK_TOGGLE_BUTTON (group->data);
1991
                if (gtk_toggle_button_get_active (btn)) {
1992
                        *((gint *)pparam->data) = GPOINTER_TO_INT
1993
                                (g_object_get_data (G_OBJECT (btn),
1994
                                                    MENU_VAL_ID));
1995
                        break;
1996
                }
1997
                group = group->next;
1998
        }
1999
}
2000

    
2001
static void prefs_account_enum_set_radiobtn(PrefParam *pparam)
2002
{
2003
        GtkRadioButton *radiobtn;
2004
        GSList *group;
2005
        gpointer data;
2006

    
2007
        data = GINT_TO_POINTER (*((gint *)pparam->data));
2008
        radiobtn = GTK_RADIO_BUTTON (*pparam->widget);
2009
        group = gtk_radio_button_get_group (radiobtn);
2010
        while (group != NULL) {
2011
                GtkToggleButton *btn = GTK_TOGGLE_BUTTON (group->data);
2012
                gpointer data1;
2013

    
2014
                data1 = g_object_get_data (G_OBJECT (btn), MENU_VAL_ID);
2015
                if (data1 == data) {
2016
                        gtk_toggle_button_set_active (btn, TRUE);
2017
                        break;
2018
                }
2019
                group = group->next;
2020
        }
2021
}
2022

    
2023

    
2024
#if USE_GPGME
2025
static void prefs_account_ascii_armored_warning(GtkWidget *widget)
2026
{
2027
        if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)) &&
2028
            gtk_notebook_get_current_page(GTK_NOTEBOOK(dialog.notebook)) > 0)
2029
                alertpanel_warning
2030
                        (_("It's not recommended to use the old style ASCII-armored\n"
2031
                           "mode for encrypted messages. It doesn't comply with the\n"
2032
                           "RFC 3156 - MIME Security with OpenPGP."));
2033
}
2034
#endif /* USE_GPGME */
2035

    
2036
static void prefs_account_protocol_set_data_from_optmenu(PrefParam *pparam)
2037
{
2038
        GtkWidget *menu;
2039
        GtkWidget *menuitem;
2040

    
2041
        menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
2042
        menuitem = gtk_menu_get_active(GTK_MENU(menu));
2043
        *((RecvProtocol *)pparam->data) = GPOINTER_TO_INT
2044
                (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
2045
}
2046

    
2047
static void prefs_account_protocol_set_optmenu(PrefParam *pparam)
2048
{
2049
        RecvProtocol protocol;
2050
        GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
2051
        GtkWidget *menu;
2052
        GtkWidget *menuitem;
2053
        gint index;
2054

    
2055
        protocol = *((RecvProtocol *)pparam->data);
2056
        index = menu_find_option_menu_index
2057
                (optmenu, GINT_TO_POINTER(protocol), NULL);
2058
        if (index < 0) return;
2059
        gtk_option_menu_set_history(optmenu, index);
2060

    
2061
        menu = gtk_option_menu_get_menu(optmenu);
2062
        menu_set_insensitive_all(GTK_MENU_SHELL(menu));
2063

    
2064
        menuitem = gtk_menu_get_active(GTK_MENU(menu));
2065
        gtk_widget_set_sensitive(menuitem, TRUE);
2066
        gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
2067
}
2068

    
2069
static void prefs_account_imap_auth_type_set_data_from_optmenu(PrefParam *pparam)
2070
{
2071
        GtkWidget *menu;
2072
        GtkWidget *menuitem;
2073

    
2074
        menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
2075
        menuitem = gtk_menu_get_active(GTK_MENU(menu));
2076
        *((RecvProtocol *)pparam->data) = GPOINTER_TO_INT
2077
                (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
2078
}
2079

    
2080
static void prefs_account_imap_auth_type_set_optmenu(PrefParam *pparam)
2081
{
2082
        IMAPAuthType type = *((IMAPAuthType *)pparam->data);
2083
        GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
2084
        GtkWidget *menu;
2085
        GtkWidget *menuitem;
2086

    
2087
        switch (type) {
2088
        case IMAP_AUTH_LOGIN:
2089
                gtk_option_menu_set_history(optmenu, 1);
2090
                break;
2091
        case IMAP_AUTH_CRAM_MD5:
2092
                gtk_option_menu_set_history(optmenu, 2);
2093
                break;
2094
        case 0:
2095
        default:
2096
                gtk_option_menu_set_history(optmenu, 0);
2097
        }
2098

    
2099
        menu = gtk_option_menu_get_menu(optmenu);
2100
        menuitem = gtk_menu_get_active(GTK_MENU(menu));
2101
        gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
2102
}
2103

    
2104
static void prefs_account_smtp_auth_type_set_data_from_optmenu(PrefParam *pparam)
2105
{
2106
        GtkWidget *menu;
2107
        GtkWidget *menuitem;
2108

    
2109
        menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(*pparam->widget));
2110
        menuitem = gtk_menu_get_active(GTK_MENU(menu));
2111
        *((RecvProtocol *)pparam->data) = GPOINTER_TO_INT
2112
                (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
2113
}
2114

    
2115
static void prefs_account_smtp_auth_type_set_optmenu(PrefParam *pparam)
2116
{
2117
        SMTPAuthType type = *((SMTPAuthType *)pparam->data);
2118
        GtkOptionMenu *optmenu = GTK_OPTION_MENU(*pparam->widget);
2119
        GtkWidget *menu;
2120
        GtkWidget *menuitem;
2121

    
2122
        switch (type) {
2123
        case SMTPAUTH_LOGIN:
2124
                gtk_option_menu_set_history(optmenu, 1);
2125
                break;
2126
        case SMTPAUTH_CRAM_MD5:
2127
                gtk_option_menu_set_history(optmenu, 2);
2128
                break;
2129
        case SMTPAUTH_DIGEST_MD5:
2130
                gtk_option_menu_set_history(optmenu, 3);
2131
                break;
2132
        case 0:
2133
        default:
2134
                gtk_option_menu_set_history(optmenu, 0);
2135
        }
2136

    
2137
        menu = gtk_option_menu_get_menu(optmenu);
2138
        menuitem = gtk_menu_get_active(GTK_MENU(menu));
2139
        gtk_menu_item_activate(GTK_MENU_ITEM(menuitem));
2140
}
2141

    
2142
static void prefs_account_protocol_activated(GtkMenuItem *menuitem)
2143
{
2144
        RecvProtocol protocol;
2145
        gboolean active;
2146

    
2147
        protocol = GPOINTER_TO_INT
2148
                (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
2149

    
2150
        switch(protocol) {
2151
        case A_NNTP:
2152
                gtk_widget_show(basic.nntpserv_label);
2153
                gtk_widget_show(basic.nntpserv_entry);
2154
                gtk_widget_show(basic.nntpauth_chkbtn);
2155
                gtk_widget_hide(basic.recvserv_label);
2156
                gtk_widget_hide(basic.recvserv_entry);
2157
                gtk_widget_hide(basic.smtpserv_label);
2158
                gtk_widget_hide(basic.smtpserv_entry);
2159
                active = gtk_toggle_button_get_active
2160
                        (GTK_TOGGLE_BUTTON(basic.nntpauth_chkbtn));
2161
                gtk_widget_set_sensitive(basic.uid_label,  active);
2162
                gtk_widget_set_sensitive(basic.pass_label, active);
2163
                gtk_widget_set_sensitive(basic.uid_entry,  active);
2164
                gtk_widget_set_sensitive(basic.pass_entry, active);
2165
                gtk_widget_hide(receive.pop3_frame);
2166
                gtk_widget_hide(receive.imap_frame);
2167
                gtk_widget_set_sensitive(receive.recvatgetall_chkbtn, TRUE);
2168

    
2169
                if (!tmp_ac_prefs.account_name) {
2170
                        gtk_toggle_button_set_active
2171
                                (GTK_TOGGLE_BUTTON(receive.recvatgetall_chkbtn),
2172
                                 FALSE);
2173
                }
2174

    
2175
#if USE_SSL
2176
                gtk_widget_hide(ssl.pop_frame);
2177
                gtk_widget_hide(ssl.imap_frame);
2178
                gtk_widget_show(ssl.nntp_frame);
2179
                gtk_widget_hide(ssl.send_frame);
2180
#endif
2181
                gtk_widget_hide(advanced.popport_hbox);
2182
                gtk_widget_hide(advanced.imapport_hbox);
2183
                gtk_widget_show(advanced.nntpport_hbox);
2184
                gtk_widget_hide(advanced.imap_frame);
2185
                break;
2186
        case A_LOCAL:
2187
                gtk_widget_hide(basic.nntpserv_label);
2188
                gtk_widget_hide(basic.nntpserv_entry);
2189
                gtk_widget_hide(basic.nntpauth_chkbtn);
2190
                gtk_widget_set_sensitive(basic.recvserv_label, FALSE);
2191
                gtk_widget_set_sensitive(basic.recvserv_entry, FALSE);
2192
                gtk_widget_show(basic.recvserv_label);
2193
                gtk_widget_show(basic.recvserv_entry);
2194
                gtk_widget_show(basic.smtpserv_label);
2195
                gtk_widget_show(basic.smtpserv_entry);
2196
                gtk_widget_set_sensitive(basic.uid_label,  FALSE);
2197
                gtk_widget_set_sensitive(basic.pass_label, FALSE);
2198
                gtk_widget_set_sensitive(basic.uid_entry,  FALSE);
2199
                gtk_widget_set_sensitive(basic.pass_entry, FALSE);
2200
                gtk_widget_hide(receive.pop3_frame);
2201
                gtk_widget_hide(receive.imap_frame);
2202
                gtk_widget_set_sensitive(receive.recvatgetall_chkbtn, FALSE);
2203

    
2204
                if (!tmp_ac_prefs.account_name) {
2205
                        gtk_toggle_button_set_active
2206
                                (GTK_TOGGLE_BUTTON(receive.recvatgetall_chkbtn),
2207
                                 TRUE);
2208
                }
2209

    
2210
#if USE_SSL
2211
                gtk_widget_hide(ssl.pop_frame);
2212
                gtk_widget_hide(ssl.imap_frame);
2213
                gtk_widget_hide(ssl.nntp_frame);
2214
                gtk_widget_show(ssl.send_frame);
2215
#endif
2216
                gtk_widget_hide(advanced.popport_hbox);
2217
                gtk_widget_hide(advanced.imapport_hbox);
2218
                gtk_widget_hide(advanced.nntpport_hbox);
2219
                gtk_widget_hide(advanced.imap_frame);
2220
                break;
2221
        case A_IMAP4:
2222
                gtk_widget_hide(basic.nntpserv_label);
2223
                gtk_widget_hide(basic.nntpserv_entry);
2224
                gtk_widget_hide(basic.nntpauth_chkbtn);
2225
                gtk_widget_set_sensitive(basic.recvserv_label, TRUE);
2226
                gtk_widget_set_sensitive(basic.recvserv_entry, TRUE);
2227
                gtk_widget_show(basic.recvserv_label);
2228
                gtk_widget_show(basic.recvserv_entry);
2229
                gtk_widget_show(basic.smtpserv_label);
2230
                gtk_widget_show(basic.smtpserv_entry);
2231
                gtk_widget_set_sensitive(basic.uid_label,  TRUE);
2232
                gtk_widget_set_sensitive(basic.pass_label, TRUE);
2233
                gtk_widget_set_sensitive(basic.uid_entry,  TRUE);
2234
                gtk_widget_set_sensitive(basic.pass_entry, TRUE);
2235
                gtk_widget_hide(receive.pop3_frame);
2236
                gtk_widget_show(receive.imap_frame);
2237
                gtk_widget_set_sensitive(receive.recvatgetall_chkbtn, TRUE);
2238

    
2239
                if (!tmp_ac_prefs.account_name) {
2240
                        gtk_toggle_button_set_active
2241
                                (GTK_TOGGLE_BUTTON(receive.recvatgetall_chkbtn),
2242
                                 FALSE);
2243
                }
2244

    
2245
#if USE_SSL
2246
                gtk_widget_hide(ssl.pop_frame);
2247
                gtk_widget_show(ssl.imap_frame);
2248
                gtk_widget_hide(ssl.nntp_frame);
2249
                gtk_widget_show(ssl.send_frame);
2250
#endif
2251
                gtk_widget_hide(advanced.popport_hbox);
2252
                gtk_widget_show(advanced.imapport_hbox);
2253
                gtk_widget_hide(advanced.nntpport_hbox);
2254
                gtk_widget_show(advanced.imap_frame);
2255
                break;
2256
        case A_POP3:
2257
        default:
2258
                gtk_widget_hide(basic.nntpserv_label);
2259
                gtk_widget_hide(basic.nntpserv_entry);
2260
                gtk_widget_hide(basic.nntpauth_chkbtn);
2261
                gtk_widget_set_sensitive(basic.recvserv_label, TRUE);
2262
                gtk_widget_set_sensitive(basic.recvserv_entry, TRUE);
2263
                gtk_widget_show(basic.recvserv_label);
2264
                gtk_widget_show(basic.recvserv_entry);
2265
                gtk_widget_show(basic.smtpserv_label);
2266
                gtk_widget_show(basic.smtpserv_entry);
2267
                gtk_widget_set_sensitive(basic.uid_label,  TRUE);
2268
                gtk_widget_set_sensitive(basic.pass_label, TRUE);
2269
                gtk_widget_set_sensitive(basic.uid_entry,  TRUE);
2270
                gtk_widget_set_sensitive(basic.pass_entry, TRUE);
2271
                gtk_widget_show(receive.pop3_frame);
2272
                gtk_widget_hide(receive.imap_frame);
2273
                gtk_widget_set_sensitive(receive.recvatgetall_chkbtn, TRUE);
2274

    
2275
                if (!tmp_ac_prefs.account_name) {
2276
                        gtk_toggle_button_set_active
2277
                                (GTK_TOGGLE_BUTTON(receive.recvatgetall_chkbtn),
2278
                                 TRUE);
2279
                }
2280

    
2281
#if USE_SSL
2282
                gtk_widget_show(ssl.pop_frame);
2283
                gtk_widget_hide(ssl.imap_frame);
2284
                gtk_widget_hide(ssl.nntp_frame);
2285
                gtk_widget_show(ssl.send_frame);
2286
#endif
2287
                gtk_widget_show(advanced.popport_hbox);
2288
                gtk_widget_hide(advanced.imapport_hbox);
2289
                gtk_widget_hide(advanced.nntpport_hbox);
2290
                gtk_widget_hide(advanced.imap_frame);
2291
                break;
2292
        }
2293

    
2294
        gtk_widget_queue_resize(basic.serv_frame);
2295
}