[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdepim/kmail
From: Thomas McGuire <mcguire () kde ! org>
Date: 2008-12-18 17:22:07
Message-ID: 1229620927.973816.24507.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 898670 by tmcguire:
Start the Akonadi server on startup of KMail if there is at least one contact \
resource using it. This prevents Akonadi from starting up at inconvenient moments, \
for example during POP3 mailcheck filtering with the filter criteria "is in \
addressbook", where the Akonadi::Control::start() subeventloop would wreak havoc with \
the POP3 state logic, causing duplicate mails in some conditions.
M +26 -9 CMakeLists.txt
M +83 -2 kmkernel.cpp
--- trunk/KDE/kdepim/kmail/CMakeLists.txt #898669:898670
@@ -299,15 +299,32 @@
endif(KMAIL_SQLITE_INDEX)
kde4_add_library(kmailprivate SHARED ${kmailprivate_LIB_SRCS})
-kdepim4_link_unique_libraries(kmailprivate ${KDE4_KHTML_LIBRARY} \
${KDE4_THREADWEAVER_LIBRARY}
- ${KDE4_KMIME_LIBRARY} \
${KDE4_KPIMIDENTITIES_LIBRARY}
- ${KDE4_PHONON_LIBRARY} \
${KDE4_KNOTIFYCONFIG_LIBRARY}
- ${KDE4_KTNEF_LIBRARY} ${KDE4_KUTILS_LIBS} \
- ${KDE4_MAILTRANSPORT_LIBRARY} \
${KDE4_KIMAP_LIBRARY}
- ${KDE4_KPARTS_LIBRARY} \
${KDE4_KRESOURCES_LIBRARY} kleo
- ${QGPGME_LIBRARIES} mimelib ksieve kpgp \
kdepim
- ${QT_QT3SUPPORT_LIBRARY} ${KDE4_KIO_LIBS} \
- ${KDE4_KABC_LIBS} ${KDE4_KPIMUTILS_LIBS} \
${KDE4_KDE3SUPPORT_LIBS}) +kdepim4_link_unique_libraries(kmailprivate
+ ${KDE4_KHTML_LIBRARY}
+ ${KDE4_THREADWEAVER_LIBRARY}
+ ${KDE4_KMIME_LIBRARY}
+ ${KDE4_KPIMIDENTITIES_LIBRARY}
+ ${KDE4_PHONON_LIBRARY}
+ ${KDE4_KNOTIFYCONFIG_LIBRARY}
+ ${KDE4_KTNEF_LIBRARY}
+ ${KDE4_KUTILS_LIBS}
+ ${KDE4_MAILTRANSPORT_LIBRARY}
+ ${KDE4_KIMAP_LIBRARY}
+ ${KDE4_KPARTS_LIBRARY}
+ ${KDE4_KRESOURCES_LIBRARY}
+ kleo
+ ${QGPGME_LIBRARIES}
+ mimelib
+ ksieve
+ kpgp
+ kdepim
+ ${QT_QT3SUPPORT_LIBRARY}
+ ${KDE4_KIO_LIBS}
+ ${KDE4_KABC_LIBS}
+ ${KDE4_KPIMUTILS_LIBS}
+ ${KDE4_KDE3SUPPORT_LIBS}
+ ${KDE4_AKONADI_LIBS}
+)
if(KMAIL_SQLITE_INDEX)
kdepim4_link_unique_libraries(kmailprivate ${SQLITE_LIBRARIES})
--- trunk/KDE/kdepim/kmail/kmkernel.cpp #898669:898670
@@ -30,12 +30,15 @@
#include "recentaddresses.h"
using KPIM::RecentAddresses;
#include "kmmsgdict.h"
-#include <kpimidentities/identity.h>
-#include <kpimidentities/identitymanager.h>
+
#include "configuredialog.h"
#include "kmcommands.h"
#include "kmsystemtray.h"
+// kdepimlibs includes
+#include <akonadi/control.h>
+#include <kpimidentities/identity.h>
+#include <kpimidentities/identitymanager.h>
#include <mailtransport/transport.h>
#include <mailtransport/transportmanager.h>
@@ -1363,12 +1366,90 @@
the_templatesFolder->open( "kmkernel" );
}
+/**
+ * This checks if the addressbook (kabc from kdepimlibs) already uses at least
+ * one Akonadi resource.
+ */
+static bool doesAddressbookUseAkonadi()
+{
+ // We check if there is at least one Akonadi resource by manually inspecting
+ // the kresource config file at $KDEHOM/share/config/kresources/contact/stdrc.
+ // A snippet of that config file is given below.
+ //
+ // Using KRES::Manager to iterate over the resources would be much more elegant,
+ // but the manager itself starts Akonadi, which we want to avoid here.
+ //
+ // Example layout of the KRES config file:
+ //
+ // [General]
+ // PassiveResourceKeys=GGqwZHEbfA,1lBPacjbOG,ok3MvDmaXR
+ // ResourceKeys=6NgdlCaLBb
+ // Standard=ok3MvDmaXR
+ //
+ // [Resource_1lBPacjbOG]
+ // ...
+ // ResourceName=LDAP Address Book
+ // ResourceType=ldapkio
+ //
+ // [Resource_GGqwZHEbfA]
+ // ...
+ // ResourceName=Akonadi Compatibility Resource
+ // ResourceType=akonadi
+ // Config file path code stolen from ManagerImpl::createStandardConfig() of
+ // kresouces
+ KConfig kresConfig( KStandardDirs::locateLocal( "config",
+ QString( "kresources/contact/stdrc" ) ) );
+
+ if ( !kresConfig.hasGroup( "General" ) ) {
+ kWarning() << "No KResources config file for contacts found!";
+ return false;
+ }
+
+ KConfigGroup general = kresConfig.group( "General" );
+ QString passiveKeys = general.readEntry( "PassiveResourceKeys" );
+ QString keys = general.readEntry( "ResourceKeys" );
+
+ QStringList resourceKeys;
+ resourceKeys += passiveKeys.split( ",", QString::SkipEmptyParts );
+ resourceKeys += keys.split( ",", QString::SkipEmptyParts );
+
+ foreach ( const QString &key, resourceKeys ) {
+ QString groupName = QString( "Resource_%1" ).arg( key );
+ if ( !kresConfig.hasGroup( groupName ) ) {
+ kWarning() << "Resource group" << groupName << "not found in KRES config!";
+ continue;
+ }
+
+ KConfigGroup resourceGroup = kresConfig.group( groupName );
+ QString resourceType = resourceGroup.readEntry( "ResourceType" );
+ if ( resourceType.toLower() == "akonadi" )
+ return true;
+ }
+
+ return false;
+}
+
void KMKernel::init()
{
the_shuttingDown = false;
the_server_is_ready = false;
+ // If KABC is using Akonadi, start it now. Otherwise, it gets started when the
+ // addressbook is first used, which causes all kind of problems because
+ // Akonadi::Control::start() uses a subeventloop.
+ // Since the KMail main loop is not yet started when invoking init(), it should
+ // be safe here.
+ //
+ // For example, if not doing this, Akonadi can be started when downloading POP3
+ // mails and the "is in addressbook" filter criteria is used. In some \
cirumstances, + // the subeventloop would destroy logic in PopAccount, leading to \
duplicate mails + // because mails weren't correctly deleted on the server.
+ if ( doesAddressbookUseAkonadi() ) {
+ kDebug() << "The addressbook is using Akonadi, starting Akonadi now...";
+ Akonadi::Control::start();
+ }
+
KConfig* cfg = KMKernel::config();
QDir dir;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic