diff --git a/agents/archivemailagent/CMakeLists.txt b/agents/archivemailagent/CMakeLists.txt index 69307d9b6..48ed07671 100644 --- a/agents/archivemailagent/CMakeLists.txt +++ b/agents/archivemailagent/CMakeLists.txt @@ -1,90 +1,88 @@ add_definitions(-DTRANSLATION_DOMAIN=\"akonadi_archivemail_agent\") set(libarchivemailagent_SRCS archivemailkernel.cpp archivemailmanager.cpp archivemailinfo.cpp job/archivejob.cpp archivemailagentutil.cpp ) kconfig_add_kcfg_files(libarchivemailagent_SRCS settings/archivemailagentsettings.kcfgc ) qt5_add_dbus_adaptor(libarchivemailagent_SRCS org.freedesktop.Akonadi.ArchiveMailAgent.xml archivemailagent.h ArchiveMailAgent) ecm_qt_declare_logging_category(libarchivemailagent_SRCS HEADER archivemailagent_debug.h IDENTIFIER ARCHIVEMAILAGENT_LOG CATEGORY_NAME org.kde.pim.archivemailagent) ki18n_wrap_ui(libarchivemailagent_SRCS ui/archivemailwidget.ui ) add_library(archivemailagent STATIC ${libarchivemailagent_SRCS}) target_link_libraries(archivemailagent KF5::MailCommon KF5::I18n KF5::Notifications KF5::IconThemes KF5::KIOWidgets ) ########################### Agent executable ################################ add_executable(akonadi_archivemail_agent archivemailagent.cpp) target_link_libraries(akonadi_archivemail_agent archivemailagent KF5::AkonadiCore KF5::IdentityManagement KF5::AkonadiMime KF5::AkonadiAgentBase KF5::DBusAddons KF5::XmlGui - KF5::WindowSystem KF5::KIOWidgets KF5::Notifications KF5::MailCommon KF5::Libkdepim KF5::IconThemes KF5::I18n ) if( APPLE ) set_target_properties(akonadi_archivemail_agent PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${kmail_SOURCE_DIR}/agents/Info.plist.template) set_target_properties(akonadi_archivemail_agent PROPERTIES MACOSX_BUNDLE_GUI_IDENTIFIER "org.kde.Akonadi.archivemail") set_target_properties(akonadi_archivemail_agent PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "KDE Akonadi Email Archiver") endif () install(TARGETS akonadi_archivemail_agent ${KDE_INSTALL_TARGETS_DEFAULT_ARGS} ) install(FILES archivemailagent.desktop DESTINATION "${KDE_INSTALL_DATAROOTDIR}/akonadi/agents") install(FILES akonadi_archivemail_agent.notifyrc DESTINATION ${KDE_INSTALL_KNOTIFY5RCDIR} ) if (BUILD_TESTING) add_subdirectory(autotests) endif() ########## Configuration ############## set(archivemailagentconfig_SRCS addarchivemaildialog.cpp archivemailwidget.cpp widgets/formatcombobox.cpp widgets/unitcombobox.cpp ) kcoreaddons_add_plugin(archivemailagentconfig JSON archivemailagentconfig.json SOURCES ${archivemailagentconfig_SRCS} INSTALL_NAMESPACE akonadi/config ) target_link_libraries(archivemailagentconfig archivemailagent KF5::AkonadiCore - KF5::WindowSystem KF5::XmlGui KF5::I18n ) install(FILES settings/archivemailagentsettings.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR}) diff --git a/agents/archivemailagent/archivemailagent.cpp b/agents/archivemailagent/archivemailagent.cpp index ddd8d7605..60653680d 100644 --- a/agents/archivemailagent/archivemailagent.cpp +++ b/agents/archivemailagent/archivemailagent.cpp @@ -1,154 +1,153 @@ /* Copyright (C) 2012-2018 Montel Laurent 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; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "archivemailagent.h" #include "archivemailagentadaptor.h" #include "archivemailmanager.h" #include "archivemailagentsettings.h" #include #include #include #include #include #include #include -#include #include #include #include //#define DEBUG_ARCHIVEMAILAGENT 1 ArchiveMailAgent::ArchiveMailAgent(const QString &id) : Akonadi::AgentBase(id) { Kdelibs4ConfigMigrator migrate(QStringLiteral("archivemailagent")); migrate.setConfigFiles(QStringList() << QStringLiteral("akonadi_archivemail_agentrc") << QStringLiteral("akonadi_archivemail_agent.notifyrc")); migrate.migrate(); connect(this, &Akonadi::AgentBase::reloadConfiguration, this, &ArchiveMailAgent::reload); mArchiveManager = new ArchiveMailManager(this); connect(mArchiveManager, &ArchiveMailManager::needUpdateConfigDialogBox, this, &ArchiveMailAgent::needUpdateConfigDialogBox); Akonadi::Monitor *collectionMonitor = new Akonadi::Monitor(this); collectionMonitor->setObjectName(QStringLiteral("ArchiveMailCollectionMonitor")); collectionMonitor->fetchCollection(true); collectionMonitor->ignoreSession(Akonadi::Session::defaultSession()); collectionMonitor->collectionFetchScope().setAncestorRetrieval(Akonadi::CollectionFetchScope::All); collectionMonitor->setMimeTypeMonitored(KMime::Message::mimeType()); new ArchiveMailAgentAdaptor(this); KDBusConnectionPool::threadConnection().registerObject(QStringLiteral("/ArchiveMailAgent"), this, QDBusConnection::ExportAdaptors); const QString service = Akonadi::ServerManager::self()->agentServiceName(Akonadi::ServerManager::Agent, identifier()); KDBusConnectionPool::threadConnection().registerService(service); connect(collectionMonitor, &Akonadi::Monitor::collectionRemoved, this, &ArchiveMailAgent::mailCollectionRemoved); if (enabledAgent()) { #ifdef DEBUG_ARCHIVEMAILAGENT QTimer::singleShot(1000, mArchiveManager, &ArchiveMailManager::load); #else QTimer::singleShot(1000 * 60 * 5, mArchiveManager, &ArchiveMailManager::load); #endif } mTimer = new QTimer(this); connect(mTimer, &QTimer::timeout, this, &ArchiveMailAgent::reload); mTimer->start(24 * 60 * 60 * 1000); } ArchiveMailAgent::~ArchiveMailAgent() { } void ArchiveMailAgent::setEnableAgent(bool enabled) { if (enabled != ArchiveMailAgentSettings::enabled()) { ArchiveMailAgentSettings::setEnabled(enabled); ArchiveMailAgentSettings::self()->save(); if (!enabled) { mTimer->stop(); pause(); } else { mTimer->start(); } } } bool ArchiveMailAgent::enabledAgent() const { return ArchiveMailAgentSettings::enabled(); } void ArchiveMailAgent::mailCollectionRemoved(const Akonadi::Collection &collection) { mArchiveManager->removeCollection(collection); } void ArchiveMailAgent::doSetOnline(bool online) { if (online) { resume(); } else { pause(); } } void ArchiveMailAgent::reload() { if (isOnline() && enabledAgent()) { mArchiveManager->load(); mTimer->start(); } } void ArchiveMailAgent::pause() { if (isOnline() && enabledAgent()) { mArchiveManager->pause(); } } void ArchiveMailAgent::resume() { if (isOnline() && enabledAgent()) { mArchiveManager->resume(); } } QString ArchiveMailAgent::printArchiveListInfo() { return mArchiveManager->printArchiveListInfo(); } QString ArchiveMailAgent::printCurrentListInfo() { return mArchiveManager->printCurrentListInfo(); } void ArchiveMailAgent::archiveFolder(const QString &path, Akonadi::Collection::Id collectionId) { mArchiveManager->archiveFolder(path, collectionId); } AKONADI_AGENT_MAIN(ArchiveMailAgent) diff --git a/agents/followupreminderagent/CMakeLists.txt b/agents/followupreminderagent/CMakeLists.txt index 803a38944..a56b730a5 100644 --- a/agents/followupreminderagent/CMakeLists.txt +++ b/agents/followupreminderagent/CMakeLists.txt @@ -1,95 +1,93 @@ add_definitions(-DTRANSLATION_DOMAIN=\"akonadi_followupreminder_agent\") set(followupreminderagent_job_SRCS jobs/followupreminderjob.cpp jobs/followupreminderfinishtaskjob.cpp jobs/followupremindershowmessagejob.cpp ) set(followupreminderagent_SRCS followupremindermanager.cpp followupremindernoanswerdialog.cpp followupreminderinfowidget.cpp ${followupreminderagent_job_SRCS} ) ecm_qt_declare_logging_category(followupreminderagent_SRCS HEADER followupreminderagent_debug.h IDENTIFIER FOLLOWUPREMINDERAGENT_LOG CATEGORY_NAME org.kde.pim.followupreminderagent) qt5_add_dbus_adaptor(followupreminderagent_SRCS org.freedesktop.Akonadi.FollowUpReminder.xml followupreminderagent.h FollowUpReminderAgent) add_library(followupreminderagent STATIC ${followupreminderagent_SRCS}) target_link_libraries(followupreminderagent KF5::AkonadiCore KF5::IdentityManagement KF5::AkonadiMime KF5::AkonadiAgentBase KF5::DBusAddons KF5::XmlGui KF5::KIOWidgets KF5::Notifications KF5::MailCommon KF5::Libkdepim KF5::IconThemes KF5::I18n KF5::CalendarCore ) ########################### Agent executable ################################ add_executable(akonadi_followupreminder_agent followupreminderagent.cpp) target_link_libraries(akonadi_followupreminder_agent followupreminderagent KF5::AkonadiCore KF5::AkonadiMime KF5::AkonadiAgentBase KF5::Mime KF5::CalendarCore KF5::DBusAddons KF5::FollowupReminder Qt5::Widgets KF5::Notifications KF5::I18n - KF5::WindowSystem KF5::IconThemes KF5::XmlGui KF5::Service ) if( APPLE ) set_target_properties(akonadi_followupreminder_agent PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${kmail_SOURCE_DIR}/agents/Info.plist.template) set_target_properties(akonadi_followupreminder_agent PROPERTIES MACOSX_BUNDLE_GUI_IDENTIFIER "org.akonadi_followupreminder_agent") set_target_properties(akonadi_followupreminder_agent PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "KDE Akonadi Followup Reminder Agent") endif () install(TARGETS akonadi_followupreminder_agent ${KDE_INSTALL_TARGETS_DEFAULT_ARGS} ) install(FILES followupreminder.desktop DESTINATION "${KDE_INSTALL_DATAROOTDIR}/akonadi/agents") if (BUILD_TESTING) add_subdirectory(autotests) endif() install(FILES akonadi_followupreminder_agent.notifyrc DESTINATION ${KDE_INSTALL_KNOTIFY5RCDIR} ) ########## Configuration ############## set(followupreminderagentconfig_SRCS followupreminderinfoconfigwidget.cpp ) kcoreaddons_add_plugin(followupreminderagentconfig JSON followupreminderagentconfig.json SOURCES ${followupreminderagentconfig_SRCS} INSTALL_NAMESPACE akonadi/config ) target_link_libraries(followupreminderagentconfig followupreminderagent KF5::AkonadiCore - KF5::WindowSystem KF5::XmlGui KF5::I18n KF5::FollowupReminder ) diff --git a/agents/followupreminderagent/followupreminderagent.cpp b/agents/followupreminderagent/followupreminderagent.cpp index 7278ee747..e9a3e9692 100644 --- a/agents/followupreminderagent/followupreminderagent.cpp +++ b/agents/followupreminderagent/followupreminderagent.cpp @@ -1,125 +1,124 @@ /* Copyright (C) 2014-2018 Montel Laurent 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; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "followupreminderagent.h" #include "followupremindermanager.h" #include "FollowupReminder/FollowUpReminderUtil" #include "followupreminderadaptor.h" #include "followupreminderagentsettings.h" -#include #include #include #include #include #include #include #include #include #include #include "followupreminderagent_debug.h" #include FollowUpReminderAgent::FollowUpReminderAgent(const QString &id) : Akonadi::AgentBase(id) { Kdelibs4ConfigMigrator migrate(QStringLiteral("followupreminderagent")); migrate.setConfigFiles(QStringList() << QStringLiteral("akonadi_followupreminder_agentrc") << QStringLiteral("akonadi_followupreminder_agent.notifyrc")); migrate.migrate(); new FollowUpReminderAgentAdaptor(this); KDBusConnectionPool::threadConnection().registerObject(QStringLiteral("/FollowUpReminder"), this, QDBusConnection::ExportAdaptors); const QString service = Akonadi::ServerManager::self()->agentServiceName(Akonadi::ServerManager::Agent, QStringLiteral("akonadi_followupreminder_agent")); KDBusConnectionPool::threadConnection().registerService(service); mManager = new FollowUpReminderManager(this); setNeedsNetwork(true); changeRecorder()->setMimeTypeMonitored(KMime::Message::mimeType()); changeRecorder()->itemFetchScope().setCacheOnly(true); changeRecorder()->itemFetchScope().setFetchModificationTime(false); changeRecorder()->fetchCollection(true); changeRecorder()->setChangeRecordingEnabled(false); changeRecorder()->ignoreSession(Akonadi::Session::defaultSession()); changeRecorder()->collectionFetchScope().setAncestorRetrieval(Akonadi::CollectionFetchScope::All); changeRecorder()->setCollectionMonitored(Akonadi::Collection::root(), true); if (FollowUpReminderAgentSettings::enabled()) { mManager->load(); } mTimer = new QTimer(this); connect(mTimer, &QTimer::timeout, this, &FollowUpReminderAgent::reload); //Reload all each 24hours mTimer->start(24 * 60 * 60 * 1000); } FollowUpReminderAgent::~FollowUpReminderAgent() { } void FollowUpReminderAgent::setEnableAgent(bool enabled) { if (FollowUpReminderAgentSettings::self()->enabled() == enabled) { return; } FollowUpReminderAgentSettings::self()->setEnabled(enabled); FollowUpReminderAgentSettings::self()->save(); if (enabled) { mManager->load(); mTimer->start(); } else { mTimer->stop(); } } bool FollowUpReminderAgent::enabledAgent() const { return FollowUpReminderAgentSettings::self()->enabled(); } void FollowUpReminderAgent::itemAdded(const Akonadi::Item &item, const Akonadi::Collection &collection) { if (!enabledAgent()) { return; } if (item.mimeType() != KMime::Message::mimeType()) { qCDebug(FOLLOWUPREMINDERAGENT_LOG) << "FollowUpReminderAgent::itemAdded called for a non-message item!"; return; } mManager->checkFollowUp(item, collection); } void FollowUpReminderAgent::reload() { if (enabledAgent()) { mManager->load(true); mTimer->start(); } } QString FollowUpReminderAgent::printDebugInfo() { return mManager->printDebugInfo(); } AKONADI_AGENT_MAIN(FollowUpReminderAgent)