Branch 'kolab/integration/4.13.0' - 9 commits - accountwizard/CMakeLists.txt accountwizard/configfile.cpp accountwizard/configfile.h accountwizard/ldap.cpp accountwizard/ldap.h accountwizard/page.cpp accountwizard/page.h accountwizard/resource.cpp accountwizard/resource.h accountwizard/setupautoconfigkolabldap.cpp accountwizard/setupmanager.cpp accountwizard/setupmanager.h accountwizard/tests accountwizard/transport.cpp accountwizard/transport.h incidenceeditor-ng/editoritemmanager.cpp korganizer/akonadicollectionview.cpp libkdepim/ldap

Christian Mollekopf mollekopf at kolabsys.com
Fri Oct 31 10:30:33 CET 2014


 accountwizard/CMakeLists.txt               |    9 +-
 accountwizard/configfile.cpp               |   32 +++++++
 accountwizard/configfile.h                 |    5 +
 accountwizard/ldap.cpp                     |  125 +++++++++++++++++++++++++----
 accountwizard/ldap.h                       |   18 ++++
 accountwizard/page.cpp                     |    6 +
 accountwizard/page.h                       |    2 
 accountwizard/resource.cpp                 |   22 ++++-
 accountwizard/resource.h                   |    4 
 accountwizard/setupautoconfigkolabldap.cpp |    3 
 accountwizard/setupmanager.cpp             |    3 
 accountwizard/setupmanager.h               |    3 
 accountwizard/tests/CMakeLists.txt         |   14 +++
 accountwizard/tests/data/ldap.cfg          |   51 +++++++++++
 accountwizard/tests/ldaptest.cpp           |  102 +++++++++++++++++++++++
 accountwizard/transport.cpp                |   20 ++++
 accountwizard/transport.h                  |    4 
 incidenceeditor-ng/editoritemmanager.cpp   |    2 
 korganizer/akonadicollectionview.cpp       |    6 +
 libkdepim/ldap/ldapclientsearchconfig.cpp  |    8 +
 libkdepim/ldap/ldapclientsearchconfig.h    |    6 +
 21 files changed, 419 insertions(+), 26 deletions(-)

New commits:
commit 4cf726e5a843db36783fd5e1f6a6868cd6295a38
Merge: 53237ce 8a66602
Author: Christian Mollekopf <chrigi_1 at fastmail.fm>
Date:   Wed Oct 29 22:48:41 2014 +0100

    Merge remote-tracking branch 'kolab/dev/accountwizard_edit' into kolab/integration/4.13.0



commit 53237cef0084554b3a4e78a6f720a7f391966a78
Merge: 5c208cb 4b8d8e4
Author: Christian Mollekopf <chrigi_1 at fastmail.fm>
Date:   Wed Oct 29 22:47:34 2014 +0100

    Merge remote-tracking branch 'kolab/dev/personnode_collapse' into kolab/integration/4.13.0



commit 8a66602714829ba045505978ac687f9a85493de5
Author: Sandro Knauß <knauss at kolabsys.com>
Date:   Tue Oct 28 13:12:50 2014 +0100

    Accountwizard: Added destroy option for ldap object.
    
    ldapclientsearchconfig:
    * Do not show the question for storing passwords in KWallet for LDAP
      (need for tests)
    
    * Added test for ldap.destroy function

diff --git a/accountwizard/CMakeLists.txt b/accountwizard/CMakeLists.txt
index bf71af1..2b202ae 100644
--- a/accountwizard/CMakeLists.txt
+++ b/accountwizard/CMakeLists.txt
@@ -82,4 +82,5 @@ install(FILES accountwizard-mime.xml DESTINATION ${XDG_MIME_INSTALL_DIR})
 update_xdg_mimetypes(${XDG_MIME_INSTALL_DIR})
 
 add_subdirectory(wizards)
-add_subdirectory(ispdb)
\ No newline at end of file
+add_subdirectory(ispdb)
+add_subdirectory(tests)
\ No newline at end of file
diff --git a/accountwizard/ldap.cpp b/accountwizard/ldap.cpp
index c5af9af..bdd42cc 100644
--- a/accountwizard/ldap.cpp
+++ b/accountwizard/ldap.cpp
@@ -36,13 +36,21 @@ Ldap::Ldap( QObject *parent )
   , m_sizeLimit(0)
   , m_entry(-1)
   , m_editMode(false)
+  , m_clientSearchConfig(new KLDAP::LdapClientSearchConfig)
 {
 }
 
 Ldap::~Ldap()
 {
+    delete m_clientSearchConfig;
 }
 
