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"
60 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
63 #include "prefs_common.h"
67 #include <libgnomevfs/gnome-vfs-volume.h>
68 #include <libgnomevfs/gnome-vfs-volume-monitor.h>
69 #include <libgnomevfs/gnome-vfs-utils.h>
80 int WELCOME_PAGE = -1;
84 int MAILBOX_PAGE = -1;
97 GtkWidget *organization;
99 GtkWidget *mailbox_name;
100 GtkWidget *mailbox_label;
102 GtkWidget *smtp_server;
103 GtkWidget *smtp_auth;
104 GtkWidget *smtp_username;
105 GtkWidget *smtp_password;
106 GtkWidget *smtp_username_label;
107 GtkWidget *smtp_password_label;
109 GtkWidget *recv_type;
110 GtkWidget *recv_label;
111 GtkWidget *recv_server;
112 GtkWidget *recv_username;
113 GtkWidget *recv_password;
114 GtkWidget *recv_username_label;
115 GtkWidget *recv_password_label;
116 GtkWidget *recv_imap_label;
117 GtkWidget *recv_imap_subdir;
118 GtkWidget *subsonly_checkbtn;
119 GtkWidget *no_imap_warning;
120 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
121 GtkWidget *smtp_use_ssl;
122 GtkWidget *recv_use_ssl;
123 GtkWidget *smtp_use_tls;
124 GtkWidget *recv_use_tls;
128 GtkWidget *data_root_nokia_radiobtn;
129 GtkWidget *data_root_mmc1_radiobtn;
130 GtkWidget *data_root_mmc2_radiobtn;
131 GnomeVFSVolumeMonitor *volmon;
132 gulong volmon_mount_sigid;
133 gulong volmon_unmount_sigid;
134 GnomeVFSVolume *vol_mmc1;
135 GnomeVFSVolume *vol_mmc2;
137 gboolean create_mailbox;
143 typedef struct _AccountTemplate {
152 RecvProtocol recvtype;
164 static AccountTemplate tmpl;
166 static PrefParam template_params[] = {
167 {"name", "$USERNAME",
168 &tmpl.name, P_STRING, NULL, NULL, NULL},
169 {"domain", "$DEFAULTDOMAIN",
170 &tmpl.domain, P_STRING, NULL, NULL, NULL},
171 {"email", "$NAME_MAIL@$DOMAIN",
172 &tmpl.email, P_STRING, NULL, NULL, NULL},
174 &tmpl.organization, P_STRING, NULL, NULL, NULL},
175 {"smtpserver", "smtp.$DOMAIN",
176 &tmpl.smtpserver, P_STRING, NULL, NULL, NULL},
177 {"smtpauth", "FALSE",
178 &tmpl.smtpauth, P_BOOL, NULL, NULL, NULL},
180 &tmpl.smtpuser, P_STRING, NULL, NULL, NULL},
182 &tmpl.smtppass, P_STRING, NULL, NULL, NULL},
184 &tmpl.recvtype, P_INT, NULL, NULL, NULL},
185 {"recvserver", "pop.$DOMAIN",
186 &tmpl.recvserver, P_STRING, NULL, NULL, NULL},
187 {"recvuser", "$LOGIN",
188 &tmpl.recvuser, P_STRING, NULL, NULL, NULL},
190 &tmpl.recvpass, P_STRING, NULL, NULL, NULL},
192 &tmpl.imapdir, P_STRING, NULL, NULL, NULL},
194 &tmpl.subsonly, P_BOOL, NULL, NULL, NULL},
195 {"mboxfile", "/var/mail/$LOGIN",
196 &tmpl.mboxfile, P_STRING, NULL, NULL, NULL},
198 &tmpl.mailbox, P_STRING, NULL, NULL, NULL},
200 &tmpl.smtpssl, P_INT, NULL, NULL, NULL},
202 &tmpl.recvssl, P_INT, NULL, NULL, NULL},
203 {NULL, NULL, NULL, P_INT, NULL, NULL, NULL}
207 static gchar *accountrc_tmpl =
208 "[AccountTemplate]\n"
209 "#you can use $DEFAULTDOMAIN here\n"
210 "#domain must be defined before the variables that use it\n"
211 "#by default, domain is extracted from the hostname\n"
214 "#you can use $USERNAME for name (this is the default)\n"
217 "#you can use $LOGIN, $NAME_MAIL and $DOMAIN here \n"
218 "#$NAME_MAIL is the name without uppercase and with dots instead\n"
220 "#the default is $NAME_MAIL@$DOMAIN\n"
223 "#you can use $DOMAIN here\n"
224 "#the default organization is empty\n"
227 "#you can use $DOMAIN here \n"
228 "#the default is stmp.$DOMAIN\n"
231 "#Whether to use smtp authentication\n"
232 "#the default is 0 (no)\n"
236 "#you can use $LOGIN, $NAME_MAIL, $DOMAIN or $EMAIL here\n"
237 "#the default is empty (same as reception username)\n"
241 "#the default is empty (same as reception password)\n"
244 "#recvtype can be:\n"
247 "#5 for a local mbox file\n"
250 "#you can use $DOMAIN here \n"
251 "#the default is {pop,imap}.$DOMAIN\n"
254 "#you can use $LOGIN, $NAME_MAIL, $DOMAIN or $EMAIL here\n"
255 "#default is $LOGIN\n"
258 "#default is empty\n"
261 "#imap dir if imap (relative to the home on the server)\n"
262 "#default is empty\n"
265 "#show subscribed folders only, if imap\n"
269 "#mbox file if local\n"
270 "#you can use $LOGIN here\n"
271 "#default is /var/mail/$LOGIN\n"
274 "#mailbox name if pop3 or local\n"
275 "#relative path from the user's home\n"
276 "#default is \"Mail\"\n"
279 "#whether to use ssl on STMP connections\n"
280 "#default is 0, 1 is ssl, 2 is starttls\n"
283 "#whether to use ssl on pop or imap connections\n"
284 "#default is 0, 1 is ssl, 2 is starttls\n"
287 static gchar *wizard_get_default_domain_name(void)
289 static gchar *domain_name = NULL;
291 if (domain_name == NULL) {
292 domain_name = g_strdup(get_domain_name());
293 if (strchr(domain_name, '.') != strrchr(domain_name, '.')
294 && strlen(strchr(domain_name, '.')) > 6) {
295 gchar *tmp = g_strdup(strchr(domain_name, '.')+1);
303 static gchar *get_name_for_mail(void)
305 gchar *name = g_strdup(tmpl.name);
309 while(strstr(name, " "))
310 *strstr(name, " ")='.';
315 #define PARSE_DEFAULT(str) { \
316 gchar *tmp = NULL, *new = NULL; \
318 tmp = g_strdup(str); \
319 if (strstr(str, "$USERNAME")) { \
320 tmp = g_strdup(str); \
321 *strstr(tmp, "$USERNAME") = '\0'; \
322 new = g_strconcat(tmp, g_get_real_name(), \
323 strstr(str, "$USERNAME")+strlen("$USERNAME"), \
330 if (strstr(str, "$LOGIN")) { \
331 tmp = g_strdup(str); \
332 *strstr(tmp, "$LOGIN") = '\0'; \
333 new = g_strconcat(tmp, g_get_user_name(), \
334 strstr(str, "$LOGIN")+strlen("$LOGIN"), \
341 if (strstr(str, "$EMAIL")) { \
342 tmp = g_strdup(str); \
343 *strstr(tmp, "$EMAIL") = '\0'; \
344 new = g_strconcat(tmp, tmpl.email, \
345 strstr(str, "$EMAIL")+strlen("$EMAIL"), \
352 if (strstr(str, "$NAME_MAIL")) { \
353 tmp = g_strdup(str); \
354 *strstr(tmp, "$NAME_MAIL") = '\0'; \
355 new = g_strconcat(tmp, get_name_for_mail(), \
356 strstr(str, "$NAME_MAIL")+strlen("$NAME_MAIL"), \
363 if (strstr(str, "$DEFAULTDOMAIN")) { \
364 tmp = g_strdup(str); \
365 *strstr(tmp, "$DEFAULTDOMAIN") = '\0'; \
366 new = g_strconcat(tmp, wizard_get_default_domain_name(), \
367 strstr(str, "$DEFAULTDOMAIN")+strlen("$DEFAULTDOMAIN"), \
374 if (strstr(str, "$DOMAIN")) { \
375 tmp = g_strdup(str); \
376 *strstr(tmp, "$DOMAIN") = '\0'; \
377 new = g_strconcat(tmp, tmpl.domain, \
378 strstr(str, "$DOMAIN")+strlen("$DOMAIN"), \
387 static void wizard_read_defaults(void)
391 rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, "accountrc.tmpl", NULL);
392 if (!is_file_exist(rcpath)) {
393 str_write_to_file(accountrc_tmpl, rcpath);
396 prefs_read_config(template_params, "AccountTemplate", rcpath, NULL);
398 PARSE_DEFAULT(tmpl.domain);
399 PARSE_DEFAULT(tmpl.name);
400 PARSE_DEFAULT(tmpl.email);
401 PARSE_DEFAULT(tmpl.organization);
402 PARSE_DEFAULT(tmpl.smtpserver);
403 PARSE_DEFAULT(tmpl.smtpuser);
404 PARSE_DEFAULT(tmpl.smtppass);
405 PARSE_DEFAULT(tmpl.recvserver);
406 PARSE_DEFAULT(tmpl.recvuser);
407 PARSE_DEFAULT(tmpl.recvpass);
408 PARSE_DEFAULT(tmpl.imapdir);
409 PARSE_DEFAULT(tmpl.mboxfile);
410 PARSE_DEFAULT(tmpl.mailbox);
413 "%s, %s, %s, %s, %s, %d, %s, %s, %s, %s, %s, %s, %d, %d\n",
414 tmpl.name,tmpl.domain,tmpl.email,tmpl.organization,tmpl.smtpserver,
415 tmpl.recvtype,tmpl.recvserver,tmpl.recvuser,tmpl.recvpass,
416 tmpl.imapdir,tmpl.mboxfile,tmpl.mailbox,tmpl.smtpssl,tmpl.recvssl);
421 static void initialize_fonts(WizardWindow *wizard)
423 GtkWidget *widget = wizard->email;
424 gint size = pango_font_description_get_size(
425 widget->style->font_desc)
429 tmp = g_strdup(prefs_common.textfont);
430 if (strrchr(tmp, ' ')) {
431 *(strrchr(tmp, ' ')) = '\0';
432 new = g_strdup_printf("%s %d", tmp, size);
433 g_free(prefs_common.textfont);
434 prefs_common.textfont = new;
438 tmp = g_strdup(prefs_common.smallfont);
439 if (strrchr(tmp, ' ')) {
440 *(strrchr(tmp, ' ')) = '\0';
441 new = g_strdup_printf("%s %d", tmp, size);
442 g_free(prefs_common.smallfont);
443 prefs_common.smallfont = new;
447 tmp = g_strdup(prefs_common.normalfont);
448 if (strrchr(tmp, ' ')) {
449 *(strrchr(tmp, ' ')) = '\0';
450 new = g_strdup_printf("%s %d", tmp, size);
451 g_free(prefs_common.normalfont);
452 prefs_common.normalfont = new;
457 #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"
458 #define FACE "iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAAM1BMVEUAAAAcJCI\n\
459 ONl1JUi0+Z4daY2NZciPabV9ykS5kj6Wsl2ybmZOBsMjZxK2wzN3Pzczs7OsCAGN0AAAAAXRSTlM\n\
460 AQObYZgAAAAFiS0dEAIgFHUgAAAIVSURBVEjH1ZbtlqMgDIaFECoGhPu/2s0b0Lais/NzN6d1OJ7\n\
461 3yReQzrL8B5Zy3rvl9At52Pf2tv1vSMjtYj8jaa8XUyI/yn3YD6sigj/2Tf5Bn069MIsTPHvx/t5\n\
462 /3rU/6JCIY3YwGe26r/cwUfE3cFe5T28L0K5rJAUHEeYAQxs8DHojjk3M9wECU4xxjXisI8RA0gy\n\
463 oczJZJOjxiTFZVTchAnIRJrgdmEGDyFfAI3UuG5FmYTkR9RDrIC4H0SqV4pzpEcUp0HNLjwBv+jA\n\
464 dikUE5g9iBvzmu3sH2oDk4lnHd829+2Q9gj6kDqDPg7hsGwBzH02fE3ZCt6ZHmlNKIMjMeRwra5I\n\
465 ecgNoBnLGPmzaHPJIwLY8Sq2M/tLUJfj0QcqmfVXAdLSStIYF8dzWjBBb2VgvDa4mO9oc651OiUo\n\
466 BEKbZokdPATF9E9oKAjQJcJOniaPXrVZRAnVWaqIyqRoNC8ZJvgCcW8XN39RqxVP1rS8Yd4WnCdN\n\
467 aRTo2jJRDbg3vtCpEUGffgDPhqKDaSuVqYtOplFIvIcx3HUI5/MuIWl6vKyBjNlqEru8hbFXqBPA\n\
468 5TpHGIUZOePeaIyzfQ/g9Xg0opU1AvdfXM9floYhv92pPAE96OZtkPV8eivgQi9RTfwPUU36I26n\n\
469 Hy+WuCJzAT7efMSeA1TNf2/VugDz+dN139xfA5ffxGZDD+MvcP/uvyB80wzZ76wbz8gAAAABJRU5\n\
472 static void write_welcome_email(WizardWindow *wizard)
478 const gchar *mailbox = gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name));
479 Folder *folder = folder_find_from_path(mailbox);
480 FolderItem *inbox = folder ? folder->inbox:NULL;
481 gchar *file = get_tmp_file();
482 gchar enc_from_name[BUFFSIZE], enc_to_name[BUFFSIZE], enc_subject[BUFFSIZE];
484 get_rfc822_date(buf_date, sizeof(buf_date));
486 conv_encode_header_full(enc_subject, sizeof(enc_subject),
487 Q_("Welcome Mail Subject|Welcome to Claws Mail"),
488 strlen("Subject: "), FALSE, CS_INTERNAL);
489 conv_encode_header_full(enc_to_name, sizeof(enc_to_name),
490 gtk_entry_get_text(GTK_ENTRY(wizard->full_name)),
491 strlen("To: "), TRUE, CS_INTERNAL);
492 conv_encode_header_full(enc_from_name, sizeof(enc_from_name),
493 _("The Claws Mail Team"),
494 strlen("From: "), TRUE, CS_INTERNAL);
496 head = g_strdup_printf(
503 "Content-Type: text/plain; charset=UTF-8\n",
507 gtk_entry_get_text(GTK_ENTRY(wizard->email)),
508 buf_date, enc_subject, XFACE, FACE);
509 body = g_strdup_printf(
511 "Welcome to Claws Mail\n"
512 "---------------------\n"
514 "Now that you have set up your account you can fetch your\n"
515 "mail by clicking the 'Get Mail' button at the left of the\n"
518 "Claws Mail has lots of extra features accessible via plugins,\n"
519 "like anti-spam filtering and learning (via the Bogofilter or\n"
520 "SpamAssassin plugins), privacy protection (via PGP/Mime), an RSS\n"
521 "aggregator, a calendar, and much more. You can load them from\n"
522 "the menu entry '/Configuration/Plugins'.\n"
524 "You can change your Account Preferences by using the menu\n"
525 "entry '/Configuration/Preferences for current account'\n"
526 "and change the general Preferences by using\n"
527 "'/Configuration/Preferences'.\n"
529 "You can find further information in the Claws Mail manual,\n"
530 "which can be accessed by using the menu entry '/Help/Manual'\n"
531 "or online at the URL given below.\n"
539 "Mailing Lists: <%s>\n"
543 "Claws Mail is free software, released under the terms\n"
544 "of the GNU General Public License, version 3 or later, as\n"
545 "published by the Free Software Foundation, 51 Franklin Street,\n"
546 "Fifth Floor, Boston, MA 02110-1301, USA. The license can be\n"
551 "If you wish to donate to the Claws Mail project you can do\n"
553 HOMEPAGE_URI, MANUAL_URI, FAQ_URI, THEMES_URI, MAILING_LIST_URI,
554 GPL_URI, DONATE_URI);
556 msg = g_strconcat(head, body, NULL);
558 if (inbox && inbox->total_msgs == 0
559 && str_write_to_file(msg, file) >= 0) {
560 MsgFlags flags = { MSG_UNREAD|MSG_NEW, 0};
561 folder_item_add_msg(inbox, file, &flags, FALSE);
570 static gboolean wizard_write_config(WizardWindow *wizard)
572 static gboolean mailbox_ok = FALSE;
573 PrefsAccount *prefs_account = prefs_account_new();
574 GList *account_list = NULL;
575 gchar *smtp_server, *recv_server;
576 gint smtp_port, recv_port;
577 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
578 SSLType smtp_ssl_type, recv_ssl_type;
581 prefs_account->protocol = combobox_get_active_data(
582 GTK_COMBO_BOX(wizard->recv_type));
584 if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4 &&
585 !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name)))) {
586 alertpanel_error(_("Please enter the mailbox name."));
587 g_free(prefs_account);
588 gtk_notebook_set_current_page (
589 GTK_NOTEBOOK(wizard->notebook),
595 if (wizard->create_mailbox) {
596 g_free(prefs_common.data_root);
597 if (gtk_toggle_button_get_active(
598 GTK_TOGGLE_BUTTON(wizard->data_root_nokia_radiobtn)))
599 prefs_common.data_root = NULL;
600 else if (gtk_toggle_button_get_active(
601 GTK_TOGGLE_BUTTON(wizard->data_root_mmc1_radiobtn)))
602 prefs_common.data_root = g_strdup(MMC1_PATH);
603 else if (gtk_toggle_button_get_active(
604 GTK_TOGGLE_BUTTON(wizard->data_root_mmc2_radiobtn)))
605 prefs_common.data_root = g_strdup(MMC2_PATH);
610 if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4) {
611 mailbox_ok = setup_write_mailbox_path(wizard->mainwin,
613 GTK_ENTRY(wizard->mailbox_name)));
619 /* alertpanel done by setup_write_mailbox_path */
620 g_free(prefs_account);
621 gtk_notebook_set_current_page (
622 GTK_NOTEBOOK(wizard->notebook),
627 if (!strlen(gtk_entry_get_text(GTK_ENTRY(wizard->full_name)))
628 || !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->email)))) {
629 alertpanel_error(_("Please enter your name and email address."));
630 g_free(prefs_account);
631 gtk_notebook_set_current_page (
632 GTK_NOTEBOOK(wizard->notebook),
637 if (prefs_account->protocol != A_LOCAL) {
638 if (!strlen(gtk_entry_get_text(GTK_ENTRY(wizard->recv_username)))
639 || !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)))) {
640 alertpanel_error(_("Please enter your receiving server "
642 g_free(prefs_account);
643 gtk_notebook_set_current_page (
644 GTK_NOTEBOOK(wizard->notebook),
649 if (!strlen(gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)))) {
650 alertpanel_error(_("Please enter your username."));
651 g_free(prefs_account);
652 gtk_notebook_set_current_page (
653 GTK_NOTEBOOK(wizard->notebook),
659 if (!strlen(gtk_entry_get_text(GTK_ENTRY(wizard->smtp_server)))) {
660 alertpanel_error(_("Please enter your SMTP server."));
661 g_free(prefs_account);
662 gtk_notebook_set_current_page (
663 GTK_NOTEBOOK(wizard->notebook),
668 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_auth))) {
669 if (prefs_account->protocol == A_LOCAL
670 && !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->smtp_username)))) {
671 alertpanel_error(_("Please enter your SMTP username."));
672 g_free(prefs_account);
673 gtk_notebook_set_current_page (
674 GTK_NOTEBOOK(wizard->notebook),
677 } /* if it's not local we'll use the reception server */
680 if (prefs_account->protocol != A_LOCAL)
681 prefs_account->account_name = g_strdup_printf("%s@%s",
682 gtk_entry_get_text(GTK_ENTRY(wizard->recv_username)),
683 gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
685 prefs_account->account_name = g_strdup_printf("%s",
686 gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
688 recv_server = g_strdup(gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
689 smtp_server = g_strdup(gtk_entry_get_text(GTK_ENTRY(wizard->smtp_server)));
691 if (prefs_account->protocol != A_LOCAL && strstr(recv_server, ":")) {
692 recv_port = atoi(strstr(recv_server, ":")+1);
693 *(strstr(recv_server, ":")) = '\0';
694 if (prefs_account->protocol == A_IMAP4) {
695 prefs_account->set_imapport = TRUE;
696 prefs_account->imapport = recv_port;
697 } else if (prefs_account->protocol == A_POP3) {
698 prefs_account->set_popport = TRUE;
699 prefs_account->popport = recv_port;
702 if (strstr(smtp_server, ":")) {
703 smtp_port = atoi(strstr(smtp_server, ":")+1);
704 *(strstr(smtp_server, ":")) = '\0';
705 prefs_account->set_smtpport = TRUE;
706 prefs_account->smtpport = smtp_port;
709 prefs_account->name = g_strdup(
710 gtk_entry_get_text(GTK_ENTRY(wizard->full_name)));
711 prefs_account->address = g_strdup(
712 gtk_entry_get_text(GTK_ENTRY(wizard->email)));
713 prefs_account->organization = g_strdup(
714 gtk_entry_get_text(GTK_ENTRY(wizard->organization)));
715 prefs_account->smtp_server = g_strdup(smtp_server);
717 if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4) {
719 tmp = g_path_get_basename(gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name)));
720 prefs_account->inbox = g_strdup_printf("#mh/%s/inbox",
721 (!strcmp("Mail", gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name))))
724 prefs_account->local_inbox = g_strdup(prefs_account->inbox);
725 } else if (prefs_account->protocol != A_IMAP4) {
726 if (folder_get_default_inbox())
727 prefs_account->local_inbox =
728 folder_item_get_identifier(folder_get_default_inbox());
731 if (prefs_account->protocol != A_LOCAL)
732 prefs_account->recv_server = g_strdup(recv_server);
734 prefs_account->local_mbox = g_strdup(recv_server);
739 prefs_account->userid = g_strdup(
740 gtk_entry_get_text(GTK_ENTRY(wizard->recv_username)));
741 prefs_account->passwd = g_strdup(
742 gtk_entry_get_text(GTK_ENTRY(wizard->recv_password)));
744 prefs_account->smtp_userid = g_strdup(
745 gtk_entry_get_text(GTK_ENTRY(wizard->smtp_username)));
746 prefs_account->smtp_passwd = g_strdup(
747 gtk_entry_get_text(GTK_ENTRY(wizard->smtp_password)));
748 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_auth))) {
749 prefs_account->use_smtp_auth = TRUE;
752 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
753 smtp_ssl_type = SSL_NONE;
754 recv_ssl_type = SSL_NONE;
756 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_ssl))) {
757 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_tls)))
758 smtp_ssl_type = SSL_STARTTLS;
760 smtp_ssl_type = SSL_TUNNEL;
762 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->recv_use_ssl))) {
763 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->recv_use_tls)))
764 recv_ssl_type = SSL_STARTTLS;
766 recv_ssl_type = SSL_TUNNEL;
769 prefs_account->ssl_smtp = smtp_ssl_type;
771 if (prefs_account->protocol == A_IMAP4)
772 prefs_account->ssl_imap = recv_ssl_type;
774 prefs_account->ssl_pop = recv_ssl_type;
777 if (prefs_account->protocol == A_IMAP4) {
778 gchar *directory = gtk_editable_get_chars(
779 GTK_EDITABLE(wizard->recv_imap_subdir), 0, -1);
780 if (directory && strlen(directory)) {
781 prefs_account->imap_dir = g_strdup(directory);
783 prefs_account->imap_subsonly =
784 gtk_toggle_button_get_active(
785 GTK_TOGGLE_BUTTON(wizard->subsonly_checkbtn));
789 account_list = g_list_append(account_list, prefs_account);
790 prefs_account_write_config_all(account_list);
791 prefs_account_free(prefs_account);
792 account_read_config_all();
794 initialize_fonts(wizard);
795 if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4)
796 write_welcome_email(wizard);
799 if (wizard->volmon_mount_sigid)
800 g_signal_handler_disconnect(
801 G_OBJECT(wizard->volmon),
802 wizard->volmon_mount_sigid);
803 if (wizard->volmon_unmount_sigid)
804 g_signal_handler_disconnect(
805 G_OBJECT(wizard->volmon),
806 wizard->volmon_unmount_sigid);
810 plugin_load_standard_plugins();
815 static GtkWidget* create_page (WizardWindow *wizard, const char * title)
823 vbox = gtk_vbox_new (FALSE, 6);
824 gtk_container_set_border_width (GTK_CONTAINER(vbox), 10);
826 /* create the titlebar */
827 hbox = gtk_hbox_new (FALSE, 12);
828 image = stock_pixmap_widget(wizard->window,
829 STOCK_PIXMAP_CLAWS_MAIL_ICON);
830 gtk_box_pack_start (GTK_BOX(hbox), image, FALSE, FALSE, 0);
831 title_string = g_strconcat ("<span size=\"xx-large\" weight=\"ultrabold\">", title ? title : "", "</span>", NULL);
832 w = gtk_label_new (title_string);
833 gtk_label_set_use_markup (GTK_LABEL(w), TRUE);
834 g_free (title_string);
835 gtk_box_pack_start (GTK_BOX(hbox), w, FALSE, FALSE, 0);
837 /* pack the titlebar */
838 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
840 /* pack the separator */
841 gtk_box_pack_start (GTK_BOX(vbox), gtk_hseparator_new(), FALSE, FALSE, 0);
844 w = gtk_alignment_new (0, 0, 0, 0);
845 gtk_widget_set_size_request (w, 0, 6);
846 gtk_box_pack_start (GTK_BOX(vbox), w, FALSE, FALSE, 0);
851 #define PACK_BOX(hbox,text,entry) { \
852 GtkWidget *label = gtk_label_new(text); \
853 gtk_label_set_use_markup(GTK_LABEL(label), TRUE); \
854 if (GTK_IS_MISC(label)) \
855 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); \
856 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); \
857 gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0); \
860 static gchar *get_default_server(WizardWindow * wizard, const gchar *type)
862 if (!strcmp(type, "smtp")) {
863 if (!tmpl.smtpserver || !strlen(tmpl.smtpserver))
864 return g_strconcat(type, ".", tmpl.domain, NULL);
866 return g_strdup(tmpl.smtpserver);
868 if (!tmpl.recvserver || !strlen(tmpl.recvserver))
869 return g_strconcat(type, ".", tmpl.domain, NULL);
871 return g_strdup(tmpl.recvserver);
875 static gchar *get_default_account(WizardWindow * wizard)
877 gchar *result = NULL;
879 if (!tmpl.recvuser || !strlen(tmpl.recvuser)) {
880 result = gtk_editable_get_chars(
881 GTK_EDITABLE(wizard->email), 0, -1);
883 if (strstr(result, "@")) {
884 *(strstr(result,"@")) = '\0';
887 result = g_strdup(tmpl.recvuser);
892 static gchar *get_default_smtp_account(WizardWindow * wizard)
894 gchar *result = NULL;
896 if (!tmpl.smtpuser || !strlen(tmpl.smtpuser)) {
899 result = g_strdup(tmpl.smtpuser);
904 static void wizard_email_changed(GtkWidget *widget, gpointer data)
906 WizardWindow *wizard = (WizardWindow *)data;
907 RecvProtocol protocol;
909 protocol = combobox_get_active_data(GTK_COMBO_BOX(wizard->recv_type));
911 text = get_default_server(wizard, "smtp");
912 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_server), text);
915 text = get_default_account(wizard);
916 gtk_entry_set_text(GTK_ENTRY(wizard->recv_username), text);
919 if (protocol == A_POP3) {
920 text = get_default_server(wizard, "pop");
921 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
923 } else if (protocol == A_IMAP4) {
924 text = get_default_server(wizard, "imap");
925 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
927 } else if (protocol == A_LOCAL) {
928 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), tmpl.mboxfile?tmpl.mboxfile:"");
933 static GtkWidget* user_page (WizardWindow * wizard)
935 GtkWidget *table = gtk_table_new(1,1, FALSE);
939 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
940 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
942 vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
943 gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
945 gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2,
946 GTK_EXPAND|GTK_FILL, 0, 0, 0);
948 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
949 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
950 wizard->full_name = gtk_entry_new();
951 gtk_entry_set_text(GTK_ENTRY(wizard->full_name), tmpl.name?tmpl.name:"");
952 PACK_BOX(hbox, _("<span weight=\"bold\">Your name:</span>"),
955 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
956 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
957 wizard->email = gtk_entry_new();
958 gtk_entry_set_text(GTK_ENTRY(wizard->email), tmpl.email?tmpl.email:"");
959 PACK_BOX(hbox, _("<span weight=\"bold\">Your email address:</span>"),
962 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
963 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
964 wizard->organization = gtk_entry_new();
965 gtk_entry_set_text(GTK_ENTRY(wizard->organization), tmpl.organization?tmpl.organization:"");
966 PACK_BOX(hbox, _("Your organization:"), wizard->organization);
968 g_signal_connect(G_OBJECT(wizard->email), "changed",
969 G_CALLBACK(wizard_email_changed),
975 static void wizard_vol_mount_cb(GnomeVFSVolumeMonitor *vfs, GnomeVFSVolume *vol, WizardWindow *wizard)
977 gchar *uri = gnome_vfs_volume_get_activation_uri (vol);
978 gchar *mount_path = uri?gnome_vfs_get_local_path_from_uri (uri):NULL;
981 if(!strcmp(mount_path, MMC1_PATH)) {
982 gtk_widget_set_sensitive(wizard->data_root_mmc1_radiobtn, TRUE);
984 if(!strcmp(mount_path, MMC2_PATH)) {
985 gtk_widget_set_sensitive(wizard->data_root_mmc2_radiobtn, TRUE);
990 static void wizard_vol_unmount_cb(GnomeVFSVolumeMonitor *vfs, GnomeVFSVolume *vol, WizardWindow *wizard)
992 gchar *uri = gnome_vfs_volume_get_activation_uri (vol);
993 gchar *mount_path = uri?gnome_vfs_get_local_path_from_uri (uri):NULL;
996 if(!strcmp(mount_path, MMC1_PATH)) {
997 gtk_widget_set_sensitive(wizard->data_root_mmc1_radiobtn, FALSE);
998 if (gtk_toggle_button_get_active(
999 GTK_TOGGLE_BUTTON(wizard->data_root_mmc1_radiobtn))) {
1000 gtk_toggle_button_set_active(
1001 GTK_TOGGLE_BUTTON(wizard->data_root_nokia_radiobtn), TRUE);
1004 if(!strcmp(mount_path, MMC2_PATH)) {
1005 gtk_widget_set_sensitive(wizard->data_root_mmc2_radiobtn, FALSE);
1006 if (gtk_toggle_button_get_active(
1007 GTK_TOGGLE_BUTTON(wizard->data_root_mmc2_radiobtn))) {
1008 gtk_toggle_button_set_active(
1009 GTK_TOGGLE_BUTTON(wizard->data_root_nokia_radiobtn), TRUE);
1016 void data_root_changed (GtkToggleButton *toggle_btn,
1017 WizardWindow *wizard)
1019 gchar *name = g_path_get_basename(gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name)));
1021 if (gtk_toggle_button_get_active(
1022 GTK_TOGGLE_BUTTON(wizard->data_root_nokia_radiobtn)))
1023 gtk_entry_set_text(GTK_ENTRY(wizard->mailbox_name), name);
1024 else if (gtk_toggle_button_get_active(
1025 GTK_TOGGLE_BUTTON(wizard->data_root_mmc1_radiobtn))) {
1026 path = g_strconcat(MMC1_PATH, G_DIR_SEPARATOR_S,
1027 "Claws", G_DIR_SEPARATOR_S,
1028 g_get_user_name(), G_DIR_SEPARATOR_S,
1030 gtk_entry_set_text(GTK_ENTRY(wizard->mailbox_name), path);
1032 } else if (gtk_toggle_button_get_active(
1033 GTK_TOGGLE_BUTTON(wizard->data_root_mmc2_radiobtn))) {
1034 path = g_strconcat(MMC2_PATH, G_DIR_SEPARATOR_S,
1035 "Claws", G_DIR_SEPARATOR_S,
1036 g_get_user_name(), G_DIR_SEPARATOR_S,
1038 gtk_entry_set_text(GTK_ENTRY(wizard->mailbox_name), path);
1045 static GtkWidget* mailbox_page (WizardWindow * wizard)
1047 GtkWidget *table = gtk_table_new(1,1, FALSE);
1051 gchar *uri, *mount_path;
1054 GtkTooltips *tips = gtk_tooltips_new();
1056 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
1057 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
1059 vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
1060 gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
1062 gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2,
1063 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1065 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1066 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1068 wizard->mailbox_label = gtk_label_new(_("<span weight=\"bold\">Mailbox name:</span>"));
1069 gtk_label_set_use_markup(GTK_LABEL(wizard->mailbox_label), TRUE);
1070 if (GTK_IS_MISC(wizard->mailbox_label))
1071 gtk_misc_set_alignment(GTK_MISC(wizard->mailbox_label), 1, 0.5);
1072 wizard->mailbox_name = gtk_entry_new();
1074 gtk_entry_set_text(GTK_ENTRY(wizard->mailbox_name), tmpl.mailbox?tmpl.mailbox:"");
1076 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips), wizard->mailbox_name,
1077 _("You can also specify an absolute path, for example: "
1078 "\"/home/john/Documents/Mail\""),
1081 gtk_box_pack_start(GTK_BOX(hbox), wizard->mailbox_label, FALSE, FALSE, 0);
1082 gtk_box_pack_start(GTK_BOX(hbox), wizard->mailbox_name, TRUE, TRUE, 0);
1085 wizard->data_root_nokia_radiobtn = gtk_radio_button_new_with_label(NULL,
1086 _("on internal memory"));
1087 wizard->data_root_mmc1_radiobtn = gtk_radio_button_new_with_label_from_widget(
1088 GTK_RADIO_BUTTON(wizard->data_root_nokia_radiobtn),
1089 _("on /media/mmc1"));
1090 wizard->data_root_mmc2_radiobtn = gtk_radio_button_new_with_label_from_widget(
1091 GTK_RADIO_BUTTON(wizard->data_root_nokia_radiobtn),
1092 _("on /media/mmc2"));
1094 g_signal_connect(G_OBJECT(wizard->data_root_nokia_radiobtn), "toggled",
1095 G_CALLBACK(data_root_changed), wizard);
1096 g_signal_connect(G_OBJECT(wizard->data_root_mmc1_radiobtn), "toggled",
1097 G_CALLBACK(data_root_changed), wizard);
1098 g_signal_connect(G_OBJECT(wizard->data_root_mmc2_radiobtn), "toggled",
1099 G_CALLBACK(data_root_changed), wizard);
1101 wizard->volmon = gnome_vfs_get_volume_monitor();
1102 wizard->vol_mmc1 = gnome_vfs_volume_monitor_get_volume_for_path(wizard->volmon, MMC1_PATH);
1103 wizard->vol_mmc2 = gnome_vfs_volume_monitor_get_volume_for_path(wizard->volmon, MMC2_PATH);
1105 uri = gnome_vfs_volume_get_activation_uri (wizard->vol_mmc1);
1106 mount_path = uri?gnome_vfs_get_local_path_from_uri (uri):NULL;
1108 if (wizard->vol_mmc1 == NULL || !gnome_vfs_volume_is_mounted(wizard->vol_mmc1)
1109 || strcmp(mount_path, MMC1_PATH)) {
1110 gtk_widget_set_sensitive(wizard->data_root_mmc1_radiobtn, FALSE);
1114 uri = gnome_vfs_volume_get_activation_uri (wizard->vol_mmc2);
1115 mount_path = uri?gnome_vfs_get_local_path_from_uri (uri):NULL;
1117 if (wizard->vol_mmc2 == NULL || !gnome_vfs_volume_is_mounted(wizard->vol_mmc2)
1118 || strcmp(mount_path, MMC2_PATH)) {
1119 gtk_widget_set_sensitive(wizard->data_root_mmc2_radiobtn, FALSE);
1123 gnome_vfs_volume_unref(wizard->vol_mmc1);
1124 gnome_vfs_volume_unref(wizard->vol_mmc2);
1125 wizard->vol_mmc1 = NULL;
1126 wizard->vol_mmc2 = NULL;
1128 wizard->volmon_mount_sigid = g_signal_connect(G_OBJECT(wizard->volmon),
1129 "volume-mounted", G_CALLBACK(wizard_vol_mount_cb), wizard);
1130 wizard->volmon_unmount_sigid = g_signal_connect(G_OBJECT(wizard->volmon),
1131 "volume-unmounted", G_CALLBACK(wizard_vol_unmount_cb), wizard);
1133 vbox2 = gtk_vbox_new(FALSE, VSPACING_NARROW);
1134 gtk_box_pack_start (GTK_BOX(vbox2), wizard->data_root_nokia_radiobtn, FALSE, FALSE, 0);
1135 gtk_box_pack_start (GTK_BOX(vbox2), wizard->data_root_mmc1_radiobtn, FALSE, FALSE, 0);
1136 gtk_box_pack_start (GTK_BOX(vbox2), wizard->data_root_mmc2_radiobtn, FALSE, FALSE, 0);
1138 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1139 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1140 PACK_BOX(hbox, _("<span weight=\"bold\">Store data</span>"),
1147 static void smtp_auth_changed (GtkWidget *btn, gpointer data)
1149 WizardWindow *wizard = (WizardWindow *)data;
1150 gboolean do_auth = gtk_toggle_button_get_active(
1151 GTK_TOGGLE_BUTTON(wizard->smtp_auth));
1152 gtk_widget_set_sensitive(wizard->smtp_username, do_auth);
1153 gtk_widget_set_sensitive(wizard->smtp_username_label, do_auth);
1154 gtk_widget_set_sensitive(wizard->smtp_password, do_auth);
1155 gtk_widget_set_sensitive(wizard->smtp_password_label, do_auth);
1158 static GtkWidget* smtp_page (WizardWindow * wizard)
1160 GtkWidget *table = gtk_table_new(1, 1, FALSE);
1163 GtkTooltips *tips = gtk_tooltips_new();
1166 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
1167 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
1169 vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
1170 gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
1172 gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2,
1173 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1175 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1176 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1177 wizard->smtp_server = gtk_entry_new();
1178 text = get_default_server(wizard, "smtp");
1179 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_server), text);
1182 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips), wizard->smtp_server,
1183 _("You can specify the port number by appending it at the end: "
1184 "\"mail.example.com:25\""),
1187 PACK_BOX(hbox, _("<span weight=\"bold\">SMTP server address:</span>"),
1188 wizard->smtp_server);
1191 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1192 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1193 wizard->smtp_auth = gtk_check_button_new_with_label(
1194 _("Use authentication"));
1195 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->smtp_auth),
1197 g_signal_connect(G_OBJECT(wizard->smtp_auth), "toggled",
1198 G_CALLBACK(smtp_auth_changed),
1200 gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_auth, FALSE, FALSE, 0);
1202 text = get_default_smtp_account(wizard);
1204 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1205 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1206 wizard->smtp_username = gtk_entry_new();
1207 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_username), text);
1209 wizard->smtp_username_label = gtk_label_new(_("SMTP username:\n"
1210 "<span size=\"small\">(empty to use the same as receive)</span>"));
1211 gtk_label_set_use_markup(GTK_LABEL(wizard->smtp_username_label), TRUE);
1212 if (GTK_IS_MISC(wizard->smtp_username_label))
1213 gtk_misc_set_alignment(GTK_MISC(wizard->smtp_username_label), 1, 0.5);
1214 gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_username_label, FALSE, FALSE, 0);
1215 gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_username, TRUE, TRUE, 0);
1217 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1218 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1219 wizard->smtp_password = gtk_entry_new();
1220 gtk_entry_set_text(GTK_ENTRY(wizard->smtp_password), tmpl.smtppass?tmpl.smtppass:"");
1221 gtk_entry_set_visibility(GTK_ENTRY(wizard->smtp_password), FALSE);
1222 wizard->smtp_password_label = gtk_label_new(_("SMTP password:\n"
1223 "<span size=\"small\">(empty to use the same as receive)</span>"));
1224 gtk_label_set_use_markup(GTK_LABEL(wizard->smtp_password_label), TRUE);
1225 if (GTK_IS_MISC(wizard->smtp_password_label))
1226 gtk_misc_set_alignment(GTK_MISC(wizard->smtp_password_label), 1, 0.5);
1227 gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_password_label, FALSE, FALSE, 0);
1228 gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_password, TRUE, TRUE, 0);
1229 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
1230 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1231 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1232 wizard->smtp_use_ssl = gtk_check_button_new_with_label(
1233 _("Use SSL to connect to SMTP server"));
1234 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_ssl),
1236 gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_use_ssl, FALSE, FALSE, 0);
1238 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1239 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1240 wizard->smtp_use_tls = gtk_check_button_new_with_label(
1241 _("Use SSL via STARTTLS"));
1242 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_tls),
1244 gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_use_tls, FALSE, FALSE, 0);
1245 SET_TOGGLE_SENSITIVITY (wizard->smtp_use_ssl, wizard->smtp_use_tls);
1247 smtp_auth_changed(NULL, wizard);
1251 static void wizard_protocol_change(WizardWindow *wizard, RecvProtocol protocol)
1255 if (protocol == A_POP3) {
1256 text = get_default_server(wizard, "pop");
1257 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
1258 gtk_widget_hide(wizard->recv_imap_label);
1259 gtk_widget_hide(wizard->recv_imap_subdir);
1260 gtk_widget_hide(wizard->subsonly_checkbtn);
1261 gtk_widget_show(wizard->recv_username);
1262 gtk_widget_show(wizard->recv_password);
1263 gtk_widget_show(wizard->recv_username_label);
1264 gtk_widget_show(wizard->recv_password_label);
1265 gtk_widget_hide(wizard->no_imap_warning);
1266 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
1267 gtk_widget_show(wizard->recv_use_ssl);
1268 gtk_widget_show(wizard->recv_use_tls);
1270 gtk_label_set_text(GTK_LABEL(wizard->recv_label), _("<span weight=\"bold\">Server address:</span>"));
1271 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
1272 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, TRUE);
1274 if (wizard->create_mailbox) {
1275 gtk_widget_show(wizard->mailbox_label);
1276 gtk_widget_show(wizard->mailbox_name);
1278 } else if (protocol == A_IMAP4) {
1279 #ifdef HAVE_LIBETPAN
1280 text = get_default_server(wizard, "imap");
1281 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
1282 gtk_widget_show(wizard->recv_imap_label);
1283 gtk_widget_show(wizard->recv_imap_subdir);
1284 gtk_widget_show(wizard->subsonly_checkbtn);
1285 gtk_widget_show(wizard->recv_username);
1286 gtk_widget_show(wizard->recv_password);
1287 gtk_widget_show(wizard->recv_username_label);
1288 gtk_widget_show(wizard->recv_password_label);
1289 gtk_widget_hide(wizard->no_imap_warning);
1290 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
1291 gtk_widget_show(wizard->recv_use_ssl);
1292 gtk_widget_show(wizard->recv_use_tls);
1294 gtk_label_set_text(GTK_LABEL(wizard->recv_label), _("<span weight=\"bold\">Server address:</span>"));
1295 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
1296 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, TRUE);
1298 if (wizard->create_mailbox) {
1299 gtk_widget_hide(wizard->mailbox_label);
1300 gtk_widget_hide(wizard->mailbox_name);
1303 gtk_widget_hide(wizard->recv_imap_label);
1304 gtk_widget_hide(wizard->recv_imap_subdir);
1305 gtk_widget_hide(wizard->subsonly_checkbtn);
1306 gtk_widget_hide(wizard->recv_username);
1307 gtk_widget_hide(wizard->recv_password);
1308 gtk_widget_hide(wizard->recv_username_label);
1309 gtk_widget_hide(wizard->recv_password_label);
1310 gtk_widget_show(wizard->no_imap_warning);
1311 if (wizard->create_mailbox) {
1312 gtk_widget_hide(wizard->mailbox_label);
1313 gtk_widget_hide(wizard->mailbox_name);
1315 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
1316 gtk_widget_hide(wizard->recv_use_ssl);
1317 gtk_widget_hide(wizard->recv_use_tls);
1319 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, FALSE);
1321 } else if (protocol == A_LOCAL) {
1322 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), tmpl.mboxfile?tmpl.mboxfile:"");
1323 gtk_label_set_text(GTK_LABEL(wizard->recv_label), _("<span weight=\"bold\">Local mailbox:</span>"));
1324 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
1325 gtk_widget_hide(wizard->no_imap_warning);
1326 gtk_widget_hide(wizard->recv_imap_label);
1327 gtk_widget_hide(wizard->recv_imap_subdir);
1328 gtk_widget_hide(wizard->subsonly_checkbtn);
1329 gtk_widget_hide(wizard->recv_username);
1330 gtk_widget_hide(wizard->recv_password);
1331 gtk_widget_hide(wizard->recv_username_label);
1332 gtk_widget_hide(wizard->recv_password_label);
1333 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
1334 gtk_widget_hide(wizard->recv_use_ssl);
1335 gtk_widget_hide(wizard->recv_use_tls);
1337 if (wizard->create_mailbox) {
1338 gtk_widget_show(wizard->mailbox_label);
1339 gtk_widget_show(wizard->mailbox_name);
1341 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, TRUE);
1345 static void wizard_protocol_changed(GtkComboBox *combo, gpointer data)
1347 WizardWindow *wizard = (WizardWindow *)data;
1348 RecvProtocol protocol = combobox_get_active_data(combo);
1350 wizard_protocol_change(wizard, protocol);
1353 static GtkWidget* recv_page (WizardWindow * wizard)
1355 GtkWidget *table = gtk_table_new(1,1, FALSE);
1356 GtkTooltips *tips = gtk_tooltips_new();
1359 GtkListStore *store;
1364 gtk_table_set_row_spacings(GTK_TABLE(table), 4);
1365 gtk_table_set_col_spacings(GTK_TABLE(table), 8);
1367 vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
1368 gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
1370 gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2,
1371 GTK_EXPAND|GTK_FILL, 0, 0, 0);
1373 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1374 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1375 wizard->recv_type = gtkut_sc_combobox_create(NULL, FALSE);
1376 store = GTK_LIST_STORE(gtk_combo_box_get_model(
1377 GTK_COMBO_BOX(wizard->recv_type)));
1379 COMBOBOX_ADD(store, _("POP3"), A_POP3);
1380 COMBOBOX_ADD(store, _("IMAP"), A_IMAP4);
1381 COMBOBOX_ADD(store, _("Local mbox file"), A_LOCAL);
1383 switch(tmpl.recvtype) {
1396 gtk_combo_box_set_active(GTK_COMBO_BOX (wizard->recv_type), index);
1397 g_signal_connect(G_OBJECT(wizard->recv_type), "changed",
1398 G_CALLBACK(wizard_protocol_changed),
1400 PACK_BOX(hbox, _("<span weight=\"bold\">Server type:</span>"),
1403 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1404 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1405 wizard->recv_server = gtk_entry_new();
1406 text = get_default_server(wizard, "pop");
1407 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
1410 gtk_tooltips_set_tip(GTK_TOOLTIPS(tips), wizard->recv_server,
1411 _("You can specify the port number by appending it at the end: "
1412 "\"mail.example.com:110\""),
1415 wizard->recv_label = gtk_label_new(_("<span weight=\"bold\">Server address:</span>"));
1416 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
1417 if (GTK_IS_MISC(wizard->recv_label))
1418 gtk_misc_set_alignment(GTK_MISC(wizard->recv_label), 1, 0.5);
1419 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_label, FALSE, FALSE, 0);
1420 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_server, TRUE, TRUE, 0);
1422 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1423 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1424 wizard->recv_username = gtk_entry_new();
1425 wizard->recv_username_label = gtk_label_new(_("<span weight=\"bold\">Username:</span>"));
1426 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_username_label), TRUE);
1427 if (GTK_IS_MISC(wizard->recv_username_label))
1428 gtk_misc_set_alignment(GTK_MISC(wizard->recv_username_label), 1, 0.5);
1429 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_username_label, FALSE, FALSE, 0);
1430 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_username, TRUE, TRUE, 0);
1432 text = get_default_account(wizard);
1433 gtk_entry_set_text(GTK_ENTRY(wizard->recv_username), text);
1436 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1437 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1438 wizard->recv_password = gtk_entry_new();
1439 gtk_entry_set_text(GTK_ENTRY(wizard->recv_password), tmpl.recvpass?tmpl.recvpass:"");
1440 wizard->recv_password_label = gtk_label_new(_("Password:"));
1441 if (GTK_IS_MISC(wizard->recv_password_label))
1442 gtk_misc_set_alignment(GTK_MISC(wizard->recv_password_label), 1, 0.5);
1443 gtk_entry_set_visibility(GTK_ENTRY(wizard->recv_password), FALSE);
1444 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_password_label, FALSE, FALSE, 0);
1445 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_password, TRUE, TRUE, 0);
1447 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
1448 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1449 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1450 wizard->recv_use_ssl = gtk_check_button_new_with_label(
1451 _("Use SSL to connect to receiving server"));
1452 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->recv_use_ssl),
1454 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_use_ssl, FALSE, FALSE, 0);
1456 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1457 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1458 wizard->recv_use_tls = gtk_check_button_new_with_label(
1459 _("Use SSL via STARTTLS"));
1460 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->recv_use_tls),
1462 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_use_tls, FALSE, FALSE, 0);
1463 SET_TOGGLE_SENSITIVITY (wizard->recv_use_ssl, wizard->recv_use_tls);
1465 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1466 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1467 wizard->recv_imap_subdir = gtk_entry_new();
1468 gtk_entry_set_text(GTK_ENTRY(wizard->recv_imap_subdir), tmpl.imapdir?tmpl.imapdir:"");
1469 wizard->recv_imap_label = gtk_label_new(_("IMAP server directory:"));
1470 if (GTK_IS_MISC(wizard->recv_imap_label))
1471 gtk_misc_set_alignment(GTK_MISC(wizard->recv_imap_label), 1, 0.5);
1472 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_imap_label, FALSE, FALSE, 0);
1473 gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_imap_subdir, TRUE, TRUE, 0);
1475 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1476 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1477 wizard->subsonly_checkbtn = gtk_check_button_new_with_label(
1478 _("Show only subscribed folders"));
1479 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->subsonly_checkbtn),
1481 gtk_box_pack_start(GTK_BOX(hbox), wizard->subsonly_checkbtn, FALSE, FALSE, 0);
1483 hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1484 gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1485 wizard->no_imap_warning = gtk_label_new(_(
1486 "<span weight=\"bold\">Warning: this version of Claws Mail\n"
1487 "has been built without IMAP support.</span>"));
1488 gtk_label_set_use_markup(GTK_LABEL(wizard->no_imap_warning), TRUE);
1489 gtk_box_pack_start(GTK_BOX(hbox), wizard->no_imap_warning, FALSE, FALSE, 0);
1495 wizard_response_cb (GtkDialog * dialog, int response, gpointer data)
1497 WizardWindow * wizard = (WizardWindow *)data;
1498 int current_page, num_pages;
1499 gboolean skip_mailbox_page = FALSE;
1501 gint protocol = combobox_get_active_data(GTK_COMBO_BOX(wizard->recv_type));
1503 if (protocol == A_IMAP4) {
1504 skip_mailbox_page = TRUE;
1508 num_pages = g_slist_length(wizard->pages);
1510 current_page = gtk_notebook_get_current_page (
1511 GTK_NOTEBOOK(wizard->notebook));
1512 if (response == CANCEL)
1514 wizard->result = FALSE;
1515 wizard->finished = TRUE;
1516 gtk_widget_destroy (GTK_WIDGET(dialog));
1518 else if (response == FINISHED)
1520 if (!wizard_write_config(wizard)) {
1521 current_page = gtk_notebook_get_current_page (
1522 GTK_NOTEBOOK(wizard->notebook));
1525 wizard->result = TRUE;
1526 wizard->finished = TRUE;
1527 gtk_widget_destroy (GTK_WIDGET(dialog));
1531 if (response == GO_BACK)
1533 if (current_page > 0) {
1535 if (current_page == MAILBOX_PAGE && skip_mailbox_page) {
1539 gtk_notebook_set_current_page (
1540 GTK_NOTEBOOK(wizard->notebook),
1544 else if (response == GO_FORWARD)
1546 if (current_page < (num_pages-1)) {
1548 if (current_page == MAILBOX_PAGE && skip_mailbox_page) {
1552 gtk_notebook_set_current_page (
1553 GTK_NOTEBOOK(wizard->notebook),
1558 gtk_dialog_set_response_sensitive (dialog, GO_BACK,
1560 gtk_dialog_set_response_sensitive (dialog, GO_FORWARD,
1561 current_page < (num_pages - 1));
1562 if (current_page == (num_pages -1)) {
1563 gtk_dialog_set_response_sensitive (dialog, FINISHED, TRUE);
1564 gtk_dialog_set_default_response(GTK_DIALOG(wizard->window), FINISHED);
1566 gtk_dialog_set_response_sensitive (dialog, FINISHED, FALSE);
1567 gtk_dialog_set_default_response(GTK_DIALOG(wizard->window), GO_FORWARD);
1573 static gint wizard_close_cb(GtkWidget *widget, GdkEventAny *event,
1576 WizardWindow *wizard = (WizardWindow *)data;
1577 wizard->result = FALSE;
1578 wizard->finished = TRUE;
1583 #define PACK_WARNING(text) { \
1584 label = gtk_label_new(text); \
1585 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); \
1586 gtk_box_pack_end(GTK_BOX(widget), label, FALSE, FALSE, 0); \
1589 gboolean run_wizard(MainWindow *mainwin, gboolean create_mailbox) {
1590 WizardWindow *wizard = g_new0(WizardWindow, 1);
1594 GtkWidget *scrolled_window;
1599 wizard->mainwin = mainwin;
1600 wizard->create_mailbox = create_mailbox;
1602 gtk_widget_hide(mainwin->window);
1604 wizard_read_defaults();
1606 wizard->window = gtk_dialog_new_with_buttons (_("Claws Mail Setup Wizard"),
1608 GTK_STOCK_GO_BACK, GO_BACK,
1609 GTK_STOCK_GO_FORWARD, GO_FORWARD,
1610 GTK_STOCK_SAVE, FINISHED,
1611 GTK_STOCK_CANCEL, CANCEL,
1614 g_signal_connect(wizard->window, "response",
1615 G_CALLBACK(wizard_response_cb), wizard);
1616 gtk_widget_realize(wizard->window);
1617 gtk_dialog_set_default_response(GTK_DIALOG(wizard->window),
1619 gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window),
1621 gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window),
1623 gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window),
1625 gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window),
1628 wizard->notebook = gtk_notebook_new();
1629 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(wizard->notebook), FALSE);
1630 gtk_notebook_set_show_border(GTK_NOTEBOOK(wizard->notebook), FALSE);
1631 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(wizard->window)->vbox),
1632 wizard->notebook, TRUE, TRUE, 0);
1634 wizard->pages = NULL;
1636 /*welcome page: 0 */
1638 page = create_page(wizard, _("Welcome to Claws Mail"));
1640 wizard->pages = g_slist_append(wizard->pages, page);
1641 widget = stock_pixmap_widget(wizard->window,
1642 STOCK_PIXMAP_CLAWS_MAIL_LOGO);
1644 gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1646 text = g_strdup(_("Welcome to the Claws Mail setup wizard.\n\n"
1647 "We will begin by defining some basic "
1648 "information about you and your most common "
1649 "mail options so that you can start to use "
1650 "Claws Mail in less than five minutes."));
1651 widget = gtk_label_new(text);
1652 gtk_label_set_line_wrap(GTK_LABEL(widget), TRUE);
1654 gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1656 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
1657 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
1658 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1659 gtk_box_pack_start(GTK_BOX(page), scrolled_window, TRUE, TRUE, 0);
1661 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1669 widget = create_page (wizard, _("About You"));
1670 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
1671 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
1672 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1673 gtk_box_pack_start(GTK_BOX(widget), scrolled_window, TRUE, TRUE, 0);
1675 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1677 PACK_WARNING(_("Bold fields must be completed"));
1679 wizard->pages = g_slist_append(wizard->pages, widget);
1681 /* recv+auth page: 2 */
1684 widget = create_page (wizard, _("Receiving mail"));
1685 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
1686 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
1687 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1688 gtk_box_pack_start(GTK_BOX(widget), scrolled_window, TRUE, TRUE, 0);
1690 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1692 PACK_WARNING(_("Bold fields must be completed"));
1694 wizard->pages = g_slist_append(wizard->pages, widget);
1699 widget = create_page (wizard, _("Sending mail"));
1700 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
1701 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
1702 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1703 gtk_box_pack_start(GTK_BOX(widget), scrolled_window, TRUE, TRUE, 0);
1705 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1707 PACK_WARNING(_("Bold fields must be completed"));
1709 wizard->pages = g_slist_append(wizard->pages, widget);
1711 /* mailbox page: 4 */
1712 if (create_mailbox) {
1715 widget = create_page (wizard, _("Saving mail on disk"));
1716 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
1717 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
1718 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1719 gtk_box_pack_start(GTK_BOX(widget), scrolled_window, TRUE, TRUE, 0);
1721 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1722 mailbox_page(wizard));
1723 PACK_WARNING(_("Bold fields must be completed"));
1725 wizard->pages = g_slist_append(wizard->pages, widget);
1731 page = create_page(wizard, _("Configuration finished"));
1733 wizard->pages = g_slist_append(wizard->pages, page);
1734 widget = stock_pixmap_widget(wizard->window,
1735 STOCK_PIXMAP_CLAWS_MAIL_LOGO);
1737 gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1739 text = g_strdup(_("Claws Mail is now ready.\n"
1740 "Click Save to start."));
1741 widget = gtk_label_new(text);
1742 gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1746 for (cur = wizard->pages; cur && cur->data; cur = cur->next) {
1747 gtk_notebook_append_page (GTK_NOTEBOOK(wizard->notebook),
1748 GTK_WIDGET(cur->data), NULL);
1751 g_signal_connect(G_OBJECT(wizard->window), "delete_event",
1752 G_CALLBACK(wizard_close_cb), wizard);
1753 gtk_widget_show_all (wizard->window);
1755 gtk_widget_hide(wizard->recv_imap_label);
1756 gtk_widget_hide(wizard->recv_imap_subdir);
1757 gtk_widget_hide(wizard->subsonly_checkbtn);
1759 wizard_protocol_change(wizard, tmpl.recvtype);
1761 while (!wizard->finished)
1762 gtk_main_iteration();
1764 result = wizard->result;
1768 gtk_widget_show(mainwin->window);