2 * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2016 Colin Leroy <colin@colino.net>
4 * and the Claws Mail team
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "claws-features.h"
28 #include <glib/gi18n.h>
29 #include <gdk/gdkkeysyms.h>
37 #include "file-utils.h"
42 #include "prefs_account.h"
43 #include "mainwindow.h"
44 #include "stock_pixmap.h"
47 #include "alertpanel.h"
52 #include "prefs_common.h"
54 #include "passwordstore.h"
64 int WELCOME_PAGE = -1;
68 int MAILBOX_PAGE = -1;
81 GtkWidget *organization;
83 GtkWidget *mailbox_name;
84 GtkWidget *mailbox_label;
86 GtkWidget *smtp_server;
88 GtkWidget *smtp_username;
89 GtkWidget *smtp_password;
90 GtkWidget *smtp_username_label;
91 GtkWidget *smtp_password_label;
94 GtkWidget *recv_label;
95 GtkWidget *recv_server;
96 GtkWidget *recv_username;
97 GtkWidget *recv_password;
98 GtkWidget *recv_username_label;
99 GtkWidget *recv_password_label;
100 GtkWidget *recv_imap_label;
101 GtkWidget *recv_imap_subdir;
102 GtkWidget *subsonly_checkbtn;
103 GtkWidget *no_imap_warning;
105 GtkWidget *smtp_use_ssl;
106 GtkWidget *recv_use_ssl;
107 GtkWidget *smtp_use_tls;
108 GtkWidget *recv_use_tls;
109 GtkWidget *smtp_ssl_cert_file;
110 GtkWidget *recv_ssl_cert_file;
111 GtkWidget *smtp_ssl_cert_pass;
112 GtkWidget *recv_ssl_cert_pass;
113 GtkWidget *smtp_cert_table;
114 GtkWidget *recv_cert_table;
116 #if defined USE_GNUTLS
117 GtkWidget *auto_configure_lbl;
118 GtkWidget *auto_configure_btn;
119 GtkWidget *auto_configure_cancel_btn;
121 gboolean create_mailbox;
127 typedef struct _AccountTemplate {
136 RecvProtocol recvtype;
148 gchar *smtpssl_cert_pass;
149 gchar *recvssl_cert_pass;
152 static AccountTemplate tmpl;
154 static PrefParam template_params[] = {
155 {"name", "$USERNAME",
156 &tmpl.name, P_STRING, NULL, NULL, NULL},
157 {"domain", "$DEFAULTDOMAIN",
158 &tmpl.domain, P_STRING, NULL, NULL, NULL},
159 {"email", "$NAME_MAIL@$DOMAIN",
160 &tmpl.email, P_STRING, NULL, NULL, NULL},
162 &tmpl.organization, P_STRING, NULL, NULL, NULL},
163 {"smtpserver", "smtp.$DOMAIN",
164 &tmpl.smtpserver, P_STRING, NULL, NULL, NULL},
165 {"smtpauth", "FALSE",
166 &tmpl.smtpauth, P_BOOL, NULL, NULL, NULL},
168 &tmpl.smtpuser, P_STRING, NULL, NULL, NULL},
170 &tmpl.smtppass, P_STRING, NULL, NULL, NULL},
172 &tmpl.recvtype, P_INT, NULL, NULL, NULL},
173 {"recvserver", "pop.$DOMAIN",
174 &tmpl.recvserver, P_STRING, NULL, NULL, NULL},
175 {"recvuser", "$LOGIN",
176 &tmpl.recvuser, P_STRING, NULL, NULL, NULL},
178 &tmpl.recvpass, P_STRING, NULL, NULL, NULL},
180 &tmpl.imapdir, P_STRING, NULL, NULL, NULL},
182 &tmpl.subsonly, P_BOOL, NULL, NULL, NULL},
183 {"mboxfile", "/var/mail/$LOGIN",
184 &tmpl.mboxfile, P_STRING, NULL, NULL, NULL},
186 &tmpl.mailbox, P_STRING, NULL, NULL, NULL},
188 &tmpl.smtpssl, P_INT, NULL, NULL, NULL},
190 &tmpl.recvssl, P_INT, NULL, NULL, NULL},
192 &tmpl.smtpssl_cert, P_STRING, NULL, NULL, NULL},
194 &tmpl.recvssl_cert, P_STRING, NULL, NULL, NULL},
195 {"smtpssl_cert_pass", "",
196 &tmpl.smtpssl_cert, P_STRING, NULL, NULL, NULL},
197 {"recvssl_cert_pass", "",
198 &tmpl.recvssl_cert, P_STRING, NULL, NULL, NULL},
199 {NULL, NULL, NULL, P_INT, NULL, NULL, NULL}
203 static gchar *accountrc_tmpl =
204 "[AccountTemplate]\n"
205 "#you can use $DEFAULTDOMAIN here\n"
206 "#domain must be defined before the variables that use it\n"
207 "#by default, domain is extracted from the hostname\n"
210 "#you can use $USERNAME for name (this is the default)\n"
213 "#you can use $LOGIN, $NAME_MAIL and $DOMAIN here \n"
214 "#$NAME_MAIL is the name without uppercase and with dots instead\n"
216 "#the default is $NAME_MAIL@$DOMAIN\n"
219 "#you can use $DOMAIN here\n"
220 "#the default organization is empty\n"
223 "#you can use $DOMAIN here \n"
224 "#the default is smtp.$DOMAIN\n"
227 "#Whether to use smtp authentication\n"
228 "#the default is 0 (no)\n"
232 "#you can use $LOGIN, $NAME_MAIL, $DOMAIN or $EMAIL here\n"
233 "#the default is empty (same as reception username)\n"
237 "#the default is empty (same as reception password)\n"
240 "#recvtype can be:\n"
243 "#3 for a local mbox file\n"
246 "#you can use $DOMAIN here \n"
247 "#the default is {pop,imap}.$DOMAIN\n"
250 "#you can use $LOGIN, $NAME_MAIL, $DOMAIN or $EMAIL here\n"
251 "#default is $LOGIN\n"
254 "#default is empty\n"
257 "#imap dir if imap (relative to the home on the server)\n"
258 "#default is empty\n"
261 "#show subscribed folders only, if imap\n"
265 "#mbox file if local\n"
266 "#you can use $LOGIN here\n"
267 "#default is /var/mail/$LOGIN\n"
270 "#mailbox name if pop3 or local\n"
271 "#relative path from the user's home\n"
272 "#default is \"Mail\"\n"
275 "#whether to use encryption on SMTP connections\n"
276 "#default is 0, 1 is SSL/TLS, 2 is STARTTLS\n"
279 "#whether to use encryption on POP3 or IMAP connections\n"
280 "#default is 0, 1 is SSL/TLS, 2 is STARTTLS\n"
283 "#SSL/TLS client certificate path for SMTP\n"
284 "#default is empty (no certificate)\n"
287 "#SSL/TLS client certificate path for POP/IMAP\n"
288 "#default is empty (no certificate)\n"
291 "#SSL/TLS client certificate password for SMTP\n"
292 "#default is empty (no password)\n"
293 "#smtpssl_cert_pass=\n"
295 "#SSL/TLS client certificate password for POP/IMAP\n"
296 "#default is empty (no password)\n"
297 "#recvssl_cert_pass=\n"
300 static gchar *wizard_get_default_domain_name(void)
302 static gchar *domain_name = NULL;
304 if (domain_name == NULL) {
305 domain_name = g_strdup(get_domain_name());
306 if (strchr(domain_name, '.') != NULL
307 && strchr(domain_name, '.') != strrchr(domain_name, '.')
308 && strlen(strchr(domain_name, '.')) > 6) {
309 gchar *tmp = g_strdup(strchr(domain_name, '.')+1);
317 static gchar *get_name_for_mail(void)
320 if (tmpl.name == NULL)
322 name = g_utf8_strdown(tmpl.name, -1);
323 while(strstr(name, " "))
324 *strstr(name, " ")='.';
329 #define PARSE_DEFAULT(str) { \
330 gchar *tmp = NULL, *new = NULL; \
332 if (strstr(str, "$USERNAME")) { \
333 tmp = g_strdup(str); \
334 *strstr(tmp, "$USERNAME") = '\0'; \
335 new = g_strconcat(tmp, g_get_real_name(), \
336 strstr(str, "$USERNAME")+strlen("$USERNAME"), \
343 if (strstr(str, "$LOGIN")) { \
344 tmp = g_strdup(str); \
345 *strstr(tmp, "$LOGIN") = '\0'; \
346 new = g_strconcat(tmp, g_get_user_name(), \
347 strstr(str, "$LOGIN")+strlen("$LOGIN"), \
354 if (strstr(str, "$EMAIL")) { \
355 tmp = g_strdup(str); \
356 *strstr(tmp, "$EMAIL") = '\0'; \
357 new = g_strconcat(tmp, tmpl.email, \
358 strstr(str, "$EMAIL")+strlen("$EMAIL"), \
365 if (strstr(str, "$NAME_MAIL")) { \
366 tmp = g_strdup(str); \
367 *strstr(tmp, "$NAME_MAIL") = '\0'; \
368 new = g_strconcat(tmp, get_name_for_mail(), \
369 strstr(str, "$NAME_MAIL")+strlen("$NAME_MAIL"), \
376 if (strstr(str, "$DEFAULTDOMAIN")) { \
377 tmp = g_strdup(str); \
378 *strstr(tmp, "$DEFAULTDOMAIN") = '\0'; \
379 new = g_strconcat(tmp, wizard_get_default_domain_name(), \
380 strstr(str, "$DEFAULTDOMAIN")+strlen("$DEFAULTDOMAIN"), \
387 if (strstr(str, "$DOMAIN")) { \
388 tmp = g_strdup(str); \
389 *strstr(tmp, "$DOMAIN") = '\0'; \
390 new = g_strconcat(tmp, tmpl.domain, \
391 strstr(str, "$DOMAIN")+strlen("$DOMAIN"), \
400 static void wizard_read_defaults(void)
404 rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, "accountrc.tmpl", NULL);
405 if (!is_file_exist(rcpath)) {
406 str_write_to_file(accountrc_tmpl, rcpath, TRUE);
409 prefs_read_config(template_params, "AccountTemplate", rcpath, NULL);
411 PARSE_DEFAULT(tmpl.domain);
412 PARSE_DEFAULT(tmpl.name);
413 PARSE_DEFAULT(tmpl.email);
414 PARSE_DEFAULT(tmpl.organization);
415 PARSE_DEFAULT(tmpl.smtpserver);
416 PARSE_DEFAULT(tmpl.smtpuser);
417 PARSE_DEFAULT(tmpl.smtppass);
418 PARSE_DEFAULT(tmpl.recvserver);
419 PARSE_DEFAULT(tmpl.recvuser);
420 PARSE_DEFAULT(tmpl.recvpass);
421 PARSE_DEFAULT(tmpl.imapdir);
422 PARSE_DEFAULT(tmpl.mboxfile);
423 PARSE_DEFAULT(tmpl.mailbox);
426 "%s, %s, %s, %s, %s, %d, %s, %s, %s, %s, %s, %s, %d, %d\n",
427 tmpl.name,tmpl.domain,tmpl.email,tmpl.organization,tmpl.smtpserver,
428 tmpl.recvtype,tmpl.recvserver,tmpl.recvuser,tmpl.recvpass,
429 tmpl.imapdir,tmpl.mboxfile,tmpl.mailbox,tmpl.smtpssl,tmpl.recvssl);
434 static void initialize_fonts(WizardWindow *wizard)
436 GtkWidget *widget = wizard->email;
437 gint size = pango_font_description_get_size(
438 gtk_widget_get_style(widget)->font_desc)
442 PangoFontDescription *bold_desc;
443 gchar *curfont = pango_font_description_to_string(
444 gtk_widget_get_style(widget)->font_desc);
445 g_free(prefs_common.smallfont);
446 g_free(prefs_common.normalfont);
447 g_free(prefs_common.boldfont);
448 prefs_common.smallfont = g_strdup(curfont);
449 prefs_common.normalfont = g_strdup(curfont);
450 bold_desc = pango_font_description_from_string(curfont);
451 pango_font_description_set_weight(bold_desc, PANGO_WEIGHT_BOLD);
452 prefs_common.boldfont = pango_font_description_to_string(bold_desc);
453 pango_font_description_free(bold_desc);
456 tmp = g_strdup(prefs_common.textfont);
457 if (strrchr(tmp, ' ')) {
458 *(strrchr(tmp, ' ')) = '\0';
459 new = g_strdup_printf("%s %d", tmp, size);
460 g_free(prefs_common.textfont);
461 prefs_common.textfont = new;
465 tmp = g_strdup(prefs_common.smallfont);
466 if (strrchr(tmp, ' ')) {
467 *(strrchr(tmp, ' ')) = '\0';
468 new = g_strdup_printf("%s %d", tmp, size);
469 g_free(prefs_common.smallfont);
470 prefs_common.smallfont = new;
474 tmp = g_strdup(prefs_common.normalfont);
475 if (strrchr(tmp, ' ')) {
476 *(strrchr(tmp, ' ')) = '\0';
477 new = g_strdup_printf("%s %d", tmp, size);
478 g_free(prefs_common.normalfont);
479 prefs_common.normalfont = new;
483 tmp = g_strdup(prefs_common.boldfont);
484 if (strrchr(tmp, ' ')) {
485 *(strrchr(tmp, ' ')) = '\0';
486 new = g_strdup_printf("%s %d", tmp, size);
487 g_free(prefs_common.boldfont);
488 prefs_common.boldfont = new;
493 #define XFACE "+}Axz@~a,-Yx?0Ysa|q}CLRH=89Y]\"')DSX^<6p\"d)'81yx5%G#u^o*7JG&[aPU0h1Ux.vb2yIjH83{5`/bVo|~nn/i83vE^E)qk-4W)_E.4Y=D*qvf/,Ci_=P<iY<M6"
494 #define FACE "iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAAM1BMVEUAAAAcJCI\n\
495 ONl1JUi0+Z4daY2NZciPabV9ykS5kj6Wsl2ybmZOBsMjZxK2wzN3Pzczs7OsCAGN0AAAAAXRSTlM\n\
496 AQObYZgAAAAFiS0dEAIgFHUgAAAIVSURBVEjH1ZbtlqMgDIaFECoGhPu/2s0b0Lais/NzN6d1OJ7\n\
497 3yReQzrL8B5Zy3rvl9At52Pf2tv1vSMjtYj8jaa8XUyI/yn3YD6sigj/2Tf5Bn069MIsTPHvx/t5\n\
498 /3rU/6JCIY3YwGe26r/cwUfE3cFe5T28L0K5rJAUHEeYAQxs8DHojjk3M9wECU4xxjXisI8RA0gy\n\
499 oczJZJOjxiTFZVTchAnIRJrgdmEGDyFfAI3UuG5FmYTkR9RDrIC4H0SqV4pzpEcUp0HNLjwBv+jA\n\
500 dikUE5g9iBvzmu3sH2oDk4lnHd829+2Q9gj6kDqDPg7hsGwBzH02fE3ZCt6ZHmlNKIMjMeRwra5I\n\
501 ecgNoBnLGPmzaHPJIwLY8Sq2M/tLUJfj0QcqmfVXAdLSStIYF8dzWjBBb2VgvDa4mO9oc651OiUo\n\
502 BEKbZokdPATF9E9oKAjQJcJOniaPXrVZRAnVWaqIyqRoNC8ZJvgCcW8XN39RqxVP1rS8Yd4WnCdN\n\
503 aRTo2jJRDbg3vtCpEUGffgDPhqKDaSuVqYtOplFIvIcx3HUI5/MuIWl6vKyBjNlqEru8hbFXqBPA\n\
504 5TpHGIUZOePeaIyzfQ/g9Xg0opU1AvdfXM9floYhv92pPAE96OZtkPV8eivgQi9RTfwPUU36I26n\n\
505 Hy+WuCJzAT7efMSeA1TNf2/VugDz+dN139xfA5ffxGZDD+MvcP/uvyB80wzZ76wbz8gAAAABJRU5\n\
508 static void write_welcome_email(WizardWindow *wizard)
510 gchar date[RFC822_DATE_BUFFSIZE];
514 const gchar *mailbox = gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name));
515 Folder *folder = folder_find_from_path(mailbox);
516 FolderItem *inbox = folder ? folder->inbox:NULL;
517 gchar *file = get_tmp_file();
518 gchar enc_from_name[BUFFSIZE], enc_to_name[BUFFSIZE], enc_subject[BUFFSIZE];
520 get_rfc822_date(date, sizeof(date));
522 conv_encode_header_full(enc_subject, sizeof(enc_subject),
523 C_("Welcome Mail Subject", "Welcome to Claws Mail"),
524 strlen("Subject: "), FALSE, CS_INTERNAL);
525 conv_encode_header_full(enc_to_name, sizeof(enc_to_name),
526 gtk_entry_get_text(GTK_ENTRY(wizard->full_name)),
527 strlen("To: "), TRUE, CS_INTERNAL);
528 conv_encode_header_full(enc_from_name, sizeof(enc_from_name),
529 _("The Claws Mail Team"),
530 strlen("From: "), TRUE, CS_INTERNAL);
532 head = g_strdup_printf(
539 "Content-Type: text/plain; charset=UTF-8\n",
543 gtk_entry_get_text(GTK_ENTRY(wizard->email)),
544 date, enc_subject, XFACE, FACE);
545 body = g_strdup_printf(
547 "Welcome to Claws Mail\n"
548 "---------------------\n"
550 "Now that you have set up your account you can fetch your\n"
551 "mail by clicking the 'Get Mail' button at the left of the\n"
554 "Claws Mail has lots of extra features accessible via plugins,\n"
555 "like anti-spam filtering and learning (via the Bogofilter or\n"
556 "SpamAssassin plugins), privacy protection (via PGP/Mime), an RSS\n"
557 "aggregator, a calendar, and much more. You can load them from\n"
558 "the menu entry '/Configuration/Plugins'.\n"
560 "You can change your Account Preferences by using the menu\n"
561 "entry '/Configuration/Preferences for current account'\n"
562 "and change the general Preferences by using\n"
563 "'/Configuration/Preferences'.\n"
565 "You can find further information in the Claws Mail manual,\n"
566 "which can be accessed by using the menu entry '/Help/Manual'\n"
567 "or online at the URL given below.\n"
575 "Mailing Lists: <%s>\n"
579 "Claws Mail is free software, released under the terms\n"
580 "of the GNU General Public License, version 3 or later, as\n"
581 "published by the Free Software Foundation. The license can\n"
582 "be found at <%s>.\n"
586 "If you wish to donate to the Claws Mail project you can do\n"
588 HOMEPAGE_URI, MANUAL_URI, FAQ_URI, THEMES_URI, MAILING_LIST_URI,
589 GPL_URI, DONATE_URI);
591 msg = g_strconcat(head, body, NULL);
593 if (inbox && inbox->total_msgs == 0
594 && str_write_to_file(msg, file, TRUE) >= 0) {
595 MsgFlags flags = { MSG_UNREAD|MSG_NEW, 0};
596 folder_item_add_msg(inbox, file, &flags, FALSE);
605 static gboolean wizard_write_config(WizardWindow *wizard)
607 static gboolean mailbox_ok = FALSE;
608 PrefsAccount *prefs_account = prefs_account_new();
609 GList *account_list = NULL;
610 gchar *smtp_server, *recv_server;
611 gint smtp_port, recv_port;
613 SSLType smtp_ssl_type, recv_ssl_type;
616 prefs_account->protocol = combobox_get_active_data(
617 GTK_COMBO_BOX(wizard->recv_type));
619 if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4 &&
620 !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name)))) {
621 alertpanel_error(_("Please enter the mailbox name."));
622 g_free(prefs_account);
623 gtk_notebook_set_current_page (
624 GTK_NOTEBOOK(wizard->notebook),
630 if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4) {
631 mailbox_ok = setup_write_mailbox_path(wizard->mainwin,
633 GTK_ENTRY(wizard->mailbox_name)));
639 /* alertpanel done by setup_write_mailbox_path */
640 g_free(prefs_account);
641 gtk_notebook_set_current_page (
642 GTK_NOTEBOOK(wizard->notebook),
647 if (!strlen(gtk_entry_get_text(GTK_ENTRY(wizard->full_name)))
648 || !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->email)))) {
649 alertpanel_error(_("Please enter your name and email address."));
650 g_free(prefs_account);
651 gtk_notebook_set_current_page (
652 GTK_NOTEBOOK(wizard->notebook),
657 if (prefs_account->protocol != A_LOCAL) {
658 if (!strlen(gtk_entry_get_text(GTK_ENTRY(wizard->recv_username)))
659 || !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)))) {
660 alertpanel_error(_("Please enter your receiving server "
662 g_free(prefs_account);
663 gtk_notebook_set_current_page (
664 GTK_NOTEBOOK(wizard->notebook),
669 if (!strlen(gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)))) {
670 alertpanel_error(_("Please enter your username."));
671 g_free(prefs_account);
672 gtk_notebook_set_current_page (
673 GTK_NOTEBOOK(wizard->notebook),
679 if (!strlen(gtk_entry_get_text(GTK_ENTRY(wizard->smtp_server)))) {
680 alertpanel_error(_("Please enter your SMTP server."));
681 g_free(prefs_account);
682 gtk_notebook_set_current_page (
683 GTK_NOTEBOOK(wizard->notebook),
688 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_auth))) {
689 if (prefs_account->protocol == A_LOCAL
690 && !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->smtp_username)))) {
691 alertpanel_error(_("Please enter your SMTP username."));
692 g_free(prefs_account);
693 gtk_notebook_set_current_page (
694 GTK_NOTEBOOK(wizard->notebook),
697 } /* if it's not local we'll use the reception server */
700 if (prefs_account->protocol != A_LOCAL)
701 prefs_account->account_name = g_strdup_printf("%s@%s",
702 gtk_entry_get_text(GTK_ENTRY(wizard->recv_username)),
703 gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
705 prefs_account->account_name = g_strdup_printf("%s",
706 gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
708 recv_server = g_strdup(gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
709 smtp_server = g_strdup(gtk_entry_get_text(GTK_ENTRY(wizard->smtp_server)));
711 if (prefs_account->protocol != A_LOCAL && strstr(recv_server, ":")) {
712 recv_port = atoi(strstr(recv_server, ":")+1);
713 *(strstr(recv_server, ":")) = '\0';
714 if (prefs_account->protocol == A_IMAP4) {
715 prefs_account->set_imapport = TRUE;
716 prefs_account->imapport = recv_port;
717 } else if (prefs_account->protocol == A_POP3) {
718 prefs_account->set_popport = TRUE;
719 prefs_account->popport = recv_port;
722 if (strstr(smtp_server, ":")) {
723 smtp_port = atoi(strstr(smtp_server, ":")+1);
724 *(strstr(smtp_server, ":")) = '\0';
725 prefs_account->set_smtpport = TRUE;
726 prefs_account->smtpport = smtp_port;
729 prefs_account->name = g_strdup(
730 gtk_entry_get_text(GTK_ENTRY(wizard->full_name)));
731 prefs_account->address = g_strdup(
732 gtk_entry_get_text(GTK_ENTRY(wizard->email)));
733 prefs_account->organization = g_strdup(
734 gtk_entry_get_text(GTK_ENTRY(wizard->organization)));
735 prefs_account->smtp_server = g_strdup(smtp_server);
737 if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4) {
739 tmp = g_path_get_basename(gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name)));
740 prefs_account->inbox = g_strdup_printf("#mh/%s/inbox",
741 (!strcmp("Mail", gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name))))
744 prefs_account->local_inbox = g_strdup(prefs_account->inbox);
745 } else if (prefs_account->protocol != A_IMAP4) {
746 if (folder_get_default_inbox())
747 prefs_account->local_inbox =
748 folder_item_get_identifier(folder_get_default_inbox());
751 if (prefs_account->protocol != A_LOCAL)
752 prefs_account->recv_server = g_strdup(recv_server);
754 prefs_account->local_mbox = g_strdup(recv_server);
759 prefs_account->userid = g_strdup(
760 gtk_entry_get_text(GTK_ENTRY(wizard->recv_username)));
761 prefs_account->smtp_userid = g_strdup(
762 gtk_entry_get_text(GTK_ENTRY(wizard->smtp_username)));
764 passwd_store_set_account(prefs_account->account_id, PWS_ACCOUNT_RECV,
765 gtk_entry_get_text(GTK_ENTRY(wizard->recv_password)),
767 passwd_store_set_account(prefs_account->account_id, PWS_ACCOUNT_SEND,
768 gtk_entry_get_text(GTK_ENTRY(wizard->smtp_password)),
771 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_auth))) {
772 prefs_account->use_smtp_auth = TRUE;
776 smtp_ssl_type = SSL_NONE;
777 recv_ssl_type = SSL_NONE;
779 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_ssl))) {
780 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_tls)))
781 smtp_ssl_type = SSL_STARTTLS;
783 smtp_ssl_type = SSL_TUNNEL;
785 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->recv_use_ssl))) {
786 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->recv_use_tls)))
787 recv_ssl_type = SSL_STARTTLS;
789 recv_ssl_type = SSL_TUNNEL;
792 prefs_account->ssl_smtp = smtp_ssl_type;
794 if (prefs_account->protocol == A_IMAP4)
795 prefs_account->ssl_imap = recv_ssl_type;
797 prefs_account->ssl_pop = recv_ssl_type;
799 prefs_account->out_ssl_client_cert_file = g_strdup(
800 gtk_entry_get_text(GTK_ENTRY(wizard->smtp_ssl_cert_file)));
801 prefs_account->in_ssl_client_cert_file = g_strdup(
802 gtk_entry_get_text(GTK_ENTRY(wizard->recv_ssl_cert_file)));
804 passwd_store_set_account(prefs_account->account_id, PWS_ACCOUNT_SEND_CERT,
805 gtk_entry_get_text(GTK_ENTRY(wizard->smtp_ssl_cert_pass)),
807 passwd_store_set_account(prefs_account->account_id, PWS_ACCOUNT_RECV_CERT,
808 gtk_entry_get_text(GTK_ENTRY(wizard->recv_ssl_cert_pass)),
812 if (prefs_account->protocol == A_IMAP4) {
813 gchar *directory = gtk_editable_get_chars(
814 GTK_EDITABLE(wizard->recv_imap_subdir), 0, -1);
815 if (directory && strlen(directory)) {
816 prefs_account->imap_dir = g_strdup(directory);
818 prefs_account->imap_subsonly =
819 gtk_toggle_button_get_active(
820 GTK_TOGGLE_BUTTON(wizard->subsonly_checkbtn));
824 account_list = g_list_append(account_list, prefs_account);
825 prefs_account_write_config_all(account_list);
826 prefs_account_free(prefs_account);
827 account_read_config_all();
829 initialize_fonts(wizard);
830 if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4)
831 write_welcome_email(wizard);
834 plugin_load_standard_plugins();
839 static GtkWidget* create_page (WizardWindow *wizard, const char * title)
847 vbox = gtk_vbox_new (FALSE, 6);
848 gtk_container_set_border_width (GTK_CONTAINER(vbox), 10);
850 /* create the titlebar */
851 hbox = gtk_hbox_new (FALSE, 12);
852 image = stock_pixmap_widget(STOCK_PIXMAP_CLAWS_MAIL_ICON);
853 gtk_box_pack_start (GTK_BOX(hbox), image, FALSE, FALSE, 0);
854 title_string = g_strconcat ("<span size=\"xx-large\" weight=\"ultrabold\">", title ? title : "", "</span>", NULL);
855 w = gtk_label_new (title_string);
856 gtk_label_set_use_markup (GTK_LABEL(w), TRUE);
857 g_free (title_string);
858 gtk_box_pack_start (GTK_BOX(hbox), w, FALSE, FALSE, 0);
860 /* pack the titlebar */
861 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
863 /* pack the separator */
864 gtk_box_pack_start (GTK_BOX(vbox), gtk_hseparator_new(), FALSE, FALSE, 0);
867 w = gtk_alignment_new (0, 0, 0, 0);
868 gtk_widget_set_size_request (w, 0, 6);
869 gtk_box_pack_start (GTK_BOX(vbox), w, FALSE, FALSE, 0);
874 #define PACK_BOX(hbox,text,entry) { \
875 GtkWidget *label = gtk_label_new(text); \
876 gtk_label_set_use_markup(GTK_LABEL(label), TRUE); \
877 if (GTK_IS_MISC(label)) \
878 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); \
879 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); \
880 gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0); \
883 static gchar *get_default_server(WizardWindow * wizard, const gchar *type)
885 if (!strcmp(type, "smtp")) {
886 if (!tmpl.smtpserver || !strlen(tmpl.smtpserver))
887 return g_strconcat(type, ".", tmpl.domain, NULL);
889 return g_strdup(tmpl.smtpserver);
891 if (!tmpl.recvserver || !strlen(tmpl.recvserver))
892 return g_strconcat(type, ".", tmpl.domain, NULL);
894 return g_strdup(tmpl.recvserver);
898 static gchar *get_default_account(WizardWindow * wizard)
900 gchar *result = NULL;
902 if (!tmpl.recvuser || !strlen(tmpl.recvuser)) {
903 result = gtk_editable_get_chars(
904 GTK_EDITABLE(wizard->email), 0, -1);
906 if (strstr(result, "@")) {
907 *(strstr(result,"@")) = '\0';
910 result = g_strdup(tmpl.recvuser);
915 static gchar *get_default_smtp_account(WizardWindow * wizard)
917 gchar *result = NULL;
919 if (!tmpl.smtpuser || !strlen(tmpl.smtpuser)) {
922 result = g_strdup(tmpl.smtpuser);
927 static void wizard_email_changed(GtkWidget *widget, gpointer data)
929 WizardWindow *wizard = (WizardWindow *)data;
930 RecvProtocol protocol;
932 protocol = combobox_get_active_data(GTK_COMBO_BOX(wizard->recv_type));
934 text = get_default_server(wizard, "smtp");
935 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_server), text);
938 text = get_default_account(wizard);
939 gtk_entry_set_text(GTK_ENTRY(wizard->recv_username), text);
942 if (protocol == A_POP3) {
943 text = get_default_server(wizard, "pop");
944 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
946 } else if (protocol == A_IMAP4) {
947 text = get_default_server(wizard, "imap");
948 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
950 } else if (protocol == A_LOCAL) {
951 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), tmpl.mboxfile?tmpl.mboxfile:"");
956 static GtkWidget* user_page (WizardWindow * wizard)
958 GtkWidget *table = gtk_table_new(1,1, FALSE);
961 GtkWidget *user_table;
963 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
964 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
966 vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
967 gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
969 gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2,
970 GTK_EXPAND|GTK_FILL, 0, 0, 0);
972 user_table = gtk_table_new(3, 2, FALSE);
973 gtk_table_set_row_spacings(GTK_TABLE(user_table), VSPACING_NARROW);
974 gtk_box_pack_start(GTK_BOX(vbox), user_table, FALSE, FALSE, 0);
976 label = gtk_label_new(g_strconcat("<span weight=\"bold\">", _("Your name:"),
978 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
979 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
980 gtk_table_attach(GTK_TABLE(user_table), label, 0,1,0,1,
981 GTK_FILL, 0, VSPACING_NARROW, 0);
982 wizard->full_name = gtk_entry_new();
983 gtk_entry_set_text(GTK_ENTRY(wizard->full_name), tmpl.name?tmpl.name:"");
984 gtk_table_attach(GTK_TABLE(user_table), wizard->full_name, 1,2,0,1,
985 GTK_EXPAND|GTK_FILL, 0, 0, 0);
987 label = gtk_label_new(g_strconcat("<span weight=\"bold\">", _("Your email address:"),
989 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
990 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
991 gtk_table_attach(GTK_TABLE(user_table), label, 0,1,1,2,
992 GTK_FILL, 0, VSPACING_NARROW, 0);
993 wizard->email = gtk_entry_new();
994 gtk_entry_set_text(GTK_ENTRY(wizard->email), tmpl.email?tmpl.email:"");
995 gtk_table_attach(GTK_TABLE(user_table), wizard->email, 1,2,1,2,
996 GTK_EXPAND|GTK_FILL, 0, 0, 0);
998 label = gtk_label_new(_("Your organization:"));
999 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
1000 gtk_table_attach(GTK_TABLE(user_table), label, 0,1,2,3,
1001 GTK_FILL, 0, VSPACING_NARROW, 0);
1002 wizard->organization = gtk_entry_new();
1003 gtk_entry_set_text(GTK_ENTRY(wizard->organization), tmpl.organization?tmpl.organization:"");
1004 gtk_table_attach(GTK_TABLE(user_table), wizard->organization, 1,2,2,3,
1005 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1007 g_signal_connect(G_OBJECT(wizard->email), "changed",
1008 G_CALLBACK(wizard_email_changed),
1013 static GtkWidget* mailbox_page (WizardWindow * wizard)
1015 GtkWidget *table = gtk_table_new(1,1, FALSE);
1019 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
1020 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
1022 vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
1023 gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
1025 gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2,
1026 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1028 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1029 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1031 wizard->mailbox_label = gtk_label_new(g_strconcat("<span weight=\"bold\">",
1032 _("Mailbox name:"), "</span>", NULL));
1033 gtk_label_set_use_markup(GTK_LABEL(wizard->mailbox_label), TRUE);
1034 if (GTK_IS_MISC(wizard->mailbox_label))
1035 gtk_misc_set_alignment(GTK_MISC(wizard->mailbox_label), 1, 0.5);
1036 wizard->mailbox_name = gtk_entry_new();
1038 gtk_entry_set_text(GTK_ENTRY(wizard->mailbox_name), tmpl.mailbox?tmpl.mailbox:"");
1040 CLAWS_SET_TIP(wizard->mailbox_name, _("You can also specify an absolute path, for example: "
1041 "\"/home/john/Documents/Mail\""));
1043 gtk_box_pack_start(GTK_BOX(hbox), wizard->mailbox_label, FALSE, FALSE, 0);
1044 gtk_box_pack_start(GTK_BOX(hbox), wizard->mailbox_name, TRUE, TRUE, 0);
1049 static void smtp_auth_changed (GtkWidget *btn, gpointer data)
1051 WizardWindow *wizard = (WizardWindow *)data;
1052 gboolean do_auth = gtk_toggle_button_get_active(
1053 GTK_TOGGLE_BUTTON(wizard->smtp_auth));
1054 gtk_widget_set_sensitive(wizard->smtp_username, do_auth);
1055 gtk_widget_set_sensitive(wizard->smtp_username_label, do_auth);
1056 gtk_widget_set_sensitive(wizard->smtp_password, do_auth);
1057 gtk_widget_set_sensitive(wizard->smtp_password_label, do_auth);
1061 static void cert_browse_cb(GtkWidget *widget, gpointer data)
1063 GtkEntry *dest = GTK_ENTRY(data);
1065 gchar *utf8_filename;
1067 filename = filesel_select_file_open(_("Select certificate file"), NULL);
1068 if (!filename) return;
1070 utf8_filename = g_filename_to_utf8(filename, -1, NULL, NULL, NULL);
1071 if (!utf8_filename) {
1072 g_warning("cert_browse_cb(): failed to convert character set.");
1073 utf8_filename = g_strdup(filename);
1075 gtk_entry_set_text(dest, utf8_filename);
1076 g_free(utf8_filename);
1080 static GtkWidget* smtp_page (WizardWindow * wizard)
1082 GtkWidget *table = gtk_table_new(1, 1, FALSE);
1085 GtkWidget *hbox_spc;
1086 GtkWidget *smtp_auth_table;
1090 GtkWidget *smtp_cert_table;
1094 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
1095 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
1097 vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
1098 gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
1100 gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2,
1101 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1103 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1104 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1105 wizard->smtp_server = gtk_entry_new();
1106 text = get_default_server(wizard, "smtp");
1107 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_server), text);
1110 CLAWS_SET_TIP(wizard->smtp_server,
1111 _("You can specify the port number by appending it at the end: "
1112 "\"mail.example.com:25\""));
1114 PACK_BOX(hbox, g_strconcat("<span weight=\"bold\">", _("SMTP server address:"),
1115 "</span>", NULL), wizard->smtp_server);
1117 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1118 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1119 wizard->smtp_auth = gtk_check_button_new_with_label(
1120 _("Use authentication"));
1121 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->smtp_auth),
1123 g_signal_connect(G_OBJECT(wizard->smtp_auth), "toggled",
1124 G_CALLBACK(smtp_auth_changed),
1126 gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_auth, FALSE, FALSE, 0);
1128 label = gtk_label_new(g_strconcat("<span size=\"small\">",
1129 _("(empty to use the same as receive)"), "</span>", NULL));
1130 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
1131 SET_TOGGLE_SENSITIVITY (wizard->smtp_auth, label);
1132 gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1134 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1135 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1136 hbox_spc = gtk_hbox_new (FALSE, 0);
1137 gtk_widget_set_size_request (hbox_spc, 12, -1);
1138 gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1139 smtp_auth_table = gtk_table_new(2, 2, FALSE);
1140 SET_TOGGLE_SENSITIVITY (wizard->smtp_auth, smtp_auth_table);
1141 gtk_box_pack_start(GTK_BOX(hbox), smtp_auth_table, TRUE, TRUE, 0);
1143 wizard->smtp_username_label = gtk_label_new(_("SMTP username:"));
1144 gtk_misc_set_alignment(GTK_MISC(wizard->smtp_username_label), 1, 0.5);
1145 gtk_table_attach(GTK_TABLE(smtp_auth_table), wizard->smtp_username_label, 0,1,0,1,
1146 GTK_FILL, 0, VSPACING_NARROW, 0);
1147 text = get_default_smtp_account(wizard);
1148 wizard->smtp_username = gtk_entry_new();
1149 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_username), text);
1151 gtk_table_attach(GTK_TABLE(smtp_auth_table), wizard->smtp_username, 1,2,0,1,
1152 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1154 wizard->smtp_password_label = gtk_label_new(_("SMTP password:"));
1155 gtk_misc_set_alignment(GTK_MISC(wizard->smtp_password_label), 1, 0.5);
1156 gtk_table_attach(GTK_TABLE(smtp_auth_table), wizard->smtp_password_label, 0,1,1,2,
1157 GTK_FILL, 0, VSPACING_NARROW, 0);
1158 wizard->smtp_password = gtk_entry_new();
1159 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_password), tmpl.smtppass?tmpl.smtppass:"");
1160 gtk_entry_set_visibility(GTK_ENTRY(wizard->smtp_password), FALSE);
1161 gtk_table_attach(GTK_TABLE(smtp_auth_table), wizard->smtp_password, 1,2,1,2,
1162 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1164 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1165 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1166 wizard->smtp_use_ssl = gtk_check_button_new_with_label(
1167 _("Use SSL/TLS to connect to SMTP server"));
1168 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_ssl),
1170 gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_use_ssl, FALSE, FALSE, 0);
1172 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1173 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1174 hbox_spc = gtk_hbox_new (FALSE, 0);
1175 gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1176 gtk_widget_set_size_request (hbox_spc, 12, -1);
1177 wizard->smtp_use_tls = gtk_check_button_new_with_label(
1178 _("Use STARTTLS command to start encryption"));
1179 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_tls),
1181 gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_use_tls, FALSE, FALSE, 0);
1182 SET_TOGGLE_SENSITIVITY (wizard->smtp_use_ssl, wizard->smtp_use_tls);
1184 smtp_cert_table = gtk_table_new(3,3, FALSE);
1185 gtk_box_pack_start (GTK_BOX(vbox), smtp_cert_table, FALSE, FALSE, 4);
1186 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1187 hbox_spc = gtk_hbox_new (FALSE, 0);
1188 gtk_widget_set_size_request (hbox_spc, 12, -1);
1189 gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1190 label = gtk_label_new(_("Client SSL/TLS certificate (optional)"));
1191 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
1192 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1193 gtk_table_attach(GTK_TABLE(smtp_cert_table), hbox, 0, 3, 0, 1, GTK_FILL, 0, 0, 0);
1194 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1195 hbox_spc = gtk_hbox_new (FALSE, 0);
1196 gtk_widget_set_size_request (hbox_spc, 12, -1);
1197 gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1198 label = gtk_label_new(_("File"));
1199 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
1200 gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
1201 gtk_table_attach(GTK_TABLE(smtp_cert_table), hbox, 0, 1, 1, 2,
1202 GTK_FILL, 0, VSPACING_NARROW, 0);
1203 wizard->smtp_ssl_cert_file = gtk_entry_new();
1204 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_ssl_cert_file), tmpl.smtpssl_cert?tmpl.smtpssl_cert:"");
1205 gtk_table_attach(GTK_TABLE(smtp_cert_table), wizard->smtp_ssl_cert_file, 1, 2, 1, 2, GTK_FILL, 0, 0, 0);
1206 button = gtkut_get_browse_file_btn(_("Browse"));
1207 gtk_table_attach(GTK_TABLE(smtp_cert_table), button, 2, 3, 1, 2,
1208 GTK_FILL, 0, VSPACING_NARROW, 0);
1209 g_signal_connect(G_OBJECT(button), "clicked",
1210 G_CALLBACK(cert_browse_cb), wizard->smtp_ssl_cert_file);
1212 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1213 hbox_spc = gtk_hbox_new (FALSE, 0);
1214 gtk_widget_set_size_request (hbox_spc, 12, -1);
1215 gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1216 label = gtk_label_new(_("Password"));
1217 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
1218 gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
1219 gtk_table_attach(GTK_TABLE(smtp_cert_table), hbox, 0, 1, 2, 3,
1220 GTK_FILL, 0, VSPACING_NARROW, 0);
1221 wizard->smtp_ssl_cert_pass = gtk_entry_new();
1222 gtk_entry_set_visibility(GTK_ENTRY(wizard->smtp_ssl_cert_pass), FALSE);
1223 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_ssl_cert_pass), tmpl.smtpssl_cert_pass?tmpl.smtpssl_cert_pass:"");
1224 gtk_table_attach(GTK_TABLE(smtp_cert_table), wizard->smtp_ssl_cert_pass, 1, 2, 2, 3, GTK_FILL, 0, 0, 0);
1225 SET_TOGGLE_SENSITIVITY (wizard->smtp_use_ssl, smtp_cert_table);
1226 wizard->smtp_cert_table = smtp_cert_table;
1228 smtp_auth_changed(NULL, wizard);
1232 static void wizard_protocol_change(WizardWindow *wizard, RecvProtocol protocol)
1236 if (protocol == A_POP3) {
1237 text = get_default_server(wizard, "pop");
1238 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
1239 gtk_widget_hide(wizard->recv_imap_label);
1240 gtk_widget_hide(wizard->recv_imap_subdir);
1241 gtk_widget_hide(wizard->subsonly_checkbtn);
1242 gtk_widget_show(wizard->recv_username);
1243 gtk_widget_show(wizard->recv_password);
1244 gtk_widget_show(wizard->recv_username_label);
1245 gtk_widget_show(wizard->recv_password_label);
1246 gtk_widget_hide(wizard->no_imap_warning);
1248 gtk_widget_show(wizard->recv_use_ssl);
1249 gtk_widget_show(wizard->recv_use_tls);
1250 gtk_widget_show(wizard->recv_cert_table);
1252 #if defined USE_GNUTLS
1253 gtk_widget_show(wizard->auto_configure_btn);
1254 gtk_widget_hide(wizard->auto_configure_cancel_btn);
1255 gtk_widget_show(wizard->auto_configure_lbl);
1257 gtk_label_set_text(GTK_LABEL(wizard->recv_label),
1258 g_strconcat("<span weight=\"bold\">", _("Server address:"),
1260 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
1261 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, TRUE);
1263 if (wizard->create_mailbox) {
1264 gtk_widget_show(wizard->mailbox_label);
1265 gtk_widget_show(wizard->mailbox_name);
1267 } else if (protocol == A_IMAP4) {
1268 #ifdef HAVE_LIBETPAN
1269 text = get_default_server(wizard, "imap");
1270 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
1271 gtk_widget_show(wizard->recv_imap_label);
1272 gtk_widget_show(wizard->recv_imap_subdir);
1273 gtk_widget_show(wizard->subsonly_checkbtn);
1274 gtk_widget_show(wizard->recv_username);
1275 gtk_widget_show(wizard->recv_password);
1276 gtk_widget_show(wizard->recv_username_label);
1277 gtk_widget_show(wizard->recv_password_label);
1278 gtk_widget_hide(wizard->no_imap_warning);
1280 gtk_widget_show(wizard->recv_use_ssl);
1281 gtk_widget_show(wizard->recv_use_tls);
1282 gtk_widget_show(wizard->recv_cert_table);
1284 #if defined USE_GNUTLS
1285 gtk_widget_show(wizard->auto_configure_btn);
1286 gtk_widget_hide(wizard->auto_configure_cancel_btn);
1287 gtk_widget_show(wizard->auto_configure_lbl);
1289 gtk_label_set_text(GTK_LABEL(wizard->recv_label),
1290 g_strconcat("<span weight=\"bold\">", _("Server address:"),
1292 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
1293 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, TRUE);
1295 if (wizard->create_mailbox) {
1296 gtk_widget_hide(wizard->mailbox_label);
1297 gtk_widget_hide(wizard->mailbox_name);
1300 gtk_widget_hide(wizard->recv_imap_label);
1301 gtk_widget_hide(wizard->recv_imap_subdir);
1302 gtk_widget_hide(wizard->subsonly_checkbtn);
1303 gtk_widget_hide(wizard->recv_username);
1304 gtk_widget_hide(wizard->recv_password);
1305 gtk_widget_hide(wizard->recv_username_label);
1306 gtk_widget_hide(wizard->recv_password_label);
1307 gtk_widget_show(wizard->no_imap_warning);
1308 if (wizard->create_mailbox) {
1309 gtk_widget_hide(wizard->mailbox_label);
1310 gtk_widget_hide(wizard->mailbox_name);
1313 gtk_widget_hide(wizard->recv_use_ssl);
1314 gtk_widget_hide(wizard->recv_use_tls);
1315 gtk_widget_hide(wizard->recv_cert_table);
1317 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, FALSE);
1319 } else if (protocol == A_LOCAL) {
1320 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), tmpl.mboxfile?tmpl.mboxfile:"");
1321 gtk_label_set_text(GTK_LABEL(wizard->recv_label),
1322 g_strconcat("<span weight=\"bold\">", _("Local mailbox:"),
1324 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
1325 gtk_widget_hide(wizard->no_imap_warning);
1326 gtk_widget_hide(wizard->recv_imap_label);
1327 gtk_widget_hide(wizard->recv_imap_subdir);
1328 gtk_widget_hide(wizard->subsonly_checkbtn);
1329 gtk_widget_hide(wizard->recv_username);
1330 gtk_widget_hide(wizard->recv_password);
1331 gtk_widget_hide(wizard->recv_username_label);
1332 gtk_widget_hide(wizard->recv_password_label);
1333 #if defined USE_GNUTLS
1334 gtk_widget_hide(wizard->auto_configure_btn);
1335 gtk_widget_hide(wizard->auto_configure_cancel_btn);
1336 gtk_widget_hide(wizard->auto_configure_lbl);
1339 gtk_widget_hide(wizard->recv_use_ssl);
1340 gtk_widget_hide(wizard->recv_use_tls);
1341 gtk_widget_hide(wizard->recv_cert_table);
1343 if (wizard->create_mailbox) {
1344 gtk_widget_show(wizard->mailbox_label);
1345 gtk_widget_show(wizard->mailbox_name);
1347 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, TRUE);
1351 static void wizard_protocol_changed(GtkComboBox *combo, gpointer data)
1353 WizardWindow *wizard = (WizardWindow *)data;
1354 RecvProtocol protocol = combobox_get_active_data(combo);
1356 wizard_protocol_change(wizard, protocol);
1359 #if defined USE_GNUTLS
1360 static void auto_configure_cb (GtkWidget *widget, gpointer data)
1362 gchar *address = NULL;
1363 AutoConfigureData *recv_data;
1364 AutoConfigureData *send_data;
1365 static GCancellable *recv_cancel = NULL;
1366 static GCancellable *send_cancel = NULL;
1367 WizardWindow *wizard = (WizardWindow *)data;
1368 RecvProtocol protocol = combobox_get_active_data(GTK_COMBO_BOX(wizard->recv_type));
1371 recv_cancel = g_cancellable_new();
1372 send_cancel = g_cancellable_new();
1375 if (widget == wizard->auto_configure_cancel_btn) {
1376 g_cancellable_cancel(recv_cancel);
1377 g_cancellable_cancel(send_cancel);
1378 g_object_unref(recv_cancel);
1379 g_object_unref(send_cancel);
1385 address = gtk_editable_get_chars(GTK_EDITABLE(wizard->email), 0, -1);
1387 if (strchr(address, '@') == NULL) {
1389 gtk_label_set_text(GTK_LABEL(wizard->auto_configure_lbl),
1390 _("Failed (wrong address)"));
1394 if (protocol == A_POP3 || protocol == A_IMAP4) {
1395 recv_data = g_new0(AutoConfigureData, 1);
1396 recv_data->configure_button = GTK_BUTTON(wizard->auto_configure_btn);
1397 recv_data->cancel_button = GTK_BUTTON(wizard->auto_configure_cancel_btn);
1398 recv_data->info_label = GTK_LABEL(wizard->auto_configure_lbl);
1399 recv_data->uid_entry = GTK_ENTRY(wizard->recv_username);
1400 recv_data->cancel = recv_cancel;
1403 recv_data->ssl_service = "pop3s";
1404 recv_data->tls_service = "pop3";
1405 recv_data->address = g_strdup(address);
1406 recv_data->hostname_entry = GTK_ENTRY(wizard->recv_server);
1407 recv_data->set_port = NULL;
1408 recv_data->port = NULL;
1409 recv_data->tls_checkbtn = GTK_TOGGLE_BUTTON(wizard->recv_use_tls);
1410 recv_data->ssl_checkbtn = GTK_TOGGLE_BUTTON(wizard->recv_use_ssl);
1411 recv_data->default_port = 110;
1412 recv_data->default_ssl_port = 995;
1415 recv_data->ssl_service = "imaps";
1416 recv_data->tls_service = "imap";
1417 recv_data->address = g_strdup(address);
1418 recv_data->hostname_entry = GTK_ENTRY(wizard->recv_server);
1419 recv_data->set_port = NULL;
1420 recv_data->port = NULL;
1421 recv_data->tls_checkbtn = GTK_TOGGLE_BUTTON(wizard->recv_use_tls);
1422 recv_data->ssl_checkbtn = GTK_TOGGLE_BUTTON(wizard->recv_use_ssl);
1423 recv_data->default_port = 143;
1424 recv_data->default_ssl_port = 993;
1427 cm_return_if_fail(FALSE);
1429 auto_configure_service(recv_data);
1432 send_data = g_new0(AutoConfigureData, 1);
1433 send_data->configure_button = GTK_BUTTON(wizard->auto_configure_btn);
1434 send_data->cancel_button = GTK_BUTTON(wizard->auto_configure_cancel_btn);
1435 send_data->info_label = GTK_LABEL(wizard->auto_configure_lbl);
1436 send_data->cancel = send_cancel;
1438 send_data->ssl_service = NULL;
1439 send_data->tls_service = "submission";
1440 send_data->address = g_strdup(address);
1441 send_data->hostname_entry = GTK_ENTRY(wizard->smtp_server);
1442 send_data->set_port = NULL;
1443 send_data->port = NULL;
1444 send_data->tls_checkbtn = GTK_TOGGLE_BUTTON(wizard->smtp_use_tls);
1445 send_data->ssl_checkbtn = GTK_TOGGLE_BUTTON(wizard->smtp_use_ssl);
1446 send_data->default_port = 25;
1447 send_data->default_ssl_port = -1;
1448 send_data->auth_checkbtn = GTK_TOGGLE_BUTTON(wizard->smtp_auth);
1450 auto_configure_service(send_data);
1456 static GtkWidget* recv_page (WizardWindow * wizard)
1458 GtkWidget *table = gtk_table_new(1,1, FALSE);
1461 GtkWidget *hbox_spc;
1462 GtkWidget *recv_table;
1466 GtkWidget *recv_cert_table;
1468 #if defined USE_GNUTLS
1469 GtkWidget *auto_configure_btn;
1470 GtkWidget *auto_configure_cancel_btn;
1471 GtkWidget *auto_configure_lbl;
1473 GtkListStore *store;
1478 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
1479 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
1481 vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
1482 gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
1484 gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2,
1485 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1487 recv_table = gtk_table_new(4, 2, FALSE);
1489 gtk_box_pack_start(GTK_BOX(vbox), recv_table, FALSE, FALSE, 0);
1491 label = gtk_label_new(g_strconcat("<span weight=\"bold\">", _("Server type:"), "</span>", NULL));
1492 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
1493 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
1494 gtk_table_attach(GTK_TABLE(recv_table), label, 0,1,0,1,
1495 GTK_FILL, 0, VSPACING_NARROW, 0);
1496 wizard->recv_type = gtkut_sc_combobox_create(NULL, FALSE);
1497 store = GTK_LIST_STORE(gtk_combo_box_get_model(
1498 GTK_COMBO_BOX(wizard->recv_type)));
1500 COMBOBOX_ADD(store, _("POP3"), A_POP3);
1501 COMBOBOX_ADD(store, _("IMAP"), A_IMAP4);
1502 COMBOBOX_ADD(store, _("Local mbox file"), A_LOCAL);
1504 switch(tmpl.recvtype) {
1517 gtk_combo_box_set_active(GTK_COMBO_BOX (wizard->recv_type), index);
1518 g_signal_connect(G_OBJECT(wizard->recv_type), "changed",
1519 G_CALLBACK(wizard_protocol_changed),
1521 gtk_table_attach(GTK_TABLE(recv_table), wizard->recv_type, 1,2,0,1,
1522 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1524 #if defined USE_GNUTLS
1525 auto_configure_btn = gtk_button_new_with_label(_("Auto-configure"));
1526 auto_configure_cancel_btn = gtk_button_new_with_label(_("Cancel"));
1527 gtk_table_attach(GTK_TABLE(recv_table), auto_configure_btn, 0,1,1,2,
1528 GTK_FILL, 0, VSPACING_NARROW, 0);
1529 auto_configure_lbl = gtk_label_new("");
1530 gtk_misc_set_alignment(GTK_MISC(auto_configure_lbl), 0, 0.5);
1531 gtk_table_attach(GTK_TABLE(recv_table), auto_configure_lbl, 1,2,1,2,
1532 GTK_FILL, 0, VSPACING_NARROW, 0);
1533 gtk_widget_show(auto_configure_btn);
1534 gtk_widget_show(auto_configure_lbl);
1535 wizard->auto_configure_lbl = auto_configure_lbl;
1536 wizard->auto_configure_btn = auto_configure_btn;
1537 wizard->auto_configure_cancel_btn = auto_configure_cancel_btn;
1538 g_signal_connect (G_OBJECT (auto_configure_btn), "clicked",
1539 G_CALLBACK (auto_configure_cb), wizard);
1540 g_signal_connect (G_OBJECT (auto_configure_cancel_btn), "clicked",
1541 G_CALLBACK (auto_configure_cb), wizard);
1544 wizard->recv_label = gtk_label_new(g_strconcat("<span weight=\"bold\">",
1545 _("Server address:"), "</span>", NULL));
1546 gtk_misc_set_alignment(GTK_MISC(wizard->recv_label), 1, 0.5);
1547 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
1548 gtk_table_attach(GTK_TABLE(recv_table), wizard->recv_label, 0,1,2,3,
1549 GTK_FILL, 0, VSPACING_NARROW, 0);
1550 wizard->recv_server = gtk_entry_new();
1551 text = get_default_server(wizard, "pop");
1552 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
1555 CLAWS_SET_TIP(wizard->recv_server,
1556 _("You can specify the port number by appending it at the end: "
1557 "\"mail.example.com:110\""));
1558 gtk_table_attach(GTK_TABLE(recv_table), wizard->recv_server, 1,2,2,3,
1559 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1561 wizard->recv_username_label = gtk_label_new(g_strconcat("<span weight=\"bold\">",
1562 _("Username:"),"</span>", NULL));
1563 gtk_misc_set_alignment(GTK_MISC(wizard->recv_username_label), 1, 0.5);
1564 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_username_label), TRUE);
1565 gtk_table_attach(GTK_TABLE(recv_table), wizard->recv_username_label, 0,1,3,4,
1566 GTK_FILL, 0, VSPACING_NARROW, 0);
1567 wizard->recv_username = gtk_entry_new();
1568 text = get_default_account(wizard);
1569 gtk_entry_set_text(GTK_ENTRY(wizard->recv_username), text);
1571 gtk_table_attach(GTK_TABLE(recv_table), wizard->recv_username, 1,2,3,4,
1572 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1574 wizard->recv_password_label = gtk_label_new(_("Password:"));
1575 gtk_misc_set_alignment(GTK_MISC(wizard->recv_password_label), 1, 0.5);
1576 gtk_table_attach(GTK_TABLE(recv_table), wizard->recv_password_label, 0,1,4,5,
1577 GTK_FILL, 0, VSPACING_NARROW, 0);
1578 wizard->recv_password = gtk_entry_new();
1579 gtk_entry_set_text(GTK_ENTRY(wizard->recv_password), tmpl.recvpass?tmpl.recvpass:"");
1580 gtk_entry_set_visibility(GTK_ENTRY(wizard->recv_password), FALSE);
1581 gtk_table_attach(GTK_TABLE(recv_table), wizard->recv_password, 1,2,4,5,
1582 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1584 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1585 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1586 wizard->recv_use_ssl = gtk_check_button_new_with_label(
1587 _("Use SSL/TLS to connect to receiving server"));
1588 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->recv_use_ssl),
1590 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_use_ssl, FALSE, FALSE, 0);
1592 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1593 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1594 hbox_spc = gtk_hbox_new (FALSE, 0);
1595 gtk_widget_set_size_request (hbox_spc, 12, -1);
1596 gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1597 wizard->recv_use_tls = gtk_check_button_new_with_label(
1598 _("Use STARTTLS command to start encryption"));
1599 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->recv_use_tls),
1601 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_use_tls, FALSE, FALSE, 0);
1602 SET_TOGGLE_SENSITIVITY (wizard->recv_use_ssl, wizard->recv_use_tls);
1604 recv_cert_table = gtk_table_new(3,3, FALSE);
1605 gtk_box_pack_start (GTK_BOX(vbox), recv_cert_table, FALSE, FALSE, 4);
1606 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1607 hbox_spc = gtk_hbox_new (FALSE, 0);
1608 gtk_widget_set_size_request (hbox_spc, 12, -1);
1609 gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1610 label = gtk_label_new(_("Client SSL/TLS certificate (optional)"));
1611 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
1612 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1613 gtk_table_attach(GTK_TABLE(recv_cert_table), hbox, 0, 3, 0, 1, GTK_FILL, 0, 0, 0);
1614 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1615 hbox_spc = gtk_hbox_new (FALSE, 0);
1616 gtk_widget_set_size_request (hbox_spc, 12, -1);
1617 gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1618 label = gtk_label_new(_("File"));
1619 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
1620 gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
1621 gtk_table_attach(GTK_TABLE(recv_cert_table), hbox, 0, 1, 1, 2,
1622 GTK_FILL, 0, VSPACING_NARROW, 0);
1623 wizard->recv_ssl_cert_file = gtk_entry_new();
1624 gtk_entry_set_text(GTK_ENTRY(wizard->recv_ssl_cert_file), tmpl.recvssl_cert?tmpl.recvssl_cert:"");
1625 gtk_table_attach(GTK_TABLE(recv_cert_table), wizard->recv_ssl_cert_file, 1, 2, 1, 2, GTK_FILL, 0, 0, 0);
1626 button = gtkut_get_browse_file_btn(_("Browse"));
1627 gtk_table_attach(GTK_TABLE(recv_cert_table), button, 2, 3, 1, 2,
1628 GTK_FILL, 0, VSPACING_NARROW, 0);
1629 g_signal_connect(G_OBJECT(button), "clicked",
1630 G_CALLBACK(cert_browse_cb), wizard->recv_ssl_cert_file);
1632 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1633 hbox_spc = gtk_hbox_new (FALSE, 0);
1634 gtk_widget_set_size_request (hbox_spc, 12, -1);
1635 gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1636 label = gtk_label_new(_("Password"));
1637 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
1638 gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
1639 gtk_table_attach(GTK_TABLE(recv_cert_table), hbox, 0, 1, 2, 3,
1640 GTK_FILL, 0, VSPACING_NARROW, 0);
1641 wizard->recv_ssl_cert_pass = gtk_entry_new();
1642 gtk_entry_set_visibility(GTK_ENTRY(wizard->recv_ssl_cert_pass), FALSE);
1643 gtk_entry_set_text(GTK_ENTRY(wizard->recv_ssl_cert_pass), tmpl.recvssl_cert_pass?tmpl.recvssl_cert_pass:"");
1644 gtk_table_attach(GTK_TABLE(recv_cert_table), wizard->recv_ssl_cert_pass, 1, 2, 2, 3, GTK_FILL, 0, 0, 0);
1645 SET_TOGGLE_SENSITIVITY (wizard->recv_use_ssl, recv_cert_table);
1646 wizard->recv_cert_table = recv_cert_table;
1648 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1649 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1650 wizard->recv_imap_subdir = gtk_entry_new();
1651 gtk_entry_set_text(GTK_ENTRY(wizard->recv_imap_subdir), tmpl.imapdir?tmpl.imapdir:"");
1652 wizard->recv_imap_label = gtk_label_new(_("IMAP server directory:"));
1653 gtk_misc_set_alignment(GTK_MISC(wizard->recv_imap_label), 1, 0.5);
1654 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_imap_label, FALSE, FALSE, 0);
1655 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_imap_subdir, TRUE, TRUE, 0);
1657 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1658 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1659 hbox_spc = gtk_hbox_new (FALSE, 0);
1660 gtk_widget_set_size_request (hbox_spc, 12, -1);
1661 gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1662 wizard->subsonly_checkbtn = gtk_check_button_new_with_label(
1663 _("Show only subscribed folders"));
1664 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->subsonly_checkbtn),
1666 gtk_box_pack_start(GTK_BOX(hbox), wizard->subsonly_checkbtn, FALSE, FALSE, 0);
1668 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1669 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1670 wizard->no_imap_warning = gtk_label_new(g_strconcat("<span weight=\"bold\">",
1671 _("Warning: this version of Claws Mail\n"
1672 "has been built without IMAP support."), "</span>", NULL));
1673 gtk_label_set_use_markup(GTK_LABEL(wizard->no_imap_warning), TRUE);
1674 gtk_box_pack_start(GTK_BOX(hbox), wizard->no_imap_warning, FALSE, FALSE, 0);
1680 wizard_response_cb (GtkDialog * dialog, int response, gpointer data)
1682 WizardWindow * wizard = (WizardWindow *)data;
1683 int current_page, num_pages;
1684 gboolean skip_mailbox_page = FALSE;
1685 gint protocol = combobox_get_active_data(GTK_COMBO_BOX(wizard->recv_type));
1687 if (protocol == A_IMAP4) {
1688 skip_mailbox_page = TRUE;
1691 num_pages = g_slist_length(wizard->pages);
1693 current_page = gtk_notebook_get_current_page (
1694 GTK_NOTEBOOK(wizard->notebook));
1695 if (response == CANCEL)
1697 wizard->result = FALSE;
1698 wizard->finished = TRUE;
1699 gtk_widget_destroy (GTK_WIDGET(dialog));
1701 else if (response == FINISHED)
1703 if (!wizard_write_config(wizard)) {
1704 current_page = gtk_notebook_get_current_page (
1705 GTK_NOTEBOOK(wizard->notebook));
1708 wizard->result = TRUE;
1709 wizard->finished = TRUE;
1710 gtk_widget_destroy (GTK_WIDGET(dialog));
1714 if (response == GO_BACK)
1716 if (current_page > 0) {
1718 if (current_page == MAILBOX_PAGE && skip_mailbox_page) {
1722 gtk_notebook_set_current_page (
1723 GTK_NOTEBOOK(wizard->notebook),
1727 else if (response == GO_FORWARD)
1729 if (current_page < (num_pages-1)) {
1731 if (current_page == MAILBOX_PAGE && skip_mailbox_page) {
1735 gtk_notebook_set_current_page (
1736 GTK_NOTEBOOK(wizard->notebook),
1741 gtk_dialog_set_response_sensitive (dialog, GO_BACK,
1743 gtk_dialog_set_response_sensitive (dialog, GO_FORWARD,
1744 current_page < (num_pages - 1));
1745 if (current_page == (num_pages -1)) {
1746 gtk_dialog_set_response_sensitive (dialog, FINISHED, TRUE);
1747 gtk_dialog_set_default_response(GTK_DIALOG(wizard->window), FINISHED);
1749 gtk_dialog_set_response_sensitive (dialog, FINISHED, FALSE);
1750 gtk_dialog_set_default_response(GTK_DIALOG(wizard->window), GO_FORWARD);
1756 static gint wizard_close_cb(GtkWidget *widget, GdkEventAny *event,
1759 WizardWindow *wizard = (WizardWindow *)data;
1760 wizard->result = FALSE;
1761 wizard->finished = TRUE;
1766 #define PACK_WARNING(text) { \
1767 label = gtk_label_new(text); \
1768 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); \
1769 gtk_box_pack_end(GTK_BOX(widget), label, FALSE, FALSE, 0); \
1772 gboolean run_wizard(MainWindow *mainwin, gboolean create_mailbox) {
1773 WizardWindow *wizard = g_new0(WizardWindow, 1);
1777 GtkWidget *scrolled_window;
1782 wizard->mainwin = mainwin;
1783 wizard->create_mailbox = create_mailbox;
1785 gtk_widget_hide(mainwin->window);
1787 wizard_read_defaults();
1789 wizard->window = gtk_dialog_new_with_buttons (_("Claws Mail Setup Wizard"),
1791 GTK_STOCK_GO_BACK, GO_BACK,
1792 GTK_STOCK_GO_FORWARD, GO_FORWARD,
1793 GTK_STOCK_SAVE, FINISHED,
1794 GTK_STOCK_CANCEL, CANCEL,
1796 gtk_window_set_position(GTK_WINDOW(wizard->window), GTK_WIN_POS_CENTER);
1798 g_signal_connect(wizard->window, "response",
1799 G_CALLBACK(wizard_response_cb), wizard);
1800 gtk_widget_realize(wizard->window);
1801 gtk_dialog_set_default_response(GTK_DIALOG(wizard->window),
1803 gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window),
1805 gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window),
1807 gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window),
1809 gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window),
1812 wizard->notebook = gtk_notebook_new();
1813 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(wizard->notebook), FALSE);
1814 gtk_notebook_set_show_border(GTK_NOTEBOOK(wizard->notebook), FALSE);
1815 gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(wizard->window))),
1816 wizard->notebook, TRUE, TRUE, 0);
1818 wizard->pages = NULL;
1820 /*welcome page: 0 */
1822 page = create_page(wizard, _("Welcome to Claws Mail"));
1824 wizard->pages = g_slist_append(wizard->pages, page);
1825 widget = stock_pixmap_widget(STOCK_PIXMAP_CLAWS_MAIL_LOGO);
1827 gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1829 text = g_strdup(_("Welcome to the Claws Mail setup wizard.\n\n"
1830 "We will begin by defining some basic "
1831 "information about you and your most common "
1832 "mail options so that you can start to use "
1833 "Claws Mail in less than five minutes."));
1834 widget = gtk_label_new(text);
1835 gtk_label_set_line_wrap(GTK_LABEL(widget), TRUE);
1836 gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1842 widget = create_page (wizard, _("About You"));
1843 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
1844 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
1845 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1846 gtk_box_pack_start(GTK_BOX(widget), scrolled_window, TRUE, TRUE, 0);
1848 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1850 PACK_WARNING(_("Bold fields must be completed"));
1852 wizard->pages = g_slist_append(wizard->pages, widget);
1854 /* recv+auth page: 2 */
1857 widget = create_page (wizard, _("Receiving mail"));
1858 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
1859 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
1860 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1861 gtk_box_pack_start(GTK_BOX(widget), scrolled_window, TRUE, TRUE, 0);
1863 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1865 PACK_WARNING(_("Bold fields must be completed"));
1867 wizard->pages = g_slist_append(wizard->pages, widget);
1872 widget = create_page (wizard, _("Sending mail"));
1873 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
1874 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
1875 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1876 gtk_box_pack_start(GTK_BOX(widget), scrolled_window, TRUE, TRUE, 0);
1878 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1880 PACK_WARNING(_("Bold fields must be completed"));
1882 wizard->pages = g_slist_append(wizard->pages, widget);
1884 /* mailbox page: 4 */
1885 if (create_mailbox) {
1888 widget = create_page (wizard, _("Saving mail on disk"));
1889 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
1890 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
1891 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1892 gtk_box_pack_start(GTK_BOX(widget), scrolled_window, TRUE, TRUE, 0);
1894 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1895 mailbox_page(wizard));
1896 PACK_WARNING(_("Bold fields must be completed"));
1898 wizard->pages = g_slist_append(wizard->pages, widget);
1904 page = create_page(wizard, _("Configuration finished"));
1906 wizard->pages = g_slist_append(wizard->pages, page);
1907 widget = stock_pixmap_widget(STOCK_PIXMAP_CLAWS_MAIL_LOGO);
1909 gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1911 text = g_strdup(_("Claws Mail is now ready.\n"
1912 "Click Save to start."));
1913 widget = gtk_label_new(text);
1914 gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1918 for (cur = wizard->pages; cur && cur->data; cur = cur->next) {
1919 gtk_notebook_append_page (GTK_NOTEBOOK(wizard->notebook),
1920 GTK_WIDGET(cur->data), NULL);
1923 g_signal_connect(G_OBJECT(wizard->window), "delete_event",
1924 G_CALLBACK(wizard_close_cb), wizard);
1925 gtk_widget_show_all (wizard->window);
1927 gtk_widget_hide(wizard->recv_imap_label);
1928 gtk_widget_hide(wizard->recv_imap_subdir);
1929 gtk_widget_hide(wizard->subsonly_checkbtn);
1930 #if defined USE_GNUTLS
1931 gtk_widget_hide(wizard->auto_configure_cancel_btn);
1933 wizard_protocol_change(wizard, tmpl.recvtype);
1935 while (!wizard->finished)
1936 gtk_main_iteration();
1938 result = wizard->result;
1942 gtk_widget_show(mainwin->window);