2007-07-19 [colin] 2.10.0cvs43
[claws.git] / src / wizard.c
index a850fe8a28b341cccf0ecd3d82fe148b85a91bc5..07bdd1aa2471b36b812c32cffc3c6ba0f3a7a91b 100644 (file)
@@ -1,11 +1,11 @@
 /*
- * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2004 Hiroyuki Yamamoto
- * This file (C) 2004 Colin Leroy
+ * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 1999-2007 Colin Leroy <colin@colino.net> 
+ * and the Claws Mail team
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
@@ -14,8 +14,8 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * 
  */
 
 #ifdef HAVE_CONFIG_H
 
 #include "utils.h"
 #include "gtk/menu.h"
+#include "plugin.h"
 #include "account.h"
 #include "prefs_account.h"
 #include "mainwindow.h"
 #include "stock_pixmap.h"
 #include "setup.h"
 #include "folder.h"
+#include "alertpanel.h"
 #ifdef USE_OPENSSL                     
 #include "ssl.h"
 #endif
@@ -68,6 +70,13 @@ typedef enum
        FINISHED
 } PageNavigation;
 
+int WELCOME_PAGE = -1;
+int USER_PAGE = -1;
+int SMTP_PAGE = -1;
+int RECV_PAGE = -1;
+int MAILBOX_PAGE = -1;
+int DONE_PAGE = -1;
+
 typedef struct
 {
        GtkWidget *window;
@@ -83,6 +92,11 @@ typedef struct
        GtkWidget *mailbox_name;
        
        GtkWidget *smtp_server;
+       GtkWidget *smtp_auth;
+       GtkWidget *smtp_username;
+       GtkWidget *smtp_password;
+       GtkWidget *smtp_username_label;
+       GtkWidget *smtp_password_label;
 
        GtkWidget *recv_type;
        GtkWidget *recv_label;
@@ -93,10 +107,13 @@ typedef struct
        GtkWidget *recv_password_label;
        GtkWidget *recv_imap_label;
        GtkWidget *recv_imap_subdir;
-
+       GtkWidget *subsonly_checkbtn;
+       GtkWidget *no_imap_warning;
 #ifdef USE_OPENSSL
        GtkWidget *smtp_use_ssl;
        GtkWidget *recv_use_ssl;
+       GtkWidget *smtp_use_tls;
+       GtkWidget *recv_use_tls;
 #endif
        
        gboolean create_mailbox;
@@ -105,6 +122,284 @@ typedef struct
 
 } WizardWindow;
 
+typedef struct _AccountTemplate {
+       gchar *name;
+       gchar *domain;
+       gchar *email;
+       gchar *organization;
+       gchar *smtpserver;
+       gboolean smtpauth;
+       gchar *smtpuser;
+       gchar *smtppass;
+       RecvProtocol recvtype;
+       gchar *recvserver;
+       gchar *recvuser;
+       gchar *recvpass;
+       gchar *imapdir;
+       gboolean subsonly;
+       gchar *mboxfile;
+       gchar *mailbox;
+       gboolean smtpssl;
+       gboolean recvssl;
+} AccountTemplate;
+
+static AccountTemplate tmpl;
+
+static PrefParam template_params[] = {
+       {"name", "$USERNAME",
+        &tmpl.name, P_STRING, NULL, NULL, NULL},
+       {"domain", "$DEFAULTDOMAIN",
+        &tmpl.domain, P_STRING, NULL, NULL, NULL},
+       {"email", "$NAME_MAIL@$DOMAIN",
+        &tmpl.email, P_STRING, NULL, NULL, NULL},
+       {"organization", "",
+        &tmpl.organization, P_STRING, NULL, NULL, NULL},
+       {"smtpserver", "smtp.$DOMAIN",
+        &tmpl.smtpserver, P_STRING, NULL, NULL, NULL},
+       {"smtpauth", "FALSE",
+        &tmpl.smtpauth, P_BOOL, NULL, NULL, NULL},
+       {"smtpuser", "",
+        &tmpl.smtpuser, P_STRING, NULL, NULL, NULL},
+       {"smtppass", "",
+        &tmpl.smtppass, P_STRING, NULL, NULL, NULL},
+       {"recvtype", A_POP3,
+        &tmpl.recvtype, P_INT, NULL, NULL, NULL},
+       {"recvserver", "pop.$DOMAIN",
+        &tmpl.recvserver, P_STRING, NULL, NULL, NULL},
+       {"recvuser", "$LOGIN",
+        &tmpl.recvuser, P_STRING, NULL, NULL, NULL},
+       {"recvpass", "",
+        &tmpl.recvpass, P_STRING, NULL, NULL, NULL},
+       {"imapdir", "",
+        &tmpl.imapdir, P_STRING, NULL, NULL, NULL},
+       {"subsonly", "TRUE",
+        &tmpl.subsonly, P_BOOL, NULL, NULL, NULL},
+       {"mboxfile", "/var/mail/$LOGIN",
+        &tmpl.mboxfile, P_STRING, NULL, NULL, NULL},
+       {"mailbox", "Mail",
+        &tmpl.mailbox, P_STRING, NULL, NULL, NULL},
+       {"smtpssl", "0",
+        &tmpl.smtpssl, P_INT, NULL, NULL, NULL},
+       {"recvssl", "0",
+        &tmpl.recvssl, P_INT, NULL, NULL, NULL},
+       {NULL, NULL, NULL, P_INT, NULL, NULL, NULL}
+};
+
+
+static gchar *accountrc_tmpl =
+       "[AccountTemplate]\n"
+       "#you can use $DEFAULTDOMAIN here\n"
+       "#domain must be defined before the variables that use it\n"
+       "#by default, domain is extracted from the hostname\n"
+       "#domain=\n"
+       "\n"
+       "#you can use $USERNAME for name (this is the default)\n"
+       "#name=\n"
+       "\n"
+       "#you can use $LOGIN, $NAME_MAIL and $DOMAIN here \n"
+       "#$NAME_MAIL is the name without uppercase and with dots instead\n"
+       "#of spaces\n"
+       "#the default is $NAME_MAIL@$DOMAIN\n"
+       "#email=\n"
+       "\n"
+       "#you can use $DOMAIN here\n"
+       "#the default organization is empty\n"
+       "#organization=\n"
+       "\n"
+       "#you can use $DOMAIN here \n"
+       "#the default is stmp.$DOMAIN\n"
+       "#smtpserver=\n"
+       "\n"
+       "#Whether to use smtp authentication\n"
+       "#the default is 0 (no)\n"
+       "#smtpauth=\n"
+       "\n"
+       "#SMTP username\n"
+       "#you can use $LOGIN, $NAME_MAIL, $DOMAIN or $EMAIL here\n"
+       "#the default is empty (same as reception username)\n"
+       "#smtpuser=\n"
+       "\n"
+       "#SMTP password\n"
+       "#the default is empty (same as reception password)\n"
+       "#smtppass=\n"
+       "\n"
+       "#recvtype can be:\n"
+       "#0 for pop3\n"
+       "#3  for imap\n"
+       "#5  for a local mbox file\n"
+       "#recvtype=\n"
+       "\n"
+       "#you can use $DOMAIN here \n"
+       "#the default is {pop,imap}.$DOMAIN\n"
+       "#recvserver=\n"
+       "\n"
+       "#you can use $LOGIN, $NAME_MAIL, $DOMAIN or $EMAIL here\n"
+       "#default is $LOGIN\n"
+       "#recvuser=\n"
+       "\n"
+       "#default is empty\n"
+       "#recvpass=\n"
+       "\n"
+       "#imap dir if imap (relative to the home on the server)\n"
+       "#default is empty\n"
+       "#imapdir=\n"
+       "\n"
+       "#show subscribed folders only, if imap\n"
+       "#default is TRUE\n"
+       "#subsonly=\n"
+       "\n"
+       "#mbox file if local\n"
+       "#you can use $LOGIN here\n"
+       "#default is /var/mail/$LOGIN\n"
+       "#mboxfile=\n"
+       "\n"
+       "#mailbox name if pop3 or local\n"
+       "#relative path from the user's home\n"
+       "#default is \"Mail\"\n"
+       "#mailbox=\n"
+       "\n"
+       "#whether to use ssl on STMP connections\n"
+       "#default is 0, 1 is ssl, 2 is starttls\n"
+       "#smtpssl=\n"
+       "\n"
+       "#whether to use ssl on pop or imap connections\n"
+       "#default is 0, 1 is ssl, 2 is starttls\n"
+       "#recvssl=\n";
+
+static gchar *wizard_get_default_domain_name(void)
+{
+       static gchar *domain_name = NULL;
+       
+       if (domain_name == NULL) {
+               domain_name = g_strdup(get_domain_name());
+               if (strchr(domain_name, '.') != strrchr(domain_name, '.')
+               && strlen(strchr(domain_name, '.')) > 6) {
+                       gchar *tmp = g_strdup(strchr(domain_name, '.')+1);
+                       g_free(domain_name);
+                       domain_name = tmp;
+               }
+       }
+       return domain_name;
+}
+
+static gchar *get_name_for_mail(void)
+{
+       gchar *name = g_strdup(tmpl.name);
+       if (name == NULL)
+               return NULL;
+       g_strdown(name);
+       while(strstr(name, " "))
+               *strstr(name, " ")='.';
+       
+       return name;
+}
+
+#define PARSE_DEFAULT(str) {   \
+       gchar *tmp = NULL, *new = NULL; \
+       if (str != NULL) {      \
+               tmp = g_strdup(str);    \
+               if (strstr(str, "$USERNAME")) { \
+                       tmp = g_strdup(str);    \
+                       *strstr(tmp, "$USERNAME") = '\0';       \
+                       new = g_strconcat(tmp, g_get_real_name(),       \
+                               strstr(str, "$USERNAME")+strlen("$USERNAME"),   \
+                               NULL);  \
+                       g_free(tmp);    \
+                       g_free(str);    \
+                       str = new;      \
+                       new = NULL;     \
+               }       \
+               if (strstr(str, "$LOGIN")) {    \
+                       tmp = g_strdup(str);    \
+                       *strstr(tmp, "$LOGIN") = '\0';  \
+                       new = g_strconcat(tmp, g_get_user_name(),       \
+                               strstr(str, "$LOGIN")+strlen("$LOGIN"),         \
+                               NULL);  \
+                       g_free(tmp);    \
+                       g_free(str);    \
+                       str = new;      \
+                       new = NULL;     \
+               }       \
+               if (strstr(str, "$EMAIL")) {    \
+                       tmp = g_strdup(str);    \
+                       *strstr(tmp, "$EMAIL") = '\0';  \
+                       new = g_strconcat(tmp, tmpl.email,      \
+                               strstr(str, "$EMAIL")+strlen("$EMAIL"),         \
+                               NULL);  \
+                       g_free(tmp);    \
+                       g_free(str);    \
+                       str = new;      \
+                       new = NULL;     \
+               }       \
+               if (strstr(str, "$NAME_MAIL")) {        \
+                       tmp = g_strdup(str);    \
+                       *strstr(tmp, "$NAME_MAIL") = '\0';      \
+                       new = g_strconcat(tmp, get_name_for_mail(),     \
+                               strstr(str, "$NAME_MAIL")+strlen("$NAME_MAIL"),         \
+                               NULL);  \
+                       g_free(tmp);    \
+                       g_free(str);    \
+                       str = new;      \
+                       new = NULL;     \
+               }       \
+               if (strstr(str, "$DEFAULTDOMAIN")) {    \
+                       tmp = g_strdup(str);    \
+                       *strstr(tmp, "$DEFAULTDOMAIN") = '\0';  \
+                       new = g_strconcat(tmp, wizard_get_default_domain_name(),        \
+                               strstr(str, "$DEFAULTDOMAIN")+strlen("$DEFAULTDOMAIN"),         \
+                               NULL);  \
+                       g_free(tmp);    \
+                       g_free(str);    \
+                       str = new;      \
+                       new = NULL;     \
+               }       \
+               if (strstr(str, "$DOMAIN")) {   \
+                       tmp = g_strdup(str);    \
+                       *strstr(tmp, "$DOMAIN") = '\0'; \
+                       new = g_strconcat(tmp, tmpl.domain,     \
+                               strstr(str, "$DOMAIN")+strlen("$DOMAIN"),       \
+                               NULL);  \
+                       g_free(tmp);    \
+                       g_free(str);    \
+                       str = new;      \
+                       new = NULL;     \
+               }       \
+       }       \
+}
+static void wizard_read_defaults(void)
+{
+       gchar *rcpath;
+
+       rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, "accountrc.tmpl", NULL);
+       if (!is_file_exist(rcpath)) {
+               str_write_to_file(accountrc_tmpl, rcpath);
+       }
+
+       prefs_read_config(template_params, "AccountTemplate", rcpath, NULL);
+
+       PARSE_DEFAULT(tmpl.domain);
+       PARSE_DEFAULT(tmpl.name);
+       PARSE_DEFAULT(tmpl.email);
+       PARSE_DEFAULT(tmpl.organization);
+       PARSE_DEFAULT(tmpl.smtpserver);
+       PARSE_DEFAULT(tmpl.smtpuser);
+       PARSE_DEFAULT(tmpl.smtppass);
+       PARSE_DEFAULT(tmpl.recvserver);
+       PARSE_DEFAULT(tmpl.recvuser);
+       PARSE_DEFAULT(tmpl.recvpass);
+       PARSE_DEFAULT(tmpl.imapdir);
+       PARSE_DEFAULT(tmpl.mboxfile);
+       PARSE_DEFAULT(tmpl.mailbox);
+/*
+       printf("defaults:"
+       "%s, %s, %s, %s, %s, %d, %s, %s, %s, %s, %s, %s, %d, %d\n",
+       tmpl.name,tmpl.domain,tmpl.email,tmpl.organization,tmpl.smtpserver,
+       tmpl.recvtype,tmpl.recvserver,tmpl.recvuser,tmpl.recvpass,
+       tmpl.imapdir,tmpl.mboxfile,tmpl.mailbox,tmpl.smtpssl,tmpl.recvssl);
+*/
+       g_free(rcpath);
+}
+
 static void initialize_fonts(WizardWindow *wizard)
 {
        GtkWidget *widget = wizard->email;
@@ -141,95 +436,219 @@ static void initialize_fonts(WizardWindow *wizard)
        g_free(tmp);
 }
 