+KConfig *Ldap::config() const
+{
+    return m_clientSearchConfig->config();
+}
+
+
 void Ldap::create()
 {
   //TODO: use ldapclientsearchconfig to write config
@@ -82,8 +90,8 @@ void Ldap::create()
   basedn.prepend( QLatin1String("dc=") );
 
   // Set the changes
-  KConfig c( QLatin1String("kabldaprc") );
-  KConfigGroup group = c.group( "LDAP" );
+  KConfig *c = config();
+  KConfigGroup group = c->group( "LDAP" );
   bool hasMyServer = false;
   uint selHosts = group.readEntry( "NumSelectedHosts", 0 );
   for ( uint i = 0 ; i < selHosts && !hasMyServer; ++i ) {
@@ -121,7 +129,7 @@ void Ldap::create()
       group.writeEntry( QString::fromLatin1( "SelectedUser%1" ).arg( selHosts ), m_user );
       group.writeEntry( QString::fromLatin1( "SelectedMech%1" ).arg( selHosts ), m_mech );
     }
-    c.sync();
+    c->sync();
   }
   if (m_editMode) {
       edit();
@@ -145,7 +153,40 @@ QString Ldap::securityString()
 void Ldap::destroy()
 {
   if (m_entry >= 0 ) {
-      //TODO: delete ldap entry
+      KConfig *c = config();
+      KConfigGroup group = c->group( "LDAP" );
+      int cSelHosts = group.readEntry( "NumSelectedHosts", 0 );
+      int cHosts = group.readEntry( "NumHosts", 0 );
+      QList<KLDAP::LdapServer> selHosts;
+      QList<KLDAP::LdapServer> hosts;
+      for(int i=0; i < cSelHosts; i++) {
+          if (i != m_entry) {
+              KLDAP::LdapServer server;
+              m_clientSearchConfig->readConfig(server, group, i, true);
+              selHosts.append(server);
+          }
+      }
+      for(int i=0; i < cHosts; i++) {
+          KLDAP::LdapServer server;
+          m_clientSearchConfig->readConfig(server, group, i, false);
+          hosts.append(server);
+      }
+
+      c->deleteGroup("LDAP");
+      group = KConfigGroup (c, "LDAP");
+
+      for(int i=0; i < cSelHosts - 1; i++) {
+          m_clientSearchConfig->writeConfig(selHosts.at(i), group, i, true);
+      }
+
+      for(int i=0; i < cHosts; i++) {
+          m_clientSearchConfig->writeConfig(hosts.at(i), group, i, false);
+      }
+
+      group.writeEntry( "NumSelectedHosts", cSelHosts - 1);
+      group.writeEntry( "NumHosts", cHosts );
+      c->sync();
+
       emit info(i18n("Removed LDAP entry."));
   }
 }
diff --git a/accountwizard/ldap.h b/accountwizard/ldap.h
index d1f6ab3..fdfd223 100644
--- a/accountwizard/ldap.h
+++ b/accountwizard/ldap.h
@@ -23,6 +23,13 @@
 #include "setupobject.h"
 #include <KLDAP/LdapServer>
 
+class LdapTest;
+class KConfig;
+
+namespace KLDAP {
+    class LdapClientSearchConfig;
+}
+
 class Ldap : public SetupObject
 {
   Q_OBJECT
@@ -49,7 +56,12 @@ class Ldap : public SetupObject
     Q_SCRIPTABLE void setSizeLimit(const int sizeLimit);
     Q_SCRIPTABLE void setEditMode(const bool editMode);
 
+  protected:
+    virtual KConfig *config() const;
+
+    KLDAP::LdapClientSearchConfig *m_clientSearchConfig;
   private:
+    friend LdapTest;
     QString securityString();
 
     QString m_user;
diff --git a/accountwizard/tests/CMakeLists.txt b/accountwizard/tests/CMakeLists.txt
new file mode 100644
index 0000000..5e376a7
--- /dev/null
+++ b/accountwizard/tests/CMakeLists.txt
@@ -0,0 +1,14 @@
+include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/.. )
+add_definitions (-DTEST_DATA_DIR="\\"${CMAKE_CURRENT_SOURCE_DIR}/data\\"")
+add_definitions (-DCURRENT_SOURCE_DIR="\\"${CMAKE_CURRENT_SOURCE_DIR}\\"")
+
+kde4_add_unit_test(ldaptest ldaptest.cpp ../ldap.cpp ../setupobject.cpp)
+
+target_link_libraries(ldaptest
+    ${KDE4_KDECORE_LIBS}
+    ${KDE4_KIO_LIBS}
+    ${KDEPIMLIBS_KMIME_LIBS}
+    ${KDEPIMLIBS_KLDAP_LIBS}
+    ${QT_QTTEST_LIBRARY}
+    kdepim
+  )
\ No newline at end of file
diff --git a/accountwizard/tests/data/ldap.cfg b/accountwizard/tests/data/ldap.cfg
new file mode 100644
index 0000000..dcd43ea
--- /dev/null
+++ b/accountwizard/tests/data/ldap.cfg
@@ -0,0 +1,51 @@
+[LDAP]
+Auth0=Simple
+Base0=dc=example,dc=com
+Bind0=cn=Directory Manager
+Host0=kolab.example.com
+Mech0=DIGEST-MD5
+NumHosts=1
+NumSelectedHosts=3
+PageSize0=0
+Port0=389
+Security0=None
+SelectedAuth0=Simple
+SelectedAuth1=Anonymous
+SelectedAuth2=SASL
+SelectedBase0=dc=lhm,dc=klab,dc=cc
+SelectedBase1=dc=example,dc=com
+SelectedBase2=dc=ldap2,dc=example,dc=com
+SelectedBind0=uid=gotthold.scholz,ou=People,ou=IT,dc=lhm,dc=klab,dc=cc
+SelectedBind1=
+SelectedBind2=cn=Directory
+SelectedHost0=ldap.lhm.klab.cc
+SelectedHost1=example.com
+SelectedHost2=ldap2.example.com
+SelectedMech0=ANONYMOUS
+SelectedMech1=DIGEST-MD5
+SelectedMech2=XXX
+SelectedPageSize0=0
+SelectedPageSize1=0
+SelectedPageSize2=9999999
+SelectedPort0=389
+SelectedPort1=389
+SelectedPort2=387
+SelectedPwdBind2=XXXXXXXXXXXXXXX
+SelectedRealm2=realm.example.com
+SelectedSecurity0=None
+SelectedSecurity1=None
+SelectedSecurity2=SSL
+SelectedSizeLimit0=0
+SelectedSizeLimit1=0
+SelectedTimeLimit0=0
+SelectedTimeLimit1=0
+SelectedUser0=
+SelectedUser1=
+SelectedUser2=john.doe
+SelectedVersion0=3
+SelectedVersion1=3
+SelectedVersion2=3
+SizeLimit0=0
+TimeLimit0=0
+User0=
+Version0=3
diff --git a/accountwizard/tests/ldaptest.cpp b/accountwizard/tests/ldaptest.cpp
new file mode 100644
index 0000000..e06ea2b
--- /dev/null
+++ b/accountwizard/tests/ldaptest.cpp
@@ -0,0 +1,102 @@
+/*
+    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 <KConfig>
+#include <KConfigGroup>
+#include <boost/graph/graph_concepts.hpp>
+
+#include <libkdepim/ldap/ldapclientsearchconfig.h>
+#include "../ldap.h"
+
+class TLdap : public Ldap
+{
+public:
+    explicit TLdap(QObject *parent = 0)
+    : Ldap(parent)
+    , fname(QFileInfo(QLatin1String("ldap.cfg")).absoluteFilePath())
+    {
+        s_config = new KConfig(fname, KConfig::SimpleConfig);
+        m_clientSearchConfig->askForWallet(false);
+    }
+
+    virtual KConfig* config() const
+    {
+        s_config->reparseConfiguration();
+        return s_config;
+    }
+
+    QString fname;
+    KConfig *s_config;
+};
+
+class LdapTest : public QObject
+{
+    Q_OBJECT
+private slots:
+    void testDestroy()
+    {
+        TLdap l;
+        QFile::remove(l.fname);
+        QFile::copy(QLatin1String(TEST_DATA_DIR)+QLatin1String("/ldap.cfg"), l.fname);
+        KLDAP::LdapClientSearchConfig csc;
+        csc.askForWallet(false);
+
+        KConfigGroup group = l.config()->group("LDAP");
+        int cSelHosts = group.readEntry( "NumSelectedHosts", 0 );
+        int cHosts = group.readEntry( "NumHosts", 0 );
+        QCOMPARE(cSelHosts, 3);
+        QCOMPARE(cHosts, 1);
+        QList<KLDAP::LdapServer> selHosts;
+        QList<KLDAP::LdapServer> hosts;
+        for(int i=0; i < cSelHosts; i++) {
+            KLDAP::LdapServer server;
+            csc.readConfig(server, group, i, true);
+            selHosts.append(server);
+        }
+        for(int i=0; i < cHosts; i++) {
+          KLDAP::LdapServer server;
+          csc.readConfig(server, group, i, false);
+          hosts.append(server);
+        }
+
+        l.m_entry = 0;
+        l.destroy();
+        group = l.config()->group("LDAP");
+
+        QCOMPARE(group.readEntry( "NumSelectedHosts", 0 ), 2);
+        QCOMPARE(group.readEntry( "NumHosts", 0 ), 1);
+        KLDAP::LdapServer server;
+        csc.readConfig(server, group, 0, false);
+        QCOMPARE(server.host(), hosts.at(0).host());
+
+        csc.readConfig(server, group, 0, true);
+        QCOMPARE(server.host(), selHosts.at(1).host());
+        csc.readConfig(server, group, 1, true);
+        QCOMPARE(server.host(), selHosts.at(2).host());
+    }
+};
+
+QTEST_KDEMAIN(LdapTest, GUI)
+
+#include "ldaptest.moc"
diff --git a/libkdepim/ldap/ldapclientsearchconfig.cpp b/libkdepim/ldap/ldapclientsearchconfig.cpp
index d54ddbc..92c0f7c 100644
--- a/libkdepim/ldap/ldapclientsearchconfig.cpp
+++ b/libkdepim/ldap/ldapclientsearchconfig.cpp
@@ -36,6 +36,7 @@ class LdapClientSearchConfig::Private
 public:
     Private()
         : useWallet( false ),
+          askWallet( true ),
           wallet( 0 )
     {
 
@@ -48,6 +49,7 @@ public:
         }
     }
     bool useWallet;
+    bool askWallet;
     KWallet::Wallet* wallet;
 };
 
@@ -104,7 +106,7 @@ void LdapClientSearchConfig::readConfig( KLDAP::LdapServer &server, KConfigGroup
     const QString pwdBindBNEntry = prefix + QString::fromLatin1( "PwdBind%1" ).arg( j );
     QString pwdBindDN = config.readEntry( pwdBindBNEntry, QString() );
     if ( !pwdBindDN.isEmpty() ) {
-        if ( KMessageBox::Yes == KMessageBox::questionYesNo(0, i18n("LDAP password is stored as clear text, do you want to store it in kwallet?"),
+        if ( d->askWallet && KMessageBox::Yes == KMessageBox::questionYesNo(0, i18n("LDAP password is stored as clear text, do you want to store it in kwallet?"),
                                                             i18n("Store clear text password in KWallet"),
                                                             KStandardGuiItem::yes(),
                                                             KStandardGuiItem::no(),
@@ -229,4 +231,8 @@ void LdapClientSearchConfig::slotWalletClosed()
     d->wallet = 0;
 }
 
+void LdapClientSearchConfig::askForWallet(bool askForWallet)
+{
+    d->askWallet = askForWallet;
+}
 
diff --git a/libkdepim/ldap/ldapclientsearchconfig.h b/libkdepim/ldap/ldapclientsearchconfig.h
index 6725820..456587b 100644
--- a/libkdepim/ldap/ldapclientsearchconfig.h
+++ b/libkdepim/ldap/ldapclientsearchconfig.h
@@ -59,6 +59,12 @@ public:
      */
     void writeConfig( const KLDAP::LdapServer &server, KConfigGroup &group,
                       int clientNumber, bool active );
+
+    /**
+     * Should LdapClientSearchConfig ask, if it should use the KWallet to store passwords
+     */
+    void askForWallet(bool askForWallet);
+
 private Q_SLOTS:
     void slotWalletClosed();
 


commit 6d8a5a0ed8e7d3b2a04fe116a038381be908dd6f
Author: Sandro Knauß <knauss at kolabsys.com>
Date:   Tue Oct 28 12:08:04 2014 +0100

    Accountwizard: Disable back button in last step.

diff --git a/accountwizard/page.cpp b/accountwizard/page.cpp
index 78437d9..ef1f9a4 100644
--- a/accountwizard/page.cpp
+++ b/accountwizard/page.cpp
@@ -50,6 +50,12 @@ void Page::nextPage()
   m_parent->next();
 }
 
