2008-07-05 [colin] 3.5.0cvs12
[claws.git] / src / wizard.c
1 /*
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
5  *
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.
10  *
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.
15  *
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/>.
18  * 
19  */
20
21 #ifdef HAVE_CONFIG_H
22 #  include "config.h"
23 #endif
24
25 #include "defs.h"
26
27 #include <glib.h>
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>
39 #include <gtk/gtk.h>
40
41 #include <stdio.h>
42 #include <stdlib.h>
43 #include <string.h>
44 #include <ctype.h>
45
46 #ifdef HAVE_CONFIG_H
47 #  include "config.h"
48 #endif
49
50 #include "utils.h"
51 #include "gtk/menu.h"
52 #include "plugin.h"
53 #include "account.h"
54 #include "prefs_account.h"
55 #include "mainwindow.h"
56 #include "stock_pixmap.h"
57 #include "setup.h"
58 #include "folder.h"
59 #include "alertpanel.h"
60 #include "filesel.h"
61 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
62 #include "ssl.h"
63 #endif
64 #include "prefs_common.h"
65 #include "combobox.h"
66
67 #ifdef MAEMO
68 #include <libgnomevfs/gnome-vfs-volume.h>
69 #include <libgnomevfs/gnome-vfs-volume-monitor.h>
70 #include <libgnomevfs/gnome-vfs-utils.h>
71 #endif
72
73 typedef enum
74 {
75         GO_BACK,
76         GO_FORWARD,
77         CANCEL,
78         FINISHED
79 } PageNavigation;
80
81 int WELCOME_PAGE = -1;
82 int USER_PAGE = -1;
83 int SMTP_PAGE = -1;
84 int RECV_PAGE = -1;
85 int MAILBOX_PAGE = -1;
86 int DONE_PAGE = -1;
87
88 typedef struct
89 {
90         GtkWidget *window;
91         GSList    *pages;
92         GtkWidget *notebook;
93
94         MainWindow *mainwin;
95         
96         GtkWidget *email;
97         GtkWidget *full_name;
98         GtkWidget *organization;
99
100         GtkWidget *mailbox_name;
101         GtkWidget *mailbox_label;
102         
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;
109
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;
132 #endif
133
134 #ifdef MAEMO
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;
143 #endif  
144         gboolean create_mailbox;
145         gboolean finished;
146         gboolean result;
147
148 } WizardWindow;
149
150 typedef struct _AccountTemplate {
151         gchar *name;
152         gchar *domain;
153         gchar *email;
154         gchar *organization;
155         gchar *smtpserver;
156         gboolean smtpauth;
157         gchar *smtpuser;
158         gchar *smtppass;
159         RecvProtocol recvtype;
160         gchar *recvserver;
161         gchar *recvuser;
162         gchar *recvpass;
163         gchar *imapdir;
164         gboolean subsonly;
165         gchar *mboxfile;
166         gchar *mailbox;
167         gboolean smtpssl;
168         gboolean recvssl;
169         gchar *smtpssl_cert;
170         gchar *recvssl_cert;
171         gchar *smtpssl_cert_pass;
172         gchar *recvssl_cert_pass;
173 } AccountTemplate;
174
175 static AccountTemplate tmpl;
176
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},
184         {"organization", "",
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},
190         {"smtpuser", "",
191          &tmpl.smtpuser, P_STRING, NULL, NULL, NULL},
192         {"smtppass", "",
193          &tmpl.smtppass, P_STRING, NULL, NULL, NULL},
194         {"recvtype", A_POP3,
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},
200         {"recvpass", "",
201          &tmpl.recvpass, P_STRING, NULL, NULL, NULL},
202         {"imapdir", "",
203          &tmpl.imapdir, P_STRING, NULL, NULL, NULL},
204         {"subsonly", "TRUE",
205          &tmpl.subsonly, P_BOOL, NULL, NULL, NULL},
206         {"mboxfile", "/var/mail/$LOGIN",
207          &tmpl.mboxfile, P_STRING, NULL, NULL, NULL},
208         {"mailbox", "Mail",
209          &tmpl.mailbox, P_STRING, NULL, NULL, NULL},
210         {"smtpssl", "0",
211          &tmpl.smtpssl, P_INT, NULL, NULL, NULL},
212         {"recvssl", "0",
213          &tmpl.recvssl, P_INT, NULL, NULL, NULL},
214         {"smtpssl_cert", "",
215          &tmpl.smtpssl_cert, P_STRING, NULL, NULL, NULL},
216         {"recvssl_cert", "",
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}
223 };
224
225
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"
231         "#domain=\n"
232         "\n"
233         "#you can use $USERNAME for name (this is the default)\n"
234         "#name=\n"
235         "\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"
238         "#of spaces\n"
239         "#the default is $NAME_MAIL@$DOMAIN\n"
240         "#email=\n"
241         "\n"
242         "#you can use $DOMAIN here\n"
243         "#the default organization is empty\n"
244         "#organization=\n"
245         "\n"
246         "#you can use $DOMAIN here \n"
247         "#the default is smtp.$DOMAIN\n"
248         "#smtpserver=\n"
249         "\n"
250         "#Whether to use smtp authentication\n"
251         "#the default is 0 (no)\n"
252         "#smtpauth=\n"
253         "\n"
254         "#SMTP username\n"
255         "#you can use $LOGIN, $NAME_MAIL, $DOMAIN or $EMAIL here\n"
256         "#the default is empty (same as reception username)\n"
257         "#smtpuser=\n"
258         "\n"
259         "#SMTP password\n"
260         "#the default is empty (same as reception password)\n"
261         "#smtppass=\n"
262         "\n"
263         "#recvtype can be:\n"
264         "#0 for pop3\n"
265         "#3  for imap\n"
266         "#5  for a local mbox file\n"
267         "#recvtype=\n"
268         "\n"
269         "#you can use $DOMAIN here \n"
270         "#the default is {pop,imap}.$DOMAIN\n"
271         "#recvserver=\n"
272         "\n"
273         "#you can use $LOGIN, $NAME_MAIL, $DOMAIN or $EMAIL here\n"
274         "#default is $LOGIN\n"
275         "#recvuser=\n"
276         "\n"
277         "#default is empty\n"
278         "#recvpass=\n"
279         "\n"
280         "#imap dir if imap (relative to the home on the server)\n"
281         "#default is empty\n"
282         "#imapdir=\n"
283         "\n"
284         "#show subscribed folders only, if imap\n"
285         "#default is TRUE\n"
286         "#subsonly=\n"
287         "\n"
288         "#mbox file if local\n"
289         "#you can use $LOGIN here\n"
290         "#default is /var/mail/$LOGIN\n"
291         "#mboxfile=\n"
292         "\n"
293         "#mailbox name if pop3 or local\n"
294         "#relative path from the user's home\n"
295         "#default is \"Mail\"\n"
296         "#mailbox=\n"
297         "\n"
298         "#whether to use ssl on smtp connections\n"
299         "#default is 0, 1 is ssl, 2 is starttls\n"
300         "#smtpssl=\n"
301         "\n"
302         "#whether to use ssl on pop or imap connections\n"
303         "#default is 0, 1 is ssl, 2 is starttls\n"
304         "#recvssl=\n"
305         "\n"
306         "#SSL client certificate path for SMTP\n"
307         "#default is empty (no certificate)\n"
308         "#smtpssl_cert=\n"
309         "\n"
310         "#SSL client certificate path for POP/IMAP\n"
311         "#default is empty (no certificate)\n"
312         "#recvssl_cert=\n"
313         "\n"
314         "#SSL client certificate password for SMTP\n"
315         "#default is empty (no password)\n"
316         "#smtpssl_cert_pass=\n"
317         "\n"
318         "#SSL client certificate password for POP/IMAP\n"
319         "#default is empty (no password)\n"
320         "#recvssl_cert_pass=\n"
321         ;
322
323 static gchar *wizard_get_default_domain_name(void)
324 {
325         static gchar *domain_name = NULL;
326         
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);
332                         g_free(domain_name);
333                         domain_name = tmp;
334                 }
335         }
336         return domain_name;
337 }
338
339 static gchar *get_name_for_mail(void)
340 {
341         gchar *name = g_strdup(tmpl.name);
342         if (name == NULL)
343                 return NULL;
344         g_strdown(name);
345         while(strstr(name, " "))
346                 *strstr(name, " ")='.';
347         
348         return name;
349 }
350
351 #define PARSE_DEFAULT(str) {    \
352         gchar *tmp = NULL, *new = NULL; \
353         if (str != 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"),   \
360                                 NULL);  \
361                         g_free(tmp);    \
362                         g_free(str);    \
363                         str = new;      \
364                         new = NULL;     \
365                 }       \
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"),         \
371                                 NULL);  \
372                         g_free(tmp);    \
373                         g_free(str);    \
374                         str = new;      \
375                         new = NULL;     \
376                 }       \
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"),         \
382                                 NULL);  \
383                         g_free(tmp);    \
384                         g_free(str);    \
385                         str = new;      \
386                         new = NULL;     \
387                 }       \
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"),         \
393                                 NULL);  \
394                         g_free(tmp);    \
395                         g_free(str);    \
396                         str = new;      \
397                         new = NULL;     \
398                 }       \
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"),         \
404                                 NULL);  \
405                         g_free(tmp);    \
406                         g_free(str);    \
407                         str = new;      \
408                         new = NULL;     \
409                 }       \
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"),       \
415                                 NULL);  \
416                         g_free(tmp);    \
417                         g_free(str);    \
418                         str = new;      \
419                         new = NULL;     \
420                 }       \
421         }       \
422 }
423 static void wizard_read_defaults(void)
424 {
425         gchar *rcpath;
426
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);
430         }
431
432         prefs_read_config(template_params, "AccountTemplate", rcpath, NULL);
433
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);
447 /*
448         g_print("defaults:"
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);
453 */
454         g_free(rcpath);
455 }
456
457 static void initialize_fonts(WizardWindow *wizard)
458 {
459         GtkWidget *widget = wizard->email;
460         gint size = pango_font_description_get_size(
461                         widget->style->font_desc)
462                       /PANGO_SCALE;
463         gchar *tmp, *new;
464         
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;
471         }
472         g_free(tmp);
473         
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;
480         }
481         g_free(tmp);
482         
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;
489         }
490         g_free(tmp);
491
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;
498         }
499         g_free(tmp);
500 }
501
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\
515  ErkJggg=="
516
517 static void write_welcome_email(WizardWindow *wizard)
518 {
519         gchar buf_date[64];
520         gchar *head=NULL;
521         gchar *body=NULL;
522         gchar *msg=NULL;
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];
528         
529         get_rfc822_date(buf_date, sizeof(buf_date));
530
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);
540
541         head = g_strdup_printf(
542                 "From: %s <%s>\n"
543                 "To: %s <%s>\n"
544                 "Date: %s\n"
545                 "Subject: %s\n"
546                 "X-Face: %s\n"
547                 "Face: %s\n"
548                 "Content-Type: text/plain; charset=UTF-8\n",
549                 enc_from_name,
550                 USERS_ML_ADDR,
551                 enc_to_name,
552                 gtk_entry_get_text(GTK_ENTRY(wizard->email)),
553                 buf_date, enc_subject, XFACE, FACE);
554         body = g_strdup_printf(
555                 _("\n"
556                 "Welcome to Claws Mail\n"
557                 "---------------------\n"
558                 "\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"
561                 "toolbar.\n"
562                 "\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"
568                 "\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"
573                 "\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"
577                 "\n"
578                 "Useful URLs\n"
579                 "-----------\n"
580                 "Homepage:      <%s>\n"
581                 "Manual:        <%s>\n"
582                 "FAQ:          <%s>\n"
583                 "Themes:        <%s>\n"
584                 "Mailing Lists: <%s>\n"
585                 "\n"
586                 "LICENSE\n"
587                 "-------\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"
592                 "found at <%s>.\n"
593                 "\n"
594                 "DONATIONS\n"
595                 "---------\n"
596                 "If you wish to donate to the Claws Mail project you can do\n"
597                 "so at <%s>.\n\n"),
598                 HOMEPAGE_URI, MANUAL_URI, FAQ_URI, THEMES_URI, MAILING_LIST_URI,
599                 GPL_URI, DONATE_URI);
600         
601         msg = g_strconcat(head, body, NULL);
602
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);
607         }
608         g_free(head);
609         g_free(body);
610         g_free(msg);
611         claws_unlink(file);
612 }
613 #undef XFACE
614
615 static gboolean wizard_write_config(WizardWindow *wizard)
616 {
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;
624 #endif
625
626         prefs_account->protocol = combobox_get_active_data(
627                                         GTK_COMBO_BOX(wizard->recv_type));
628         
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), 
635                         MAILBOX_PAGE);
636                 return FALSE;
637         }
638
639 #ifdef MAEMO
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);
651         }
652 #endif
653
654         if (!mailbox_ok) {
655                 if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4) {
656                         mailbox_ok = setup_write_mailbox_path(wizard->mainwin, 
657                                         gtk_entry_get_text(
658                                                 GTK_ENTRY(wizard->mailbox_name)));
659                 } else
660                         mailbox_ok = TRUE;
661         }
662
663         if (!mailbox_ok) {
664                 /* alertpanel done by setup_write_mailbox_path */
665                 g_free(prefs_account);
666                 gtk_notebook_set_current_page (
667                         GTK_NOTEBOOK(wizard->notebook), 
668                         MAILBOX_PAGE);
669                 return FALSE;
670         }
671         
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), 
678                         USER_PAGE);
679                 return FALSE;
680         }
681         
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 "
686                                            "and username."));
687                         g_free(prefs_account);
688                         gtk_notebook_set_current_page (
689                                 GTK_NOTEBOOK(wizard->notebook), 
690                                 RECV_PAGE);
691                         return FALSE;
692                 }
693         } else {
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), 
699                                 RECV_PAGE);
700                         return FALSE;
701                 }
702         }
703         
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), 
709                         SMTP_PAGE);
710                 return FALSE;
711         }
712
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), 
720                                 SMTP_PAGE);
721                         return FALSE;           
722                 } /* if it's not local we'll use the reception server */
723         }
724
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)));
729         else
730                 prefs_account->account_name = g_strdup_printf("%s",
731                                 gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
732
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)));
735
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;
745                 }
746         }
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;
752         }
753         
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);
761
762         if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4) {
763                 gchar *tmp;
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))))
767                                 ?_("Mailbox"):tmp);
768                 g_free(tmp);
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());
774         }
775
776         if (prefs_account->protocol != A_LOCAL)
777                 prefs_account->recv_server = g_strdup(recv_server);
778         else
779                 prefs_account->local_mbox = g_strdup(recv_server);
780
781         g_free(recv_server);
782         g_free(smtp_server);
783
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)));
788
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;
795         }
796
797 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
798         smtp_ssl_type = SSL_NONE;
799         recv_ssl_type = SSL_NONE;       
800
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;
804                 else
805                         smtp_ssl_type = SSL_TUNNEL;
806         }
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;
810                 else
811                         recv_ssl_type = SSL_TUNNEL;
812         }
813
814         prefs_account->ssl_smtp = smtp_ssl_type;
815
816         if (prefs_account->protocol == A_IMAP4)
817                 prefs_account->ssl_imap = recv_ssl_type;
818         else
819                 prefs_account->ssl_pop = recv_ssl_type;
820
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)));
829 #endif
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);
835                 }
836                 prefs_account->imap_subsonly = 
837                         gtk_toggle_button_get_active(
838                                 GTK_TOGGLE_BUTTON(wizard->subsonly_checkbtn));
839                 g_free(directory);
840         }
841
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();
846
847         initialize_fonts(wizard);
848         if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4)
849                 write_welcome_email(wizard);
850
851 #ifdef MAEMO
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);
860 #endif
861
862 #ifndef G_OS_WIN32 
863         plugin_load_standard_plugins();
864 #endif
865         return TRUE;
866 }
867
868 static GtkWidget* create_page (WizardWindow *wizard, const char * title)
869 {
870         GtkWidget *w;
871         GtkWidget *vbox;
872         GtkWidget *hbox;
873         GtkWidget *image;
874         char *title_string;
875
876         vbox = gtk_vbox_new (FALSE, 6);
877         gtk_container_set_border_width  (GTK_CONTAINER(vbox), 10);
878
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);
889
890         /* pack the titlebar */
891         gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
892
893         /* pack the separator */
894         gtk_box_pack_start (GTK_BOX(vbox), gtk_hseparator_new(), FALSE, FALSE, 0);
895
896         /* pack space */
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);
900
901         return vbox;
902 }
903
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);        \
911 }
912
913 static gchar *get_default_server(WizardWindow * wizard, const gchar *type)
914 {
915         if (!strcmp(type, "smtp")) {
916                 if (!tmpl.smtpserver || !strlen(tmpl.smtpserver))
917                         return g_strconcat(type, ".", tmpl.domain, NULL);
918                 else 
919                         return g_strdup(tmpl.smtpserver);
920         } else {
921                 if (!tmpl.recvserver || !strlen(tmpl.recvserver))
922                         return g_strconcat(type, ".", tmpl.domain, NULL);
923                 else 
924                         return g_strdup(tmpl.recvserver);
925         }
926 }
927
928 static gchar *get_default_account(WizardWindow * wizard)
929 {
930         gchar *result = NULL;
931         
932         if (!tmpl.recvuser || !strlen(tmpl.recvuser)) {
933                 result = gtk_editable_get_chars(
934                                 GTK_EDITABLE(wizard->email), 0, -1);
935
936                 if (strstr(result, "@")) {
937                         *(strstr(result,"@")) = '\0';
938                 } 
939         } else {
940                 result = g_strdup(tmpl.recvuser);
941         }
942         return result;
943 }
944
945 static gchar *get_default_smtp_account(WizardWindow * wizard)
946 {
947         gchar *result = NULL;
948         
949         if (!tmpl.smtpuser || !strlen(tmpl.smtpuser)) {
950                 return g_strdup("");
951         } else {
952                 result = g_strdup(tmpl.smtpuser);
953         }
954         return result;
955 }
956
957 static void wizard_email_changed(GtkWidget *widget, gpointer data)
958 {
959         WizardWindow *wizard = (WizardWindow *)data;
960         RecvProtocol protocol;
961         gchar *text;
962         protocol = combobox_get_active_data(GTK_COMBO_BOX(wizard->recv_type));
963         
964         text = get_default_server(wizard, "smtp");
965         gtk_entry_set_text(GTK_ENTRY(wizard->smtp_server), text);
966         g_free(text);
967
968         text = get_default_account(wizard);
969         gtk_entry_set_text(GTK_ENTRY(wizard->recv_username), text);
970         g_free(text);
971
972         if (protocol == A_POP3) {
973                 text = get_default_server(wizard, "pop");
974                 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
975                 g_free(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);
979                 g_free(text);
980         } else if (protocol == A_LOCAL) {
981                 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), tmpl.mboxfile?tmpl.mboxfile:"");
982         }
983         
984 }
985
986 static GtkWidget* user_page (WizardWindow * wizard)
987 {
988         GtkWidget *table = gtk_table_new(1,1, FALSE);
989         GtkWidget *vbox;
990         GtkWidget *hbox;
991         
992         gtk_table_set_row_spacings(GTK_TABLE(table), 4);
993         gtk_table_set_col_spacings(GTK_TABLE(table), 8);
994
995         vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
996         gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
997
998         gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2, 
999                          GTK_EXPAND|GTK_FILL, 0, 0, 0);
1000
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>"),
1006                  wizard->full_name);
1007         
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>"),
1013                  wizard->email);
1014         
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);
1020         
1021         g_signal_connect(G_OBJECT(wizard->email), "changed",
1022                          G_CALLBACK(wizard_email_changed),
1023                          wizard);
1024         return table;
1025 }
1026
1027 #ifdef MAEMO
1028 static void wizard_vol_mount_cb(GnomeVFSVolumeMonitor *vfs, GnomeVFSVolume *vol, WizardWindow *wizard)
1029 {
1030         gchar *uri = gnome_vfs_volume_get_activation_uri (vol);
1031         gchar *mount_path = uri?gnome_vfs_get_local_path_from_uri (uri):NULL;
1032         g_free (uri);
1033         if (mount_path) {
1034                 if(!strcmp(mount_path, MMC1_PATH)) {
1035                         gtk_widget_set_sensitive(wizard->data_root_mmc1_radiobtn, TRUE);
1036                 }
1037                 if(!strcmp(mount_path, MMC2_PATH)) {
1038                         gtk_widget_set_sensitive(wizard->data_root_mmc2_radiobtn, TRUE);
1039                 }
1040         }
1041         g_free(mount_path);
1042 }
1043 static void wizard_vol_unmount_cb(GnomeVFSVolumeMonitor *vfs, GnomeVFSVolume *vol, WizardWindow *wizard)
1044 {
1045         gchar *uri = gnome_vfs_volume_get_activation_uri (vol);
1046         gchar *mount_path = uri?gnome_vfs_get_local_path_from_uri (uri):NULL;
1047         g_free (uri);
1048         if (mount_path) {
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);
1055                         }
1056                 }
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);
1063                         }
1064                 }
1065         }
1066         g_free(mount_path);
1067 }
1068
1069 void data_root_changed          (GtkToggleButton        *toggle_btn,
1070                                  WizardWindow *wizard)
1071 {
1072         gchar *name = g_path_get_basename(gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name)));
1073         gchar *path = NULL;
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,
1082                                   name, NULL);
1083                 gtk_entry_set_text(GTK_ENTRY(wizard->mailbox_name), path);
1084                 g_free(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,
1090                                   name, NULL);
1091                 gtk_entry_set_text(GTK_ENTRY(wizard->mailbox_name), path);
1092                 g_free(path);
1093         }
1094         g_free(name);
1095 }
1096 #endif
1097
1098 static GtkWidget* mailbox_page (WizardWindow * wizard)
1099 {
1100         GtkWidget *table = gtk_table_new(1,1, FALSE);
1101         GtkWidget *vbox;
1102 #ifdef MAEMO
1103         GtkWidget *vbox2;
1104         gchar *uri, *mount_path;
1105 #endif
1106         GtkWidget *hbox;
1107         GtkTooltips *tips = gtk_tooltips_new();
1108
1109         gtk_table_set_row_spacings(GTK_TABLE(table), 4);
1110         gtk_table_set_col_spacings(GTK_TABLE(table), 8);
1111
1112         vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
1113         gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
1114
1115         gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2, 
1116                          GTK_EXPAND|GTK_FILL, 0, 0, 0);
1117
1118         hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1119         gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1120
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();
1126
1127         gtk_entry_set_text(GTK_ENTRY(wizard->mailbox_name), tmpl.mailbox?tmpl.mailbox:"");
1128
1129         gtk_tooltips_set_tip(GTK_TOOLTIPS(tips), wizard->mailbox_name,
1130                              _("You can also specify an absolute path, for example: "
1131                                "\"/home/john/Documents/Mail\""),
1132                              NULL);
1133
1134         gtk_box_pack_start(GTK_BOX(hbox), wizard->mailbox_label, FALSE, FALSE, 0);
1135         gtk_box_pack_start(GTK_BOX(hbox), wizard->mailbox_name, TRUE, TRUE, 0);
1136
1137 #ifdef MAEMO
1138         wizard->data_root_nokia_radiobtn = gtk_radio_button_new_with_label(NULL,
1139                 _("on internal memory"));
1140         wizard->data_root_mmc1_radiobtn = gtk_radio_button_new_with_label_from_widget(
1141                 GTK_RADIO_BUTTON(wizard->data_root_nokia_radiobtn),
1142                 _("on external memory card"));
1143         wizard->data_root_mmc2_radiobtn = gtk_radio_button_new_with_label_from_widget(
1144                 GTK_RADIO_BUTTON(wizard->data_root_nokia_radiobtn),
1145                 _("on internal memory card"));
1146                 
1147         g_signal_connect(G_OBJECT(wizard->data_root_nokia_radiobtn), "toggled",
1148                          G_CALLBACK(data_root_changed), wizard);
1149         g_signal_connect(G_OBJECT(wizard->data_root_mmc1_radiobtn), "toggled",
1150                          G_CALLBACK(data_root_changed), wizard);
1151         g_signal_connect(G_OBJECT(wizard->data_root_mmc2_radiobtn), "toggled",
1152                          G_CALLBACK(data_root_changed), wizard);
1153
1154         wizard->volmon = gnome_vfs_get_volume_monitor();
1155         wizard->vol_mmc1 = gnome_vfs_volume_monitor_get_volume_for_path(wizard->volmon, MMC1_PATH);
1156         wizard->vol_mmc2 = gnome_vfs_volume_monitor_get_volume_for_path(wizard->volmon, MMC2_PATH);
1157
1158         uri = gnome_vfs_volume_get_activation_uri (wizard->vol_mmc1);
1159         mount_path = uri?gnome_vfs_get_local_path_from_uri (uri):NULL;
1160         g_free(uri);
1161         if (wizard->vol_mmc1 == NULL || !gnome_vfs_volume_is_mounted(wizard->vol_mmc1)
1162             || strcmp(mount_path, MMC1_PATH)) {
1163                 gtk_widget_set_sensitive(wizard->data_root_mmc1_radiobtn, FALSE);
1164         }
1165         g_free(mount_path);
1166
1167         uri = gnome_vfs_volume_get_activation_uri (wizard->vol_mmc2);
1168         mount_path = uri?gnome_vfs_get_local_path_from_uri (uri):NULL;
1169         g_free(uri);
1170         if (wizard->vol_mmc2 == NULL || !gnome_vfs_volume_is_mounted(wizard->vol_mmc2)
1171             || strcmp(mount_path, MMC2_PATH)) {
1172                 gtk_widget_set_sensitive(wizard->data_root_mmc2_radiobtn, FALSE);
1173         } else {
1174                 gtk_toggle_button_set_active(wizard->data_root_mmc2_radiobtn, TRUE);
1175         }
1176         g_free(mount_path);
1177         
1178         gnome_vfs_volume_unref(wizard->vol_mmc1);
1179         gnome_vfs_volume_unref(wizard->vol_mmc2);
1180         wizard->vol_mmc1 = NULL;
1181         wizard->vol_mmc2 = NULL;
1182
1183         wizard->volmon_mount_sigid = g_signal_connect(G_OBJECT(wizard->volmon), 
1184                                         "volume-mounted", G_CALLBACK(wizard_vol_mount_cb), wizard);
1185         wizard->volmon_unmount_sigid = g_signal_connect(G_OBJECT(wizard->volmon), 
1186                                         "volume-unmounted", G_CALLBACK(wizard_vol_unmount_cb), wizard);
1187
1188         vbox2 = gtk_vbox_new(FALSE, VSPACING_NARROW);
1189         gtk_box_pack_start (GTK_BOX(vbox2), wizard->data_root_nokia_radiobtn, FALSE, FALSE, 0);
1190         gtk_box_pack_start (GTK_BOX(vbox2), wizard->data_root_mmc1_radiobtn, FALSE, FALSE, 0);
1191         gtk_box_pack_start (GTK_BOX(vbox2), wizard->data_root_mmc2_radiobtn, FALSE, FALSE, 0);
1192
1193         hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1194         gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1195         PACK_BOX(hbox, _("<span weight=\"bold\">Store data</span>"),
1196                  vbox2);
1197 #endif
1198
1199         return table;
1200 }
1201
1202 static void smtp_auth_changed (GtkWidget *btn, gpointer data)
1203 {
1204         WizardWindow *wizard = (WizardWindow *)data;
1205         gboolean do_auth = gtk_toggle_button_get_active(
1206                 GTK_TOGGLE_BUTTON(wizard->smtp_auth));
1207         gtk_widget_set_sensitive(wizard->smtp_username, do_auth);
1208         gtk_widget_set_sensitive(wizard->smtp_username_label, do_auth);
1209         gtk_widget_set_sensitive(wizard->smtp_password, do_auth);
1210         gtk_widget_set_sensitive(wizard->smtp_password_label, do_auth);
1211 }
1212
1213 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
1214 static void cert_browse_cb(GtkWidget *widget, gpointer data)
1215 {
1216         GtkEntry *dest = GTK_ENTRY(data);
1217         gchar *filename;
1218         gchar *utf8_filename;
1219
1220         filename = filesel_select_file_open(_("Select certificate file"), NULL);
1221         if (!filename) return;
1222
1223         utf8_filename = g_filename_to_utf8(filename, -1, NULL, NULL, NULL);
1224         if (!utf8_filename) {
1225                 g_warning("cert_browse_cb(): failed to convert character set.");
1226                 utf8_filename = g_strdup(filename);
1227         }
1228         gtk_entry_set_text(dest, utf8_filename);
1229         g_free(utf8_filename);
1230 }
1231 #endif
1232
1233 static GtkWidget* smtp_page (WizardWindow * wizard)
1234 {
1235         GtkWidget *table = gtk_table_new(1, 1, FALSE);
1236         GtkWidget *vbox;
1237         GtkWidget *hbox;
1238         GtkWidget *label;
1239         GtkWidget *button;
1240         GtkWidget *smtp_cert_table;
1241         GtkTooltips *tips = gtk_tooltips_new();
1242         gchar *text;
1243         
1244         gtk_table_set_row_spacings(GTK_TABLE(table), 4);
1245         gtk_table_set_col_spacings(GTK_TABLE(table), 8);
1246
1247         vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
1248         gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
1249
1250         gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2, 
1251                          GTK_EXPAND|GTK_FILL, 0, 0, 0);
1252
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);
1258         g_free(text);
1259
1260         gtk_tooltips_set_tip(GTK_TOOLTIPS(tips), wizard->smtp_server,
1261                              _("You can specify the port number by appending it at the end: "
1262                                "\"mail.example.com:25\""),
1263                              NULL);
1264
1265         PACK_BOX(hbox, _("<span weight=\"bold\">SMTP server address:</span>"),
1266                  wizard->smtp_server);
1267
1268
1269         hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1270         gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1271         wizard->smtp_auth = gtk_check_button_new_with_label(
1272                                         _("Use authentication"));
1273         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->smtp_auth),
1274                         tmpl.smtpauth);
1275         g_signal_connect(G_OBJECT(wizard->smtp_auth), "toggled",
1276                          G_CALLBACK(smtp_auth_changed),
1277                          wizard);
1278         gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_auth, FALSE, FALSE, 0);
1279
1280         text = get_default_smtp_account(wizard);
1281
1282         hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1283         gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1284         wizard->smtp_username = gtk_entry_new();
1285         gtk_entry_set_text(GTK_ENTRY(wizard->smtp_username), text);
1286         g_free(text);
1287         wizard->smtp_username_label = gtk_label_new(_("SMTP username:\n"
1288                                         "<span size=\"small\">(empty to use the same as receive)</span>"));
1289         gtk_label_set_use_markup(GTK_LABEL(wizard->smtp_username_label), TRUE);
1290         if (GTK_IS_MISC(wizard->smtp_username_label))                                                 
1291                 gtk_misc_set_alignment(GTK_MISC(wizard->smtp_username_label), 1, 0.5);        
1292         gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_username_label, FALSE, FALSE, 0);
1293         gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_username, TRUE, TRUE, 0);
1294
1295         hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1296         gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1297         wizard->smtp_password = gtk_entry_new();
1298         gtk_entry_set_text(GTK_ENTRY(wizard->smtp_password), tmpl.smtppass?tmpl.smtppass:""); 
1299         gtk_entry_set_visibility(GTK_ENTRY(wizard->smtp_password), FALSE);
1300 #ifdef MAEMO
1301         hildon_gtk_entry_set_input_mode(GTK_ENTRY(wizard->smtp_password), 
1302                 HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
1303 #endif
1304         wizard->smtp_password_label = gtk_label_new(_("SMTP password:\n"
1305                                         "<span size=\"small\">(empty to use the same as receive)</span>"));
1306         gtk_label_set_use_markup(GTK_LABEL(wizard->smtp_password_label), TRUE);
1307         if (GTK_IS_MISC(wizard->smtp_password_label))                                                 
1308                 gtk_misc_set_alignment(GTK_MISC(wizard->smtp_password_label), 1, 0.5);        
1309         gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_password_label, FALSE, FALSE, 0);
1310         gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_password, TRUE, TRUE, 0);
1311 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
1312         hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1313         gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1314         wizard->smtp_use_ssl = gtk_check_button_new_with_label(
1315                                         _("Use SSL to connect to SMTP server"));
1316         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_ssl),
1317                         tmpl.smtpssl != 0);
1318         gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_use_ssl, FALSE, FALSE, 0);
1319
1320         hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1321         gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1322         wizard->smtp_use_tls = gtk_check_button_new_with_label(
1323                                         _("Use SSL via STARTTLS"));
1324         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_tls),
1325                         tmpl.smtpssl == 2);
1326         gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_use_tls, FALSE, FALSE, 0);
1327         SET_TOGGLE_SENSITIVITY (wizard->smtp_use_ssl, wizard->smtp_use_tls);
1328         
1329         smtp_cert_table = gtk_table_new(3,3, FALSE);
1330         gtk_container_set_border_width(GTK_CONTAINER(smtp_cert_table), 8);
1331         gtk_box_pack_start (GTK_BOX(vbox), smtp_cert_table, FALSE, FALSE, 0);
1332         label = gtk_label_new(_("Client SSL certificate (optional)"));
1333         gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
1334         gtk_table_attach(GTK_TABLE(smtp_cert_table), label, 0, 3, 0, 1, GTK_FILL, 0, 0, 0);
1335         label = gtk_label_new(_("File"));
1336         gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
1337         gtk_table_attach(GTK_TABLE(smtp_cert_table), label, 0, 1, 1, 2, GTK_FILL, 0, 0, 0);
1338         wizard->smtp_ssl_cert_file = gtk_entry_new();
1339         gtk_entry_set_text(GTK_ENTRY(wizard->smtp_ssl_cert_file), tmpl.smtpssl_cert?tmpl.smtpssl_cert:"");
1340         gtk_table_attach(GTK_TABLE(smtp_cert_table), wizard->smtp_ssl_cert_file, 1, 2, 1, 2, GTK_FILL, 0, 0, 0);
1341         button = gtkut_get_browse_file_btn(_("Browse"));
1342         gtk_table_attach(GTK_TABLE(smtp_cert_table), button, 2, 3, 1, 2, GTK_FILL, 0, 0, 0);
1343         SET_TOGGLE_SENSITIVITY (wizard->smtp_use_ssl, label);
1344         SET_TOGGLE_SENSITIVITY (wizard->smtp_use_ssl, wizard->smtp_ssl_cert_file);
1345         SET_TOGGLE_SENSITIVITY (wizard->smtp_use_ssl, button);
1346         g_signal_connect(G_OBJECT(button), "clicked",
1347                          G_CALLBACK(cert_browse_cb), wizard->smtp_ssl_cert_file);
1348
1349         hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1350         gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1351         label = gtk_label_new(_("Password"));
1352         gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
1353         gtk_table_attach(GTK_TABLE(smtp_cert_table), label, 0, 1, 2, 3, GTK_FILL, 0, 0, 0);
1354         wizard->smtp_ssl_cert_pass = gtk_entry_new();
1355         gtk_entry_set_visibility(GTK_ENTRY(wizard->smtp_ssl_cert_pass), FALSE);
1356         gtk_entry_set_text(GTK_ENTRY(wizard->smtp_ssl_cert_pass), tmpl.smtpssl_cert_pass?tmpl.smtpssl_cert_pass:"");
1357         gtk_table_attach(GTK_TABLE(smtp_cert_table), wizard->smtp_ssl_cert_pass, 1, 2, 2, 3, GTK_FILL, 0, 0, 0);
1358         SET_TOGGLE_SENSITIVITY (wizard->smtp_use_ssl, label);
1359         SET_TOGGLE_SENSITIVITY (wizard->smtp_use_ssl, wizard->smtp_ssl_cert_pass);
1360         wizard->smtp_cert_table = smtp_cert_table;
1361 #endif
1362         smtp_auth_changed(NULL, wizard);
1363         return table;
1364 }
1365
1366 static void wizard_protocol_change(WizardWindow *wizard, RecvProtocol protocol)
1367 {
1368         gchar *text;
1369         
1370         if (protocol == A_POP3) {
1371                 text = get_default_server(wizard, "pop");
1372                 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
1373                 gtk_widget_hide(wizard->recv_imap_label);
1374                 gtk_widget_hide(wizard->recv_imap_subdir);
1375                 gtk_widget_hide(wizard->subsonly_checkbtn);
1376                 gtk_widget_show(wizard->recv_username);
1377                 gtk_widget_show(wizard->recv_password);
1378                 gtk_widget_show(wizard->recv_username_label);
1379                 gtk_widget_show(wizard->recv_password_label);
1380                 gtk_widget_hide(wizard->no_imap_warning);
1381 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
1382                 gtk_widget_show(wizard->recv_use_ssl);
1383                 gtk_widget_show(wizard->recv_use_tls);
1384                 gtk_widget_show(wizard->recv_cert_table);
1385 #endif
1386                 gtk_label_set_text(GTK_LABEL(wizard->recv_label), _("<span weight=\"bold\">Server address:</span>"));
1387                 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
1388                 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, TRUE);
1389                 g_free(text);
1390                 if (wizard->create_mailbox) {
1391                         gtk_widget_show(wizard->mailbox_label);
1392                         gtk_widget_show(wizard->mailbox_name);
1393                 }
1394         } else if (protocol == A_IMAP4) {
1395 #ifdef HAVE_LIBETPAN
1396                 text = get_default_server(wizard, "imap");
1397                 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
1398                 gtk_widget_show(wizard->recv_imap_label);
1399                 gtk_widget_show(wizard->recv_imap_subdir);
1400                 gtk_widget_show(wizard->subsonly_checkbtn);
1401                 gtk_widget_show(wizard->recv_username);
1402                 gtk_widget_show(wizard->recv_password);
1403                 gtk_widget_show(wizard->recv_username_label);
1404                 gtk_widget_show(wizard->recv_password_label);
1405                 gtk_widget_hide(wizard->no_imap_warning);
1406 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
1407                 gtk_widget_show(wizard->recv_use_ssl);
1408                 gtk_widget_show(wizard->recv_use_tls);
1409                 gtk_widget_show(wizard->recv_cert_table);
1410 #endif
1411                 gtk_label_set_text(GTK_LABEL(wizard->recv_label), _("<span weight=\"bold\">Server address:</span>"));
1412                 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
1413                 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, TRUE);
1414                 g_free(text);
1415                 if (wizard->create_mailbox) {
1416                         gtk_widget_hide(wizard->mailbox_label);
1417                         gtk_widget_hide(wizard->mailbox_name);
1418                 }
1419 #else
1420                 gtk_widget_hide(wizard->recv_imap_label);
1421                 gtk_widget_hide(wizard->recv_imap_subdir);
1422                 gtk_widget_hide(wizard->subsonly_checkbtn);
1423                 gtk_widget_hide(wizard->recv_username);
1424                 gtk_widget_hide(wizard->recv_password);
1425                 gtk_widget_hide(wizard->recv_username_label);
1426                 gtk_widget_hide(wizard->recv_password_label);
1427                 gtk_widget_show(wizard->no_imap_warning);
1428                 if (wizard->create_mailbox) {
1429                         gtk_widget_hide(wizard->mailbox_label);
1430                         gtk_widget_hide(wizard->mailbox_name);
1431                 }
1432 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
1433                 gtk_widget_hide(wizard->recv_use_ssl);
1434                 gtk_widget_hide(wizard->recv_use_tls);
1435                 gtk_widget_hide(wizard->recv_cert_table);
1436 #endif
1437                 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, FALSE);
1438 #endif
1439         } else if (protocol == A_LOCAL) {
1440                 gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), tmpl.mboxfile?tmpl.mboxfile:"");
1441                 gtk_label_set_text(GTK_LABEL(wizard->recv_label), _("<span weight=\"bold\">Local mailbox:</span>"));
1442                 gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
1443                 gtk_widget_hide(wizard->no_imap_warning);
1444                 gtk_widget_hide(wizard->recv_imap_label);
1445                 gtk_widget_hide(wizard->recv_imap_subdir);
1446                 gtk_widget_hide(wizard->subsonly_checkbtn);
1447                 gtk_widget_hide(wizard->recv_username);
1448                 gtk_widget_hide(wizard->recv_password);
1449                 gtk_widget_hide(wizard->recv_username_label);
1450                 gtk_widget_hide(wizard->recv_password_label);
1451 #if (defined(USE_OPENSSL) || defined (USE_GNUTLS))
1452                 gtk_widget_hide(wizard->recv_use_ssl);
1453                 gtk_widget_hide(wizard->recv_use_tls);
1454                 gtk_widget_hide(wizard->recv_cert_table);
1455 #endif
1456                 if (wizard->create_mailbox) {
1457                         gtk_widget_show(wizard->mailbox_label);
1458                         gtk_widget_show(wizard->mailbox_name);
1459                 }
1460                 gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, TRUE);
1461         }
1462 }
1463
1464 static void wizard_protocol_changed(GtkComboBox *combo, gpointer data)
1465 {
1466         WizardWindow *wizard = (WizardWindow *)data;
1467         RecvProtocol protocol = combobox_get_active_data(combo);
1468
1469         wizard_protocol_change(wizard, protocol);       
1470 }
1471
1472 static GtkWidget* recv_page (WizardWindow * wizard)
1473 {
1474         GtkWidget *table = gtk_table_new(1,1, FALSE);
1475         GtkTooltips *tips = gtk_tooltips_new();
1476         GtkWidget *vbox;
1477         GtkWidget *hbox;
1478         GtkWidget *label;
1479         GtkWidget *button;
1480         GtkWidget *recv_cert_table;
1481         GtkListStore *store;
1482         GtkTreeIter iter;
1483         gchar *text;
1484         gint index = 0;
1485
1486         gtk_table_set_row_spacings(GTK_TABLE(table), 4);
1487         gtk_table_set_col_spacings(GTK_TABLE(table), 8);
1488
1489         vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
1490         gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
1491
1492         gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2, 
1493                          GTK_EXPAND|GTK_FILL, 0, 0, 0);
1494
1495         hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1496         gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1497         wizard->recv_type = gtkut_sc_combobox_create(NULL, FALSE);
1498         store = GTK_LIST_STORE(gtk_combo_box_get_model(
1499                         GTK_COMBO_BOX(wizard->recv_type)));
1500
1501         COMBOBOX_ADD(store, _("POP3"), A_POP3);
1502         COMBOBOX_ADD(store, _("IMAP"), A_IMAP4);
1503         COMBOBOX_ADD(store, _("Local mbox file"), A_LOCAL);
1504
1505         switch(tmpl.recvtype) {
1506         case A_POP3: 
1507                 index = 0;
1508                 break;
1509         case A_IMAP4:
1510                 index = 1;
1511                 break;
1512         case A_LOCAL:
1513                 index = 2;
1514                 break;
1515         default:
1516                 index = 0;
1517         }
1518         gtk_combo_box_set_active(GTK_COMBO_BOX (wizard->recv_type), index);
1519         g_signal_connect(G_OBJECT(wizard->recv_type), "changed",
1520                          G_CALLBACK(wizard_protocol_changed),
1521                          wizard);
1522         PACK_BOX(hbox, _("<span weight=\"bold\">Server type:</span>"),
1523                  wizard->recv_type);
1524
1525         hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
1526         gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
1527         wizard->recv_server = gtk_entry_new();
1528         text = get_default_server(wizard, "pop");
1529         gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
1530         g_free(text);
1531         
1532         gtk_tooltips_set_tip(GTK_TOOLTIPS(tips), wizard->recv_server,
1533                              _("You can specify the port number by appending it at the end: "
1534                                "\"mail.example.com:110\""),
1535                              NULL);
1536
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);
1543         
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);
1553         
1554         text = get_default_account(wizard);
1555         gtk_entry_set_text(GTK_ENTRY(wizard->recv_username), text);
1556         g_free(text);
1557
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);
1566 #ifdef MAEMO
1567         hildon_gtk_entry_set_input_mode(GTK_ENTRY(wizard->recv_password), 
1568                 HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
1569 #endif
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);
1572         
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),
1579                         tmpl.recvssl != 0);
1580         gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_use_ssl, FALSE, FALSE, 0);
1581
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),
1587                         tmpl.recvssl == 2);
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);
1590
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);
1610
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;
1623 #endif  
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);
1633         
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),
1639                         tmpl.subsonly);
1640         gtk_box_pack_start(GTK_BOX(hbox), wizard->subsonly_checkbtn, FALSE, FALSE, 0);
1641         
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);
1649
1650         return table;
1651 }
1652
1653 static void
1654 wizard_response_cb (GtkDialog * dialog, int response, gpointer data)
1655 {
1656         WizardWindow * wizard = (WizardWindow *)data;
1657         int current_page, num_pages;
1658         gboolean skip_mailbox_page = FALSE;
1659 #ifndef MAEMO
1660         gint protocol = combobox_get_active_data(GTK_COMBO_BOX(wizard->recv_type));
1661
1662         if (protocol == A_IMAP4) {
1663                 skip_mailbox_page = TRUE;
1664         }
1665 #endif
1666
1667         num_pages = g_slist_length(wizard->pages);
1668
1669         current_page = gtk_notebook_get_current_page (
1670                                 GTK_NOTEBOOK(wizard->notebook));
1671         if (response == CANCEL)
1672         {
1673                 wizard->result = FALSE;
1674                 wizard->finished = TRUE;
1675                 gtk_widget_destroy (GTK_WIDGET(dialog));
1676         }
1677         else if (response == FINISHED)
1678         {
1679                 if (!wizard_write_config(wizard)) {
1680                         current_page = gtk_notebook_get_current_page (
1681                                         GTK_NOTEBOOK(wizard->notebook));
1682                         goto set_sens;
1683                 }
1684                 wizard->result = TRUE;
1685                 wizard->finished = TRUE;
1686                 gtk_widget_destroy (GTK_WIDGET(dialog));
1687         }
1688         else
1689         {
1690                 if (response == GO_BACK)
1691                 {
1692                         if (current_page > 0) {
1693                                 current_page--;
1694                                 if (current_page == MAILBOX_PAGE && skip_mailbox_page) {
1695                                         /* mailbox */
1696                                         current_page--;
1697                                 }
1698                                 gtk_notebook_set_current_page (
1699                                         GTK_NOTEBOOK(wizard->notebook), 
1700                                         current_page);
1701                         }
1702                 }
1703                 else if (response == GO_FORWARD)
1704                 {
1705                         if (current_page < (num_pages-1)) {
1706                                 current_page++;
1707                                 if (current_page == MAILBOX_PAGE && skip_mailbox_page) {
1708                                         /* mailbox */
1709                                         current_page++;
1710                                 }
1711                                 gtk_notebook_set_current_page (
1712                                         GTK_NOTEBOOK(wizard->notebook), 
1713                                         current_page);
1714                         }
1715                 }
1716 set_sens:
1717                 gtk_dialog_set_response_sensitive (dialog, GO_BACK, 
1718                                 current_page > 0);
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);
1724                 } else {
1725                         gtk_dialog_set_response_sensitive (dialog, FINISHED, FALSE);
1726                         gtk_dialog_set_default_response(GTK_DIALOG(wizard->window), GO_FORWARD);
1727                 }
1728
1729         }
1730 }
1731
1732 static gint wizard_close_cb(GtkWidget *widget, GdkEventAny *event,
1733                                  gpointer data)
1734 {
1735         WizardWindow *wizard = (WizardWindow *)data;
1736         wizard->result = FALSE;
1737         wizard->finished = TRUE;
1738         
1739         return FALSE;
1740 }
1741
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);      \
1746 }
1747
1748 gboolean run_wizard(MainWindow *mainwin, gboolean create_mailbox) {
1749         WizardWindow *wizard = g_new0(WizardWindow, 1);
1750         GtkWidget *page;
1751         GtkWidget *widget;
1752         GtkWidget *label;
1753         GtkWidget *scrolled_window;
1754         gchar     *text;
1755         GSList    *cur;
1756         gboolean   result;
1757         gint i = 0;
1758         wizard->mainwin = mainwin;
1759         wizard->create_mailbox = create_mailbox;
1760         
1761         gtk_widget_hide(mainwin->window);
1762         
1763         wizard_read_defaults();
1764         
1765         wizard->window = gtk_dialog_new_with_buttons (_("Claws Mail Setup Wizard"),
1766                         NULL, 0, 
1767                         GTK_STOCK_GO_BACK, GO_BACK,
1768                         GTK_STOCK_GO_FORWARD, GO_FORWARD,
1769                         GTK_STOCK_SAVE, FINISHED,
1770                         GTK_STOCK_CANCEL, CANCEL,
1771                         NULL);
1772         gtk_widget_set_size_request(wizard->window, -1, 480);
1773
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), 
1778                         GO_FORWARD);
1779         gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window), 
1780                         GO_BACK, FALSE);
1781         gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window), 
1782                         GO_FORWARD, TRUE);
1783         gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window), 
1784                         FINISHED, FALSE);
1785         gtk_dialog_set_response_sensitive(GTK_DIALOG(wizard->window), 
1786                         CANCEL, TRUE);
1787         
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);
1793         
1794         wizard->pages = NULL;
1795         
1796 /*welcome page: 0 */
1797         WELCOME_PAGE = i;
1798         page = create_page(wizard, _("Welcome to Claws Mail"));
1799         
1800         wizard->pages = g_slist_append(wizard->pages, page);
1801         widget = stock_pixmap_widget(wizard->window, 
1802                                 STOCK_PIXMAP_CLAWS_MAIL_LOGO);
1803
1804         gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1805         
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);
1813 #ifndef MAEMO
1814         gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1815 #else
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);
1820
1821         gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1822                                               widget);
1823 #endif
1824         g_free(text);
1825
1826 /* user page: 1 */
1827         i++;
1828         USER_PAGE = i;
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);
1834
1835         gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1836                                               user_page(wizard));
1837         PACK_WARNING(_("Bold fields must be completed"));
1838         
1839         wizard->pages = g_slist_append(wizard->pages, widget);
1840
1841 /* recv+auth page: 2 */
1842         i++;
1843         RECV_PAGE = i;
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);
1849
1850         gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1851                                               recv_page(wizard));
1852         PACK_WARNING(_("Bold fields must be completed"));
1853         
1854         wizard->pages = g_slist_append(wizard->pages, widget);
1855
1856 /*smtp page: 3 */
1857         i++;
1858         SMTP_PAGE = i;
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);
1864
1865         gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1866                                               smtp_page(wizard));
1867         PACK_WARNING(_("Bold fields must be completed"));
1868         
1869         wizard->pages = g_slist_append(wizard->pages, widget);
1870
1871 /* mailbox page: 4 */
1872         if (create_mailbox) {
1873                 i++;
1874                 MAILBOX_PAGE = i;
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);
1880
1881                 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
1882                                               mailbox_page(wizard));
1883                 PACK_WARNING(_("Bold fields must be completed"));
1884         
1885                 wizard->pages = g_slist_append(wizard->pages, widget);
1886         }
1887
1888 /* done page: 6 */
1889         i++;
1890         DONE_PAGE = i;
1891         page = create_page(wizard, _("Configuration finished"));
1892         
1893         wizard->pages = g_slist_append(wizard->pages, page);
1894         widget = stock_pixmap_widget(wizard->window, 
1895                                 STOCK_PIXMAP_CLAWS_MAIL_LOGO);
1896
1897         gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
1898         
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);
1903         g_free(text);
1904
1905
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);
1909         }
1910         
1911         g_signal_connect(G_OBJECT(wizard->window), "delete_event",
1912                          G_CALLBACK(wizard_close_cb), wizard);
1913         gtk_widget_show_all (wizard->window);
1914
1915         gtk_widget_hide(wizard->recv_imap_label);
1916         gtk_widget_hide(wizard->recv_imap_subdir);
1917         gtk_widget_hide(wizard->subsonly_checkbtn);
1918
1919         wizard_protocol_change(wizard, tmpl.recvtype);
1920
1921         while (!wizard->finished)
1922                 gtk_main_iteration();
1923
1924         result = wizard->result;
1925         
1926         GTK_EVENTS_FLUSH();
1927
1928         gtk_widget_show(mainwin->window);
1929         g_free(wizard);
1930
1931         return result;
1932 }