+#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"
+#define FACE "iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAAM1BMVEUAAAAcJCI\n\
+ ONl1JUi0+Z4daY2NZciPabV9ykS5kj6Wsl2ybmZOBsMjZxK2wzN3Pzczs7OsCAGN0AAAAAXRSTlM\n\
+ AQObYZgAAAAFiS0dEAIgFHUgAAAIVSURBVEjH1ZbtlqMgDIaFECoGhPu/2s0b0Lais/NzN6d1OJ7\n\
+ 3yReQzrL8B5Zy3rvl9At52Pf2tv1vSMjtYj8jaa8XUyI/yn3YD6sigj/2Tf5Bn069MIsTPHvx/t5\n\
+ /3rU/6JCIY3YwGe26r/cwUfE3cFe5T28L0K5rJAUHEeYAQxs8DHojjk3M9wECU4xxjXisI8RA0gy\n\
+ oczJZJOjxiTFZVTchAnIRJrgdmEGDyFfAI3UuG5FmYTkR9RDrIC4H0SqV4pzpEcUp0HNLjwBv+jA\n\
+ dikUE5g9iBvzmu3sH2oDk4lnHd829+2Q9gj6kDqDPg7hsGwBzH02fE3ZCt6ZHmlNKIMjMeRwra5I\n\
+ ecgNoBnLGPmzaHPJIwLY8Sq2M/tLUJfj0QcqmfVXAdLSStIYF8dzWjBBb2VgvDa4mO9oc651OiUo\n\
+ BEKbZokdPATF9E9oKAjQJcJOniaPXrVZRAnVWaqIyqRoNC8ZJvgCcW8XN39RqxVP1rS8Yd4WnCdN\n\
+ aRTo2jJRDbg3vtCpEUGffgDPhqKDaSuVqYtOplFIvIcx3HUI5/MuIWl6vKyBjNlqEru8hbFXqBPA\n\
+ 5TpHGIUZOePeaIyzfQ/g9Xg0opU1AvdfXM9floYhv92pPAE96OZtkPV8eivgQi9RTfwPUU36I26n\n\
+ Hy+WuCJzAT7efMSeA1TNf2/VugDz+dN139xfA5ffxGZDD+MvcP/uvyB80wzZ76wbz8gAAAABJRU5\n\
+ ErkJggg=="
+
 static void write_welcome_email(WizardWindow *wizard)
 {
        gchar buf_date[64];
+       gchar *head=NULL;
        gchar *body=NULL;
+       gchar *msg=NULL;
        const gchar *mailbox = gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name));
        Folder *folder = folder_find_from_path(mailbox);
        FolderItem *inbox = folder ? folder->inbox:NULL;
        gchar *file = get_tmp_file();
+       gchar enc_from_name[BUFFSIZE], enc_to_name[BUFFSIZE], enc_subject[BUFFSIZE];
        
        get_rfc822_date(buf_date, sizeof(buf_date));
 