+KAssistantDialog * Page::assistantDialog() const
+{
+  return m_parent;
+}
+
+
 void Page::enterPageBack() {}
 void Page::enterPageNext() {}
 void Page::leavePageBack() {}
diff --git a/accountwizard/page.h b/accountwizard/page.h
index 1d229f0..307b3af 100644
--- a/accountwizard/page.h
+++ b/accountwizard/page.h
@@ -40,6 +40,8 @@ class Page : public QWidget
     virtual void leavePageNextRequested();
     virtual void leavePageBackRequested();
 
+    KAssistantDialog *assistantDialog() const;
+
   signals:
     Q_SCRIPTABLE void pageEnteredNext();
     Q_SCRIPTABLE void pageEnteredBack();
diff --git a/accountwizard/setupmanager.cpp b/accountwizard/setupmanager.cpp
index 421362d..1edb126 100644
--- a/accountwizard/setupmanager.cpp
+++ b/accountwizard/setupmanager.cpp
@@ -31,6 +31,7 @@
 
 #include <kemailsettings.h>
 #include <kwallet.h>
+#include <KAssistantDialog>
 
 SetupManager::SetupManager( QWidget* parent) :
   QObject(parent),
@@ -92,6 +93,7 @@ void SetupManager::execute()
 {
   m_page->setStatus( i18n( "Setting up account..." ) );
   m_page->setValid( false );
+  m_page->assistantDialog()->enableButton(KDialog::User3, false);
 
   // ### FIXME this is a bad over-simplification and would need a real topological sort
   // but for current usage it is good enough
@@ -139,6 +141,7 @@ void SetupManager::setupNext()
     m_page->setStatus( i18n( "Setup complete." ) );
     m_page->setProgress( 100 );
     m_page->setValid( true );
+    m_page->assistantDialog()->enableButton(KDialog::User3, false);
   } else {
     const int setupObjectCount = m_objectToSetup.size() + m_setupObjects.size();
     const int remainingObjectCount = setupObjectCount - m_objectToSetup.size();


commit c11ef8993ca73417b1ca1a0773199f27542ae5fa
Author: Sandro Knauß <knauss at kolabsys.com>
Date:   Tue Oct 28 09:13:15 2014 +0100

    Accountwizard: Moved setupInfo to public to make script be able to display messages

diff --git a/accountwizard/setupmanager.h b/accountwizard/setupmanager.h
index ad6fcb0..1a2bb54 100644
--- a/accountwizard/setupmanager.h
+++ b/accountwizard/setupmanager.h
@@ -58,6 +58,8 @@ class SetupManager : public QObject
     Q_SCRIPTABLE void execute();
     Q_SCRIPTABLE QObject* ispDB( const QString &type );
 
+    Q_SCRIPTABLE void setupInfo( const QString &msg );
+
     void requestRollback();
 
   signals:
@@ -71,7 +73,6 @@ class SetupManager : public QObject
   private slots:
     void setupSucceeded( const QString &msg );
     void setupFailed( const QString &msg );
-    void setupInfo( const QString &msg );
 
   private:
     QString m_name, m_email, m_password;


commit 5d4ef10d0cfba0519f48da6e24912415993a6fc7
Author: Sandro Knauß <knauss at kolabsys.com>
Date:   Tue Oct 28 09:09:43 2014 +0100

    Accountwizard: Added ldap setBaseDN
    
    do not fail if no username is set (and test for edit mode).

diff --git a/accountwizard/ldap.cpp b/accountwizard/ldap.cpp
index a72100d..c5af9af 100644
--- a/accountwizard/ldap.cpp
+++ b/accountwizard/ldap.cpp
@@ -48,24 +48,29 @@ void Ldap::create()
   //TODO: use ldapclientsearchconfig to write config
   emit info( i18n( "Setting up LDAP server..." ) );
 
-  if ( m_server.isEmpty() || m_user.isEmpty() ) {
-    emit error(i18n("Needed parameters are missing for ldap config server='%1', user='%1'", m_server, m_user));
+  if (m_server.isEmpty()) {
+    emit error(i18n("Needed parameters are missing for ldap config server='%1'", m_server));
+    if (m_editMode) {
+      edit();
+    }
     return;
   }
 
   const QString host = m_server;
 
   // Figure out the basedn
-  QString basedn = host;
-  // If the user gave a full email address, the domain name
-  // of that overrides the server name for the ldap dn
-  const QString user = m_user;
-  int pos = user.indexOf( QLatin1String("@") );
-  if ( pos > 0 ) {
-    const QString h = user.mid( pos+1 );
-    if ( !h.isEmpty() )
-      // The user did type in a domain on the email address. Use that
-      basedn = h;
+  QString basedn = m_baseDn.isEmpty() ? host : m_baseDn;
+  if (m_baseDn.isEmpty() && !m_user.isEmpty()) {
+      // If the user gave a full email address, the domain name
+      // of that overrides the server name for the ldap dn
+      const QString user = m_user;
+      int pos = user.indexOf( QLatin1String("@") );
+      if ( pos > 0 ) {
+        const QString h = user.mid( pos+1 );
+        if ( !h.isEmpty() )
+          // The user did type in a domain on the email address. Use that
+          basedn = h;
+      }
   }
   { // while we're here, write default domain
     KConfig c( QLatin1String("kmail2rc") );
@@ -139,7 +144,10 @@ QString Ldap::securityString()
 
 void Ldap::destroy()
 {
-  emit info( i18n( "LDAP not configuring." ) );
+  if (m_entry >= 0 ) {
+      //TODO: delete ldap entry
+      emit info(i18n("Removed LDAP entry."));
+  }
 }
 
 void Ldap::edit()
@@ -172,6 +180,11 @@ void Ldap::setServer( const QString &server )
   m_server = server;
 }
 
+void Ldap::setBaseDn(const QString &baseDn)
+{
+  m_baseDn = baseDn;
+}
+
 void Ldap::setAuthenticationMethod(const QString& meth)
 {
   m_authMethod = meth;
diff --git a/accountwizard/ldap.h b/accountwizard/ldap.h
index 398ad13..d1f6ab3 100644
--- a/accountwizard/ldap.h
+++ b/accountwizard/ldap.h
@@ -37,6 +37,7 @@ class Ldap : public SetupObject
     Q_SCRIPTABLE void setServer( const QString &server );
     Q_SCRIPTABLE void setAuthenticationMethod( const QString &meth );
     Q_SCRIPTABLE void setBindDn( const QString &bindDn );
+    Q_SCRIPTABLE void setBaseDn( const QString &baseDn );
     Q_SCRIPTABLE void setPassword( const QString &password );
     Q_SCRIPTABLE void setPort(const int port);
     Q_SCRIPTABLE void setSecurity(const KLDAP::LdapServer::Security security);
@@ -60,6 +61,7 @@ class Ldap : public SetupObject
     KLDAP::LdapServer::Security m_security;
     QString m_mech;
     QString m_realm;
+    QString m_baseDn;
     int m_version;
     int m_pageSize;
     int m_timeLimit;
diff --git a/accountwizard/setupautoconfigkolabldap.cpp b/accountwizard/setupautoconfigkolabldap.cpp
index 41aeb45..b97bf1f 100644
--- a/accountwizard/setupautoconfigkolabldap.cpp
+++ b/accountwizard/setupautoconfigkolabldap.cpp
@@ -40,10 +40,11 @@ void SetupAutoconfigKolabLdap::fillLdapServer(int i, QObject *o) const
     ldapServer isp = mIspdb->ldapServers().values()[i];
     Ldap *ldapRes = qobject_cast<Ldap *>(o);
 
-    //TODO: setting dn & filter
+    //TODO: setting filter
 
     ldapRes->setServer(isp.hostname);
     ldapRes->setPort(isp.port);
+    ldapRes->setBaseDn(isp.dn);
     ldapRes->setSecurity(isp.socketType);
     ldapRes->setVersion(isp.ldapVersion);
     ldapRes->setUser(isp.username);


commit 01cd9951ce1fcca0a2faa63ebcafc89f888da246
Author: Sandro Knauß <knauss at kolabsys.com>
Date:   Wed Oct 22 13:17:28 2014 +0200

    Accountwizard: Add Editmode for different setupobjects
    
    * for configfile (freebusy)
    * for transport (smtp)
    * for imap
    * for ldap
    
    KOLAB: 3728

diff --git a/accountwizard/CMakeLists.txt b/accountwizard/CMakeLists.txt
index 7bc69a2..bf71af1 100644
--- a/accountwizard/CMakeLists.txt
+++ b/accountwizard/CMakeLists.txt
@@ -7,6 +7,10 @@ if ( ACCOUNTWIZARD_NO_GHNS )
   add_definitions( -DACCOUNTWIZARD_NO_GHNS )
 endif ()
 
+include_directories(
+  ${CMAKE_SOURCE_DIR}/libkdepim
+)
+
 set(accountwizard_srcs
   dialog.cpp
   typepage.cpp
@@ -48,10 +52,12 @@ set(accountwizard_libs
   ${KDE4_KROSSCORE_LIBS}
   ${KDE4_KDECORE_LIBS}
   ${KDE4_KIO_LIBS}
+  ${KDE4_KCMUTILS_LIBS}
   ${KDEPIMLIBS_KMIME_LIBS}
   ${KDEPIMLIBS_KPIMIDENTITIES_LIBS}
   ${QT_QTGUI_LIBRARY}
   ${QT_QTUITOOLS_LIBRARY}
+  kdepim
 )
 
 if ( NOT ACCOUNTWIZARD_NO_GHNS )
diff --git a/accountwizard/configfile.cpp b/accountwizard/configfile.cpp
index 627333f..6409b6b 100644
--- a/accountwizard/configfile.cpp
+++ b/accountwizard/configfile.cpp
@@ -19,6 +19,7 @@
 
 #include "configfile.h"
 
+#include <KCMultiDialog>
 #include <KConfig>
 #include <KConfigGroup>
 #include <KLocalizedString>
@@ -26,6 +27,7 @@
 
 ConfigFile::ConfigFile( const QString & configName, QObject *parent )
   : SetupObject( parent )
+  , m_editMode(false)
 {
   m_name = configName;
   m_config = new KConfig( configName );
@@ -54,6 +56,11 @@ void ConfigFile::create()
   }
 
   m_config->sync();
+
+  if (m_editMode) {
+      edit();
+  }
+
   emit finished( i18n( "Config file for %1 is writing.", m_name ) );
 }
 
@@ -88,4 +95,29 @@ void ConfigFile::setPassword(const QString& group, const QString& key, const QSt
   m_configData.append( conf );
 }
 
+void ConfigFile::edit()
+{
+    if (m_editName.isEmpty()) {
+        emit error( i18n("No given name for the configuration"));
+        return;
+    }
+
+    if (m_editName == QLatin1String("freebusy")) {
+        KCMultiDialog *dialog = new KCMultiDialog( );
+        dialog->addModule(QLatin1String("korganizer_configfreebusy.desktop"));
+        dialog->show();
+        return;
+    }
+
+    emit error( i18n("Unknown configurationname '%1'", m_editName));
+}
+
+void ConfigFile::setEditName(const QString &name)
+{
+  m_editName = name;
+}
 
+void ConfigFile::setEditMode(const bool editMode)
+{
+  m_editMode = editMode;
+}
diff --git a/accountwizard/configfile.h b/accountwizard/configfile.h
index 6e11ce9..e47bad4 100644
--- a/accountwizard/configfile.h
+++ b/accountwizard/configfile.h
@@ -39,15 +39,20 @@ class ConfigFile : public SetupObject
     ~ConfigFile();
     void create();
     void destroy();
+    void edit();
   public slots:
     Q_SCRIPTABLE void write();
     Q_SCRIPTABLE void setName( const QString & name );
     Q_SCRIPTABLE void setConfig( const QString &group, const QString &key, const QString &value );
     Q_SCRIPTABLE void setPassword( const QString &group, const QString &key, const QString &value );
+    Q_SCRIPTABLE void setEditMode(const bool editMode);
+    Q_SCRIPTABLE void setEditName(const QString &name);
   private:
     QList<Config> m_configData;
     QString m_name;
     KConfig *m_config;
+    QString m_editName;
+    bool m_editMode;
 };
 
 #endif
diff --git a/accountwizard/ldap.cpp b/accountwizard/ldap.cpp
index ac4080f..a72100d 100644
--- a/accountwizard/ldap.cpp
+++ b/accountwizard/ldap.cpp
@@ -18,6 +18,8 @@
 */
 
 #include "ldap.h"
+#include <libkdepim/ldap/ldapclientsearchconfig.h>
+#include <libkdepim/ldap/addhostdialog.h>
 
 #include <KConfig>
 #include <KConfigGroup>
@@ -32,6 +34,8 @@ Ldap::Ldap( QObject *parent )
   , m_pageSize(0)
   , m_timeLimit(0)
   , m_sizeLimit(0)
+  , m_entry(-1)
+  , m_editMode(false)
 {
 }
 
@@ -41,10 +45,13 @@ Ldap::~Ldap()
 
 void Ldap::create()
 {
+  //TODO: use ldapclientsearchconfig to write config
   emit info( i18n( "Setting up LDAP server..." ) );
 
-  if ( m_server.isEmpty() || m_user.isEmpty() )
+  if ( m_server.isEmpty() || m_user.isEmpty() ) {
+    emit error(i18n("Needed parameters are missing for ldap config server='%1', user='%1'", m_server, m_user));
     return;
+  }
 
   const QString host = m_server;
 
@@ -74,10 +81,14 @@ void Ldap::create()
   KConfigGroup group = c.group( "LDAP" );
   bool hasMyServer = false;
   uint selHosts = group.readEntry( "NumSelectedHosts", 0 );
-  for ( uint i = 0 ; i < selHosts && !hasMyServer; ++i )
-    if ( group.readEntry( QString::fromLatin1( "SelectedHost%1" ).arg( i ), QString() ) == host )
+  for ( uint i = 0 ; i < selHosts && !hasMyServer; ++i ) {
+    if ( group.readEntry( QString::fromLatin1( "SelectedHost%1" ).arg( i ), QString() ) == host ) {
       hasMyServer = true;
+      m_entry = i;
+    }
+  }
   if ( !hasMyServer ) {
+    m_entry = selHosts;
     group.writeEntry( "NumSelectedHosts", selHosts + 1 );
     group.writeEntry( QString::fromLatin1( "SelectedHost%1" ).arg( selHosts ), host );
     group.writeEntry( QString::fromLatin1( "SelectedBase%1" ).arg( selHosts ), basedn );
@@ -105,6 +116,10 @@ void Ldap::create()
       group.writeEntry( QString::fromLatin1( "SelectedUser%1" ).arg( selHosts ), m_user );
       group.writeEntry( QString::fromLatin1( "SelectedMech%1" ).arg( selHosts ), m_mech );
     }
+    c.sync();
+  }
+  if (m_editMode) {
+      edit();
   }
   emit finished( i18n( "LDAP set up." ) );
 }
@@ -127,6 +142,26 @@ void Ldap::destroy()
   emit info( i18n( "LDAP not configuring." ) );
 }
 
+void Ldap::edit()
+{
+    if (m_entry < 0) {
+        emit error(i18n("No config found to edit"));
+        return;
+    }
+
+    KLDAP::LdapServer server;
+    KLDAP::LdapClientSearchConfig clientSearchConfig;
+    KConfigGroup group = clientSearchConfig.config()->group( "LDAP" );
+    clientSearchConfig.readConfig(server, group, m_entry, true);
+    AddHostDialog dlg(&server, 0);
+    dlg.setCaption(i18n("Edit Host"));
+
+    if ( dlg.exec() && !server.host().isEmpty() ) { //krazy:exclude=crashy
+        clientSearchConfig.writeConfig(server, group, m_entry, true);
+    }
+}
+
+
 void Ldap::setUser( const QString &user )
 {
   m_user = user;
@@ -193,3 +228,7 @@ void Ldap::setVersion(const int version)
     m_version = version;
 }
 
+void Ldap::setEditMode(const bool editMode)
+{
+    m_editMode = editMode;
+}
diff --git a/accountwizard/ldap.h b/accountwizard/ldap.h
index 4162f72..398ad13 100644
--- a/accountwizard/ldap.h
+++ b/accountwizard/ldap.h
@@ -31,6 +31,7 @@ class Ldap : public SetupObject
     ~Ldap();
     void create();
     void destroy();
+    void edit();
   public slots:
     Q_SCRIPTABLE void setUser( const QString & name );
     Q_SCRIPTABLE void setServer( const QString &server );
@@ -45,6 +46,7 @@ class Ldap : public SetupObject
     Q_SCRIPTABLE void setPageSize(const int pageSize);
     Q_SCRIPTABLE void setTimeLimit(const int timeLimit);
     Q_SCRIPTABLE void setSizeLimit(const int sizeLimit);
+    Q_SCRIPTABLE void setEditMode(const bool editMode);
 
   private:
     QString securityString();
@@ -62,6 +64,8 @@ class Ldap : public SetupObject
     int m_pageSize;
     int m_timeLimit;
     int m_sizeLimit;
+    int m_entry;
+    bool m_editMode;
 };
 
 #endif
