Branch 'kolab/integration/4.13.0' - 4 commits - accountwizard/CMakeLists.txt accountwizard/ispdb accountwizard/ldap.cpp accountwizard/ldap.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 resources/kolab resources/kolabproxy
Sandro Knauß
knauss at kolabsys.com
Mon Aug 11 13:48:36 CEST 2014
accountwizard/CMakeLists.txt | 7
accountwizard/ispdb/CMakeLists.txt | 6
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 | 159 +++++++++++-
accountwizard/ispdb/ispdb.h | 97 +++++++
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 | 80 ++++++
accountwizard/ldap.h | 21 +
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 | 20 +
accountwizard/setupmanager.h | 1
resources/kolab/CMakeLists.txt | 2
resources/kolab/wizard/CMakeLists.txt | 5
resources/kolab/wizard/Messages.sh | 4
resources/kolab/wizard/kolabwizard.desktop | 101 ++++++++
resources/kolab/wizard/kolabwizard.es | 224 ++++++++++++++++++
resources/kolab/wizard/kolabwizard.ui | 98 +++++++
resources/kolab/wizard/kolabwizard2.ui | 188 +++++++++++++++
resources/kolabproxy/wizard/CMakeLists.txt | 2
resources/kolabproxy/wizard/kolabwizard.desktop | 96 -------
40 files changed, 3016 insertions(+), 121 deletions(-)
New commits:
commit 459401ec91becaab3e4ab5519dc559d07c00c72a
Author: Sandro Knauà <mail at sandroknauss.de>
Date: Wed Jul 16 19:25:46 2014 +0200
adding setupwizard to kolab resource
REVIEW: 119487
diff --git a/resources/kolab/CMakeLists.txt b/resources/kolab/CMakeLists.txt
index 0e8e237..a787615 100644
--- a/resources/kolab/CMakeLists.txt
+++ b/resources/kolab/CMakeLists.txt
@@ -59,3 +59,5 @@ target_link_libraries(akonadi_kolab_resource
install(FILES kolabresource.desktop DESTINATION "${CMAKE_INSTALL_PREFIX}/share/akonadi/agents")
install(TARGETS akonadi_kolab_resource ${INSTALL_TARGETS_DEFAULT_ARGS})
+
+add_subdirectory(wizard)
\ No newline at end of file
diff --git a/resources/kolab/wizard/CMakeLists.txt b/resources/kolab/wizard/CMakeLists.txt
new file mode 100644
index 0000000..a3e4d76
--- /dev/null
+++ b/resources/kolab/wizard/CMakeLists.txt
@@ -0,0 +1,5 @@
+
+install(
+ FILES kolabwizard.desktop kolabwizard.es kolabwizard.ui kolabwizard2.ui
+ DESTINATION ${DATA_INSTALL_DIR}/akonadi/accountwizard/kolab
+)
diff --git a/resources/kolab/wizard/Messages.sh b/resources/kolab/wizard/Messages.sh
new file mode 100644
index 0000000..a41341f
--- /dev/null
+++ b/resources/kolab/wizard/Messages.sh
@@ -0,0 +1,4 @@
+#! /usr/bin/env bash
+$EXTRACTRC *.ui >> rc.cpp
+$XGETTEXT *.cpp -o $podir/accountwizard_kolab.pot
+$XGETTEXT -kqsTr *.es -j -o $podir/accountwizard_kolab.pot
diff --git a/resources/kolab/wizard/kolabwizard.desktop b/resources/kolab/wizard/kolabwizard.desktop
new file mode 100644
index 0000000..367dcd4
--- /dev/null
+++ b/resources/kolab/wizard/kolabwizard.desktop
@@ -0,0 +1,101 @@
+[Desktop Entry]
+Name=Kolab Groupware Server
+Name[bg]=СÑÑвÑÑ Kolab Groupware
+Name[bs]=Server kolaborativnog softvera
+Name[ca]=Servidor de treball en grup Kolab
+Name[ca at valencia]=Servidor de treball en grup Kolab
+Name[cs]=Kolab Groupware server
+Name[da]=Kolab groupware-server
+Name[de]=Kolab Groupware-Server
+Name[el]=ÎξÏ
ÏηÏεÏηÏÎ®Ï Groupware Kolab
+Name[en_GB]=Kolab Groupware Server
+Name[es]=Servidor de trabajo en grupo Kolab
+Name[et]=Kolabi grupitöö server
+Name[fi]=Kolab-työryhmäpalvelin
+Name[fr]=Serveur de logiciels de collaboration Kolab
+Name[ga]=Freastalaà Groupware Kolab
+Name[gl]=Servidor de Traballo en Grupo Kolab
+Name[hu]=Kolab csoportmunka-kiszolgáló
+Name[ia]=Servitor de Kolab Groupware
+Name[it]=Server di groupware Kolab
+Name[ja]=Kolab ã°ã«ã¼ãã¦ã§ã¢ãµã¼ã
+Name[kk]=Kolab ÑопÑÑÒ ÑÑ ÑеÑвеÑÑ
+Name[km]=ááá¶ááá¸áâááááá¾ Kolab Groupware
+Name[ko]=Kolab 그룹ì¨ì´ ìë²
+Name[lt]=Kolab grupinio darbo serveris
+Name[lv]=Kolab grupdarba serveris
+Name[nb]=Kolab groupware-tjener
+Name[nds]=Kolab-Arbeitkoppelserver
+Name[nl]=Kolab groupwareserver
+Name[nn]=Kolab Groupware-tenar
+Name[pl]=Serwer Groupware Kolab
+Name[pt]=Servidor de Groupware Kolab
+Name[pt_BR]=Servidor groupware Kolab
+Name[ro]=Server Kolab Groupware
+Name[ru]=СеÑÐ²ÐµÑ ÑовмеÑÑной ÑабоÑÑ Kolab
+Name[sk]=Groupware Server Kolab
+Name[sl]=Strežnik za skupinsko delo Kolab
+Name[sr]=Ðолабов гÑÑпвеÑÑки ÑеÑвеÑ
+Name[sr at ijekavian]=Ðолабов гÑÑпвеÑÑки ÑеÑвеÑ
+Name[sr at ijekavianlatin]=Kolabov grupverski server
+Name[sr at latin]=Kolabov grupverski server
+Name[sv]=Kolab grupprogramserver
+Name[tr]=Kolab Groupware Sunucusu
+Name[uk]=СеÑÐ²ÐµÑ Ð³ÑÑÐ¿Ð¾Ð²Ð¾Ñ ÑобоÑи Kolab
+Name[x-test]=xxKolab Groupware Serverxx
+Name[zh_CN]=Kolab 群件æå¡å¨
+Name[zh_TW]=Kolab 群çµä¼ºæå¨
+Icon=kolab
+Comment=Kolab Groupware Server
+Comment[bg]=СÑÑвÑÑ Kolab Groupware
+Comment[bs]=Server kolaborativnog softvera
+Comment[ca]=Servidor de treball en grup Kolab
+Comment[ca at valencia]=Servidor de treball en grup Kolab
+Comment[cs]=Kolab Groupware server
+Comment[da]=Kolab groupware-server
+Comment[de]=Kolab Groupware-Server
+Comment[el]=ÎξÏ
ÏηÏεÏηÏÎ®Ï Groupware Kolab
+Comment[en_GB]=Kolab Groupware Server
+Comment[es]=Servidor de trabajo en grupo Kolab
+Comment[et]=Kolabi grupitöö server
+Comment[fi]=Kolab-työryhmäpalvelin
+Comment[fr]=Serveur de logiciels de collaboration Kolab
+Comment[ga]=Freastalaà Groupware Kolab
+Comment[gl]=Servidor de traballo en grupo Kolab
+Comment[hu]=Kolab csoportmunka-kiszolgáló
+Comment[ia]=Servitor de Kolab Groupware
+Comment[it]=Server di groupware Kolab
+Comment[ja]=Kolab ã°ã«ã¼ãã¦ã§ã¢ãµã¼ã
+Comment[kk]=Kolab ÑопÑÑÒ ÑÑ ÑеÑвеÑÑ
+Comment[km]=ááá¶ááá¸áâááááá¾ Kolab Groupware
+Comment[ko]=Kolab 그룹ì¨ì´ ìë²
+Comment[lt]=Kolab grupinio darbo serveris
+Comment[lv]=Kolab grupdarba serveris
+Comment[nb]=Kolab groupware-tjener
+Comment[nds]=Kolab-Arbeitkoppelserver
+Comment[nl]=Kolab-groupware-server
+Comment[nn]=Kolab Groupware-tenar
+Comment[pl]=Serwer Kolab Groupware
+Comment[pt]=Servidor de 'Groupware' Kolab
+Comment[pt_BR]=Servidor groupware Kolab
+Comment[ro]=Server Kolab Groupware
+Comment[ru]=СеÑÐ²ÐµÑ ÑовмеÑÑной ÑабоÑÑ Kolab
+Comment[sk]=Groupware Server Kolab
+Comment[sl]=Strežnik za skupinsko delo Kolab
+Comment[sr]=Ðолабов гÑÑпвеÑÑки ÑеÑвеÑ
+Comment[sr at ijekavian]=Ðолабов гÑÑпвеÑÑки ÑеÑвеÑ
+Comment[sr at ijekavianlatin]=Kolabov grupverski server
+Comment[sr at latin]=Kolabov grupverski server
+Comment[sv]=Kolab grupprogramserver
+Comment[tr]=Kolab Groupware Sunucusu
+Comment[uk]=СеÑÐ²ÐµÑ Ð³ÑÑÐ¿Ð¾Ð²Ð¾Ñ ÑобоÑи Kolab
+Comment[x-test]=xxKolab Groupware Serverxx
+Comment[zh_CN]=Kolab 群件æå¡å¨
+Comment[zh_TW]=Kolab 群çµä¼ºæå¨
+
+[Wizard]
+Type=message/rfc822,text/directory,text/calendar,text/x-vnd.akonadi.note
+Script=kolabwizard.es
+
+[Translate]
+Filename=accountwizard_kolab
diff --git a/resources/kolab/wizard/kolabwizard.es b/resources/kolab/wizard/kolabwizard.es
new file mode 100644
index 0000000..2ecf14c
--- /dev/null
+++ b/resources/kolab/wizard/kolabwizard.es
@@ -0,0 +1,224 @@
+/*
+ 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.
+*/
+
+// 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("kolabwizard.ui", qsTr("Personal Settings"));
+var page2 = Dialog.addPage("kolabwizard2.ui", qsTr("Autoconfiguration"));
+var userChangedServerAddress = false;
+
+page.widget().nameEdit.text = SetupManager.name()
+page.widget().emailEdit.text = SetupManager.email()
+page.widget().passwordEdit.text = SetupManager.password()
+
+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);
+ return server;
+ }
+}
+
+function emailChanged(arg)
+{
+ validateInput();
+}
+
+function validateInput()
+{
+ if (page.widget().emailEdit.text.trim() == "") {
+ page.setValid(false);
+ } else {
+ page.setValid(true);
+ }
+}
+
+var identity; // global so it can be accesed in setup and testOk
+
+var kolabRes;
+var smtp;
+var imapRes;
+
+var ac_mail;
+var ac_freebusy;
+var ac_ldap;
+
+function checkAutoconfig()
+{
+ ac_mail = SetupManager.ispDB('autoconfigkolabmail');
+ ac_mail.ispdbFinished.connect(mail_finished);
+ ac_mail.info.connect(mail_text);
+ ac_mail.setEmail(page.widget().emailEdit.text);
+ ac_mail.setPassword(page.widget().passwordEdit.text);
+ ac_mail.start();
+
+ ac_freebusy = SetupManager.ispDB('autoconfigkolabfreebusy');
+ ac_freebusy.ispdbFinished.connect(freebusy_finished);
+ ac_freebusy.info.connect(freebusy_text);
+ ac_freebusy.setEmail(page.widget().emailEdit.text);
+ ac_freebusy.setPassword(page.widget().passwordEdit.text);
+ ac_freebusy.start();
+
+ ac_ldap = SetupManager.ispDB('autoconfigkolabldap');
+ ac_ldap.ispdbFinished.connect(ldap_finished);
+ ac_ldap.info.connect(ldap_text);
+ ac_ldap.setEmail(page.widget().emailEdit.text);
+ ac_ldap.setPassword(page.widget().passwordEdit.text);
+ ac_ldap.start();
+}
+
+guessServerName();
+
+function mail_finished(stat) {
+ if (stat) {
+ page2.widget().checkBoxImap.checked = true;
+ page2.widget().checkBoxImap.enabled = true;
+ page2.widget().checkBoxSmtp.checked = true;
+ page2.widget().checkBoxSmtp.enabled = true;
+ } else {
+ page2.widget().checkBoxImap.checked = false;
+ page2.widget().checkBoxImap.enabled = false;
+ page2.widget().checkBoxSmtp.checked = false;
+ page2.widget().checkBoxSmtp.enabled = false;
+ }
+}
+
+function mail_text(text) {
+ page2.widget().labelImapSearch.text = text;
+ page2.widget().labelSmtpSearch.text = text;
+}
+
+function freebusy_finished(stat) {
+ if (stat) {
+ page2.widget().checkBoxFreebusy.checked = true;
+ page2.widget().checkBoxFreebusy.enabled = true;
+ } else {
+ page2.widget().checkBoxFreebusy.checked = false;
+ page2.widget().checkBoxFreebusy.enabled = false;
+ }
+}
+
+function freebusy_text(text) {
+ page2.widget().labelFreebusySearch.text = text;
+}
+
+
+function ldap_finished(stat) {
+ if (stat) {
+ page2.widget().checkBoxLdap.checked = true;
+ page2.widget().checkBoxLdap.enabled = true;
+ } else {
+ page2.widget().checkBoxLdap.checked = false;
+ page2.widget().checkBoxLdap.enabled = false;
+ }
+}
+
+function ldap_text(text) {
+ page2.widget().labelLdapSearch.text = text;
+}
+
+function setup()
+{
+ SetupManager.openWallet();
+ smtp = SetupManager.createTransport("smtp");
+ smtp.setPassword(page.widget().passwordEdit.text);
+
+ if (page2.widget().checkBoxSmtp.checked) {
+ ac_mail.fillSmtpServer(0, smtp);
+ } else if (guessServerName()) {
+ var serverAddress = guessServerName();
+ smtp.setName(serverAddress);
+ smtp.setHost(serverAddress);
+ smtp.setPort(465);
+ smtp.setEncryption("SSL");
+ smtp.setAuthenticationType("plain"); // using plain is ok, because we are using SSL.
+ smtp.setUsername(page.widget().emailEdit.text);
+ }
+
+ for (i = 0; i < ac_mail.countIdentities(); i++) {
+ var j = SetupManager.createIdentity();
+ j.setTransport(smtp);
+ //templates
+ //drafts
+ //fcc
+ ac_mail.fillIdentitiy(i,j);
+ if (i == ac_mail.defaultIdentity()) {
+ identity = j;
+ }
+ }
+
+ if (ac_mail.countIdentities() == 0) {
+ identity = SetupManager.createIdentity();
+ identity.setEmail(page.widget().emailEdit.text);
+ identity.setRealName(page.widget().nameEdit.text);
+ identity.setTransport(smtp);
+ }
+
+ kolabRes = SetupManager.createResource("akonadi_kolab_resource");
+ kolabRes.setOption("Password", page.widget().passwordEdit.text);
+ kolabRes.setOption("UseDefaultIdentity", false);
+ kolabRes.setOption("AccountIdentity", identity.uoid());
+ kolabRes.setOption("DisconnectedModeEnabled", true);
+ kolabRes.setOption("IntervalCheckTime", 60);
+ kolabRes.setOption("SubscriptionEnabled", true);
+ kolabRes.setOption("SieveSupport", true);
+
+ if (page2.widget().checkBoxImap.checked) {
+ ac_mail.fillImapServer(0, kolabRes);
+ } else if (guessServerName()) {
+ var serverAddress = guessServerName();
+ kolabRes.setOption("ImapServer", serverAddress);
+ kolabRes.setOption("UserName", page.widget().emailEdit.text.trim());
+ kolabRes.setOption("Authentication", 7);
+ kolabRes.setOption("Safety", "STARTTLS");
+ kolabRes.setOption("ImapPort", 143);
+ }
+ if (page2.widget().checkBoxLdap.checked) {
+ for (i = 0; i < ac_ldap.countLdapServers(); i++) {
+ var ldap = SetupManager.createLdap();
+ ac_ldap.fillLdapServer(i,ldap);
+ }
+ } else if (page2.widget().checkBoxLdapEdit) {
+ SetupManager.createLdap();
+ }
+
+ if (page2.widget().checkBoxFreebusy.checked) {
+ var korganizer = SetupManager.createConfigFile("korganizerrc");
+ korganizer.setName("korganizer");
+ ispdb.fillFreebusyServer(0,korganizer);
+ }
+
+ SetupManager.execute();
+}
+
+try {
+ page.widget().emailEdit.textChanged.connect(emailChanged);
+ page.pageLeftNext.connect(checkAutoconfig);
+ page2.pageLeftNext.connect(setup);
+} catch (e) {
+ print(e);
+}
+
+validateInput();
diff --git a/resources/kolab/wizard/kolabwizard.ui b/resources/kolab/wizard/kolabwizard.ui
new file mode 100644
index 0000000..b7c0890
--- /dev/null
+++ b/resources/kolab/wizard/kolabwizard.ui
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>kolabWizard_step1</class>
+ <widget class="QWidget" name="kolabWizard_step1">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>368</width>
+ <height>125</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="2" 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="2" column="1">
+ <widget class="KLineEdit" name="emailEdit"/>
+ </item>
+ <item row="4" 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="4" column="1">
+ <widget class="KLineEdit" name="passwordEdit">
+ <property name="echoMode">
+ <enum>QLineEdit::Password</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Kolab Version:</string>
+ </property>
+ <property name="buddy">
+ <cstring>versionComboBox</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="1">
+ <widget class="QComboBox" name="versionComboBox">
+ <property name="currentIndex">
+ <number>1</number>
+ </property>
+ <item>
+ <property name="text">
+ <string>v2</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>v3</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>KLineEdit</class>
+ <extends>QLineEdit</extends>
+ <header>klineedit.h</header>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/resources/kolab/wizard/kolabwizard2.ui b/resources/kolab/wizard/kolabwizard2.ui
new file mode 100644
index 0000000..aa664a0
--- /dev/null
+++ b/resources/kolab/wizard/kolabwizard2.ui
@@ -0,0 +1,188 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>kolabWizard_step2</class>
+ <widget class="QWidget" name="kolabWizard_step2">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>368</width>
+ <height>116</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string/>
+ </property>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="imapLabel">
+ <property name="text">
+ <string>Imap:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="labelImapSearch">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="checkBoxImap">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Use Autoconfig</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="checkBoxImapEdit">
+ <property name="text">
+ <string>Edit</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="4" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout_4">
+ <item>
+ <widget class="QLabel" name="labelFreebusySearch">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="checkBoxFreebusy">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Use Autoconfig</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="checkBoxFreebusyEdit">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Edit</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="labelFreebusy">
+ <property name="text">
+ <string>Freebusy:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="labelSmtp">
+ <property name="text">
+ <string>Smtp:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QLabel" name="labelSmtpSearch">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="checkBoxSmtp">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Use Autoconfig</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="checkBoxSmtpEdit">
+ <property name="text">
+ <string>Edit</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="2" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QLabel" name="labelLdapSearch">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="checkBoxLdap">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Use Autoconfig</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="checkBoxLdapEdit">
+ <property name="text">
+ <string>Edit</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="labelLdap">
+ <property name="text">
+ <string>Ldap:</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/resources/kolabproxy/wizard/CMakeLists.txt b/resources/kolabproxy/wizard/CMakeLists.txt
index b18bebf..9889204 100644
--- a/resources/kolabproxy/wizard/CMakeLists.txt
+++ b/resources/kolabproxy/wizard/CMakeLists.txt
@@ -1,5 +1,5 @@
install(
FILES kolabwizard.desktop kolabwizard.es kolabwizard.ui
- DESTINATION ${DATA_INSTALL_DIR}/akonadi/accountwizard/kolab
+ DESTINATION ${DATA_INSTALL_DIR}/akonadi/accountwizard/kolabproxy
)
diff --git a/resources/kolabproxy/wizard/kolabwizard.desktop b/resources/kolabproxy/wizard/kolabwizard.desktop
index 7162d01..4d6a1cd 100644
--- a/resources/kolabproxy/wizard/kolabwizard.desktop
+++ b/resources/kolabproxy/wizard/kolabwizard.desktop
@@ -1,101 +1,11 @@
[Desktop Entry]
-Name=Kolab Groupware Server
-Name[bg]=СÑÑвÑÑ Kolab Groupware
-Name[bs]=Server kolaborativnog softvera
-Name[ca]=Servidor de treball en grup Kolab
-Name[ca at valencia]=Servidor de treball en grup Kolab
-Name[cs]=Kolab Groupware server
-Name[da]=Kolab groupware-server
-Name[de]=Kolab Groupware-Server
-Name[el]=ÎξÏ
ÏηÏεÏηÏÎ®Ï Groupware Kolab
-Name[en_GB]=Kolab Groupware Server
-Name[es]=Servidor de trabajo en grupo Kolab
-Name[et]=Kolabi grupitöö server
-Name[fi]=Kolab-työryhmäpalvelin
-Name[fr]=Serveur de logiciels de collaboration Kolab
-Name[ga]=Freastalaà Groupware Kolab
-Name[gl]=Servidor de Traballo en Grupo Kolab
-Name[hu]=Kolab csoportmunka-kiszolgáló
-Name[ia]=Servitor de Kolab Groupware
-Name[it]=Server di groupware Kolab
-Name[ja]=Kolab ã°ã«ã¼ãã¦ã§ã¢ãµã¼ã
-Name[kk]=Kolab ÑопÑÑÒ ÑÑ ÑеÑвеÑÑ
-Name[km]=ááá¶ááá¸áâááááá¾ Kolab Groupware
-Name[ko]=Kolab 그룹ì¨ì´ ìë²
-Name[lt]=Kolab grupinio darbo serveris
-Name[lv]=Kolab grupdarba serveris
-Name[nb]=Kolab groupware-tjener
-Name[nds]=Kolab-Arbeitkoppel-Server
-Name[nl]=Kolab groupwareserver
-Name[nn]=Kolab Groupware-tenar
-Name[pl]=Serwer Groupware Kolab
-Name[pt]=Servidor de Groupware Kolab
-Name[pt_BR]=Servidor groupware Kolab
-Name[ro]=Server Kolab Groupware
-Name[ru]=СеÑÐ²ÐµÑ ÑовмеÑÑной ÑабоÑÑ Kolab
-Name[sk]=Groupware Server Kolab
-Name[sl]=Strežnik za skupinsko delo Kolab
-Name[sr]=Ðолабов гÑÑпвеÑÑки ÑеÑвеÑ
-Name[sr at ijekavian]=Ðолабов гÑÑпвеÑÑки ÑеÑвеÑ
-Name[sr at ijekavianlatin]=Kolabov grupverski server
-Name[sr at latin]=Kolabov grupverski server
-Name[sv]=Kolab grupprogramserver
-Name[tr]=Kolab Groupware Sunucusu
-Name[uk]=СеÑÐ²ÐµÑ Ð³ÑÑÐ¿Ð¾Ð²Ð¾Ñ ÑобоÑи Kolab
-Name[x-test]=xxKolab Groupware Serverxx
-Name[zh_CN]=Kolab 群件æå¡å¨
-Name[zh_TW]=Kolab 群çµä¼ºæå¨
+Name=Kolab Groupware Server (Old)
Icon=kolab
-Comment=Kolab Groupware Server
-Comment[bg]=СÑÑвÑÑ Kolab Groupware
-Comment[bs]=Server kolaborativnog softvera
-Comment[ca]=Servidor de treball en grup Kolab
-Comment[ca at valencia]=Servidor de treball en grup Kolab
-Comment[cs]=Kolab Groupware server
-Comment[da]=Kolab groupware-server
-Comment[de]=Kolab Groupware-Server
-Comment[el]=ÎξÏ
ÏηÏεÏηÏÎ®Ï Groupware Kolab
-Comment[en_GB]=Kolab Groupware Server
-Comment[es]=Servidor de trabajo en grupo Kolab
-Comment[et]=Kolabi grupitöö server
-Comment[fi]=Kolab-työryhmäpalvelin
-Comment[fr]=Serveur de logiciels de collaboration Kolab
-Comment[ga]=Freastalaà Groupware Kolab
-Comment[gl]=Servidor de traballo en grupo Kolab
-Comment[hu]=Kolab csoportmunka-kiszolgáló
-Comment[ia]=Servitor de Kolab Groupware
-Comment[it]=Server di groupware Kolab
-Comment[ja]=Kolab ã°ã«ã¼ãã¦ã§ã¢ãµã¼ã
-Comment[kk]=Kolab ÑопÑÑÒ ÑÑ ÑеÑвеÑÑ
-Comment[km]=ááá¶ááá¸áâááááá¾ Kolab Groupware
-Comment[ko]=Kolab 그룹ì¨ì´ ìë²
-Comment[lt]=Kolab grupinio darbo serveris
-Comment[lv]=Kolab grupdarba serveris
-Comment[nb]=Kolab groupware-tjener
-Comment[nds]=Kolab-Arbeitkoppel-Server
-Comment[nl]=Kolab-groupware-server
-Comment[nn]=Kolab Groupware-tenar
-Comment[pl]=Serwer Kolab Groupware
-Comment[pt]=Servidor de 'Groupware' Kolab
-Comment[pt_BR]=Servidor groupware Kolab
-Comment[ro]=Server Kolab Groupware
-Comment[ru]=СеÑÐ²ÐµÑ ÑовмеÑÑной ÑабоÑÑ Kolab
-Comment[sk]=Groupware Server Kolab
-Comment[sl]=Strežnik za skupinsko delo Kolab
-Comment[sr]=Ðолабов гÑÑпвеÑÑки ÑеÑвеÑ
-Comment[sr at ijekavian]=Ðолабов гÑÑпвеÑÑки ÑеÑвеÑ
-Comment[sr at ijekavianlatin]=Kolabov grupverski server
-Comment[sr at latin]=Kolabov grupverski server
-Comment[sv]=Kolab grupprogramserver
-Comment[tr]=Kolab Groupware Sunucusu
-Comment[uk]=СеÑÐ²ÐµÑ Ð³ÑÑÐ¿Ð¾Ð²Ð¾Ñ ÑобоÑи Kolab
-Comment[x-test]=xxKolab Groupware Serverxx
-Comment[zh_CN]=Kolab 群件æå¡å¨
-Comment[zh_TW]=Kolab 群çµä¼ºæå¨
+Comment=Kolab Groupware Server via kolabproxy
[Wizard]
Type=message/rfc822,text/directory,text/calendar,text/x-vnd.akonadi.note
Script=kolabwizard.es
[Translate]
-Filename=accountwizard_kolab
+Filename=accountwizard_kolabproxy
commit ed98d813da3887b84d5aab53e1ab4e8a0d9cd2a2
Author: Sandro Knauà <mail at sandroknauss.de>
Date: Sat Jul 26 16:50:31 2014 +0200
made ispdb available for scripts
REVIEW: 119481
diff --git a/accountwizard/setupmanager.cpp b/accountwizard/setupmanager.cpp
index 75e3023..421362d 100644
--- a/accountwizard/setupmanager.cpp
+++ b/accountwizard/setupmanager.cpp
@@ -24,6 +24,10 @@
#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>
@@ -231,6 +235,22 @@ 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() ) {
diff --git a/accountwizard/setupmanager.h b/accountwizard/setupmanager.h
index e1e0b07..ad6fcb0 100644
--- a/accountwizard/setupmanager.h
+++ b/accountwizard/setupmanager.h
@@ -56,6 +56,7 @@ class SetupManager : public QObject
Q_SCRIPTABLE QObject* createLdap();
Q_SCRIPTABLE QObject* createIdentity();
Q_SCRIPTABLE void execute();
+ Q_SCRIPTABLE QObject* ispDB( const QString &type );
void requestRollback();
commit 328dd041834928bf7b5174c82ffd8448424193cf
Author: Sandro Knauà <mail at sandroknauss.de>
Date: Wed Jul 16 12:48:59 2014 +0200
make autoconfiguration available for setupmanager
REVIEW: 119484
diff --git a/accountwizard/CMakeLists.txt b/accountwizard/CMakeLists.txt
index 1478ca0..7bc69a2 100644
--- a/accountwizard/CMakeLists.txt
+++ b/accountwizard/CMakeLists.txt
@@ -22,9 +22,16 @@ set(accountwizard_srcs
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
diff --git a/accountwizard/ldap.cpp b/accountwizard/ldap.cpp
index 14b84f6..ac4080f 100644
--- a/accountwizard/ldap.cpp
+++ b/accountwizard/ldap.cpp
@@ -26,6 +26,12 @@
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)
{
}
@@ -75,16 +81,47 @@ void Ldap::create()
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 ), "389" );
+ 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." ) );
@@ -115,3 +152,44 @@ 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
index 4da5c02..4162f72 100644
--- a/accountwizard/ldap.h
+++ b/accountwizard/ldap.h
@@ -21,7 +21,7 @@
#define LDAP_H
#include "setupobject.h"
-
+#include <KLDAP/LdapServer>
class Ldap : public SetupObject
{
@@ -37,12 +37,31 @@ class Ldap : public SetupObject
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/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
commit 7f7f67add6ab09ba26b289c75eef837903a43ac8
Author: Sandro Knauà <mail at sandroknauss.de>
Date: Wed Jul 16 12:47:46 2014 +0200
Add autoconfiguration for kolab
REVIEW: 119480
diff --git a/accountwizard/ispdb/CMakeLists.txt b/accountwizard/ispdb/CMakeLists.txt
index a2e2be4..c15ce4b 100644
--- a/accountwizard/ispdb/CMakeLists.txt
+++ b/accountwizard/ispdb/CMakeLists.txt
@@ -1,7 +1,9 @@
-
set(ispdb_srcs
main.cpp
ispdb.cpp
+ autoconfigkolabmail.cpp
+ autoconfigkolabldap.cpp
+ autoconfigkolabfreebusy.cpp
)
kde4_add_executable(ispdb ${ispdb_srcs})
@@ -13,3 +15,5 @@ target_link_libraries(ispdb
)
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
index 7667259..1301739 100644
--- a/accountwizard/ispdb/ispdb.cpp
+++ b/accountwizard/ispdb/ispdb.cpp
@@ -1,5 +1,6 @@
/*
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
@@ -27,7 +28,9 @@
#include <QDomDocument>
Ispdb::Ispdb( QObject *parent )
- : QObject( parent ), mServerType( DataBase )
+ : QObject( parent )
+ , mServerType( DataBase )
+ , mStart( true )
{
}
@@ -42,15 +45,27 @@ void Ispdb::setEmail( const QString& address )
mAddr = box.addrSpec();
}
+void Ispdb::setPassword( const QString &password )
+{
+ mPassword = password;
+}
+
+
void Ispdb::start()
{
- kDebug() << mAddr.asString();
// we should do different things in here. But lets focus in the db first.
- lookupInDb();
+ 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;
@@ -62,33 +77,44 @@ void Ispdb::startJob( const KUrl&url )
this, SLOT(dataArrived(KIO::Job*,QByteArray)) );
}
-void Ispdb::lookupInDb()
+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() + QLatin1String("/mail/config-v1.1.xml?emailaddress=") + mAddr.asString().toLower() );
- Q_EMIT searchType(i18n("Lookup configuration: Email provider"));
+ url = KUrl( QLatin1String("http://autoconfig.") + mAddr.domain.toLower() + QLatin1Char('/') + path );
break;
}
case IspWellKnow:
{
- url = KUrl( QLatin1String("http://") + mAddr.domain.toLower() + QLatin1String("/.well-known/autoconfig/mail/config-v1.1.xml") );
- Q_EMIT searchType(i18n("Lookup configuration: Trying common server name"));
+ 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() );
- Q_EMIT searchType(i18n("Lookup configuration: Mozilla database"));
break;
}
}
- startJob( url );
+
+ 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() ) {
@@ -115,7 +141,7 @@ void Ispdb::slotResult( KJob* job )
emit finished( false );
return;
}
- lookupInDb();
+ lookupInDb( false, false );
return;
}
@@ -128,11 +154,24 @@ void Ispdb::slotResult( KJob* job )
return;
}
+ parseResult( document );
+
+}
+
+void Ispdb::parseResult( const QDomDocument &document )
+{
QDomElement docElem = document.documentElement();
- QDomNode m = docElem.firstChild(); // emailprovider
- QDomNode n = m.firstChild(); // emailprovider
+ QDomNodeList l = docElem.elementsByTagName(QLatin1String("emailProvider"));
+
+ if ( l.isEmpty() ) {
+ emit finished(false);
+ return;
+ }
- while ( !n.isNull() ) {
+ //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() );
@@ -146,9 +185,9 @@ void Ispdb::slotResult( KJob* job )
else if ( tagName == QLatin1String( "incomingServer" )
&& e.attribute( QLatin1String("type") ) == QLatin1String( "imap" ) ) {
server s = createServer( e );
- if (s.isValid())
+ if (s.isValid())
mImapServers.append( s );
- } else if ( tagName == QLatin1String( "incomingServer" )
+ } else if ( tagName == QLatin1String( "incomingServer" )
&& e.attribute( QLatin1String("type") ) == QLatin1String( "pop3" ) ) {
server s = createServer( e );
if (s.isValid())
@@ -158,6 +197,14 @@ void Ispdb::slotResult( KJob* job )
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();
@@ -166,6 +213,7 @@ void Ispdb::slotResult( KJob* job )
emit finished( true );
}
+
server Ispdb::createServer( const QDomElement& n )
{
QDomNode o = n.firstChild();
@@ -211,6 +259,45 @@ server Ispdb::createServer( const QDomElement& n )
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 );
@@ -257,3 +344,43 @@ 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
index c29ef6a..36eb2b2 100644
--- a/accountwizard/ispdb/ispdb.h
+++ b/accountwizard/ispdb/ispdb.h
@@ -1,5 +1,6 @@
/*
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
@@ -26,8 +27,10 @@
#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
@@ -49,7 +52,7 @@ public:
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 };
+ enum authType { Plain = 0, CramMD5, NTLM, GSSAPI, ClientIP, NoAuth, Basic };
enum length { Long = 0, Short };
/** Constructor */
@@ -80,38 +83,94 @@ public:
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* );
- void dataArrived( KIO::Job*, const QByteArray& data );
signals:
/** emitted when done. **/
void finished( bool );
void searchType( const QString &type );
-private:
- enum searchServerType { IspAutoConfig = 0, IspWellKnow, DataBase };
+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;
- server createServer( const QDomElement& n );
- void lookupInDb();
+ /** replaces %EMAILLOCALPART%, %EMAILADDRESS% and %EMAILDOMAIN% with the
+ parts of the emailaddress */
QString replacePlaceholders( const QString& );
- void startJob( const KUrl&url );
+ 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
- QByteArray mData; // storage of incoming data from kio
+ 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 {
@@ -130,4 +189,26 @@ struct server {
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/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"
More information about the commits
mailing list