-       body = g_strdup_printf(
-               "From: Sylpheed-Claws Team <sylpheed-claws-users@lists.sf.net>\n"
+       conv_encode_header_full(enc_subject, sizeof(enc_subject), 
+                       Q_("Welcome Mail Subject|Welcome to Claws Mail"),
+                       strlen("Subject: "), FALSE, CS_INTERNAL);
+       conv_encode_header_full(enc_to_name, sizeof(enc_to_name), 
+                       gtk_entry_get_text(GTK_ENTRY(wizard->full_name)),
+                       strlen("To: "), TRUE, CS_INTERNAL);
+       conv_encode_header_full(enc_from_name, sizeof(enc_from_name), 
+                       _("The Claws Mail Team"),
+                       strlen("From: "), TRUE, CS_INTERNAL);
+
+       head = g_strdup_printf(
+               "From: %s <%s>\n"
                "To: %s <%s>\n"
                "Date: %s\n"
-               "Subject: Welcome to Sylpheed-Claws.\n"
-               "\n"
-               "Welcome to Sylpheed-Claws\n"
-               "-------------------------\n"
+               "Subject: %s\n"
+               "X-Face: %s\n"
+               "Face: %s\n"
+               "Content-Type: text/plain; charset=UTF-8\n",
+               enc_from_name,
+               USERS_ML_ADDR,
+               enc_to_name,
+               gtk_entry_get_text(GTK_ENTRY(wizard->email)),
+               buf_date, enc_subject, XFACE, FACE);
+       body = g_strdup_printf(
+               _("\n"
+               "Welcome to Claws Mail\n"
+               "---------------------\n"
                "\n"
                "Now that you have set up your account you can fetch your\n"
-               "mail by clicking the 'Get All' button at the left of the\n"
+               "mail by clicking the 'Get Mail' button at the left of the\n"
                "toolbar.\n"
                "\n"
+               "Claws Mail has lots of extra features accessible via plugins,\n"
+               "like anti-spam filtering and learning (via the Bogofilter or\n"
+               "SpamAssassin plugins), privacy protection (via PGP/Mime), an RSS\n"
+               "aggregator, a calendar, and much more. You can load them from\n"
+               "the menu entry '/Configuration/Plugins'.\n"
+               "\n"
                "You can change your Account Preferences by using the menu\n"
                "entry '/Configuration/Preferences for current account'\n"
                "and change the general Preferences by using\n"
                "'/Configuration/Preferences'.\n"
                "\n"
-               "You can find futher information in the Sylpheed-Claws manual,\n"
+               "You can find further information in the Claws Mail manual,\n"
                "which can be accessed by using the menu entry '/Help/Manual'\n"
                "or online at the URL given below.\n"
                "\n"
                "Useful URLs\n"
                "-----------\n"
-               "Homepage:      <http://claws.sylpheed.org>\n"
-               "Manual:        <http://claws.sylpheed.org/manual/>\n"
-               "FAQ:          <http://claws.sylpheed.org/faq.php>\n"
-               "Themes:        <http://claws.sylpheed.org/themes.php>\n"
-               "Mailing Lists: <http://claws.sylpheed.org/MLs.php>\n"
+               "Homepage:      <%s>\n"
+               "Manual:        <%s>\n"
+               "FAQ:          <%s>\n"
+               "Themes:        <%s>\n"
+               "Mailing Lists: <%s>\n"
                "\n"
                "LICENSE\n"
                "-------\n"
-               "Sylpheed-Claws is free software, released under the terms\n"
-               "of the GNU General Public License, version 2 or later, as\n"
+               "Claws Mail is free software, released under the terms\n"
+               "of the GNU General Public License, version 3 or later, as\n"
                "published by the Free Software Foundation, 51 Franklin Street,\n"
                "Fifth Floor, Boston, MA 02110-1301, USA. The license can be\n"
-               "found at <http://www.gnu.org/licenses/gpl.html>.\n"
+               "found at <%s>.\n"
                "\n"
                "DONATIONS\n"
                "---------\n"
-               "If you wish to donate to the Sylpheed-Claws project you can do\n"
-               "so at <https://sourceforge.net/donate/index.php?group_id=25528>.",             gtk_entry_get_text(GTK_ENTRY(wizard->full_name)),
-               gtk_entry_get_text(GTK_ENTRY(wizard->email)),
-               buf_date);
+               "If you wish to donate to the Claws Mail project you can do\n"
+               "so at <%s>.\n\n"),
+               HOMEPAGE_URI, MANUAL_URI, FAQ_URI, THEMES_URI, MAILING_LIST_URI,
+               GPL_URI, DONATE_URI);
        
+       msg = g_strconcat(head, body, NULL);
+
        if (inbox && inbox->total_msgs == 0
-        && str_write_to_file(body, file) >= 0) {
+        && str_write_to_file(msg, file) >= 0) {
                MsgFlags flags = { MSG_UNREAD|MSG_NEW, 0};
                folder_item_add_msg(inbox, file, &flags, FALSE);
        }
+       g_free(head);
        g_free(body);
-       g_unlink(file); 
+       g_free(msg);
+       g_unlink(file);
 }
+#undef XFACE
+
 static gboolean wizard_write_config(WizardWindow *wizard)
 {
-       gboolean mailbox_ok = FALSE;
+       static gboolean mailbox_ok = FALSE;
        PrefsAccount *prefs_account = prefs_account_new();
        GList *account_list = NULL;
        GtkWidget *menu, *menuitem;
-       
+       gchar *smtp_server, *recv_server;
+       gchar *tmp;
+       gint smtp_port, recv_port;
+#ifdef USE_OPENSSL                     
+       SSLType smtp_ssl_type, recv_ssl_type;
+#endif
+
        menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(wizard->recv_type));
        menuitem = gtk_menu_get_active(GTK_MENU(menu));
        prefs_account->protocol = GPOINTER_TO_INT
                        (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
        
-       if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4) {
-               mailbox_ok = setup_write_mailbox_path(wizard->mainwin, 
-                               gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name)));
-       } else
-               mailbox_ok = TRUE;
+       
+       if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4 && 
+           !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name)))) {
+               alertpanel_error(_("Please enter the mailbox name."));
+               g_free(prefs_account);
+               gtk_notebook_set_current_page (
+                       GTK_NOTEBOOK(wizard->notebook), 
+                       MAILBOX_PAGE);
+               return FALSE;
+       }
+
+       if (!mailbox_ok) {
+               if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4) {
+                       mailbox_ok = setup_write_mailbox_path(wizard->mainwin, 
+                                       gtk_entry_get_text(
+                                               GTK_ENTRY(wizard->mailbox_name)));
+               } else
+                       mailbox_ok = TRUE;
+       }
 
        if (!mailbox_ok) {
+               /* alertpanel done by setup_write_mailbox_path */
+               g_free(prefs_account);
+               gtk_notebook_set_current_page (
+                       GTK_NOTEBOOK(wizard->notebook), 
+                       MAILBOX_PAGE);
+               return FALSE;
+       }
+       
+       if (!strlen(gtk_entry_get_text(GTK_ENTRY(wizard->full_name)))
+       ||  !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->email)))) {
+               alertpanel_error(_("Please enter your name and email address."));
+               g_free(prefs_account);
                gtk_notebook_set_current_page (
                        GTK_NOTEBOOK(wizard->notebook), 
-                       4);
+                       USER_PAGE);
                return FALSE;
        }
        
+       if (prefs_account->protocol != A_LOCAL) {
+               if (!strlen(gtk_entry_get_text(GTK_ENTRY(wizard->recv_username)))
+               ||  !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)))) {
+                       alertpanel_error(_("Please enter your receiving server "
+                                          "and username."));
+                       g_free(prefs_account);
+                       gtk_notebook_set_current_page (
+                               GTK_NOTEBOOK(wizard->notebook), 
+                               RECV_PAGE);
+                       return FALSE;
+               }
+       } else {
+               if (!strlen(gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)))) {
+                       alertpanel_error(_("Please enter your username."));
+                       g_free(prefs_account);
+                       gtk_notebook_set_current_page (
+                               GTK_NOTEBOOK(wizard->notebook), 
+                               RECV_PAGE);
+                       return FALSE;
+               }
+       }
+       
+       if (!strlen(gtk_entry_get_text(GTK_ENTRY(wizard->smtp_server)))) {
+               alertpanel_error(_("Please enter your SMTP server."));
+               g_free(prefs_account);
+               gtk_notebook_set_current_page (
+                       GTK_NOTEBOOK(wizard->notebook), 
+                       SMTP_PAGE);
+               return FALSE;
+       }
+
+       if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_auth))) {
+               if (prefs_account->protocol == A_LOCAL
+               &&  !strlen(gtk_entry_get_text(GTK_ENTRY(wizard->smtp_username)))) {
+                       alertpanel_error(_("Please enter your SMTP username."));
+                       g_free(prefs_account);
+                       gtk_notebook_set_current_page (
+                               GTK_NOTEBOOK(wizard->notebook), 
+                               SMTP_PAGE);
+                       return FALSE;           
+               } /* if it's not local we'll use the reception server */
+       }
+
        if (prefs_account->protocol != A_LOCAL)
                prefs_account->account_name = g_strdup_printf("%s@%s",
                                gtk_entry_get_text(GTK_ENTRY(wizard->recv_username)),
@@ -238,36 +657,87 @@ static gboolean wizard_write_config(WizardWindow *wizard)
                prefs_account->account_name = g_strdup_printf("%s",
                                gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
 
+       recv_server = g_strdup(gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
+       smtp_server = g_strdup(gtk_entry_get_text(GTK_ENTRY(wizard->smtp_server)));
+
+       if (prefs_account->protocol != A_LOCAL && strstr(recv_server, ":")) {
+               recv_port = atoi(strstr(recv_server, ":")+1);
+               *(strstr(recv_server, ":")) = '\0';
+               if (prefs_account->protocol == A_IMAP4) {
+                       prefs_account->set_imapport = TRUE;
+                       prefs_account->imapport = recv_port;
+               } else if (prefs_account->protocol == A_POP3) {
+                       prefs_account->set_popport = TRUE;
+                       prefs_account->popport = recv_port;
+               }
+       }
+       if (strstr(smtp_server, ":")) {
+               smtp_port = atoi(strstr(smtp_server, ":")+1);
+               *(strstr(smtp_server, ":")) = '\0';
+               prefs_account->set_smtpport = TRUE;
+               prefs_account->smtpport = smtp_port;
+       }
+       
        prefs_account->name = g_strdup(
                                gtk_entry_get_text(GTK_ENTRY(wizard->full_name)));
        prefs_account->address = g_strdup(
                                gtk_entry_get_text(GTK_ENTRY(wizard->email)));
        prefs_account->organization = g_strdup(
                                gtk_entry_get_text(GTK_ENTRY(wizard->organization)));
-       prefs_account->smtp_server = g_strdup(
-                               gtk_entry_get_text(GTK_ENTRY(wizard->smtp_server)));
+       prefs_account->smtp_server = g_strdup(smtp_server);
+
+       tmp = g_path_get_basename(gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name)));
+       prefs_account->inbox = g_strdup_printf("#mh/%s/inbox",
+                       (!strcmp("Mail", gtk_entry_get_text(GTK_ENTRY(wizard->mailbox_name))))
+                               ?_("Mailbox"):tmp);
+       g_free(tmp);
+       prefs_account->local_inbox = g_strdup(prefs_account->inbox);
 
        if (prefs_account->protocol != A_LOCAL)
-               prefs_account->recv_server = g_strdup(
-                               gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
+               prefs_account->recv_server = g_strdup(recv_server);
        else
-               prefs_account->local_mbox = g_strdup(
-                               gtk_entry_get_text(GTK_ENTRY(wizard->recv_server)));
+               prefs_account->local_mbox = g_strdup(recv_server);
+
+       g_free(recv_server);
+       g_free(smtp_server);
 
        prefs_account->userid = g_strdup(
                                gtk_entry_get_text(GTK_ENTRY(wizard->recv_username)));
        prefs_account->passwd = g_strdup(
                                gtk_entry_get_text(GTK_ENTRY(wizard->recv_password)));
 
-#ifdef USE_OPENSSL                     
-       if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_ssl)))
-               prefs_account->ssl_smtp = SSL_TUNNEL;
+       prefs_account->smtp_userid = g_strdup(
+                               gtk_entry_get_text(GTK_ENTRY(wizard->smtp_username)));
+       prefs_account->smtp_passwd = g_strdup(
+                               gtk_entry_get_text(GTK_ENTRY(wizard->smtp_password)));
+       if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_auth))) {
+               prefs_account->use_smtp_auth = TRUE;
+       }
+
+#ifdef USE_OPENSSL
+       smtp_ssl_type = SSL_NONE;
+       recv_ssl_type = SSL_NONE;       
+
+       if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_ssl))) {
+               if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_tls)))
+                       smtp_ssl_type = SSL_STARTTLS;
+               else
+                       smtp_ssl_type = SSL_TUNNEL;
+       }
        if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->recv_use_ssl))) {
-               if (prefs_account->protocol == A_IMAP4)
-                       prefs_account->ssl_imap = SSL_TUNNEL;
+               if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wizard->recv_use_tls)))
+                       recv_ssl_type = SSL_STARTTLS;
                else
-                       prefs_account->ssl_pop = SSL_TUNNEL;
+                       recv_ssl_type = SSL_TUNNEL;
        }
+
+       prefs_account->ssl_smtp = smtp_ssl_type;
+
+       if (prefs_account->protocol == A_IMAP4)
+               prefs_account->ssl_imap = recv_ssl_type;
+       else
+               prefs_account->ssl_pop = recv_ssl_type;
+
 #endif
        if (prefs_account->protocol == A_IMAP4) {
                gchar *directory = gtk_editable_get_chars(
@@ -275,6 +745,9 @@ static gboolean wizard_write_config(WizardWindow *wizard)
                if (directory && strlen(directory)) {
                        prefs_account->imap_dir = g_strdup(directory);
                }
+               prefs_account->imap_subsonly = 
+                       gtk_toggle_button_get_active(
+                               GTK_TOGGLE_BUTTON(wizard->subsonly_checkbtn));
                g_free(directory);
        }
 
@@ -287,6 +760,9 @@ static gboolean wizard_write_config(WizardWindow *wizard)
        if (wizard->create_mailbox && prefs_account->protocol != A_IMAP4)
                write_welcome_email(wizard);
        
+#ifndef G_OS_WIN32 
+       plugin_load_standard_plugins();
+#endif
        return TRUE;
 }
 
@@ -304,7 +780,7 @@ static GtkWidget* create_page (WizardWindow *wizard, const char * title)
        /* create the titlebar */
        hbox = gtk_hbox_new (FALSE, 12);
        image = stock_pixmap_widget(wizard->window, 
-                               STOCK_PIXMAP_SYLPHEED_ICON);
+                               STOCK_PIXMAP_CLAWS_MAIL_ICON);
        gtk_box_pack_start (GTK_BOX(hbox), image, FALSE, FALSE, 0);
        title_string = g_strconcat ("<span size=\"xx-large\" weight=\"ultrabold\">", title ? title : "", "</span>", NULL);
        w = gtk_label_new (title_string);
@@ -326,57 +802,56 @@ static GtkWidget* create_page (WizardWindow *wizard, const char * title)
        return vbox;
 }
 
-#define GTK_TABLE_ADD_ROW_AT(table,text,entry,i) {                           \
-       GtkWidget *label = gtk_label_new(text);                               \
-       gtk_table_attach(GTK_TABLE(table), label,                             \
-                        0,1,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);            \
-       if (GTK_IS_MISC(label))                                               \
-               gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);              \
-       gtk_table_attach(GTK_TABLE(table), entry,                             \
-                        1,2,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);            \
+#define PACK_BOX(hbox,text,entry) {                                    \
+       GtkWidget *label = gtk_label_new(text);                         \
+       gtk_label_set_use_markup(GTK_LABEL(label), TRUE);               \
+       if (GTK_IS_MISC(label))                                         \
+               gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);        \
+       gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);      \
+       gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0);        \
 }
 
-static gchar *get_default_email_addr(void)
+static gchar *get_default_server(WizardWindow * wizard, const gchar *type)
 {
-       gchar *domain_name = g_strdup(get_domain_name());
-       gchar *result;
-       if (strchr(domain_name, '.') != strrchr(domain_name, '.')
-       && strlen(strchr(domain_name, '.')) > 6) {
-               gchar *tmp = g_strdup(strchr(domain_name, '.')+1);
-               g_free(domain_name);
-               domain_name = tmp;
+       if (!strcmp(type, "smtp")) {
+               if (!tmpl.smtpserver || !strlen(tmpl.smtpserver))
+                       return g_strconcat(type, ".", tmpl.domain, NULL);
+               else 
+                       return g_strdup(tmpl.smtpserver);
+       } else {
+               if (!tmpl.recvserver || !strlen(tmpl.recvserver))
+                       return g_strconcat(type, ".", tmpl.domain, NULL);
+               else 
+                       return g_strdup(tmpl.recvserver);
+       }
+}
+
+static gchar *get_default_account(WizardWindow * wizard)
+{
+       gchar *result = NULL;
+       
+       if (!tmpl.recvuser || !strlen(tmpl.recvuser)) {
+               result = gtk_editable_get_chars(
+                               GTK_EDITABLE(wizard->email), 0, -1);
+
+               if (strstr(result, "@")) {
+                       *(strstr(result,"@")) = '\0';
+               } 
+       } else {
+               result = g_strdup(tmpl.recvuser);
        }
-       result = g_strdup_printf("%s@%s",
-                               g_get_user_name(),
-                               domain_name);
-       g_free(domain_name);
        return result;
 }
 
-static gchar *get_default_server(WizardWindow * wizard, const gchar *type)
+static gchar *get_default_smtp_account(WizardWindow * wizard)
 {
-       gchar *domain_name = g_strdup(get_domain_name());
-       gchar *result;
-       
-       if (strchr(domain_name, '.') != strrchr(domain_name, '.')
-       && strlen(strchr(domain_name, '.')) > 6) {
-               gchar *tmp = g_strdup(strchr(domain_name, '.')+1);
-               g_free(domain_name);
-               domain_name = tmp;
-       } else if (strchr(domain_name, '.') == NULL) {
-               /* only hostname found, use email suffix */
-               gchar *mail;
-               mail = gtk_editable_get_chars(GTK_EDITABLE(wizard->email), 0, -1);
-
-               if (strlen (mail) && strstr(mail, "@")) {
-                       g_free(domain_name);
-                       domain_name = g_strdup(strstr(mail, "@")+1);
-               }
-               g_free(mail);
+       gchar *result = NULL;
+       
+       if (!tmpl.smtpuser || !strlen(tmpl.smtpuser)) {
+               return g_strdup("");
+       } else {
+               result = g_strdup(tmpl.smtpuser);
        }
-       result = g_strdup_printf("%s.%s",
-                               type, domain_name);
-       g_free(domain_name);
        return result;
 }
 
@@ -392,6 +867,10 @@ static void wizard_email_changed(GtkWidget *widget, gpointer data)
        gtk_entry_set_text(GTK_ENTRY(wizard->smtp_server), text);
        g_free(text);
 
+       text = get_default_account(wizard);
+       gtk_entry_set_text(GTK_ENTRY(wizard->recv_username), text);
+       g_free(text);
+
        if (protocol == A_POP3) {
                text = get_default_server(wizard, "pop");
                gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
@@ -401,36 +880,45 @@ static void wizard_email_changed(GtkWidget *widget, gpointer data)
                gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
                g_free(text);
        } else if (protocol == A_LOCAL) {
-               gchar *mbox = g_strdup_printf("/var/mail/%s", g_get_user_name());
-               gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), mbox);
-               g_free(mbox);
+               gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), tmpl.mboxfile?tmpl.mboxfile:"");
        }
+       
 }
 
 static GtkWidget* user_page (WizardWindow * wizard)
 {
-       GtkWidget *table = gtk_table_new(3,2, FALSE);
-       gchar *text;
-       gint i = 0;
+       GtkWidget *table = gtk_table_new(1,1, FALSE);
+       GtkWidget *vbox;
+       GtkWidget *hbox;
        
        gtk_table_set_row_spacings(GTK_TABLE(table), 4);
        gtk_table_set_col_spacings(GTK_TABLE(table), 8);
 
+       vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
+       gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
+
+       gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2, 
+                        GTK_EXPAND|GTK_FILL, 0, 0, 0);
+
+       hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
+       gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
        wizard->full_name = gtk_entry_new();
-       gtk_entry_set_text(GTK_ENTRY(wizard->full_name), g_get_real_name());
-       GTK_TABLE_ADD_ROW_AT(table, _("Your name:"), 
-                            wizard->full_name, i); i++;
+       gtk_entry_set_text(GTK_ENTRY(wizard->full_name), tmpl.name?tmpl.name:"");
+       PACK_BOX(hbox, _("<span weight=\"bold\">Your name:</span>"),
+                wizard->full_name);
        
+       hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
+       gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
        wizard->email = gtk_entry_new();
-       text = get_default_email_addr();
-       gtk_entry_set_text(GTK_ENTRY(wizard->email), text);
-       g_free(text);
-       GTK_TABLE_ADD_ROW_AT(table, _("Your email address:"), 
-                            wizard->email, i); i++;
+       gtk_entry_set_text(GTK_ENTRY(wizard->email), tmpl.email?tmpl.email:"");
+       PACK_BOX(hbox, _("<span weight=\"bold\">Your email address:</span>"),
+                wizard->email);
        
+       hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
+       gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);      
        wizard->organization = gtk_entry_new();
-       GTK_TABLE_ADD_ROW_AT(table, _("Your organization:"), 
-                            wizard->organization, i); i++;
+       gtk_entry_set_text(GTK_ENTRY(wizard->organization), tmpl.organization?tmpl.organization:"");
+       PACK_BOX(hbox, _("Your organization:"), wizard->organization);
        
        g_signal_connect(G_OBJECT(wizard->email), "changed",
                         G_CALLBACK(wizard_email_changed),
@@ -440,184 +928,375 @@ static GtkWidget* user_page (WizardWindow * wizard)
 
 static GtkWidget* mailbox_page (WizardWindow * wizard)
 {
-       GtkWidget *table = gtk_table_new(1,2, FALSE);
-       gint i = 0;
-       
+       GtkWidget *table = gtk_table_new(1,1, FALSE);
+       GtkWidget *vbox;
+       GtkWidget *hbox;
+       GtkTooltips *tips = gtk_tooltips_new();
+
        gtk_table_set_row_spacings(GTK_TABLE(table), 4);
        gtk_table_set_col_spacings(GTK_TABLE(table), 8);
 
+       vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
+       gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
+
+       gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2, 
+                        GTK_EXPAND|GTK_FILL, 0, 0, 0);
+
+       hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
+       gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
        wizard->mailbox_name = gtk_entry_new();
-       gtk_entry_set_text(GTK_ENTRY(wizard->mailbox_name), "Mail");
-       GTK_TABLE_ADD_ROW_AT(table, _("Mailbox name:"), 
-                            wizard->mailbox_name, i); i++;
+       gtk_entry_set_text(GTK_ENTRY(wizard->mailbox_name), tmpl.mailbox?tmpl.mailbox:"");
+
+       gtk_tooltips_set_tip(GTK_TOOLTIPS(tips), wizard->mailbox_name,
+                            _("You can also specify an absolute path, for example: "
+                              "\"/home/john/Documents/Mail\""),
+                            NULL);
+
+       PACK_BOX(hbox, _("<span weight=\"bold\">Mailbox name:</span>"),
+                wizard->mailbox_name);
        
        return table;
 }
 
+static void smtp_auth_changed (GtkWidget *btn, gpointer data)
+{
+       WizardWindow *wizard = (WizardWindow *)data;
+       gboolean do_auth = gtk_toggle_button_get_active(
+               GTK_TOGGLE_BUTTON(wizard->smtp_auth));
+       gtk_widget_set_sensitive(wizard->smtp_username, do_auth);
+       gtk_widget_set_sensitive(wizard->smtp_username_label, do_auth);
+       gtk_widget_set_sensitive(wizard->smtp_password, do_auth);
+       gtk_widget_set_sensitive(wizard->smtp_password_label, do_auth);
+}
+
 static GtkWidget* smtp_page (WizardWindow * wizard)
 {
-       GtkWidget *table = gtk_table_new(1,2, FALSE);
+       GtkWidget *table = gtk_table_new(1, 1, FALSE);
+       GtkWidget *vbox;
+       GtkWidget *hbox;
+       GtkTooltips *tips = gtk_tooltips_new();
        gchar *text;
-       gint i = 0;
        
        gtk_table_set_row_spacings(GTK_TABLE(table), 4);
        gtk_table_set_col_spacings(GTK_TABLE(table), 8);
 
+       vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
+       gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
+
+       gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2, 
+                        GTK_EXPAND|GTK_FILL, 0, 0, 0);
+
+       hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
+       gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
        wizard->smtp_server = gtk_entry_new();
        text = get_default_server(wizard, "smtp");
        gtk_entry_set_text(GTK_ENTRY(wizard->smtp_server), text);
        g_free(text);
-       GTK_TABLE_ADD_ROW_AT(table, _("SMTP server address:"), 
-                            wizard->smtp_server, i); i++;
+
+       gtk_tooltips_set_tip(GTK_TOOLTIPS(tips), wizard->smtp_server,
+                            _("You can specify the port number by appending it at the end: "
+                              "\"mail.example.com:25\""),
+                            NULL);
+
+       PACK_BOX(hbox, _("<span weight=\"bold\">SMTP server address:</span>"),
+                wizard->smtp_server);
+
+
+       hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
+       gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
+       wizard->smtp_auth = gtk_check_button_new_with_label(
+                                       _("Use authentication"));
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->smtp_auth),
+                       tmpl.smtpauth);
+       g_signal_connect(G_OBJECT(wizard->smtp_auth), "toggled",
+                        G_CALLBACK(smtp_auth_changed),
+                        wizard);
+       gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_auth, FALSE, FALSE, 0);
+
+       text = get_default_smtp_account(wizard);
+
+       hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
+       gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
+       wizard->smtp_username = gtk_entry_new();
+       gtk_entry_set_text(GTK_ENTRY(wizard->smtp_username), text);
+       g_free(text);
+       wizard->smtp_username_label = gtk_label_new(_("SMTP username:\n"
+                                       "<span size=\"small\">(empty to use the same as receive)</span>"));
+       gtk_label_set_use_markup(GTK_LABEL(wizard->smtp_username_label), TRUE);
+       if (GTK_IS_MISC(wizard->smtp_username_label))                                                 
+               gtk_misc_set_alignment(GTK_MISC(wizard->smtp_username_label), 1, 0.5);        
+       gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_username_label, FALSE, FALSE, 0);
+       gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_username, TRUE, TRUE, 0);
+
+       hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
+       gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
+       wizard->smtp_password = gtk_entry_new();
+       gtk_entry_set_text(GTK_ENTRY(wizard->smtp_password), tmpl.smtppass?tmpl.smtppass:""); 
+       gtk_entry_set_visibility(GTK_ENTRY(wizard->smtp_password), FALSE);
+       wizard->smtp_password_label = gtk_label_new(_("SMTP password:\n"
+                                       "<span size=\"small\">(empty to use the same as receive)</span>"));
+       gtk_label_set_use_markup(GTK_LABEL(wizard->smtp_password_label), TRUE);
+       if (GTK_IS_MISC(wizard->smtp_password_label))                                                 
+               gtk_misc_set_alignment(GTK_MISC(wizard->smtp_password_label), 1, 0.5);        
+       gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_password_label, FALSE, FALSE, 0);
+       gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_password, TRUE, TRUE, 0);
+#ifdef USE_OPENSSL
+       hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
+       gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
+       wizard->smtp_use_ssl = gtk_check_button_new_with_label(
+                                       _("Use SSL to connect to SMTP server"));
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_ssl),
+                       tmpl.smtpssl != 0);
+       gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_use_ssl, FALSE, FALSE, 0);
+
+       hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
+       gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
+       wizard->smtp_use_tls = gtk_check_button_new_with_label(
+                                       _("Use SSL via STARTTLS"));
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->smtp_use_tls),
+                       tmpl.smtpssl == 2);
+       gtk_box_pack_start(GTK_BOX(hbox), wizard->smtp_use_tls, FALSE, FALSE, 0);
+       SET_TOGGLE_SENSITIVITY (wizard->smtp_use_ssl, wizard->smtp_use_tls);
+#endif
+       smtp_auth_changed(NULL, wizard);
        return table;
 }
 
-static void wizard_protocol_changed(GtkMenuItem *menuitem, gpointer data)
+static void wizard_protocol_change(WizardWindow *wizard, RecvProtocol protocol)
 {
-       WizardWindow *wizard = (WizardWindow *)data;
-       RecvProtocol protocol;
        gchar *text;
-       protocol = GPOINTER_TO_INT
-               (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
        
        if (protocol == A_POP3) {
                text = get_default_server(wizard, "pop");
                gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
                gtk_widget_hide(wizard->recv_imap_label);
                gtk_widget_hide(wizard->recv_imap_subdir);
+               gtk_widget_hide(wizard->subsonly_checkbtn);
                gtk_widget_show(wizard->recv_username);
                gtk_widget_show(wizard->recv_password);
                gtk_widget_show(wizard->recv_username_label);
                gtk_widget_show(wizard->recv_password_label);
-               gtk_label_set_text(GTK_LABEL(wizard->recv_label), _("Server address:"));
+               gtk_widget_hide(wizard->no_imap_warning);
+#ifdef USE_OPENSSL
+               gtk_widget_show(wizard->recv_use_ssl);
+               gtk_widget_show(wizard->recv_use_tls);
+#endif
+               gtk_label_set_text(GTK_LABEL(wizard->recv_label), _("<span weight=\"bold\">Server address:</span>"));
+               gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
+               gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, TRUE);
                g_free(text);
        } else if (protocol == A_IMAP4) {
+#ifdef HAVE_LIBETPAN
                text = get_default_server(wizard, "imap");
                gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
                gtk_widget_show(wizard->recv_imap_label);
                gtk_widget_show(wizard->recv_imap_subdir);
+               gtk_widget_show(wizard->subsonly_checkbtn);
                gtk_widget_show(wizard->recv_username);
                gtk_widget_show(wizard->recv_password);
                gtk_widget_show(wizard->recv_username_label);
                gtk_widget_show(wizard->recv_password_label);
-               gtk_label_set_text(GTK_LABEL(wizard->recv_label), _("Server address:"));
+               gtk_widget_hide(wizard->no_imap_warning);
+#ifdef USE_OPENSSL
+               gtk_widget_show(wizard->recv_use_ssl);
+               gtk_widget_show(wizard->recv_use_tls);
+#endif
+               gtk_label_set_text(GTK_LABEL(wizard->recv_label), _("<span weight=\"bold\">Server address:</span>"));
+               gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
+               gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, TRUE);
                g_free(text);
+#else
+               gtk_widget_hide(wizard->recv_imap_label);
+               gtk_widget_hide(wizard->recv_imap_subdir);
+               gtk_widget_hide(wizard->subsonly_checkbtn);
+               gtk_widget_hide(wizard->recv_username);
+               gtk_widget_hide(wizard->recv_password);
+               gtk_widget_hide(wizard->recv_username_label);
+               gtk_widget_hide(wizard->recv_password_label);
+               gtk_widget_show(wizard->no_imap_warning);
+#ifdef USE_OPENSSL
+               gtk_widget_hide(wizard->recv_use_ssl);
+               gtk_widget_hide(wizard->recv_use_tls);
+#endif
+               gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, FALSE);
+#endif
        } else if (protocol == A_LOCAL) {
-               gchar *mbox = g_strdup_printf("/var/mail/%s", g_get_user_name());
-               gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), mbox);
-               g_free(mbox);
-               gtk_label_set_text(GTK_LABEL(wizard->recv_label), _("Local mailbox:"));
+               gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), tmpl.mboxfile?tmpl.mboxfile:"");
+               gtk_label_set_text(GTK_LABEL(wizard->recv_label), _("<span weight=\"bold\">Local mailbox:</span>"));
+               gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
+               gtk_widget_hide(wizard->no_imap_warning);
                gtk_widget_hide(wizard->recv_imap_label);
                gtk_widget_hide(wizard->recv_imap_subdir);
+               gtk_widget_hide(wizard->subsonly_checkbtn);
                gtk_widget_hide(wizard->recv_username);
                gtk_widget_hide(wizard->recv_password);
                gtk_widget_hide(wizard->recv_username_label);
                gtk_widget_hide(wizard->recv_password_label);
+#ifdef USE_OPENSSL
+               gtk_widget_hide(wizard->recv_use_ssl);
+               gtk_widget_hide(wizard->recv_use_tls);
+#endif
+               gtk_dialog_set_response_sensitive (GTK_DIALOG(wizard->window), GO_FORWARD, TRUE);
        }
 }
 
+static void wizard_protocol_changed(GtkMenuItem *menuitem, gpointer data)
+{
+       WizardWindow *wizard = (WizardWindow *)data;
+       RecvProtocol protocol;
+       protocol = GPOINTER_TO_INT
+               (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
+
+       wizard_protocol_change(wizard, protocol);       
+}
+
 static GtkWidget* recv_page (WizardWindow * wizard)
 {
-       GtkWidget *table = gtk_table_new(5,2, FALSE);
+       GtkWidget *table = gtk_table_new(1,1, FALSE);
        GtkWidget *menu = gtk_menu_new();
        GtkWidget *menuitem;
+       GtkTooltips *tips = gtk_tooltips_new();
+       GtkWidget *vbox;
+       GtkWidget *hbox;
        gchar *text;
-       gint i = 0;
-       
+       gint index = 0;
+
        gtk_table_set_row_spacings(GTK_TABLE(table), 4);
        gtk_table_set_col_spacings(GTK_TABLE(table), 8);
 
+       vbox = gtk_vbox_new(FALSE, VSPACING_NARROW);
+       gtk_container_set_border_width(GTK_CONTAINER(vbox), VSPACING_NARROW_2);
+
+       gtk_table_attach(GTK_TABLE(table), vbox, 0,1,1,2, 
+                        GTK_EXPAND|GTK_FILL, 0, 0, 0);
+
+       hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
+       gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
        wizard->recv_type = gtk_option_menu_new();
        
        MENUITEM_ADD (menu, menuitem, _("POP3"), A_POP3);
        g_signal_connect(G_OBJECT(menuitem), "activate",
                         G_CALLBACK(wizard_protocol_changed),
                         wizard);
+
        MENUITEM_ADD (menu, menuitem, _("IMAP"), A_IMAP4);
        g_signal_connect(G_OBJECT(menuitem), "activate",
                         G_CALLBACK(wizard_protocol_changed),
                         wizard);
+
        MENUITEM_ADD (menu, menuitem, _("Local mbox file"), A_LOCAL);
        g_signal_connect(G_OBJECT(menuitem), "activate",
                         G_CALLBACK(wizard_protocol_changed),
                         wizard);
 
        gtk_option_menu_set_menu (GTK_OPTION_MENU (wizard->recv_type), menu);
-       GTK_TABLE_ADD_ROW_AT(table, _("Server type:"), 
-                            wizard->recv_type, i); i++;
+       switch(tmpl.recvtype) {
+       case A_POP3: 
+               index = 0;
+               break;
+       case A_IMAP4:
+               index = 1;
+               break;
+       case A_LOCAL:
+               index = 2;
+               break;
+       default:
+               index = 0;
+       }
+       gtk_option_menu_set_history(GTK_OPTION_MENU (wizard->recv_type), index);
+       PACK_BOX(hbox, _("<span weight=\"bold\">Server type:</span>"),
+                wizard->recv_type);
 
+       hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
+       gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
        wizard->recv_server = gtk_entry_new();
        text = get_default_server(wizard, "pop");
        gtk_entry_set_text(GTK_ENTRY(wizard->recv_server), text);
        g_free(text);
        
-       wizard->recv_label = gtk_label_new(_("Server address:"));
-       gtk_table_attach(GTK_TABLE(table), wizard->recv_label,                        
-                        0,1,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);            
+       gtk_tooltips_set_tip(GTK_TOOLTIPS(tips), wizard->recv_server,
+                            _("You can specify the port number by appending it at the end: "
+                              "\"mail.example.com:110\""),
+                            NULL);
+
+       wizard->recv_label = gtk_label_new(_("<span weight=\"bold\">Server address:</span>"));
+       gtk_label_set_use_markup(GTK_LABEL(wizard->recv_label), TRUE);
        if (GTK_IS_MISC(wizard->recv_label))                                                  
                gtk_misc_set_alignment(GTK_MISC(wizard->recv_label), 1, 0.5);         
-       gtk_table_attach(GTK_TABLE(table), wizard->recv_server,       
-                        1,2,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);            
-       i++;
+       gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_label, FALSE, FALSE, 0);
+       gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_server, TRUE, TRUE, 0);
        
+       hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
+       gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
        wizard->recv_username = gtk_entry_new();
-       wizard->recv_username_label = gtk_label_new(_("Username:"));
-       gtk_table_attach(GTK_TABLE(table), wizard->recv_username_label,                               
-                        0,1,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);            
+       wizard->recv_username_label = gtk_label_new(_("<span weight=\"bold\">Username:</span>"));
+       gtk_label_set_use_markup(GTK_LABEL(wizard->recv_username_label), TRUE);
        if (GTK_IS_MISC(wizard->recv_username_label))                                                 
                gtk_misc_set_alignment(GTK_MISC(wizard->recv_username_label), 1, 0.5);        
-       gtk_table_attach(GTK_TABLE(table), wizard->recv_username,             
-                        1,2,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);            
-       i++;
+       gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_username_label, FALSE, FALSE, 0);
+       gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_username, TRUE, TRUE, 0);
        
+       text = get_default_account(wizard);
+       gtk_entry_set_text(GTK_ENTRY(wizard->recv_username), text);
+       g_free(text);
+
+       hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
+       gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
        wizard->recv_password = gtk_entry_new();
+       gtk_entry_set_text(GTK_ENTRY(wizard->recv_password), tmpl.recvpass?tmpl.recvpass:"");
        wizard->recv_password_label = gtk_label_new(_("Password:"));
-       gtk_table_attach(GTK_TABLE(table), wizard->recv_password_label,                               
-                        0,1,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);            
        if (GTK_IS_MISC(wizard->recv_password_label))                                                 
                gtk_misc_set_alignment(GTK_MISC(wizard->recv_password_label), 1, 0.5);        
-       gtk_table_attach(GTK_TABLE(table), wizard->recv_password,             
-                        1,2,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);            
        gtk_entry_set_visibility(GTK_ENTRY(wizard->recv_password), FALSE);
-       i++;
+       gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_password_label, FALSE, FALSE, 0);
+       gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_password, TRUE, TRUE, 0);
        
+#ifdef USE_OPENSSL
+       hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
+       gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
+       wizard->recv_use_ssl = gtk_check_button_new_with_label(
+                                       _("Use SSL to connect to receiving server"));
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->recv_use_ssl),
+                       tmpl.recvssl != 0);
+       gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_use_ssl, FALSE, FALSE, 0);
+
+       hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
+       gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
+       wizard->recv_use_tls = gtk_check_button_new_with_label(
+                                       _("Use SSL via STARTTLS"));
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->recv_use_tls),
+                       tmpl.recvssl == 2);
+       gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_use_tls, FALSE, FALSE, 0);
+       SET_TOGGLE_SENSITIVITY (wizard->recv_use_ssl, wizard->recv_use_tls);
+#endif 
+       hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
+       gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
        wizard->recv_imap_subdir = gtk_entry_new();
+       gtk_entry_set_text(GTK_ENTRY(wizard->recv_imap_subdir), tmpl.imapdir?tmpl.imapdir:"");
        wizard->recv_imap_label = gtk_label_new(_("IMAP server directory:"));
-       
-       gtk_table_attach(GTK_TABLE(table), wizard->recv_imap_label,                           
-                        0,1,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);            
        if (GTK_IS_MISC(wizard->recv_imap_label))                                                     
                gtk_misc_set_alignment(GTK_MISC(wizard->recv_imap_label), 1, 0.5);            
-       gtk_table_attach(GTK_TABLE(table), wizard->recv_imap_subdir,          
-                        1,2,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);            
-
-       i++;
+       gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_imap_label, FALSE, FALSE, 0);
+       gtk_box_pack_start(GTK_BOX(hbox), wizard->recv_imap_subdir, TRUE, TRUE, 0);
        
-       return table;
-}
-
-#ifdef USE_OPENSSL
-static GtkWidget* ssl_page (WizardWindow * wizard)
-{
-       GtkWidget *table = gtk_table_new(2,2, FALSE);
-       gint i = 0;
+       hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
+       gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
+       wizard->subsonly_checkbtn = gtk_check_button_new_with_label(
+                       _("Show only subscribed folders"));
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(wizard->subsonly_checkbtn),
+                       tmpl.subsonly);
+       gtk_box_pack_start(GTK_BOX(hbox), wizard->subsonly_checkbtn, FALSE, FALSE, 0);
        
-       gtk_table_set_row_spacings(GTK_TABLE(table), 4);
-       gtk_table_set_col_spacings(GTK_TABLE(table), 8);
+       hbox = gtk_hbox_new(FALSE, VSPACING_NARROW);
+       gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
+       wizard->no_imap_warning = gtk_label_new(_(
+                         "<span weight=\"bold\">Warning: this version of Claws Mail\n"
+                         "has been built without IMAP support.</span>"));
+       gtk_label_set_use_markup(GTK_LABEL(wizard->no_imap_warning), TRUE);
+       gtk_box_pack_start(GTK_BOX(hbox), wizard->no_imap_warning, FALSE, FALSE, 0);
 
-       wizard->smtp_use_ssl = gtk_check_button_new_with_label(
-                                       _("Use SSL to connect to SMTP server"));
-       gtk_table_attach(GTK_TABLE(table), wizard->smtp_use_ssl,      
-                        0,1,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0); i++;
-       
-       wizard->recv_use_ssl = gtk_check_button_new_with_label(
-                                       _("Use SSL to connect to receiving server"));
-       gtk_table_attach(GTK_TABLE(table), wizard->recv_use_ssl,      
-                        0,1,i,i+1, GTK_EXPAND|GTK_FILL, 0, 0, 0);
-       
        return table;
 }
-#endif
 
 static void
 wizard_response_cb (GtkDialog * dialog, int response, gpointer data)