diff --git a/accountwizard/resource.cpp b/accountwizard/resource.cpp
index fab7d1c..208eec0 100644
--- a/accountwizard/resource.cpp
+++ b/accountwizard/resource.cpp
@@ -60,7 +60,8 @@ static QVariant::Type argumentType( const QMetaObject *mo, const QString &method
 
 Resource::Resource(const QString& type, QObject* parent) :
   SetupObject( parent ),
-  m_typeIdentifier( type )
+  m_typeIdentifier( type ),
+  m_editMode(false)
 {
 }
 
@@ -88,6 +89,9 @@ void Resource::create()
     foreach ( const AgentInstance &instance, AgentManager::self()->instances() ) {
       kDebug() << instance.type().identifier() << ( instance.type() == type );
       if ( instance.type() == type ) {
+        if (m_editMode) {
+          edit();
+        }
         emit finished( i18n( "Resource '%1' is already set up.", type.name() ) );
         return;
       }
@@ -140,10 +144,19 @@ void Resource::instanceCreateResult(KJob* job)
     }
     m_instance.reconfigure();
   }
-
+  if (m_editMode) {
+      edit();
+  }
   emit finished( i18n( "Resource setup completed." ) );
 }
 
+void Resource::edit()
+{
+  if ( m_instance.isValid() ) {
+      m_instance.configure();
+  }
+}
+
 void Resource::destroy()
 {
   if ( m_instance.isValid() ) {
@@ -162,4 +175,7 @@ void Resource::reconfigure()
     m_instance.reconfigure();
 }
 
-
+void Resource::setEditMode(const bool editMode)
+{
+    m_editMode = editMode;
+}
diff --git a/accountwizard/resource.h b/accountwizard/resource.h
index ab09ba1..25b5be3 100644
--- a/accountwizard/resource.h
+++ b/accountwizard/resource.h
@@ -33,12 +33,14 @@ class Resource : public SetupObject
     explicit Resource( const QString &type, QObject *parent = 0 );
     void create();
     void destroy();
+    void edit();
 
   public slots:
     Q_SCRIPTABLE void setName( const QString &name );
     Q_SCRIPTABLE void setOption( const QString &key, const QVariant &value );
     Q_SCRIPTABLE QString identifier();
     Q_SCRIPTABLE void reconfigure();
+    Q_SCRIPTABLE void setEditMode(const bool editMode);
 
   private slots:
     void instanceCreateResult( KJob* job );
@@ -47,5 +49,7 @@ class Resource : public SetupObject
     QString m_typeIdentifier, m_name;
     QMap<QString, QVariant> m_settings;
     Akonadi::AgentInstance m_instance;
+
+    bool m_editMode;
 };
 #endif
