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>
41 #include "prefs_account.h"
42 #include "mainwindow.h"
43 #include "stock_pixmap.h"
46 #include "alertpanel.h"
51 #include "prefs_common.h"
53 #include "passwordstore.h"
63 int WELCOME_PAGE = -1;
67 int MAILBOX_PAGE = -1;
80 GtkWidget *organization;
82 GtkWidget *mailbox_name;
83 GtkWidget *mailbox_label;
85 GtkWidget *smtp_server;
87 GtkWidget *smtp_username;
88 GtkWidget *smtp_password;
89 GtkWidget *smtp_username_label;
90 GtkWidget *smtp_password_label;
93 GtkWidget *recv_label;
94 GtkWidget *recv_server;
95 GtkWidget *recv_username;
96 GtkWidget *recv_password;
97 GtkWidget *recv_username_label;
98 GtkWidget *recv_password_label;
99 GtkWidget *recv_imap_label;
100 GtkWidget *recv_imap_subdir;
101 GtkWidget *subsonly_checkbtn;
102 GtkWidget *no_imap_warning;
104 GtkWidget *smtp_use_ssl;
105 GtkWidget *recv_use_ssl;
106 GtkWidget *smtp_use_tls;
107 GtkWidget *recv_use_tls;
108 GtkWidget *smtp_ssl_cert_file;
109 GtkWidget *recv_ssl_cert_file;
110 GtkWidget *smtp_ssl_cert_pass;
111 GtkWidget *recv_ssl_cert_pass;
112 GtkWidget *smtp_cert_table;
113 GtkWidget *recv_cert_table;
115 #if defined USE_GNUTLS
116 GtkWidget *auto_configure_lbl;
117 GtkWidget *auto_configure_btn;
118 GtkWidget *auto_configure_cancel_btn;
120 gboolean create_mailbox;
126 typedef struct _AccountTemplate {
135 RecvProtocol recvtype;
147 gchar *smtpssl_cert_pass;
148 gchar *recvssl_cert_pass;
151 static AccountTemplate tmpl;
153 static PrefParam template_params[] = {
154 {"name", "$USERNAME",
155 &tmpl.name, P_STRING, NULL, NULL, NULL},
156 {"domain", "$DEFAULTDOMAIN",
157 &tmpl.domain, P_STRING, NULL, NULL, NULL},
158 {"email", "$NAME_MAIL@$DOMAIN",
159 &tmpl.email, P_STRING, NULL, NULL, NULL},
161 &tmpl.organization, P_STRING, NULL, NULL, NULL},
162 {"smtpserver", "smtp.$DOMAIN",
163 &tmpl.smtpserver, P_STRING, NULL, NULL, NULL},
164 {"smtpauth", "FALSE",
165 &tmpl.smtpauth, P_BOOL, NULL, NULL, NULL},
167 &tmpl.smtpuser, P_STRING, NULL, NULL, NULL},
169 &tmpl.smtppass, P_STRING, NULL, NULL, NULL},
171 &tmpl.recvtype, P_INT, NULL, NULL, NULL},
172 {"recvserver", "pop.$DOMAIN",
173 &tmpl.recvserver, P_STRING, NULL, NULL, NULL},
174 {"recvuser", "$LOGIN",
175 &tmpl.recvuser, P_STRING, NULL, NULL, NULL},
177 &tmpl.recvpass, P_STRING, NULL, NULL, NULL},
179 &tmpl.imapdir, P_STRING, NULL, NULL, NULL},
181 &tmpl.subsonly, P_BOOL, NULL, NULL, NULL},
182 {"mboxfile", "/var/mail/$LOGIN",
183 &tmpl.mboxfile, P_STRING, NULL, NULL, NULL},
185 &tmpl.mailbox, P_STRING, NULL, NULL, NULL},
187 &tmpl.smtpssl, P_INT, NULL, NULL, NULL},
189 &tmpl.recvssl, P_INT, NULL, NULL, NULL},
191 &tmpl.smtpssl_cert, P_STRING, NULL, NULL, NULL},
193 &tmpl.recvssl_cert, P_STRING, NULL, NULL, NULL},
194 {"smtpssl_cert_pass", "",
195 &tmpl.smtpssl_cert, P_STRING, NULL, NULL, NULL},
196 {"recvssl_cert_pass", "",
197 &tmpl.recvssl_cert, P_STRING, NULL, NULL, NULL},
198 {NULL, NULL, NULL, P_INT, NULL, NULL, NULL}
202 static gchar *accountrc_tmpl =
203 "[AccountTemplate]\n"
204 "#you can use $DEFAULTDOMAIN here\n"
205 "#domain must be defined before the variables that use it\n"
206 "#by default, domain is extracted from the hostname\n"
209 "#you can use $USERNAME for name (this is the default)\n"
212 "#you can use $LOGIN, $NAME_MAIL and $DOMAIN here \n"
213 "#$NAME_MAIL is the name without uppercase and with dots instead\n"
215 "#the default is $NAME_MAIL@$DOMAIN\n"
218 "#you can use $DOMAIN here\n"
219 "#the default organization is empty\n"
222 "#you can use $DOMAIN here \n"
223 "#the default is smtp.$DOMAIN\n"
226 "#Whether to use smtp authentication\n"
227 "#the default is 0 (no)\n"
231 "#you can use $LOGIN, $NAME_MAIL, $DOMAIN or $EMAIL here\n"
232 "#the default is empty (same as reception username)\n"
236 "#the default is empty (same as reception password)\n"
239 "#recvtype can be:\n"
242 "#5 for a local mbox file\n"
245 "#you can use $DOMAIN here \n"
246 "#the default is {pop,imap}.$DOMAIN\n"
249 "#you can use $LOGIN, $NAME_MAIL, $DOMAIN or $EMAIL here\n"
250 "#default is $LOGIN\n"
253 "#default is empty\n"
256 "#imap dir if imap (relative to the home on the server)\n"
257 "#default is empty\n"
260 "#show subscribed folders only, if imap\n"
264 "#mbox file if local\n"
265 "#you can use $LOGIN here\n"
266 "#default is /var/mail/$LOGIN\n"
269 "#mailbox name if pop3 or local\n"
270 "#relative path from the user's home\n"
271 "#default is \"Mail\"\n"
274 "#whether to use encryption on SMTP connections\n"
275 "#default is 0, 1 is SSL/TLS, 2 is STARTTLS\n"
278 "#whether to use encryption on POP3 or IMAP connections\n"
279 "#default is 0, 1 is SSL/TLS, 2 is STARTTLS\n"
282 "#SSL/TLS client certificate path for SMTP\n"
283 "#default is empty (no certificate)\n"
286 "#SSL/TLS client certificate path for POP/IMAP\n"
287 "#default is empty (no certificate)\n"
290 "#SSL/TLS client certificate password for SMTP\n"
291 "#default is empty (no password)\n"
292 "#smtpssl_cert_pass=\n"
294 "#SSL/TLS client certificate password for POP/IMAP\n"
295 "#default is empty (no password)\n"
296 "#recvssl_cert_pass=\n"
299 static gchar *wizard_get_default_domain_name(void)
301 static gchar *domain_name = NULL;
303 if (domain_name == NULL) {
304 domain_name = g_strdup(get_domain_name());
305 if (strchr(domain_name, '.') != NULL
306 && strchr(domain_name, '.') != strrchr(domain_name, '.')
307 && strlen(strchr(domain_name, '.')) > 6) {
308 gchar *tmp = g_strdup(strchr(domain_name, '.')+1);
316 static gchar *get_name_for_mail(void)
319 if (tmpl.name == NULL)
321 name = g_utf8_strdown(tmpl.name, -1);
322 while(strstr(name, " "))
323 *strstr(name, " ")='.';
328 #define PARSE_DEFAULT(str) { \
329 gchar *tmp = NULL, *new = NULL; \
331 if (strstr(str, "$USERNAME")) { \
332 tmp = g_strdup(str); \
333 *strstr(tmp, "$USERNAME") = '\0'; \
334 new = g_strconcat(tmp, g_get_real_name(), \
335 strstr(str, "$USERNAME")+strlen("$USERNAME"), \
342 if (strstr(str, "$LOGIN")) { \
343 tmp = g_strdup(str); \
344 *strstr(tmp, "$LOGIN") = '\0'; \
345 new = g_strconcat(tmp, g_get_user_name(), \
346 strstr(str, "$LOGIN")+strlen("$LOGIN"), \
353 if (strstr(str, "$EMAIL")) { \
354 tmp = g_strdup(str); \
355 *strstr(tmp, "$EMAIL") = '\0'; \
356 new = g_strconcat(tmp, tmpl.email, \
357 strstr(str, "$EMAIL")+strlen("$EMAIL"), \
364 if (strstr(str, "$NAME_MAIL")) { \
365 tmp = g_strdup(str); \
366 *strstr(tmp, "$NAME_MAIL") = '\0'; \
367 new = g_strconcat(tmp, get_name_for_mail(), \
368 strstr(str, "$NAME_MAIL")+strlen("$NAME_MAIL"), \
375 if (strstr(str, "$DEFAULTDOMAIN")) { \
376 tmp = g_strdup(str); \
377 *strstr(tmp, "$DEFAULTDOMAIN") = '\0'; \
378 new = g_strconcat(tmp, wizard_get_default_domain_name(), \
379 strstr(str, "$DEFAULTDOMAIN")+strlen("$DEFAULTDOMAIN"), \
386 if (strstr(str, "$DOMAIN")) { \
387 tmp = g_strdup(str); \
388 *strstr(tmp, "$DOMAIN") = '\0'; \
389 new = g_strconcat(tmp, tmpl.domain, \
390 strstr(str, "$DOMAIN")+strlen("$DOMAIN"), \
399 static void wizard_read_defaults(void)
403 rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, "accountrc.tmpl", NULL);
404 if (!is_file_exist(rcpath)) {
405 str_write_to_file(accountrc_tmpl, rcpath);
408 prefs_read_config(template_params, "AccountTemplate", rcpath, NULL);
410 PARSE_DEFAULT(tmpl.domain);
411 PARSE_DEFAULT(tmpl.name);
412 PARSE_DEFAULT(tmpl.email);
413 PARSE_DEFAULT(tmpl.organization);
414 PARSE_DEFAULT(tmpl.smtpserver);
415 PARSE_DEFAULT(tmpl.smtpuser);
416 PARSE_DEFAULT(tmpl.smtppass);
417 PARSE_DEFAULT(tmpl.recvserver);
418 PARSE_DEFAULT(tmpl.recvuser);
419 PARSE_DEFAULT(tmpl.recvpass);
420 PARSE_DEFAULT(tmpl.imapdir);
421 PARSE_DEFAULT(tmpl.mboxfile);
422 PARSE_DEFAULT(tmpl.mailbox);
425 "%s, %s, %s, %s, %s, %d, %s, %s, %s, %s, %s, %s, %d, %d\n",
426 tmpl.name,tmpl.domain,tmpl.email,tmpl.organization,tmpl.smtpserver,
427 tmpl.recvtype,tmpl.recvserver,tmpl.recvuser,tmpl.recvpass,
428 tmpl.imapdir,tmpl.mboxfile,tmpl.mailbox,tmpl.smtpssl,tmpl.recvssl);
433 static void initialize_fonts(WizardWindow *wizard)
435 GtkWidget *widget = wizard->email;
436 gint size = pango_font_description_get_size(
437 gtk_widget_get_style(widget)->font_desc)
441 PangoFontDescription *bold_desc;
442 gchar *curfont = pango_font_description_to_string(
443 gtk_widget_get_style(widget)->font_desc);
444 g_free(prefs_common.smallfont);
445 g_free(prefs_common.normalfont);
446 g_free(prefs_common.boldfont);
447 prefs_common.smallfont = g_strdup(curfont);
448 prefs_common.normalfont = g_strdup(curfont);
449 bold_desc = pango_font_description_from_string(curfont);
450 pango_font_description_set_weight(bold_desc, PANGO_WEIGHT_BOLD);
451 prefs_common.boldfont = pango_font_description_to_string(bold_desc);
452 pango_font_description_free(bold_desc);
455 tmp = g_strdup(prefs_common.textfont);
456 if (strrchr(tmp, ' ')) {
457 *(strrchr(tmp, ' ')) = '\0';
458 new = g_strdup_printf("%s %d", tmp, size);
459 g_free(prefs_common.textfont);
460 prefs_common.textfont = new;
464 tmp = g_strdup(prefs_common.smallfont);
465 if (strrchr(tmp, ' ')) {
466 *(strrchr(tmp, ' ')) = '\0';
467 new = g_strdup_printf("%s %d", tmp, size);
468 g_free(prefs_common.smallfont);
469 prefs_common.smallfont = new;
473 tmp = g_strdup(prefs_common.normalfont);
474 if (strrchr(tmp, ' ')) {
475 *(strrchr(tmp, ' ')) = '\0';
476 new = g_strdup_printf("%s %d", tmp, size);
477 g_free(prefs_common.normalfont);
478 prefs_common.normalfont = new;
482 tmp = g_strdup(prefs_common.boldfont);
483 if (strrchr(tmp, ' ')) {
484 *(strrchr(tmp, ' ')) = '\0';
485 new = g_strdup_printf("%s %d", tmp, size);
486 g_free(prefs_common.boldfont);
487 prefs_common.boldfont = new;
492 #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"
493 #define FACE "iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAAM1BMVEUAAAAcJCI\n\
494 ONl1JUi0+Z4daY2NZciPabV9ykS5kj6Wsl2ybmZOBsMjZxK2wzN3Pzczs7OsCAGN0AAAAAXRSTlM\n\
495 AQObYZgAAAAFiS0dEAIgFHUgAAAIVSURBVEjH1ZbtlqMgDIaFECoGhPu/2s0b0Lais/NzN6d1OJ7\n\
496 3yReQzrL8B5Zy3rvl9At52Pf2tv1vSMjtYj8jaa8XUyI/yn3YD6sigj/2Tf5Bn069MIsTPHvx/t5\n\
497 /3rU/6JCIY3YwGe26r/cwUfE3cFe5T28L0K5rJAUHEeYAQxs8DHojjk3M9wECU4xxjXisI8RA0gy\n\
498 oczJZJOjxiTFZVTchAnIRJrgdmEGDyFfAI3UuG5FmYTkR9RDrIC4H0SqV4pzpEcUp0HNLjwBv+jA\n\
499 dikUE5g9iBvzmu3sH2oDk4lnHd829+2Q9gj6kDqDPg7hsGwBzH02fE3ZCt6ZHmlNKIMjMeRwra5I\n\
500 ecgNoBnLGPmzaHPJIwLY8Sq2M/tLUJfj0QcqmfVXAdLSStIYF8dzWjBBb2VgvDa4mO9oc651OiUo\n\
501 BEKbZokdPATF9E9oKAjQJcJOniaPXrVZRAnVWaqIyqRoNC8ZJvgCcW8XN39RqxVP1rS8Yd4WnCdN\n\
502 aRTo2jJRDbg3vtCpEUGffgDPhqKDaSuVqYtOplFIvIcx3HUI5/MuIWl6vKyBjNlqEru8hbFXqBPA\n\
503 5TpHGIUZOePeaIyzfQ/g9Xg0opU1AvdfXM9floYhv92pPAE96OZtkPV8eivgQi9RTfwPUU36I26n\n\
504 Hy+WuCJzAT7efMSeA1TNf2/VugDz+dN139xfA5ffxGZDD+MvcP/uvyB80wzZ76wbz8gAAAABJRU5\n\
507 static void write_welcome_email(WizardWindow *wizard)
509 gchar date[RFC822_DATE_BUFFSIZE];
513 const gchar *mailbox = gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name));
514 Folder *folder = folder_find_from_path(mailbox);
515 FolderItem *inbox = folder ? folder->inbox:NULL;
516 gchar *file = get_tmp_file();
517 gchar enc_from_name[BUFFSIZE], enc_to_name[BUFFSIZE], enc_subject[BUFFSIZE];
519 get_rfc822_date(date, sizeof(date));
521 conv_encode_header_full(enc_subject, sizeof(enc_subject),
522 C_("Welcome Mail Subject", "Welcome to Claws Mail"),
523 strlen("Subject: "), FALSE, CS_INTERNAL);
524 conv_encode_header_full(enc_to_name, sizeof(enc_to_name),
525 gtk_entry_get_text(GTK_ENTRY(wizard->full_name)),
526 strlen("To: "), TRUE, CS_INTERNAL);
527 conv_encode_header_full(enc_from_name, sizeof(enc_from_name),
528 _("The Claws Mail Team"),
529 strlen("From: "), TRUE, CS_INTERNAL);
531 head = g_strdup_printf(
538 "Content-Type: text/plain; charset=UTF-8\n",
542 gtk_entry_get_text(GTK_ENTRY(wizard->email)),
543 date, enc_subject, XFACE, FACE);
544 body = g_strdup_printf(
546 "Welcome to Claws Mail\n"
547 "---------------------\n"
549 "Now that you have set up your account you can fetch your\n"
550 "mail by clicking the 'Get Mail' button at the left of the\n"
553 "Claws Mail has lots of extra features accessible via plugins,\n"
554 "like anti-spam filtering and learning (via the Bogofilter or\n"
555 "SpamAssassin plugins), privacy protection (via PGP/Mime), an RSS\n"
556 "aggregator, a calendar, and much more. You can load them from\n"
557 "the menu entry '/Configuration/Plugins'.\n"
559 "You can change your Account Preferences by using the menu\n"
560 "entry '/Configuration/Preferences for current account'\n"
561 "and change the general Preferences by using\n"
562 "'/Configuration/Preferences'.\n"
564 "You can find further information in the Claws Mail manual,\n"
565 "which can be accessed by using the menu entry '/Help/Manual'\n"
566 "or online at the URL given below.\n"
574 "Mailing Lists: <%s>\n"
578 "Claws Mail is free software, released under the terms\n"
579 "of the GNU General Public License, version 3 or later, as\n"
580 "published by the Free Software Foundation. The license can\n"
581 "be found at <%s>.\n"
585 "If you wish to donate to the Claws Mail project you can do\n"
587 HOMEPAGE_URI, MANUAL_URI, FAQ_URI, THEMES_URI, MAILING_LIST_URI,
588 GPL_URI, DONATE_URI);
590 msg = g_strconcat(head, body, NULL);
592 if (inbox && inbox->total_msgs == 0
593 && str_write_to_file(msg, file) >= 0) {
594 MsgFlags flags = { MSG_UNREAD|MSG_NEW, 0};
595 folder_item_add_msg(inbox, file, &flags, FALSE);
604 static gboolean wizard_write_config(WizardWindow *wizard)
606 static gboolean mailbox_ok = FALSE;
607 PrefsAccount *prefs_account = prefs_account_new();
608 GList *account_list = NULL;
609 gchar *smtp_server, *recv_server;
610 gint smtp_port, recv_port;
612 SSLType smtp_ssl_type, recv_ssl_type;
615 prefs_account->protocol = combobox_get_active_data(
616 GTK_COMBO_BOX(wizard->recv_type));
618 if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4 &&
619 !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name)))) {
620 alertpanel_error(_("Please enter the mailbox name."));
621 g_free(prefs_account);
622 gtk_notebook_set_current_page (
623 GTK_NOTEBOOK(wizard->notebook),
629 if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4) {
630 mailbox_ok = setup_write_mailbox_path(wizard->mainwin,
632 GTK_ENTRY(wizard->mailbox_name)));
638 /* alertpanel done by setup_write_mailbox_path */
639 g_free(prefs_account);
640 gtk_notebook_set_current_page (
641 GTK_NOTEBOOK(wizard->notebook),
646 if (!strlen(gtk_entry_get_text(GTK_ENTRY(wizard->full_name)))
647 || !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->email)))) {
648 alertpanel_error(_("Please enter your name and email address."));
649 g_free(prefs_account);
650 gtk_notebook_set_current_page (
651 GTK_NOTEBOOK(wizard->notebook),
656 if (prefs_account->protocol != A_LOCAL) {
657 if (!strlen(gtk_entry_get_text(GTK_ENTRY(wizard->recv_username)))
658 || !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)))) {
659 alertpanel_error(_("Please enter your receiving server "
661 g_free(prefs_account);
662 gtk_notebook_set_current_page (
663 GTK_NOTEBOOK(wizard->notebook),
668 if (!strlen(gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)))) {
669 alertpanel_error(_("Please enter your username."));
670 g_free(prefs_account);
671 gtk_notebook_set_current_page (
672 GTK_NOTEBOOK(wizard->notebook),
678 if (!strlen(gtk_entry_get_text(GTK_ENTRY(wizard->smtp_server)))) {
679 alertpanel_error(_("Please enter your SMTP server."));
680 g_free(prefs_account);
681 gtk_notebook_set_current_page (
682 GTK_NOTEBOOK(wizard->notebook),
687 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_auth))) {
688 if (prefs_account->protocol == A_LOCAL
689 && !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->smtp_username)))) {
690 alertpanel_error(_("Please enter your SMTP username."));
691 g_free(prefs_account);
692 gtk_notebook_set_current_page (
693 GTK_NOTEBOOK(wizard->notebook),
696 } /* if it's not local we'll use the reception server */
699 if (prefs_account->protocol != A_LOCAL)
700 prefs_account->account_name = g_strdup_printf("%s@%s",
701 gtk_entry_get_text(GTK_ENTRY(wizard->recv_username)),
702 gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
704 prefs_account->account_name = g_strdup_printf("%s",
705 gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
707 recv_server = g_strdup(gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
708 smtp_server = g_strdup(gtk_entry_get_text(GTK_ENTRY(wizard->smtp_server)));
710 if (prefs_account->protocol != A_LOCAL && strstr(recv_server, ":")) {
711 recv_port = atoi(strstr(recv_server, ":")+1);
712 *(strstr(recv_server, ":")) = '\0';
713 if (prefs_account->protocol == A_IMAP4) {
714 prefs_account->set_imapport = TRUE;
715 prefs_account->imapport = recv_port;
716 } else if (prefs_account->protocol == A_POP3) {
717 prefs_account->set_popport = TRUE;
718 prefs_account->popport = recv_port;
721 if (strstr(smtp_server, ":")) {
722 smtp_port = atoi(strstr(smtp_server, ":")+1);
723 *(strstr(smtp_server, ":")) = '\0';
724 prefs_account->set_smtpport = TRUE;
725 prefs_account->smtpport = smtp_port;
728 prefs_account->name = g_strdup(
729 gtk_entry_get_text(GTK_ENTRY(wizard->full_name)));
730 prefs_account->address = g_strdup(
731 gtk_entry_get_text(GTK_ENTRY(wizard->email)));
732 prefs_account->organization = g_strdup(
733 gtk_entry_get_text(GTK_ENTRY(wizard->organization)));
734 prefs_account->smtp_server = g_strdup(smtp_server);
736 if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4) {
738 tmp = g_path_get_basename(gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name)));
739 prefs_account->inbox = g_strdup_printf("#mh/%s/inbox",
740 (!strcmp("Mail", gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name))))
743 prefs_account->local_inbox = g_strdup(prefs_account->inbox);
744 } else if (prefs_account->protocol != A_IMAP4) {
745 if (folder_get_default_inbox())
746 prefs_account->local_inbox =
747 folder_item_get_identifier(folder_get_default_inbox());
750 if (prefs_account->protocol != A_LOCAL)
751 prefs_account->recv_server = g_strdup(recv_server);
753 prefs_account->local_mbox = g_strdup(recv_server);
758 prefs_account->userid = g_strdup(
759 gtk_entry_get_text(GTK_ENTRY(wizard->recv_username)));
760 prefs_account->smtp_userid = g_strdup(
761 gtk_entry_get_text(GTK_ENTRY(wizard->smtp_username)));
763 passwd_store_set_account(prefs_account->account_id, PWS_ACCOUNT_RECV,
764 gtk_entry_get_text(GTK_ENTRY(wizard->recv_password)),
766 passwd_store_set_account(prefs_account->account_id, PWS_ACCOUNT_SEND,
767 gtk_entry_get_text(GTK_ENTRY(wizard->smtp_password)),
770 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_auth))) {
771 prefs_account->use_smtp_auth = TRUE;
775 smtp_ssl_type = SSL_NONE;
776 recv_ssl_type = SSL_NONE;
778 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_ssl))) {
779 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_tls)))
780 smtp_ssl_type = SSL_STARTTLS;
782 smtp_ssl_type = SSL_TUNNEL;
784 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->recv_use_ssl))) {
785 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->recv_use_tls)))
786 recv_ssl_type = SSL_STARTTLS;
788 recv_ssl_type = SSL_TUNNEL;
791 prefs_account->ssl_smtp = smtp_ssl_type;
793 if (prefs_account->protocol == A_IMAP4)
794 prefs_account->ssl_imap = recv_ssl_type;
796 prefs_account->ssl_pop = recv_ssl_type;
798 prefs_account->out_ssl_client_cert_file = g_strdup(
799 gtk_entry_get_text(GTK_ENTRY(wizard->smtp_ssl_cert_file)));
800 prefs_account->in_ssl_client_cert_file = g_strdup(
801 gtk_entry_get_text(GTK_ENTRY(wizard->recv_ssl_cert_file)));
803 passwd_store_set_account(prefs_account->account_id, PWS_ACCOUNT_SEND_CERT,
804 gtk_entry_get_text(GTK_ENTRY(wizard->smtp_ssl_cert_pass)),
806 passwd_store_set_account(prefs_account->account_id, PWS_ACCOUNT_RECV_CERT,
807 gtk_entry_get_text(GTK_ENTRY(wizard->recv_ssl_cert_pass)),
811 if (prefs_account->protocol == A_IMAP4) {
812 gchar *directory = gtk_editable_get_chars(
813 GTK_EDITABLE(wizard->recv_imap_subdir), 0, -1);
814 if (directory && strlen(directory)) {
815 prefs_account->imap_dir = g_strdup(directory);
817 prefs_account->imap_subsonly =
818 gtk_toggle_button_get_active(
819 GTK_TOGGLE_BUTTON(wizard->subsonly_checkbtn));
823 account_list = g_list_append(account_list, prefs_account);
824 prefs_account_write_config_all(account_list);
825 prefs_account_free(prefs_account);
826 account_read_config_all();
828 initialize_fonts(wizard);
829 if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4)
830 write_welcome_email(wizard);
833 plugin_load_standard_plugins();
838 static GtkWidget* create_page (WizardWindow *wizard, const char * title)
846 vbox = gtk_vbox_new (FALSE, 6);
847 gtk_container_set_border_width (GTK_CONTAINER(vbox), 10);
849 /* create the titlebar */
850 hbox = gtk_hbox_new (FALSE, 12);
851 image = stock_pixmap_widget(STOCK_PIXMAP_CLAWS_MAIL_ICON);
852 gtk_box_pack_start (GTK_BOX(hbox), image, FALSE, FALSE, 0);
853 title_string = g_strconcat ("<span size=\"xx-large\" weight=\"ultrabold\">", title ? title : "", "</span>", NULL);
854 w = gtk_label_new (title_string);
855 gtk_label_set_use_markup (GTK_LABEL(w), TRUE);
856 g_free (title_string);
857 gtk_box_pack_start (GTK_BOX(hbox), w, FALSE, FALSE, 0);
859 /* pack the titlebar */
860 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
862 /* pack the separator */
863 gtk_box_pack_start (GTK_BOX(vbox), gtk_hseparator_new(), FALSE, FALSE, 0);
866 w = gtk_alignment_new (0, 0, 0, 0);
867 gtk_widget_set_size_request (w, 0, 6);
868 gtk_box_pack_start (GTK_BOX(vbox), w, FALSE, FALSE, 0);
873 #define PACK_BOX(hbox,text,entry) { \
874 GtkWidget *label = gtk_label_new(text); \
875 gtk_label_set_use_markup(GTK_LABEL(label), TRUE); \
876 if (GTK_IS_MISC(label)) \
877 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); \
878 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); \
879 gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0); \
882 static gchar *get_default_server(WizardWindow * wizard, const gchar *type)
884 if (!strcmp(type, "smtp")) {
885 if (!tmpl.smtpserver || !strlen(tmpl.smtpserver))
886 return g_strconcat(type, ".", tmpl.domain, NULL);
888 return g_strdup(tmpl.smtpserver);
890 if (!tmpl.recvserver || !strlen(tmpl.recvserver))
891 return g_strconcat(type, ".", tmpl.domain, NULL);
893 return g_strdup(tmpl.recvserver);
897 static gchar *get_default_account(WizardWindow * wizard)
899 gchar *result = NULL;
901 if (!tmpl.recvuser || !strlen(tmpl.recvuser)) {
902 result = gtk_editable_get_chars(
903 GTK_EDITABLE(wizard->email), 0, -1);
905 if (strstr(result, "@")) {
906 *(strstr(result,"@")) = '\0';
909 result = g_strdup(tmpl.recvuser);
914 static gchar *get_default_smtp_account(WizardWindow * wizard)
916 gchar *result = NULL;
918 if (!tmpl.smtpuser || !strlen(tmpl.smtpuser)) {
921 result = g_strdup(tmpl.smtpuser);
926 static void wizard_email_changed(GtkWidget *widget, gpointer data)
928 WizardWindow *wizard = (WizardWindow *)data;
929 RecvProtocol protocol;
931 protocol = combobox_get_active_data(GTK_COMBO_BOX(wizard->recv_type));
933 text = get_default_server(wizard, "smtp");
934 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_server), text);
937 text = get_default_account(wizard);
938 gtk_entry_set_text(GTK_ENTRY(wizard->recv_username), text);
941 if (protocol == A_POP3) {
942 text = get_default_server(wizard, "pop");
943 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
945 } else if (protocol == A_IMAP4) {
946 text = get_default_server(wizard, "imap");
947 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
949 } else if (protocol == A_LOCAL) {
950 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), tmpl.mboxfile?tmpl.mboxfile:"");
955 static GtkWidget* user_page (WizardWindow * wizard)
957 GtkWidget *table = gtk_table_new(1,1, FALSE);
960 GtkWidget *user_table;
962 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
963 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
965 vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
966 gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
968 gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2,
969 GTK_EXPAND|GTK_FILL, 0, 0, 0);
971 user_table = gtk_table_new(3, 2, FALSE);
972 gtk_table_set_row_spacings(GTK_TABLE(user_table), VSPACING_NARROW);
973 gtk_box_pack_start(GTK_BOX(vbox), user_table, FALSE, FALSE, 0);
975 label = gtk_label_new(g_strconcat("<span weight=\"bold\">", _("Your name:"),
977 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
978 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
979 gtk_table_attach(GTK_TABLE(user_table), label, 0,1,0,1,
980 GTK_FILL, 0, VSPACING_NARROW, 0);
981 wizard->full_name = gtk_entry_new();
982 gtk_entry_set_text(GTK_ENTRY(wizard->full_name), tmpl.name?tmpl.name:"");
983 gtk_table_attach(GTK_TABLE(user_table), wizard->full_name, 1,2,0,1,
984 GTK_EXPAND|GTK_FILL, 0, 0, 0);
986 label = gtk_label_new(g_strconcat("<span weight=\"bold\">", _("Your email address:"),
988 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
989 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
990 gtk_table_attach(GTK_TABLE(user_table), label, 0,1,1,2,
991 GTK_FILL, 0, VSPACING_NARROW, 0);
992 wizard->email = gtk_entry_new();
993 gtk_entry_set_text(GTK_ENTRY(wizard->email), tmpl.email?tmpl.email:"");
994 gtk_table_attach(GTK_TABLE(user_table), wizard->email, 1,2,1,2,
995 GTK_EXPAND|GTK_FILL, 0, 0, 0);
997 label = gtk_label_new(_("Your organization:"));
998 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
999 gtk_table_attach(GTK_TABLE(user_table), label, 0,1,2,3,
1000 GTK_FILL, 0, VSPACING_NARROW, 0);
1001 wizard->organization = gtk_entry_new();
1002 gtk_entry_set_text(GTK_ENTRY(wizard->organization), tmpl.organization?tmpl.organization:"");
1003 gtk_table_attach(GTK_TABLE(user_table), wizard->organization, 1,2,2,3,
1004 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1006 g_signal_connect(G_OBJECT(wizard->email), "changed",
1007 G_CALLBACK(wizard_email_changed),
1012 static GtkWidget* mailbox_page (WizardWindow * wizard)
1014 GtkWidget *table = gtk_table_new(1,1, FALSE);
1018 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
1019 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
1021 vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
1022 gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
1024 gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2,
1025 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1027 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1028 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1030 wizard->mailbox_label = gtk_label_new(g_strconcat("<span weight=\"bold\">",
1031 _("Mailbox name:"), "</span>", NULL));
1032 gtk_label_set_use_markup(GTK_LABEL(wizard->mailbox_label), TRUE);
1033 if (GTK_IS_MISC(wizard->mailbox_label))
1034 gtk_misc_set_alignment(GTK_MISC(wizard->mailbox_label), 1, 0.5);
1035 wizard->mailbox_name = gtk_entry_new();
1037 gtk_entry_set_text(GTK_ENTRY(wizard->mailbox_name), tmpl.mailbox?tmpl.mailbox:"");
1039 CLAWS_SET_TIP(wizard->mailbox_name, _("You can also specify an absolute path, for example: "
1040 "\"/home/john/Documents/Mail\""));
1042 gtk_box_pack_start(GTK_BOX(hbox), wizard->mailbox_label, FALSE, FALSE, 0);
1043 gtk_box_pack_start(GTK_BOX(hbox), wizard->mailbox_name, TRUE, TRUE, 0);
1048 static void smtp_auth_changed (GtkWidget *btn, gpointer data)
1050 WizardWindow *wizard = (WizardWindow *)data;
1051 gboolean do_auth = gtk_toggle_button_get_active(
1052 GTK_TOGGLE_BUTTON(wizard->smtp_auth));
1053 gtk_widget_set_sensitive(wizard->smtp_username, do_auth);
1054 gtk_widget_set_sensitive(wizard->smtp_username_label, do_auth);
1055 gtk_widget_set_sensitive(wizard->smtp_password, do_auth);
1056 gtk_widget_set_sensitive(wizard->smtp_password_label, do_auth);
1060 static void cert_browse_cb(GtkWidget *widget, gpointer data)
1062 GtkEntry *dest = GTK_ENTRY(data);
1064 gchar *utf8_filename;
1066 filename = filesel_select_file_open(_("Select certificate file"), NULL);
1067 if (!filename) return;
1069 utf8_filename = g_filename_to_utf8(filename, -1, NULL, NULL, NULL);
1070 if (!utf8_filename) {
1071 g_warning("cert_browse_cb(): failed to convert character set.");
1072 utf8_filename = g_strdup(filename);
1074 gtk_entry_set_text(dest, utf8_filename);
1075 g_free(utf8_filename);
1079 static GtkWidget* smtp_page (WizardWindow * wizard)
1081 GtkWidget *table = gtk_table_new(1, 1, FALSE);
1084 GtkWidget *hbox_spc;
1085 GtkWidget *smtp_auth_table;
1089 GtkWidget *smtp_cert_table;
1093 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
1094 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
1096 vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
1097 gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
1099 gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2,
1100 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1102 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1103 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1104 wizard->smtp_server = gtk_entry_new();
1105 text = get_default_server(wizard, "smtp");
1106 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_server), text);
1109 CLAWS_SET_TIP(wizard->smtp_server,
1110 _("You can specify the port number by appending it at the end: "
1111 "\"mail.example.com:25\""));
1113 PACK_BOX(hbox, g_strconcat("<span weight=\"bold\">", _("SMTP server address:"),
1114 "</span>", NULL), wizard->smtp_server);
1116 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1117 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1118 wizard->smtp_auth = gtk_check_button_new_with_label(
1119 _("Use authentication"));
1120 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->smtp_auth),
1122 g_signal_connect(G_OBJECT(wizard->smtp_auth), "toggled",
1123 G_CALLBACK(smtp_auth_changed),
1125 gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_auth, FALSE, FALSE, 0);
1127 label = gtk_label_new(g_strconcat("<span size=\"small\">",
1128 _("(empty to use the same as receive)"), "</span>", NULL));
1129 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
1130 SET_TOGGLE_SENSITIVITY (wizard->smtp_auth, label);
1131 gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 0);
1133 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1134 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1135 hbox_spc = gtk_hbox_new (FALSE, 0);
1136 gtk_widget_set_size_request (hbox_spc, 12, -1);
1137 gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1138 smtp_auth_table = gtk_table_new(2, 2, FALSE);
1139 SET_TOGGLE_SENSITIVITY (wizard->smtp_auth, smtp_auth_table);
1140 gtk_box_pack_start(GTK_BOX(hbox), smtp_auth_table, TRUE, TRUE, 0);
1142 wizard->smtp_username_label = gtk_label_new(_("SMTP username:"));
1143 gtk_misc_set_alignment(GTK_MISC(wizard->smtp_username_label), 1, 0.5);
1144 gtk_table_attach(GTK_TABLE(smtp_auth_table), wizard->smtp_username_label, 0,1,0,1,
1145 GTK_FILL, 0, VSPACING_NARROW, 0);
1146 text = get_default_smtp_account(wizard);
1147 wizard->smtp_username = gtk_entry_new();
1148 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_username), text);
1150 gtk_table_attach(GTK_TABLE(smtp_auth_table), wizard->smtp_username, 1,2,0,1,
1151 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1153 wizard->smtp_password_label = gtk_label_new(_("SMTP password:"));
1154 gtk_misc_set_alignment(GTK_MISC(wizard->smtp_password_label), 1, 0.5);
1155 gtk_table_attach(GTK_TABLE(smtp_auth_table), wizard->smtp_password_label, 0,1,1,2,
1156 GTK_FILL, 0, VSPACING_NARROW, 0);
1157 wizard->smtp_password = gtk_entry_new();
1158 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_password), tmpl.smtppass?tmpl.smtppass:"");
1159 gtk_entry_set_visibility(GTK_ENTRY(wizard->smtp_password), FALSE);
1160 gtk_table_attach(GTK_TABLE(smtp_auth_table), wizard->smtp_password, 1,2,1,2,
1161 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1163 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1164 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1165 wizard->smtp_use_ssl = gtk_check_button_new_with_label(
1166 _("Use SSL/TLS to connect to SMTP server"));
1167 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_ssl),
1169 gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_use_ssl, FALSE, FALSE, 0);
1171 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1172 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1173 hbox_spc = gtk_hbox_new (FALSE, 0);
1174 gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1175 gtk_widget_set_size_request (hbox_spc, 12, -1);
1176 wizard->smtp_use_tls = gtk_check_button_new_with_label(
1177 _("Use STARTTLS command to start encryption"));
1178 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_tls),
1180 gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_use_tls, FALSE, FALSE, 0);
1181 SET_TOGGLE_SENSITIVITY (wizard->smtp_use_ssl, wizard->smtp_use_tls);
1183 smtp_cert_table = gtk_table_new(3,3, FALSE);
1184 gtk_box_pack_start (GTK_BOX(vbox), smtp_cert_table, FALSE, FALSE, 4);
1185 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1186 hbox_spc = gtk_hbox_new (FALSE, 0);
1187 gtk_widget_set_size_request (hbox_spc, 12, -1);
1188 gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1189 label = gtk_label_new(_("Client SSL/TLS certificate (optional)"));
1190 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
1191 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1192 gtk_table_attach(GTK_TABLE(smtp_cert_table), hbox, 0, 3, 0, 1, GTK_FILL, 0, 0, 0);
1193 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1194 hbox_spc = gtk_hbox_new (FALSE, 0);
1195 gtk_widget_set_size_request (hbox_spc, 12, -1);
1196 gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1197 label = gtk_label_new(_("File"));
1198 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
1199 gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
1200 gtk_table_attach(GTK_TABLE(smtp_cert_table), hbox, 0, 1, 1, 2,
1201 GTK_FILL, 0, VSPACING_NARROW, 0);
1202 wizard->smtp_ssl_cert_file = gtk_entry_new();
1203 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_ssl_cert_file), tmpl.smtpssl_cert?tmpl.smtpssl_cert:"");
1204 gtk_table_attach(GTK_TABLE(smtp_cert_table), wizard->smtp_ssl_cert_file, 1, 2, 1, 2, GTK_FILL, 0, 0, 0);
1205 button = gtkut_get_browse_file_btn(_("Browse"));
1206 gtk_table_attach(GTK_TABLE(smtp_cert_table), button, 2, 3, 1, 2,
1207 GTK_FILL, 0, VSPACING_NARROW, 0);
1208 g_signal_connect(G_OBJECT(button), "clicked",
1209 G_CALLBACK(cert_browse_cb), wizard->smtp_ssl_cert_file);
1211 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1212 hbox_spc = gtk_hbox_new (FALSE, 0);
1213 gtk_widget_set_size_request (hbox_spc, 12, -1);
1214 gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1215 label = gtk_label_new(_("Password"));
1216 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
1217 gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
1218 gtk_table_attach(GTK_TABLE(smtp_cert_table), hbox, 0, 1, 2, 3,
1219 GTK_FILL, 0, VSPACING_NARROW, 0);
1220 wizard->smtp_ssl_cert_pass = gtk_entry_new();
1221 gtk_entry_set_visibility(GTK_ENTRY(wizard->smtp_ssl_cert_pass), FALSE);
1222 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_ssl_cert_pass), tmpl.smtpssl_cert_pass?tmpl.smtpssl_cert_pass:"");
1223 gtk_table_attach(GTK_TABLE(smtp_cert_table), wizard->smtp_ssl_cert_pass, 1, 2, 2, 3, GTK_FILL, 0, 0, 0);
1224 SET_TOGGLE_SENSITIVITY (wizard->smtp_use_ssl, smtp_cert_table);
1225 wizard->smtp_cert_table = smtp_cert_table;
1227 smtp_auth_changed(NULL, wizard);
1231 static void wizard_protocol_change(WizardWindow *wizard, RecvProtocol protocol)
1235 if (protocol == A_POP3) {
1236 text = get_default_server(wizard, "pop");
1237 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
1238 gtk_widget_hide(wizard->recv_imap_label);
1239 gtk_widget_hide(wizard->recv_imap_subdir);
1240 gtk_widget_hide(wizard->subsonly_checkbtn);
1241 gtk_widget_show(wizard->recv_username);
1242 gtk_widget_show(wizard->recv_password);
1243 gtk_widget_show(wizard->recv_username_label);
1244 gtk_widget_show(wizard->recv_password_label);
1245 gtk_widget_hide(wizard->no_imap_warning);
1247 gtk_widget_show(wizard->recv_use_ssl);
1248 gtk_widget_show(wizard->recv_use_tls);
1249 gtk_widget_show(wizard->recv_cert_table);
1251 #if defined USE_GNUTLS
1252 gtk_widget_show(wizard->auto_configure_btn);
1253 gtk_widget_hide(wizard->auto_configure_cancel_btn);
1254 gtk_widget_show(wizard->auto_configure_lbl);
1256 gtk_label_set_text(GTK_LABEL(wizard->recv_label),
1257 g_strconcat("<span weight=\"bold\">", _("Server address:"),
1259 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
1260 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, TRUE);
1262 if (wizard->create_mailbox) {
1263 gtk_widget_show(wizard->mailbox_label);
1264 gtk_widget_show(wizard->mailbox_name);
1266 } else if (protocol == A_IMAP4) {
1267 #ifdef HAVE_LIBETPAN
1268 text = get_default_server(wizard, "imap");
1269 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
1270 gtk_widget_show(wizard->recv_imap_label);
1271 gtk_widget_show(wizard->recv_imap_subdir);
1272 gtk_widget_show(wizard->subsonly_checkbtn);
1273 gtk_widget_show(wizard->recv_username);
1274 gtk_widget_show(wizard->recv_password);
1275 gtk_widget_show(wizard->recv_username_label);
1276 gtk_widget_show(wizard->recv_password_label);
1277 gtk_widget_hide(wizard->no_imap_warning);
1279 gtk_widget_show(wizard->recv_use_ssl);
1280 gtk_widget_show(wizard->recv_use_tls);
1281 gtk_widget_show(wizard->recv_cert_table);
1283 #if defined USE_GNUTLS
1284 gtk_widget_show(wizard->auto_configure_btn);
1285 gtk_widget_hide(wizard->auto_configure_cancel_btn);
1286 gtk_widget_show(wizard->auto_configure_lbl);
1288 gtk_label_set_text(GTK_LABEL(wizard->recv_label),
1289 g_strconcat("<span weight=\"bold\">", _("Server address:"),
1291 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
1292 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, TRUE);
1294 if (wizard->create_mailbox) {
1295 gtk_widget_hide(wizard->mailbox_label);
1296 gtk_widget_hide(wizard->mailbox_name);
1299 gtk_widget_hide(wizard->recv_imap_label);
1300 gtk_widget_hide(wizard->recv_imap_subdir);
1301 gtk_widget_hide(wizard->subsonly_checkbtn);
1302 gtk_widget_hide(wizard->recv_username);
1303 gtk_widget_hide(wizard->recv_password);
1304 gtk_widget_hide(wizard->recv_username_label);
1305 gtk_widget_hide(wizard->recv_password_label);
1306 gtk_widget_show(wizard->no_imap_warning);
1307 if (wizard->create_mailbox) {
1308 gtk_widget_hide(wizard->mailbox_label);
1309 gtk_widget_hide(wizard->mailbox_name);
1312 gtk_widget_hide(wizard->recv_use_ssl);
1313 gtk_widget_hide(wizard->recv_use_tls);
1314 gtk_widget_hide(wizard->recv_cert_table);
1316 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, FALSE);
1318 } else if (protocol == A_LOCAL) {
1319 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), tmpl.mboxfile?tmpl.mboxfile:"");
1320 gtk_label_set_text(GTK_LABEL(wizard->recv_label),
1321 g_strconcat("<span weight=\"bold\">", _("Local mailbox:"),
1323 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
1324 gtk_widget_hide(wizard->no_imap_warning);
1325 gtk_widget_hide(wizard->recv_imap_label);
1326 gtk_widget_hide(wizard->recv_imap_subdir);
1327 gtk_widget_hide(wizard->subsonly_checkbtn);
1328 gtk_widget_hide(wizard->recv_username);
1329 gtk_widget_hide(wizard->recv_password);
1330 gtk_widget_hide(wizard->recv_username_label);
1331 gtk_widget_hide(wizard->recv_password_label);
1332 #if defined USE_GNUTLS
1333 gtk_widget_hide(wizard->auto_configure_btn);
1334 gtk_widget_hide(wizard->auto_configure_cancel_btn);
1335 gtk_widget_hide(wizard->auto_configure_lbl);
1338 gtk_widget_hide(wizard->recv_use_ssl);
1339 gtk_widget_hide(wizard->recv_use_tls);
1340 gtk_widget_hide(wizard->recv_cert_table);
1342 if (wizard->create_mailbox) {
1343 gtk_widget_show(wizard->mailbox_label);
1344 gtk_widget_show(wizard->mailbox_name);
1346 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, TRUE);
1350 static void wizard_protocol_changed(GtkComboBox *combo, gpointer data)
1352 WizardWindow *wizard = (WizardWindow *)data;
1353 RecvProtocol protocol = combobox_get_active_data(combo);
1355 wizard_protocol_change(wizard, protocol);
1358 #if defined USE_GNUTLS
1359 static void auto_configure_cb (GtkWidget *widget, gpointer data)
1361 gchar *address = NULL;
1362 AutoConfigureData *recv_data;
1363 AutoConfigureData *send_data;
1364 static GCancellable *recv_cancel = NULL;
1365 static GCancellable *send_cancel = NULL;
1366 WizardWindow *wizard = (WizardWindow *)data;
1367 RecvProtocol protocol = combobox_get_active_data(GTK_COMBO_BOX(wizard->recv_type));
1370 recv_cancel = g_cancellable_new();
1371 send_cancel = g_cancellable_new();
1374 if (widget == wizard->auto_configure_cancel_btn) {
1375 g_cancellable_cancel(recv_cancel);
1376 g_cancellable_cancel(send_cancel);
1377 g_object_unref(recv_cancel);
1378 g_object_unref(send_cancel);
1384 address = gtk_editable_get_chars(GTK_EDITABLE(wizard->email), 0, -1);
1386 if (strchr(address, '@') == NULL) {
1388 gtk_label_set_text(GTK_LABEL(wizard->auto_configure_lbl),
1389 _("Failed (wrong address)"));
1393 if (protocol == A_POP3 || protocol == A_IMAP4) {
1394 recv_data = g_new0(AutoConfigureData, 1);
1395 recv_data->configure_button = GTK_BUTTON(wizard->auto_configure_btn);
1396 recv_data->cancel_button = GTK_BUTTON(wizard->auto_configure_cancel_btn);
1397 recv_data->info_label = GTK_LABEL(wizard->auto_configure_lbl);
1398 recv_data->uid_entry = GTK_ENTRY(wizard->recv_username);
1399 recv_data->cancel = recv_cancel;
1402 recv_data->ssl_service = "pop3s";
1403 recv_data->tls_service = "pop3";
1404 recv_data->address = g_strdup(address);
1405 recv_data->hostname_entry = GTK_ENTRY(wizard->recv_server);
1406 recv_data->set_port = NULL;
1407 recv_data->port = NULL;
1408 recv_data->tls_checkbtn = GTK_TOGGLE_BUTTON(wizard->recv_use_tls);
1409 recv_data->ssl_checkbtn = GTK_TOGGLE_BUTTON(wizard->recv_use_ssl);
1410 recv_data->default_port = 110;
1411 recv_data->default_ssl_port = 995;
1414 recv_data->ssl_service = "imaps";
1415 recv_data->tls_service = "imap";
1416 recv_data->address = g_strdup(address);
1417 recv_data->hostname_entry = GTK_ENTRY(wizard->recv_server);
1418 recv_data->set_port = NULL;
1419 recv_data->port = NULL;
1420 recv_data->tls_checkbtn = GTK_TOGGLE_BUTTON(wizard->recv_use_tls);
1421 recv_data->ssl_checkbtn = GTK_TOGGLE_BUTTON(wizard->recv_use_ssl);
1422 recv_data->default_port = 143;
1423 recv_data->default_ssl_port = 993;
1426 cm_return_if_fail(FALSE);
1428 auto_configure_service(recv_data);
1431 send_data = g_new0(AutoConfigureData, 1);
1432 send_data->configure_button = GTK_BUTTON(wizard->auto_configure_btn);
1433 send_data->cancel_button = GTK_BUTTON(wizard->auto_configure_cancel_btn);
1434 send_data->info_label = GTK_LABEL(wizard->auto_configure_lbl);
1435 send_data->cancel = send_cancel;
1437 send_data->ssl_service = NULL;
1438 send_data->tls_service = "submission";
1439 send_data->address = g_strdup(address);
1440 send_data->hostname_entry = GTK_ENTRY(wizard->smtp_server);
1441 send_data->set_port = NULL;
1442 send_data->port = NULL;
1443 send_data->tls_checkbtn = GTK_TOGGLE_BUTTON(wizard->smtp_use_tls);
1444 send_data->ssl_checkbtn = GTK_TOGGLE_BUTTON(wizard->smtp_use_ssl);
1445 send_data->default_port = 25;
1446 send_data->default_ssl_port = -1;
1447 send_data->auth_checkbtn = GTK_TOGGLE_BUTTON(wizard->smtp_auth);
1449 auto_configure_service(send_data);
1455 static GtkWidget* recv_page (WizardWindow * wizard)
1457 GtkWidget *table = gtk_table_new(1,1, FALSE);
1460 GtkWidget *hbox_spc;
1461 GtkWidget *recv_table;
1465 GtkWidget *recv_cert_table;
1467 #if defined USE_GNUTLS
1468 GtkWidget *auto_configure_btn;
1469 GtkWidget *auto_configure_cancel_btn;
1470 GtkWidget *auto_configure_lbl;
1472 GtkListStore *store;
1477 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
1478 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
1480 vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
1481 gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
1483 gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2,
1484 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1486 recv_table = gtk_table_new(4, 2, FALSE);
1488 gtk_box_pack_start(GTK_BOX(vbox), recv_table, FALSE, FALSE, 0);
1490 label = gtk_label_new(g_strconcat("<span weight=\"bold\">", _("Server type:"), "</span>", NULL));
1491 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
1492 gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
1493 gtk_table_attach(GTK_TABLE(recv_table), label, 0,1,0,1,
1494 GTK_FILL, 0, VSPACING_NARROW, 0);
1495 wizard->recv_type = gtkut_sc_combobox_create(NULL, FALSE);
1496 store = GTK_LIST_STORE(gtk_combo_box_get_model(
1497 GTK_COMBO_BOX(wizard->recv_type)));
1499 COMBOBOX_ADD(store, _("POP3"), A_POP3);
1500 COMBOBOX_ADD(store, _("IMAP"), A_IMAP4);
1501 COMBOBOX_ADD(store, _("Local mbox file"), A_LOCAL);
1503 switch(tmpl.recvtype) {
1516 gtk_combo_box_set_active(GTK_COMBO_BOX (wizard->recv_type), index);
1517 g_signal_connect(G_OBJECT(wizard->recv_type), "changed",
1518 G_CALLBACK(wizard_protocol_changed),
1520 gtk_table_attach(GTK_TABLE(recv_table), wizard->recv_type, 1,2,0,1,
1521 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1523 #if defined USE_GNUTLS
1524 auto_configure_btn = gtk_button_new_with_label(_("Auto-configure"));
1525 auto_configure_cancel_btn = gtk_button_new_with_label(_("Cancel"));
1526 gtk_table_attach(GTK_TABLE(recv_table), auto_configure_btn, 0,1,1,2,
1527 GTK_FILL, 0, VSPACING_NARROW, 0);
1528 auto_configure_lbl = gtk_label_new("");
1529 gtk_misc_set_alignment(GTK_MISC(auto_configure_lbl), 0, 0.5);
1530 gtk_table_attach(GTK_TABLE(recv_table), auto_configure_lbl, 1,2,1,2,
1531 GTK_FILL, 0, VSPACING_NARROW, 0);
1532 gtk_widget_show(auto_configure_btn);
1533 gtk_widget_show(auto_configure_lbl);
1534 wizard->auto_configure_lbl = auto_configure_lbl;
1535 wizard->auto_configure_btn = auto_configure_btn;
1536 wizard->auto_configure_cancel_btn = auto_configure_cancel_btn;
1537 g_signal_connect (G_OBJECT (auto_configure_btn), "clicked",
1538 G_CALLBACK (auto_configure_cb), wizard);
1539 g_signal_connect (G_OBJECT (auto_configure_cancel_btn), "clicked",
1540 G_CALLBACK (auto_configure_cb), wizard);
1543 wizard->recv_label = gtk_label_new(g_strconcat("<span weight=\"bold\">",
1544 _("Server address:"), "</span>", NULL));
1545 gtk_misc_set_alignment(GTK_MISC(wizard->recv_label), 1, 0.5);
1546 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
1547 gtk_table_attach(GTK_TABLE(recv_table), wizard->recv_label, 0,1,2,3,
1548 GTK_FILL, 0, VSPACING_NARROW, 0);
1549 wizard->recv_server = gtk_entry_new();
1550 text = get_default_server(wizard, "pop");
1551 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
1554 CLAWS_SET_TIP(wizard->recv_server,
1555 _("You can specify the port number by appending it at the end: "
1556 "\"mail.example.com:110\""));
1557 gtk_table_attach(GTK_TABLE(recv_table), wizard->recv_server, 1,2,2,3,
1558 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1560 wizard->recv_username_label = gtk_label_new(g_strconcat("<span weight=\"bold\">",
1561 _("Username:"),"</span>", NULL));
1562 gtk_misc_set_alignment(GTK_MISC(wizard->recv_username_label), 1, 0.5);
1563 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_username_label), TRUE);
1564 gtk_table_attach(GTK_TABLE(recv_table), wizard->recv_username_label, 0,1,3,4,
1565 GTK_FILL, 0, VSPACING_NARROW, 0);
1566 wizard->recv_username = gtk_entry_new();
1567 text = get_default_account(wizard);
1568 gtk_entry_set_text(GTK_ENTRY(wizard->recv_username), text);
1570 gtk_table_attach(GTK_TABLE(recv_table), wizard->recv_username, 1,2,3,4,
1571 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1573 wizard->recv_password_label = gtk_label_new(_("Password:"));
1574 gtk_misc_set_alignment(GTK_MISC(wizard->recv_password_label), 1, 0.5);
1575 gtk_table_attach(GTK_TABLE(recv_table), wizard->recv_password_label, 0,1,4,5,
1576 GTK_FILL, 0, VSPACING_NARROW, 0);
1577 wizard->recv_password = gtk_entry_new();
1578 gtk_entry_set_text(GTK_ENTRY(wizard->recv_password), tmpl.recvpass?tmpl.recvpass:"");
1579 gtk_entry_set_visibility(GTK_ENTRY(wizard->recv_password), FALSE);
1580 gtk_table_attach(GTK_TABLE(recv_table), wizard->recv_password, 1,2,4,5,
1581 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1583 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1584 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1585 wizard->recv_use_ssl = gtk_check_button_new_with_label(
1586 _("Use SSL/TLS to connect to receiving server"));
1587 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->recv_use_ssl),
1589 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_use_ssl, FALSE, FALSE, 0);
1591 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1592 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1593 hbox_spc = gtk_hbox_new (FALSE, 0);
1594 gtk_widget_set_size_request (hbox_spc, 12, -1);
1595 gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1596 wizard->recv_use_tls = gtk_check_button_new_with_label(
1597 _("Use STARTTLS command to start encryption"));
1598 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->recv_use_tls),
1600 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_use_tls, FALSE, FALSE, 0);
1601 SET_TOGGLE_SENSITIVITY (wizard->recv_use_ssl, wizard->recv_use_tls);
1603 recv_cert_table = gtk_table_new(3,3, FALSE);
1604 gtk_box_pack_start (GTK_BOX(vbox), recv_cert_table, FALSE, FALSE, 4);
1605 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1606 hbox_spc = gtk_hbox_new (FALSE, 0);
1607 gtk_widget_set_size_request (hbox_spc, 12, -1);
1608 gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1609 label = gtk_label_new(_("Client SSL/TLS certificate (optional)"));
1610 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
1611 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
1612 gtk_table_attach(GTK_TABLE(recv_cert_table), hbox, 0, 3, 0, 1, GTK_FILL, 0, 0, 0);
1613 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1614 hbox_spc = gtk_hbox_new (FALSE, 0);
1615 gtk_widget_set_size_request (hbox_spc, 12, -1);
1616 gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1617 label = gtk_label_new(_("File"));
1618 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
1619 gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
1620 gtk_table_attach(GTK_TABLE(recv_cert_table), hbox, 0, 1, 1, 2,
1621 GTK_FILL, 0, VSPACING_NARROW, 0);
1622 wizard->recv_ssl_cert_file = gtk_entry_new();
1623 gtk_entry_set_text(GTK_ENTRY(wizard->recv_ssl_cert_file), tmpl.recvssl_cert?tmpl.recvssl_cert:"");
1624 gtk_table_attach(GTK_TABLE(recv_cert_table), wizard->recv_ssl_cert_file, 1, 2, 1, 2, GTK_FILL, 0, 0, 0);
1625 button = gtkut_get_browse_file_btn(_("Browse"));
1626 gtk_table_attach(GTK_TABLE(recv_cert_table), button, 2, 3, 1, 2,
1627 GTK_FILL, 0, VSPACING_NARROW, 0);
1628 g_signal_connect(G_OBJECT(button), "clicked",
1629 G_CALLBACK(cert_browse_cb), wizard->recv_ssl_cert_file);
1631 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1632 hbox_spc = gtk_hbox_new (FALSE, 0);
1633 gtk_widget_set_size_request (hbox_spc, 12, -1);
1634 gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1635 label = gtk_label_new(_("Password"));
1636 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
1637 gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
1638 gtk_table_attach(GTK_TABLE(recv_cert_table), hbox, 0, 1, 2, 3,
1639 GTK_FILL, 0, VSPACING_NARROW, 0);
1640 wizard->recv_ssl_cert_pass = gtk_entry_new();
1641 gtk_entry_set_visibility(GTK_ENTRY(wizard->recv_ssl_cert_pass), FALSE);
1642 gtk_entry_set_text(GTK_ENTRY(wizard->recv_ssl_cert_pass), tmpl.recvssl_cert_pass?tmpl.recvssl_cert_pass:"");
1643 gtk_table_attach(GTK_TABLE(recv_cert_table), wizard->recv_ssl_cert_pass, 1, 2, 2, 3, GTK_FILL, 0, 0, 0);
1644 SET_TOGGLE_SENSITIVITY (wizard->recv_use_ssl, recv_cert_table);
1645 wizard->recv_cert_table = recv_cert_table;
1647 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1648 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1649 wizard->recv_imap_subdir = gtk_entry_new();
1650 gtk_entry_set_text(GTK_ENTRY(wizard->recv_imap_subdir), tmpl.imapdir?tmpl.imapdir:"");
1651 wizard->recv_imap_label = gtk_label_new(_("IMAP server directory:"));
1652 gtk_misc_set_alignment(GTK_MISC(wizard->recv_imap_label), 1, 0.5);
1653 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_imap_label, FALSE, FALSE, 0);
1654 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_imap_subdir, TRUE, TRUE, 0);
1656 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1657 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1658 hbox_spc = gtk_hbox_new (FALSE, 0);
1659 gtk_widget_set_size_request (hbox_spc, 12, -1);
1660 gtk_box_pack_start (GTK_BOX (hbox), hbox_spc, FALSE, FALSE, 0);
1661 wizard->subsonly_checkbtn = gtk_check_button_new_with_label(
1662 _("Show only subscribed folders"));
1663 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->subsonly_checkbtn),
1665 gtk_box_pack_start(GTK_BOX(hbox), wizard->subsonly_checkbtn, FALSE, FALSE, 0);
1667 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1668 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1669 wizard->no_imap_warning = gtk_label_new(g_strconcat("<span weight=\"bold\">",
1670 _("Warning: this version of Claws Mail\n"
1671 "has been built without IMAP support."), "</span>", NULL));
1672 gtk_label_set_use_markup(GTK_LABEL(wizard->no_imap_warning), TRUE);
1673 gtk_box_pack_start(GTK_BOX(hbox), wizard->no_imap_warning, FALSE, FALSE, 0);
1679 wizard_response_cb (GtkDialog * dialog, int response, gpointer data)
1681 WizardWindow * wizard = (WizardWindow *)data;
1682 int current_page, num_pages;
1683 gboolean skip_mailbox_page = FALSE;
1684 gint protocol = combobox_get_active_data(GTK_COMBO_BOX(wizard->recv_type));
1686 if (protocol == A_IMAP4) {
1687 skip_mailbox_page = TRUE;
1690 num_pages = g_slist_length(wizard->pages);
1692 current_page = gtk_notebook_get_current_page (
1693 GTK_NOTEBOOK(wizard->notebook));
1694 if (response == CANCEL)
1696 wizard->result = FALSE;
1697 wizard->finished = TRUE;
1698 gtk_widget_destroy (GTK_WIDGET(dialog));
1700 else if (response == FINISHED)
1702 if (!wizard_write_config(wizard)) {
1703 current_page = gtk_notebook_get_current_page (
1704 GTK_NOTEBOOK(wizard->notebook));
1707 wizard->result = TRUE;
1708 wizard->finished = TRUE;
1709 gtk_widget_destroy (GTK_WIDGET(dialog));
1713 if (response == GO_BACK)
1715 if (current_page > 0) {
1717 if (current_page == MAILBOX_PAGE && skip_mailbox_page) {
1721 gtk_notebook_set_current_page (
1722 GTK_NOTEBOOK(wizard->notebook),
1726 else if (response == GO_FORWARD)
1728 if (current_page < (num_pages-1)) {
1730 if (current_page == MAILBOX_PAGE && skip_mailbox_page) {
1734 gtk_notebook_set_current_page (
1735 GTK_NOTEBOOK(wizard->notebook),
1740 gtk_dialog_set_response_sensitive (dialog, GO_BACK,
1742 gtk_dialog_set_response_sensitive (dialog, GO_FORWARD,
1743 current_page < (num_pages - 1));
1744 if (current_page == (num_pages -1)) {
1745 gtk_dialog_set_response_sensitive (dialog, FINISHED, TRUE);
1746 gtk_dialog_set_default_response(GTK_DIALOG(wizard->window), FINISHED);
1748 gtk_dialog_set_response_sensitive (dialog, FINISHED, FALSE);
1749 gtk_dialog_set_default_response(GTK_DIALOG(wizard->window), GO_FORWARD);
1755 static gint wizard_close_cb(GtkWidget *widget, GdkEventAny *event,
1758 WizardWindow *wizard = (WizardWindow *)data;
1759 wizard->result = FALSE;
1760 wizard->finished = TRUE;
1765 #define PACK_WARNING(text) { \
1766 label = gtk_label_new(text); \
1767 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); \
1768 gtk_box_pack_end(GTK_BOX(widget), label, FALSE, FALSE, 0); \
1771 gboolean run_wizard(MainWindow *mainwin, gboolean create_mailbox) {
1772 WizardWindow *wizard = g_new0(WizardWindow, 1);
1776 GtkWidget *scrolled_window;
1781 wizard->mainwin = mainwin;
1782 wizard->create_mailbox = create_mailbox;
1784 gtk_widget_hide(mainwin->window);
1786 wizard_read_defaults();
1788 wizard->window = gtk_dialog_new_with_buttons (_("Claws Mail Setup Wizard"),
1790 GTK_STOCK_GO_BACK, GO_BACK,
1791 GTK_STOCK_GO_FORWARD, GO_FORWARD,
1792 GTK_STOCK_SAVE, FINISHED,
1793 GTK_STOCK_CANCEL, CANCEL,
1795 gtk_window_set_position(GTK_WINDOW(wizard->window), GTK_WIN_POS_CENTER);
1797 g_signal_connect(wizard->window, "response",
1798 G_CALLBACK(wizard_response_cb), wizard);
1799 gtk_widget_realize(wizard->window);
1800 gtk_dialog_set_default_response(GTK_DIALOG(wizard->window),
1802 gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window),
1804 gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window),
1806 gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window),
1808 gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window),
1811 wizard->notebook = gtk_notebook_new();
1812 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(wizard->notebook), FALSE);
1813 gtk_notebook_set_show_border(GTK_NOTEBOOK(wizard->notebook), FALSE);
1814 gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(wizard->window))),
1815 wizard->notebook, TRUE, TRUE, 0);
1817 wizard->pages = NULL;
1819 /*welcome page: 0 */
1821 page = create_page(wizard, _("Welcome to Claws Mail"));
1823 wizard->pages = g_slist_append(wizard->pages, page);
1824 widget = stock_pixmap_widget(STOCK_PIXMAP_CLAWS_MAIL_LOGO);
1826 gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1828 text = g_strdup(_("Welcome to the Claws Mail setup wizard.\n\n"
1829 "We will begin by defining some basic "
1830 "information about you and your most common "
1831 "mail options so that you can start to use "
1832 "Claws Mail in less than five minutes."));
1833 widget = gtk_label_new(text);
1834 gtk_label_set_line_wrap(GTK_LABEL(widget), TRUE);
1835 gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1841 widget = create_page (wizard, _("About You"));
1842 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
1843 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
1844 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1845 gtk_box_pack_start(GTK_BOX(widget), scrolled_window, TRUE, TRUE, 0);
1847 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1849 PACK_WARNING(_("Bold fields must be completed"));
1851 wizard->pages = g_slist_append(wizard->pages, widget);
1853 /* recv+auth page: 2 */
1856 widget = create_page (wizard, _("Receiving mail"));
1857 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
1858 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
1859 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1860 gtk_box_pack_start(GTK_BOX(widget), scrolled_window, TRUE, TRUE, 0);
1862 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1864 PACK_WARNING(_("Bold fields must be completed"));
1866 wizard->pages = g_slist_append(wizard->pages, widget);
1871 widget = create_page (wizard, _("Sending mail"));
1872 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
1873 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
1874 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1875 gtk_box_pack_start(GTK_BOX(widget), scrolled_window, TRUE, TRUE, 0);
1877 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1879 PACK_WARNING(_("Bold fields must be completed"));
1881 wizard->pages = g_slist_append(wizard->pages, widget);
1883 /* mailbox page: 4 */
1884 if (create_mailbox) {
1887 widget = create_page (wizard, _("Saving mail on disk"));
1888 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
1889 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
1890 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1891 gtk_box_pack_start(GTK_BOX(widget), scrolled_window, TRUE, TRUE, 0);
1893 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1894 mailbox_page(wizard));
1895 PACK_WARNING(_("Bold fields must be completed"));
1897 wizard->pages = g_slist_append(wizard->pages, widget);
1903 page = create_page(wizard, _("Configuration finished"));
1905 wizard->pages = g_slist_append(wizard->pages, page);
1906 widget = stock_pixmap_widget(STOCK_PIXMAP_CLAWS_MAIL_LOGO);
1908 gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1910 text = g_strdup(_("Claws Mail is now ready.\n"
1911 "Click Save to start."));
1912 widget = gtk_label_new(text);
1913 gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1917 for (cur = wizard->pages; cur && cur->data; cur = cur->next) {
1918 gtk_notebook_append_page (GTK_NOTEBOOK(wizard->notebook),
1919 GTK_WIDGET(cur->data), NULL);
1922 g_signal_connect(G_OBJECT(wizard->window), "delete_event",
1923 G_CALLBACK(wizard_close_cb), wizard);
1924 gtk_widget_show_all (wizard->window);
1926 gtk_widget_hide(wizard->recv_imap_label);
1927 gtk_widget_hide(wizard->recv_imap_subdir);
1928 gtk_widget_hide(wizard->subsonly_checkbtn);
1929 #if defined USE_GNUTLS
1930 gtk_widget_hide(wizard->auto_configure_cancel_btn);
1932 wizard_protocol_change(wizard, tmpl.recvtype);
1934 while (!wizard->finished)
1935 gtk_main_iteration();
1937 result = wizard->result;
1941 gtk_widget_show(mainwin->window);