@@ -661,7 +1340,7 @@ wizard_response_cb (GtkDialog * dialog, int response, gpointer data)
                {
                        if (current_page > 0) {
                                current_page--;
-                               if (current_page == 4 && skip_mailbox_page) {
+                               if (current_page == MAILBOX_PAGE && skip_mailbox_page) {
                                        /* mailbox */
                                        current_page--;
                                }
@@ -674,7 +1353,7 @@ wizard_response_cb (GtkDialog * dialog, int response, gpointer data)
                {
                        if (current_page < (num_pages-1)) {
                                current_page++;
-                               if (current_page == 4 && skip_mailbox_page) {
+                               if (current_page == MAILBOX_PAGE && skip_mailbox_page) {
                                        /* mailbox */
                                        current_page++;
                                }
@@ -688,10 +1367,14 @@ set_sens:
                                current_page > 0);
                gtk_dialog_set_response_sensitive (dialog, GO_FORWARD, 
                                current_page < (num_pages - 1));
-               gtk_dialog_set_response_sensitive (dialog, FINISHED, 
-                               current_page == (num_pages - 1));
-               gtk_dialog_set_response_sensitive (dialog, CANCEL, 
-                               current_page != (num_pages - 1));
+               if (current_page == (num_pages -1)) {
+                       gtk_dialog_set_response_sensitive (dialog, FINISHED, TRUE);
+                       gtk_dialog_set_default_response(GTK_DIALOG(wizard->window), FINISHED);
+               } else {
+                       gtk_dialog_set_response_sensitive (dialog, FINISHED, FALSE);
+                       gtk_dialog_set_default_response(GTK_DIALOG(wizard->window), GO_FORWARD);
+               }
+
        }
 }
 
@@ -705,25 +1388,35 @@ static gint wizard_close_cb(GtkWidget *widget, GdkEventAny *event,
        return FALSE;
 }
 
+#define PACK_WARNING(text) {                                           \
+       label = gtk_label_new(text);                                    \
+       gtk_misc_set_alignment(GTK_MISC(label), 0, 0);                  \
+       gtk_box_pack_end(GTK_BOX(widget), label, FALSE, FALSE, 0);      \
+}
+
 gboolean run_wizard(MainWindow *mainwin, gboolean create_mailbox) {
        WizardWindow *wizard = g_new0(WizardWindow, 1);
        GtkWidget *page;
        GtkWidget *widget;
+       GtkWidget *label;
+       GtkWidget *scrolled_window;
        gchar     *text;
        GSList    *cur;
        gboolean   result;
-       
+       gint i = 0;
        wizard->mainwin = mainwin;
        wizard->create_mailbox = create_mailbox;
        
        gtk_widget_hide(mainwin->window);
        
-       wizard->window = gtk_dialog_new_with_buttons (_("New User"),
+       wizard_read_defaults();
+       
+       wizard->window = gtk_dialog_new_with_buttons (_("Claws Mail Setup Wizard"),
                        NULL, 0, 
                        GTK_STOCK_GO_BACK, GO_BACK,
                        GTK_STOCK_GO_FORWARD, GO_FORWARD,
                        GTK_STOCK_SAVE, FINISHED,
-                       GTK_STOCK_QUIT, CANCEL,
+                       GTK_STOCK_CANCEL, CANCEL,
                        NULL);
 
        g_signal_connect(wizard->window, "response", 
@@ -749,62 +1442,99 @@ gboolean run_wizard(MainWindow *mainwin, gboolean create_mailbox) {
        wizard->pages = NULL;
        
 /*welcome page: 0 */
-       page = create_page(wizard, _("Welcome to Sylpheed-Claws."));
+       WELCOME_PAGE = i;
+       page = create_page(wizard, _("Welcome to Claws Mail"));
        
        wizard->pages = g_slist_append(wizard->pages, page);
        widget = stock_pixmap_widget(wizard->window, 
-                               STOCK_PIXMAP_SYLPHEED_LOGO);
+                               STOCK_PIXMAP_CLAWS_MAIL_LOGO);
 
        gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
        
-       text = g_strdup(_("Welcome to Sylpheed-Claws.\n\n"
-                         "It looks like it's the first time you use \n"
-                         "Sylpheed-Claws. So, we'll now define some basic\n"
-                         "information about yourself and your most common\n"
-                         "mail parameters; so that you can begin to use\n"
-                         "Sylpheed-Claws in less than five minutes."));
+       text = g_strdup(_("Welcome to the Claws Mail setup wizard.\n\n"
+                         "We will begin by defining some basic "
+                         "information about you and your most common "
+                         "mail options so that you can start to use "
+                         "Claws Mail in less than five minutes."));
        widget = gtk_label_new(text);
+       gtk_label_set_line_wrap(GTK_LABEL(widget), TRUE);
        gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
        g_free(text);
 
 /* user page: 1 */
+       i++;
+       USER_PAGE = i;
        widget = create_page (wizard, _("About You"));
-       gtk_box_pack_start (GTK_BOX(widget), user_page(wizard), FALSE, FALSE, 0);
+       scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+       gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
+                                        GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+       gtk_box_pack_start(GTK_BOX(widget), scrolled_window, TRUE, TRUE, 0);
+
+       gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
+                                             user_page(wizard));
+       PACK_WARNING(_("Bold fields must be completed"));
+       
        wizard->pages = g_slist_append(wizard->pages, widget);
 
-/*smtp page: 2 */
-       widget = create_page (wizard, _("Sending mail"));
-       gtk_box_pack_start (GTK_BOX(widget), smtp_page(wizard), FALSE, FALSE, 0);
+/* recv+auth page: 2 */
+       i++;
+       RECV_PAGE = i;
+       widget = create_page (wizard, _("Receiving mail"));
+       scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+       gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
+                                        GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+       gtk_box_pack_start(GTK_BOX(widget), scrolled_window, TRUE, TRUE, 0);
+
+       gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
+                                             recv_page(wizard));
+       PACK_WARNING(_("Bold fields must be completed"));
+       
        wizard->pages = g_slist_append(wizard->pages, widget);
 
-/* recv+auth page: 3 */
-       widget = create_page (wizard, _("Receiving mail"));
-       gtk_box_pack_start (GTK_BOX(widget), recv_page(wizard), FALSE, FALSE, 0);
+/*smtp page: 3 */
+       i++;
+       SMTP_PAGE = i;
+       widget = create_page (wizard, _("Sending mail"));
+       scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+       gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
+                                        GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+       gtk_box_pack_start(GTK_BOX(widget), scrolled_window, TRUE, TRUE, 0);
+
+       gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
+                                             smtp_page(wizard));
+       PACK_WARNING(_("Bold fields must be completed"));
+       
        wizard->pages = g_slist_append(wizard->pages, widget);
 
 /* mailbox page: 4 */
        if (create_mailbox) {
+               i++;
+               MAILBOX_PAGE = i;
                widget = create_page (wizard, _("Saving mail on disk"));
-               gtk_box_pack_start (GTK_BOX(widget), mailbox_page(wizard), FALSE, FALSE, 0);
+               scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+               gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
+                                        GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+               gtk_box_pack_start(GTK_BOX(widget), scrolled_window, TRUE, TRUE, 0);
+
+               gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window),
+                                             mailbox_page(wizard));
+               PACK_WARNING(_("Bold fields must be completed"));
+       
                wizard->pages = g_slist_append(wizard->pages, widget);
        }
-/* ssl page: 5 */
-#ifdef USE_OPENSSL
-       widget = create_page (wizard, _("Security"));
-       gtk_box_pack_start (GTK_BOX(widget), ssl_page(wizard), FALSE, FALSE, 0);
-       wizard->pages = g_slist_append(wizard->pages, widget);
-#endif
 
 /* done page: 6 */
-       page = create_page(wizard, _("Configuration finished."));
+       i++;
+       DONE_PAGE = i;
+       page = create_page(wizard, _("Configuration finished"));
        
        wizard->pages = g_slist_append(wizard->pages, page);
        widget = stock_pixmap_widget(wizard->window, 
-                               STOCK_PIXMAP_SYLPHEED_LOGO);
+                               STOCK_PIXMAP_CLAWS_MAIL_LOGO);
 
        gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
        
-       text = g_strdup(_("Sylpheed-Claws is now ready to run.\n\n"
+       text = g_strdup(_("Claws Mail is now ready.\n"
                          "Click Save to start."));
        widget = gtk_label_new(text);
        gtk_box_pack_start (GTK_BOX(page), widget, FALSE, FALSE, 0);
@@ -822,6 +1552,9 @@ gboolean run_wizard(MainWindow *mainwin, gboolean create_mailbox) {
 
        gtk_widget_hide(wizard->recv_imap_label);
        gtk_widget_hide(wizard->recv_imap_subdir);
+       gtk_widget_hide(wizard->subsonly_checkbtn);
+
+       wizard_protocol_change(wizard, tmpl.recvtype);
 
        while (!wizard->finished)
                gtk_main_iteration();