diff --git a/accountwizard/transport.cpp b/accountwizard/transport.cpp
index 7d20b42..3ffc4df 100644
--- a/accountwizard/transport.cpp
+++ b/accountwizard/transport.cpp
@@ -76,7 +76,8 @@ Transport::Transport(const QString& type, QObject* parent) :
   m_transportId( -1 ),
   m_port( -1 ),
   m_encr( MailTransport::Transport::EnumEncryption::TLS ),
-  m_auth( MailTransport::Transport::EnumAuthenticationType::PLAIN )
+  m_auth( MailTransport::Transport::EnumAuthenticationType::PLAIN ),
+  m_editMode(false)
 {
   m_transportType = stringToValue( transportTypeEnums, transportTypeEnumsSize, type );
   if ( m_transportType == MailTransport::Transport::EnumType::SMTP )
@@ -105,6 +106,9 @@ void Transport::create()
   mt->writeConfig();
   MailTransport::TransportManager::self()->addTransport( mt );
   MailTransport::TransportManager::self()->setDefaultTransport( mt->id() );
+  if (m_editMode) {
+      edit();
+  }
   emit finished( i18n( "Mail transport account set up." ) );
 }
 
@@ -114,6 +118,16 @@ void Transport::destroy()
   emit info( i18n( "Mail transport account deleted." ) );
 }
 
