diff --git a/akonadi/CMakeLists.txt b/akonadi/CMakeLists.txt index e4d9a2760..1cd22870f 100644 --- a/akonadi/CMakeLists.txt +++ b/akonadi/CMakeLists.txt @@ -1,269 +1,271 @@ project(akonadi-kde) add_definitions( -DKDE_DEFAULT_DEBUG_AREA=5250 ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${KDE4_ENABLE_EXCEPTIONS}" ) if(CMAKE_COMPILE_GCOV) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage") endif(CMAKE_COMPILE_GCOV) if (KDE4_BUILD_TESTS) # only with this macro the AKONADI_TESTS_EXPORT macro will do something add_definitions(-DCOMPILING_TESTS) add_subdirectory( tests ) endif (KDE4_BUILD_TESTS) add_definitions( -DQT_NO_CAST_FROM_ASCII ) add_definitions( -DQT_NO_CAST_TO_ASCII ) add_subdirectory( kabc ) add_subdirectory( kmime ) include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${QT_QTDBUS_INCLUDE_DIR} ${Boost_INCLUDE_DIR} ${KDE4_INCLUDE_DIR} ${AKONADI_INCLUDE_DIR} ${AKONADI_INCLUDE_DIR}/akonadi/private ) # libakonadi-kde set( akonadikde_LIB_SRC entity.cpp # keep it at top to not break enable-final agentbase.cpp agentfilterproxymodel.cpp agentinstance.cpp agentinstancecreatejob.cpp agentinstancemodel.cpp agentinstancewidget.cpp agentmanager.cpp agenttype.cpp agenttypemodel.cpp agenttypewidget.cpp agenttypedialog.cpp attribute.cpp attributefactory.cpp cachepolicy.cpp cachepolicypage.cpp changerecorder.cpp collection.cpp collectioncopyjob.cpp collectioncreatejob.cpp collectiondeletejob.cpp collectiondialog.cpp collectionfilterproxymodel.cpp collectiongeneralpropertiespage.cpp collectionfetchjob.cpp collectionfetchscope.cpp collectionmodel.cpp collectionmodel_p.cpp collectionmodifyjob.cpp collectionmovejob.cpp collectionpathresolver.cpp collectionpropertiesdialog.cpp collectionpropertiespage.cpp collectionrequester.cpp collectionrightsattribute.cpp collectionselectjob.cpp collectionstatistics.cpp collectionstatisticsdelegate.cpp collectionstatisticsjob.cpp collectionstatisticsmodel.cpp collectionsync.cpp collectionview.cpp control.cpp descendantsproxymodel.cpp entitycache.cpp entitydisplayattribute.cpp entityhiddenattribute.cpp entitytreemodel.cpp entitytreemodel_p.cpp entityfilterproxymodel.cpp entitytreeviewstatesaver.cpp erroroverlay.cpp exception.cpp favoritecollectionsmodel.cpp firstrun.cpp flatcollectionproxymodel.cpp item.cpp itemcreatejob.cpp itemcopyjob.cpp itemdeletejob.cpp itemfetchjob.cpp itemfetchscope.cpp itemmodel.cpp itemmonitor.cpp itemmovejob.cpp itemsearchjob.cpp itemserializer.cpp itemserializerplugin.cpp itemmodifyjob.cpp itemsync.cpp itemview.cpp job.cpp linkjob.cpp filteractionjob.cpp mimetypechecker.cpp monitor.cpp monitor_p.cpp pastehelper.cpp preprocessorbase.cpp protocolhelper.cpp resourcebase.cpp resourcescheduler.cpp resourceselectjob.cpp + resourcesynchronizationjob.cpp searchcreatejob.cpp selectionproxymodel.cpp selftestdialog.cpp session.cpp servermanager.cpp standardactionmanager.cpp statisticsproxymodel.cpp statisticstooltipproxymodel.cpp subscriptionjob.cpp subscriptionchangeproxymodel.cpp subscriptiondialog.cpp subscriptionmodel.cpp transactionjobs.cpp transactionsequence.cpp transportresourcebase.cpp unlinkjob.cpp # Temporary until ported to Qt-plugin framework pluginloader.cpp ) # DBus interfaces and adaptors set(akonadi_xml ${AKONADI_DBUS_INTERFACES_DIR}/org.freedesktop.Akonadi.NotificationManager.xml) set_source_files_properties(${akonadi_xml} PROPERTIES INCLUDE "notificationmessage_p.h") qt4_add_dbus_interface( akonadikde_LIB_SRC ${akonadi_xml} notificationmanagerinterface ) qt4_add_dbus_interfaces( akonadikde_LIB_SRC ${AKONADI_DBUS_INTERFACES_DIR}/org.freedesktop.Akonadi.AgentManager.xml ) qt4_add_dbus_interfaces( akonadikde_LIB_SRC ${AKONADI_DBUS_INTERFACES_DIR}/org.freedesktop.Akonadi.Tracer.xml ) qt4_add_dbus_adaptor( akonadikde_LIB_SRC ${AKONADI_DBUS_INTERFACES_DIR}/org.freedesktop.Akonadi.Resource.xml resourcebase.h Akonadi::ResourceBase ) qt4_add_dbus_adaptor( akonadikde_LIB_SRC ${AKONADI_DBUS_INTERFACES_DIR}/org.freedesktop.Akonadi.Preprocessor.xml preprocessorbase.h Akonadi::PreprocessorBase ) qt4_add_dbus_adaptor( akonadikde_LIB_SRC ${AKONADI_DBUS_INTERFACES_DIR}/org.freedesktop.Akonadi.Agent.Status.xml agentbase.h Akonadi::AgentBase ) qt4_add_dbus_adaptor( akonadikde_LIB_SRC ${AKONADI_DBUS_INTERFACES_DIR}/org.freedesktop.Akonadi.Agent.Control.xml agentbase.h Akonadi::AgentBase ) # TODO move this to kdesupport/akonadi/interfaces qt4_add_dbus_adaptor( akonadikde_LIB_SRC interfaces/org.freedesktop.Akonadi.Resource.Transport.xml transportresourcebase_p.h Akonadi::TransportResourceBasePrivate ) #qt4_add_dbus_interface( akonadikde_LIB_SRC interfaces/org.freedesktop.Akonadi.Resource.Transport.xml resourcetransportinterface ) kde4_add_ui_files( akonadikde_LIB_SRC cachepolicypage.ui collectiongeneralpropertiespage.ui subscriptiondialog.ui controlprogressindicator.ui selftestdialog.ui ) kde4_add_library( akonadi-kde SHARED ${akonadikde_LIB_SRC} ) macro_ensure_version( "4.2.0" ${KDE_VERSION} KDE_IS_AT_LEAST_42 ) target_link_libraries( akonadi-kde ${KDE4_SOLID_LIBS} ${QT_QTNETWORK_LIBRARY} ${QT_QTDBUS_LIBRARY} ${QT_QTSQL_LIBRARY} ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} ${AKONADI_COMMON_LIBRARIES} ) set( AKONADI_KDE_DEPS ${KDE4_KDEUI_LIBS} ${QT_QTDBUS_LIBRARY} ${QT_QTCORE_LIBRARY} ) if(${KDE_IS_AT_LEAST_42}) target_link_libraries( akonadi-kde LINK_INTERFACE_LIBRARIES ${AKONADI_KDE_DEPS}) else(${KDE_IS_AT_LEAST_42}) target_link_libraries( akonadi-kde ${AKONADI_KDE_DEPS}) endif(${KDE_IS_AT_LEAST_42}) set_target_properties( akonadi-kde PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} ) install( TARGETS akonadi-kde EXPORT kdepimlibsLibraryTargets ${INSTALL_TARGETS_DEFAULT_ARGS} ) ########### install files ############### install( FILES akonadi_export.h agentbase.h agentfilterproxymodel.h agentinstance.h agentinstancecreatejob.h agentinstancemodel.h agentinstancewidget.h agentmanager.h agenttype.h agenttypemodel.h agenttypewidget.h agenttypedialog.h attribute.h attributefactory.h cachepolicy.h changerecorder.h collection.h collectioncopyjob.h collectioncreatejob.h collectiondeletejob.h collectiondialog.h collectionfilterproxymodel.h collectionfetchjob.h collectionfetchscope.h collectionmodel.h collectionmodifyjob.h collectionpropertiesdialog.h collectionpropertiespage.h collectionrequester.h collectionstatisticsdelegate.h collectionstatisticsmodel.h collectionstatistics.h collectionstatisticsjob.h collectionview.h control.h descendantsproxymodel.h entity.h entitydisplayattribute.h entityhiddenattribute.h entitytreemodel.h entityfilterproxymodel.h entitytreeviewstatesaver.h exception.h favoritecollectionsmodel.h item.h itemcreatejob.h itemcopyjob.h itemdeletejob.h itemfetchjob.h itemfetchscope.h itemmodel.h itemmodifyjob.h itemmonitor.h itemmovejob.h itempayloadinternals_p.h itemsearchjob.h itemserializerplugin.h itemsync.h itemview.h job.h linkjob.h filteractionjob.h mimetypechecker.h monitor.h qtest_akonadi.h preprocessorbase.h resourcebase.h + resourcesynchronizationjob.h searchcreatejob.h selectionproxymodel.h session.h servermanager.h standardactionmanager.h statisticsproxymodel.h statisticstooltipproxymodel.h transactionjobs.h transactionsequence.h transportresourcebase.h unlinkjob.h DESTINATION ${INCLUDE_INSTALL_DIR}/akonadi COMPONENT Devel ) install( FILES collectionpathresolver_p.h DESTINATION ${INCLUDE_INSTALL_DIR}/akonadi/private COMPONENT Devel ) install( FILES kcfg2dbus.xsl DESTINATION ${DATA_INSTALL_DIR}/akonadi-kde ) diff --git a/akonadi/kmime/CMakeLists.txt b/akonadi/kmime/CMakeLists.txt index 878d6c9bd..1dcfa2f37 100644 --- a/akonadi/kmime/CMakeLists.txt +++ b/akonadi/kmime/CMakeLists.txt @@ -1,44 +1,43 @@ include_directories( ${CMAKE_SOURCE_DIR}/ ${QT_QTDBUS_INCLUDE_DIR} ${Boost_INCLUDE_DIR} ) add_subdirectory( tests ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII ${KDE4_ENABLE_EXCEPTIONS}" ) ########### next target ############### set( kmimeakonadi_LIB_SRC addressattribute.cpp localfolders.cpp localfoldersbuildjob.cpp messagemodel.cpp messageparts.cpp messagethreadingattribute.cpp messagethreaderproxymodel.cpp - resourcesynchronizationjob.cpp # copied from playground/pim/akonaditest/resourcetester ) kde4_add_kcfg_files( kmimeakonadi_LIB_SRC localfolderssettings.kcfgc ) install( FILES localfolders.kcfg DESTINATION ${KCFG_INSTALL_DIR} ) kde4_add_library( akonadi-kmime SHARED ${kmimeakonadi_LIB_SRC} ) target_link_libraries( akonadi-kmime akonadi-kde kmime ${QT_QTGUI_LIBRARY} ${KDE4_KDECORE_LIBS} ${KDE4_KDEUI_LIBS}) set_target_properties( akonadi-kmime PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} ) install(TARGETS akonadi-kmime EXPORT kdepimlibsLibraryTargets ${INSTALL_TARGETS_DEFAULT_ARGS}) ########### install files ############### install( FILES addressattribute.h localfolders.h akonadi-kmime_export.h messagemodel.h messageparts.h messagethreadingattribute.h messagethreaderproxymodel.h DESTINATION ${INCLUDE_INSTALL_DIR}/akonadi/kmime COMPONENT Devel ) diff --git a/akonadi/kmime/resourcesynchronizationjob.cpp b/akonadi/resourcesynchronizationjob.cpp similarity index 75% rename from akonadi/kmime/resourcesynchronizationjob.cpp rename to akonadi/resourcesynchronizationjob.cpp index e6a8946f2..7f5600306 100644 --- a/akonadi/kmime/resourcesynchronizationjob.cpp +++ b/akonadi/resourcesynchronizationjob.cpp @@ -1,121 +1,126 @@ /* * Copyright (c) 2009 Volker Krause * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #include "resourcesynchronizationjob.h" #include #include #include #include #include #include #include namespace Akonadi { class ResourceSynchronizationJobPrivate { public: - ResourceSynchronizationJobPrivate() : + ResourceSynchronizationJobPrivate( ResourceSynchronizationJob* parent ) : + q( parent ), interface( 0 ), safetyTimer( 0 ), timeoutCount( 0 ) {} + ResourceSynchronizationJob *q; AgentInstance instance; QDBusInterface* interface; QTimer* safetyTimer; int timeoutCount; static int timeoutCountLimit; + + void slotSynchronized(); + void slotTimeout(); }; int ResourceSynchronizationJobPrivate::timeoutCountLimit = 60; ResourceSynchronizationJob::ResourceSynchronizationJob(const AgentInstance& instance, QObject* parent) : KJob( parent ), - d( new ResourceSynchronizationJobPrivate ) + d( new ResourceSynchronizationJobPrivate( this ) ) { d->instance = instance; d->safetyTimer = new QTimer( this ); connect( d->safetyTimer, SIGNAL(timeout()), SLOT(slotTimeout()) ); d->safetyTimer->setInterval( 10 * 1000 ); d->safetyTimer->setSingleShot( false ); } ResourceSynchronizationJob::~ResourceSynchronizationJob() { delete d; } void ResourceSynchronizationJob::start() { if ( !d->instance.isValid() ) { setError( UserDefinedError ); setErrorText( i18n( "Invalid resource instance." ) ); emitResult(); return; } d->interface = new QDBusInterface( QString::fromLatin1( "org.freedesktop.Akonadi.Resource.%1" ).arg( d->instance.identifier() ), QString::fromLatin1( "/" ), QString::fromLatin1( "org.freedesktop.Akonadi.Resource" ), QDBusConnection::sessionBus(), this ); connect( d->interface, SIGNAL(synchronized()), SLOT(slotSynchronized()) ); if ( d->interface->isValid() ) { d->instance.synchronize(); d->safetyTimer->start(); } else { setError( UserDefinedError ); setErrorText( i18n( "Unable to obtain D-Bus interface for resource '%1'", d->instance.identifier() ) ); emitResult(); return; } } -void ResourceSynchronizationJob::slotSynchronized() +void ResourceSynchronizationJobPrivate::slotSynchronized() { - disconnect( d->interface, SIGNAL(synchronized()), this, SLOT(slotSynchronized()) ); - d->safetyTimer->stop(); - emitResult(); + q->disconnect( interface, SIGNAL(synchronized()), q, SLOT(slotSynchronized()) ); + safetyTimer->stop(); + q->emitResult(); } -void ResourceSynchronizationJob::slotTimeout() +void ResourceSynchronizationJobPrivate::slotTimeout() { - d->instance = AgentManager::self()->instance( d->instance.identifier() ); - d->timeoutCount++; - - if ( d->timeoutCount > d->timeoutCountLimit ) { - d->safetyTimer->stop(); - setError( UserDefinedError ); - setErrorText( i18n( "Resource synchronization timed out." ) ); - emitResult(); + instance = AgentManager::self()->instance( instance.identifier() ); + timeoutCount++; + + if ( timeoutCount > timeoutCountLimit ) { + safetyTimer->stop(); + q->setError( KJob::UserDefinedError ); + q->setErrorText( i18n( "Resource synchronization timed out." ) ); + q->emitResult(); return; } - if ( d->instance.status() == AgentInstance::Idle ) { + if ( instance.status() == AgentInstance::Idle ) { // try again, we might have lost the synchronized() signal - kDebug() << "trying again to sync resource" << d->instance.identifier(); - d->instance.synchronize(); + kDebug() << "trying again to sync resource" << instance.identifier(); + instance.synchronize(); } } } #include "resourcesynchronizationjob.moc" diff --git a/akonadi/kmime/resourcesynchronizationjob.h b/akonadi/resourcesynchronizationjob.h similarity index 67% rename from akonadi/kmime/resourcesynchronizationjob.h rename to akonadi/resourcesynchronizationjob.h index 6ed04db2f..9d29e5dea 100644 --- a/akonadi/kmime/resourcesynchronizationjob.h +++ b/akonadi/resourcesynchronizationjob.h @@ -1,58 +1,67 @@ /* * Copyright (c) 2009 Volker Krause * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #ifndef AKONADI_RESOURCESYNCJOB_H #define AKONADI_RESOURCESYNCJOB_H +#include "akonadi_export.h" #include namespace Akonadi { class AgentInstance; class ResourceSynchronizationJobPrivate; /** - Synchronizes a given resource. + Synchronizes a given resource. If you only want to trigger a + resource synchronization without being interested in the result, + using Akonadi::AgentInstance::synchronize() is enough. If you want + to wait until it's finished, this job is for you. + + @note This is a KJob not an Akonadi::Job, so it wont auto-start! + + @since 4.4 */ -class ResourceSynchronizationJob : public KJob +class AKONADI_EXPORT ResourceSynchronizationJob : public KJob { Q_OBJECT public: /** Create a new synchronization job for the given agent. + @param instance The resource instance to synchronize. */ ResourceSynchronizationJob( const AgentInstance &instance, QObject *parent = 0 ); /** Destructor. */ ~ResourceSynchronizationJob(); /* reimpl */ void start(); - private slots: - void slotSynchronized(); - void slotTimeout(); - private: ResourceSynchronizationJobPrivate* const d; + friend class ResourceSynchronizationJobPrivate; + + Q_PRIVATE_SLOT( d, void slotSynchronized() ) + Q_PRIVATE_SLOT( d, void slotTimeout() ) }; } #endif