2 * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2007 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/>.
28 #include <glib/gi18n.h>
29 #include <gdk/gdkkeysyms.h>
30 #include <gtk/gtkwidget.h>
31 #include <gtk/gtkvbox.h>
32 #include <gtk/gtkbox.h>
33 #include <gtk/gtktable.h>
34 #include <gtk/gtkentry.h>
35 #include <gtk/gtklabel.h>
36 #include <gtk/gtknotebook.h>
37 #include <gtk/gtktogglebutton.h>
38 #include <gtk/gtkcheckbutton.h>
54 #include "prefs_account.h"
55 #include "mainwindow.h"
56 #include "stock_pixmap.h"
59 #include "alertpanel.h"
61 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
64 #include "prefs_common.h"
68 #include <libgnomevfs/gnome-vfs-volume.h>
69 #include <libgnomevfs/gnome-vfs-volume-monitor.h>
70 #include <libgnomevfs/gnome-vfs-utils.h>
81 int WELCOME_PAGE = -1;
85 int MAILBOX_PAGE = -1;
98 GtkWidget *organization;
100 GtkWidget *mailbox_name;
101 GtkWidget *mailbox_label;
103 GtkWidget *smtp_server;
104 GtkWidget *smtp_auth;
105 GtkWidget *smtp_username;
106 GtkWidget *smtp_password;
107 GtkWidget *smtp_username_label;
108 GtkWidget *smtp_password_label;
110 GtkWidget *recv_type;
111 GtkWidget *recv_label;
112 GtkWidget *recv_server;
113 GtkWidget *recv_username;
114 GtkWidget *recv_password;
115 GtkWidget *recv_username_label;
116 GtkWidget *recv_password_label;
117 GtkWidget *recv_imap_label;
118 GtkWidget *recv_imap_subdir;
119 GtkWidget *subsonly_checkbtn;
120 GtkWidget *no_imap_warning;
121 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
122 GtkWidget *smtp_use_ssl;
123 GtkWidget *recv_use_ssl;
124 GtkWidget *smtp_use_tls;
125 GtkWidget *recv_use_tls;
126 GtkWidget *smtp_ssl_cert_file;
127 GtkWidget *recv_ssl_cert_file;
128 GtkWidget *smtp_ssl_cert_pass;
129 GtkWidget *recv_ssl_cert_pass;
130 GtkWidget *smtp_cert_table;
131 GtkWidget *recv_cert_table;
135 GtkWidget *data_root_nokia_radiobtn;
136 GtkWidget *data_root_mmc1_radiobtn;
137 GtkWidget *data_root_mmc2_radiobtn;
138 GnomeVFSVolumeMonitor *volmon;
139 gulong volmon_mount_sigid;
140 gulong volmon_unmount_sigid;
141 GnomeVFSVolume *vol_mmc1;
142 GnomeVFSVolume *vol_mmc2;
144 gboolean create_mailbox;
150 typedef struct _AccountTemplate {
159 RecvProtocol recvtype;
171 gchar *smtpssl_cert_pass;
172 gchar *recvssl_cert_pass;
175 static AccountTemplate tmpl;
177 static PrefParam template_params[] = {
178 {"name", "$USERNAME",
179 &tmpl.name, P_STRING, NULL, NULL, NULL},
180 {"domain", "$DEFAULTDOMAIN",
181 &tmpl.domain, P_STRING, NULL, NULL, NULL},
182 {"email", "$NAME_MAIL@$DOMAIN",
183 &tmpl.email, P_STRING, NULL, NULL, NULL},
185 &tmpl.organization, P_STRING, NULL, NULL, NULL},
186 {"smtpserver", "smtp.$DOMAIN",
187 &tmpl.smtpserver, P_STRING, NULL, NULL, NULL},
188 {"smtpauth", "FALSE",
189 &tmpl.smtpauth, P_BOOL, NULL, NULL, NULL},
191 &tmpl.smtpuser, P_STRING, NULL, NULL, NULL},
193 &tmpl.smtppass, P_STRING, NULL, NULL, NULL},
195 &tmpl.recvtype, P_INT, NULL, NULL, NULL},
196 {"recvserver", "pop.$DOMAIN",
197 &tmpl.recvserver, P_STRING, NULL, NULL, NULL},
198 {"recvuser", "$LOGIN",
199 &tmpl.recvuser, P_STRING, NULL, NULL, NULL},
201 &tmpl.recvpass, P_STRING, NULL, NULL, NULL},
203 &tmpl.imapdir, P_STRING, NULL, NULL, NULL},
205 &tmpl.subsonly, P_BOOL, NULL, NULL, NULL},
206 {"mboxfile", "/var/mail/$LOGIN",
207 &tmpl.mboxfile, P_STRING, NULL, NULL, NULL},
209 &tmpl.mailbox, P_STRING, NULL, NULL, NULL},
211 &tmpl.smtpssl, P_INT, NULL, NULL, NULL},
213 &tmpl.recvssl, P_INT, NULL, NULL, NULL},
215 &tmpl.smtpssl_cert, P_STRING, NULL, NULL, NULL},
217 &tmpl.recvssl_cert, P_STRING, NULL, NULL, NULL},
218 {"smtpssl_cert_pass", "",
219 &tmpl.smtpssl_cert, P_STRING, NULL, NULL, NULL},
220 {"recvssl_cert_pass", "",
221 &tmpl.recvssl_cert, P_STRING, NULL, NULL, NULL},
222 {NULL, NULL, NULL, P_INT, NULL, NULL, NULL}
226 static gchar *accountrc_tmpl =
227 "[AccountTemplate]\n"
228 "#you can use $DEFAULTDOMAIN here\n"
229 "#domain must be defined before the variables that use it\n"
230 "#by default, domain is extracted from the hostname\n"
233 "#you can use $USERNAME for name (this is the default)\n"
236 "#you can use $LOGIN, $NAME_MAIL and $DOMAIN here \n"
237 "#$NAME_MAIL is the name without uppercase and with dots instead\n"
239 "#the default is $NAME_MAIL@$DOMAIN\n"
242 "#you can use $DOMAIN here\n"
243 "#the default organization is empty\n"
246 "#you can use $DOMAIN here \n"
247 "#the default is smtp.$DOMAIN\n"
250 "#Whether to use smtp authentication\n"
251 "#the default is 0 (no)\n"
255 "#you can use $LOGIN, $NAME_MAIL, $DOMAIN or $EMAIL here\n"
256 "#the default is empty (same as reception username)\n"
260 "#the default is empty (same as reception password)\n"
263 "#recvtype can be:\n"
266 "#5 for a local mbox file\n"
269 "#you can use $DOMAIN here \n"
270 "#the default is {pop,imap}.$DOMAIN\n"
273 "#you can use $LOGIN, $NAME_MAIL, $DOMAIN or $EMAIL here\n"
274 "#default is $LOGIN\n"
277 "#default is empty\n"
280 "#imap dir if imap (relative to the home on the server)\n"
281 "#default is empty\n"
284 "#show subscribed folders only, if imap\n"
288 "#mbox file if local\n"
289 "#you can use $LOGIN here\n"
290 "#default is /var/mail/$LOGIN\n"
293 "#mailbox name if pop3 or local\n"
294 "#relative path from the user's home\n"
295 "#default is \"Mail\"\n"
298 "#whether to use ssl on smtp connections\n"
299 "#default is 0, 1 is ssl, 2 is starttls\n"
302 "#whether to use ssl on pop or imap connections\n"
303 "#default is 0, 1 is ssl, 2 is starttls\n"
306 "#SSL client certificate path for SMTP\n"
307 "#default is empty (no certificate)\n"
310 "#SSL client certificate path for POP/IMAP\n"
311 "#default is empty (no certificate)\n"
314 "#SSL client certificate password for SMTP\n"
315 "#default is empty (no password)\n"
316 "#smtpssl_cert_pass=\n"
318 "#SSL client certificate password for POP/IMAP\n"
319 "#default is empty (no password)\n"
320 "#recvssl_cert_pass=\n"
323 static gchar *wizard_get_default_domain_name(void)
325 static gchar *domain_name = NULL;
327 if (domain_name == NULL) {
328 domain_name = g_strdup(get_domain_name());
329 if (strchr(domain_name, '.') != strrchr(domain_name, '.')
330 && strlen(strchr(domain_name, '.')) > 6) {
331 gchar *tmp = g_strdup(strchr(domain_name, '.')+1);
339 static gchar *get_name_for_mail(void)
342 if (tmpl.name == NULL)
344 name = g_utf8_strdown(tmpl.name, -1);
345 while(strstr(name, " "))
346 *strstr(name, " ")='.';
351 #define PARSE_DEFAULT(str) { \
352 gchar *tmp = NULL, *new = NULL; \
354 tmp = g_strdup(str); \
355 if (strstr(str, "$USERNAME")) { \
356 tmp = g_strdup(str); \
357 *strstr(tmp, "$USERNAME") = '\0'; \
358 new = g_strconcat(tmp, g_get_real_name(), \
359 strstr(str, "$USERNAME")+strlen("$USERNAME"), \
366 if (strstr(str, "$LOGIN")) { \
367 tmp = g_strdup(str); \
368 *strstr(tmp, "$LOGIN") = '\0'; \
369 new = g_strconcat(tmp, g_get_user_name(), \
370 strstr(str, "$LOGIN")+strlen("$LOGIN"), \
377 if (strstr(str, "$EMAIL")) { \
378 tmp = g_strdup(str); \
379 *strstr(tmp, "$EMAIL") = '\0'; \
380 new = g_strconcat(tmp, tmpl.email, \
381 strstr(str, "$EMAIL")+strlen("$EMAIL"), \
388 if (strstr(str, "$NAME_MAIL")) { \
389 tmp = g_strdup(str); \
390 *strstr(tmp, "$NAME_MAIL") = '\0'; \
391 new = g_strconcat(tmp, get_name_for_mail(), \
392 strstr(str, "$NAME_MAIL")+strlen("$NAME_MAIL"), \
399 if (strstr(str, "$DEFAULTDOMAIN")) { \
400 tmp = g_strdup(str); \
401 *strstr(tmp, "$DEFAULTDOMAIN") = '\0'; \
402 new = g_strconcat(tmp, wizard_get_default_domain_name(), \
403 strstr(str, "$DEFAULTDOMAIN")+strlen("$DEFAULTDOMAIN"), \
410 if (strstr(str, "$DOMAIN")) { \
411 tmp = g_strdup(str); \
412 *strstr(tmp, "$DOMAIN") = '\0'; \
413 new = g_strconcat(tmp, tmpl.domain, \
414 strstr(str, "$DOMAIN")+strlen("$DOMAIN"), \
423 static void wizard_read_defaults(void)
427 rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, "accountrc.tmpl", NULL);
428 if (!is_file_exist(rcpath)) {
429 str_write_to_file(accountrc_tmpl, rcpath);
432 prefs_read_config(template_params, "AccountTemplate", rcpath, NULL);
434 PARSE_DEFAULT(tmpl.domain);
435 PARSE_DEFAULT(tmpl.name);
436 PARSE_DEFAULT(tmpl.email);
437 PARSE_DEFAULT(tmpl.organization);
438 PARSE_DEFAULT(tmpl.smtpserver);
439 PARSE_DEFAULT(tmpl.smtpuser);
440 PARSE_DEFAULT(tmpl.smtppass);
441 PARSE_DEFAULT(tmpl.recvserver);
442 PARSE_DEFAULT(tmpl.recvuser);
443 PARSE_DEFAULT(tmpl.recvpass);
444 PARSE_DEFAULT(tmpl.imapdir);
445 PARSE_DEFAULT(tmpl.mboxfile);
446 PARSE_DEFAULT(tmpl.mailbox);
449 "%s, %s, %s, %s, %s, %d, %s, %s, %s, %s, %s, %s, %d, %d\n",
450 tmpl.name,tmpl.domain,tmpl.email,tmpl.organization,tmpl.smtpserver,
451 tmpl.recvtype,tmpl.recvserver,tmpl.recvuser,tmpl.recvpass,
452 tmpl.imapdir,tmpl.mboxfile,tmpl.mailbox,tmpl.smtpssl,tmpl.recvssl);
457 static void initialize_fonts(WizardWindow *wizard)
459 GtkWidget *widget = wizard->email;
460 gint size = pango_font_description_get_size(
461 widget->style->font_desc)
465 tmp = g_strdup(prefs_common.textfont);
466 if (strrchr(tmp, ' ')) {
467 *(strrchr(tmp, ' ')) = '\0';
468 new = g_strdup_printf("%s %d", tmp, size);
469 g_free(prefs_common.textfont);
470 prefs_common.textfont = new;
474 tmp = g_strdup(prefs_common.smallfont);
475 if (strrchr(tmp, ' ')) {
476 *(strrchr(tmp, ' ')) = '\0';
477 new = g_strdup_printf("%s %d", tmp, size);
478 g_free(prefs_common.smallfont);
479 prefs_common.smallfont = new;
483 tmp = g_strdup(prefs_common.normalfont);
484 if (strrchr(tmp, ' ')) {
485 *(strrchr(tmp, ' ')) = '\0';
486 new = g_strdup_printf("%s %d", tmp, size);
487 g_free(prefs_common.normalfont);
488 prefs_common.normalfont = new;
492 tmp = g_strdup(prefs_common.boldfont);
493 if (strrchr(tmp, ' ')) {
494 *(strrchr(tmp, ' ')) = '\0';
495 new = g_strdup_printf("%s %d", tmp, size);
496 g_free(prefs_common.boldfont);
497 prefs_common.boldfont = new;
502 #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"
503 #define FACE "iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAAM1BMVEUAAAAcJCI\n\
504 ONl1JUi0+Z4daY2NZciPabV9ykS5kj6Wsl2ybmZOBsMjZxK2wzN3Pzczs7OsCAGN0AAAAAXRSTlM\n\
505 AQObYZgAAAAFiS0dEAIgFHUgAAAIVSURBVEjH1ZbtlqMgDIaFECoGhPu/2s0b0Lais/NzN6d1OJ7\n\
506 3yReQzrL8B5Zy3rvl9At52Pf2tv1vSMjtYj8jaa8XUyI/yn3YD6sigj/2Tf5Bn069MIsTPHvx/t5\n\
507 /3rU/6JCIY3YwGe26r/cwUfE3cFe5T28L0K5rJAUHEeYAQxs8DHojjk3M9wECU4xxjXisI8RA0gy\n\
508 oczJZJOjxiTFZVTchAnIRJrgdmEGDyFfAI3UuG5FmYTkR9RDrIC4H0SqV4pzpEcUp0HNLjwBv+jA\n\
509 dikUE5g9iBvzmu3sH2oDk4lnHd829+2Q9gj6kDqDPg7hsGwBzH02fE3ZCt6ZHmlNKIMjMeRwra5I\n\
510 ecgNoBnLGPmzaHPJIwLY8Sq2M/tLUJfj0QcqmfVXAdLSStIYF8dzWjBBb2VgvDa4mO9oc651OiUo\n\
511 BEKbZokdPATF9E9oKAjQJcJOniaPXrVZRAnVWaqIyqRoNC8ZJvgCcW8XN39RqxVP1rS8Yd4WnCdN\n\
512 aRTo2jJRDbg3vtCpEUGffgDPhqKDaSuVqYtOplFIvIcx3HUI5/MuIWl6vKyBjNlqEru8hbFXqBPA\n\
513 5TpHGIUZOePeaIyzfQ/g9Xg0opU1AvdfXM9floYhv92pPAE96OZtkPV8eivgQi9RTfwPUU36I26n\n\
514 Hy+WuCJzAT7efMSeA1TNf2/VugDz+dN139xfA5ffxGZDD+MvcP/uvyB80wzZ76wbz8gAAAABJRU5\n\
517 static void write_welcome_email(WizardWindow *wizard)
523 const gchar *mailbox = gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name));
524 Folder *folder = folder_find_from_path(mailbox);
525 FolderItem *inbox = folder ? folder->inbox:NULL;
526 gchar *file = get_tmp_file();
527 gchar enc_from_name[BUFFSIZE], enc_to_name[BUFFSIZE], enc_subject[BUFFSIZE];
529 get_rfc822_date(buf_date, sizeof(buf_date));
531 conv_encode_header_full(enc_subject, sizeof(enc_subject),
532 Q_("Welcome Mail Subject|Welcome to Claws Mail"),
533 strlen("Subject: "), FALSE, CS_INTERNAL);
534 conv_encode_header_full(enc_to_name, sizeof(enc_to_name),
535 gtk_entry_get_text(GTK_ENTRY(wizard->full_name)),
536 strlen("To: "), TRUE, CS_INTERNAL);
537 conv_encode_header_full(enc_from_name, sizeof(enc_from_name),
538 _("The Claws Mail Team"),
539 strlen("From: "), TRUE, CS_INTERNAL);
541 head = g_strdup_printf(
548 "Content-Type: text/plain; charset=UTF-8\n",
552 gtk_entry_get_text(GTK_ENTRY(wizard->email)),
553 buf_date, enc_subject, XFACE, FACE);
554 body = g_strdup_printf(
556 "Welcome to Claws Mail\n"
557 "---------------------\n"
559 "Now that you have set up your account you can fetch your\n"
560 "mail by clicking the 'Get Mail' button at the left of the\n"
563 "Claws Mail has lots of extra features accessible via plugins,\n"
564 "like anti-spam filtering and learning (via the Bogofilter or\n"
565 "SpamAssassin plugins), privacy protection (via PGP/Mime), an RSS\n"
566 "aggregator, a calendar, and much more. You can load them from\n"
567 "the menu entry '/Configuration/Plugins'.\n"
569 "You can change your Account Preferences by using the menu\n"
570 "entry '/Configuration/Preferences for current account'\n"
571 "and change the general Preferences by using\n"
572 "'/Configuration/Preferences'.\n"
574 "You can find further information in the Claws Mail manual,\n"
575 "which can be accessed by using the menu entry '/Help/Manual'\n"
576 "or online at the URL given below.\n"
584 "Mailing Lists: <%s>\n"
588 "Claws Mail is free software, released under the terms\n"
589 "of the GNU General Public License, version 3 or later, as\n"
590 "published by the Free Software Foundation, 51 Franklin Street,\n"
591 "Fifth Floor, Boston, MA 02110-1301, USA. The license can be\n"
596 "If you wish to donate to the Claws Mail project you can do\n"
598 HOMEPAGE_URI, MANUAL_URI, FAQ_URI, THEMES_URI, MAILING_LIST_URI,
599 GPL_URI, DONATE_URI);
601 msg = g_strconcat(head, body, NULL);
603 if (inbox && inbox->total_msgs == 0
604 && str_write_to_file(msg, file) >= 0) {
605 MsgFlags flags = { MSG_UNREAD|MSG_NEW, 0};
606 folder_item_add_msg(inbox, file, &flags, FALSE);
615 static gboolean wizard_write_config(WizardWindow *wizard)
617 static gboolean mailbox_ok = FALSE;
618 PrefsAccount *prefs_account = prefs_account_new();
619 GList *account_list = NULL;
620 gchar *smtp_server, *recv_server;
621 gint smtp_port, recv_port;
622 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
623 SSLType smtp_ssl_type, recv_ssl_type;
626 prefs_account->protocol = combobox_get_active_data(
627 GTK_COMBO_BOX(wizard->recv_type));
629 if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4 &&
630 !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name)))) {
631 alertpanel_error(_("Please enter the mailbox name."));
632 g_free(prefs_account);
633 gtk_notebook_set_current_page (
634 GTK_NOTEBOOK(wizard->notebook),
640 if (wizard->create_mailbox) {
641 g_free(prefs_common.data_root);
642 if (gtk_toggle_button_get_active(
643 GTK_TOGGLE_BUTTON(wizard->data_root_nokia_radiobtn)))
644 prefs_common.data_root = NULL;
645 else if (gtk_toggle_button_get_active(
646 GTK_TOGGLE_BUTTON(wizard->data_root_mmc1_radiobtn)))
647 prefs_common.data_root = g_strdup(MMC1_PATH);
648 else if (gtk_toggle_button_get_active(
649 GTK_TOGGLE_BUTTON(wizard->data_root_mmc2_radiobtn)))
650 prefs_common.data_root = g_strdup(MMC2_PATH);
655 if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4) {
656 mailbox_ok = setup_write_mailbox_path(wizard->mainwin,
658 GTK_ENTRY(wizard->mailbox_name)));
664 /* alertpanel done by setup_write_mailbox_path */
665 g_free(prefs_account);
666 gtk_notebook_set_current_page (
667 GTK_NOTEBOOK(wizard->notebook),
672 if (!strlen(gtk_entry_get_text(GTK_ENTRY(wizard->full_name)))
673 || !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->email)))) {
674 alertpanel_error(_("Please enter your name and email address."));
675 g_free(prefs_account);
676 gtk_notebook_set_current_page (
677 GTK_NOTEBOOK(wizard->notebook),
682 if (prefs_account->protocol != A_LOCAL) {
683 if (!strlen(gtk_entry_get_text(GTK_ENTRY(wizard->recv_username)))
684 || !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)))) {
685 alertpanel_error(_("Please enter your receiving server "
687 g_free(prefs_account);
688 gtk_notebook_set_current_page (
689 GTK_NOTEBOOK(wizard->notebook),
694 if (!strlen(gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)))) {
695 alertpanel_error(_("Please enter your username."));
696 g_free(prefs_account);
697 gtk_notebook_set_current_page (
698 GTK_NOTEBOOK(wizard->notebook),
704 if (!strlen(gtk_entry_get_text(GTK_ENTRY(wizard->smtp_server)))) {
705 alertpanel_error(_("Please enter your SMTP server."));
706 g_free(prefs_account);
707 gtk_notebook_set_current_page (
708 GTK_NOTEBOOK(wizard->notebook),
713 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_auth))) {
714 if (prefs_account->protocol == A_LOCAL
715 && !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->smtp_username)))) {
716 alertpanel_error(_("Please enter your SMTP username."));
717 g_free(prefs_account);
718 gtk_notebook_set_current_page (
719 GTK_NOTEBOOK(wizard->notebook),
722 } /* if it's not local we'll use the reception server */
725 if (prefs_account->protocol != A_LOCAL)
726 prefs_account->account_name = g_strdup_printf("%s@%s",
727 gtk_entry_get_text(GTK_ENTRY(wizard->recv_username)),
728 gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
730 prefs_account->account_name = g_strdup_printf("%s",
731 gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
733 recv_server = g_strdup(gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
734 smtp_server = g_strdup(gtk_entry_get_text(GTK_ENTRY(wizard->smtp_server)));
736 if (prefs_account->protocol != A_LOCAL && strstr(recv_server, ":")) {
737 recv_port = atoi(strstr(recv_server, ":")+1);
738 *(strstr(recv_server, ":")) = '\0';
739 if (prefs_account->protocol == A_IMAP4) {
740 prefs_account->set_imapport = TRUE;
741 prefs_account->imapport = recv_port;
742 } else if (prefs_account->protocol == A_POP3) {
743 prefs_account->set_popport = TRUE;
744 prefs_account->popport = recv_port;
747 if (strstr(smtp_server, ":")) {
748 smtp_port = atoi(strstr(smtp_server, ":")+1);
749 *(strstr(smtp_server, ":")) = '\0';
750 prefs_account->set_smtpport = TRUE;
751 prefs_account->smtpport = smtp_port;
754 prefs_account->name = g_strdup(
755 gtk_entry_get_text(GTK_ENTRY(wizard->full_name)));
756 prefs_account->address = g_strdup(
757 gtk_entry_get_text(GTK_ENTRY(wizard->email)));
758 prefs_account->organization = g_strdup(
759 gtk_entry_get_text(GTK_ENTRY(wizard->organization)));
760 prefs_account->smtp_server = g_strdup(smtp_server);
762 if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4) {
764 tmp = g_path_get_basename(gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name)));
765 prefs_account->inbox = g_strdup_printf("#mh/%s/inbox",
766 (!strcmp("Mail", gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name))))
769 prefs_account->local_inbox = g_strdup(prefs_account->inbox);
770 } else if (prefs_account->protocol != A_IMAP4) {
771 if (folder_get_default_inbox())
772 prefs_account->local_inbox =
773 folder_item_get_identifier(folder_get_default_inbox());
776 if (prefs_account->protocol != A_LOCAL)
777 prefs_account->recv_server = g_strdup(recv_server);
779 prefs_account->local_mbox = g_strdup(recv_server);
784 prefs_account->userid = g_strdup(
785 gtk_entry_get_text(GTK_ENTRY(wizard->recv_username)));
786 prefs_account->passwd = g_strdup(
787 gtk_entry_get_text(GTK_ENTRY(wizard->recv_password)));
789 prefs_account->smtp_userid = g_strdup(
790 gtk_entry_get_text(GTK_ENTRY(wizard->smtp_username)));
791 prefs_account->smtp_passwd = g_strdup(
792 gtk_entry_get_text(GTK_ENTRY(wizard->smtp_password)));
793 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_auth))) {
794 prefs_account->use_smtp_auth = TRUE;
797 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
798 smtp_ssl_type = SSL_NONE;
799 recv_ssl_type = SSL_NONE;
801 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_ssl))) {
802 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_tls)))
803 smtp_ssl_type = SSL_STARTTLS;
805 smtp_ssl_type = SSL_TUNNEL;
807 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->recv_use_ssl))) {
808 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->recv_use_tls)))
809 recv_ssl_type = SSL_STARTTLS;
811 recv_ssl_type = SSL_TUNNEL;
814 prefs_account->ssl_smtp = smtp_ssl_type;
816 if (prefs_account->protocol == A_IMAP4)
817 prefs_account->ssl_imap = recv_ssl_type;
819 prefs_account->ssl_pop = recv_ssl_type;
821 prefs_account->out_ssl_client_cert_file = g_strdup(
822 gtk_entry_get_text(GTK_ENTRY(wizard->smtp_ssl_cert_file)));
823 prefs_account->out_ssl_client_cert_pass = g_strdup(
824 gtk_entry_get_text(GTK_ENTRY(wizard->smtp_ssl_cert_pass)));
825 prefs_account->in_ssl_client_cert_file = g_strdup(
826 gtk_entry_get_text(GTK_ENTRY(wizard->recv_ssl_cert_file)));
827 prefs_account->in_ssl_client_cert_pass = g_strdup(
828 gtk_entry_get_text(GTK_ENTRY(wizard->recv_ssl_cert_pass)));
830 if (prefs_account->protocol == A_IMAP4) {
831 gchar *directory = gtk_editable_get_chars(
832 GTK_EDITABLE(wizard->recv_imap_subdir), 0, -1);
833 if (directory && strlen(directory)) {
834 prefs_account->imap_dir = g_strdup(directory);
836 prefs_account->imap_subsonly =
837 gtk_toggle_button_get_active(
838 GTK_TOGGLE_BUTTON(wizard->subsonly_checkbtn));
842 account_list = g_list_append(account_list, prefs_account);
843 prefs_account_write_config_all(account_list);
844 prefs_account_free(prefs_account);
845 account_read_config_all();
847 initialize_fonts(wizard);
848 if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4)
849 write_welcome_email(wizard);
852 if (wizard->volmon_mount_sigid)
853 g_signal_handler_disconnect(
854 G_OBJECT(wizard->volmon),
855 wizard->volmon_mount_sigid);
856 if (wizard->volmon_unmount_sigid)
857 g_signal_handler_disconnect(
858 G_OBJECT(wizard->volmon),
859 wizard->volmon_unmount_sigid);
863 plugin_load_standard_plugins();
868 static GtkWidget* create_page (WizardWindow *wizard, const char * title)
876 vbox = gtk_vbox_new (FALSE, 6);
877 gtk_container_set_border_width (GTK_CONTAINER(vbox), 10);
879 /* create the titlebar */
880 hbox = gtk_hbox_new (FALSE, 12);
881 image = stock_pixmap_widget(wizard->window,
882 STOCK_PIXMAP_CLAWS_MAIL_ICON);
883 gtk_box_pack_start (GTK_BOX(hbox), image, FALSE, FALSE, 0);
884 title_string = g_strconcat ("<span size=\"xx-large\" weight=\"ultrabold\">", title ? title : "", "</span>", NULL);
885 w = gtk_label_new (title_string);
886 gtk_label_set_use_markup (GTK_LABEL(w), TRUE);
887 g_free (title_string);
888 gtk_box_pack_start (GTK_BOX(hbox), w, FALSE, FALSE, 0);
890 /* pack the titlebar */
891 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
893 /* pack the separator */
894 gtk_box_pack_start (GTK_BOX(vbox), gtk_hseparator_new(), FALSE, FALSE, 0);
897 w = gtk_alignment_new (0, 0, 0, 0);
898 gtk_widget_set_size_request (w, 0, 6);
899 gtk_box_pack_start (GTK_BOX(vbox), w, FALSE, FALSE, 0);
904 #define PACK_BOX(hbox,text,entry) { \
905 GtkWidget *label = gtk_label_new(text); \
906 gtk_label_set_use_markup(GTK_LABEL(label), TRUE); \
907 if (GTK_IS_MISC(label)) \
908 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); \
909 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); \
910 gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0); \
913 static gchar *get_default_server(WizardWindow * wizard, const gchar *type)
915 if (!strcmp(type, "smtp")) {
916 if (!tmpl.smtpserver || !strlen(tmpl.smtpserver))
917 return g_strconcat(type, ".", tmpl.domain, NULL);
919 return g_strdup(tmpl.smtpserver);
921 if (!tmpl.recvserver || !strlen(tmpl.recvserver))
922 return g_strconcat(type, ".", tmpl.domain, NULL);
924 return g_strdup(tmpl.recvserver);
928 static gchar *get_default_account(WizardWindow * wizard)
930 gchar *result = NULL;
932 if (!tmpl.recvuser || !strlen(tmpl.recvuser)) {
933 result = gtk_editable_get_chars(
934 GTK_EDITABLE(wizard->email), 0, -1);
936 if (strstr(result, "@")) {
937 *(strstr(result,"@")) = '\0';
940 result = g_strdup(tmpl.recvuser);
945 static gchar *get_default_smtp_account(WizardWindow * wizard)
947 gchar *result = NULL;
949 if (!tmpl.smtpuser || !strlen(tmpl.smtpuser)) {
952 result = g_strdup(tmpl.smtpuser);
957 static void wizard_email_changed(GtkWidget *widget, gpointer data)
959 WizardWindow *wizard = (WizardWindow *)data;
960 RecvProtocol protocol;
962 protocol = combobox_get_active_data(GTK_COMBO_BOX(wizard->recv_type));
964 text = get_default_server(wizard, "smtp");
965 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_server), text);
968 text = get_default_account(wizard);
969 gtk_entry_set_text(GTK_ENTRY(wizard->recv_username), text);
972 if (protocol == A_POP3) {
973 text = get_default_server(wizard, "pop");
974 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
976 } else if (protocol == A_IMAP4) {
977 text = get_default_server(wizard, "imap");
978 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
980 } else if (protocol == A_LOCAL) {
981 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), tmpl.mboxfile?tmpl.mboxfile:"");
986 static GtkWidget* user_page (WizardWindow * wizard)
988 GtkWidget *table = gtk_table_new(1,1, FALSE);
992 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
993 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
995 vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
996 gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
998 gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2,
999 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1001 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1002 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1003 wizard->full_name = gtk_entry_new();
1004 gtk_entry_set_text(GTK_ENTRY(wizard->full_name), tmpl.name?tmpl.name:"");
1005 PACK_BOX(hbox, _("<span weight=\"bold\">Your name:</span>"),
1008 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1009 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1010 wizard->email = gtk_entry_new();
1011 gtk_entry_set_text(GTK_ENTRY(wizard->email), tmpl.email?tmpl.email:"");
1012 PACK_BOX(hbox, _("<span weight=\"bold\">Your email address:</span>"),
1015 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1016 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1017 wizard->organization = gtk_entry_new();
1018 gtk_entry_set_text(GTK_ENTRY(wizard->organization), tmpl.organization?tmpl.organization:"");
1019 PACK_BOX(hbox, _("Your organization:"), wizard->organization);
1021 g_signal_connect(G_OBJECT(wizard->email), "changed",
1022 G_CALLBACK(wizard_email_changed),
1028 static void wizard_vol_mount_cb(GnomeVFSVolumeMonitor *vfs, GnomeVFSVolume *vol, WizardWindow *wizard)
1030 gchar *uri = gnome_vfs_volume_get_activation_uri (vol);
1031 gchar *mount_path = uri?gnome_vfs_get_local_path_from_uri (uri):NULL;
1034 if(!strcmp(mount_path, MMC1_PATH)) {
1035 gtk_widget_set_sensitive(wizard->data_root_mmc1_radiobtn, TRUE);
1037 if(!strcmp(mount_path, MMC2_PATH)) {
1038 gtk_widget_set_sensitive(wizard->data_root_mmc2_radiobtn, TRUE);
1043 static void wizard_vol_unmount_cb(GnomeVFSVolumeMonitor *vfs, GnomeVFSVolume *vol, WizardWindow *wizard)
1045 gchar *uri = gnome_vfs_volume_get_activation_uri (vol);
1046 gchar *mount_path = uri?gnome_vfs_get_local_path_from_uri (uri):NULL;
1049 if(!strcmp(mount_path, MMC1_PATH)) {
1050 gtk_widget_set_sensitive(wizard->data_root_mmc1_radiobtn, FALSE);
1051 if (gtk_toggle_button_get_active(
1052 GTK_TOGGLE_BUTTON(wizard->data_root_mmc1_radiobtn))) {
1053 gtk_toggle_button_set_active(
1054 GTK_TOGGLE_BUTTON(wizard->data_root_nokia_radiobtn), TRUE);
1057 if(!strcmp(mount_path, MMC2_PATH)) {
1058 gtk_widget_set_sensitive(wizard->data_root_mmc2_radiobtn, FALSE);
1059 if (gtk_toggle_button_get_active(
1060 GTK_TOGGLE_BUTTON(wizard->data_root_mmc2_radiobtn))) {
1061 gtk_toggle_button_set_active(
1062 GTK_TOGGLE_BUTTON(wizard->data_root_nokia_radiobtn), TRUE);
1069 void data_root_changed (GtkToggleButton *toggle_btn,
1070 WizardWindow *wizard)
1072 gchar *name = g_path_get_basename(gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name)));
1074 if (gtk_toggle_button_get_active(
1075 GTK_TOGGLE_BUTTON(wizard->data_root_nokia_radiobtn)))
1076 gtk_entry_set_text(GTK_ENTRY(wizard->mailbox_name), name);
1077 else if (gtk_toggle_button_get_active(
1078 GTK_TOGGLE_BUTTON(wizard->data_root_mmc1_radiobtn))) {
1079 path = g_strconcat(MMC1_PATH, G_DIR_SEPARATOR_S,
1080 "Claws", G_DIR_SEPARATOR_S,
1081 g_get_user_name(), G_DIR_SEPARATOR_S,
1083 gtk_entry_set_text(GTK_ENTRY(wizard->mailbox_name), path);
1085 } else if (gtk_toggle_button_get_active(
1086 GTK_TOGGLE_BUTTON(wizard->data_root_mmc2_radiobtn))) {
1087 path = g_strconcat(MMC2_PATH, G_DIR_SEPARATOR_S,
1088 "Claws", G_DIR_SEPARATOR_S,
1089 g_get_user_name(), G_DIR_SEPARATOR_S,
1091 gtk_entry_set_text(GTK_ENTRY(wizard->mailbox_name), path);
1098 static GtkWidget* mailbox_page (WizardWindow * wizard)
1100 GtkWidget *table = gtk_table_new(1,1, FALSE);
1104 gchar *uri, *mount_path;
1109 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
1110 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
1112 vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
1113 gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
1115 gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2,
1116 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1118 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1119 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1121 wizard->mailbox_label = gtk_label_new(_("<span weight=\"bold\">Mailbox name:</span>"));
1122 gtk_label_set_use_markup(GTK_LABEL(wizard->mailbox_label), TRUE);
1123 if (GTK_IS_MISC(wizard->mailbox_label))
1124 gtk_misc_set_alignment(GTK_MISC(wizard->mailbox_label), 1, 0.5);
1125 wizard->mailbox_name = gtk_entry_new();
1127 gtk_entry_set_text(GTK_ENTRY(wizard->mailbox_name), tmpl.mailbox?tmpl.mailbox:"");
1129 CLAWS_SET_TIP(wizard->mailbox_name, _("You can also specify an absolute path, for example: "
1130 "\"/home/john/Documents/Mail\""));
1132 gtk_box_pack_start(GTK_BOX(hbox), wizard->mailbox_label, FALSE, FALSE, 0);
1133 gtk_box_pack_start(GTK_BOX(hbox), wizard->mailbox_name, TRUE, TRUE, 0);
1136 wizard->data_root_nokia_radiobtn = gtk_radio_button_new_with_label(NULL,
1137 _("on internal memory"));
1138 wizard->data_root_mmc1_radiobtn = gtk_radio_button_new_with_label_from_widget(
1139 GTK_RADIO_BUTTON(wizard->data_root_nokia_radiobtn),
1140 _("on external memory card"));
1141 wizard->data_root_mmc2_radiobtn = gtk_radio_button_new_with_label_from_widget(
1142 GTK_RADIO_BUTTON(wizard->data_root_nokia_radiobtn),
1143 _("on internal memory card"));
1145 g_signal_connect(G_OBJECT(wizard->data_root_nokia_radiobtn), "toggled",
1146 G_CALLBACK(data_root_changed), wizard);
1147 g_signal_connect(G_OBJECT(wizard->data_root_mmc1_radiobtn), "toggled",
1148 G_CALLBACK(data_root_changed), wizard);
1149 g_signal_connect(G_OBJECT(wizard->data_root_mmc2_radiobtn), "toggled",
1150 G_CALLBACK(data_root_changed), wizard);
1152 wizard->volmon = gnome_vfs_get_volume_monitor();
1153 wizard->vol_mmc1 = gnome_vfs_volume_monitor_get_volume_for_path(wizard->volmon, MMC1_PATH);
1154 wizard->vol_mmc2 = gnome_vfs_volume_monitor_get_volume_for_path(wizard->volmon, MMC2_PATH);
1156 uri = gnome_vfs_volume_get_activation_uri (wizard->vol_mmc1);
1157 mount_path = uri?gnome_vfs_get_local_path_from_uri (uri):NULL;
1159 if (wizard->vol_mmc1 == NULL || !gnome_vfs_volume_is_mounted(wizard->vol_mmc1)
1160 || strcmp(mount_path, MMC1_PATH)) {
1161 gtk_widget_set_sensitive(wizard->data_root_mmc1_radiobtn, FALSE);
1165 uri = gnome_vfs_volume_get_activation_uri (wizard->vol_mmc2);
1166 mount_path = uri?gnome_vfs_get_local_path_from_uri (uri):NULL;
1168 if (wizard->vol_mmc2 == NULL || !gnome_vfs_volume_is_mounted(wizard->vol_mmc2)
1169 || strcmp(mount_path, MMC2_PATH)) {
1170 gtk_widget_set_sensitive(wizard->data_root_mmc2_radiobtn, FALSE);
1172 gtk_toggle_button_set_active(wizard->data_root_mmc2_radiobtn, TRUE);
1176 gnome_vfs_volume_unref(wizard->vol_mmc1);
1177 gnome_vfs_volume_unref(wizard->vol_mmc2);
1178 wizard->vol_mmc1 = NULL;
1179 wizard->vol_mmc2 = NULL;
1181 wizard->volmon_mount_sigid = g_signal_connect(G_OBJECT(wizard->volmon),
1182 "volume-mounted", G_CALLBACK(wizard_vol_mount_cb), wizard);
1183 wizard->volmon_unmount_sigid = g_signal_connect(G_OBJECT(wizard->volmon),
1184 "volume-unmounted", G_CALLBACK(wizard_vol_unmount_cb), wizard);
1186 vbox2 = gtk_vbox_new(FALSE, VSPACING_NARROW);
1187 gtk_box_pack_start (GTK_BOX(vbox2), wizard->data_root_nokia_radiobtn, FALSE, FALSE, 0);
1188 gtk_box_pack_start (GTK_BOX(vbox2), wizard->data_root_mmc1_radiobtn, FALSE, FALSE, 0);
1189 gtk_box_pack_start (GTK_BOX(vbox2), wizard->data_root_mmc2_radiobtn, FALSE, FALSE, 0);
1191 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1192 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1193 PACK_BOX(hbox, _("<span weight=\"bold\">Store data</span>"),
1200 static void smtp_auth_changed (GtkWidget *btn, gpointer data)
1202 WizardWindow *wizard = (WizardWindow *)data;
1203 gboolean do_auth = gtk_toggle_button_get_active(
1204 GTK_TOGGLE_BUTTON(wizard->smtp_auth));
1205 gtk_widget_set_sensitive(wizard->smtp_username, do_auth);
1206 gtk_widget_set_sensitive(wizard->smtp_username_label, do_auth);
1207 gtk_widget_set_sensitive(wizard->smtp_password, do_auth);
1208 gtk_widget_set_sensitive(wizard->smtp_password_label, do_auth);
1211 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
1212 static void cert_browse_cb(GtkWidget *widget, gpointer data)
1214 GtkEntry *dest = GTK_ENTRY(data);
1216 gchar *utf8_filename;
1218 filename = filesel_select_file_open(_("Select certificate file"), NULL);
1219 if (!filename) return;
1221 utf8_filename = g_filename_to_utf8(filename, -1, NULL, NULL, NULL);
1222 if (!utf8_filename) {
1223 g_warning("cert_browse_cb(): failed to convert character set.");
1224 utf8_filename = g_strdup(filename);
1226 gtk_entry_set_text(dest, utf8_filename);
1227 g_free(utf8_filename);
1231 static GtkWidget* smtp_page (WizardWindow * wizard)
1233 GtkWidget *table = gtk_table_new(1, 1, FALSE);
1236 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
1239 GtkWidget *smtp_cert_table;
1244 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
1245 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
1247 vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
1248 gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
1250 gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2,
1251 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1253 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1254 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1255 wizard->smtp_server = gtk_entry_new();
1256 text = get_default_server(wizard, "smtp");
1257 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_server), text);
1260 CLAWS_SET_TIP(wizard->smtp_server,
1261 _("You can specify the port number by appending it at the end: "
1262 "\"mail.example.com:25\""));
1264 PACK_BOX(hbox, _("<span weight=\"bold\">SMTP server address:</span>"),
1265 wizard->smtp_server);
1268 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1269 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1270 wizard->smtp_auth = gtk_check_button_new_with_label(
1271 _("Use authentication"));
1272 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->smtp_auth),
1274 g_signal_connect(G_OBJECT(wizard->smtp_auth), "toggled",
1275 G_CALLBACK(smtp_auth_changed),
1277 gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_auth, FALSE, FALSE, 0);
1279 text = get_default_smtp_account(wizard);
1281 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1282 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1283 wizard->smtp_username = gtk_entry_new();
1284 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_username), text);
1286 wizard->smtp_username_label = gtk_label_new(_("SMTP username:\n"
1287 "<span size=\"small\">(empty to use the same as receive)</span>"));
1288 gtk_label_set_use_markup(GTK_LABEL(wizard->smtp_username_label), TRUE);
1289 if (GTK_IS_MISC(wizard->smtp_username_label))
1290 gtk_misc_set_alignment(GTK_MISC(wizard->smtp_username_label), 1, 0.5);
1291 gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_username_label, FALSE, FALSE, 0);
1292 gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_username, TRUE, TRUE, 0);
1294 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1295 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1296 wizard->smtp_password = gtk_entry_new();
1297 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_password), tmpl.smtppass?tmpl.smtppass:"");
1298 gtk_entry_set_visibility(GTK_ENTRY(wizard->smtp_password), FALSE);
1300 hildon_gtk_entry_set_input_mode(GTK_ENTRY(wizard->smtp_password),
1301 HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
1303 wizard->smtp_password_label = gtk_label_new(_("SMTP password:\n"
1304 "<span size=\"small\">(empty to use the same as receive)</span>"));
1305 gtk_label_set_use_markup(GTK_LABEL(wizard->smtp_password_label), TRUE);
1306 if (GTK_IS_MISC(wizard->smtp_password_label))
1307 gtk_misc_set_alignment(GTK_MISC(wizard->smtp_password_label), 1, 0.5);
1308 gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_password_label, FALSE, FALSE, 0);
1309 gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_password, TRUE, TRUE, 0);
1310 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
1311 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1312 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1313 wizard->smtp_use_ssl = gtk_check_button_new_with_label(
1314 _("Use SSL to connect to SMTP server"));
1315 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_ssl),
1317 gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_use_ssl, FALSE, FALSE, 0);
1319 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1320 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1321 wizard->smtp_use_tls = gtk_check_button_new_with_label(
1322 _("Use SSL via STARTTLS"));
1323 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_tls),
1325 gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_use_tls, FALSE, FALSE, 0);
1326 SET_TOGGLE_SENSITIVITY (wizard->smtp_use_ssl, wizard->smtp_use_tls);
1328 smtp_cert_table = gtk_table_new(3,3, FALSE);
1329 gtk_container_set_border_width(GTK_CONTAINER(smtp_cert_table), 8);
1330 gtk_box_pack_start (GTK_BOX(vbox), smtp_cert_table, FALSE, FALSE, 0);
1331 label = gtk_label_new(_("Client SSL certificate (optional)"));
1332 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
1333 gtk_table_attach(GTK_TABLE(smtp_cert_table), label, 0, 3, 0, 1, GTK_FILL, 0, 0, 0);
1334 label = gtk_label_new(_("File"));
1335 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
1336 gtk_table_attach(GTK_TABLE(smtp_cert_table), label, 0, 1, 1, 2, GTK_FILL, 0, 0, 0);
1337 wizard->smtp_ssl_cert_file = gtk_entry_new();
1338 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_ssl_cert_file), tmpl.smtpssl_cert?tmpl.smtpssl_cert:"");
1339 gtk_table_attach(GTK_TABLE(smtp_cert_table), wizard->smtp_ssl_cert_file, 1, 2, 1, 2, GTK_FILL, 0, 0, 0);
1340 button = gtkut_get_browse_file_btn(_("Browse"));
1341 gtk_table_attach(GTK_TABLE(smtp_cert_table), button, 2, 3, 1, 2, GTK_FILL, 0, 0, 0);
1342 SET_TOGGLE_SENSITIVITY (wizard->smtp_use_ssl, label);
1343 SET_TOGGLE_SENSITIVITY (wizard->smtp_use_ssl, wizard->smtp_ssl_cert_file);
1344 SET_TOGGLE_SENSITIVITY (wizard->smtp_use_ssl, button);
1345 g_signal_connect(G_OBJECT(button), "clicked",
1346 G_CALLBACK(cert_browse_cb), wizard->smtp_ssl_cert_file);
1348 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1349 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1350 label = gtk_label_new(_("Password"));
1351 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
1352 gtk_table_attach(GTK_TABLE(smtp_cert_table), label, 0, 1, 2, 3, GTK_FILL, 0, 0, 0);
1353 wizard->smtp_ssl_cert_pass = gtk_entry_new();
1354 gtk_entry_set_visibility(GTK_ENTRY(wizard->smtp_ssl_cert_pass), FALSE);
1355 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_ssl_cert_pass), tmpl.smtpssl_cert_pass?tmpl.smtpssl_cert_pass:"");
1356 gtk_table_attach(GTK_TABLE(smtp_cert_table), wizard->smtp_ssl_cert_pass, 1, 2, 2, 3, GTK_FILL, 0, 0, 0);
1357 SET_TOGGLE_SENSITIVITY (wizard->smtp_use_ssl, label);
1358 SET_TOGGLE_SENSITIVITY (wizard->smtp_use_ssl, wizard->smtp_ssl_cert_pass);
1359 wizard->smtp_cert_table = smtp_cert_table;
1361 smtp_auth_changed(NULL, wizard);
1365 static void wizard_protocol_change(WizardWindow *wizard, RecvProtocol protocol)
1369 if (protocol == A_POP3) {
1370 text = get_default_server(wizard, "pop");
1371 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
1372 gtk_widget_hide(wizard->recv_imap_label);
1373 gtk_widget_hide(wizard->recv_imap_subdir);
1374 gtk_widget_hide(wizard->subsonly_checkbtn);
1375 gtk_widget_show(wizard->recv_username);
1376 gtk_widget_show(wizard->recv_password);
1377 gtk_widget_show(wizard->recv_username_label);
1378 gtk_widget_show(wizard->recv_password_label);
1379 gtk_widget_hide(wizard->no_imap_warning);
1380 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
1381 gtk_widget_show(wizard->recv_use_ssl);
1382 gtk_widget_show(wizard->recv_use_tls);
1383 gtk_widget_show(wizard->recv_cert_table);
1385 gtk_label_set_text(GTK_LABEL(wizard->recv_label), _("<span weight=\"bold\">Server address:</span>"));
1386 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
1387 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, TRUE);
1389 if (wizard->create_mailbox) {
1390 gtk_widget_show(wizard->mailbox_label);
1391 gtk_widget_show(wizard->mailbox_name);
1393 } else if (protocol == A_IMAP4) {
1394 #ifdef HAVE_LIBETPAN
1395 text = get_default_server(wizard, "imap");
1396 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
1397 gtk_widget_show(wizard->recv_imap_label);
1398 gtk_widget_show(wizard->recv_imap_subdir);
1399 gtk_widget_show(wizard->subsonly_checkbtn);
1400 gtk_widget_show(wizard->recv_username);
1401 gtk_widget_show(wizard->recv_password);
1402 gtk_widget_show(wizard->recv_username_label);
1403 gtk_widget_show(wizard->recv_password_label);
1404 gtk_widget_hide(wizard->no_imap_warning);
1405 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
1406 gtk_widget_show(wizard->recv_use_ssl);
1407 gtk_widget_show(wizard->recv_use_tls);
1408 gtk_widget_show(wizard->recv_cert_table);
1410 gtk_label_set_text(GTK_LABEL(wizard->recv_label), _("<span weight=\"bold\">Server address:</span>"));
1411 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
1412 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, TRUE);
1414 if (wizard->create_mailbox) {
1415 gtk_widget_hide(wizard->mailbox_label);
1416 gtk_widget_hide(wizard->mailbox_name);
1419 gtk_widget_hide(wizard->recv_imap_label);
1420 gtk_widget_hide(wizard->recv_imap_subdir);
1421 gtk_widget_hide(wizard->subsonly_checkbtn);
1422 gtk_widget_hide(wizard->recv_username);
1423 gtk_widget_hide(wizard->recv_password);
1424 gtk_widget_hide(wizard->recv_username_label);
1425 gtk_widget_hide(wizard->recv_password_label);
1426 gtk_widget_show(wizard->no_imap_warning);
1427 if (wizard->create_mailbox) {
1428 gtk_widget_hide(wizard->mailbox_label);
1429 gtk_widget_hide(wizard->mailbox_name);
1431 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
1432 gtk_widget_hide(wizard->recv_use_ssl);
1433 gtk_widget_hide(wizard->recv_use_tls);
1434 gtk_widget_hide(wizard->recv_cert_table);
1436 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, FALSE);
1438 } else if (protocol == A_LOCAL) {
1439 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), tmpl.mboxfile?tmpl.mboxfile:"");
1440 gtk_label_set_text(GTK_LABEL(wizard->recv_label), _("<span weight=\"bold\">Local mailbox:</span>"));
1441 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
1442 gtk_widget_hide(wizard->no_imap_warning);
1443 gtk_widget_hide(wizard->recv_imap_label);
1444 gtk_widget_hide(wizard->recv_imap_subdir);
1445 gtk_widget_hide(wizard->subsonly_checkbtn);
1446 gtk_widget_hide(wizard->recv_username);
1447 gtk_widget_hide(wizard->recv_password);
1448 gtk_widget_hide(wizard->recv_username_label);
1449 gtk_widget_hide(wizard->recv_password_label);
1450 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
1451 gtk_widget_hide(wizard->recv_use_ssl);
1452 gtk_widget_hide(wizard->recv_use_tls);
1453 gtk_widget_hide(wizard->recv_cert_table);
1455 if (wizard->create_mailbox) {
1456 gtk_widget_show(wizard->mailbox_label);
1457 gtk_widget_show(wizard->mailbox_name);
1459 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, TRUE);
1463 static void wizard_protocol_changed(GtkComboBox *combo, gpointer data)
1465 WizardWindow *wizard = (WizardWindow *)data;
1466 RecvProtocol protocol = combobox_get_active_data(combo);
1468 wizard_protocol_change(wizard, protocol);
1471 static GtkWidget* recv_page (WizardWindow * wizard)
1473 GtkWidget *table = gtk_table_new(1,1, FALSE);
1476 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
1479 GtkWidget *recv_cert_table;
1481 GtkListStore *store;
1487 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
1488 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
1490 vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
1491 gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
1493 gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2,
1494 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1496 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1497 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1498 wizard->recv_type = gtkut_sc_combobox_create(NULL, FALSE);
1499 store = GTK_LIST_STORE(gtk_combo_box_get_model(
1500 GTK_COMBO_BOX(wizard->recv_type)));
1502 COMBOBOX_ADD(store, _("POP3"), A_POP3);
1503 COMBOBOX_ADD(store, _("IMAP"), A_IMAP4);
1504 COMBOBOX_ADD(store, _("Local mbox file"), A_LOCAL);
1506 switch(tmpl.recvtype) {
1519 gtk_combo_box_set_active(GTK_COMBO_BOX (wizard->recv_type), index);
1520 g_signal_connect(G_OBJECT(wizard->recv_type), "changed",
1521 G_CALLBACK(wizard_protocol_changed),
1523 PACK_BOX(hbox, _("<span weight=\"bold\">Server type:</span>"),
1526 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1527 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1528 wizard->recv_server = gtk_entry_new();
1529 text = get_default_server(wizard, "pop");
1530 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
1533 CLAWS_SET_TIP(wizard->recv_server,
1534 _("You can specify the port number by appending it at the end: "
1535 "\"mail.example.com:110\""));
1537 wizard->recv_label = gtk_label_new(_("<span weight=\"bold\">Server address:</span>"));
1538 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
1539 if (GTK_IS_MISC(wizard->recv_label))
1540 gtk_misc_set_alignment(GTK_MISC(wizard->recv_label), 1, 0.5);
1541 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_label, FALSE, FALSE, 0);
1542 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_server, TRUE, TRUE, 0);
1544 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1545 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1546 wizard->recv_username = gtk_entry_new();
1547 wizard->recv_username_label = gtk_label_new(_("<span weight=\"bold\">Username:</span>"));
1548 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_username_label), TRUE);
1549 if (GTK_IS_MISC(wizard->recv_username_label))
1550 gtk_misc_set_alignment(GTK_MISC(wizard->recv_username_label), 1, 0.5);
1551 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_username_label, FALSE, FALSE, 0);
1552 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_username, TRUE, TRUE, 0);
1554 text = get_default_account(wizard);
1555 gtk_entry_set_text(GTK_ENTRY(wizard->recv_username), text);
1558 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1559 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1560 wizard->recv_password = gtk_entry_new();
1561 gtk_entry_set_text(GTK_ENTRY(wizard->recv_password), tmpl.recvpass?tmpl.recvpass:"");
1562 wizard->recv_password_label = gtk_label_new(_("Password:"));
1563 if (GTK_IS_MISC(wizard->recv_password_label))
1564 gtk_misc_set_alignment(GTK_MISC(wizard->recv_password_label), 1, 0.5);
1565 gtk_entry_set_visibility(GTK_ENTRY(wizard->recv_password), FALSE);
1567 hildon_gtk_entry_set_input_mode(GTK_ENTRY(wizard->recv_password),
1568 HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
1570 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_password_label, FALSE, FALSE, 0);
1571 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_password, TRUE, TRUE, 0);
1573 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
1574 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1575 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1576 wizard->recv_use_ssl = gtk_check_button_new_with_label(
1577 _("Use SSL to connect to receiving server"));
1578 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->recv_use_ssl),
1580 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_use_ssl, FALSE, FALSE, 0);
1582 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1583 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1584 wizard->recv_use_tls = gtk_check_button_new_with_label(
1585 _("Use SSL via STARTTLS"));
1586 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->recv_use_tls),
1588 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_use_tls, FALSE, FALSE, 0);
1589 SET_TOGGLE_SENSITIVITY (wizard->recv_use_ssl, wizard->recv_use_tls);
1591 recv_cert_table = gtk_table_new(3,3, FALSE);
1592 gtk_container_set_border_width(GTK_CONTAINER(recv_cert_table), 8);
1593 gtk_box_pack_start (GTK_BOX(vbox), recv_cert_table, FALSE, FALSE, 0);
1594 label = gtk_label_new(_("Client SSL certificate (optional)"));
1595 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
1596 gtk_table_attach(GTK_TABLE(recv_cert_table), label, 0, 3, 0, 1, GTK_FILL, 0, 0, 0);
1597 label = gtk_label_new(_("File"));
1598 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
1599 gtk_table_attach(GTK_TABLE(recv_cert_table), label, 0, 1, 1, 2, GTK_FILL, 0, 0, 0);
1600 wizard->recv_ssl_cert_file = gtk_entry_new();
1601 gtk_entry_set_text(GTK_ENTRY(wizard->recv_ssl_cert_file), tmpl.recvssl_cert?tmpl.recvssl_cert:"");
1602 gtk_table_attach(GTK_TABLE(recv_cert_table), wizard->recv_ssl_cert_file, 1, 2, 1, 2, GTK_FILL, 0, 0, 0);
1603 button = gtkut_get_browse_file_btn(_("Browse"));
1604 gtk_table_attach(GTK_TABLE(recv_cert_table), button, 2, 3, 1, 2, GTK_FILL, 0, 0, 0);
1605 SET_TOGGLE_SENSITIVITY (wizard->recv_use_ssl, label);
1606 SET_TOGGLE_SENSITIVITY (wizard->recv_use_ssl, wizard->recv_ssl_cert_file);
1607 SET_TOGGLE_SENSITIVITY (wizard->recv_use_ssl, button);
1608 g_signal_connect(G_OBJECT(button), "clicked",
1609 G_CALLBACK(cert_browse_cb), wizard->recv_ssl_cert_file);
1611 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1612 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1613 label = gtk_label_new(_("Password"));
1614 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
1615 gtk_table_attach(GTK_TABLE(recv_cert_table), label, 0, 1, 2, 3, GTK_FILL, 0, 0, 0);
1616 wizard->recv_ssl_cert_pass = gtk_entry_new();
1617 gtk_entry_set_visibility(GTK_ENTRY(wizard->recv_ssl_cert_pass), FALSE);
1618 gtk_entry_set_text(GTK_ENTRY(wizard->recv_ssl_cert_pass), tmpl.recvssl_cert_pass?tmpl.recvssl_cert_pass:"");
1619 gtk_table_attach(GTK_TABLE(recv_cert_table), wizard->recv_ssl_cert_pass, 1, 2, 2, 3, GTK_FILL, 0, 0, 0);
1620 SET_TOGGLE_SENSITIVITY (wizard->recv_use_ssl, label);
1621 SET_TOGGLE_SENSITIVITY (wizard->recv_use_ssl, wizard->recv_ssl_cert_pass);
1622 wizard->recv_cert_table = recv_cert_table;
1624 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1625 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1626 wizard->recv_imap_subdir = gtk_entry_new();
1627 gtk_entry_set_text(GTK_ENTRY(wizard->recv_imap_subdir), tmpl.imapdir?tmpl.imapdir:"");
1628 wizard->recv_imap_label = gtk_label_new(_("IMAP server directory:"));
1629 if (GTK_IS_MISC(wizard->recv_imap_label))
1630 gtk_misc_set_alignment(GTK_MISC(wizard->recv_imap_label), 1, 0.5);
1631 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_imap_label, FALSE, FALSE, 0);
1632 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_imap_subdir, TRUE, TRUE, 0);
1634 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1635 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1636 wizard->subsonly_checkbtn = gtk_check_button_new_with_label(
1637 _("Show only subscribed folders"));
1638 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->subsonly_checkbtn),
1640 gtk_box_pack_start(GTK_BOX(hbox), wizard->subsonly_checkbtn, FALSE, FALSE, 0);
1642 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1643 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1644 wizard->no_imap_warning = gtk_label_new(_(
1645 "<span weight=\"bold\">Warning: this version of Claws Mail\n"
1646 "has been built without IMAP support.</span>"));
1647 gtk_label_set_use_markup(GTK_LABEL(wizard->no_imap_warning), TRUE);
1648 gtk_box_pack_start(GTK_BOX(hbox), wizard->no_imap_warning, FALSE, FALSE, 0);
1654 wizard_response_cb (GtkDialog * dialog, int response, gpointer data)
1656 WizardWindow * wizard = (WizardWindow *)data;
1657 int current_page, num_pages;
1658 gboolean skip_mailbox_page = FALSE;
1660 gint protocol = combobox_get_active_data(GTK_COMBO_BOX(wizard->recv_type));
1662 if (protocol == A_IMAP4) {
1663 skip_mailbox_page = TRUE;
1667 num_pages = g_slist_length(wizard->pages);
1669 current_page = gtk_notebook_get_current_page (
1670 GTK_NOTEBOOK(wizard->notebook));
1671 if (response == CANCEL)
1673 wizard->result = FALSE;
1674 wizard->finished = TRUE;
1675 gtk_widget_destroy (GTK_WIDGET(dialog));
1677 else if (response == FINISHED)
1679 if (!wizard_write_config(wizard)) {
1680 current_page = gtk_notebook_get_current_page (
1681 GTK_NOTEBOOK(wizard->notebook));
1684 wizard->result = TRUE;
1685 wizard->finished = TRUE;
1686 gtk_widget_destroy (GTK_WIDGET(dialog));
1690 if (response == GO_BACK)
1692 if (current_page > 0) {
1694 if (current_page == MAILBOX_PAGE && skip_mailbox_page) {
1698 gtk_notebook_set_current_page (
1699 GTK_NOTEBOOK(wizard->notebook),
1703 else if (response == GO_FORWARD)
1705 if (current_page < (num_pages-1)) {
1707 if (current_page == MAILBOX_PAGE && skip_mailbox_page) {
1711 gtk_notebook_set_current_page (
1712 GTK_NOTEBOOK(wizard->notebook),
1717 gtk_dialog_set_response_sensitive (dialog, GO_BACK,
1719 gtk_dialog_set_response_sensitive (dialog, GO_FORWARD,
1720 current_page < (num_pages - 1));
1721 if (current_page == (num_pages -1)) {
1722 gtk_dialog_set_response_sensitive (dialog, FINISHED, TRUE);
1723 gtk_dialog_set_default_response(GTK_DIALOG(wizard->window), FINISHED);
1725 gtk_dialog_set_response_sensitive (dialog, FINISHED, FALSE);
1726 gtk_dialog_set_default_response(GTK_DIALOG(wizard->window), GO_FORWARD);
1732 static gint wizard_close_cb(GtkWidget *widget, GdkEventAny *event,
1735 WizardWindow *wizard = (WizardWindow *)data;
1736 wizard->result = FALSE;
1737 wizard->finished = TRUE;
1742 #define PACK_WARNING(text) { \
1743 label = gtk_label_new(text); \
1744 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); \
1745 gtk_box_pack_end(GTK_BOX(widget), label, FALSE, FALSE, 0); \
1748 gboolean run_wizard(MainWindow *mainwin, gboolean create_mailbox) {
1749 WizardWindow *wizard = g_new0(WizardWindow, 1);
1753 GtkWidget *scrolled_window;
1758 wizard->mainwin = mainwin;
1759 wizard->create_mailbox = create_mailbox;
1761 gtk_widget_hide(mainwin->window);
1763 wizard_read_defaults();
1765 wizard->window = gtk_dialog_new_with_buttons (_("Claws Mail Setup Wizard"),
1767 GTK_STOCK_GO_BACK, GO_BACK,
1768 GTK_STOCK_GO_FORWARD, GO_FORWARD,
1769 GTK_STOCK_SAVE, FINISHED,
1770 GTK_STOCK_CANCEL, CANCEL,
1772 gtk_widget_set_size_request(wizard->window, -1, 480);
1774 g_signal_connect(wizard->window, "response",
1775 G_CALLBACK(wizard_response_cb), wizard);
1776 gtk_widget_realize(wizard->window);
1777 gtk_dialog_set_default_response(GTK_DIALOG(wizard->window),
1779 gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window),
1781 gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window),
1783 gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window),
1785 gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window),
1788 wizard->notebook = gtk_notebook_new();
1789 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(wizard->notebook), FALSE);
1790 gtk_notebook_set_show_border(GTK_NOTEBOOK(wizard->notebook), FALSE);
1791 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(wizard->window)->vbox),
1792 wizard->notebook, TRUE, TRUE, 0);
1794 wizard->pages = NULL;
1796 /*welcome page: 0 */
1798 page = create_page(wizard, _("Welcome to Claws Mail"));
1800 wizard->pages = g_slist_append(wizard->pages, page);
1801 widget = stock_pixmap_widget(wizard->window,
1802 STOCK_PIXMAP_CLAWS_MAIL_LOGO);
1804 gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1806 text = g_strdup(_("Welcome to the Claws Mail setup wizard.\n\n"
1807 "We will begin by defining some basic "
1808 "information about you and your most common "
1809 "mail options so that you can start to use "
1810 "Claws Mail in less than five minutes."));
1811 widget = gtk_label_new(text);
1812 gtk_label_set_line_wrap(GTK_LABEL(widget), TRUE);
1814 gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1816 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
1817 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
1818 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1819 gtk_box_pack_start(GTK_BOX(page), scrolled_window, TRUE, TRUE, 0);
1821 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1829 widget = create_page (wizard, _("About You"));
1830 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
1831 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
1832 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1833 gtk_box_pack_start(GTK_BOX(widget), scrolled_window, TRUE, TRUE, 0);
1835 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1837 PACK_WARNING(_("Bold fields must be completed"));
1839 wizard->pages = g_slist_append(wizard->pages, widget);
1841 /* recv+auth page: 2 */
1844 widget = create_page (wizard, _("Receiving mail"));
1845 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
1846 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
1847 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1848 gtk_box_pack_start(GTK_BOX(widget), scrolled_window, TRUE, TRUE, 0);
1850 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1852 PACK_WARNING(_("Bold fields must be completed"));
1854 wizard->pages = g_slist_append(wizard->pages, widget);
1859 widget = create_page (wizard, _("Sending mail"));
1860 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
1861 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
1862 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1863 gtk_box_pack_start(GTK_BOX(widget), scrolled_window, TRUE, TRUE, 0);
1865 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1867 PACK_WARNING(_("Bold fields must be completed"));
1869 wizard->pages = g_slist_append(wizard->pages, widget);
1871 /* mailbox page: 4 */
1872 if (create_mailbox) {
1875 widget = create_page (wizard, _("Saving mail on disk"));
1876 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
1877 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
1878 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1879 gtk_box_pack_start(GTK_BOX(widget), scrolled_window, TRUE, TRUE, 0);
1881 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1882 mailbox_page(wizard));
1883 PACK_WARNING(_("Bold fields must be completed"));
1885 wizard->pages = g_slist_append(wizard->pages, widget);
1891 page = create_page(wizard, _("Configuration finished"));
1893 wizard->pages = g_slist_append(wizard->pages, page);
1894 widget = stock_pixmap_widget(wizard->window,
1895 STOCK_PIXMAP_CLAWS_MAIL_LOGO);
1897 gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1899 text = g_strdup(_("Claws Mail is now ready.\n"
1900 "Click Save to start."));
1901 widget = gtk_label_new(text);
1902 gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1906 for (cur = wizard->pages; cur && cur->data; cur = cur->next) {
1907 gtk_notebook_append_page (GTK_NOTEBOOK(wizard->notebook),
1908 GTK_WIDGET(cur->data), NULL);
1911 g_signal_connect(G_OBJECT(wizard->window), "delete_event",
1912 G_CALLBACK(wizard_close_cb), wizard);
1913 gtk_widget_show_all (wizard->window);
1915 gtk_widget_hide(wizard->recv_imap_label);
1916 gtk_widget_hide(wizard->recv_imap_subdir);
1917 gtk_widget_hide(wizard->subsonly_checkbtn);
1919 wizard_protocol_change(wizard, tmpl.recvtype);
1921 while (!wizard->finished)
1922 gtk_main_iteration();
1924 result = wizard->result;
1928 gtk_widget_show(mainwin->window);