+void Transport::edit()
+{
+    MailTransport::Transport* mt = MailTransport::TransportManager::self()->transportById(m_transportId, false);
+    if (!mt) {
+        emit error(i18n("Could not load config dialog for uid=%1", m_transportId));
+    } else {
+        MailTransport::TransportManager::self()->configureTransport(mt, 0);
+    }
+}
+
 void Transport::setName( const QString &name )
 {
   m_name = name;
@@ -154,3 +168,7 @@ int Transport::transportId() const
   return m_transportId;
 }
 
+void Transport::setEditMode(const bool editMode)
+{
+  m_editMode = editMode;
+}
diff --git a/accountwizard/transport.h b/accountwizard/transport.h
index 36666cb..6d7c82e 100644
--- a/accountwizard/transport.h
+++ b/accountwizard/transport.h
@@ -31,6 +31,7 @@ class Transport : public SetupObject
     explicit Transport( const QString &type, QObject *parent = 0 );
     void create();
     void destroy();
+    void edit();
 
     int transportId() const;
 
@@ -42,6 +43,7 @@ class Transport : public SetupObject
     Q_SCRIPTABLE void setPassword( const QString &password );
     Q_SCRIPTABLE void setEncryption( const QString &encryption );
     Q_SCRIPTABLE void setAuthenticationType( const QString &authType );
