Branch 'kolab/integration/4.13.0' - 3 commits - accountwizard/accountwizard.desktop accountwizard/accountwizard.knsrc accountwizard/accountwizard-mime.xml accountwizard/CMakeLists.txt accountwizard/configfile.cpp accountwizard/configfile.h accountwizard/dialog.cpp accountwizard/dialog.h accountwizard/dynamicpage.cpp accountwizard/dynamicpage.h accountwizard/global.cpp accountwizard/global.h accountwizard/HOWTO accountwizard/identity.cpp accountwizard/identity.h accountwizard/inprocess-main.cpp accountwizard/ispdb accountwizard/ldap.cpp accountwizard/ldap.h accountwizard/loadpage.cpp accountwizard/loadpage.h accountwizard/main.cpp accountwizard/Messages.sh accountwizard/page.cpp accountwizard/page.h accountwizard/personaldatapage.cpp accountwizard/personaldatapage.h accountwizard/providerpage.cpp accountwizard/providerpage.h accountwizard/resource.cpp accountwizard/resource.h accountwizard/servertest.cpp accountwizard/servertest.h accountwizard/setupautoconfigkolabfreebusy.cpp accountwizard/setupautoconfigkolabfreebusy.h accountwizard/setupautoconfigkolabldap.cpp accountwizard/setupautoconfigkolabldap.h accountwizard/setupautoconfigkolabmail.cpp accountwizard/setupautoconfigkolabmail.h accountwizard/setupispdb.cpp accountwizard/setupispdb.h accountwizard/setupmanager.cpp accountwizard/setupmanager.h accountwizard/setupobject.cpp accountwizard/setupobject.h accountwizard/setuppage.cpp accountwizard/setuppage.h accountwizard/TODO accountwizard/transport.cpp accountwizard/transport.h accountwizard/typepage.cpp accountwizard/typepage.h accountwizard/ui accountwizard/wizards CMakeLists.txt incidenceeditor-ng/combinedincidenceeditor.cpp incidenceeditor-ng/combinedincidenceeditor.h incidenceeditor-ng/dialogdesktop.ui incidenceeditor-ng/editoritemmanager.cpp incidenceeditor-ng/incidencecategories.cpp incidenceeditor-ng/incidencecategories.h incidenceeditor-ng/incidencedialog.cpp incidenceeditor-ng/incidenceeditor.cpp incidenceeditor-ng/incidenceeditor-ng.h libkdepim/CMakeLists.txt libkdepim/ldap libkdepim/widgets

Christian Mollekopf mollekopf at kolabsys.com
Sun Oct 26 12:48:50 CET 2014


 CMakeLists.txt                                        |    5 
 accountwizard/CMakeLists.txt                          |   79 +++
 accountwizard/HOWTO                                   |    2 
 accountwizard/Messages.sh                             |    3 
 accountwizard/TODO                                    |    5 
 accountwizard/accountwizard-mime.xml                  |    7 
 accountwizard/accountwizard.desktop                   |   97 ++++
 accountwizard/accountwizard.knsrc                     |    5 
 accountwizard/configfile.cpp                          |   91 ++++
 accountwizard/configfile.h                            |   53 ++
 accountwizard/dialog.cpp                              |  206 +++++++++
 accountwizard/dialog.h                                |   69 +++
 accountwizard/dynamicpage.cpp                         |   65 +++
 accountwizard/dynamicpage.h                           |   39 +
 accountwizard/global.cpp                              |  115 +++++
 accountwizard/global.h                                |   39 +
 accountwizard/identity.cpp                            |  152 +++++++
 accountwizard/identity.h                              |   68 +++
 accountwizard/inprocess-main.cpp                      |   46 ++
 accountwizard/ispdb/CMakeLists.txt                    |   19 
 accountwizard/ispdb/autoconfigkolabfreebusy.cpp       |  105 ++++
 accountwizard/ispdb/autoconfigkolabfreebusy.h         |   63 ++
 accountwizard/ispdb/autoconfigkolabldap.cpp           |  131 ++++++
 accountwizard/ispdb/autoconfigkolabldap.h             |   77 +++
 accountwizard/ispdb/autoconfigkolabmail.cpp           |   87 ++++
 accountwizard/ispdb/autoconfigkolabmail.h             |   37 +
 accountwizard/ispdb/ispdb.cpp                         |  386 ++++++++++++++++++
 accountwizard/ispdb/ispdb.h                           |  214 +++++++++
 accountwizard/ispdb/main.cpp                          |  128 +++++
 accountwizard/ispdb/tests/CMakeLists.txt              |   43 ++
 accountwizard/ispdb/tests/autoconfigkolabfreebusy.cpp |  174 ++++++++
 accountwizard/ispdb/tests/autoconfigkolabldaptest.cpp |  209 +++++++++
 accountwizard/ispdb/tests/autoconfigkolabmailtest.cpp |  159 +++++++
 accountwizard/ispdb/tests/data/autoconfig.xml         |   43 ++
 accountwizard/ispdb/tests/data/freebusy.xml           |   29 +
 accountwizard/ispdb/tests/data/ldap.xml               |   67 +++
 accountwizard/ispdb/tests/errorserver.py              |   18 
 accountwizard/ispdb/tests/ispdbtest.cpp               |  132 ++++++
 accountwizard/ldap.cpp                                |  195 +++++++++
 accountwizard/ldap.h                                  |   67 +++
 accountwizard/loadpage.cpp                            |   88 ++++
 accountwizard/loadpage.h                              |   51 ++
 accountwizard/main.cpp                                |   81 +++
 accountwizard/page.cpp                                |   60 ++
 accountwizard/page.h                                  |   64 ++
 accountwizard/personaldatapage.cpp                    |  278 ++++++++++++
 accountwizard/personaldatapage.h                      |   64 ++
 accountwizard/providerpage.cpp                        |  175 ++++++++
 accountwizard/providerpage.h                          |   75 +++
 accountwizard/resource.cpp                            |  165 +++++++
 accountwizard/resource.h                              |   51 ++
 accountwizard/servertest.cpp                          |   64 ++
 accountwizard/servertest.h                            |   54 ++
 accountwizard/setupautoconfigkolabfreebusy.cpp        |  109 +++++
 accountwizard/setupautoconfigkolabfreebusy.h          |   59 ++
 accountwizard/setupautoconfigkolabldap.cpp            |  113 +++++
 accountwizard/setupautoconfigkolabldap.h              |   59 ++
 accountwizard/setupautoconfigkolabmail.cpp            |   29 +
 accountwizard/setupautoconfigkolabmail.h              |   35 +
 accountwizard/setupispdb.cpp                          |  178 ++++++++
 accountwizard/setupispdb.h                            |   70 +++
 accountwizard/setupmanager.cpp                        |  265 ++++++++++++
 accountwizard/setupmanager.h                          |   87 ++++
 accountwizard/setupobject.cpp                         |   35 +
 accountwizard/setupobject.h                           |   46 ++
 accountwizard/setuppage.cpp                           |   71 +++
 accountwizard/setuppage.h                             |   52 ++
 accountwizard/transport.cpp                           |  156 +++++++
 accountwizard/transport.h                             |   62 ++
 accountwizard/typepage.cpp                            |  117 +++++
 accountwizard/typepage.h                              |   47 ++
 accountwizard/ui/loadpage.ui                          |   54 ++
 accountwizard/ui/personaldatapage.ui                  |  283 +++++++++++++
 accountwizard/ui/providerpage.ui                      |   63 ++
 accountwizard/ui/setuppage.ui                         |  103 ++++
 accountwizard/ui/typepage.ui                          |   84 +++
 accountwizard/wizards/CMakeLists.txt                  |    1 
 accountwizard/wizards/tine20/CMakeLists.txt           |    2 
 accountwizard/wizards/tine20/Messages.sh              |    4 
 accountwizard/wizards/tine20/tine20wizard.desktop     |   91 ++++
 accountwizard/wizards/tine20/tine20wizard.es          |  177 ++++++++
 accountwizard/wizards/tine20/tine20wizard.ui          |   87 ++++
 incidenceeditor-ng/combinedincidenceeditor.cpp        |   32 +
 incidenceeditor-ng/combinedincidenceeditor.h          |    3 
 incidenceeditor-ng/dialogdesktop.ui                   |    8 
 incidenceeditor-ng/editoritemmanager.cpp              |   31 -
 incidenceeditor-ng/incidencecategories.cpp            |   79 +--
 incidenceeditor-ng/incidencecategories.h              |   21 
 incidenceeditor-ng/incidencedialog.cpp                |    4 
 incidenceeditor-ng/incidenceeditor-ng.h               |    6 
 incidenceeditor-ng/incidenceeditor.cpp                |   10 
 libkdepim/CMakeLists.txt                              |    2 
 libkdepim/ldap/addhostdialog.cpp                      |    4 
 libkdepim/ldap/addhostdialog.h                        |   54 ++
 libkdepim/ldap/addhostdialog_p.h                      |   52 --
 libkdepim/ldap/kcmldap.cpp                            |    2 
 libkdepim/widgets/tagwidgets.cpp                      |    6 
 libkdepim/widgets/tagwidgets.h                        |    3 
 98 files changed, 7511 insertions(+), 144 deletions(-)

New commits:
commit d945086677ad21155c931765d14785a8c483844c
Author: Sandro Knauß <knauss at kolabsys.com>
Date:   Wed Oct 22 13:15:25 2014 +0200

    make ldap settings available for other apps

diff --git a/libkdepim/CMakeLists.txt b/libkdepim/CMakeLists.txt
index 448fdd5..f8b1725 100644
--- a/libkdepim/CMakeLists.txt
+++ b/libkdepim/CMakeLists.txt
@@ -47,6 +47,7 @@ set(kdepim_LIB_SRCS
    ldap/ldapsearchdialog.cpp
    ldap/ldapclientsearch.cpp
    ldap/ldapclientsearchconfig.cpp
+   ldap/addhostdialog.cpp
    misc/broadcaststatus.cpp
    misc/maillistdrag.cpp
    misc/uistatesaver.cpp
@@ -134,7 +135,6 @@ endif ()
 ########### next target ###############
 
 set( kcm_ldap_SRCS
-     ldap/addhostdialog.cpp
      ldap/kcmldap.cpp
 )
 
diff --git a/libkdepim/ldap/addhostdialog.cpp b/libkdepim/ldap/addhostdialog.cpp
index 6c21316..b7049d3 100644
--- a/libkdepim/ldap/addhostdialog.cpp
+++ b/libkdepim/ldap/addhostdialog.cpp
@@ -19,7 +19,7 @@
   Boston, MA 02110-1301, USA.
 */
 
-#include "addhostdialog_p.h"
+#include "addhostdialog.h"
 
 #include <QHBoxLayout>
 
@@ -147,4 +147,4 @@ void AddHostDialog::slotOk()
     KDialog::accept();
 }
 
-#include "moc_addhostdialog_p.cpp"
+#include "moc_addhostdialog.cpp"
diff --git a/libkdepim/ldap/addhostdialog.h b/libkdepim/ldap/addhostdialog.h
new file mode 100644
index 0000000..627a474
--- /dev/null
+++ b/libkdepim/ldap/addhostdialog.h
@@ -0,0 +1,54 @@
+/*
+  This file is part of libkldap.
+
+  Copyright (c) 2002-2010 Tobias Koenig <tokoe at kde.org>
+
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Library General  Public
+  License as published by the Free Software Foundation; either
+  version 2 of the License, or (at your option) any later version.
+
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  Library General Public License for more details.
+
+  You should have received a copy of the GNU Library General Public License
+  along with this library; see the file COPYING.LIB.  If not, write to
+  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+  Boston, MA 02110-1301, USA.
+*/
+
+#ifndef ADDHOSTDIALOG_H
+#define ADDHOSTDIALOG_H
+
+#include "libkdepim/kdepim_export.h"
+
+#include <kdialog.h>
+
+namespace KLDAP {
+class LdapConfigWidget;
+class LdapServer;
+}
+
+class KDEPIM_EXPORT AddHostDialog : public KDialog
+{
+    Q_OBJECT
+
+  public:
+    explicit AddHostDialog( KLDAP::LdapServer *server, QWidget *parent = 0 );
+    ~AddHostDialog();
+
+  Q_SIGNALS:
+    void changed( bool );
+
+  private Q_SLOTS:
+    void slotHostEditChanged( const QString& );
+    void slotOk();
+
+  private:
+    KLDAP::LdapConfigWidget *mCfg;
+    KLDAP::LdapServer *mServer;
+};
+
+#endif // ADDHOSTDIALOG_H
diff --git a/libkdepim/ldap/addhostdialog_p.h b/libkdepim/ldap/addhostdialog_p.h
deleted file mode 100644
index 53c2050..0000000
--- a/libkdepim/ldap/addhostdialog_p.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
-  This file is part of libkldap.
-
-  Copyright (c) 2002-2010 Tobias Koenig <tokoe at kde.org>
-
-  This library is free software; you can redistribute it and/or
-  modify it under the terms of the GNU Library General  Public
-  License as published by the Free Software Foundation; either
-  version 2 of the License, or (at your option) any later version.
-
-  This library is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  Library General Public License for more details.
-
-  You should have received a copy of the GNU Library General Public License
-  along with this library; see the file COPYING.LIB.  If not, write to
-  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-  Boston, MA 02110-1301, USA.
-*/
-
-#ifndef ADDHOSTDIALOG_H
-#define ADDHOSTDIALOG_H
-
-#include <kdialog.h>
-
-namespace KLDAP {
-class LdapConfigWidget;
-class LdapServer;
-}
-
-class AddHostDialog : public KDialog
-{
-    Q_OBJECT
-
-  public:
-    explicit AddHostDialog( KLDAP::LdapServer *server, QWidget *parent = 0 );
-    ~AddHostDialog();
-
-  Q_SIGNALS:
-    void changed( bool );
-
-  private Q_SLOTS:
-    void slotHostEditChanged( const QString& );
-    void slotOk();
-
-  private:
-    KLDAP::LdapConfigWidget *mCfg;
-    KLDAP::LdapServer *mServer;
-};
-
-#endif // ADDHOSTDIALOG_H
diff --git a/libkdepim/ldap/kcmldap.cpp b/libkdepim/ldap/kcmldap.cpp
index 24dd249..f222c34 100644
--- a/libkdepim/ldap/kcmldap.cpp
+++ b/libkdepim/ldap/kcmldap.cpp
@@ -48,7 +48,7 @@
 #include "ldapclientsearchconfig.h"
 #include <kldap/ldapserver.h>
 
-#include "addhostdialog_p.h"
+#include "addhostdialog.h"
 
 K_PLUGIN_FACTORY( KCMLdapFactory, registerPlugin<KCMLdap>(); )
 K_EXPORT_PLUGIN( KCMLdapFactory( "kcmldap" ) )


commit 5c20d86c1ab3499c200dded2e26e0da5d9f5aa17
Author: Sandro Knauß <knauss at kolabsys.com>
Date:   Wed Oct 22 13:13:18 2014 +0200

    move accountwizard from kdepim-runtim->kdepim

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 73feda9..68c7741 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -192,6 +192,10 @@ else()
   find_package(LibKGAPI2 2.1.0 QUIET CONFIG)
   set_package_properties(LibKGAPI2 PROPERTIES DESCRIPTION "KDE-based library for accessing various Google services" URL "https://projects.kde.org/libkgapi" TYPE OPTIONAL PURPOSE "LibKGAPI is required to build Google Drive Storage Service")
 
+  # shared-mime-info
+  find_package(SharedMimeInfo 0.30)
+  set_package_properties(SharedMimeInfo PROPERTIES DESCRIPTION "The shared-mime-info utility" URL "http://freedesktop.org/wiki/Software/shared-mime-info" TYPE REQUIRED PURPOSE "Information about filetypes")
+
   if( LibKGAPI2_FOUND )
     add_definitions( -DKDEPIM_STORAGESERVICE_GDRIVE )
   endif()
@@ -229,6 +233,7 @@ else()
 
   # These targets will always be built before anything else.
 
+  add_subdirectory(accountwizard)
   add_subdirectory(noteshared)
   add_subdirectory(akonadi_next)
   add_subdirectory(libkdepim)
diff --git a/accountwizard/CMakeLists.txt b/accountwizard/CMakeLists.txt
new file mode 100644
index 0000000..7bc69a2
--- /dev/null
+++ b/accountwizard/CMakeLists.txt
@@ -0,0 +1,79 @@
+add_definitions( -DQT_NO_CAST_FROM_ASCII )
+add_definitions( -DQT_NO_CAST_TO_ASCII )
+
+# allow to disable GHNS support on resource-constrained systems
+option( ACCOUNTWIZARD_NO_GHNS "Disable GHNS support in the account wizard" ${KDEPIM_MOBILE_UI} )
+if ( ACCOUNTWIZARD_NO_GHNS )
+  add_definitions( -DACCOUNTWIZARD_NO_GHNS )
+endif ()
+
+set(accountwizard_srcs
+  dialog.cpp
+  typepage.cpp
+  loadpage.cpp
+  global.cpp
+  page.cpp
+  dynamicpage.cpp
+  setupmanager.cpp
+  setuppage.cpp
+  resource.cpp
+  setupobject.cpp
+  transport.cpp
+  configfile.cpp
+  ldap.cpp
+  identity.cpp
+  setupispdb.cpp
+  setupautoconfigkolabmail.cpp
+  setupautoconfigkolabldap.cpp
+  setupautoconfigkolabfreebusy.cpp
+  servertest.cpp
+  personaldatapage.cpp
+  ispdb/ispdb.cpp
+  ispdb/autoconfigkolabmail.cpp
+  ispdb/autoconfigkolabldap.cpp
+  ispdb/autoconfigkolabfreebusy.cpp
+)
+
+kde4_add_ui_files(accountwizard_srcs
+  ui/typepage.ui
+  ui/loadpage.ui
+  ui/setuppage.ui
+  ui/personaldatapage.ui
+)
+
+set(accountwizard_libs
+  ${KDEPIMLIBS_AKONADI_LIBS}
+  ${KDEPIMLIBS_MAILTRANSPORT_LIBS}
+  ${KDEPIMLIBS_KPIMUTILS_LIBS}
+  ${KDE4_KROSSCORE_LIBS}
+  ${KDE4_KDECORE_LIBS}
+  ${KDE4_KIO_LIBS}
+  ${KDEPIMLIBS_KMIME_LIBS}
+  ${KDEPIMLIBS_KPIMIDENTITIES_LIBS}
+  ${QT_QTGUI_LIBRARY}
+  ${QT_QTUITOOLS_LIBRARY}
+)
+
+if ( NOT ACCOUNTWIZARD_NO_GHNS )
+  set(accountwizard_srcs ${accountwizard_srcs} providerpage.cpp)
+  kde4_add_ui_files(accountwizard_srcs ui/providerpage.ui)
+  set(accountwizard_libs ${accountwizard_libs} ${KDE4_KNEWSTUFF3_LIBS})
+endif ()
+
+kde4_add_executable(accountwizard ${accountwizard_srcs} main.cpp)
+target_link_libraries(accountwizard ${accountwizard_libs})
+
+kde4_add_plugin(accountwizard_plugin ${accountwizard_srcs} inprocess-main.cpp)
+target_link_libraries(accountwizard_plugin ${accountwizard_libs})
+
+if ( NOT ACCOUNTWIZARD_NO_GHNS )
+  install(FILES accountwizard.knsrc DESTINATION ${CONFIG_INSTALL_DIR})
+endif ()
+install(TARGETS accountwizard ${INSTALL_TARGETS_DEFAULT_ARGS})
+install(TARGETS accountwizard_plugin DESTINATION ${PLUGIN_INSTALL_DIR})
+install(PROGRAMS accountwizard.desktop DESTINATION ${XDG_APPS_INSTALL_DIR})
+install(FILES accountwizard-mime.xml DESTINATION ${XDG_MIME_INSTALL_DIR})
+update_xdg_mimetypes(${XDG_MIME_INSTALL_DIR})
+
+add_subdirectory(wizards)
+add_subdirectory(ispdb)
\ No newline at end of file
diff --git a/accountwizard/HOWTO b/accountwizard/HOWTO
new file mode 100644
index 0000000..4356b3a
--- /dev/null
+++ b/accountwizard/HOWTO
@@ -0,0 +1,2 @@
+You can create packages too... Want to read about it?
+http://techbase.kde.org/Development/Tutorials/Akonadi/CreatingAccountWizardPackages
diff --git a/accountwizard/Messages.sh b/accountwizard/Messages.sh
new file mode 100644
index 0000000..7720e83
--- /dev/null
+++ b/accountwizard/Messages.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+$EXTRACTRC ui/*.ui >> rc.cpp
+$XGETTEXT *.cpp ispdb/*.cpp  -o $podir/accountwizard.pot
diff --git a/accountwizard/TODO b/accountwizard/TODO
new file mode 100644
index 0000000..e2d3ad7
--- /dev/null
+++ b/accountwizard/TODO
@@ -0,0 +1,5 @@
+- figure out i18n for the actual wizards (DONE)
+- imap+pop3wizard has no encryption as default i.c.w. plain auth method. Not a good default!
+- remember which set up resources/transports/ldap accounts/identities belong together so we can offer to remove them in one go again
+- add more wizards (In progress)
+- sort out password fields at least for pop3.
diff --git a/accountwizard/accountwizard-mime.xml b/accountwizard/accountwizard-mime.xml
new file mode 100644
index 0000000..5114828
--- /dev/null
+++ b/accountwizard/accountwizard-mime.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
+    <mime-type type="application/x-accountwizard-package">
+        <comment>KDE Accountwizard Package</comment>
+        <glob pattern="*.awp"></glob>
+    </mime-type>
+</mime-info>
diff --git a/accountwizard/accountwizard.desktop b/accountwizard/accountwizard.desktop
new file mode 100644
index 0000000..93714ac
--- /dev/null
+++ b/accountwizard/accountwizard.desktop
@@ -0,0 +1,97 @@
+[Desktop Entry]
+Name=Account Wizard
+Name[bg]=Помощник за сметки
+Name[bs]=ÄŒarobnjak naloga
+Name[ca]=Assistent de comptes
+Name[ca at valencia]=Assistent de comptes
+Name[cs]=Průvodce nastavením účtu
+Name[da]=Kontoguide
+Name[de]=Zugangsassistent 
+Name[el]=Οδηγός Λογαριασμού
+Name[en_GB]=Account Wizard
+Name[es]=Asistente de cuentas
+Name[et]=Kontonõustaja
+Name[fi]=Opastettu tilien asetus
+Name[fr]=Assistant de comptes
+Name[ga]=Treoraí Cuntais
+Name[gl]=Asistente de contas
+Name[hu]=Azonosítóbeállító varázsló
+Name[ia]=Assistente de conto
+Name[it]=Procedura guidata per la creazione di account
+Name[ja]=アカウントウィザード
+Name[kk]=Тіркелгі шебері
+Name[km]=អ្នក​ជំនួយការ​គណនី
+Name[ko]=계정 마법사
+Name[lt]=Paskyros vediklis
+Name[lv]=Konta vednis
+Name[mai]=खाता विजार्ड
+Name[nb]=Konto-veiviser
+Name[nds]=Konto-Hölper
+Name[nl]=Accountassistent
+Name[pa]=ਅਕਾਊਂਟ ਸਹਾਇਕ
+Name[pl]=Pomocnik konta 
+Name[pt]=Assistente de Contas
+Name[pt_BR]=Assistente de contas
+Name[ro]=Expert conturi
+Name[ru]=Мастер учётных записей
+Name[sk]=Sprievodca účtom
+Name[sl]=Čarovnik za račune
+Name[sr]=Чаробњак за налоге
+Name[sr at ijekavian]=Чаробњак за налоге
+Name[sr at ijekavianlatin]=ÄŒarobnjak za naloge
+Name[sr at latin]=ÄŒarobnjak za naloge
+Name[sv]=Kontoguide
+Name[tr]=Hesap Sihirbazı
+Name[ug]=زىيارەت يېتەكچىسى
+Name[uk]=Майстер облікових записів
+Name[x-test]=xxAccount Wizardxx
+Name[zh_CN]=账户向导
+Name[zh_TW]=帳號精靈
+Exec=accountwizard --package %u
+Type=Application
+NoDisplay=true
+Comment=Launch the account wizard to configure PIM accounts.
+Comment[bs]=Pokreni čarobnjaka za naloge za konfigurisanje PIM naloga.
+Comment[ca]=Llança l'assistent de comptes per a configurar comptes de PIM.
+Comment[ca at valencia]=Llança l'assistent de comptes per a configurar comptes de PIM.
+Comment[cs]=Spustit průvodce nastavením PIM účtů.
+Comment[da]=Start kontoguiden for at konfigurere PIM-konti.
+Comment[de]=Den Zugangsassistenten zum Einrichten von PIM-Zugängen starten.
+Comment[el]=Εκτέλεση του οδηγού λογαριασμού για τη διαμόρφωση λογαριασμών PIM.
+Comment[en_GB]=Launch the account wizard to configure PIM accounts.
+Comment[es]=Lanzar el asistente de cuentas para configurar las cuentas PIM.
+Comment[et]=Kontonõustaja käivitamine PIM-kontode seadistamiseks.
+Comment[fi]=Käynnistä PIM-tilien opastettu asetus.
+Comment[fr]=Lance l'assistant de compte pour configurer les comptes PIM.
+Comment[gl]=Iniciar o asistente de contas para configurar as contas de información persoal
+Comment[hu]=A PIM azonosítókat beállító varázsló elindítása.
+Comment[ia]=Aperi le assistente de conto pro configurar contos del Administration de Informationes Personal
+Comment[it]=Esegue la procedura guidata per la creazione di account per configurare gli account di PIM.
+Comment[kk]=PIM тіркелгілерін баптау үшін шеберін жегеді.
+Comment[km]=ចាប់ផ្ដើម​អ្នក​ជំនួយការ​គណនី​ ដើម្បី​កំណត់​រចនាសម្ព័ន្ធ​គណនី PIM ។
+Comment[ko]=계정 마법사를 실행하여 PIM 계정을 설정합니다.
+Comment[lt]=PIM paskyros nustatymui, paleisti paskyros vediklį.
+Comment[lv]=Palaiž konta vedni, lai konfigurētu PIM kontus.
+Comment[nb]=Start kontoveiviseren for å sette opp PIM-kontoer.
+Comment[nds]=Konto-Hölper för't Inrichten vun PIM-Kontos starten
+Comment[nl]=Start de accountassistent om PIM-accounts in te stellen.
+Comment[pl]=Uruchom pomocnika konta, aby skonfigurować konta ZIO.
+Comment[pt]=Lançar o assistente de contas para configurar as contas PIM.
+Comment[pt_BR]=Executa o assistente para configuração das contas PIM.
+Comment[ro]=Lansează expertul de conturi pentru a configura conturi noi.
+Comment[ru]=Мастер для настройки учётных записей персонального информационного менеджера.
+Comment[sk]=Spustí sprievodcu účtami na nasatavenie PIM účtov.
+Comment[sl]=Zaženite čarovnika za nastavljanje računov za osebne podatke.
+Comment[sr]=Покрените чаробњак да подесите ПИМ налоге.
+Comment[sr at ijekavian]=Покрените чаробњак да подесите ПИМ налоге.
+Comment[sr at ijekavianlatin]=Pokrenite čarobnjak da podesite PIM naloge.
+Comment[sr at latin]=Pokrenite čarobnjak da podesite PIM naloge.
+Comment[sv]=Starta kontoguiden för att anpassa konton för personlig informationshantering.
+Comment[tr]=PIM hesaplarını düzenlemek için hesap sihirbazını başlat.
+Comment[ug]=PIM ھېساباتلىرىنى سەپلەشتە ئىشلىتىدىغان ھېسابات يېتەكچىسىنى ئىجرا قىلىش
+Comment[uk]=Запустити майстер облікових записів для налаштування.
+Comment[x-test]=xxLaunch the account wizard to configure PIM accounts.xx
+Comment[zh_CN]=调用账户向导配置个人信息账户。
+Comment[zh_TW]=啟動帳號精靈來設定 PIM 帳號
+MimeType=application/x-accountwizard-package;
+Terminal=false
diff --git a/accountwizard/accountwizard.knsrc b/accountwizard/accountwizard.knsrc
new file mode 100644
index 0000000..42f00a6
--- /dev/null
+++ b/accountwizard/accountwizard.knsrc
@@ -0,0 +1,5 @@
+[KNewStuff3]
+ProvidersUrl=http://download.kde.org/ocs/providers.xml
+Categories=Akonadi Email Providers
+TargetDir=akonadi/accountwizard
+Uncompress=archive
diff --git a/accountwizard/configfile.cpp b/accountwizard/configfile.cpp
new file mode 100644
index 0000000..627333f
--- /dev/null
+++ b/accountwizard/configfile.cpp
@@ -0,0 +1,91 @@
+/*
+    Copyright (c) 2010 Laurent Montel <montel at kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#include "configfile.h"
+
+#include <KConfig>
+#include <KConfigGroup>
+#include <KLocalizedString>
+#include <KStringHandler>
+
+ConfigFile::ConfigFile( const QString & configName, QObject *parent )
+  : SetupObject( parent )
+{
+  m_name = configName;
+  m_config = new KConfig( configName );
+}
+
+ConfigFile::~ConfigFile()
+{
+  delete m_config;
+}
+
+void ConfigFile::write()
+{
+    create();
+}
+
+void ConfigFile::create()
+{
+  emit info( i18n( "Writing config file for %1...",m_name ) );
+
+  foreach ( const Config &c, m_configData ) {
+    KConfigGroup grp = m_config->group( c.group );
+    if ( c.obscure )
+      grp.writeEntry( c.key, KStringHandler::obscure( c.value ) );
+    else
+      grp.writeEntry( c.key, c.value );
+  }
+
+  m_config->sync();
+  emit finished( i18n( "Config file for %1 is writing.", m_name ) );
+}
+
+void ConfigFile::destroy()
+{
+  emit info( i18n( "Config file for %1 was not changed.", m_name ) );
+}
+
+void ConfigFile::setName( const QString &name )
+{
+  m_name = name;
+}
+
+
+void ConfigFile::setConfig( const QString &group, const QString &key, const QString &value )
+{
+  Config conf;
+  conf.group = group;
+  conf.key = key;
+  conf.value = value;
+  conf.obscure = false;
+  m_configData.append( conf );
+}
+
+void ConfigFile::setPassword(const QString& group, const QString& key, const QString& value)
+{
+  Config conf;
+  conf.group = group;
+  conf.key = key;
+  conf.value = value;
+  conf.obscure = true;
+  m_configData.append( conf );
+}
+
+
diff --git a/accountwizard/configfile.h b/accountwizard/configfile.h
new file mode 100644
index 0000000..6e11ce9
--- /dev/null
+++ b/accountwizard/configfile.h
@@ -0,0 +1,53 @@
+/*
+    Copyright (c) 2010 Laurent Montel <montel at kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef CONFIGFILE_H
+#define CONFIGFILE_H
+
+#include "setupobject.h"
+
+class KConfig;
+
+struct Config {
+  QString group;
+  QString key;
+  QString value;
+  bool obscure;
+};
+
+class ConfigFile : public SetupObject
+{
+  Q_OBJECT
+  public:
+    explicit ConfigFile( const QString& configName, QObject *parent = 0 );
+    ~ConfigFile();
+    void create();
+    void destroy();
+  public slots:
+    Q_SCRIPTABLE void write();
+    Q_SCRIPTABLE void setName( const QString & name );
+    Q_SCRIPTABLE void setConfig( const QString &group, const QString &key, const QString &value );
+    Q_SCRIPTABLE void setPassword( const QString &group, const QString &key, const QString &value );
+  private:
+    QList<Config> m_configData;
+    QString m_name;
+    KConfig *m_config;
+};
+
+#endif
diff --git a/accountwizard/dialog.cpp b/accountwizard/dialog.cpp
new file mode 100644
index 0000000..32c374d
--- /dev/null
+++ b/accountwizard/dialog.cpp
@@ -0,0 +1,206 @@
+/*
+    Copyright (c) 2009 Volker Krause <vkrause at kde.org>
+    Copyright (c) 2010 Tom Albers <toma at kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#include "dialog.h"
+#include "personaldatapage.h"
+#ifndef ACCOUNTWIZARD_NO_GHNS
+#include "providerpage.h"
+#endif
+#include "typepage.h"
+#include "loadpage.h"
+#include "global.h"
+#include "dynamicpage.h"
+#include "setupmanager.h"
+#include "servertest.h"
+#include "setuppage.h"
+
+#include <KMime/Message>
+
+#include <klocalizedstring.h>
+#include <kross/core/action.h>
+#include <kdebug.h>
+#include <kmessagebox.h>
+
+#include <qplatformdefs.h>
+
+Dialog::Dialog(QWidget* parent, Qt::WindowFlags flags ) :
+  KAssistantDialog( parent, flags )
+{
+#if defined (Q_WS_MAEMO_5) || defined (MEEGO_EDITION_HARMATTAN)
+  setWindowState( Qt::WindowFullScreen );
+#endif
+
+  showButton( Help, false ); // we don't have help for the account wizard atm
+
+  mSetupManager = new SetupManager( this );
+  const bool showPersonalDataPage = Global::typeFilter().size() == 1 && Global::typeFilter().first() == KMime::Message::mimeType();
+
+  if ( showPersonalDataPage ) {
+    // todo: dont ask these details based on a setting of the desktop file.
+    PersonalDataPage *pdpage = new PersonalDataPage( this );
+    addPage( pdpage, i18n( "Provide personal data" ) );
+    connect( pdpage, SIGNAL(manualWanted(bool)), SLOT(slotManualConfigWanted(bool)) );
+    if ( !Global::assistant().isEmpty() ) {
+      pdpage->setHideOptionInternetSearch( true );
+    }
+  }
+
+  if ( Global::assistant().isEmpty() ) {
+    TypePage* typePage = new TypePage( this );
+    connect( typePage->treeview(), SIGNAL(doubleClicked(QModelIndex)), SLOT(slotNextPage()) );
+#ifndef ACCOUNTWIZARD_NO_GHNS
+    connect( typePage, SIGNAL(ghnsWanted()), SLOT(slotGhnsWanted()) );
+#endif
+    mTypePage = addPage( typePage, i18n( "Select Account Type" ) );
+    setAppropriate( mTypePage, false );
+
+#ifndef ACCOUNTWIZARD_NO_GHNS
+    ProviderPage *ppage = new ProviderPage( this );
+    connect( typePage, SIGNAL(ghnsWanted()), ppage, SLOT(startFetchingData()) );
+    connect( ppage->treeview(), SIGNAL(doubleClicked(QModelIndex)), SLOT(slotNextPage()) );
+    connect( ppage, SIGNAL(ghnsNotWanted()), SLOT(slotGhnsNotWanted()) );
+    mProviderPage = addPage( ppage, i18n( "Select Provider" ) );
+    setAppropriate( mProviderPage, false );
+#endif
+  }
+
+  LoadPage *loadPage = new LoadPage( this );
+  mLoadPage = addPage( loadPage, i18n( "Loading Assistant" ) );
+  setAppropriate( mLoadPage, false );
+  loadPage->exportObject( this, QLatin1String( "Dialog" ) );
+  loadPage->exportObject( mSetupManager, QLatin1String( "SetupManager" ) );
+  loadPage->exportObject( new ServerTest( this ), QLatin1String( "ServerTest" ) );
+  connect( loadPage, SIGNAL(aboutToStart()), SLOT(clearDynamicPages()) );
+
+  SetupPage *setupPage = new SetupPage( this );
+  mLastPage = addPage( setupPage, i18n( "Setting up Account" )  );
+  mSetupManager->setSetupPage( setupPage );
+
+  slotManualConfigWanted( !showPersonalDataPage );
+
+  Page *page = qobject_cast<Page*>( currentPage()->widget() );
+  page->enterPageNext();
+  emit page->pageEnteredNext();
+  enableButton( KDialog::Help, false );
+}
+
+KPageWidgetItem* Dialog::addPage(Page* page, const QString &title)
+{
+  KPageWidgetItem *item = KAssistantDialog::addPage( page, title );
+  connect( page, SIGNAL(leavePageNextOk()), SLOT(slotNextOk()) );
+  connect( page, SIGNAL(leavePageBackOk()), SLOT(slotBackOk()) );
+  page->setPageWidgetItem( item );
+  return item;
+}
+
+
+void Dialog::slotNextPage()
+{
+  next();
+}
+
+void Dialog::next()
+{
+  Page *page = qobject_cast<Page*>( currentPage()->widget() );
+  page->leavePageNext();
+  page->leavePageNextRequested();
+}
+
+void Dialog::slotNextOk()
+{
+  Page *page = qobject_cast<Page*>( currentPage()->widget() );
+  emit page->pageLeftNext();
+  KAssistantDialog::next();
+  page = qobject_cast<Page*>( currentPage()->widget() );
+  page->enterPageNext();
+  emit page->pageEnteredNext();
+}
+
+
+void Dialog::back()
+{
+  Page *page = qobject_cast<Page*>( currentPage()->widget() );
+  page->leavePageBack();
+  page->leavePageBackRequested();
+}
+
+void Dialog::slotBackOk()
+{
+  Page *page = qobject_cast<Page*>( currentPage()->widget() );
+  emit page->pageLeftBack();
+  KAssistantDialog::back();
+  page = qobject_cast<Page*>( currentPage()->widget() );
+  page->enterPageBack();
+  emit page->pageEnteredBack();
+}
+
+QObject* Dialog::addPage(const QString& uiFile, const QString &title )
+{
+  kDebug() << uiFile;
+  DynamicPage *page = new DynamicPage( Global::assistantBasePath() + uiFile, this );
+  connect( page, SIGNAL(leavePageNextOk()), SLOT(slotNextOk()) );
+  connect( page, SIGNAL(leavePageBackOk()), SLOT(slotBackOk()) );
+  KPageWidgetItem* item = insertPage( mLastPage, page, title );
+  page->setPageWidgetItem( item );
+  mDynamicPages.push_back( item );
+  return page;
+}
+
+void Dialog::slotManualConfigWanted( bool show )
+{
+  Q_ASSERT( mTypePage );
+  setAppropriate( mTypePage, show );
+  setAppropriate( mLoadPage, show );
+}
+
+#ifndef ACCOUNTWIZARD_NO_GHNS
+void Dialog::slotGhnsWanted()
+{
+  Q_ASSERT( mProviderPage );
+  setAppropriate( mProviderPage, true );
+  setCurrentPage( mProviderPage );
+}
+
+void Dialog::slotGhnsNotWanted()
+{
+  Q_ASSERT( mProviderPage );
+  setAppropriate( mProviderPage, false );
+}
+#endif
+
+SetupManager* Dialog::setupManager()
+{
+  return mSetupManager;
+}
+
+void Dialog::clearDynamicPages()
+{
+  foreach ( KPageWidgetItem *item, mDynamicPages )
+    removePage( item );
+  mDynamicPages.clear();
+}
+
+void Dialog::reject()
+{
+  connect( mSetupManager, SIGNAL(rollbackComplete()), SLOT(close()) );
+  mSetupManager->requestRollback();
+}
+
+
diff --git a/accountwizard/dialog.h b/accountwizard/dialog.h
new file mode 100644
index 0000000..44b0182
--- /dev/null
+++ b/accountwizard/dialog.h
@@ -0,0 +1,69 @@
+/*
+    Copyright (c) 2009 Volker Krause <vkrause at kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef DIALOG_H
+#define DIALOG_H
+
+#include "setupmanager.h"
+#include <kassistantdialog.h>
+
+class Page;
+class TypePage;
+
+class Dialog : public KAssistantDialog
+{
+  Q_OBJECT
+  public:
+    explicit Dialog( QWidget *parent = 0, Qt::WindowFlags flags = 0 );
+
+    /* reimpl */ void next();
+    /* reimpl */ void back();
+
+    // give room for certain pages to create objects too.
+    SetupManager* setupManager();
+
+  public slots:
+    Q_SCRIPTABLE QObject* addPage( const QString &uiFile, const QString &title );
+
+    void reject();
+
+  private slots:
+    void slotNextPage();
+#ifndef ACCOUNTWIZARD_NO_GHNS
+    void slotGhnsWanted();
+    void slotGhnsNotWanted();
+#endif
+    void slotManualConfigWanted( bool );
+    void slotNextOk();
+    void slotBackOk();
+    void clearDynamicPages();
+
+  private:
+    KPageWidgetItem* addPage( Page* page, const QString &title );
+
+  private:
+    SetupManager* mSetupManager;
+    KPageWidgetItem* mLastPage;
+    KPageWidgetItem* mProviderPage;
+    KPageWidgetItem* mTypePage;
+    KPageWidgetItem* mLoadPage;
+    QVector<KPageWidgetItem*> mDynamicPages;
+};
+
+#endif
diff --git a/accountwizard/dynamicpage.cpp b/accountwizard/dynamicpage.cpp
new file mode 100644
index 0000000..fe38598
--- /dev/null
+++ b/accountwizard/dynamicpage.cpp
@@ -0,0 +1,65 @@
+/*
+    Copyright (c) 2009 Volker Krause <vkrause at kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#include "dynamicpage.h"
+
+#include <KDebug>
+
+#include <QUiLoader>
+#include <QFile>
+#include <qboxlayout.h>
+#include <qscrollarea.h>
+
+DynamicPage::DynamicPage(const QString& uiFile, KAssistantDialog* parent) : Page( parent )
+{
+  QVBoxLayout *layout = new QVBoxLayout;
+  layout->setMargin( 0 );
+  setLayout( layout );
+
+#ifdef KDEPIM_MOBILE_UI
+  // for mobile ui we put the page into a scroll area in case it's too big
+  QScrollArea *pageParent = new QScrollArea( this );
+  pageParent->setFrameShape( QFrame::NoFrame );
+  pageParent->setWidgetResizable( true );
+  layout->addWidget( pageParent );
+#else
+  QWidget *pageParent = this;
+#endif
+
+  QUiLoader loader;
+  QFile file( uiFile );
+  file.open( QFile::ReadOnly );
+  kDebug() << uiFile;
+  m_dynamicWidget = loader.load( &file, pageParent );
+  file.close();
+
+#ifdef KDEPIM_MOBILE_UI
+  pageParent->setWidget( m_dynamicWidget );
+#else
+  layout->addWidget( m_dynamicWidget );
+#endif
+
+  setValid( true );
+}
+
+QObject* DynamicPage::widget() const
+{
+  return m_dynamicWidget;
+}
+
diff --git a/accountwizard/dynamicpage.h b/accountwizard/dynamicpage.h
new file mode 100644
index 0000000..ae74fb0
--- /dev/null
+++ b/accountwizard/dynamicpage.h
@@ -0,0 +1,39 @@
+/*
+    Copyright (c) 2009 Volker Krause <vkrause at kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef DYNAMICPAGE_H
+#define DYNAMICPAGE_H
+
+#include "page.h"
+
+class DynamicPage : public Page
+{
+  Q_OBJECT
+  public:
+    explicit DynamicPage( const QString &uiFile, KAssistantDialog* parent = 0 );
+
+  public slots:
+    /// returns the top-level widget of the UI file
+    Q_SCRIPTABLE QObject* widget() const;
+
+  private:
+    QWidget* m_dynamicWidget;
+};
+
+#endif
diff --git a/accountwizard/global.cpp b/accountwizard/global.cpp
new file mode 100644
index 0000000..372b374
--- /dev/null
+++ b/accountwizard/global.cpp
@@ -0,0 +1,115 @@
+/*
+    Copyright (c) 2009 Volker Krause <vkrause at kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#include "global.h"
+
+#include <kdebug.h>
+#include <KGlobal>
+#include <KStandardDirs>
+#include <QtCore/qfileinfo.h>
+#include <QtCore/QDir>
+#include <kio/copyjob.h>
+#include <kio/netaccess.h>
+
+class GlobalPrivate
+{
+  public:
+    QStringList filter;
+    QString assistant;
+};
+
+K_GLOBAL_STATIC( GlobalPrivate, sInstance )
+
+
+QString Global::assistant()
+{
+  return sInstance->assistant;
+}
+
+void Global::setAssistant(const QString& assistant)
+{
+  const QFileInfo info( assistant );
+  if ( info.isAbsolute() ) {
+    sInstance->assistant = assistant;
+    return;
+  }
+
+  const QStringList list = KGlobal::dirs()->findAllResources(
+    "data", QLatin1String( "akonadi/accountwizard/*.desktop" ),
+    KStandardDirs::Recursive | KStandardDirs::NoDuplicates );
+  foreach ( const QString &entry, list ) {
+    const QFileInfo info( entry );
+    const QDir dir( info.absolutePath() );
+    kDebug() << dir.dirName();
+    if ( dir.dirName() == assistant ) {
+      sInstance->assistant = entry;
+      return;
+    }
+  }
+
+  sInstance->assistant.clear();
+}
+
+
+QStringList Global::typeFilter()
+{
+  return sInstance->filter;
+}
+
+void Global::setTypeFilter(const QStringList& filter)
+{
+  sInstance->filter = filter;
+}
+
+QString Global::assistantBasePath()
+{
+  const QFileInfo info( assistant() );
+  if ( info.isAbsolute() )
+    return info.absolutePath() + QDir::separator();
+  return QString();
+}
+
+QString Global::unpackAssistant( const KUrl& remotePackageUrl )
+{
+  QString localPackageFile;
+  if ( remotePackageUrl.protocol() == QLatin1String( "file" ) ) {
+    localPackageFile = remotePackageUrl.path();
+  } else {
+    QString remoteFileName = QFileInfo( remotePackageUrl.path() ).fileName();
+    localPackageFile = KStandardDirs::locateLocal( "cache", QLatin1String("accountwizard/") + remoteFileName );
+    KIO::Job* job = KIO::copy( remotePackageUrl, localPackageFile, KIO::Overwrite | KIO::HideProgressInfo );
+    kDebug() << "downloading remote URL" << remotePackageUrl << "to" << localPackageFile;
+    if ( !KIO::NetAccess::synchronousRun( job, 0 ) )
+      return QString();
+  }
+
+  const KUrl file( QLatin1String("tar://") + localPackageFile );
+  const QFileInfo fi( localPackageFile );
+  const QString assistant = fi.baseName();
+  const QString dest = KStandardDirs::locateLocal( "appdata", QLatin1String("/") );
+  KStandardDirs::makeDir( dest + file.fileName() );
+  KIO::Job* getJob = KIO::copy( file, dest, KIO::Overwrite | KIO::HideProgressInfo );
+  if ( KIO::NetAccess::synchronousRun( getJob, 0 ) ) {
+    kDebug() << "worked, unpacked in " << dest;
+    return dest + file.fileName() + QLatin1Char('/') + assistant + QLatin1Char('/') + assistant + QLatin1String(".desktop");
+  } else {
+    kDebug() << "failed" << getJob->errorString();
+    return QString();
+  }
+}
diff --git a/accountwizard/global.h b/accountwizard/global.h
new file mode 100644
index 0000000..666e5f4
--- /dev/null
+++ b/accountwizard/global.h
@@ -0,0 +1,39 @@
+/*
+    Copyright (c) 2009 Volker Krause <vkrause at kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef GLOBAL_H
+#define GLOBAL_H
+
+#include <KUrl>
+#include <QStringList>
+
+namespace Global
+{
+  QStringList typeFilter();
+  void setTypeFilter( const QStringList &filter );
+
+  QString assistant();
+  void setAssistant( const QString &assistant );
+
+  QString assistantBasePath();
+
+  QString unpackAssistant( const KUrl& remotePackageUrl );
+}
+
+#endif
diff --git a/accountwizard/identity.cpp b/accountwizard/identity.cpp
new file mode 100644
index 0000000..417e673
--- /dev/null
+++ b/accountwizard/identity.cpp
@@ -0,0 +1,152 @@
+/*
+    Copyright (c) 2010 Laurent Montel <montel at kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#include "identity.h"
+#include "transport.h"
+
+#include <kpimidentities/identitymanager.h>
+#include <kpimidentities/identity.h>
+
+#include <KLocalizedString>
+
+Identity::Identity( QObject *parent )
+  : SetupObject( parent ),
+  m_transport( 0 )
+{
+  m_manager = new KPIMIdentities::IdentityManager( false, this, "mIdentityManager" );
+  m_identity = &m_manager->newFromScratch( QString() );
+  Q_ASSERT( m_identity != 0 );
+}
+
+Identity::~Identity()
+{
+  delete m_manager;
+}
+
+void Identity::create()
+{
+  emit info( i18n( "Setting up identity..." ) );
+
+  // store identity information
+  // TODO now that we have the identity object around anyway we can probably get rid of most of the other members
+  m_identity->setIdentityName( identityName() );
+  m_identity->setFullName( m_realName );
+  m_identity->setPrimaryEmailAddress( m_email );
+  m_identity->setOrganization( m_organization );
+  if ( m_transport && m_transport->transportId() > 0 )
+    m_identity->setTransport( QString::number( m_transport->transportId() ) );
+  if ( !m_signature.isEmpty() ) {
+    const KPIMIdentities::Signature sig( m_signature );
+    m_identity->setSignature( sig );
+  }
+  if ( !m_prefCryptoFormat.isEmpty() )
+    m_identity->setPreferredCryptoMessageFormat( m_prefCryptoFormat );
+  if ( !m_xface.isEmpty() ) {
+    m_identity->setXFaceEnabled( true );
+    m_identity->setXFace( m_xface );
+  }
+  m_manager->setAsDefault( m_identity->uoid() );
+  m_manager->commit();
+
+  emit finished( i18n( "Identity set up." ) );
+}
+
+QString Identity::identityName() const
+{
+  // create identity name
+  QString name( m_identityName );
+  if ( name.isEmpty() ) {
+    name = i18nc( "Default name for new email accounts/identities.", "Unnamed" );
+
+    QString idName = m_email;
+    int pos = idName.indexOf( QLatin1Char('@') );
+    if ( pos != -1 ) {
+      name = idName.mid( 0, pos );
+    }
+
+    // Make the name a bit more human friendly
+    name.replace( QLatin1Char('.'), QLatin1Char(' ') );
+    pos = name.indexOf( QLatin1Char(' ') );
+    if ( pos != 0 ) {
+      name[ pos + 1 ] = name[ pos + 1 ].toUpper();
+    }
+    name[ 0 ] = name[ 0 ].toUpper();
+  }
+
+  if ( !m_manager->isUnique( name ) ) {
+    name = m_manager->makeUnique( name );
+  }
+  return name;
+}
+
+
+void Identity::destroy()
+{
+  m_manager->removeIdentityForced( m_identity->identityName() );
+  m_manager->commit();
+  m_identity = 0;
+  emit info( i18n( "Identity removed." ) );
+}
+
+void Identity::setIdentityName(const QString& name)
+{
+  m_identityName = name;
+}
+
+void Identity::setRealName( const QString &name )
+{
+  m_realName = name;
+}
+
+void Identity::setOrganization( const QString &org )
+{
+  m_organization = org;
+}
+
+void Identity::setEmail( const QString &email )
+{
+  m_email = email;
+}
+
+uint Identity::uoid() const
+{
+  return m_identity->uoid();
+}
+
+void Identity::setTransport(QObject* transport)
+{
+  m_transport = qobject_cast<Transport*>( transport );
+  setDependsOn( qobject_cast<SetupObject*>( transport ) );
+}
+
+void Identity::setSignature(const QString& sig)
+{
+  m_signature = sig;
+}
+
+void Identity::setPreferredCryptoMessageFormat(const QString& format)
+{
+  m_prefCryptoFormat = format;
+}
+
+void Identity::setXFace(const QString& xface)
+{
+  m_xface = xface;
+}
+
diff --git a/accountwizard/identity.h b/accountwizard/identity.h
new file mode 100644
index 0000000..e5f1039
--- /dev/null
+++ b/accountwizard/identity.h
@@ -0,0 +1,68 @@
+/*
+    Copyright (c) 2010 Laurent Montel <montel at kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef IDENTITY_H
+#define IDENTITY_H
+
+#include "setupobject.h"
+
+class Transport;
+
+namespace KPIMIdentities {
+  class Identity;
+  class IdentityManager;
+}
+
+class Identity : public SetupObject
+{
+  Q_OBJECT
+  public:
+    explicit Identity( QObject *parent = 0 );
+    ~Identity();
+    void create();
+    void destroy();
+
+  public slots:
+    Q_SCRIPTABLE void setIdentityName( const QString &name );
+    Q_SCRIPTABLE void setRealName( const QString & name );
+    Q_SCRIPTABLE void setEmail( const QString &email );
+    Q_SCRIPTABLE void setOrganization( const QString &org );
+    Q_SCRIPTABLE void setSignature( const QString &sig );
+    Q_SCRIPTABLE uint uoid() const;
+    Q_SCRIPTABLE void setTransport( QObject* transport );
+    Q_SCRIPTABLE void setPreferredCryptoMessageFormat( const QString &format );
+    Q_SCRIPTABLE void setXFace( const QString &xface );
+
+  protected:
+    QString identityName() const;
+
+  private:
+    QString m_identityName;
+    QString m_realName;
+    QString m_email;
+    QString m_organization;
+    QString m_signature;
+    QString m_prefCryptoFormat;
+    QString m_xface;
+    Transport *m_transport;
+    KPIMIdentities::IdentityManager *m_manager;
+    KPIMIdentities::Identity *m_identity;
+};
+
+#endif
diff --git a/accountwizard/inprocess-main.cpp b/accountwizard/inprocess-main.cpp
new file mode 100644
index 0000000..41f850d
--- /dev/null
+++ b/accountwizard/inprocess-main.cpp
@@ -0,0 +1,46 @@
+/*
+    Copyright (c) 2010 Volker Krause <vkrause at kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#include "dialog.h"
+#include "global.h"
+
+#include <kglobal.h>
+#include <QtCore/QObject>
+#include <QtCore/QtPlugin>
+#include <QtCore/QStringList>
+
+class AccountWizard : public QObject
+{
+  Q_OBJECT
+  public:
+    explicit AccountWizard( QObject* parent = 0 ) : QObject( parent ) {}
+
+  public slots:
+    void run( const QStringList &types, QWidget *parent )
+    {
+      if ( !types.isEmpty() )
+        Global::setTypeFilter( types );
+      Dialog dlg( parent );
+      dlg.exec();
+    }
+};
+
+Q_EXPORT_PLUGIN2( accountwizard, AccountWizard )
+
+#include "inprocess-main.moc"
diff --git a/accountwizard/ispdb/CMakeLists.txt b/accountwizard/ispdb/CMakeLists.txt
new file mode 100644
index 0000000..c15ce4b
--- /dev/null
+++ b/accountwizard/ispdb/CMakeLists.txt
@@ -0,0 +1,19 @@
+set(ispdb_srcs
+  main.cpp
+  ispdb.cpp
+  autoconfigkolabmail.cpp
+  autoconfigkolabldap.cpp
+  autoconfigkolabfreebusy.cpp
+)
+
+kde4_add_executable(ispdb ${ispdb_srcs})
+
+target_link_libraries(ispdb
+  ${KDE4_KDECORE_LIBS}
+  ${KDE4_KIO_LIBS}
+  ${KDEPIMLIBS_KMIME_LIBS}
+)
+
+install(TARGETS ispdb ${INSTALL_TARGETS_DEFAULT_ARGS})
+
+add_subdirectory(tests)
\ No newline at end of file
diff --git a/accountwizard/ispdb/autoconfigkolabfreebusy.cpp b/accountwizard/ispdb/autoconfigkolabfreebusy.cpp
new file mode 100644
index 0000000..f555cc4
--- /dev/null
+++ b/accountwizard/ispdb/autoconfigkolabfreebusy.cpp
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2014  Sandro Knauß <knauss at kolabsys.com>
+ *
+ * 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
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "autoconfigkolabfreebusy.h"
+
+#include <QDomDocument>
+
+AutoconfigKolabFreebusy::AutoconfigKolabFreebusy(QObject *parent)
+    : AutoconfigKolabMail(parent)
+{
+
+}
+
+void AutoconfigKolabFreebusy::lookupInDb(bool auth, bool crypt)
+{
+    if (serverType() == DataBase) {
+        setServerType(IspAutoConfig);
+    }
+
+    startJob(lookupUrl(QLatin1String("freebusy"), QLatin1String("1.0"), auth, crypt));
+}
+
+void AutoconfigKolabFreebusy::parseResult(const QDomDocument &document)
+{
+    const QDomElement docElem = document.documentElement();
+    const QDomNodeList l = docElem.elementsByTagName(QLatin1String("freebusyProvider"));
+
+    if (l.isEmpty()) {
+        emit finished(false);
+        return;
+    }
+
+    for (int i = 0; i < l.count(); ++i) {
+        QDomElement e = l.at(i).toElement();
+        freebusy s = createFreebusyServer(e);
+        if (s.isValid()) {
+            mFreebusyServer[e.attribute(QLatin1String("id"))] = s;
+        }
+    }
+
+    emit finished(true);
+}
+
+freebusy AutoconfigKolabFreebusy::createFreebusyServer(const QDomElement &n)
+{
+    QDomNode o = n.firstChild();
+    freebusy s;
+    while (!o.isNull()) {
+        QDomElement f = o.toElement();
+        if (!f.isNull()) {
+            const QString tagName(f.tagName());
+            if (tagName == QLatin1String("hostname")) {
+                s.hostname = replacePlaceholders(f.text());
+            } else if (tagName == QLatin1String("port")) {
+                s.port = f.text().toInt();
+            } else if (tagName == QLatin1String("socketType")) {
+                const QString type(f.text());
+                if (type == QLatin1String("plain")) {
+                    s.socketType = None;
+                } else if (type == QLatin1String("SSL")) {
+                    s.socketType = SSL;
+                }
+                if (type == QLatin1String("TLS")) {
+                    s.socketType = StartTLS;
+                }
+            } else if (tagName == QLatin1String("username")) {
+                s.username = replacePlaceholders(f.text());
+            } else if (tagName == QLatin1String("password")) {
+                s.password = f.text();
+            } else if (tagName == QLatin1String("authentication")) {
+                const QString type(f.text());
+                if (type == QLatin1String("none")
+                        || type == QLatin1String("plain")) {
+                    s.authentication = Plain;
+                } else if (type == QLatin1String("basic")) {
+                    s.authentication = Basic;
+                }
+            } else if (tagName == QLatin1String("path")) {
+                s.path = f.text();
+            }
+        }
+        o = o.nextSibling();
+    }
+    return s;
+}
+
+QHash< QString, freebusy > AutoconfigKolabFreebusy::freebusyServers() const
+{
+    return mFreebusyServer;
+}
diff --git a/accountwizard/ispdb/autoconfigkolabfreebusy.h b/accountwizard/ispdb/autoconfigkolabfreebusy.h
new file mode 100644
index 0000000..be9446f
--- /dev/null
+++ b/accountwizard/ispdb/autoconfigkolabfreebusy.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2014  Sandro Knauß <knauss at kolabsys.com>
+ *
+ * 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 22 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef AUTOCONFIGKOLABFREEBUSY_H
+#define AUTOCONFIGKOLABFREEBUSY_H
+
+#include "autoconfigkolabmail.h"
+
+struct freebusy;
+
+class AutoconfigKolabFreebusy : public AutoconfigKolabMail
+{
+public:
+    /** Constructor */
+    explicit AutoconfigKolabFreebusy(QObject *parent = 0);
+
+    QHash<QString, freebusy> freebusyServers() const;
+
+protected:
+    virtual void lookupInDb(bool auth, bool crypt);
+    virtual void parseResult(const QDomDocument &document);
+
+private:
+    freebusy createFreebusyServer(const QDomElement &n);
+
+    QHash<QString, freebusy> mFreebusyServer;
+};
+
+struct freebusy {
+    freebusy()
+        : port(80)
+        , socketType(Ispdb::None)
+        , authentication(Ispdb::Plain)
+    {
+    }
+    bool isValid() const {
+        return (port != -1);
+    }
+    QString hostname;
+    int port;
+    Ispdb::socketType socketType;
+    Ispdb::authType authentication;
+    QString username;
+    QString password;
+    QString path;
+};
+
+#endif // AUTOCONFIGKOLABFREEBUSY_H
diff --git a/accountwizard/ispdb/autoconfigkolabldap.cpp b/accountwizard/ispdb/autoconfigkolabldap.cpp
new file mode 100644
index 0000000..a0b8158
--- /dev/null
+++ b/accountwizard/ispdb/autoconfigkolabldap.cpp
@@ -0,0 +1,131 @@
+/*
+ * Copyright (C) 2014  Sandro Knauß <knauss at kolabsys.com>
+ *
+ * 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 cense as published by
+ * the Free Software Foundation, either version 2: of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "autoconfigkolabldap.h"
+
+#include <QDomDocument>
+
+AutoconfigKolabLdap::AutoconfigKolabLdap(QObject *parent)
+    : AutoconfigKolabMail(parent)
+{
+
+}
+
+void AutoconfigKolabLdap::lookupInDb(bool auth, bool crypt)
+{
+    if (serverType() == DataBase) {
+        setServerType(IspAutoConfig);
+    }
+
+    startJob(lookupUrl(QLatin1String("ldap"), QLatin1String("1.0"), auth, crypt));
+}
+
+void AutoconfigKolabLdap::parseResult(const QDomDocument &document)
+{
+    const QDomElement docElem = document.documentElement();
+    const QDomNodeList l = docElem.elementsByTagName(QLatin1String("ldapProvider"));
+
+    if (l.isEmpty()) {
+        emit finished(false);
+        return;
+    }
+
+    for (int i = 0; i < l.count(); ++i) {
+        QDomElement e = l.at(i).toElement();
+        ldapServer s = createLdapServer(e);
+        if (s.isValid()) {
+            mLdapServers[e.attribute(QLatin1String("id"))] = s;
+        }
+    }
+
+    emit finished(true);
+}
+
+ldapServer AutoconfigKolabLdap::createLdapServer(const QDomElement &n)
+{
+    QDomNode o = n.firstChild();
+    ldapServer s;
+    while (!o.isNull()) {
+        QDomElement f = o.toElement();
+        if (!f.isNull()) {
+            const QString tagName(f.tagName());
+            if (tagName == QLatin1String("hostname")) {
+                s.hostname = replacePlaceholders(f.text());
+            } else if (tagName == QLatin1String("port")) {
+                s.port = f.text().toInt();
+            } else if (tagName == QLatin1String("socketType")) {
+                const QString type(f.text());
+                if (type == QLatin1String("plain")) {
+                    s.socketType = KLDAP::LdapServer::None;
+                } else if (type == QLatin1String("SSL")) {
+                    s.socketType =  KLDAP::LdapServer::SSL;
+                } else if (type == QLatin1String("TLS")) {
+                    s.socketType = KLDAP::LdapServer::TLS;
+                }
+            } else if (tagName == QLatin1String("authentication")) {
+                const QString type(f.text());
+                if (type == QLatin1String("anonyoum")) {
+                    s.authentication = KLDAP::LdapServer::Anonymous;
+                } else if (type == QLatin1String("simple")) {
+                    s.authentication = KLDAP::LdapServer::Simple;
+                } else if (type == QLatin1String("sasl")) {
+                    s.authentication = KLDAP::LdapServer::SASL;
+                }
+            } else if (tagName == QLatin1String("bindDn")) {
+                s.bindDn = f.text();
+            } else if (tagName == QLatin1String("sasl-mech")) {
+                s.saslMech = f.text();
+            } else if (tagName == QLatin1String("username")) {
+                s.username = f.text();
+            } else if (tagName == QLatin1String("password")) {
+                s.password = f.text();
+            } else if (tagName == QLatin1String("realm")) {
+                s.realm = f.text();
+            } else if (tagName == QLatin1String("dn")) {
+                s.dn = f.text();
+            } else if (tagName == QLatin1String("ldapVersion")) {
+                s.ldapVersion = f.text().toInt();
+            } else if (tagName == QLatin1String("filter")) {
+                s.filter = f.text();
+            } else if (tagName == QLatin1String("pagesize")) {
+                s.pageSize = f.text().toInt();
+                if (s.pageSize < 1 || s.pageSize > 9999999) {
+                    s.pageSize = -1;
+                }
+            } else if (tagName == QLatin1String("timelimit")) {
+                s.timeLimit = f.text().toInt();
+                if (s.timeLimit < 1 || s.timeLimit > 9999999) {
+                    s.timeLimit = -1;
+                }
+            } else if (tagName == QLatin1String("sizelimit")) {
+                s.sizeLimit = f.text().toInt();
+                if (s.sizeLimit < 1 || s.sizeLimit > 9999999) {
+                    s.sizeLimit = -1;
+                }
+            }
+        }
+        o = o.nextSibling();
+    }
+    return s;
+}
+
+QHash< QString, ldapServer > AutoconfigKolabLdap::ldapServers() const
+{
+    return mLdapServers;
+}
diff --git a/accountwizard/ispdb/autoconfigkolabldap.h b/accountwizard/ispdb/autoconfigkolabldap.h
new file mode 100644
index 0000000..6474217
--- /dev/null
+++ b/accountwizard/ispdb/autoconfigkolabldap.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2014  Sandro Knauß <knauss at kolabsys.com>
+ *
+ * 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
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef AUTOCONFIGKOLABLDAP_H
+#define AUTOCONFIGKOLABLDAP_H
+
+#include "autoconfigkolabmail.h"
+#include <kldap/ldapserver.h>
+
+struct ldapServer;
+
+class AutoconfigKolabLdap : public AutoconfigKolabMail
+{
+public:
+    /** Constructor */
+    explicit AutoconfigKolabLdap(QObject *parent = 0);
+
+    QHash<QString, ldapServer> ldapServers() const;
+
+protected:
+    virtual void lookupInDb(bool auth, bool crypt);
+    virtual void parseResult(const QDomDocument &document);
+
+private:
+    ldapServer createLdapServer(const QDomElement &n);
+
+    QHash<QString, ldapServer> mLdapServers;
+
+};
+
+struct ldapServer {
+    ldapServer()
+        : port(-1)
+        , socketType(KLDAP::LdapServer::None)
+        , authentication(KLDAP::LdapServer::Anonymous)
+        , ldapVersion(3)
+        , pageSize(-1)
+        , timeLimit(-1)
+        , sizeLimit(-1)
+    {
+    }
+    bool isValid() const {
+        return (port != -1);
+    }
+    QString hostname;
+    int port;
+    KLDAP::LdapServer::Security socketType;
+    KLDAP::LdapServer::Auth authentication;
+    int ldapVersion;
+    int pageSize;
+    int timeLimit;
+    int sizeLimit;
+    QString bindDn;
+    QString password;
+    QString saslMech;
+    QString username;
+    QString realm;
+    QString dn;
+    QString filter;
+};
+
+#endif // AUTOCONFIGKOLABLDAP_H
diff --git a/accountwizard/ispdb/autoconfigkolabmail.cpp b/accountwizard/ispdb/autoconfigkolabmail.cpp
new file mode 100644
index 0000000..9bebdcc
--- /dev/null
+++ b/accountwizard/ispdb/autoconfigkolabmail.cpp
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2014  Sandro Knauß <knauss at kolabsys.com>
+ *
+ * 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
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "autoconfigkolabmail.h"
+#include <QDomDocument>
+#include <KDebug>
+
+AutoconfigKolabMail::AutoconfigKolabMail(QObject *parent)
+    : Ispdb(parent)
+{
+
+}
+
+void AutoconfigKolabMail::startJob(const KUrl &url)
+{
+    mData.clear();
+    QMap< QString, QVariant > map;
+    map[QLatin1String("errorPage")] = false;
+    map[QLatin1String("no-auth-promt")] = true;
+    map[QLatin1String("no-www-auth")] = true;
+
+    KIO::TransferJob *job = KIO::get(url, KIO::NoReload, KIO::HideProgressInfo);
+    job->setMetaData(map);
+    connect(job, SIGNAL(result(KJob*)),
+            this, SLOT(slotResult(KJob*)));
+    connect(job, SIGNAL(data(KIO::Job*,QByteArray)),
+            this, SLOT(dataArrived(KIO::Job*,QByteArray)));
+}
+
+void AutoconfigKolabMail::slotResult(KJob *job)
+{
+    if (job->error()) {
+        if (job->error() == KIO::ERR_INTERNAL_SERVER ||   // error 500
+                job->error() == KIO::ERR_DOES_NOT_EXIST) {    // error 404
+            if (serverType() == DataBase) {
+                setServerType(IspAutoConfig);
+                lookupInDb(false, false);
+            } else if (serverType() == IspAutoConfig) {
+                setServerType(IspWellKnow);
+                lookupInDb(false, false);
+            } else {
+                emit finished(false);
+            }
+        } else {
+            kDebug() << "Fetching failed" << job->error() << job->errorString();
+            emit finished(false);
+        }
+        return;
+    }
+
+    KIO::TransferJob *tjob = qobject_cast<KIO::TransferJob *>(job);
+
+    int responsecode = tjob->queryMetaData(QLatin1String("responsecode")).toInt();
+
+    if (responsecode == 401) {
+        lookupInDb(true, true);
+        return;
+    } else if (responsecode != 200  && responsecode != 0 && responsecode != 304) {
+        kDebug() << "Fetching failed with" << responsecode;
+        emit finished(false);
+        return;
+    }
+
+    QDomDocument document;
+    bool ok = document.setContent(mData);
+    if (!ok) {
+        kDebug() << "Could not parse xml" << mData;
+        emit finished(false);
+        return;
+    }
+    parseResult(document);
+}
diff --git a/accountwizard/ispdb/autoconfigkolabmail.h b/accountwizard/ispdb/autoconfigkolabmail.h
new file mode 100644
index 0000000..f5f8070
--- /dev/null
+++ b/accountwizard/ispdb/autoconfigkolabmail.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2014  Sandro Knauß <knauss at kolabsys.com>
+ *
+ * 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
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef AUTOCONFIGKOLABMAIL_H
+#define AUTOCONFIGKOLABMAIL_H
+
+#include "ispdb.h"
+
+class AutoconfigKolabMail :  public Ispdb
+{
+    Q_OBJECT
+public:
+    /** Constructor */
+    explicit AutoconfigKolabMail(QObject *parent = 0);
+
+    virtual void startJob(const KUrl &url);
+
+private slots:
+    void slotResult(KJob *);
+};
+
+#endif // AUTOCONFIGKOLABMAIL_H
diff --git a/accountwizard/ispdb/ispdb.cpp b/accountwizard/ispdb/ispdb.cpp
new file mode 100644
index 0000000..1301739
--- /dev/null
+++ b/accountwizard/ispdb/ispdb.cpp
@@ -0,0 +1,386 @@
+/*
+    Copyright (c) 2010 Omat Holding B.V. <info at omat.nl>
+    Copyright (c) 2014  Sandro Knauß <knauss at kolabsys.com>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#include "ispdb.h"
+#include <kdebug.h>
+#include <kio/job.h>
+#include <kio/jobclasses.h>
+#include <KLocalizedString>
+
+#include <kmime/kmime_header_parsing.h>
+#include <QDomDocument>
+
+Ispdb::Ispdb( QObject *parent )
+    : QObject( parent )
+    , mServerType( DataBase )
+    , mStart( true )
+{
+}
+
+Ispdb::~Ispdb()
+{
+}
+
+void Ispdb::setEmail( const QString& address )
+{
+    KMime::Types::Mailbox box;
+    box.fromUnicodeString( address );
+    mAddr = box.addrSpec();
+}
+
+void Ispdb::setPassword( const QString &password )
+{
+    mPassword = password;
+}
+
+
+void Ispdb::start()
+{
+    // we should do different things in here. But lets focus in the db first.
+    lookupInDb(false, false);
+}
+
+void Ispdb::lookupInDb( bool auth, bool crypt )
+{
+    setServerType(mServerType);
+    startJob( lookupUrl(QLatin1String("mail"), QLatin1String("1.1"), auth, crypt) );
+}
+
+void Ispdb::startJob( const KUrl&url )
+{
+    mData.clear();
+    QMap< QString, QVariant > map;
+    map[QLatin1String("errorPage")] = false;
+
+    KIO::TransferJob* job = KIO::get( url, KIO::NoReload, KIO::HideProgressInfo );
+    job->setMetaData( map );
+    connect( job, SIGNAL(result(KJob*)),
+             this, SLOT(slotResult(KJob*)) );
+    connect( job, SIGNAL(data(KIO::Job*,QByteArray)),
+             this, SLOT(dataArrived(KIO::Job*,QByteArray)) );
+}
+
+KUrl Ispdb::lookupUrl( const QString &type, const QString &version, bool auth, bool crypt )
+{
+    KUrl url;
+    const QString path = type + QLatin1String("/config-v") + version + QLatin1String(".xml");
+
+    switch( mServerType )
+    {
+    case IspAutoConfig:
+    {
+        url = KUrl( QLatin1String("http://autoconfig.") + mAddr.domain.toLower() + QLatin1Char('/') + path );
+        break;
+    }
+    case IspWellKnow:
+    {
+        url = KUrl( QLatin1String("http://") + mAddr.domain.toLower() + QLatin1String("/.well-known/autoconfig/") + path );
+        break;
+    }
+    case DataBase:
+    {
+        url = KUrl( QLatin1String("https://autoconfig.thunderbird.net/v1.1/") + mAddr.domain.toLower() );
+        break;
+    }
+    }
+
+    if ( mServerType != DataBase ) {
+        if (crypt) {
+            url.setProtocol(QLatin1String("https"));
+        }
+
+        if(auth) {
+            url.setUser(mAddr.asString());
+            url.setPass(mPassword);
+        }
+    }
+    return url;
+}
+
+
+void Ispdb::slotResult( KJob* job )
+{
+    if ( job->error() ) {
+      kDebug() << "Fetching failed" << job->errorString();
+      bool lookupFinished = false;
+
+      switch( mServerType ) {
+      case IspAutoConfig: {
+        mServerType = IspWellKnow;
+        break;
+      }
+      case IspWellKnow: {
+        lookupFinished = true;
+        break;
+      }
+      case DataBase: {
+        mServerType = IspAutoConfig;
+        break;
+      }
+      }
+
+      if ( lookupFinished )
+      {
+        emit finished( false );
+        return;
+      }
+      lookupInDb( false, false );
+      return;
+    }
+
+    //kDebug() << mData;
+    QDomDocument document;
+    bool ok = document.setContent( mData );
+    if ( !ok ) {
+        kDebug() << "Could not parse xml" << mData;
+        emit finished( false );
+        return;
+    }
+
+    parseResult( document );
+
+}
+
+void Ispdb::parseResult( const QDomDocument &document )
+{
+    QDomElement docElem = document.documentElement();
+    QDomNodeList l = docElem.elementsByTagName(QLatin1String("emailProvider"));
+
+    if ( l.isEmpty() ) {
+        emit finished(false);
+        return;
+    }
+
+    //only handle the first emailProvider entry
+    QDomNode firstProvider = l.at(0);
+    QDomNode n = firstProvider.firstChild();
+    while( !n.isNull() ) {
+        QDomElement e = n.toElement();
+        if ( !e.isNull() ) {
+            //kDebug()  << qPrintable( e.tagName() );
+          const QString tagName( e.tagName() );
+            if ( tagName == QLatin1String( "domain" ) )
+                mDomains << e.text();
+            else if ( tagName == QLatin1String( "displayName" ) )
+                mDisplayName = e.text();
+            else if ( tagName == QLatin1String( "displayShortName" ) )
+                mDisplayShortName = e.text();
+            else if ( tagName == QLatin1String( "incomingServer" )
+                      && e.attribute( QLatin1String("type") ) == QLatin1String( "imap" ) ) {
+                server s = createServer( e );
+                if (s.isValid())
+                   mImapServers.append( s );
+            } else if ( tagName == QLatin1String( "incomingServer" )
+                      && e.attribute( QLatin1String("type") ) == QLatin1String( "pop3" ) ) {
+                server s = createServer( e );
+                if (s.isValid())
+                   mPop3Servers.append( s );
+            } else if ( tagName == QLatin1String( "outgoingServer" )
+                      && e.attribute( QLatin1String("type") ) == QLatin1String( "smtp" ) ) {
+                server s = createServer( e );
+                if (s.isValid())
+                   mSmtpServers.append( s );
+            } else if ( tagName == QLatin1String( "identity" ) ) {
+                identity i = createIdentity( e );
+                if ( i.isValid() ) {
+                    mIdentities.append( i );
+                    if ( i.isDefault() ) {
+                        mDefaultIdentity = mIdentities.count()-1;
+                    }
+                }
+            }
+        }
+        n = n.nextSibling();
+    }
+
+    emit finished( true );
+}
+
+
+server Ispdb::createServer( const QDomElement& n )
+{
+    QDomNode o = n.firstChild();
+    server s;
+    while ( !o.isNull() ) {
+        QDomElement f = o.toElement();
+        if ( !f.isNull() ) {
+          const QString tagName( f.tagName() );
+            if ( tagName == QLatin1String( "hostname" ) )
+                s.hostname = replacePlaceholders( f.text() );
+            else if ( tagName == QLatin1String( "port" ) )
+                s.port = f.text().toInt();
+            else if ( tagName == QLatin1String( "socketType" ) ) {
+              const QString type( f.text() );
+                if ( type == QLatin1String( "plain" ) )
+                    s.socketType = None;
+                else if ( type == QLatin1String( "SSL" ) )
+                    s.socketType = SSL;
+                if ( type == QLatin1String( "STARTTLS" ) )
+                    s.socketType = StartTLS;
+            } else if ( tagName == QLatin1String( "username" ) ) {
+                s.username = replacePlaceholders( f.text() );
+            } else if ( tagName == QLatin1String( "authentication" ) ) {
+              const QString type( f.text() );
+                if ( type == QLatin1String( "password-cleartext" )
+                     || type == QLatin1String( "plain" ) )
+                  s.authentication = Plain;
+                else if ( type == QLatin1String( "password-encrypted" )
+                          || type == QLatin1String( "secure" ) )
+                  s.authentication = CramMD5;
+                else if ( type == QLatin1String( "NTLM" ) )
+                    s.authentication = NTLM;
+                else if ( type == QLatin1String( "GSSAPI" ) )
+                    s.authentication = GSSAPI;
+                else if ( type == QLatin1String( "client-ip-based" ) )
+                    s.authentication = ClientIP;
+                else if ( type == QLatin1String( "none" ) )
+                    s.authentication = NoAuth;
+            }
+        }
+        o = o.nextSibling();
+    }
+    return s;
+}
+
+identity Ispdb::createIdentity( const QDomElement& n )
+{
+    QDomNode o = n.firstChild();
+    identity i;
+
+    //type="kolab" version="1.0" is the only identity that is defined
+    if ( n.attribute(QLatin1String("type")) != QLatin1String("kolab")
+            || n.attribute(QLatin1String("version")) != QLatin1String("1.0") ) {
+        kDebug() << "unknown type of identity element.";
+    }
+
+    while ( !o.isNull() ) {
+        QDomElement f = o.toElement();
+        if ( !f.isNull() ) {
+          const QString tagName( f.tagName() );
+          if ( tagName == QLatin1String( "default" ) ) {
+              i.mDefault = f.text().toLower() == QLatin1String( "true" );
+          } else if ( tagName == QLatin1String( "email" ) ) {
+              i.email = f.text();
+          } else if ( tagName == QLatin1String( "name" ) ) {
+              i.name = f.text();
+          } else if ( tagName == QLatin1String( "organization" ) ) {
+              i.organization = f.text();
+          } else if ( tagName == QLatin1String( "signature" ) ) {
+              QTextStream stream(&i.signature);
+              f.save(stream, 0);
+              i.signature = i.signature.trimmed();
+              if ( i.signature.startsWith(QLatin1String("<signature>")) ) {
+                  i.signature = i.signature.mid(11,i.signature.length()-23);
+                  i.signature = i.signature.trimmed();
+              }
+          }
+        }
+        o = o.nextSibling();
+    }
+
+    return i;
+}
+
+QString Ispdb::replacePlaceholders( const QString& in )
+{
+    QString out( in );
+    out.replace( QLatin1String("%EMAILLOCALPART%"), mAddr.localPart );
+    out.replace( QLatin1String("%EMAILADDRESS%"), mAddr.asString() );
+    out.replace( QLatin1String("%EMAILDOMAIN%"), mAddr.domain );
+    return out;
+}
+
+void Ispdb::dataArrived( KIO::Job*, const QByteArray& data )
+{
+    mData.append( data );
+}
+
+// The getters
+
+QStringList Ispdb::relevantDomains() const
+{
+    return mDomains;
+}
+
+QString Ispdb::name( length l ) const
+{
+    if ( l == Long )
+        return mDisplayName;
+    else if ( l == Short )
+        return  mDisplayShortName;
+    else
+        return QString(); //make compiler happy. Not me.
+}
+
+QList< server > Ispdb::imapServers() const
+{
+    return mImapServers;
+}
+
+QList< server > Ispdb::pop3Servers() const
+{
+    return mPop3Servers;
+}
+
+QList< server > Ispdb::smtpServers() const
+{
+    return mSmtpServers;
+}
+
+int Ispdb::defaultIdentity() const
+{
+    return mDefaultIdentity;
+}
+
+QList< identity > Ispdb::identities() const
+{
+    return mIdentities;
+}
+
+void Ispdb::setServerType( Ispdb::searchServerType type )
+{
+    if ( type != mServerType || mStart ) {
+        mServerType = type;
+        mStart  = false;
+        switch( mServerType )
+        {
+        case IspAutoConfig:
+        {
+            Q_EMIT searchType(i18n("Lookup configuration: Email provider"));
+            break;
+        }
+        case IspWellKnow:
+        {
+            Q_EMIT searchType(i18n("Lookup configuration: Trying common server name"));
+            break;
+        }
+        case DataBase:
+        {
+            Q_EMIT searchType(i18n("Lookup configuration: Mozilla database"));
+            break;
+        }
+        }
+    }
+}
+
+Ispdb::searchServerType Ispdb::serverType() const
+{
+    return mServerType;
+}
diff --git a/accountwizard/ispdb/ispdb.h b/accountwizard/ispdb/ispdb.h
new file mode 100644
index 0000000..36eb2b2
--- /dev/null
+++ b/accountwizard/ispdb/ispdb.h
@@ -0,0 +1,214 @@
+/*
+    Copyright (c) 2010 Omat Holding B.V. <info at omat.nl>
+    Copyright (c) 2014  Sandro Knauß <knauss at kolabsys.com>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef ISPDB_H
+#define ISPDB_H
+
+#include <QObject>
+
+#include <kio/job.h>
+#include <kmime/kmime_header_parsing.h>
+
+class QDomElement;
+class QDomDocument;
+
+struct server;
+struct identity;
+
+/**
+  This class will search in Mozilla's database for an xml file
+  describing the isp data belonging to that address. This class
+  searches and wraps the result for further usage. References:
+    https://wiki.mozilla.org/Thunderbird:Autoconfiguration
+    https://developer.mozilla.org/en/Thunderbird/Autoconfiguration
+    https://ispdb.mozillamessaging.com/
+*/
+class Ispdb : public QObject
+{
+    Q_OBJECT
+public:
+    enum socketType { None = 0, SSL, StartTLS };
+
+    /**
+     Ispdb uses custom authtyps, hence the enum here.
+     @see https://wiki.mozilla.org/Thunderbird:Autoconfiguration:ConfigFileFormat
+     In particular, note that Ispdb's Plain represents both Cleartext and AUTH Plain
+     We will always treat it as Cleartext
+     */
+    enum authType { Plain = 0, CramMD5, NTLM, GSSAPI, ClientIP, NoAuth, Basic };
+    enum length { Long = 0, Short };
+
+    /** Constructor */
+    explicit Ispdb( QObject *parent = 0 );
+
+    /** Destructor */
+    ~Ispdb();
+
+    /** After finished() has been emitted you can
+        retrieve the domains that are covered by these
+        settings */
+    QStringList relevantDomains() const;
+
+    /** After finished() has been emitted you can
+        get the name of the provider, you can get a long
+        name and a short one */
+    QString name( length ) const;
+
+    /** After finished() has been emitted you can
+        get a list of imap servers available for this provider */
+    QList< server > imapServers() const;
+
+    /** After finished() has been emitted you can
+        get a list of pop3 servers available for this provider */
+    QList< server > pop3Servers() const;
+
+    /** After finished() has been emitted you can
+        get a list of smtp servers available for this provider */
+    QList< server > smtpServers() const;
+
+    QList< identity > identities() const;
+
+    int defaultIdentity() const;
+
+public slots:
+    /** Sets the emailaddress you want to servers for */
+    void setEmail( const QString& );
+
+    /** Sets the password for login */
+    void setPassword( const QString& );
+
+    /** Starts looking up the servers which belong to the e-mailaddress */
+    void start();
+
+private slots:
+    void slotResult( KJob* );
+
+signals:
+    /** emitted when done. **/
+    void finished( bool );
+    void searchType( const QString &type );
+
+protected:
+    /** search types, where to search for autoconfig
+        @see lookupUrl to geneerate a url base on this type
+     */
+    enum searchServerType {
+      IspAutoConfig = 0,                  /**< http://autoconfig.example.com/mail/config-v1.1.xml */
+      IspWellKnow,                        /**< http://example.com/.well-known/autoconfig/mail/config-v1.1.xml */
+      DataBase                            /**< https://autoconfig.thunderbird.net/v1.1/example.com */
+    };
+
+    /** let's request the autoconfig server */
+    virtual void startJob( const KUrl &url );
+
+    /** generate url and start job afterwards */
+    virtual void lookupInDb( bool auth, bool crypt );
+
+    /** an valid xml document is available, parse it and create all the objects
+        should run createServer, createIdentity, ...
+     */
+    virtual void parseResult( const QDomDocument &document );
+
+    /** create a server object out of an element */
+    virtual server createServer( const QDomElement& n );
+
+    /** create a identity object out of an element */
+    virtual identity createIdentity( const QDomElement& n );
+
+    /** get standard urls for autoconfig
+        @return the standard url for autoconfig depends on serverType
+        @param type of request ( ex. "mail" )
+        @param version of the file ( example for mail "1.1" )
+        @param auth use authentification with username & password to access autoconfig file
+                    ( username is the emailaddress )
+        @param crypt use https
+     */
+    KUrl lookupUrl( const QString& type, const QString& version, bool auth, bool crypt );
+
+    /** setter for serverType */
+    void setServerType( Ispdb::searchServerType type );
+
+    /** getter for serverType */
+    Ispdb::searchServerType serverType() const;
+
+    /** replaces %EMAILLOCALPART%, %EMAILADDRESS% and %EMAILDOMAIN% with the
+        parts of the emailaddress */
+    QString replacePlaceholders( const QString& );
+
+    QByteArray mData;             /** storage of incoming data from kio */
+protected slots:
+
+    /** slot for TransferJob to dump data */
+    void dataArrived( KIO::Job*, const QByteArray& data );
+
+private:
+    KMime::Types::AddrSpec mAddr; // emailaddress
+    QString mPassword;
+
+    // storage of the results
+    QStringList mDomains;
+    QString mDisplayName, mDisplayShortName;
+    QList< server > mImapServers, mPop3Servers, mSmtpServers;
+    QList< identity > mIdentities;
+
+    int mDefaultIdentity;
+    Ispdb::searchServerType mServerType;
+    bool mStart;
+};
+
+struct server {
+    server() {
+       port = -1;
+       authentication = Ispdb::Plain;
+       socketType = Ispdb::None;
+    }
+    bool isValid() const {
+       return (port != -1);
+    }
+    QString hostname;
+    int port;
+    Ispdb::socketType socketType;
+    QString username;
+    Ispdb::authType authentication;
+};
+
+struct identity {
+    identity()
+         : mDefault(false)
+    {
+    }
+
+    bool isValid() const {
+        return !name.isEmpty();
+    }
+
+    bool isDefault() const {
+        return mDefault;
+    }
+
+    bool mDefault;
+    QString email;
+    QString name;
+    QString organization;
+    QString signature;
+};
+
+
+#endif
diff --git a/accountwizard/ispdb/main.cpp b/accountwizard/ispdb/main.cpp
new file mode 100644
index 0000000..e1ed9a1
--- /dev/null
+++ b/accountwizard/ispdb/main.cpp
@@ -0,0 +1,128 @@
+/*
+    Copyright (c) 2010 Omat Holding B.V. <info at omat.nl>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#include "ispdb.h"
+
+#include <kaboutdata.h>
+#include <kapplication.h>
+#include <kcmdlineargs.h>
+#include <kglobal.h>
+
+#include <KDebug>
+
+QString socketTypeToStr( Ispdb::socketType socketType )
+{
+    QString enc = QLatin1String("None");
+    if ( socketType == Ispdb::SSL ) {
+        enc = QLatin1String("SSL");
+    } else if ( socketType == Ispdb::StartTLS ) {
+        enc = QLatin1String("TLS");
+    }
+    return enc;
+}
+
+QString authTypeToStr( Ispdb::authType authType )
+{
+    QString auth = QLatin1String("unknown");
+    switch ( authType ) {
+      case Ispdb::Plain:
+        auth = QLatin1String("plain");
+        break;
+      case Ispdb::CramMD5:
+        auth = QLatin1String("CramMD5");
+        break;
+      case Ispdb::NTLM:
+        auth = QLatin1String("NTLM");
+        break;
+      case Ispdb::GSSAPI:
+        auth = QLatin1String("GSSAPI");
+        break;
+      case Ispdb::ClientIP:
+        auth = QLatin1String("ClientIP");
+        break;
+      case Ispdb::NoAuth:
+        auth = QLatin1String("NoAuth");
+        break;
+    }
+    return auth;
+}
+int main( int argc, char **argv )
+{
+    KAboutData aboutData( "ispdb", 0,
+                          ki18n( "ISPDB Assistant" ),
+                          "0.1",
+                          ki18n( "Helps setting up PIM accounts" ),
+                          KAboutData::License_LGPL,
+                          ki18n( "(c) 2010 Omat Holding B.V." ),
+                          KLocalizedString(),
+                          "http://pim.kde.org/akonadi/" );
+    aboutData.setProgramIconName( QLatin1String("akonadi") );
+    aboutData.addAuthor( ki18n( "Tom Albers" ),  ki18n( "Author" ), "toma at kde.org" );
+
+    KCmdLineArgs::init( argc, argv, &aboutData );
+    KCmdLineOptions options;
+    options.add( "email <emailaddress>", ki18n( "Tries to fetch the settings for that email address" ) );
+    KCmdLineArgs::addCmdLineOptions( options );
+    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+
+    QString email( QLatin1String("blablabla at gmail.com") );
+    if ( !args->getOption( "email" ).isEmpty() ) {
+        email = args->getOption( "email" );
+    }
+
+    KApplication app;
+
+    QEventLoop loop;
+    Ispdb ispdb;
+    ispdb.setEmail( email );
+
+    loop.connect( &ispdb, SIGNAL(finished(bool)), SLOT(quit()) );
+
+    ispdb.start();
+
+    loop.exec();
+    kDebug() << "Domains" << ispdb.relevantDomains();
+    kDebug() << "Name" << ispdb.name( Ispdb::Long ) << "(" << ispdb.name( Ispdb::Short ) << ")";
+    kDebug() << "Imap servers:";
+    foreach ( const server &s, ispdb.imapServers() ) {
+        kDebug() << "\thostname:" << s.hostname
+                 << "- port:" << s.port
+                 << "- encryption:" << socketTypeToStr(s.socketType)
+                 << "- username:" << s.username
+                 << "- authentication:" << authTypeToStr(s.authentication);
+    }
+    kDebug() << "pop3 servers:";
+    foreach ( const server &s, ispdb.pop3Servers() ) {
+        kDebug() << "\thostname:" << s.hostname
+                 << "- port:" << s.port
+                 << "- encryption:" << socketTypeToStr(s.socketType)
+                 << "- username:" << s.username
+                 << "- authentication:" << authTypeToStr(s.authentication);
+    }
+    kDebug() << "smtp servers:";
+    foreach ( const server &s, ispdb.smtpServers() ) {
+        kDebug() << "\thostname:" << s.hostname
+                 << "- port:" << s.port
+                 << "- encryption:" << socketTypeToStr(s.socketType)
+                 << "- username:" << s.username
+                 << "- authentication:" << authTypeToStr(s.authentication);
+    }
+
+    return true;
+}
diff --git a/accountwizard/ispdb/tests/CMakeLists.txt b/accountwizard/ispdb/tests/CMakeLists.txt
new file mode 100644
index 0000000..42804dc
--- /dev/null
+++ b/accountwizard/ispdb/tests/CMakeLists.txt
@@ -0,0 +1,43 @@
+include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/.. )
+add_definitions (-DAUTOCONFIG_DATA_DIR="\\"${CMAKE_CURRENT_SOURCE_DIR}/data\\"")
+add_definitions (-DCURRENT_SOURCE_DIR="\\"${CMAKE_CURRENT_SOURCE_DIR}\\"")
+
+kde4_add_unit_test(ispdbtest ispdbtest.cpp ../ispdb.cpp)
+
+target_link_libraries(ispdbtest
+    ${KDE4_KDECORE_LIBS}
+    ${KDE4_KIO_LIBS}
+    ${KDEPIMLIBS_KMIME_LIBS}
+    ${KDEPIMLIBS_KLDAP_LIBS}
+    ${QT_QTTEST_LIBRARY}
+  )
+
+kde4_add_unit_test(autoconfigkolabmailtest autoconfigkolabmailtest.cpp ../ispdb.cpp ../autoconfigkolabmail.cpp)
+
+target_link_libraries(autoconfigkolabmailtest
+    ${KDE4_KDECORE_LIBS}
+    ${KDE4_KIO_LIBS}
+    ${KDEPIMLIBS_KMIME_LIBS}
+    ${KDEPIMLIBS_KLDAP_LIBS}
+    ${QT_QTTEST_LIBRARY}
+  )
+  
+kde4_add_unit_test(autoconfigkolabldaptest autoconfigkolabldaptest.cpp ../ispdb.cpp ../autoconfigkolabmail.cpp ../autoconfigkolabldap.cpp)
+
+target_link_libraries(autoconfigkolabldaptest
+    ${KDE4_KDECORE_LIBS}
+    ${KDE4_KIO_LIBS}
+    ${KDEPIMLIBS_KMIME_LIBS}
+    ${KDEPIMLIBS_KLDAP_LIBS}
+    ${QT_QTTEST_LIBRARY}
+  )
+  
+kde4_add_unit_test(autoconfigkolabfreebusytest autoconfigkolabfreebusy.cpp ../ispdb.cpp ../autoconfigkolabmail.cpp ../autoconfigkolabfreebusy.cpp)
+
+target_link_libraries(autoconfigkolabfreebusytest
+    ${KDE4_KDECORE_LIBS}
+    ${KDE4_KIO_LIBS}
+    ${KDEPIMLIBS_KMIME_LIBS}
+    ${KDEPIMLIBS_KLDAP_LIBS}
+    ${QT_QTTEST_LIBRARY}
+  )
\ No newline at end of file
diff --git a/accountwizard/ispdb/tests/autoconfigkolabfreebusy.cpp b/accountwizard/ispdb/tests/autoconfigkolabfreebusy.cpp
new file mode 100644
index 0000000..b9b4dd7
--- /dev/null
+++ b/accountwizard/ispdb/tests/autoconfigkolabfreebusy.cpp
@@ -0,0 +1,174 @@
+/*
+    Copyright (c) 2014 Sandro Knauß <knauss at kolabsys.com>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#include <QObject>
+#include <QDir>
+#include <qtest_kde.h>
+
+#include <KDebug>
+
+#include "../autoconfigkolabfreebusy.h"
+
+class TAutoconfFreebusy : public AutoconfigKolabFreebusy
+{
+public:
+    void startJob(const KUrl &url)
+    {
+        QCOMPARE(url, expectedUrls.takeFirst());
+        if (replace.contains(url)) {
+            AutoconfigKolabFreebusy::startJob(replace[url]);
+        } else {
+            AutoconfigKolabFreebusy::startJob(url);
+        }
+    }
+
+    QMap<KUrl, KUrl> replace;
+    QList<KUrl> expectedUrls;
+};
+
+class AutoconfFreebusyTest : public QObject
+{
+    Q_OBJECT
+public:
+    AutoconfigKolabFreebusy *execIspdb(const QString &file)
+    {
+        QDir dir(QLatin1String(AUTOCONFIG_DATA_DIR));
+        QString furl = QLatin1String("file://%1/%2");
+
+        QEventLoop loop;
+        TAutoconfFreebusy *ispdb = new TAutoconfFreebusy();
+
+        loop.connect(ispdb, SIGNAL(finished(bool)), SLOT(quit()));
+
+        KUrl url(furl.arg(dir.path()).arg(file));
+        ispdb->setEmail(QLatin1String("john.doe at example.com"));
+        ispdb->expectedUrls.append(url);
+        ispdb->startJob(url);
+
+        loop.exec();
+        return ispdb;
+    }
+
+    void testFreebusy(const freebusy &test, const freebusy &expected) const
+    {
+        QVERIFY(test.isValid());
+        QCOMPARE(test.hostname, expected.hostname);
+        QCOMPARE(test.port, expected.port);
+        QCOMPARE(test.socketType, expected.socketType);
+        QCOMPARE(test.authentication, expected.authentication);
+        QCOMPARE(test.username, expected.username);
+        QCOMPARE(test.password, expected.password);
+        QCOMPARE(test.path, expected.path);
+    }
+private slots:
+    void testFreebusyParsing()
+    {
+        AutoconfigKolabFreebusy *ispdb = execIspdb(QLatin1String("freebusy.xml"));
+
+        freebusy s;
+
+        s.hostname = QLatin1String("example.com");
+        s.port = 80;
+        s.socketType = Ispdb::None;
+        s.authentication = Ispdb::Basic;
+        s.username = QLatin1String("user");
+        s.password = QLatin1String("pass");
+        s.path = QLatin1String("/freebusy/$EMAIL$.ifb");
+
+        QCOMPARE(ispdb->freebusyServers().count(), 1);
+        testFreebusy(ispdb->freebusyServers()[QLatin1String("freebusy.example.com")], s);
+    }
+
+    void testFreebusyCompleteFail()
+    {
+        QEventLoop loop;
+        TAutoconfFreebusy *ispdb = new TAutoconfFreebusy();
+
+        loop.connect(ispdb, SIGNAL(finished(bool)), SLOT(quit()));
+        connect(ispdb, SIGNAL(finished(bool)), SLOT(expectedReturn(bool)));
+
+        KUrl expected(QLatin1String("http://autoconfig.example.com/freebusy/config-v1.0.xml"));
+        KUrl expected2(QLatin1String("http://example.com/.well-known/autoconfig/freebusy/config-v1.0.xml"));
+        mReturn = false;
+        ispdb->setEmail(QLatin1String("john.doe at example.com"));
+        ispdb->expectedUrls.append(expected);
+        ispdb->expectedUrls.append(expected2);
+        ispdb->replace[expected] = QLatin1String("http://localhost:8000/500");
+        ispdb->replace[expected2] = QLatin1String("http://localhost:8000/404");
+        ispdb->start();
+        loop.exec();
+        QCOMPARE(ispdb->expectedUrls.count(), 0);
+    }
+
+    void testFreebusyLogin()
+    {
+        QDir dir(QLatin1String(AUTOCONFIG_DATA_DIR));
+        QString furl = QLatin1String("file://%1/freebusy.xml");
+
+        QEventLoop loop;
+        TAutoconfFreebusy *ispdb = new TAutoconfFreebusy();
+
+        loop.connect(ispdb, SIGNAL(finished(bool)), SLOT(quit()));
+        connect(ispdb, SIGNAL(finished(bool)), SLOT(expectedReturn(bool)));
+
+        KUrl expected(QLatin1String("http://autoconfig.example.com/freebusy/config-v1.0.xml"));
+        KUrl expected2(QLatin1String("https://john.doe%40example.com:xxx@autoconfig.example.com/freebusy/config-v1.0.xml"));
+        KUrl expected3(QLatin1String("http://example.com/.well-known/autoconfig/freebusy/config-v1.0.xml"));
+
+        mReturn = true;
+        ispdb->setEmail(QLatin1String("john.doe at example.com"));
+        ispdb->setPassword(QLatin1String("xxx"));
+        ispdb->expectedUrls.append(expected);
+        ispdb->expectedUrls.append(expected2);
+        ispdb->expectedUrls.append(expected3);
+        ispdb->replace[expected] = QLatin1String("http://localhost:8000/401");
+        ispdb->replace[expected2] = QLatin1String("http://localhost:8000/500");
+        ispdb->replace[expected3] = furl.arg(dir.path());
+        ispdb->start();
+        loop.exec();
+        QCOMPARE(ispdb->expectedUrls.count(), 0);
+    }
+
+    void expectedReturn(bool ret)
+    {
+        QCOMPARE(ret, mReturn);
+    }
+
+    void initTestCase()
+    {
+        QDir dir(QLatin1String(CURRENT_SOURCE_DIR));
+        QString furl = QLatin1String("%1/errorserver.py");
+        process.start(QLatin1String("python"), QStringList() << furl.arg(dir.path()));
+        process.waitForStarted();
+        QCOMPARE(process.state(), QProcess::Running);
+    }
+
+    void cleanupTestCase()
+    {
+        process.terminate();
+        process.waitForFinished();
+    }
+public:
+    bool mReturn;
+    QProcess process;
+};
+
+QTEST_KDEMAIN(AutoconfFreebusyTest, NoGUI)
+
+#include "autoconfigkolabfreebusy.moc"
diff --git a/accountwizard/ispdb/tests/autoconfigkolabldaptest.cpp b/accountwizard/ispdb/tests/autoconfigkolabldaptest.cpp
new file mode 100644
index 0000000..2722ec4
--- /dev/null
+++ b/accountwizard/ispdb/tests/autoconfigkolabldaptest.cpp
@@ -0,0 +1,209 @@
+/*
+    Copyright (c) 2014 Sandro Knauß <knauss at kolabsys.com>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#include <QObject>
+#include <QDir>
+#include <qtest_kde.h>
+
+#include <KDebug>
+
+#include "../autoconfigkolabldap.h"
+
+class TAutoconfLdap : public AutoconfigKolabLdap
+{
+public:
+    void startJob(const KUrl &url)
+    {
+        QCOMPARE(url, expectedUrls.takeFirst());
+        if (replace.contains(url)) {
+            AutoconfigKolabLdap::startJob(replace[url]);
+        } else {
+            AutoconfigKolabLdap::startJob(url);
+        }
+    }
+
+    QMap<KUrl, KUrl> replace;
+    QList<KUrl> expectedUrls;
+};
+
+class AutoconfLdapTest : public QObject
+{
+    Q_OBJECT
+public:
+    AutoconfigKolabLdap *execIspdb(const QString &file)
+    {
+        QDir dir(QLatin1String(AUTOCONFIG_DATA_DIR));
+        QString furl = QLatin1String("file://%1/%2");
+
+        QEventLoop loop;
+        TAutoconfLdap *ispdb = new TAutoconfLdap();
+
+        loop.connect(ispdb, SIGNAL(finished(bool)), SLOT(quit()));
+
+        KUrl url(furl.arg(dir.path()).arg(file));
+        ispdb->setEmail(QLatin1String("john.doe at example.com"));
+        ispdb->expectedUrls.append(url);
+        ispdb->startJob(url);
+
+        loop.exec();
+        return ispdb;
+    }
+
+    void testLdapServer(const ldapServer &test, const ldapServer &expected) const {
+        QCOMPARE(test.hostname, expected.hostname);
+        QCOMPARE(test.port, expected.port);
+        QCOMPARE(test.socketType, expected.socketType);
+        QCOMPARE(test.authentication, expected.authentication);
+        QCOMPARE(test.bindDn, expected.bindDn);
+        QCOMPARE(test.password, expected.password);
+        QCOMPARE(test.saslMech, expected.saslMech);
+        QCOMPARE(test.username, expected.username);
+        QCOMPARE(test.realm, expected.realm);
+        QCOMPARE(test.dn, expected.dn);
+        QCOMPARE(test.ldapVersion, expected.ldapVersion);
+        QCOMPARE(test.filter, expected.filter);
+        QCOMPARE(test.pageSize, expected.pageSize);
+        QCOMPARE(test.timeLimit, expected.timeLimit);
+        QCOMPARE(test.sizeLimit, expected.sizeLimit);
+    }
+
+private slots:
+    void testLdapParsing()
+    {
+        AutoconfigKolabLdap *ispdb = execIspdb(QLatin1String("ldap.xml"));
+
+        ldapServer s;
+        QCOMPARE(ispdb->ldapServers().count(), 2);
+
+        s.hostname = QLatin1String("ldap.example.com");
+        s.port = 389;
+        s.socketType = KLDAP::LdapServer::None;
+        s.authentication = KLDAP::LdapServer::Simple;
+        s.bindDn = QLatin1String("cn=Directory Manager");
+        s.password = QLatin1String("Welcome2KolabSystems");
+        s.saslMech = QString();
+        s.username = QString();
+        s.realm = QString();
+        s.dn = QLatin1String("dc=kolabsys,dc=com");
+        s.ldapVersion = 3;
+        s.filter = QString();
+        s.pageSize = -1;
+        s.timeLimit = -1;
+        s.sizeLimit = -1;
+
+        testLdapServer(ispdb->ldapServers()[QLatin1String("ldap.example.com")], s);
+
+        s.hostname = QLatin1String("ldap2.example.com");
+        s.port = 387;
+        s.socketType = KLDAP::LdapServer::SSL;
+        s.authentication = KLDAP::LdapServer::SASL;
+        s.bindDn = QLatin1String("cn=Directory");
+        s.password = QLatin1String("Welcome2KolabSystems");
+        s.saslMech = QLatin1String("XXX");
+        s.username = QLatin1String("john.doe");
+        s.realm = QLatin1String("realm.example.com");
+        s.dn = QLatin1String("dc=example,dc=com");
+        s.ldapVersion = 3;
+        s.filter = QString();
+        s.pageSize = 10;
+        s.timeLimit = -1;
+        s.sizeLimit = 9999999;
+
+        testLdapServer(ispdb->ldapServers()[QLatin1String("ldap2.example.com")], s);
+    }
+
+    void testLdapCompleteFail()
+    {
+        QEventLoop loop;
+        TAutoconfLdap *ispdb = new TAutoconfLdap();
+
+        loop.connect(ispdb, SIGNAL(finished(bool)), SLOT(quit()));
+        connect(ispdb, SIGNAL(finished(bool)), SLOT(expectedReturn(bool)));
+
+        KUrl expected(QLatin1String("http://autoconfig.example.com/ldap/config-v1.0.xml"));
+        KUrl expected2(QLatin1String("http://example.com/.well-known/autoconfig/ldap/config-v1.0.xml"));
+
+        mReturn = false;
+        ispdb->setEmail(QLatin1String("john.doe at example.com"));
+        ispdb->expectedUrls.append(expected);
+        ispdb->expectedUrls.append(expected2);
+        ispdb->replace[expected] = QLatin1String("http://localhost:8000/500");
+        ispdb->replace[expected2] = QLatin1String("http://localhost:8000/404");
+        ispdb->start();
+        loop.exec();
+        QCOMPARE(ispdb->expectedUrls.count(), 0);
+    }
+
+    void testLdapLogin()
+    {
+        QDir dir(QLatin1String(AUTOCONFIG_DATA_DIR));
+        QString furl = QLatin1String("file://%1/ldap.xml");
+
+        QEventLoop loop;
+        TAutoconfLdap *ispdb = new TAutoconfLdap();
+
+        loop.connect(ispdb, SIGNAL(finished(bool)), SLOT(quit()));
+        connect(ispdb, SIGNAL(finished(bool)), SLOT(expectedReturn(bool)));
+
+        KUrl expected(QLatin1String("http://autoconfig.example.com/ldap/config-v1.0.xml"));
+        KUrl expected2(QLatin1String("https://john.doe%40example.com:xxx@autoconfig.example.com/ldap/config-v1.0.xml"));
+        KUrl expected3(QLatin1String("http://example.com/.well-known/autoconfig/ldap/config-v1.0.xml"));
+
+        mReturn = true;
+        ispdb->setEmail(QLatin1String("john.doe at example.com"));
+        ispdb->setPassword(QLatin1String("xxx"));
+        ispdb->expectedUrls.append(expected);
+        ispdb->expectedUrls.append(expected2);
+        ispdb->expectedUrls.append(expected3);
+        ispdb->replace[expected] = QLatin1String("http://localhost:8000/401");
+        ispdb->replace[expected2] = QLatin1String("http://localhost:8000/500");
+        ispdb->replace[expected3] = furl.arg(dir.path());
+        ispdb->start();
+        loop.exec();
+        QCOMPARE(ispdb->expectedUrls.count(), 0);
+    }
+
+    void expectedReturn(bool ret)
+    {
+        QCOMPARE(ret, mReturn);
+    }
+
+    void initTestCase()
+    {
+        QDir dir(QLatin1String(CURRENT_SOURCE_DIR));
+        QString furl = QLatin1String("%1/errorserver.py");
+        process.start(QLatin1String("python"), QStringList() << furl.arg(dir.path()));
+        process.waitForStarted();
+        QCOMPARE(process.state(), QProcess::Running);
+    }
+
+    void cleanupTestCase()
+    {
+        process.terminate();
+        process.waitForFinished();
+    }
+
+public:
+    bool mReturn;
+    QProcess process;
+};
+
+QTEST_KDEMAIN(AutoconfLdapTest, NoGUI)
+
+#include "autoconfigkolabldaptest.moc"
diff --git a/accountwizard/ispdb/tests/autoconfigkolabmailtest.cpp b/accountwizard/ispdb/tests/autoconfigkolabmailtest.cpp
new file mode 100644
index 0000000..bfe8250
--- /dev/null
+++ b/accountwizard/ispdb/tests/autoconfigkolabmailtest.cpp
@@ -0,0 +1,159 @@
+/*
+    Copyright (c) 2014 Sandro Knauß <knauss at kolabsys.com>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#include <QObject>
+#include <QDir>
+#include <QProcess>
+
+#include <qtest_kde.h>
+
+#include <KDebug>
+
+#include "../ispdb.h"
+#include "../autoconfigkolabmail.h"
+
+class TAutoconfMail : public AutoconfigKolabMail
+{
+public:
+    void startJob(const KUrl &url)
+    {
+        QCOMPARE(url, expectedUrls.takeFirst());
+        if (replace.contains(url)) {
+            AutoconfigKolabMail::startJob(replace[url]);
+        } else {
+            AutoconfigKolabMail::startJob(url);
+        }
+    }
+
+    QMap<KUrl, KUrl> replace;
+    QList<KUrl> expectedUrls;
+};
+
+class AutoconfMailTest : public QObject
+{
+    Q_OBJECT
+public:
+    TAutoconfMail *getAutoconf()
+    {
+        return new TAutoconfMail();
+    }
+
+    AutoconfigKolabMail *execIspdb(const QString &file)
+    {
+        QDir dir(QLatin1String(AUTOCONFIG_DATA_DIR));
+        QString furl = QLatin1String("file://%1/%2");
+
+        QEventLoop loop;
+        TAutoconfMail *ispdb = getAutoconf();
+
+        loop.connect(ispdb, SIGNAL(finished(bool)), SLOT(quit()));
+
+        KUrl url(furl.arg(dir.path()).arg(file));
+        ispdb->setEmail(QLatin1String("john.doe at example.com"));
+        ispdb->expectedUrls.append(url);
+        ispdb->startJob(url);
+
+        loop.exec();
+        return ispdb;
+    }
+
+private slots:
+    void testCompleteFail()
+    {
+        QEventLoop loop;
+        TAutoconfMail *ispdb = getAutoconf();
+
+        loop.connect(ispdb, SIGNAL(finished(bool)), SLOT(quit()));
+        connect(ispdb, SIGNAL(finished(bool)), SLOT(expectedReturn(bool)));
+
+        KUrl expected0(QLatin1String("https://autoconfig.thunderbird.net/v1.1/example.com"));
+        KUrl expected1(QLatin1String("http://autoconfig.example.com/mail/config-v1.1.xml"));
+        KUrl expected2(QLatin1String("http://example.com/.well-known/autoconfig/mail/config-v1.1.xml"));
+        mReturn = false;
+        ispdb->setEmail(QLatin1String("john.doe at example.com"));
+        ispdb->expectedUrls.append(expected0);
+        ispdb->expectedUrls.append(expected1);
+        ispdb->expectedUrls.append(expected2);
+        ispdb->replace[expected0] = QLatin1String("http://localhost:8000/500");
+        ispdb->replace[expected1] = QLatin1String("http://localhost:8000/500");
+        ispdb->replace[expected2] = QLatin1String("http://localhost:8000/404");
+        ispdb->start();
+        loop.exec();
+        QCOMPARE(ispdb->expectedUrls.count(), 0);
+    }
+
+    void testLogin()
+    {
+        QDir dir(QLatin1String(AUTOCONFIG_DATA_DIR));
+        QString furl = QLatin1String("file://%1/autoconfig.xml");
+
+        QEventLoop loop;
+        TAutoconfMail *ispdb = getAutoconf();
+
+        loop.connect(ispdb, SIGNAL(finished(bool)), SLOT(quit()));
+        connect(ispdb, SIGNAL(finished(bool)), SLOT(expectedReturn(bool)));
+
+        KUrl expected0(QLatin1String("https://autoconfig.thunderbird.net/v1.1/example.com"));
+        KUrl expected1(QLatin1String("http://autoconfig.example.com/mail/config-v1.1.xml"));
+        KUrl expected2(QLatin1String("https://john.doe%40example.com:xxx@autoconfig.example.com/mail/config-v1.1.xml"));
+        KUrl expected3(QLatin1String("http://example.com/.well-known/autoconfig/mail/config-v1.1.xml"));
+
+        mReturn = true;
+        ispdb->setEmail(QLatin1String("john.doe at example.com"));
+        ispdb->setPassword(QLatin1String("xxx"));
+        ispdb->expectedUrls.append(expected0);
+        ispdb->expectedUrls.append(expected1);
+        ispdb->expectedUrls.append(expected2);
+        ispdb->expectedUrls.append(expected3);
+        ispdb->replace[expected0] = QLatin1String("http://localhost:8000/500");
+        ispdb->replace[expected1] = QLatin1String("http://localhost:8000/401");
+        ispdb->replace[expected2] = QLatin1String("http://localhost:8000/500");
+        ispdb->replace[expected3] = furl.arg(dir.path());
+        ispdb->start();
+        loop.exec();
+        QCOMPARE(ispdb->expectedUrls.count(), 0);
+    }
+
+    void expectedReturn(bool ret)
+    {
+        QCOMPARE(ret, mReturn);
+    }
+
+    void initTestCase()
+    {
+        QDir dir(QLatin1String(CURRENT_SOURCE_DIR));
+        QString furl = QLatin1String("%1/errorserver.py");
+        process.start(QLatin1String("python"), QStringList() << furl.arg(dir.path()));
+        process.waitForStarted();
+        QCOMPARE(process.state(), QProcess::Running);
+    }
+
+    void cleanupTestCase()
+    {
+        process.terminate();
+        process.waitForFinished();
+    }
+public:
+    bool mReturn;
+    QProcess process;
+};
+
+QTEST_KDEMAIN(AutoconfMailTest, NoGUI)
+
+#include "autoconfigkolabmailtest.moc"
diff --git a/accountwizard/ispdb/tests/data/autoconfig.xml b/accountwizard/ispdb/tests/data/autoconfig.xml
new file mode 100644
index 0000000..399c160
--- /dev/null
+++ b/accountwizard/ispdb/tests/data/autoconfig.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<clientConfig version="1.1">
+	<emailProvider id="example.com">
+		<domain>example.com</domain>
+		<displayName>Example Mail</displayName>
+		<displayShortName>Example</displayShortName>
+		<incomingServer type="imap">
+			<hostname>imap.example.com</hostname>
+			<port>993</port>
+			<socketType>SSL</socketType>
+			<authentication>password-encrypted</authentication>
+			<username>%EMAILADDRESS%</username>
+		</incomingServer>
+		<outgoingServer type="smtp">
+			<hostname>smtp.example.com</hostname>
+			<port>25</port>
+			<socketType>plain</socketType>
+			<authentication>plain</authentication>
+			<username>%EMAILLOCALPART%</username>
+		</outgoingServer>
+		<incomingServer type="pop3">
+			<hostname>pop.example.com</hostname>
+			<port>995</port>
+			<socketType>STARTTLS</socketType>
+			<authentication>NTLM</authentication>
+			<username>%EMAILDOMAIN%</username>
+		</incomingServer>
+
+		<identity id="john.doe at example.com" type="kolab" version="1.0">
+			<default>true</default>
+			<email>john.doe at example.com</email>
+			<name>John Doe</name>
+			<organization>Example AG</organization>
+			<signature>John Doe
+Head of World
+
+Example AG
+
+w: <a href="http://example.com">http://example.com</a></signature>
+		</identity>
+	</emailProvider>
+	<emailProvider />
+</clientConfig>
diff --git a/accountwizard/ispdb/tests/data/freebusy.xml b/accountwizard/ispdb/tests/data/freebusy.xml
new file mode 100644
index 0000000..bd9247a
--- /dev/null
+++ b/accountwizard/ispdb/tests/data/freebusy.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0"?>
+<clientConfig version="1.0">
+    <freebusyProvider id="freebusy.example.com">
+        <hostname>example.com</hostname>
+        <!--
+        "plain":
+            No encryption
+        "TLS":
+            Using TLS to connect server
+        "SSL":
+            Using SSL to connect to server -->
+        <socketType>plain</socketType>
+        <!--
+        "none":
+            No authentication
+        "basic":
+            Use simple authentication -->
+        <authentication>basic</authentication>
+        <username>user</username>
+        <password>pass</password>
+        <!-- path to the ifb file:
+        $EMAIL$:
+            will be replaced with the email for that a ifb is requested
+        $USER$:
+            will be replaced with the username of the ifb that is requested
+            -->
+        <path>/freebusy/$EMAIL$.ifb</path>
+</freebusyProvider>
+</clientConfig>
diff --git a/accountwizard/ispdb/tests/data/ldap.xml b/accountwizard/ispdb/tests/data/ldap.xml
new file mode 100644
index 0000000..c93ba53
--- /dev/null
+++ b/accountwizard/ispdb/tests/data/ldap.xml
@@ -0,0 +1,67 @@
+<?xml version="1.0"?>
+<clientConfig version="1.0">
+    <ldapProvider id="ldap.example.com">
+        <hostname>ldap.example.com</hostname>
+        <port>389</port>
+        <!--
+        "plain":
+            No encryption
+        "TLS":
+            Using TLS to connect server
+        "SSL":
+            Using SSL to connect to server -->
+        <socketType>plain</socketType>
+        <!--
+        "anonyoum":
+            Use anonyoum authentification
+        "simple":
+            Use simple authentification
+        "sasl":
+            Use sasl authentification -->
+        <authentication>simple</authentication>
+
+        <!-- not used for anoyoum authentification -->
+        <bindDn>cn=Directory Manager</bindDn>
+
+        <!-- not used for anoyoum authentification -->
+        <password>Welcome2KolabSystems</password>
+
+        <!-- sasl-mech is the SASL mechanism to login for SASL authentification -->
+        <sasl-mech />
+        <!-- only used for SASL -->
+        <username />
+        <!-- only used for SASL -->
+        <realm />
+
+        <!-- BaseDN (namingcontexts) of the ldapServer -->
+        <dn>dc=kolabsys,dc=com</dn>
+
+        <ldapVersion>3</ldapVersion>
+        <filter/>
+        <!-- value 1-9999999 (not setting is using default) -->
+        <pagesize />
+        <!-- value 1-9999999 (not setting is using default) -->
+        <timelimit />
+        <!-- value 1-9999999 (not setting is using default) -->
+        <sizelimit />
+    </ldapProvider>
+    <ldapProvider id="ldap2.example.com">
+        <hostname>ldap2.example.com</hostname>
+        <port>387</port>
+        <socketType>SSL</socketType>
+        <authentication>sasl</authentication>
+        <bindDn>cn=Directory</bindDn>
+        <password>Welcome2KolabSystems</password>
+        <sasl-mech>XXX</sasl-mech>
+        <username>john.doe</username>
+        <realm>realm.example.com</realm>
+        <dn>dc=example,dc=com</dn>
+        <ldapVersion>3</ldapVersion>
+        <pagesize>10</pagesize>
+        <timelimit>10000000</timelimit>
+        <sizelimit>9999999</sizelimit>
+    </ldapProvider>
+
+
+</clientConfig>
+
diff --git a/accountwizard/ispdb/tests/errorserver.py b/accountwizard/ispdb/tests/errorserver.py
new file mode 100644
index 0000000..41f9f16
--- /dev/null
+++ b/accountwizard/ispdb/tests/errorserver.py
@@ -0,0 +1,18 @@
+import BaseHTTPServer
+import os.path
+
+class ErrorServer(BaseHTTPServer.BaseHTTPRequestHandler):
+    '''a simple server that always anwsers with the corresponding error code:
+    /500 -> error 500
+    '''
+    def do_GET(self):
+        self.send_response(int(os.path.basename(self.path)))
+
+def run(server_class=BaseHTTPServer.HTTPServer,
+        handler_class=ErrorServer):
+    global keep_running
+    server_address = ('localhost', 8000)
+    httpd = server_class(server_address, handler_class)
+    httpd.serve_forever()
+
+run()
diff --git a/accountwizard/ispdb/tests/ispdbtest.cpp b/accountwizard/ispdb/tests/ispdbtest.cpp
new file mode 100644
index 0000000..3c39169
--- /dev/null
+++ b/accountwizard/ispdb/tests/ispdbtest.cpp
@@ -0,0 +1,132 @@
+/*
+    Copyright (c) 2014 Sandro Knauß <knauss at kolabsys.com>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#include <QObject>
+#include <QDir>
+#include <qtest_kde.h>
+
+#include <KDebug>
+
+#include "../ispdb.h"
+
+class TIspdb : public Ispdb
+{
+public:
+    void start(const KUrl &url)
+    {
+        setServerType(Ispdb::IspWellKnow);
+        startJob(url);
+    }
+};
+
+class IspdbTest : public QObject
+{
+    Q_OBJECT
+public:
+    Ispdb *execIspdb(const QString &file)
+    {
+        QDir dir(QLatin1String(AUTOCONFIG_DATA_DIR));
+        QString furl = QLatin1String("file://%1/%2");
+
+        QEventLoop loop;
+        TIspdb *ispdb = new TIspdb();
+
+        loop.connect(ispdb, SIGNAL(finished(bool)), SLOT(quit()));
+
+        KUrl url(furl.arg(dir.path()).arg(file));
+        ispdb->setEmail(QLatin1String("john.doe at example.com"));
+        ispdb->start(url);
+
+        loop.exec();
+        return ispdb;
+    }
+
+    void testServer(const server &test, const server &expected) const
+    {
+        QVERIFY(test.isValid());
+        QCOMPARE(test.hostname, expected.hostname);
+        QCOMPARE(test.port, expected.port);
+        QCOMPARE(test.socketType, expected.socketType);
+        QCOMPARE(test.username, expected.username);
+        QCOMPARE(test.authentication, expected.authentication);
+    }
+
+    void testIdendity(const identity &test, const identity &expected) const
+    {
+        QVERIFY(test.isValid());
+        QCOMPARE(test.name, expected.name);
+        QCOMPARE(test.email, expected.email);
+        QCOMPARE(test.organization, expected.organization);
+        QCOMPARE(test.signature, expected.signature);
+        QCOMPARE(test.isDefault(), expected.isDefault());
+    }
+
+private slots:
+    void testParsing()
+    {
+        Ispdb *ispdb = execIspdb(QLatin1String("autoconfig.xml"));
+
+        server s;
+        identity i;
+
+        s.hostname = QLatin1String("imap.example.com");
+        s.port = 993;
+        s.socketType = Ispdb::SSL;
+        s.authentication = Ispdb::CramMD5;
+        s.username = QLatin1String("john.doe at example.com");
+
+        QCOMPARE(ispdb->imapServers().count(), 1);
+        testServer(ispdb->imapServers().first(), s);
+
+        s.hostname = QLatin1String("smtp.example.com");
+        s.port = 25;
+        s.socketType = Ispdb::None;
+        s.authentication = Ispdb::Plain;
+        s.username = QLatin1String("john.doe");
+        QCOMPARE(ispdb->smtpServers().count(), 1);
+        testServer(ispdb->smtpServers().first(), s);
+
+        s.hostname = QLatin1String("pop.example.com");
+        s.port = 995;
+        s.socketType = Ispdb::StartTLS;
+        s.authentication = Ispdb::NTLM;
+        s.username = QLatin1String("example.com");
+        QCOMPARE(ispdb->pop3Servers().count(), 1);
+        testServer(ispdb->pop3Servers().first(), s);
+
+        i.mDefault = true;
+        i.name = QLatin1String("John Doe");
+        i.email = QLatin1String("john.doe at example.com");
+        i.organization = QLatin1String("Example AG");
+        i.signature = QLatin1String("John Doe\n\
+Head of World\n\
+\n\
+Example AG\n\
+\n\
+w: <a href=\"http://example.com\">http://example.com</a>");
+
+        QCOMPARE(ispdb->identities().count(), 1);
+        testIdendity(ispdb->identities().first(), i);
+        QCOMPARE(ispdb->defaultIdentity(), 0);
+    }
+};
+
+QTEST_KDEMAIN(IspdbTest, NoGUI)
+
+#include "ispdbtest.moc"
diff --git a/accountwizard/ldap.cpp b/accountwizard/ldap.cpp
new file mode 100644
index 0000000..ac4080f
--- /dev/null
+++ b/accountwizard/ldap.cpp
@@ -0,0 +1,195 @@
+/*
+    Copyright (c) 2010 Laurent Montel <montel at kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#include "ldap.h"
+
+#include <KConfig>
+#include <KConfigGroup>
+#include <KLocalizedString>
+
+
+Ldap::Ldap( QObject *parent )
+  : SetupObject( parent )
+  , m_port(389)
+  , m_security(KLDAP::LdapServer::None)
+  , m_version(3)
+  , m_pageSize(0)
+  , m_timeLimit(0)
+  , m_sizeLimit(0)
+{
+}
+
+Ldap::~Ldap()
+{
+}
+
+void Ldap::create()
+{
+  emit info( i18n( "Setting up LDAP server..." ) );
+
+  if ( m_server.isEmpty() || m_user.isEmpty() )
+    return;
+
+  const QString host = m_server;
+
+  // Figure out the basedn
+  QString basedn = host;
+  // If the user gave a full email address, the domain name
+  // of that overrides the server name for the ldap dn
+  const QString user = m_user;
+  int pos = user.indexOf( QLatin1String("@") );
+  if ( pos > 0 ) {
+    const QString h = user.mid( pos+1 );
+    if ( !h.isEmpty() )
+      // The user did type in a domain on the email address. Use that
+      basedn = h;
+  }
+  { // while we're here, write default domain
+    KConfig c( QLatin1String("kmail2rc") );
+    KConfigGroup group = c.group( "General" );
+    group.writeEntry( "Default domain", basedn );
+  }
+
+  basedn.replace( QLatin1Char('.'), QLatin1String(",dc=") );
+  basedn.prepend( QLatin1String("dc=") );
+
+  // Set the changes
+  KConfig c( QLatin1String("kabldaprc") );
+  KConfigGroup group = c.group( "LDAP" );
+  bool hasMyServer = false;
+  uint selHosts = group.readEntry( "NumSelectedHosts", 0 );
+  for ( uint i = 0 ; i < selHosts && !hasMyServer; ++i )
+    if ( group.readEntry( QString::fromLatin1( "SelectedHost%1" ).arg( i ), QString() ) == host )
+      hasMyServer = true;
+  if ( !hasMyServer ) {
+    group.writeEntry( "NumSelectedHosts", selHosts + 1 );
+    group.writeEntry( QString::fromLatin1( "SelectedHost%1" ).arg( selHosts ), host );
+    group.writeEntry( QString::fromLatin1( "SelectedBase%1" ).arg( selHosts ), basedn );
+    group.writeEntry( QString::fromLatin1( "SelectedPort%1" ).arg( selHosts ), m_port );
+    group.writeEntry( QString::fromLatin1( "SelectedVersion%1" ).arg( selHosts ), m_version );
+    group.writeEntry( QString::fromLatin1( "SelectedSecurity%1" ).arg( selHosts ), securityString() );
+
+    if (m_pageSize > 0) {
+        group.writeEntry( QString::fromLatin1( "SelectedPageSize%1" ).arg( selHosts ), m_pageSize );
+    }
+
+    if (m_timeLimit > 0) {
+        group.writeEntry( QString::fromLatin1( "SelectedTimeLimit%1" ).arg( selHosts ), m_timeLimit );
+    }
+
+    if (m_sizeLimit > 0) {
+        group.writeEntry( QString::fromLatin1( "SelectedSizeLimit%1" ).arg( selHosts ), m_sizeLimit );
+    }
+
+    if ( !m_authMethod.isEmpty() ) {
+      group.writeEntry( QString::fromLatin1( "SelectedAuth%1" ).arg( selHosts ), m_authMethod );
+      group.writeEntry( QString::fromLatin1( "SelectedBind%1" ).arg( selHosts ), m_bindDn );
+      group.writeEntry( QString::fromLatin1( "SelectedPwdBind%1" ).arg( selHosts ), m_password );
+      group.writeEntry( QString::fromLatin1( "SelectedRealm%1" ).arg( selHosts ), m_realm );
+      group.writeEntry( QString::fromLatin1( "SelectedUser%1" ).arg( selHosts ), m_user );
+      group.writeEntry( QString::fromLatin1( "SelectedMech%1" ).arg( selHosts ), m_mech );
+    }
+  }
+  emit finished( i18n( "LDAP set up." ) );
+}
+
+QString Ldap::securityString()
+{
+    if (m_security == KLDAP::LdapServer::None) {
+        return QLatin1String("None");
+    } else if (m_security == KLDAP::LdapServer::SSL) {
+        return QLatin1String("SSL");
+    } else if (m_security == KLDAP::LdapServer::TLS) {
+        return QLatin1String("TLS");
+    }
+    return QLatin1String("");
+}
+
+
+void Ldap::destroy()
+{
+  emit info( i18n( "LDAP not configuring." ) );
+}
+
+void Ldap::setUser( const QString &user )
+{
+  m_user = user;
+}
+
+void Ldap::setServer( const QString &server )
+{
+  m_server = server;
+}
+
+void Ldap::setAuthenticationMethod(const QString& meth)
+{
+  m_authMethod = meth;
+}
+
+void Ldap::setBindDn(const QString& bindDn)
+{
+  m_bindDn = bindDn;
+}
+
+void Ldap::setPassword(const QString& password)
+{
+  m_password = password;
+}
+
+
+void Ldap::setPageSize(const int pageSize)
+{
+    m_pageSize = pageSize;
+}
+
+void Ldap::setPort(const int port)
+{
+    m_port = port;
+}
+
+void Ldap::setRealm(const QString &realm)
+{
+    m_realm = realm;
+}
+
+void Ldap::setSaslMech(const QString &saslmech)
+{
+    m_mech = saslmech;
+}
+
+void Ldap::setSecurity(const KLDAP::LdapServer::Security security)
+{
+    m_security = security;
+}
+
+void Ldap::setSizeLimit(const int sizeLimit)
+{
+    m_sizeLimit = sizeLimit;
+}
+
+void Ldap::setTimeLimit(const int timeLimit)
+{
+    m_timeLimit = timeLimit;
+}
+
+void Ldap::setVersion(const int version)
+{
+    m_version = version;
+}
+
diff --git a/accountwizard/ldap.h b/accountwizard/ldap.h
new file mode 100644
index 0000000..4162f72
--- /dev/null
+++ b/accountwizard/ldap.h
@@ -0,0 +1,67 @@
+/*
+    Copyright (c) 2010 Laurent Montel <montel at kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef LDAP_H
+#define LDAP_H
+
+#include "setupobject.h"
+#include <KLDAP/LdapServer>
+
+class Ldap : public SetupObject
+{
+  Q_OBJECT
+  public:
+    explicit Ldap( QObject *parent = 0 );
+    ~Ldap();
+    void create();
+    void destroy();
+  public slots:
+    Q_SCRIPTABLE void setUser( const QString & name );
+    Q_SCRIPTABLE void setServer( const QString &server );
+    Q_SCRIPTABLE void setAuthenticationMethod( const QString &meth );
+    Q_SCRIPTABLE void setBindDn( const QString &bindDn );
+    Q_SCRIPTABLE void setPassword( const QString &password );
+    Q_SCRIPTABLE void setPort(const int port);
+    Q_SCRIPTABLE void setSecurity(const KLDAP::LdapServer::Security security);
+    Q_SCRIPTABLE void setSaslMech(const QString &saslmech);
+    Q_SCRIPTABLE void setRealm(const QString &realm);
+    Q_SCRIPTABLE void setVersion(const int version);
+    Q_SCRIPTABLE void setPageSize(const int pageSize);
+    Q_SCRIPTABLE void setTimeLimit(const int timeLimit);
+    Q_SCRIPTABLE void setSizeLimit(const int sizeLimit);
+
+  private:
+    QString securityString();
+
+    QString m_user;
+    QString m_server;
+    QString m_bindDn;
+    QString m_authMethod;
+    QString m_password;
+    int m_port;
+    KLDAP::LdapServer::Security m_security;
+    QString m_mech;
+    QString m_realm;
+    int m_version;
+    int m_pageSize;
+    int m_timeLimit;
+    int m_sizeLimit;
+};
+
+#endif
diff --git a/accountwizard/loadpage.cpp b/accountwizard/loadpage.cpp
new file mode 100644
index 0000000..fa763b0
--- /dev/null
+++ b/accountwizard/loadpage.cpp
@@ -0,0 +1,88 @@
+/*
+    Copyright (c) 2009 Volker Krause <vkrause at kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#include "loadpage.h"
+#include "global.h"
+#include <kassistantdialog.h>
+#include <kconfig.h>
+#include <kconfiggroup.h>
+#include <kross/core/action.h>
+#include <QtCore/qfile.h>
+
+LoadPage::LoadPage(KAssistantDialog* parent) :
+  Page( parent ),
+  m_action( 0 )
+{
+  ui.setupUi( this );
+  setValid( false );
+}
+
+void LoadPage::enterPageNext()
+{
+  setValid( false );
+  // FIXME: deletion seems to delete the exported objects as well, killing the entire wizard...
+  //delete m_action;
+  m_action = 0;
+  emit aboutToStart();
+
+  const KConfig f( Global::assistant() );
+  KConfigGroup grp( &f, "Wizard" );
+  const QString scriptFile = grp.readEntry( "Script", QString() );
+  if ( scriptFile.isEmpty() ) {
+    ui.statusLabel->setText( i18n( "No script specified in '%1'.", Global::assistant() ) );
+    return;
+  }
+  if ( !QFile::exists( Global::assistantBasePath() + scriptFile ) ) {
+    ui.statusLabel->setText( i18n( "Unable to load assistant: File '%1' does not exist.", Global::assistantBasePath() + scriptFile ) );
+    return;
+  }
+  ui.statusLabel->setText( i18n( "Loading script '%1'...", Global::assistantBasePath() + scriptFile ) );
+
+  m_action = new Kross::Action( this, QLatin1String("AccountWizard") );
+  typedef QPair<QObject*, QString> ObjectStringPair;
+  foreach ( const ObjectStringPair &exportedObject, m_exportedObjects )
+    m_action->addQObject( exportedObject.first, exportedObject.second );
+
+  if ( !m_action->setFile( Global::assistantBasePath() + scriptFile ) ) {
+    ui.statusLabel->setText( i18n( "Failed to load script: '%1'.", m_action->errorMessage() ) );
+    return;
+  }
+
+  KConfigGroup grpTranslate( &f, "Translate" );
+  const QString poFileName = grpTranslate.readEntry( "Filename" );
+  if ( !poFileName.isEmpty() )
+    KGlobal::locale()->insertCatalog( poFileName );
+
+  m_action->trigger();
+
+  m_parent->next();
+}
+
+void LoadPage::enterPageBack()
+{
+  // TODO: if we are the first page, call enterPageNext(), hm, can we get here then at all?
+  m_parent->back();
+}
+
+void LoadPage::exportObject(QObject* object, const QString& name)
+{
+  m_exportedObjects.push_back( qMakePair( object, name ) );
+}
+
+
diff --git a/accountwizard/loadpage.h b/accountwizard/loadpage.h
new file mode 100644
index 0000000..a53f9e2
--- /dev/null
+++ b/accountwizard/loadpage.h
@@ -0,0 +1,51 @@
+/*
+    Copyright (c) 2009 Volker Krause <vkrause at kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef LOADPAGE_H
+#define LOADPAGE_H
+
+#include "page.h"
+
+#include "ui_loadpage.h"
+
+namespace Kross {
+class Action;
+}
+
+class LoadPage : public Page
+{
+  Q_OBJECT
+  public:
+    explicit LoadPage( KAssistantDialog *parent );
+
+    virtual void enterPageNext();
+    virtual void enterPageBack();
+
+    void exportObject( QObject *object, const QString &name );
+
+  Q_SIGNALS:
+    void aboutToStart();
+
+  private:
+    Ui::LoadPage ui;
+    QVector< QPair< QObject*, QString > > m_exportedObjects;
+    Kross::Action* m_action;
+};
+
+#endif
diff --git a/accountwizard/main.cpp b/accountwizard/main.cpp
new file mode 100644
index 0000000..c091a10
--- /dev/null
+++ b/accountwizard/main.cpp
@@ -0,0 +1,81 @@
+/*
+    Copyright (c) 2009 Volker Krause <vkrause at kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#include "dialog.h"
+#include "global.h"
+
+#include <akonadi/control.h>
+
+#include <kaboutdata.h>
+#include <kapplication.h>
+#include <kcmdlineargs.h>
+#include <kglobal.h>
+#include <KUniqueApplication>
+
+
+#include <stdio.h>
+
+int main( int argc, char **argv )
+{
+  KAboutData aboutData( "accountwizard", 0,
+                        ki18n( "Account Assistant" ),
+                        "0.1",
+                        ki18n( "Helps setting up PIM accounts" ),
+                        KAboutData::License_LGPL,
+                        ki18n( "(c) 2009 the Akonadi developers" ),
+                        KLocalizedString(),
+                        "http://pim.kde.org/akonadi/" );
+  aboutData.setProgramIconName( QLatin1String("akonadi") );
+  aboutData.addAuthor( ki18n( "Volker Krause" ),  ki18n( "Author" ), "vkrause at kde.org" );
+  aboutData.addAuthor( ki18n( "Laurent Montel" ), KLocalizedString() , "montel at kde.org" );
+
+  KCmdLineArgs::init( argc, argv, &aboutData );
+
+  KCmdLineOptions options;
+  options.add( "type <type>", ki18n( "Only offer accounts that support the given type." ) );
+  options.add( "assistant <assistant>", ki18n( "Run the specified assistant." ) );
+  options.add( "package <fullpath>", ki18n( "unpack fullpath on startup and launch that assistant" ) );
+  KCmdLineArgs::addCmdLineOptions( options );
+  KUniqueApplication::addCmdLineOptions();
+
+  if ( !KUniqueApplication::start() ) {
+      fprintf( stderr, "accountwizard is already running!\n" );
+      exit( 0 );
+  }
+
+  KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+
+  KUniqueApplication app;
+  KGlobal::locale()->insertCatalog( QLatin1String("libakonadi") );
+
+  Akonadi::Control::start( 0 );
+
+  if ( !args->getOption( "package" ).isEmpty() ) {
+    Global::setAssistant( Global::unpackAssistant( KUrl( args->getOption( "package" ) ) ) );
+  } else
+    Global::setAssistant( args->getOption( "assistant" ) );
+
+  if ( !args->getOption( "type" ).isEmpty() )
+     Global::setTypeFilter( args->getOption( "type" ).split( QLatin1Char(',') ) );
+  args->clear();
+  Dialog dlg( 0/*, Qt::WindowStaysOnTopHint*/ );
+  dlg.show();
+
+  return app.exec();
+}
diff --git a/accountwizard/page.cpp b/accountwizard/page.cpp
new file mode 100644
index 0000000..78437d9
--- /dev/null
+++ b/accountwizard/page.cpp
@@ -0,0 +1,60 @@
+/*
+    Copyright (c) 2009 Volker Krause <vkrause at kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#include "page.h"
+#include <kpagewidgetmodel.h>
+#include <kassistantdialog.h>
+
+Page::Page(KAssistantDialog* parent):
+  QWidget(parent),
+  m_item( 0 ),
+  m_parent( parent ),
+  m_valid( false )
+{
+}
+
+
+void Page::setPageWidgetItem(KPageWidgetItem* item)
+{
+  m_item = item;
+  m_parent->setValid( m_item, m_valid );
+}
+
+
+void Page::setValid(bool valid)
+{
+  if ( !m_item )
+    m_valid = valid;
+  else
+    m_parent->setValid( m_item, valid );
+}
+
+void Page::nextPage()
+{
+  m_parent->next();
+}
+
+void Page::enterPageBack() {}
+void Page::enterPageNext() {}
+void Page::leavePageBack() {}
+void Page::leavePageNext() {}
+
+void Page::leavePageBackRequested() { emit leavePageBackOk(); }
+void Page::leavePageNextRequested() { emit leavePageNextOk(); }
+
diff --git a/accountwizard/page.h b/accountwizard/page.h
new file mode 100644
index 0000000..1d229f0
--- /dev/null
+++ b/accountwizard/page.h
@@ -0,0 +1,64 @@
+/*
+    Copyright (c) 2009 Volker Krause <vkrause at kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef PAGE_H
+#define PAGE_H
+
+#include <QtGui/QWidget>
+
+class KAssistantDialog;
+class KPageWidgetItem;
+
+class Page : public QWidget
+{
+  Q_OBJECT
+  public:
+    explicit Page( KAssistantDialog *parent );
+
+    void setPageWidgetItem( KPageWidgetItem *item );
+
+    virtual void enterPageNext();
+    virtual void enterPageBack();
+    virtual void leavePageNext();
+    virtual void leavePageBack();
+    virtual void leavePageNextRequested();
+    virtual void leavePageBackRequested();
+
+  signals:
+    Q_SCRIPTABLE void pageEnteredNext();
+    Q_SCRIPTABLE void pageEnteredBack();
+    Q_SCRIPTABLE void pageLeftNext();
+    Q_SCRIPTABLE void pageLeftBack();
+    Q_SCRIPTABLE void leavePageNextOk();
+    Q_SCRIPTABLE void leavePageBackOk();
+
+  public slots:
+    Q_SCRIPTABLE void setValid( bool valid );
+    Q_SCRIPTABLE void nextPage();
+
+  protected:
+    KPageWidgetItem *m_item;
+    KAssistantDialog *m_parent;
+
+  private:
+    friend class Dialog;
+    bool m_valid;
+};
+
+#endif // PAGE_H
diff --git a/accountwizard/personaldatapage.cpp b/accountwizard/personaldatapage.cpp
new file mode 100644
index 0000000..e7cde5c
--- /dev/null
+++ b/accountwizard/personaldatapage.cpp
@@ -0,0 +1,278 @@
+/*
+    Copyright (c) 2009 Volker Krause <vkrause at kde.org>
+    Copyright (c) 2010 Tom Albers <toma at kde.org>
+    Copyright (c) 2012 Laurent Montel <montel at kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#include "personaldatapage.h"
+
+#include "config-enterprise.h"
+#include "global.h"
+#include "dialog.h"
+#include "transport.h"
+#include "resource.h"
+#include "ispdb/ispdb.h"
+
+#include <kpimutils/emailvalidator.h>
+#include <kpimutils/email.h>
+
+#include <mailtransport/transport.h>
+
+#include <KDebug>
+
+
+QString accountName(Ispdb *ispdb, QString username)
+{
+  const int pos(username.indexOf(QLatin1Char('@')));
+  username = username.left(pos);
+  return ispdb->name( Ispdb::Long ) + QString::fromLatin1(" (%1)").arg(username);
+}
+
+PersonalDataPage::PersonalDataPage(Dialog* parent) :
+  Page( parent ), mIspdb( 0 ), mSetupManager( parent->setupManager() )
+{
+  QWidget *pageParent = this;
+
+  ui.setupUi( pageParent );
+
+  KPIMUtils::EmailValidator* emailValidator = new KPIMUtils::EmailValidator( this );
+  ui.emailEdit->setValidator( emailValidator );
+
+  // KEmailSettings defaults
+  ui.nameEdit->setText( mSetupManager->name() );
+  ui.emailEdit->setText( mSetupManager->email() );
+  slotTextChanged();
+  connect( ui.emailEdit, SIGNAL(textChanged(QString)), SLOT(slotTextChanged()) );
+  connect( ui.nameEdit, SIGNAL(textChanged(QString)), SLOT(slotTextChanged()) );
+  connect( ui.createAccountPb, SIGNAL(clicked()), SLOT(slotCreateAccountClicked()) );
+  connect( ui.buttonGroup, SIGNAL(buttonClicked(QAbstractButton*)), SLOT(slotRadioButtonClicked(QAbstractButton*)) );
+#ifdef KDEPIM_ENTERPRISE_BUILD
+  ui.checkOnlineGroupBox->setChecked( false );
+#endif
+}
+
+void PersonalDataPage::setHideOptionInternetSearch( bool hide )
+{
+  ui.checkOnlineGroupBox->setChecked( !hide );
+  ui.checkOnlineGroupBox->setVisible( !hide );
+}
+
+void PersonalDataPage::slotRadioButtonClicked( QAbstractButton* button)
+{
+  QString smptHostname;
+  if ( !mIspdb->smtpServers().isEmpty() ) {
+    server s = mIspdb->smtpServers().first();
+    smptHostname = s.hostname;
+  }
+  ui.outgoingLabel->setText( i18n( "SMTP, %1", smptHostname ) );
+  if ( button ==  ui.imapAccount ) {
+    server simap = mIspdb->imapServers().first(); // should be ok.
+    ui.incommingLabel->setText( i18n( "IMAP, %1", simap.hostname ) );
+    ui.usernameLabel->setText( simap.username );
+  } else if ( button == ui.pop3Account ) {
+    server spop3 = mIspdb->pop3Servers().first(); // should be ok.
+    ui.incommingLabel->setText( i18n( "POP3, %1", spop3.hostname ) );
+    ui.usernameLabel->setText( spop3.username );
+  }
+}
+
+void PersonalDataPage::slotCreateAccountClicked()
+{
+  configureSmtpAccount();
+  if ( ui.imapAccount->isChecked() )
+    configureImapAccount();
+  else
+    configurePop3Account();
+  emit leavePageNextOk();  // go to the next page
+  mSetupManager->execute();
+}
+
+void PersonalDataPage::slotTextChanged()
+{
+  // Ignore the password field, as that can be empty when auth is based on ip-address.
+  setValid( !ui.emailEdit->text().isEmpty() &&
+            !ui.nameEdit->text().isEmpty()  &&
+            KPIMUtils::isValidSimpleAddress( ui.emailEdit->text() ) );
+}
+
+void PersonalDataPage::leavePageNext()
+{
+  ui.stackedPage->setCurrentIndex( 0 );
+  ui.imapAccount->setChecked( true );
+  mSetupManager->setPersonalDataAvailable( true );
+  mSetupManager->setName( ui.nameEdit->text() );
+  mSetupManager->setPassword( ui.passwordEdit->text() );
+  mSetupManager->setEmail( ui.emailEdit->text().trimmed() );
+
+  if ( ui.checkOnlineGroupBox->isChecked() ) {
+    // since the user can go back and forth, explicitly disable the man page
+    emit manualWanted( false );
+    setCursor( Qt::BusyCursor );
+    ui.mProgress->start();
+    kDebug() << "Searching on internet";
+    delete mIspdb;
+    mIspdb = new Ispdb( this );
+    connect(mIspdb, SIGNAL(searchType(QString)), this, SLOT(slotSearchType(QString)));
+    mIspdb->setEmail( ui.emailEdit->text() );
+    mIspdb->start();
+
+    connect( mIspdb, SIGNAL(finished(bool)),
+             SLOT(ispdbSearchFinished(bool)) );
+  } else {
+    emit manualWanted( true );     // enable the manual page
+    emit leavePageNextOk();  // go to the next page
+  }
+}
+
+void PersonalDataPage::ispdbSearchFinished( bool ok )
+{
+  kDebug() << ok;
+
+  unsetCursor();
+  ui.mProgress->stop();
+  if ( ok ) {
+
+    if ( !mIspdb->imapServers().isEmpty() && !mIspdb->pop3Servers().isEmpty() )
+    {
+      ui.stackedPage->setCurrentIndex( 1 );
+      slotRadioButtonClicked( ui.imapAccount );
+    }
+    else
+      automaticConfigureAccount();
+
+  } else {
+    emit manualWanted( true );     // enable the manual page
+    emit leavePageNextOk();
+  }
+}
+
+void PersonalDataPage::slotSearchType(const QString &type)
+{
+    ui.mProgress->setActiveLabel(type);
+}
+
+void PersonalDataPage::configureSmtpAccount()
+{
+  if ( !mIspdb->smtpServers().isEmpty() ) {
+    server s = mIspdb->smtpServers().first(); // should be ok.
+    kDebug() << "Configuring transport for" << s.hostname;
+
+    QObject* object = mSetupManager->createTransport( QLatin1String("smtp") );
+    Transport* t = qobject_cast<Transport*>( object );
+    t->setName( accountName(mIspdb,s.username) );
+    t->setHost( s.hostname );
+    t->setPort( s.port );
+    t->setUsername( s.username );
+    t->setPassword( ui.passwordEdit->text() );
+    switch ( s.authentication ) {
+    case Ispdb::Plain: t->setAuthenticationType( QLatin1String("plain") ); break;
+    case Ispdb::CramMD5: t->setAuthenticationType( QLatin1String("cram-md5") ); break;
+    case Ispdb::NTLM: t->setAuthenticationType( QLatin1String("ntlm") ); break;
+    case Ispdb::GSSAPI: t->setAuthenticationType( QLatin1String("gssapi") ); break;
+    case Ispdb::ClientIP: break;
+    case Ispdb::NoAuth: break;
+    default: break;
+    }
+    switch ( s.socketType ) {
+    case Ispdb::Plain: t->setEncryption( QLatin1String("none") );break;
+    case Ispdb::SSL: t->setEncryption( QLatin1String("ssl") );break;
+    case Ispdb::StartTLS: t->setEncryption( QLatin1String("tls") );break;
+    default: break;
+    }
+  } else
+    kDebug() << "No transport to be created....";
+}
+
+void PersonalDataPage::configureImapAccount()
+{
+  if ( !mIspdb->imapServers().isEmpty() ) {
+    server s = mIspdb->imapServers().first(); // should be ok.
+    kDebug() << "Configuring imap for" << s.hostname;
+
+    QObject* object = mSetupManager->createResource( QLatin1String("akonadi_imap_resource") );
+    Resource* t = qobject_cast<Resource*>( object );
+    t->setName( accountName(mIspdb,s.username) );
+    t->setOption( QLatin1String("ImapServer"), s.hostname );
+    t->setOption( QLatin1String("ImapPort"), s.port );
+    t->setOption( QLatin1String("UserName"), s.username );
+    t->setOption( QLatin1String("Password"), ui.passwordEdit->text() );
+    switch ( s.authentication ) {
+    case Ispdb::Plain: t->setOption( QLatin1String("Authentication"), MailTransport::Transport::EnumAuthenticationType::CLEAR ); break;
+    case Ispdb::CramMD5: t->setOption( QLatin1String("Authentication"), MailTransport::Transport::EnumAuthenticationType::CRAM_MD5 ); break;
+    case Ispdb::NTLM: t->setOption( QLatin1String("Authentication"), MailTransport::Transport::EnumAuthenticationType::NTLM ); break;
+    case Ispdb::GSSAPI: t->setOption( QLatin1String("Authentication"), MailTransport::Transport::EnumAuthenticationType::GSSAPI ); break;
+    case Ispdb::ClientIP: break;
+    case Ispdb::NoAuth: break;
+    default: break;
+    }
+    switch ( s.socketType ) {
+    case Ispdb::None: t->setOption( QLatin1String("Safety"), QLatin1String("None") );break;
+    case Ispdb::SSL: t->setOption( QLatin1String("Safety"), QLatin1String("SSL") );break;
+    case Ispdb::StartTLS: t->setOption( QLatin1String("Safety"), QLatin1String("STARTTLS") );break;
+    default: break;
+    }
+  }
+}
+
+void PersonalDataPage::configurePop3Account()
+{
+  if ( !mIspdb->pop3Servers().isEmpty() ) {
+    server s = mIspdb->pop3Servers().first(); // should be ok.
+    kDebug() << "No Imap to be created, configuring pop3 for" << s.hostname;
+
+    QObject* object = mSetupManager->createResource( QLatin1String("akonadi_pop3_resource") );
+    Resource* t = qobject_cast<Resource*>( object );
+    t->setName( accountName(mIspdb,s.username) );
+    t->setOption( QLatin1String("Host"), s.hostname );
+    t->setOption( QLatin1String("Port"), s.port );
+    t->setOption( QLatin1String("Login"), s.username );
+    t->setOption( QLatin1String("Password"), ui.passwordEdit->text() );
+    switch ( s.authentication ) {
+    case Ispdb::Plain: t->setOption( QLatin1String("AuthenticationMethod"), MailTransport::Transport::EnumAuthenticationType::PLAIN ); break;
+    case Ispdb::CramMD5: t->setOption( QLatin1String("AuthenticationMethod"), MailTransport::Transport::EnumAuthenticationType::CRAM_MD5 ); break;
+    case Ispdb::NTLM: t->setOption( QLatin1String("AuthenticationMethod"), MailTransport::Transport::EnumAuthenticationType::NTLM ); break;
+    case Ispdb::GSSAPI: t->setOption( QLatin1String("AuthenticationMethod"), MailTransport::Transport::EnumAuthenticationType::GSSAPI ); break;
+    case Ispdb::ClientIP:
+    case Ispdb::NoAuth:
+    default: t->setOption( QLatin1String("AuthenticationMethod"), MailTransport::Transport::EnumAuthenticationType::CLEAR ); break;
+    }
+    switch ( s.socketType ) {
+    case Ispdb::SSL: t->setOption( QLatin1String("UseSSL"), 1 );break;
+    case Ispdb::StartTLS: t->setOption( QLatin1String("UseTLS"), 1 );break;
+    case Ispdb::None:
+    default: t->setOption( QLatin1String("UseTLS"), 1 ); break;
+    }
+  }
+}
+
+void PersonalDataPage::automaticConfigureAccount()
+{
+  configureSmtpAccount();
+  configureImapAccount();
+  configurePop3Account();
+  emit leavePageNextOk();  // go to the next page
+  mSetupManager->execute();
+}
+
+void PersonalDataPage::leavePageNextRequested()
+{
+  // override base class with doing nothing...
+}
+
+
+
diff --git a/accountwizard/personaldatapage.h b/accountwizard/personaldatapage.h
new file mode 100644
index 0000000..bf26a08
--- /dev/null
+++ b/accountwizard/personaldatapage.h
@@ -0,0 +1,64 @@
+/*
+    Copyright (c) 2009 Volker Krause <vkrause at kde.org>
+    Copyright (c) 2010 Tom Albers <toma at kde.org>
+    Copyright (c) 2012 Laurent Montel <montel at kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef PERSONALDATA_H
+#define PERSONALDATA_H
+
+#include "page.h"
+#include "setupmanager.h"
+#include "dialog.h"
+
+#include "ui_personaldatapage.h"
+
+class Ispdb;
+
+class PersonalDataPage : public Page
+{
+  Q_OBJECT
+  public:
+    explicit PersonalDataPage( Dialog* parent = 0 );
+    void setHideOptionInternetSearch( bool );
+
+    virtual void leavePageNext();
+    virtual void leavePageNextRequested();
+
+  private slots:
+    void ispdbSearchFinished( bool ok );
+    void slotTextChanged();
+    void slotCreateAccountClicked();
+    void slotRadioButtonClicked( QAbstractButton* button);
+    void slotSearchType(const QString&);
+
+  signals:
+    void manualWanted( bool );
+
+  private:
+    void automaticConfigureAccount();
+    void configureSmtpAccount();
+    void configureImapAccount();
+    void configurePop3Account();
+
+    Ui::PersonalDataPage ui;
+    Ispdb* mIspdb;
+    SetupManager *mSetupManager;
+};
+
+#endif
diff --git a/accountwizard/providerpage.cpp b/accountwizard/providerpage.cpp
new file mode 100644
index 0000000..8252386
--- /dev/null
+++ b/accountwizard/providerpage.cpp
@@ -0,0 +1,175 @@
+/*
+    Copyright (c) 2009 Volker Krause <vkrause at kde.org>
+    Copyright (c) 2010 Tom Albers <toma at kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#include "providerpage.h"
+#include "global.h"
+
+#include <KDebug>
+#include <QSortFilterProxyModel>
+#include <knewstuff3/downloadmanager.h>
+
+ProviderPage::ProviderPage(KAssistantDialog* parent) :
+  Page( parent ),
+  m_model( new QStandardItemModel( this ) ),
+  m_downloadManager( new KNS3::DownloadManager( this ) ),
+  m_newPageWanted( false ),
+  m_newPageReady( false )
+{
+  ui.setupUi( this );
+
+  QSortFilterProxyModel *proxy = new QSortFilterProxyModel( this );
+  proxy->setSourceModel( m_model );
+  ui.listView->setModel( proxy );
+  ui.searchLine->setProxy( proxy );
+
+  m_fetchItem = new QStandardItem( i18n( "Fetching provider list..." ) );
+  m_model->appendRow( m_fetchItem );
+
+  // we can start the search, whenever the user reaches this page, chances
+  // are we have the full list.
+  connect( m_downloadManager, SIGNAL(searchResult(KNS3::Entry::List)),
+           SLOT(fillModel(KNS3::Entry::List)) );
+  connect( m_downloadManager, SIGNAL(entryStatusChanged(KNS3::Entry)),
+           SLOT(providerStatusChanged(KNS3::Entry)) );
+  m_downloadManager->setSearchOrder( KNS3::DownloadManager::Alphabetical );
+
+  connect( ui.listView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SLOT(selectionChanged()) );
+
+  kDebug();
+}
+
+void ProviderPage::startFetchingData()
+{
+  m_downloadManager->search( 0, 100000 );
+}
+
+void ProviderPage::fillModel(  const KNS3::Entry::List& list )
+{
+  kDebug();
+  m_model->removeRows( m_model->indexFromItem( m_fetchItem ).row(), 1 );
+
+  // KNS3::Entry::Entry() is private, so we need to save the whole list. 
+  // we can not use a QHash or whatever, as that needs that constructor...
+  m_providerEntries = list;
+
+  foreach ( const KNS3::Entry& e, list ) {
+    kDebug() << "Found Entry: " << e.name();
+
+    QStandardItem *item = new QStandardItem( e.name() );
+    item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
+    item->setData( e.name(), Qt::ToolTipRole );
+    item->setData( e.id(), Qt::UserRole );
+    item->setData( e.providerId(), Qt::UserRole+ 1 );
+    m_model->appendRow( item );
+  }
+}
+
+void ProviderPage::selectionChanged()
+{
+  if ( ui.listView->selectionModel()->hasSelection() ) {
+    setValid( true );
+  } else {
+    setValid( false );
+  }
+}
+
+void ProviderPage::leavePageNext()
+{
+  m_newPageReady = false;
+  if ( !ui.listView->selectionModel()->hasSelection() )
+    return;
+  const QModelIndex index = ui.listView->selectionModel()->selectedIndexes().first();
+  if ( !index.isValid() )
+    return;
+
+  const QSortFilterProxyModel *proxy = static_cast<const QSortFilterProxyModel*>( ui.listView->model() );
+  const QStandardItem* item =  m_model->itemFromIndex( proxy->mapToSource( index ) );
+  kDebug() << "Item selected:"<< item->text();
+
+  // download and execute it...
+  foreach ( const KNS3::Entry& e, m_providerEntries ) {
+    if ( e.id() == item->data( Qt::UserRole ) &&
+         e.providerId() == item->data( Qt::UserRole+ 1 ) ) {
+
+      m_wantedProvider.entryId = e.id();
+      m_wantedProvider.entryProviderId = e.providerId();
+
+      if ( e.status() == KNS3::Entry::Installed ) {
+        kDebug() << "already installed" << e.installedFiles();
+        findDesktopAndSetAssistant(  e.installedFiles() );
+      } else {
+        kDebug() << "Starting download for " << e.name();
+        m_downloadManager->installEntry( e );
+      }
+
+      break;
+    }
+  }
+}
+
+void ProviderPage::providerStatusChanged( const KNS3::Entry& e )
+{
+  kDebug() << e.name();
+  if ( e.id() == m_wantedProvider.entryId &&
+       e.providerId() == m_wantedProvider.entryProviderId &&
+       e.status() == KNS3::Entry::Installed ) {
+    findDesktopAndSetAssistant(  e.installedFiles() );
+  }
+}
+
+void ProviderPage::findDesktopAndSetAssistant( const QStringList& list )
+{
+  foreach ( const QString& file, list ) {
+    kDebug() << file;
+    if ( file.endsWith( QLatin1String ( ".desktop" ) ) ) {
+      kDebug() << "Yay, a desktop file!" << file;
+      Global::setAssistant( file );
+      m_newPageReady = true;
+      if ( m_newPageWanted ) {
+        kDebug() << "New page was already requested, now we are done, approve it";
+        emit leavePageNextOk();
+      }
+      break;
+    }
+  }
+}
+
+QTreeView *ProviderPage::treeview() const
+{
+  return ui.listView;
+}
+
+void ProviderPage::leavePageBackRequested()
+{
+  emit leavePageBackOk();
+  emit ghnsNotWanted();
+}
+
+void ProviderPage::leavePageNextRequested()
+{
+  m_newPageWanted = true;
+  if ( m_newPageReady ) {
+    kDebug() << "New page requested and we are done, so ok...";
+    emit leavePageNextOk();
+  } else {
+    kDebug() << "New page requested, but we are not done yet...";
+  }
+}
+
diff --git a/accountwizard/providerpage.h b/accountwizard/providerpage.h
new file mode 100644
index 0000000..8738e1c
--- /dev/null
+++ b/accountwizard/providerpage.h
@@ -0,0 +1,75 @@
+/*
+    Copyright (c) 2009 Volker Krause <vkrause at kde.org>
+    Copyright (c) 2010 Tom Albers <toma at kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef PROVIDERPAGE_H
+#define PROVIDERPAGE_H
+
+#include "page.h"
+#include <QStandardItemModel>
+
+#include "ui_providerpage.h"
+#include <knewstuff3/entry.h>
+
+struct Provider {
+  QString entryId;
+  QString entryProviderId;
+};
+
+namespace KNS3 {
+  class DownloadManager;
+}
+
+class ProviderPage : public Page
+{
+  Q_OBJECT
+  public:
+    explicit ProviderPage( KAssistantDialog* parent = 0 );
+
+    virtual void leavePageNext();
+    virtual void leavePageNextRequested();
+    virtual void leavePageBackRequested();
+
+    QTreeView *treeview() const;
+
+  signals:
+    void ghnsNotWanted();
+
+  public slots:
+    void startFetchingData();
+
+  private slots:
+    void fillModel( const KNS3::Entry::List& );
+    void selectionChanged();
+    void providerStatusChanged( const KNS3::Entry& );
+
+  private:
+    void findDesktopAndSetAssistant( const QStringList& list );
+
+    Ui::ProviderPage ui;
+    QStandardItemModel *m_model;
+    QStandardItem *m_fetchItem;
+    KNS3::DownloadManager *m_downloadManager;
+    KNS3::Entry::List m_providerEntries;
+    Provider m_wantedProvider;
+    bool m_newPageWanted;
+    bool m_newPageReady;
+};
+
+#endif
diff --git a/accountwizard/resource.cpp b/accountwizard/resource.cpp
new file mode 100644
index 0000000..fab7d1c
--- /dev/null
+++ b/accountwizard/resource.cpp
@@ -0,0 +1,165 @@
+/*
+    Copyright (c) 2009 Volker Krause <vkrause at kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#include "resource.h"
+
+#include <akonadi/agenttype.h>
+#include <akonadi/agentmanager.h>
+#include <akonadi/agentinstancecreatejob.h>
+
+#include <KDebug>
+#include <KLocalizedString>
+
+#include <QMetaMethod>
+#include <QVariant>
+#include <QtDBus/qdbusinterface.h>
+#include <QtDBus/qdbusreply.h>
+
+using namespace Akonadi;
+
+static QVariant::Type argumentType( const QMetaObject *mo, const QString &method )
+{
+  QMetaMethod m;
+  for ( int i = 0; i < mo->methodCount(); ++i ) {
+    const QString signature = QString::fromLatin1( mo->method( i ).signature() );
+    if ( signature.contains( method + QLatin1Char( '(' ) ) ) {
+      m = mo->method( i );
+      break;
+    }
+  }
+
+  if ( !m.signature() ) {
+    kWarning() << "Did not find D-Bus method: " << method << " available methods are:";
+    for ( int i = 0; i < mo->methodCount(); ++i )
+      kWarning() << mo->method( i ).signature();
+    return QVariant::Invalid;
+  }
+
+  const QList<QByteArray> argTypes = m.parameterTypes();
+  if ( argTypes.count() != 1 )
+    return QVariant::Invalid;
+
+  return QVariant::nameToType( argTypes.first() );
+}
+
+Resource::Resource(const QString& type, QObject* parent) :
+  SetupObject( parent ),
+  m_typeIdentifier( type )
+{
+}
+
+void Resource::setOption( const QString &key, const QVariant &value )
+{
+  m_settings.insert( key, value );
+}
+
+void Resource::setName( const QString &name )
+{
+  m_name = name;
+}
+
+void Resource::create()
+{
+  const AgentType type = AgentManager::self()->type( m_typeIdentifier );
+  if ( !type.isValid() ) {
+    emit error( i18n( "Resource type '%1' is not available.", m_typeIdentifier ) );
+    return;
+  }
+
+  // check if unique instance already exists
+  kDebug() << type.capabilities();
+  if ( type.capabilities().contains( QLatin1String( "Unique" ) ) ) {
+    foreach ( const AgentInstance &instance, AgentManager::self()->instances() ) {
+      kDebug() << instance.type().identifier() << ( instance.type() == type );
+      if ( instance.type() == type ) {
+        emit finished( i18n( "Resource '%1' is already set up.", type.name() ) );
+        return;
+      }
+    }
+  }
+
+  emit info( i18n( "Creating resource instance for '%1'...", type.name() ) );
+  AgentInstanceCreateJob *job = new AgentInstanceCreateJob( type, this );
+  connect( job, SIGNAL(result(KJob*)), SLOT(instanceCreateResult(KJob*)) );
+  job->start();
+}
+
+
+void Resource::instanceCreateResult(KJob* job)
+{
+  if ( job->error() ) {
+    emit error( i18n( "Failed to create resource instance: %1", job->errorText() ) );
+    return;
+  }
+
+  m_instance = qobject_cast<AgentInstanceCreateJob*>( job )->instance();
+
+  if ( !m_settings.isEmpty() ) {
+    emit info( i18n( "Configuring resource instance..." ) );
+    QDBusInterface iface( QLatin1String("org.freedesktop.Akonadi.Resource.") + m_instance.identifier(), QLatin1String("/Settings") );
+    if ( !iface.isValid() ) {
+      emit error( i18n( "Unable to configure resource instance." ) );
+      return;
+    }
+
+    // configure resource
+    if ( !m_name.isEmpty() )
+      m_instance.setName( m_name );
+    QMap<QString, QVariant>::const_iterator end( m_settings.constEnd() );
+    for ( QMap<QString, QVariant>::const_iterator it = m_settings.constBegin(); it != end; ++it ) {
+      kDebug() << "Setting up " << it.key() << " for agent " << m_instance.identifier();
+      const QString methodName = QString::fromLatin1( "set%1" ).arg( it.key() );
+      QVariant arg = it.value();
+      const QVariant::Type targetType = argumentType( iface.metaObject(), methodName );
+      if ( !arg.canConvert( targetType ) ) {
+        emit error( i18n( "Could not convert value of setting '%1' to required type %2.", it.key(), QLatin1String(QVariant::typeToName( targetType )) ) );
+        return;
+      }
+      arg.convert( targetType );
+      QDBusReply<void> reply = iface.call( methodName, arg );
+      if ( !reply.isValid() ) {
+        emit error( i18n( "Could not set setting '%1': %2", it.key(), reply.error().message() ) );
+        return;
+      }
+    }
+    m_instance.reconfigure();
+  }
+
+  emit finished( i18n( "Resource setup completed." ) );
+}
+
+void Resource::destroy()
+{
+  if ( m_instance.isValid() ) {
+    AgentManager::self()->removeInstance( m_instance );
+    emit info( i18n( "Removed resource instance for '%1'.", m_instance.type().name() ) );
+  }
+}
+
+QString Resource::identifier()
+{
+    return m_instance.identifier();
+}
+
+void Resource::reconfigure()
+{
+    m_instance.reconfigure();
+}
+
+
diff --git a/accountwizard/resource.h b/accountwizard/resource.h
new file mode 100644
index 0000000..ab09ba1
--- /dev/null
+++ b/accountwizard/resource.h
@@ -0,0 +1,51 @@
+/*
+    Copyright (c) 2009 Volker Krause <vkrause at kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef RESOURCE_H
+#define RESOURCE_H
+
+#include "setupobject.h"
+#include <akonadi/agentinstance.h>
+#include <QtCore/QMap>
+
+class KJob;
+
+class Resource : public SetupObject
+{
+  Q_OBJECT
+  public:
+    explicit Resource( const QString &type, QObject *parent = 0 );
+    void create();
+    void destroy();
+
+  public slots:
+    Q_SCRIPTABLE void setName( const QString &name );
+    Q_SCRIPTABLE void setOption( const QString &key, const QVariant &value );
+    Q_SCRIPTABLE QString identifier();
+    Q_SCRIPTABLE void reconfigure();
+
+  private slots:
+    void instanceCreateResult( KJob* job );
+
+  private:
+    QString m_typeIdentifier, m_name;
+    QMap<QString, QVariant> m_settings;
+    Akonadi::AgentInstance m_instance;
+};
+#endif
diff --git a/accountwizard/servertest.cpp b/accountwizard/servertest.cpp
new file mode 100644
index 0000000..89fee3b
--- /dev/null
+++ b/accountwizard/servertest.cpp
@@ -0,0 +1,64 @@
+/*
+    Copyright (c) 2010 Tom Albers <toma at kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#include "servertest.h"
+#include <mailtransport/transport.h>
+#include <mailtransport/servertest.h>
+
+#include <kdebug.h>
+#include <kmessagebox.h>
+#include <klocale.h>
+
+ServerTest::ServerTest( QObject* parent) :
+  QObject(parent), m_serverTest( new MailTransport::ServerTest( 0 ) )
+{
+  kDebug() << "Welcome!";
+  connect( m_serverTest, SIGNAL(finished(QList<int>)),
+           SLOT(testFinished(QList<int>)) );
+}
+
+ServerTest::~ServerTest()
+{
+  delete m_serverTest;
+}
+
+void ServerTest::test( const QString server, const QString protocol )
+{
+  kDebug() << server << protocol;
+  m_serverTest->setServer( server );
+  m_serverTest->setProtocol( protocol );
+  m_serverTest->start();
+}
+
+void ServerTest::testFinished( QList< int > list )
+{
+  kDebug() << "types: " << list;
+  if ( list.contains( MailTransport::Transport::EnumEncryption::TLS ) ) {
+    emit testResult( QLatin1String("tls") );
+  } else if ( list.contains( MailTransport::Transport::EnumEncryption::SSL ) ) {
+    emit testResult( QLatin1String("ssl") );
+  } else {
+    KMessageBox::information( 0, i18n( "There seems to be a problem in reaching this server "
+          "or choosing a safe way to sent the credentials to server. We advise you to "
+          "check the settings of the account and adjust it manually if needed." ),
+          i18n( "Autodetecting settings failed" ) );
+    emit testFail();
+  }
+}
+
diff --git a/accountwizard/servertest.h b/accountwizard/servertest.h
new file mode 100644
index 0000000..26ced2d
--- /dev/null
+++ b/accountwizard/servertest.h
@@ -0,0 +1,54 @@
+/*
+    Copyright (c) 2010 Tom Albers <toma at kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef SERVERTEST_H
+#define SERVERTEST_H
+
+#include <QtCore/QObject>
+
+namespace MailTransport {
+    class ServerTest;
+}
+
+class ServerTest : public QObject
+{
+  Q_OBJECT
+  public:
+    explicit ServerTest( QObject *parent );
+    ~ServerTest();
+
+  public slots:
+    /* @p protocol being 'imap' 'smtp' or 'pop3' */
+    Q_SCRIPTABLE void test( const QString server, const QString protocol );
+
+  signals:
+    /* returns the advised setting, @p result begin 'ssl' 'tls' or 'none'. */
+    void testResult( const QString& result );
+
+    /* returns if no connection is possible, test failed. */
+    void testFail();
+
+  private slots:
+    void testFinished( QList< int > list );
+
+  private:
+    MailTransport::ServerTest* m_serverTest;
+};
+
+#endif
diff --git a/accountwizard/setupautoconfigkolabfreebusy.cpp b/accountwizard/setupautoconfigkolabfreebusy.cpp
new file mode 100644
index 0000000..d3657d6
--- /dev/null
+++ b/accountwizard/setupautoconfigkolabfreebusy.cpp
@@ -0,0 +1,109 @@
+/*
+    Copyright (c) 2014 Sandro Knauß <knauss at kolabsys.com>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#include "setupautoconfigkolabfreebusy.h"
+#include "configfile.h"
+
+#include <KLocalizedString>
+
+SetupAutoconfigKolabFreebusy::SetupAutoconfigKolabFreebusy(QObject *parent)
+    : SetupObject(parent)
+{
+    mIspdb = new AutoconfigKolabFreebusy(this);
+    connect(mIspdb, SIGNAL(finished(bool)), SLOT(onIspdbFinished(bool)));
+}
+
+SetupAutoconfigKolabFreebusy::~SetupAutoconfigKolabFreebusy()
+{
+    delete mIspdb;
+}
+
+int SetupAutoconfigKolabFreebusy::countFreebusyServers() const
+{
+    return mIspdb->freebusyServers().count();
+}
+
+void SetupAutoconfigKolabFreebusy::fillFreebusyServer(int i, QObject *o) const
+{
+    freebusy isp = mIspdb->freebusyServers().values()[i];
+    ConfigFile *korganizer = qobject_cast<ConfigFile *>(o);
+    QString url(QLatin1String("https://"));
+
+    if (isp.socketType == Ispdb::None) {
+        url = QLatin1String("http://");
+    }
+
+    url += isp.hostname;
+
+    if (isp.port != 80) {
+        url += QLatin1Char(':');
+        url += QString::number(isp.port);
+    }
+
+    if (!isp.path.startsWith(QLatin1Char('/'))) {
+        url += QLatin1Char('/');
+    }
+
+    url += isp.path;
+
+    QString group(QLatin1String("FreeBusy Retrieve"));
+
+    korganizer->setConfig(group, QLatin1String("FreeBusyFullDomainRetrieval"), QLatin1String("true"));
+    korganizer->setConfig(group, QLatin1String("FreeBusyRetrieveAuto"), QLatin1String("true"));
+    korganizer->setConfig(group, QLatin1String("FreeBusyRetrieveUrl"), url);
+    korganizer->setConfig(group, QLatin1String("FreeBusyRetrieverUser"), isp.username);
+    korganizer->setConfig(group, QLatin1String("FreeBusyRetrieverPassword"), isp.password);
+    if (!isp.password.isEmpty()) {
+        korganizer->setConfig(group, QLatin1String("FreeBusyRetrieveSavePassword"), QLatin1String("true"));
+    }
+}
+
+void SetupAutoconfigKolabFreebusy::start()
+{
+    mIspdb->start();
+    emit info(i18n("Searching for autoconfiguration..."));
+}
+
+void SetupAutoconfigKolabFreebusy::setEmail(const QString &email)
+{
+    mIspdb->setEmail(email);
+}
+
+void SetupAutoconfigKolabFreebusy::setPassword(const QString &password)
+{
+    mIspdb->setPassword(password);
+}
+
+void SetupAutoconfigKolabFreebusy::create()
+{
+}
+
+void SetupAutoconfigKolabFreebusy::destroy()
+{
+}
+
+void SetupAutoconfigKolabFreebusy::onIspdbFinished(bool status)
+{
+    emit ispdbFinished(status);
+    if (status) {
+        emit info(i18n("Autoconfiguration found."));
+    } else {
+        emit info(i18n("Autoconfiguration failed."));
+    }
+}
diff --git a/accountwizard/setupautoconfigkolabfreebusy.h b/accountwizard/setupautoconfigkolabfreebusy.h
new file mode 100644
index 0000000..d3cd9ed
--- /dev/null
+++ b/accountwizard/setupautoconfigkolabfreebusy.h
@@ -0,0 +1,59 @@
+/*
+    Copyright (c) 2014 Sandro Knauß <knauss at kolabsys.com>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef SETUPAUTOCONFIGKOLABFREEBUSY_H
+#define SETUPAUTOCONFIGKOLABFREEBUSY_H
+
+#include "setupobject.h"
+#include "ispdb/autoconfigkolabfreebusy.h"
+
+class Identity;
+
+class SetupAutoconfigKolabFreebusy : public SetupObject
+{
+    Q_OBJECT
+public:
+    /** Constructor */
+    explicit SetupAutoconfigKolabFreebusy(QObject *parent = 0);
+    ~SetupAutoconfigKolabFreebusy();
+
+    virtual void create();
+    virtual void destroy();
+
+public slots:
+    Q_SCRIPTABLE void fillFreebusyServer(int i, QObject *) const;
+    Q_SCRIPTABLE int countFreebusyServers() const;
+
+    Q_SCRIPTABLE void start();
+
+    Q_SCRIPTABLE void setEmail(const QString &);
+    Q_SCRIPTABLE void setPassword(const QString &);
+
+signals:
+    void ispdbFinished(bool);
+
+private slots:
+    void onIspdbFinished(bool);
+
+private :
+    AutoconfigKolabFreebusy *mIspdb;
+
+};
+
+#endif
diff --git a/accountwizard/setupautoconfigkolabldap.cpp b/accountwizard/setupautoconfigkolabldap.cpp
new file mode 100644
index 0000000..41aeb45
--- /dev/null
+++ b/accountwizard/setupautoconfigkolabldap.cpp
@@ -0,0 +1,113 @@
+/*
+    Copyright (c) 2014 Sandro Knauß <knauss at kolabsys.com>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#include "setupautoconfigkolabldap.h"
+#include "ldap.h"
+#include "configfile.h"
+
+#include <KLocalizedString>
+
+SetupAutoconfigKolabLdap::SetupAutoconfigKolabLdap(QObject *parent)
+    : SetupObject(parent)
+{
+    mIspdb = new AutoconfigKolabLdap(this);
+    connect(mIspdb, SIGNAL(finished(bool)), SLOT(onIspdbFinished(bool)));
+}
+
+SetupAutoconfigKolabLdap::~SetupAutoconfigKolabLdap()
+{
+    delete mIspdb;
+}
+
+void SetupAutoconfigKolabLdap::fillLdapServer(int i, QObject *o) const
+{
+    ldapServer isp = mIspdb->ldapServers().values()[i];
+    Ldap *ldapRes = qobject_cast<Ldap *>(o);
+
+    //TODO: setting dn & filter
+
+    ldapRes->setServer(isp.hostname);
+    ldapRes->setPort(isp.port);
+    ldapRes->setSecurity(isp.socketType);
+    ldapRes->setVersion(isp.ldapVersion);
+    ldapRes->setUser(isp.username);
+    ldapRes->setPassword(isp.password);
+    ldapRes->setBindDn(isp.bindDn);
+
+    ldapRes->setRealm(isp.realm);
+    ldapRes->setSaslMech(isp.saslMech);
+
+    if (isp.pageSize != -1) {
+        ldapRes->setPageSize(isp.pageSize);
+    }
+
+    if (isp.timeLimit != -1) {
+        ldapRes->setPageSize(isp.timeLimit);
+    }
+
+    if (isp.sizeLimit != -1) {
+        ldapRes->setPageSize(isp.sizeLimit);
+    }
+
+    //Anonymous is set by not setting the AuthenticationMethod
+    if (isp.authentication == KLDAP::LdapServer::SASL) {
+        ldapRes->setAuthenticationMethod(QLatin1String("SASL"));
+    } else if (isp.authentication == KLDAP::LdapServer::Simple) {
+        ldapRes->setAuthenticationMethod(QLatin1String("Simple"));
+    }
+}
+
+int SetupAutoconfigKolabLdap::countLdapServers() const
+{
+    return mIspdb->ldapServers().count();
+}
+
+void SetupAutoconfigKolabLdap::start()
+{
+    mIspdb->start();
+    emit info(i18n("Searching for autoconfiguration..."));
+}
+
+void SetupAutoconfigKolabLdap::setEmail(const QString &email)
+{
+    mIspdb->setEmail(email);
+}
+
+void SetupAutoconfigKolabLdap::setPassword(const QString &password)
+{
+    mIspdb->setPassword(password);
+}
+
+void SetupAutoconfigKolabLdap::create()
+{
+}
+
+void SetupAutoconfigKolabLdap::destroy()
+{
+}
+
+void SetupAutoconfigKolabLdap::onIspdbFinished(bool status)
+{
+    emit ispdbFinished(status);
+    if (status) {
+        emit info(i18n("Autoconfiguration found."));
+    } else {
+        emit info(i18n("Autoconfiguration failed."));
+    }
+}
diff --git a/accountwizard/setupautoconfigkolabldap.h b/accountwizard/setupautoconfigkolabldap.h
new file mode 100644
index 0000000..93d44ab
--- /dev/null
+++ b/accountwizard/setupautoconfigkolabldap.h
@@ -0,0 +1,59 @@
+/*
+    Copyright (c) 2014 Sandro Knauß <knauss at kolabsys.com>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef SETUPAUTOCONFIGKOLABLDAPDB_H
+#define SETUPAUTOCONFIGKOLABLDAPDB_H
+
+#include "setupobject.h"
+#include "ispdb/autoconfigkolabldap.h"
+
+class Identity;
+
+class SetupAutoconfigKolabLdap : public SetupObject
+{
+    Q_OBJECT
+public:
+    /** Constructor */
+    explicit SetupAutoconfigKolabLdap(QObject *parent = 0);
+    ~SetupAutoconfigKolabLdap();
+
+    virtual void create();
+    virtual void destroy();
+
+public slots:
+    Q_SCRIPTABLE void fillLdapServer(int i, QObject *) const;
+    Q_SCRIPTABLE int countLdapServers() const;
+
+    Q_SCRIPTABLE void start();
+
+    Q_SCRIPTABLE void setEmail(const QString &);
+    Q_SCRIPTABLE void setPassword(const QString &);
+
+signals:
+    void ispdbFinished(bool);
+
+private slots:
+    void onIspdbFinished(bool);
+
+private :
+    AutoconfigKolabLdap *mIspdb;
+
+};
+
+#endif
diff --git a/accountwizard/setupautoconfigkolabmail.cpp b/accountwizard/setupautoconfigkolabmail.cpp
new file mode 100644
index 0000000..c5b1262
--- /dev/null
+++ b/accountwizard/setupautoconfigkolabmail.cpp
@@ -0,0 +1,29 @@
+/*
+    Copyright (c) 2014 Sandro Knauß <knauss at kolabsys.com>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#include "setupautoconfigkolabmail.h"
+#include "ispdb/autoconfigkolabmail.h"
+
+SetupAutoconfigKolabMail::SetupAutoconfigKolabMail(QObject *parent)
+    : SetupIspdb(parent)
+{
+    delete mIspdb;
+    mIspdb = new AutoconfigKolabMail(this);
+    connect(mIspdb, SIGNAL(finished(bool)), SLOT(onIspdbFinished(bool)));
+}
\ No newline at end of file
diff --git a/accountwizard/setupautoconfigkolabmail.h b/accountwizard/setupautoconfigkolabmail.h
new file mode 100644
index 0000000..229e61c
--- /dev/null
+++ b/accountwizard/setupautoconfigkolabmail.h
@@ -0,0 +1,35 @@
+/*
+    Copyright (c) 2014 Sandro Knauß <knauss at kolabsys.com>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef SETUPAUTOCONFIGKOLABMAIL_H
+#define SETUPAUTOCONFIGKOLABMAIL_H
+
+#include "setupispdb.h"
+
+class Identity;
+
+class SetupAutoconfigKolabMail : public SetupIspdb
+{
+    Q_OBJECT
+public:
+    /** Constructor */
+    explicit SetupAutoconfigKolabMail(QObject *parent = 0);
+};
+
+#endif
diff --git a/accountwizard/setupispdb.cpp b/accountwizard/setupispdb.cpp
new file mode 100644
index 0000000..9c70757
--- /dev/null
+++ b/accountwizard/setupispdb.cpp
@@ -0,0 +1,178 @@
+/*
+    Copyright (c) 2014 Sandro Knauß <knauss at kolabsys.com>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#include "setupispdb.h"
+#include "identity.h"
+#include "resource.h"
+#include "transport.h"
+#include "ldap.h"
+#include "configfile.h"
+
+#include <KLocalizedString>
+
+SetupIspdb::SetupIspdb(QObject *parent)
+    : SetupObject(parent)
+{
+    mIspdb = new Ispdb(this);
+    connect(mIspdb, SIGNAL(finished(bool)), SLOT(onIspdbFinished(bool)));
+}
+
+SetupIspdb::~SetupIspdb()
+{
+    delete mIspdb;
+}
+
+QStringList SetupIspdb::relevantDomains() const
+{
+    return mIspdb->relevantDomains();
+}
+
+QString SetupIspdb::name(int l) const
+{
+    return mIspdb->name((Ispdb::length)l);
+}
+
+int SetupIspdb::defaultIdentity() const
+{
+    return mIspdb->defaultIdentity();
+}
+
+int SetupIspdb::countIdentities() const
+{
+    return mIspdb->identities().count();
+}
+
+void SetupIspdb::fillIdentitiy(int i, QObject *o) const
+{
+    identity isp = mIspdb->identities()[i];
+
+    Identity *id = qobject_cast<Identity *>(o);
+
+    id->setIdentityName(isp.name);
+    id->setRealName(isp.name);
+    id->setEmail(isp.email);
+    id->setOrganization(isp.organization);
+    id->setSignature(isp.signature);
+}
+
+void SetupIspdb::fillImapServer(int i, QObject *o) const
+{
+    server isp = mIspdb->imapServers()[i];
+    Resource *imapRes = qobject_cast<Resource *>(o);
+
+    imapRes->setName(isp.hostname);
+    imapRes->setOption(QLatin1String("ImapServer"), isp.hostname);
+    imapRes->setOption(QLatin1String("UserName"), isp.username);
+    imapRes->setOption(QLatin1String("ImapPort"), isp.port);
+    imapRes->setOption(QLatin1String("Authentication"), isp.authentication);  //TODO: setup with right authentification
+    if (isp.socketType == Ispdb::None) {
+        imapRes->setOption(QLatin1String("Safety"), QLatin1String("NONE"));
+    } else if (isp.socketType == Ispdb::SSL) {
+        imapRes->setOption(QLatin1String("Safety"), QLatin1String("SSL"));
+    } else {
+        imapRes->setOption(QLatin1String("Safety"), QLatin1String("STARTTLS"));
+    }
+}
+
+int SetupIspdb::countImapServers() const
+{
+    return mIspdb->imapServers().count();
+}
+
+void SetupIspdb::fillSmtpServer(int i, QObject *o) const
+{
+    server isp = mIspdb->smtpServers()[i];
+    Transport *smtpRes = qobject_cast<Transport *>(o);
+
+    smtpRes->setName(isp.hostname);
+    smtpRes->setHost(isp.hostname);
+    smtpRes->setPort(isp.port);
+    smtpRes->setUsername(isp.username);
+
+    switch (isp.authentication) {
+    case Ispdb::Plain:
+        smtpRes->setAuthenticationType(QLatin1String("plain"));
+        break;
+    case Ispdb::CramMD5:
+        smtpRes->setAuthenticationType(QLatin1String("cram-md5"));
+        break;
+    case Ispdb::NTLM:
+        smtpRes->setAuthenticationType(QLatin1String("ntlm"));
+    break;
+    case Ispdb::GSSAPI:
+        smtpRes->setAuthenticationType(QLatin1String("gssapi"));
+        break;
+    case Ispdb::ClientIP:
+    case Ispdb::NoAuth:
+    default:
+        break;
+    }
+    switch (isp.socketType) {
+    case Ispdb::None:
+          smtpRes->setEncryption(QLatin1String("none"));
+          break;
+    case Ispdb::SSL:
+          smtpRes->setEncryption(QLatin1String("ssl"));
+          break;
+    case Ispdb::StartTLS:
+          smtpRes->setEncryption(QLatin1String("tls"));
+          break;
+    default:
+          break;
+    }
+}
+
+int SetupIspdb::countSmtpServers() const
+{
+    return mIspdb->smtpServers().count();
+}
+
+void SetupIspdb::start()
+{
+    mIspdb->start();
+    emit info(i18n("Searching for autoconfiguration..."));
+}
+
+void SetupIspdb::setEmail(const QString &email)
+{
+    mIspdb->setEmail(email);
+}
+
+void SetupIspdb::setPassword(const QString &password)
+{
+    mIspdb->setPassword(password);
+}
+
+void SetupIspdb::create()
+{
+}
+
+void SetupIspdb::destroy()
+{
+}
+
+void SetupIspdb::onIspdbFinished(bool status)
+{
+    emit ispdbFinished(status);
+    if (status) {
+        emit info(i18n("Autoconfiguration found."));
+    } else {
+        emit info(i18n("Autoconfiguration failed."));
+    }
+}
diff --git a/accountwizard/setupispdb.h b/accountwizard/setupispdb.h
new file mode 100644
index 0000000..05aa78e
--- /dev/null
+++ b/accountwizard/setupispdb.h
@@ -0,0 +1,70 @@
+/*
+    Copyright (c) 2014 Sandro Knauß <knauss at kolabsys.com>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef SETUPISPDB_H
+#define SETUPISPDB_H
+
+#include "setupobject.h"
+#include "ispdb/ispdb.h"
+
+class Identity;
+
+class SetupIspdb : public SetupObject
+{
+    Q_OBJECT
+public:
+    /** Constructor */
+    explicit SetupIspdb(QObject *parent = 0);
+    SetupIspdb(QObject *parent, Ispdb *ispdb);
+    ~SetupIspdb();
+
+    virtual void create();
+    virtual void destroy();
+
+public slots:
+    Q_SCRIPTABLE QStringList relevantDomains() const;
+    Q_SCRIPTABLE QString name(int l) const;
+
+    Q_SCRIPTABLE void fillImapServer(int i, QObject *) const;
+    Q_SCRIPTABLE int countImapServers() const;
+
+    Q_SCRIPTABLE void fillSmtpServer(int i, QObject *) const;
+    Q_SCRIPTABLE int countSmtpServers() const;
+
+    Q_SCRIPTABLE void fillIdentitiy(int i, QObject *) const;
+    Q_SCRIPTABLE int countIdentities() const;
+    Q_SCRIPTABLE int defaultIdentity() const;
+
+    Q_SCRIPTABLE void start();
+
+    Q_SCRIPTABLE void setEmail(const QString &);
+    Q_SCRIPTABLE void setPassword(const QString &);
+
+signals:
+    void ispdbFinished(bool);
+
+protected slots:
+    void onIspdbFinished(bool);
+
+protected :
+    Ispdb *mIspdb;
+
+};
+
+#endif
diff --git a/accountwizard/setupmanager.cpp b/accountwizard/setupmanager.cpp
new file mode 100644
index 0000000..421362d
--- /dev/null
+++ b/accountwizard/setupmanager.cpp
@@ -0,0 +1,265 @@
+/*
+    Copyright (c) 2009 Volker Krause <vkrause at kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#include "setupmanager.h"
+#include "resource.h"
+#include "setuppage.h"
+#include "transport.h"
+#include "configfile.h"
+#include "ldap.h"
+#include "identity.h"
+#include "setupispdb.h"
+#include "setupautoconfigkolabmail.h"
+#include "setupautoconfigkolabldap.h"
+#include "setupautoconfigkolabfreebusy.h"
+
+#include <kemailsettings.h>
+#include <kwallet.h>
+
+SetupManager::SetupManager( QWidget* parent) :
+  QObject(parent),
+  m_currentSetupObject( 0 ),
+  m_page( 0 ),
+  m_wallet( 0 ),
+  m_personalDataAvailable( false ),
+  m_rollbackRequested( false )
+{
+  KEMailSettings e;
+  m_name = e.getSetting( KEMailSettings::RealName );
+  m_email = e.getSetting( KEMailSettings::EmailAddress );
+}
+
+SetupManager::~SetupManager()
+{
+  delete m_wallet;
+}
+
+void SetupManager::setSetupPage(SetupPage* page)
+{
+  m_page = page;
+}
+
+QObject* SetupManager::createResource(const QString& type)
+{
+  return connectObject( new Resource( type, this ) );
+}
+
+QObject* SetupManager::createTransport(const QString& type)
+{
+  return connectObject( new Transport( type, this ) );
+}
+
+QObject* SetupManager::createConfigFile(const QString& fileName)
+{
+  return connectObject( new ConfigFile( fileName, this ) );
+}
+
+QObject* SetupManager::createLdap()
+{
+  return connectObject( new Ldap( this ) );
+}
+
+
+QObject* SetupManager::createIdentity()
+{
+  return connectObject( new Identity( this ) );
+}
+
+static bool dependencyCompare( SetupObject *left, SetupObject *right )
+{
+  if ( !left->dependsOn() && right->dependsOn() )
+    return true;
+  return false;
+}
+
+void SetupManager::execute()
+{
+  m_page->setStatus( i18n( "Setting up account..." ) );
+  m_page->setValid( false );
+
+  // ### FIXME this is a bad over-simplification and would need a real topological sort
+  // but for current usage it is good enough
+  qStableSort( m_objectToSetup.begin(), m_objectToSetup.end(), dependencyCompare );
+  setupNext();
+}
+
+void SetupManager::setupSucceeded(const QString& msg)
+{
+  Q_ASSERT( m_page );
+  m_page->addMessage( SetupPage::Success, msg );
+  if(m_currentSetupObject) {
+    m_setupObjects.append( m_currentSetupObject );
+    m_currentSetupObject = 0;
+  }
+  setupNext();
+}
+
+void SetupManager::setupFailed(const QString& msg)
+{
+  Q_ASSERT( m_page );
+  m_page->addMessage( SetupPage::Error, msg );
+  if( m_currentSetupObject ) {
+    m_setupObjects.append( m_currentSetupObject );
+    m_currentSetupObject = 0;
+  }
+  rollback();
+}
+
+void SetupManager::setupInfo(const QString& msg)
+{
+  Q_ASSERT( m_page );
+  m_page->addMessage( SetupPage::Info, msg );
+}
+
+void SetupManager::setupNext()
+{
+  // user canceld during the previous setup step
+  if ( m_rollbackRequested ) {
+    rollback();
+    return;
+  }
+
+  if ( m_objectToSetup.isEmpty() ) {
+    m_page->setStatus( i18n( "Setup complete." ) );
+    m_page->setProgress( 100 );
+    m_page->setValid( true );
+  } else {
+    const int setupObjectCount = m_objectToSetup.size() + m_setupObjects.size();
+    const int remainingObjectCount = setupObjectCount - m_objectToSetup.size();
+    m_page->setProgress( ( remainingObjectCount * 100 ) / setupObjectCount );
+    m_currentSetupObject = m_objectToSetup.takeFirst();
+    m_currentSetupObject->create();
+  }
+}
+
+void SetupManager::rollback()
+{
+  m_page->setStatus( i18n( "Failed to set up account, rolling back..." ) );
+  const int setupObjectCount = m_objectToSetup.size() + m_setupObjects.size();
+  int remainingObjectCount = m_setupObjects.size();
+  foreach ( SetupObject* obj, m_setupObjects ) {
+    m_page->setProgress( ( remainingObjectCount * 100 ) / setupObjectCount );
+    if( obj ) {
+      obj->destroy();
+      m_objectToSetup.prepend( obj );
+    }
+  }
+  m_setupObjects.clear();
+  m_page->setProgress( 0 );
+  m_page->setStatus( i18n( "Failed to set up account." ) );
+  m_page->setValid( true );
+  m_rollbackRequested = false;
+  emit rollbackComplete();
+}
+
+SetupObject* SetupManager::connectObject(SetupObject* obj)
+{
+  connect( obj, SIGNAL(finished(QString)), SLOT(setupSucceeded(QString)) );
+  connect( obj, SIGNAL(info(QString)), SLOT(setupInfo(QString)) );
+  connect( obj, SIGNAL(error(QString)), SLOT(setupFailed(QString)) );
+  m_objectToSetup.append( obj );
+  return obj;
+}
+
+void SetupManager::setName( const QString& name )
+{
+  m_name = name;
+}
+
+QString SetupManager::name()
+{
+  return m_name;
+}
+
+void SetupManager::setEmail( const QString& email)
+{
+  m_email = email;
+}
+
+QString SetupManager::email()
+{
+  return m_email;
+}
+
+void SetupManager::setPassword( const QString& password)
+{
+  m_password = password;
+}
+
+QString SetupManager::password()
+{
+  return m_password;
+}
+
+QString SetupManager::country()
+{
+  return KGlobal::locale()->country();
+}
+
+void SetupManager::openWallet()
+{
+  using namespace KWallet;
+  if ( Wallet::isOpen( Wallet::NetworkWallet() ) )
+    return;
+
+  Q_ASSERT( parent()->isWidgetType() );
+  m_wallet = Wallet::openWallet( Wallet::NetworkWallet(), qobject_cast<QWidget*>( parent() )->effectiveWinId(), Wallet::Asynchronous );
+  QEventLoop loop;
+  connect( m_wallet, SIGNAL(walletOpened(bool)), &loop, SLOT(quit()) );
+  loop.exec();
+}
+
+bool SetupManager::personalDataAvailable()
+{
+  return m_personalDataAvailable;
+}
+
+void SetupManager::setPersonalDataAvailable(bool available)
+{
+  m_personalDataAvailable = available;
+}
+
+QObject* SetupManager::ispDB(const QString &type)
+{
+    const QString t = type.toLower();
+    if ( t == QLatin1String("autoconfigkolabmail") ) {
+        return new SetupAutoconfigKolabMail(this);
+    } else if ( t == QLatin1String("autoconfigkolabldap") ) {
+        return new SetupAutoconfigKolabLdap(this);
+    } else if ( t == QLatin1String("autoconfigkolabfreebusy") ) {
+        return new SetupAutoconfigKolabFreebusy(this);
+    } else if ( t == QLatin1String("ispdb") ) {
+        return new SetupIspdb( this );
+    } else {
+        return new SetupIspdb( this );
+    }
+}
+
+void SetupManager::requestRollback()
+{
+  if ( m_setupObjects.isEmpty() ) {
+    emit rollbackComplete();
+  } else {
+    m_rollbackRequested = true;
+    if ( !m_currentSetupObject )
+      rollback();
+  }
+}
+
+
diff --git a/accountwizard/setupmanager.h b/accountwizard/setupmanager.h
new file mode 100644
index 0000000..ad6fcb0
--- /dev/null
+++ b/accountwizard/setupmanager.h
@@ -0,0 +1,87 @@
+/*
+    Copyright (c) 2009 Volker Krause <vkrause at kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef SETUPMANAGER_H
+#define SETUPMANAGER_H
+
+#include <QtCore/QObject>
+
+namespace KWallet {
+  class Wallet;
+}
+
+class SetupObject;
+class SetupPage;
+
+class SetupManager : public QObject
+{
+  Q_OBJECT
+  public:
+    explicit SetupManager( QWidget *parent );
+    ~SetupManager();
+    void setSetupPage( SetupPage* page );
+
+    void setName( const QString& );
+    void setEmail( const QString& );
+    void setPassword( const QString& );
+    void setPersonalDataAvailable( bool available );
+
+  public slots:
+    Q_SCRIPTABLE bool personalDataAvailable();
+    Q_SCRIPTABLE QString name();
+    Q_SCRIPTABLE QString email();
+    Q_SCRIPTABLE QString password();
+    Q_SCRIPTABLE QString country();
+    /** Ensures the wallet is open for subsequent sync wallet access in the resources. */
+    Q_SCRIPTABLE void openWallet();
+    Q_SCRIPTABLE QObject* createResource( const QString &type );
+    Q_SCRIPTABLE QObject* createTransport( const QString &type );
+    Q_SCRIPTABLE QObject* createConfigFile( const QString &configName );
+    Q_SCRIPTABLE QObject* createLdap();
+    Q_SCRIPTABLE QObject* createIdentity();
+    Q_SCRIPTABLE void execute();
+    Q_SCRIPTABLE QObject* ispDB( const QString &type );
+
+    void requestRollback();
+
+  signals:
+    void rollbackComplete();
+
+  private:
+    void setupNext();
+    void rollback();
+    SetupObject* connectObject( SetupObject* obj );
+
+  private slots:
+    void setupSucceeded( const QString &msg );
+    void setupFailed( const QString &msg );
+    void setupInfo( const QString &msg );
+
+  private:
+    QString m_name, m_email, m_password;
+    QList<SetupObject*> m_objectToSetup;
+    QList<SetupObject*> m_setupObjects;
+    SetupObject* m_currentSetupObject;
+    SetupPage* m_page;
+    KWallet::Wallet *m_wallet;
+    bool m_personalDataAvailable;
+    bool m_rollbackRequested;
+};
+
+#endif
diff --git a/accountwizard/setupobject.cpp b/accountwizard/setupobject.cpp
new file mode 100644
index 0000000..744fe2f
--- /dev/null
+++ b/accountwizard/setupobject.cpp
@@ -0,0 +1,35 @@
+/*
+    Copyright (c) 2009 Volker Krause <vkrause at kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#include "setupobject.h"
+
+SetupObject::SetupObject(QObject* parent): QObject(parent), m_dependsOn( 0 )
+{
+}
+
+SetupObject* SetupObject::dependsOn() const
+{
+  return m_dependsOn;
+}
+
+void SetupObject::setDependsOn(SetupObject* obj)
+{
+  m_dependsOn = obj;
+}
+
diff --git a/accountwizard/setupobject.h b/accountwizard/setupobject.h
new file mode 100644
index 0000000..7d8f65e
--- /dev/null
+++ b/accountwizard/setupobject.h
@@ -0,0 +1,46 @@
+/*
+    Copyright (c) 2009 Volker Krause <vkrause at kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef SETUPOBJECT_H
+#define SETUPOBJECT_H
+
+#include <QtCore/QObject>
+
+class SetupObject : public QObject
+{
+  Q_OBJECT
+  public:
+    explicit SetupObject( QObject *parent );
+
+    virtual void create() = 0;
+    virtual void destroy() = 0;
+
+    SetupObject* dependsOn() const;
+    void setDependsOn( SetupObject* obj );
+
+  signals:
+    void error( const QString &msg );
+    void info( const QString &msg );
+    void finished( const QString &msg );
+
+  private:
+    SetupObject *m_dependsOn;
+};
+
+#endif
diff --git a/accountwizard/setuppage.cpp b/accountwizard/setuppage.cpp
new file mode 100644
index 0000000..d44003f
--- /dev/null
+++ b/accountwizard/setuppage.cpp
@@ -0,0 +1,71 @@
+/*
+    Copyright (c) 2009 Volker Krause <vkrause at kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#include "setuppage.h"
+
+#include <qstandarditemmodel.h>
+
+SetupPage::SetupPage(KAssistantDialog* parent) :
+  Page(parent),
+  m_msgModel( new QStandardItemModel( this ) )
+{
+  ui.setupUi( this );
+  ui.detailView->setModel( m_msgModel );
+  connect( ui.detailsButton, SIGNAL(clicked()), SLOT(detailsClicked()) );
+}
+
+void SetupPage::enterPageNext()
+{
+  ui.stackWidget->setCurrentIndex( 0 );
+}
+
+void SetupPage::detailsClicked()
+{
+  ui.stackWidget->setCurrentIndex( 1 );
+}
+
+void SetupPage::addMessage(SetupPage::MessageType type, const QString& msg)
+{
+  QStandardItem *item = new QStandardItem;
+  item->setText( msg );
+  item->setEditable( false );
+  switch ( type ) {
+    case Success:
+      item->setIcon( KIcon( QLatin1String("dialog-ok") ) );
+      break;
+    case Info:
+      item->setIcon( KIcon( QLatin1String("dialog-information" )) );
+      break;
+    case Error:
+      item->setIcon( KIcon( QLatin1String("dialog-error") ) );
+      break;
+  }
+  m_msgModel->appendRow( item );
+}
+
+void SetupPage::setStatus(const QString& msg)
+{
+  ui.progressLabel->setText( msg );
+}
+
+void SetupPage::setProgress(int percent)
+{
+  ui.progressBar->setValue( percent );
+}
+
diff --git a/accountwizard/setuppage.h b/accountwizard/setuppage.h
new file mode 100644
index 0000000..2354d8a
--- /dev/null
+++ b/accountwizard/setuppage.h
@@ -0,0 +1,52 @@
+/*
+    Copyright (c) 2009 Volker Krause <vkrause at kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef SETUPPAGE_H
+#define SETUPPAGE_H
+
+#include "page.h"
+#include "ui_setuppage.h"
+
+class QStandardItemModel;
+
+class SetupPage : public Page
+{
+  Q_OBJECT
+  public:
+    explicit SetupPage( KAssistantDialog *parent );
+    virtual void enterPageNext();
+
+    enum MessageType {
+      Success,
+      Info,
+      Error
+    };
+    void addMessage( MessageType type, const QString &msg );
+    void setStatus( const QString &msg );
+    void setProgress( int percent );
+
+  private slots:
+    void detailsClicked();
+
+  private:
+    Ui::SetupPage ui;
+    QStandardItemModel* m_msgModel;
+};
+
+#endif
diff --git a/accountwizard/transport.cpp b/accountwizard/transport.cpp
new file mode 100644
index 0000000..7d20b42
--- /dev/null
+++ b/accountwizard/transport.cpp
@@ -0,0 +1,156 @@
+/*
+    Copyright (c) 2009 Volker Krause <vkrause at kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#include "transport.h"
+
+#include <mailtransport/transportmanager.h>
+
+#include <KDebug>
+#include <KLocalizedString>
+
+#define TABLE_SIZE x
+
+template <typename T>
+struct StringValueTable {
+  const char * name;
+  typename T::type value;
+  typedef typename T::type value_type;
+};
+
+static const StringValueTable<MailTransport::Transport::EnumType> transportTypeEnums[] = {
+  { "smtp", MailTransport::Transport::EnumType::SMTP },
+  { "sendmail", MailTransport::Transport::EnumType::Sendmail },
+  { "akonadi", MailTransport::Transport::EnumType::Akonadi }
+};
+static const int transportTypeEnumsSize = sizeof( transportTypeEnums ) / sizeof ( *transportTypeEnums );
+
+static const StringValueTable<MailTransport::Transport::EnumEncryption> encryptionEnum[] = {
+  { "none", MailTransport::Transport::EnumEncryption::None },
+  { "ssl", MailTransport::Transport::EnumEncryption::SSL },
+  { "tls", MailTransport::Transport::EnumEncryption::TLS }
+};
+static const int encryptionEnumSize = sizeof( encryptionEnum ) / sizeof( *encryptionEnum );
+
+static const StringValueTable<MailTransport::Transport::EnumAuthenticationType> authenticationTypeEnum[] = {
+  { "login",      MailTransport::Transport::EnumAuthenticationType::LOGIN },
+  { "plain",      MailTransport::Transport::EnumAuthenticationType::PLAIN },
+  { "cram-md5",   MailTransport::Transport::EnumAuthenticationType::CRAM_MD5 },
+  { "digest-md5", MailTransport::Transport::EnumAuthenticationType::DIGEST_MD5 },
+  { "gssapi",     MailTransport::Transport::EnumAuthenticationType::GSSAPI },
+  { "ntlm",       MailTransport::Transport::EnumAuthenticationType::NTLM },
+  { "apop",       MailTransport::Transport::EnumAuthenticationType::APOP },
+  { "clear",      MailTransport::Transport::EnumAuthenticationType::CLEAR },
+  { "anonymous",  MailTransport::Transport::EnumAuthenticationType::ANONYMOUS }
+};
+static const int authenticationTypeEnumSize = sizeof( authenticationTypeEnum ) / sizeof( *authenticationTypeEnum );
+
+template <typename T>
+static typename T::value_type stringToValue( const T *table, const int tableSize, const QString &string )
+{
+  const QString ref = string.toLower();
+  for ( int i = 0; i < tableSize; ++i ) {
+    if ( ref == QLatin1String( table[i].name ) )
+      return table[i].value;
+  }
+  return table[0].value; // TODO: error handling
+}
+
+Transport::Transport(const QString& type, QObject* parent) :
+  SetupObject( parent ),
+  m_transportId( -1 ),
+  m_port( -1 ),
+  m_encr( MailTransport::Transport::EnumEncryption::TLS ),
+  m_auth( MailTransport::Transport::EnumAuthenticationType::PLAIN )
+{
+  m_transportType = stringToValue( transportTypeEnums, transportTypeEnumsSize, type );
+  if ( m_transportType == MailTransport::Transport::EnumType::SMTP )
+    m_port = 25;
+}
+
+void Transport::create()
+{
+  emit info( i18n( "Setting up mail transport account..." ) );
+  MailTransport::Transport* mt = MailTransport::TransportManager::self()->createTransport();
+  mt->setName( m_name );
+  mt->setHost( m_host );
+  if ( m_port > 0 )
+    mt->setPort( m_port );
+  if ( !m_user.isEmpty() ) {
+    mt->setUserName( m_user );
+    mt->setRequiresAuthentication( true );
+  }
+  if ( !m_password.isEmpty() ) {
+    mt->setStorePassword( true );
+    mt->setPassword( m_password );
+  }
+  mt->setEncryption( m_encr );
+  mt->setAuthenticationType( m_auth );
+  m_transportId = mt->id();
+  mt->writeConfig();
+  MailTransport::TransportManager::self()->addTransport( mt );
+  MailTransport::TransportManager::self()->setDefaultTransport( mt->id() );
+  emit finished( i18n( "Mail transport account set up." ) );
+}
+
+void Transport::destroy()
+{
+  MailTransport::TransportManager::self()->removeTransport( m_transportId );
+  emit info( i18n( "Mail transport account deleted." ) );
+}
+
+void Transport::setName( const QString &name )
+{
+  m_name = name;
+}
+
+void Transport::setHost( const QString &host )
+{
+  m_host = host;
+}
+
+void Transport::setPort( int port )
+{
+  m_port = port;
+}
+
+void Transport::setUsername( const QString &user )
+{
+  m_user = user;
+}
+
+void Transport::setPassword( const QString &password )
+{
+  m_password = password;
+}
+
+void Transport::setEncryption( const QString &encryption )
+{
+  m_encr = stringToValue( encryptionEnum, encryptionEnumSize, encryption );
+}
+
+void Transport::setAuthenticationType( const QString &authType )
+{
+  m_auth = stringToValue( authenticationTypeEnum, authenticationTypeEnumSize, authType );
+}
+
+int Transport::transportId() const
+{
+  return m_transportId;
+}
+
diff --git a/accountwizard/transport.h b/accountwizard/transport.h
new file mode 100644
index 0000000..36666cb
--- /dev/null
+++ b/accountwizard/transport.h
@@ -0,0 +1,62 @@
+/*
+    Copyright (c) 2009 Volker Krause <vkrause at kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef TRANSPORT_H
+#define TRANSPORT_H
+
+#include "setupobject.h"
+#include <mailtransport/transport.h>
+
+
+class Transport : public SetupObject
+{
+  Q_OBJECT
+  public:
+    explicit Transport( const QString &type, QObject *parent = 0 );
+    void create();
+    void destroy();
+
+    int transportId() const;
+
+  public slots:
+    Q_SCRIPTABLE void setName( const QString &name );
+    Q_SCRIPTABLE void setHost( const QString &host );
+    Q_SCRIPTABLE void setPort( int port );
+    Q_SCRIPTABLE void setUsername( const QString &user );
+    Q_SCRIPTABLE void setPassword( const QString &password );
+    Q_SCRIPTABLE void setEncryption( const QString &encryption );
+    Q_SCRIPTABLE void setAuthenticationType( const QString &authType );
+
+  private:
+    MailTransport::Transport::EnumEncryption stringToEncryption( const QString &encryptionString );
+    MailTransport::Transport::EnumAuthenticationType stringToAuthType( const QString &authString );
+
+  private:
+    int m_transportId;
+    MailTransport::Transport::EnumType::type m_transportType;
+    QString m_name;
+    QString m_host;
+    int m_port;
+    QString m_user;
+    QString m_password;
+    MailTransport::Transport::EnumEncryption::type m_encr;
+    MailTransport::Transport::EnumAuthenticationType::type m_auth;
+};
+
+#endif
diff --git a/accountwizard/typepage.cpp b/accountwizard/typepage.cpp
new file mode 100644
index 0000000..8a3dfaa
--- /dev/null
+++ b/accountwizard/typepage.cpp
@@ -0,0 +1,117 @@
+/*
+    Copyright (c) 2009 Volker Krause <vkrause at kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#include "typepage.h"
+
+#include <KDebug>
+#include <KDesktopFile>
+#include <KStandardDirs>
+
+#include <QSortFilterProxyModel>
+#include "global.h"
+#include <kmimetype.h>
+
+TypePage::TypePage(KAssistantDialog* parent) :
+  Page( parent ),
+  m_model( new QStandardItemModel( this ) )
+{
+  ui.setupUi( this );
+#ifdef KDEPIM_MOBILE_UI
+  ui.label->setHidden( true );
+  ui.searchLine->setHidden( true );
+#endif
+
+#ifdef ACCOUNTWIZARD_NO_GHNS
+  ui.ghnsButton->hide();
+#endif
+
+  QSortFilterProxyModel *proxy = new QSortFilterProxyModel( this );
+  proxy->setSourceModel( m_model );
+  ui.listView->setModel( proxy );
+  ui.searchLine->setProxy( proxy );
+
+  const QStringList list = KGlobal::dirs()->findAllResources( "data", QLatin1String( "akonadi/accountwizard/*.desktop" ),
+                                                              KStandardDirs::Recursive | KStandardDirs::NoDuplicates );
+  const QStringList filter = Global::typeFilter();
+  foreach ( const QString &entry, list ) {
+    KDesktopFile f( entry );
+    kDebug() << entry << f.readName();
+    const KConfig configWizard( entry );
+    KConfigGroup grp( &configWizard, "Wizard" );
+    const QStringList lstType = grp.readEntry( "Type", QStringList() );
+    if ( lstType.isEmpty() ) {
+      kDebug() << QString::fromLatin1( " %1 doesn't contains specific type" ).arg( f.readName() );
+    }
+    if ( !filter.isEmpty() ) {
+      // stolen from agentfilterproxymodel
+      bool found = false;
+      foreach ( const QString &mimeType, lstType ) {
+        if ( filter.contains( mimeType ) ) {
+          found = true;
+          break;
+        } else {
+          foreach ( const QString &type, filter ) {
+            KMimeType::Ptr typePtr = KMimeType::mimeType( type, KMimeType::ResolveAliases );
+            if ( !typePtr.isNull() && typePtr->is( mimeType ) ) {
+              found = true;
+              break;
+            }
+          }
+        }
+        if ( found )
+          break;
+      }
+      if ( !found )
+        continue;
+    }
+    QStandardItem *item = new QStandardItem( f.readName() );
+    item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
+    item->setData( entry, Qt::UserRole );
+    if ( !f.readIcon().isEmpty() )
+      item->setData( KIcon( f.readIcon() ), Qt::DecorationRole );
+    item->setData( f.readComment(), Qt::ToolTipRole );
+    m_model->appendRow( item );
+  }
+
+  connect( ui.listView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SLOT(selectionChanged()) );
+  connect( ui.ghnsButton, SIGNAL(clicked()), SIGNAL(ghnsWanted()) );
+}
+
+void TypePage::selectionChanged()
+{
+  if ( ui.listView->selectionModel()->hasSelection() ) {
+    setValid( true );
+  } else {
+    setValid( false );
+  }
+}
+
+void TypePage::leavePageNext()
+{
+  if ( !ui.listView->selectionModel()->hasSelection() )
+    return;
+  const QModelIndex index = ui.listView->selectionModel()->selectedIndexes().first();
+  Global::setAssistant( index.data( Qt::UserRole ).toString() );
+}
+
+QTreeView *TypePage::treeview() const
+{
+  return ui.listView;
+}
+
diff --git a/accountwizard/typepage.h b/accountwizard/typepage.h
new file mode 100644
index 0000000..f69ba0f
--- /dev/null
+++ b/accountwizard/typepage.h
@@ -0,0 +1,47 @@
+/*
+    Copyright (c) 2009 Volker Krause <vkrause at kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef TYPEPAGE_H
+#define TYPEPAGE_H
+
+#include "page.h"
+#include <QStandardItemModel>
+
+#include "ui_typepage.h"
+
+class TypePage : public Page
+{
+  Q_OBJECT
+  public:
+    explicit TypePage( KAssistantDialog* parent = 0 );
+
+    virtual void leavePageNext();
+    QTreeView *treeview() const;
+
+  signals:
+    void ghnsWanted();
+
+  private slots:
+    void selectionChanged();
+  private:
+    Ui::TypePage ui;
+    QStandardItemModel *m_model;
+};
+
+#endif
diff --git a/accountwizard/ui/loadpage.ui b/accountwizard/ui/loadpage.ui
new file mode 100644
index 0000000..8701a1b
--- /dev/null
+++ b/accountwizard/ui/loadpage.ui
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>LoadPage</class>
+ <widget class="QWidget" name="LoadPage">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>84</height>
+   </rect>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <spacer name="verticalSpacer">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>129</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item>
+    <widget class="QLabel" name="statusLabel">
+     <property name="text">
+      <string>Loading assistant...</string>
+     </property>
+     <property name="alignment">
+      <set>Qt::AlignCenter</set>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <spacer name="verticalSpacer_2">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>129</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/accountwizard/ui/personaldatapage.ui b/accountwizard/ui/personaldatapage.ui
new file mode 100644
index 0000000..26e142c
--- /dev/null
+++ b/accountwizard/ui/personaldatapage.ui
@@ -0,0 +1,283 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>PersonalDataPage</class>
+ <widget class="QWidget" name="PersonalDataPage">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>521</width>
+    <height>289</height>
+   </rect>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout_3">
+   <item>
+    <widget class="QLabel" name="welcomeLabel">
+     <property name="text">
+      <string>With a few simple steps we create the right settings for you. Please follow the steps of this wizard carefully.</string>
+     </property>
+     <property name="wordWrap">
+      <bool>true</bool>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <layout class="QGridLayout" name="gridLayout">
+     <item row="0" column="0">
+      <widget class="QLabel" name="nameLabel">
+       <property name="text">
+        <string>Full name:</string>
+       </property>
+       <property name="alignment">
+        <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+       </property>
+       <property name="buddy">
+        <cstring>nameEdit</cstring>
+       </property>
+      </widget>
+     </item>
+     <item row="0" column="1">
+      <widget class="KLineEdit" name="nameEdit">
+       <property name="minimumSize">
+        <size>
+         <width>0</width>
+         <height>22</height>
+        </size>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="0">
+      <widget class="QLabel" name="emailLabel">
+       <property name="text">
+        <string>E-mail address:</string>
+       </property>
+       <property name="alignment">
+        <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+       </property>
+       <property name="buddy">
+        <cstring>emailEdit</cstring>
+       </property>
+      </widget>
+     </item>
+     <item row="1" column="1">
+      <widget class="KLineEdit" name="emailEdit">
+       <property name="minimumSize">
+        <size>
+         <width>0</width>
+         <height>22</height>
+        </size>
+       </property>
+      </widget>
+     </item>
+     <item row="2" column="1">
+      <widget class="KLineEdit" name="passwordEdit">
+       <property name="minimumSize">
+        <size>
+         <width>0</width>
+         <height>22</height>
+        </size>
+       </property>
+       <property name="echoMode">
+        <enum>QLineEdit::Password</enum>
+       </property>
+      </widget>
+     </item>
+     <item row="2" column="0">
+      <widget class="QLabel" name="passwordLabel">
+       <property name="text">
+        <string>Password:</string>
+       </property>
+       <property name="alignment">
+        <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+       </property>
+       <property name="buddy">
+        <cstring>passwordEdit</cstring>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <widget class="QStackedWidget" name="stackedPage">
+     <property name="currentIndex">
+      <number>0</number>
+     </property>
+     <widget class="QWidget" name="internetPage">
+      <layout class="QHBoxLayout" name="horizontalLayout_3">
+       <item>
+        <widget class="QGroupBox" name="checkOnlineGroupBox">
+         <property name="title">
+          <string>Find provider settings on the Internet</string>
+         </property>
+         <property name="checkable">
+          <bool>true</bool>
+         </property>
+         <layout class="QVBoxLayout" name="verticalLayout">
+          <item>
+           <widget class="QLabel" name="checkOnlineExplanation">
+            <property name="text">
+             <string>Check online for the settings needed for this email provider. Only the domain name part of the e-mail address will be sent over the Internet at this point. If this option is unchecked, the account can be set up manually.</string>
+            </property>
+            <property name="wordWrap">
+             <bool>true</bool>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <layout class="QHBoxLayout" name="horizontalLayout_4">
+            <item>
+             <widget class="KPIMUtils::ProgressIndicatorLabel" name="mProgress"/>
+            </item>
+           </layout>
+          </item>
+         </layout>
+        </widget>
+       </item>
+      </layout>
+     </widget>
+     <widget class="QWidget" name="accountPage">
+      <layout class="QGridLayout" name="gridLayout_4">
+       <item row="0" column="0">
+        <layout class="QHBoxLayout" name="horizontalLayout">
+         <item>
+          <widget class="QRadioButton" name="imapAccount">
+           <property name="text">
+            <string>IMAP account</string>
+           </property>
+           <property name="checked">
+            <bool>true</bool>
+           </property>
+           <attribute name="buttonGroup">
+            <string notr="true">buttonGroup</string>
+           </attribute>
+          </widget>
+         </item>
+         <item>
+          <widget class="QRadioButton" name="pop3Account">
+           <property name="text">
+            <string>POP3 account</string>
+           </property>
+           <attribute name="buttonGroup">
+            <string notr="true">buttonGroup</string>
+           </attribute>
+          </widget>
+         </item>
+        </layout>
+       </item>
+       <item row="1" column="0">
+        <layout class="QGridLayout" name="gridLayout_2">
+         <item row="0" column="0">
+          <widget class="QLabel" name="label">
+           <property name="text">
+            <string>Incoming:</string>
+           </property>
+           <property name="alignment">
+            <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+           </property>
+          </widget>
+         </item>
+         <item row="0" column="1">
+          <widget class="QLabel" name="incommingLabel">
+           <property name="text">
+            <string comment="KDE::DoNotExtract">TextLabel</string>
+           </property>
+          </widget>
+         </item>
+         <item row="1" column="0">
+          <widget class="QLabel" name="label_2">
+           <property name="text">
+            <string>Outgoing:</string>
+           </property>
+           <property name="alignment">
+            <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+           </property>
+          </widget>
+         </item>
+         <item row="1" column="1">
+          <widget class="QLabel" name="outgoingLabel">
+           <property name="text">
+            <string comment="KDE::DoNotExtract">TextLabel</string>
+           </property>
+          </widget>
+         </item>
+         <item row="2" column="0">
+          <widget class="QLabel" name="label_3">
+           <property name="text">
+            <string>Username:</string>
+           </property>
+           <property name="alignment">
+            <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+           </property>
+          </widget>
+         </item>
+         <item row="2" column="1">
+          <widget class="QLabel" name="usernameLabel">
+           <property name="text">
+            <string comment="KDE::DoNotExtract">TextLabel</string>
+           </property>
+          </widget>
+         </item>
+        </layout>
+       </item>
+       <item row="2" column="0">
+        <layout class="QHBoxLayout" name="horizontalLayout_2">
+         <item>
+          <spacer name="horizontalSpacer">
+           <property name="orientation">
+            <enum>Qt::Horizontal</enum>
+           </property>
+           <property name="sizeHint" stdset="0">
+            <size>
+             <width>40</width>
+             <height>20</height>
+            </size>
+           </property>
+          </spacer>
+         </item>
+         <item>
+          <widget class="QPushButton" name="createAccountPb">
+           <property name="text">
+            <string>Create Account</string>
+           </property>
+          </widget>
+         </item>
+        </layout>
+       </item>
+      </layout>
+     </widget>
+    </widget>
+   </item>
+   <item>
+    <spacer name="verticalSpacer_2">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>20</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+  </layout>
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>KLineEdit</class>
+   <extends>QLineEdit</extends>
+   <header>klineedit.h</header>
+  </customwidget>
+  <customwidget>
+   <class>KPIMUtils::ProgressIndicatorLabel</class>
+   <extends>QLabel</extends>
+   <header location="global">kpimutils/progressindicatorlabel.h</header>
+   <container>1</container>
+  </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+ <buttongroups>
+  <buttongroup name="buttonGroup"/>
+ </buttongroups>
+</ui>
diff --git a/accountwizard/ui/providerpage.ui b/accountwizard/ui/providerpage.ui
new file mode 100644
index 0000000..7c80c67
--- /dev/null
+++ b/accountwizard/ui/providerpage.ui
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ProviderPage</class>
+ <widget class="QWidget" name="ProviderPage">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>172</height>
+   </rect>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <widget class="QLabel" name="label">
+     <property name="text">
+      <string>Select your provider from the list below or click advanced if your provider is not listed</string>
+     </property>
+     <property name="wordWrap">
+      <bool>true</bool>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="KFilterProxySearchLine" name="searchLine"/>
+   </item>
+   <item>
+    <widget class="QTreeView" name="listView">
+     <property name="rootIsDecorated">
+      <bool>false</bool>
+     </property>
+     <property name="uniformRowHeights">
+      <bool>true</bool>
+     </property>
+     <property name="sortingEnabled">
+      <bool>true</bool>
+     </property>
+     <property name="allColumnsShowFocus">
+      <bool>true</bool>
+     </property>
+     <property name="headerHidden">
+      <bool>true</bool>
+     </property>
+     <attribute name="headerShowSortIndicator" stdset="0">
+      <bool>true</bool>
+     </attribute>
+     <attribute name="headerShowSortIndicator" stdset="0">
+      <bool>true</bool>
+     </attribute>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>KFilterProxySearchLine</class>
+   <extends>QWidget</extends>
+   <header>kfilterproxysearchline.h</header>
+  </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/accountwizard/ui/setuppage.ui b/accountwizard/ui/setuppage.ui
new file mode 100644
index 0000000..deba775
--- /dev/null
+++ b/accountwizard/ui/setuppage.ui
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>SetupPage</class>
+ <widget class="QWidget" name="SetupPage">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>143</height>
+   </rect>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout_2">
+   <item>
+    <widget class="QStackedWidget" name="stackWidget">
+     <property name="currentIndex">
+      <number>0</number>
+     </property>
+     <widget class="QWidget" name="page">
+      <layout class="QVBoxLayout" name="verticalLayout">
+       <item>
+        <spacer name="verticalSpacer">
+         <property name="orientation">
+          <enum>Qt::Vertical</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>20</width>
+           <height>109</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+       <item>
+        <widget class="QLabel" name="progressLabel">
+         <property name="text">
+          <string>Setting up account...</string>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QProgressBar" name="progressBar"/>
+       </item>
+       <item>
+        <layout class="QHBoxLayout" name="horizontalLayout">
+         <item>
+          <spacer name="horizontalSpacer">
+           <property name="orientation">
+            <enum>Qt::Horizontal</enum>
+           </property>
+           <property name="sizeHint" stdset="0">
+            <size>
+             <width>40</width>
+             <height>20</height>
+            </size>
+           </property>
+          </spacer>
+         </item>
+         <item>
+          <widget class="KPushButton" name="detailsButton">
+           <property name="text">
+            <string>&Details...</string>
+           </property>
+          </widget>
+         </item>
+        </layout>
+       </item>
+       <item>
+        <spacer name="verticalSpacer_2">
+         <property name="orientation">
+          <enum>Qt::Vertical</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>20</width>
+           <height>74</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+      </layout>
+     </widget>
+     <widget class="QWidget" name="page_2">
+      <layout class="QVBoxLayout" name="verticalLayout_3">
+       <item>
+        <widget class="QListView" name="detailView"/>
+       </item>
+      </layout>
+     </widget>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>KPushButton</class>
+   <extends>QPushButton</extends>
+   <header>kpushbutton.h</header>
+  </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/accountwizard/ui/typepage.ui b/accountwizard/ui/typepage.ui
new file mode 100644
index 0000000..3358671
--- /dev/null
+++ b/accountwizard/ui/typepage.ui
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>TypePage</class>
+ <widget class="QWidget" name="TypePage">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>151</height>
+   </rect>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <widget class="QLabel" name="label">
+     <property name="text">
+      <string>Select which kind of account you want to create:</string>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="KFilterProxySearchLine" name="searchLine"/>
+   </item>
+   <item>
+    <widget class="QTreeView" name="listView">
+     <property name="rootIsDecorated">
+      <bool>false</bool>
+     </property>
+     <property name="uniformRowHeights">
+      <bool>true</bool>
+     </property>
+     <property name="sortingEnabled">
+      <bool>true</bool>
+     </property>
+     <property name="allColumnsShowFocus">
+      <bool>true</bool>
+     </property>
+     <property name="headerHidden">
+      <bool>true</bool>
+     </property>
+     <attribute name="headerShowSortIndicator" stdset="0">
+      <bool>true</bool>
+     </attribute>
+     <attribute name="headerShowSortIndicator" stdset="0">
+      <bool>true</bool>
+     </attribute>
+    </widget>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout">
+     <item>
+      <spacer name="horizontalSpacer">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QPushButton" name="ghnsButton">
+       <property name="text">
+        <string>Check for more on Internet</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>KFilterProxySearchLine</class>
+   <extends>QWidget</extends>
+   <header>kfilterproxysearchline.h</header>
+  </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/accountwizard/wizards/CMakeLists.txt b/accountwizard/wizards/CMakeLists.txt
new file mode 100644
index 0000000..798868e
--- /dev/null
+++ b/accountwizard/wizards/CMakeLists.txt
@@ -0,0 +1 @@
+add_subdirectory(tine20)
diff --git a/accountwizard/wizards/tine20/CMakeLists.txt b/accountwizard/wizards/tine20/CMakeLists.txt
new file mode 100644
index 0000000..f0d3b66
--- /dev/null
+++ b/accountwizard/wizards/tine20/CMakeLists.txt
@@ -0,0 +1,2 @@
+
+install ( FILES tine20wizard.desktop tine20wizard.es tine20wizard.ui DESTINATION ${DATA_INSTALL_DIR}/akonadi/accountwizard/tine20 ) 
diff --git a/accountwizard/wizards/tine20/Messages.sh b/accountwizard/wizards/tine20/Messages.sh
new file mode 100644
index 0000000..9738d4d
--- /dev/null
+++ b/accountwizard/wizards/tine20/Messages.sh
@@ -0,0 +1,4 @@
+#! /usr/bin/env bash
+$EXTRACTRC *.ui >> rc.cpp
+$XGETTEXT *.cpp -o $podir/accountwizard_tine20.pot
+$XGETTEXT -kqsTr *.es -j -o $podir/accountwizard_tine20.pot
diff --git a/accountwizard/wizards/tine20/tine20wizard.desktop b/accountwizard/wizards/tine20/tine20wizard.desktop
new file mode 100644
index 0000000..3395b9b
--- /dev/null
+++ b/accountwizard/wizards/tine20/tine20wizard.desktop
@@ -0,0 +1,91 @@
+[Desktop Entry]
+Name=Tine 2.0 Groupware Server
+Name[bs]=Tine 2.0 Groupware Server
+Name[ca]=Servidor de treball en grup Tine 2.0
+Name[ca at valencia]=Servidor de treball en grup Tine 2.0
+Name[cs]=Groupware Server Tine 2.0
+Name[da]=Tine 2.0 groupware-server
+Name[de]=Tine 2.0 Groupware-Server
+Name[el]=Tine 2.0 Groupware Server
+Name[es]=Servidor de trabajo en grupo Tine 2.0
+Name[et]=Tine 2.0 grupitöö server
+Name[fi]=Tine 2.0 -työryhmäpalvelin
+Name[fr]=Serveur de logiciels de collaboration Tine 2.0
+Name[ga]=Freastalaí Groupware Tine 2.0
+Name[gl]=Servidor de grupos Tine 2.0
+Name[hu]=Tine 2.0 csoportmunka-kiszolgáló
+Name[ia]=Servitor de Tine 2.0 Groupware
+Name[it]=Server di groupware Tine 2.0
+Name[kk]=Tine 2.0 топтық іс сервері
+Name[km]=ម៉ាស៊ីន​បម្រើ Tine ២.០ Groupware
+Name[ko]=Tine 2.0 그룹웨어 서버
+Name[lt]=Tine 2.0 grupinio darbo serveris
+Name[lv]=Tine 2.0 grupprogrammatūras serveris
+Name[nb]=Tine 2.0 gruppevare-tjener
+Name[nds]=Tine 2.0-Arbeitkoppel-Server
+Name[nl]=Tine 2.0 groupwareserver
+Name[pl]=Serwer Groupware Tine 2.0
+Name[pt]=Servidor de Groupware Tine 2.0
+Name[pt_BR]=Servidor groupware Tine 2.0
+Name[ru]=Сервер совместной работы Tine 2.0
+Name[sk]=Tine 2.0 Groupware Server
+Name[sl]=Strežnik Tine 2.0 za skupinsko delo
+Name[sr]=Тинеов групверски сервер
+Name[sr at ijekavian]=Тинеов групверски сервер
+Name[sr at ijekavianlatin]=Tineov grupverski server
+Name[sr at latin]=Tineov grupverski server
+Name[sv]=Tine 2.0 grupprogramserver
+Name[tr]=Tine 2.0 Groupware Sunucusu
+Name[uk]=Сервер групової роботи Tine 2.0
+Name[x-test]=xxTine 2.0 Groupware Serverxx
+Name[zh_CN]=Tine 2.0 群件服务器
+Name[zh_TW]=Tine 2.0 群組伺服器
+Icon=applications-internet
+Comment=Tine 2.0 Groupware Server
+Comment[bs]=Tine 2.0 Groupware Server
+Comment[ca]=Servidor de treball en grup Tine 2.0
+Comment[ca at valencia]=Servidor de treball en grup Tine 2.0
+Comment[cs]=Groupware Server Tine 2.0
+Comment[da]=Tine 2.0 groupware-server
+Comment[de]=Tine 2.0 Groupware-Server
+Comment[el]=Εξυπηρετητής Tine 2.0 Groupware
+Comment[es]=Servidor de trabajo en grupo Tine 2.0
+Comment[et]=Tine 2.0 grupitöö server
+Comment[fi]=Tine 2.0 -työryhmäpalvelin
+Comment[fr]=Serveur de logiciels de collaboration Tine 2.0
+Comment[ga]=Freastalaí Groupware Tine 2.0
+Comment[gl]=Servidor de grupos Tine 2.0
+Comment[hu]=Tine 2.0 csoportmunka-kiszolgáló
+Comment[ia]=Servitor de Tine 2.0 Groupware
+Comment[it]=Server di groupware Tine 2.0
+Comment[kk]=Tine 2.0 топтық іс сервері
+Comment[km]=ម៉ាស៊ីន​បម្រើ Tine ២.០ Groupware
+Comment[ko]=Tine 2.0 그룹웨어 서버
+Comment[lt]=Tine 2.0 grupinio darbo serveris
+Comment[lv]=Tine 2.0 grupprogrammatūras serveris
+Comment[nb]=Tine 2.0 gruppevare-tjener
+Comment[nds]=Tine 2.0-Arbeitkoppel-Server
+Comment[nl]=Tine 2.0 groupwareserver
+Comment[pl]=Serwer Groupware Tine 2.0
+Comment[pt]=Servidor de 'Groupware' Tine 2.0
+Comment[pt_BR]=Servidor groupware Tine 2.0
+Comment[ru]=Сервер совместной работы Tine 2.0
+Comment[sk]=Tine 2.0 Groupware Server
+Comment[sl]=Strežnik Tine 2.0 za skupinsko delo
+Comment[sr]=Тинеов групверски сервер
+Comment[sr at ijekavian]=Тинеов групверски сервер
+Comment[sr at ijekavianlatin]=Tineov grupverski server
+Comment[sr at latin]=Tineov grupverski server
+Comment[sv]=Tine 2.0 grupprogramserver
+Comment[tr]=Tine 2.0 Groupware Sunucusu
+Comment[uk]=Сервер групової роботи Tine 2.0
+Comment[x-test]=xxTine 2.0 Groupware Serverxx
+Comment[zh_CN]=Tine 2.0 群件服务器
+Comment[zh_TW]=Tine 2.0 群組伺服器
+
+[Wizard]
+Type=message/rfc822,text/directory,text/calendar
+Script=tine20wizard.es
+
+[Translate]
+Filename=accountwizard_tine20
diff --git a/accountwizard/wizards/tine20/tine20wizard.es b/accountwizard/wizards/tine20/tine20wizard.es
new file mode 100644
index 0000000..2c79999
--- /dev/null
+++ b/accountwizard/wizards/tine20/tine20wizard.es
@@ -0,0 +1,177 @@
+/*
+    Copyright (c) 2012 Volker Krause <vkrause at kde.org>
+    Copyright (c) 2010 Casey Link <unnamedrambler at gmail.com>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+// add this function to trim user input of whitespace when needed
+String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ""); };
+
+var page = Dialog.addPage( "tine20wizard.ui", qsTr("Personal Settings") );
+var userChangedServerAddress = false;
+
+page.widget().nameEdit.text = SetupManager.name()
+page.widget().emailEdit.text = SetupManager.email()
+page.widget().passwordEdit.text = SetupManager.password()
+guessServerName();
+
+if ( SetupManager.personalDataAvailable() ) {
+  page.widget().nameEdit.visible = false;
+  page.widget().nameLabel.visible = false;
+  page.widget().emailEdit.visible = false;
+  page.widget().emailLabel.visible = false;
+  page.widget().passwordEdit.visible = false;
+  page.widget().passwordLabel.visible = false;
+}
+
+
+function guessServerName()
+{
+  if ( userChangedServerAddress == true ) {
+    return;
+  }
+
+  var email = page.widget().emailEdit.text;
+  var pos = email.indexOf( "@" );
+  if ( pos >= 0 && (pos + 1) < email.length ) {
+    var server = email.slice( pos + 1, email.length );
+    page.widget().serverAddress.text = server;
+  }
+
+  userChangedServerAddress = false;
+}
+
+function emailChanged( arg )
+{
+  validateInput();
+  guessServerName();
+}
+
+function serverChanged( arg )
+{
+  validateInput();
+  if ( arg == "" ) {
+    userChangedServerAddress = false;
+  } else {
+    userChangedServerAddress = true;
+  }
+}
+
+function validateInput()
+{
+  if ( page.widget().serverAddress.text.trim() == "" || page.widget().emailEdit.text.trim() == "" ) {
+    page.setValid( false );
+  } else {
+    page.setValid( true );
+  }
+}
+
+// stage 1, setup identity and run imap server test
+// stage 2, smtp setup (no server test) and Dav resources
+var stage = 1;
+var identity; // global so it can be accesed in setup and testOk
+
+function setup()
+{
+  print("setup() "  + stage);
+  var serverAddress = page.widget().serverAddress.text.trim();
+  if ( stage == 1 ) {
+    SetupManager.openWallet();
+
+    identity = SetupManager.createIdentity();
+    identity.setEmail( page.widget().emailEdit.text );
+    identity.setRealName( page.widget().nameEdit.text );
+
+    ServerTest.test( serverAddress, "imap" );
+  } else { // stage 2
+    var smtp = SetupManager.createTransport( "smtp" );
+    smtp.setName( serverAddress );
+    smtp.setHost( serverAddress );
+    smtp.setPort( 25 );
+    smtp.setEncryption( "TLS" );
+    smtp.setAuthenticationType( "plain" );
+    smtp.setUsername( page.widget().emailEdit.text );
+    smtp.setPassword( page.widget().passwordEdit.text );
+    identity.setTransport( smtp );
+
+    var dav = SetupManager.createResource( "akonadi_davgroupware_resource" );
+    print("dav: " + dav );
+    try {
+    dav.setName( "Tine 2.0" );
+    dav.setOption( "DisplayName", "Tine 2.0" );
+    dav.setOption( "RefreshInterval", 60 );
+    dav.setOption( "RemoteUrls", ["$default$|CalDav|https://" + page.widget().serverAddress.text.trim() + "/calendars", 
+                    "$default$|CardDav|https://" + page.widget().serverAddress.text.trim() + "/addressbooks"] );
+    dav.setOption( "DefaultUsername", page.widget().emailEdit.text.trim() );
+    } catch (e) { print(e); }
+
+    print("pre-exec");
+    SetupManager.execute();
+    print("post-exec");
+  }
+}
+
+function testResultFail()
+{
+  testOk( -1 );
+}
+
+function testOk( arg )
+{
+    print("testOk arg =", arg);
+    var imapRes = SetupManager.createResource( "akonadi_imap_resource" );
+    imapRes.setName( page.widget().serverAddress.text.trim() );
+    imapRes.setOption( "ImapServer", page.widget().serverAddress.text.trim() );
+    imapRes.setOption( "UserName", page.widget().emailEdit.text.trim() );
+    imapRes.setOption( "Password", page.widget().passwordEdit.text.trim() );
+    imapRes.setOption( "UseDefaultIdentity", false );
+    imapRes.setOption( "AccountIdentity", identity.uoid() );
+    imapRes.setOption( "DisconnectedModeEnabled", true );
+    imapRes.setOption( "IntervalCheckTime", 60 );
+    imapRes.setOption( "SubscriptionEnabled", true );
+    imapRes.setOption( "SieveSupport", false );
+    imapRes.setOption( "Authentication", 7 ); // ClearText
+    if ( arg == "ssl" ) { 
+      // The ENUM used for authentication (in the imap resource only)
+      imapRes.setOption( "Safety", "SSL" ); // SSL/TLS
+      imapRes.setOption( "ImapPort", 993 );
+    } else if ( arg == "tls" ) { // tls is really STARTTLS
+      imapRes.setOption( "Safety", "STARTTLS" );  // STARTTLS
+      imapRes.setOption( "ImapPort", 143 );
+    } else if ( arg == "none" ) {
+      imapRes.setOption( "Safety", "NONE" );  // No encryption
+      imapRes.setOption( "ImapPort", 143 );
+    } else {
+      // safe default fallback in case server test failed
+      imapRes.setOption( "Safety", "STARTTLS" );
+      imapRes.setOption( "ImapPort", 143 );
+    }
+    stage = 2;
+    setup();
+}
+
+try {
+  ServerTest.testFail.connect(testResultFail);
+  ServerTest.testResult.connect(testOk);
+  page.widget().emailEdit.textChanged.connect(emailChanged);
+  page.widget().serverAddress.textChanged.connect(serverChanged);
+  page.pageLeftNext.connect(setup);
+} catch (e) {
+  print(e);
+}
+
+validateInput();
diff --git a/accountwizard/wizards/tine20/tine20wizard.ui b/accountwizard/wizards/tine20/tine20wizard.ui
new file mode 100644
index 0000000..db2d106
--- /dev/null
+++ b/accountwizard/wizards/tine20/tine20wizard.ui
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>tine20Wizard</class>
+ <widget class="QWidget" name="tine20Wizard">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>368</width>
+    <height>124</height>
+   </rect>
+  </property>
+  <layout class="QFormLayout" name="formLayout">
+   <property name="fieldGrowthPolicy">
+    <enum>QFormLayout::ExpandingFieldsGrow</enum>
+   </property>
+   <item row="0" column="0">
+    <widget class="QLabel" name="nameLabel">
+     <property name="text">
+      <string>&Name:</string>
+     </property>
+     <property name="buddy">
+      <cstring>nameEdit</cstring>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="1">
+    <widget class="KLineEdit" name="nameEdit"/>
+   </item>
+   <item row="1" column="0">
+    <widget class="QLabel" name="emailLabel">
+     <property name="text">
+      <string>&Email:</string>
+     </property>
+     <property name="buddy">
+      <cstring>emailEdit</cstring>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="1">
+    <widget class="KLineEdit" name="emailEdit"/>
+   </item>
+   <item row="2" column="0">
+    <widget class="QLabel" name="passwordLabel">
+     <property name="text">
+      <string>&Password:</string>
+     </property>
+     <property name="buddy">
+      <cstring>passwordEdit</cstring>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="1">
+    <widget class="KLineEdit" name="passwordEdit">
+     <property name="echoMode">
+      <enum>QLineEdit::Password</enum>
+     </property>
+    </widget>
+   </item>
+   <item row="3" column="0">
+    <widget class="QLabel" name="label_2">
+     <property name="text">
+      <string>&Server Address:</string>
+     </property>
+     <property name="buddy">
+      <cstring>serverAddress</cstring>
+     </property>
+    </widget>
+   </item>
+   <item row="3" column="1">
+    <widget class="KLineEdit" name="serverAddress"/>
+   </item>
+  </layout>
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>KLineEdit</class>
+   <extends>QLineEdit</extends>
+   <header>klineedit.h</header>
+  </customwidget>
+ </customwidgets>
+ <tabstops>
+  <tabstop>serverAddress</tabstop>
+ </tabstops>
+ <resources/>
+ <connections/>
+</ui>


commit 552a48be473d45c091707657c25ceb92dd05e214
Author: Christian Mollekopf <chrigi_1 at fastmail.fm>
Date:   Fri Oct 24 17:45:57 2014 +0200

    IncidenceEditor: replaced categories with Akonadi::Tags
    
    We now always load the item from storage initially (to make sure we have tags available).

diff --git a/incidenceeditor-ng/combinedincidenceeditor.cpp b/incidenceeditor-ng/combinedincidenceeditor.cpp
index 91c8a99..db4153b 100644
--- a/incidenceeditor-ng/combinedincidenceeditor.cpp
+++ b/incidenceeditor-ng/combinedincidenceeditor.cpp
@@ -113,6 +113,31 @@ void CombinedIncidenceEditor::load( const KCalCore::Incidence::Ptr &incidence )
   emit dirtyStatusChanged( false );
 }
 
+void CombinedIncidenceEditor::load( const Akonadi::Item &item )
+{
+  foreach ( IncidenceEditor *editor, mCombinedEditors ) {
+    // load() may fire dirtyStatusChanged(), reset mDirtyEditorCount to make sure
+    // we don't end up with an invalid dirty count.
+    editor->blockSignals( true );
+    editor->load( item );
+    editor->blockSignals( false );
+
+    if ( editor->isDirty() ) {
+      // We are going to crash due to assert. Print some useful info before crashing.
+      kWarning() << "Faulty editor was " << editor->objectName();
+      // kWarning() << "Incidence " << ( incidence ? incidence->uid() : "null" );
+
+      editor->printDebugInfo();
+
+      Q_ASSERT_X( false, "load", "editor shouldn't be dirty" );
+    }
+  }
+
+  mWasDirty = false;
+  mDirtyEditorCount = 0;
+  emit dirtyStatusChanged( false );
+}
+
 void CombinedIncidenceEditor::save( const KCalCore::Incidence::Ptr &incidence )
 {
   foreach ( IncidenceEditor *editor, mCombinedEditors ) {
@@ -120,3 +145,10 @@ void CombinedIncidenceEditor::save( const KCalCore::Incidence::Ptr &incidence )
   }
 }
 
+void CombinedIncidenceEditor::save( Akonadi::Item &item )
+{
+  foreach ( IncidenceEditor *editor, mCombinedEditors ) {
+    editor->save( item );
+  }
+}
+
diff --git a/incidenceeditor-ng/combinedincidenceeditor.h b/incidenceeditor-ng/combinedincidenceeditor.h
index 63839d9..f299d9e 100644
--- a/incidenceeditor-ng/combinedincidenceeditor.h
+++ b/incidenceeditor-ng/combinedincidenceeditor.h
@@ -25,6 +25,7 @@
 #include "incidenceeditor-ng.h"
 
 #include <KMessageWidget>
+#include <Akonadi/Item>
 
 namespace IncidenceEditorNG {
 
@@ -59,7 +60,9 @@ class INCIDENCEEDITORS_NG_EXPORT CombinedIncidenceEditor : public IncidenceEdito
      * implementation too.
      */
     virtual void load( const KCalCore::Incidence::Ptr &incidence );
+    virtual void load( const Akonadi::Item &item );
     virtual void save( const KCalCore::Incidence::Ptr &incidence );
+    virtual void save( Akonadi::Item &item );
 
   private Q_SLOTS:
     void handleDirtyStatusChange( bool isDirty );
diff --git a/incidenceeditor-ng/dialogdesktop.ui b/incidenceeditor-ng/dialogdesktop.ui
index fa610b2..00a2fb4 100644
--- a/incidenceeditor-ng/dialogdesktop.ui
+++ b/incidenceeditor-ng/dialogdesktop.ui
@@ -578,7 +578,7 @@
      <item row="12" column="0" colspan="2">
       <widget class="KTabWidget" name="mTabWidget">
        <property name="currentIndex">
-        <number>2</number>
+        <number>0</number>
        </property>
        <widget class="QWidget" name="mGeneralTab">
         <attribute name="title">
@@ -586,7 +586,7 @@
         </attribute>
         <layout class="QGridLayout" name="gridLayout_9">
          <item row="2" column="1">
-          <widget class="KPIM::TagWidget" name="mTagWidget" native="true"/>
+          <widget class="Akonadi::TagWidget" name="mTagWidget" native="true"/>
          </item>
          <item row="2" column="2">
           <widget class="QLabel" name="mSecrecyLabel">
@@ -1647,9 +1647,9 @@
    <header>calendarsupport/messagewidget.h</header>
   </customwidget>
   <customwidget>
-   <class>KPIM::TagWidget</class>
+   <class>Akonadi::TagWidget</class>
    <extends>QWidget</extends>
-   <header>libkdepim/widgets/tagwidgets.h</header>
+   <header location="global">akonadi/tagwidget.h</header>
    <container>1</container>
   </customwidget>
  </customwidgets>
diff --git a/incidenceeditor-ng/editoritemmanager.cpp b/incidenceeditor-ng/editoritemmanager.cpp
index 20ddc7e..0a022a7 100644
--- a/incidenceeditor-ng/editoritemmanager.cpp
+++ b/incidenceeditor-ng/editoritemmanager.cpp
@@ -31,6 +31,7 @@
 #include <Akonadi/ItemMoveJob>
 #include <Akonadi/Monitor>
 #include <Akonadi/Session>
+#include <Akonadi/TagFetchScope>
 
 #include <KJob>
 #include <KLocalizedString>
@@ -73,14 +74,17 @@ class ItemEditorPrivate
 
     void setupMonitor();
     void moveJobFinished( KJob *job );
+    void setItem( const Akonadi::Item &item );
 };
 
 ItemEditorPrivate::ItemEditorPrivate( Akonadi::IncidenceChanger *changer, EditorItemManager *qq )
-  : q_ptr( qq ), mItemMonitor( 0 ), mIsCounterProposal( false )
+  : q_ptr( qq ), /* mItemMonitor( 0 ),  */mIsCounterProposal( false )
   , currentAction(EditorItemManager::None)
 {
   mFetchScope.fetchFullPayload();
   mFetchScope.setAncestorRetrieval( Akonadi::ItemFetchScope::Parent );
+  mFetchScope.setFetchTags( true );
+  mFetchScope.tagFetchScope().setFetchIdOnly(false);
 
   mChanger = changer ? changer : new Akonadi::IncidenceChanger( new IndividualMailComponentFactory(qq), qq );
 
@@ -127,7 +131,7 @@ void ItemEditorPrivate::itemFetchResult( KJob *job )
 
   Akonadi::Item item = fetchJob->items().first();
   if ( mItemUi->hasSupportedPayload( item ) ) {
-    q->load( item );
+    setItem( item );
     if ( action != EditorItemManager::None ) {
       // Finally enable ok/apply buttons, we've finished loading
       emit q->itemSaveFinished( action );
@@ -137,6 +141,15 @@ void ItemEditorPrivate::itemFetchResult( KJob *job )
   }
 }
 
+void ItemEditorPrivate::setItem( const Akonadi::Item &item )
+{
+  Q_ASSERT( item.hasPayload() );
+  mPrevItem = item;
+  mItem = item;
+  mItemUi->load( item );
+  setupMonitor();
+}
+
 void ItemEditorPrivate::itemMoveResult( KJob *job )
 {
   Q_ASSERT( job );
@@ -295,16 +308,10 @@ void EditorItemManager::load( const Akonadi::Item &item )
 {
   Q_D( ItemEditor );
 
-  if ( item.hasPayload() ) {
-    d->mPrevItem = item;
-    d->mItem = item;
-    d->mItemUi->load( item );
-    d->setupMonitor();
-  } else {
-    Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob( item, this );
-    job->setFetchScope( d->mFetchScope );
-    connect( job, SIGNAL(result(KJob*)), SLOT(itemFetchResult(KJob*)) );
-  }
+  //We fetch anyways to make sure we have everything required including tags
+  Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob( item, this );
+  job->setFetchScope( d->mFetchScope );
+  connect( job, SIGNAL(result(KJob*)), SLOT(itemFetchResult(KJob*)) );
 }
 
 void EditorItemManager::save()
diff --git a/incidenceeditor-ng/incidencecategories.cpp b/incidenceeditor-ng/incidencecategories.cpp
index 4169d36..8593d62 100644
--- a/incidenceeditor-ng/incidencecategories.cpp
+++ b/incidenceeditor-ng/incidencecategories.cpp
@@ -22,11 +22,7 @@
 
 #include "editorconfig.h"
 
-#ifdef KDEPIM_MOBILE_UI
-  #include "ui_dialogmoremobile.h"
-#else
-  #include "ui_dialogdesktop.h"
-#endif
+#include "ui_dialogdesktop.h"
 
 #include <libkdepim/widgets/tagwidgets.h>
 #include <KConfigSkeleton>
@@ -36,88 +32,64 @@
 
 using namespace IncidenceEditorNG;
 
-#ifdef KDEPIM_MOBILE_UI
-IncidenceCategories::IncidenceCategories( Ui::EventOrTodoMore *ui )
-#else
 IncidenceCategories::IncidenceCategories( Ui::EventOrTodoDesktop *ui )
-#endif
   : mUi( ui )
 {
   setObjectName( "IncidenceCategories" );
 
-#ifdef KDEPIM_MOBILE_UI
-connect( mUi->mSelectCategoriesButton, SIGNAL(clicked()),
-          SLOT(selectCategories()) );
-#else
-  connect( mUi->mTagWidget, SIGNAL(selectionChanged(QStringList)),
-          SLOT(onSelectionChanged(QStringList)) );
-#endif
+  connect( mUi->mTagWidget, SIGNAL(selectionChanged(Akonadi::Tag::List)),
+          SLOT(onSelectionChanged(Akonadi::Tag::List)) );
 }
 
-void IncidenceCategories::onSelectionChanged(const QStringList &list)
+void IncidenceCategories::onSelectionChanged(const Akonadi::Tag::List &list)
 {
-  mSelectedCategories = list;
+  mSelectedTags = list;
+  mDirty = true;
   checkDirtyStatus();
 }
 
 void IncidenceCategories::load( const KCalCore::Incidence::Ptr &incidence )
 {
   mLoadedIncidence = incidence;
+  mDirty = false;
   if ( mLoadedIncidence ) {
     checkForUnknownCategories( mLoadedIncidence->categories() );
-    setCategories( mLoadedIncidence->categories() );
   } else {
-    setCategories( QStringList() );
+    mSelectedTags.clear();
   }
 
   mWasDirty = false;
 }
 
+void IncidenceCategories::load( const Akonadi::Item &item )
+{
+  mSelectedTags = item.tags();
+  mUi->mTagWidget->setSelection(item.tags());
+}
+
 void IncidenceCategories::save( const KCalCore::Incidence::Ptr &incidence )
 {
   Q_ASSERT( incidence );
   incidence->setCategories( categories() );
 }
 
-QStringList IncidenceCategories::categories() const
+void IncidenceCategories::save( Akonadi::Item &item )
 {
-  return mSelectedCategories;
+  item.setTags(mSelectedTags);
 }
 
-bool IncidenceCategories::isDirty() const
-{
-  // If no Incidence was loaded, mSelectedCategories should be empty.
-  bool categoriesEqual = categories().isEmpty();
-
-  if ( mLoadedIncidence ) { // There was an Incidence loaded
-    categoriesEqual =
-      ( mLoadedIncidence->categories().toSet() == categories().toSet() );
-  }
-  return !categoriesEqual;
-}
-
-void IncidenceCategories::selectCategories()
+QStringList IncidenceCategories::categories() const
 {
-  QPointer<KPIM::TagSelectionDialog> dialog( new KPIM::TagSelectionDialog() );
-  dialog->setSelection( categories() );
-  dialog->exec();
-
-  if (dialog) {
-    setCategories( dialog->selection() );
-    delete dialog;
+  QStringList list;
+  Q_FOREACH (const Akonadi::Tag &tag, mSelectedTags) {
+    list << tag.name();
   }
+  return list;
 }
 
-void IncidenceCategories::setCategories( const QStringList &categories )
+bool IncidenceCategories::isDirty() const
 {
-  mSelectedCategories = categories;
-#ifdef KDEPIM_MOBILE_UI
-  mUi->mCategoriesLabel->setText( mSelectedCategories.join( QLatin1String( "," ) ) );
-#else
-  mUi->mTagWidget->setSelection(categories);
-#endif
-
-  checkDirtyStatus();
+  return mDirty;
 }
 
 void IncidenceCategories::printDebugInfo() const
@@ -128,12 +100,9 @@ void IncidenceCategories::printDebugInfo() const
 
 void IncidenceCategories::checkForUnknownCategories( const QStringList &categoriesToCheck )
 {
-#ifndef KDEPIM_MOBILE_UI // desktop only
   foreach ( const QString &category, categoriesToCheck ) {
     Akonadi::TagCreateJob *tagCreateJob = new Akonadi::TagCreateJob(Akonadi::Tag(category), this);
     tagCreateJob->setMergeIfExisting(true);
+    //TODO add the missing tags to the item and add them to the list of selected tags in the widget
   }
-#else
-  Q_UNUSED( categoriesToCheck );
-#endif
 }
diff --git a/incidenceeditor-ng/incidencecategories.h b/incidenceeditor-ng/incidencecategories.h
index b2e408f..bb25321 100644
--- a/incidenceeditor-ng/incidencecategories.h
+++ b/incidenceeditor-ng/incidencecategories.h
@@ -34,19 +34,12 @@ class INCIDENCEEDITORS_NG_EXPORT IncidenceCategories : public IncidenceEditor
 {
   Q_OBJECT
   public:
-#ifdef KDEPIM_MOBILE_UI
-    explicit IncidenceCategories( Ui::EventOrTodoMore *ui );
-#else
     explicit IncidenceCategories( Ui::EventOrTodoDesktop *ui );
-#endif
 
     virtual void load( const KCalCore::Incidence::Ptr &incidence );
+    virtual void load( const Akonadi::Item &item );
     virtual void save( const KCalCore::Incidence::Ptr &incidence );
-
-    /**
-     * Sets the currently selected categories.
-     */
-    void setCategories( const QStringList &categories );
+    virtual void save( Akonadi::Item &item );
 
     /**
      * Returns the list of currently selected categories.
@@ -58,8 +51,7 @@ class INCIDENCEEDITORS_NG_EXPORT IncidenceCategories : public IncidenceEditor
     void printDebugInfo() const;
 
   private slots:
-    void selectCategories();
-    void onSelectionChanged(const QStringList &);
+    void onSelectionChanged(const Akonadi::Tag::List &);
 
   private:
 
@@ -71,12 +63,9 @@ class INCIDENCEEDITORS_NG_EXPORT IncidenceCategories : public IncidenceEditor
      * */
     void checkForUnknownCategories( const QStringList &categoriesToCheck );
 
-    QStringList mSelectedCategories;
-#ifdef KDEPIM_MOBILE_UI
-    Ui::EventOrTodoMore *mUi;
-#else
     Ui::EventOrTodoDesktop *mUi;
-#endif
+    Akonadi::Tag::List mSelectedTags;
+    bool mDirty;
 };
 
 }
diff --git a/incidenceeditor-ng/incidencedialog.cpp b/incidenceeditor-ng/incidencedialog.cpp
index 440fb54..13e0227 100644
--- a/incidenceeditor-ng/incidencedialog.cpp
+++ b/incidenceeditor-ng/incidencedialog.cpp
@@ -320,6 +320,7 @@ void IncidenceDialogPrivate::loadTemplate( const QString &templateName )
   // We add a custom property so that some fields aren't loaded, dates for example
   newInc->setCustomProperty( QByteArray("kdepim"), "isTemplate", "true");
   mEditor->load( newInc );
+  mEditor->load( newInc );
   newInc->removeCustomProperty( QByteArray(), "isTemplate");
 }
 
@@ -488,6 +489,7 @@ void IncidenceDialogPrivate::handleItemSaveFinish( EditorItemManager::SaveAction
     // Now the item is succesfull saved, reload it in the editor in order to
     // reset the dirty status of the editor.
     mEditor->load( item.payload<KCalCore::Incidence::Ptr>() );
+    mEditor->load( item );
 
     // Set the buttons to a reasonable state as well (ok and apply should be
     // disabled at this point).
@@ -546,6 +548,7 @@ void IncidenceDialogPrivate::load( const Akonadi::Item &item )
   }
 
   mEditor->load( CalendarSupport::incidence( item ) );
+  mEditor->load( item );
 
   const KCalCore::Incidence::Ptr incidence = CalendarSupport::incidence( item );
   const QStringList allEmails = IncidenceEditorNG::EditorConfig::instance()->allEmails();
@@ -611,6 +614,7 @@ Akonadi::Item IncidenceDialogPrivate::save( const Akonadi::Item &item )
   newIncidence->setRelatedTo( incidenceInEditor->relatedTo() );
 
   mEditor->save( newIncidence );
+  mEditor->save( result );
 
   // TODO: Remove this once we support moving of events/todo's
   mCalSelector->setEnabled( false );
diff --git a/incidenceeditor-ng/incidenceeditor-ng.h b/incidenceeditor-ng/incidenceeditor-ng.h
index f7c850e..2c74855 100644
--- a/incidenceeditor-ng/incidenceeditor-ng.h
+++ b/incidenceeditor-ng/incidenceeditor-ng.h
@@ -24,7 +24,7 @@
 #include "incidenceeditors-ng_export.h"
 
 #include <KCalCore/Incidence>
-
+#include <Akonadi/Item>
 
 namespace IncidenceEditorNG {
 
@@ -45,11 +45,15 @@ class INCIDENCEEDITORS_NG_EXPORT IncidenceEditor : public QObject
      * incidence is kept for comparing with the current values of the editor.
      */
     virtual void load( const KCalCore::Incidence::Ptr &incidence ) = 0;
+    /// This was introduced to replace categories with Akonadi::Tags
+    virtual void load( const Akonadi::Item &item );
 
     /**
      * Store the current values of the editor into @param incidince.
      */
     virtual void save( const KCalCore::Incidence::Ptr &incidence ) = 0;
+    /// This was introduced to replace categories with Akonadi::Tags
+    virtual void save( Akonadi::Item &item );
 
     /**
      * Returns whether or not the current values in the editor differ from the
diff --git a/incidenceeditor-ng/incidenceeditor.cpp b/incidenceeditor-ng/incidenceeditor.cpp
index cc4efcb..906c4ec 100644
--- a/incidenceeditor-ng/incidenceeditor.cpp
+++ b/incidenceeditor-ng/incidenceeditor.cpp
@@ -83,4 +83,14 @@ void IncidenceEditor::printDebugInfo() const
   // implement this in derived classes.
 }
 
+void IncidenceEditor::load( const Akonadi::Item &item )
+{
+    Q_UNUSED(item);
+}
+
+void IncidenceEditor::save( Akonadi::Item &item )
+{
+    Q_UNUSED(item);
+}
+
 #include "moc_incidenceeditor-ng.cpp"
diff --git a/libkdepim/widgets/tagwidgets.cpp b/libkdepim/widgets/tagwidgets.cpp
index 9c9be6d..f2e4a59 100644
--- a/libkdepim/widgets/tagwidgets.cpp
+++ b/libkdepim/widgets/tagwidgets.cpp
@@ -50,6 +50,7 @@ void TagWidget::onSelectionChanged(const Akonadi::Tag::List &tags)
         mCachedTagNames << tag.name();
     }
     emit selectionChanged(mCachedTagNames);
+    emit selectionChanged(tags);
 }
 
 void TagWidget::setSelection(const QStringList &tagNames)
@@ -118,6 +119,11 @@ QStringList TagSelectionDialog::selection() const
     return list;
 }
 
+Akonadi::Tag::List TagSelectionDialog::tagSelection() const
+{
+    return Akonadi::TagSelectionDialog::selection();
+}
+
 class MatchingCheckableProxyModel : public KCheckableProxyModel
 {
 public:
diff --git a/libkdepim/widgets/tagwidgets.h b/libkdepim/widgets/tagwidgets.h
index a5ad100..9b58682 100644
--- a/libkdepim/widgets/tagwidgets.h
+++ b/libkdepim/widgets/tagwidgets.h
@@ -40,8 +40,10 @@ public:
     explicit TagWidget(QWidget* parent = 0);
     void setSelection(const QStringList &);
     QStringList selection() const;
+
 signals:
     void selectionChanged(const QStringList &);
+    void selectionChanged(const Akonadi::Tag::List &);
 
 private slots:
     void onTagCreated(KJob*);
@@ -60,6 +62,7 @@ public:
     explicit TagSelectionDialog(QWidget* parent = 0);
     void setSelection(const QStringList &);
     QStringList selection() const;
+    Akonadi::Tag::List tagSelection() const;
 
 private slots:
     void onTagCreated(KJob*);




More information about the commits mailing list