+    Q_SCRIPTABLE void setEditMode(const bool editMode);
 
   private:
     MailTransport::Transport::EnumEncryption stringToEncryption( const QString &encryptionString );
@@ -57,6 +59,8 @@ class Transport : public SetupObject
     QString m_password;
     MailTransport::Transport::EnumEncryption::type m_encr;
     MailTransport::Transport::EnumAuthenticationType::type m_auth;
+
+    bool m_editMode;
 };
 
 #endif


commit 5c208cb7780968cf596698bd12f0b621eb94cb6c
Author: Christian Mollekopf <chrigi_1 at fastmail.fm>
Date:   Sun Oct 26 17:33:18 2014 +0100

    IncidenceEditor-Ng: Fixed crash

diff --git a/incidenceeditor-ng/editoritemmanager.cpp b/incidenceeditor-ng/editoritemmanager.cpp
index 0a022a7..bc7827c 100644
--- a/incidenceeditor-ng/editoritemmanager.cpp
+++ b/incidenceeditor-ng/editoritemmanager.cpp
@@ -78,7 +78,7 @@ class ItemEditorPrivate
 };
 
 ItemEditorPrivate::ItemEditorPrivate( Akonadi::IncidenceChanger *changer, EditorItemManager *qq )
-  : q_ptr( qq ), /* mItemMonitor( 0 ),  */mIsCounterProposal( false )
+  : q_ptr( qq ), mItemMonitor( 0 ), mIsCounterProposal( false )
   , currentAction(EditorItemManager::None)
 {
   mFetchScope.fetchFullPayload();


commit 4b8d8e4630332175bc0699442772d53869a31eeb
Author: Sandro Knauß <knauss at kolabsys.com>
Date:   Fri Oct 24 21:41:49 2014 +0200

    Collapse Person node always by default
    
    KOLAB: 3623

diff --git a/korganizer/akonadicollectionview.cpp b/korganizer/akonadicollectionview.cpp
index 503300e..e128288 100644
--- a/korganizer/akonadicollectionview.cpp
+++ b/korganizer/akonadicollectionview.cpp
@@ -164,7 +164,11 @@ private Q_SLOTS:
         for (int i = start; i <= end; i++) {
             const QModelIndex index = mTreeView->model()->index(i, 0, parent);
             // kDebug() << "expanding " << index.data().toString();
-            mTreeView->expand(index);
+            if (index.data(NodeTypeRole).toInt() == PersonNodeRole) {
+                mTreeView->collapse(index);
+            } else {
+                mTreeView->expand(index);
+            }
             if (mTreeView->model()->hasChildren(index)) {
                 onSourceRowsInserted(index, 0, mTreeView->model()->rowCount(index) - 1);
             }




More information about the commits mailing list