diff --git a/CMakeLists.txt b/CMakeLists.txt index d85d583..8d1805a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,83 +1,82 @@ cmake_minimum_required(VERSION 3.5) set(PIM_VERSION "5.14.40") project(kdepim-apps-lib VERSION ${PIM_VERSION}) set(KF5_MIN_VERSION "5.70.0") find_package(ECM ${KF5_MIN_VERSION} CONFIG REQUIRED) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) set(LIBRARY_NAMELINK) if (POLICY CMP0053) cmake_policy(SET CMP0053 NEW) endif() include(KDEInstallDirs) include(KDECMakeSettings) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) include(GenerateExportHeader) include(ECMGenerateHeaders) include(ECMGeneratePriFile) include(ECMSetupVersion) include(FeatureSummary) include(ECMQtDeclareLoggingCategory) include(ECMAddTests) set(KDEPIM_APPS_LIB_VERSION ${PIM_VERSION}) set(QT_REQUIRED_VERSION "5.12.0") set(AKONADI_VERSION "5.14.40") set(GRANTLEETHEME_LIB_VERSION "5.14.40") set(AKONADICONTACT_LIB_VERSION "5.14.40") set(LIBKLEO_LIB_VERSION "5.14.40") set(PIMCOMMON_LIB_VERSION "5.14.40") set(GRANTLEE_LIB_VERSION "5.2") find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED Widgets DBus Gui) find_package(KF5Config ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5ConfigWidgets ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5CoreAddons ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5I18n ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5KIO ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5Service ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5WidgetsAddons ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5Akonadi ${AKONADI_VERSION} CONFIG REQUIRED) find_package(KF5AkonadiContact ${AKONADICONTACT_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Contacts ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5ContactEditor ${AKONADICONTACT_LIB_VERSION} CONFIG REQUIRED) find_package(KF5GrantleeTheme ${GRANTLEETHEME_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Libkleo ${LIBKLEO_LIB_VERSION} CONFIG REQUIRED) find_package(KF5PimCommonAkonadi ${PIMCOMMON_LIB_VERSION} CONFIG REQUIRED) find_package(Grantlee5 ${GRANTLEE_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Prison ${KF5_MIN_VERSION} CONFIG REQUIRED) if(BUILD_TESTING) find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED Test) add_definitions(-DBUILD_TESTING) endif() if (EXISTS "${CMAKE_SOURCE_DIR}/.git") add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050e00) add_definitions(-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x054600) endif() add_definitions(-DQT_NO_FOREACH) add_definitions(-DQT_NO_KEYWORDS) -add_subdirectory(libsendlater) add_subdirectory(kaddressbookgrantlee) add_subdirectory(kaddressbookimportexport) feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) ecm_qt_install_logging_categories( EXPORT KDEPIMAPPSLIB FILE kdepim-apps-lib.categories DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR} ) diff --git a/libsendlater/CMakeLists.txt b/libsendlater/CMakeLists.txt deleted file mode 100644 index 606f216..0000000 --- a/libsendlater/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -ecm_setup_version(PROJECT VARIABLE_PREFIX SENDLATER - VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/sendlater_version.h" - PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5SendLaterConfigVersion.cmake" - SOVERSION 5 -) - - -########### CMake Config Files ########### -set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5SendLater") - -configure_package_config_file( - "${CMAKE_CURRENT_SOURCE_DIR}/KF5SendLaterConfig.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/KF5SendLaterConfig.cmake" - INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR} -) - -install(FILES - "${CMAKE_CURRENT_BINARY_DIR}/KF5SendLaterConfig.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/KF5SendLaterConfigVersion.cmake" - DESTINATION "${CMAKECONFIG_INSTALL_DIR}" - COMPONENT Devel -) - -install(EXPORT KF5SendLaterTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE KF5SendLaterTargets.cmake NAMESPACE KF5::) - -install(FILES - ${CMAKE_CURRENT_BINARY_DIR}/sendlater_version.h - DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5} COMPONENT Devel -) - -add_subdirectory(src) - diff --git a/libsendlater/KF5SendLaterConfig.cmake.in b/libsendlater/KF5SendLaterConfig.cmake.in deleted file mode 100644 index f4fcec9..0000000 --- a/libsendlater/KF5SendLaterConfig.cmake.in +++ /dev/null @@ -1,5 +0,0 @@ -@PACKAGE_INIT@ - -include(CMakeFindDependencyMacro) -find_dependency(KF5Akonadi "@AKONADI_VERSION@") -include("${CMAKE_CURRENT_LIST_DIR}/KF5SendLaterTargets.cmake") diff --git a/libsendlater/src/CMakeLists.txt b/libsendlater/src/CMakeLists.txt deleted file mode 100644 index 2c228bf..0000000 --- a/libsendlater/src/CMakeLists.txt +++ /dev/null @@ -1,84 +0,0 @@ - -add_definitions(-DTRANSLATION_DOMAIN=\"libsendlater\") - -set(sendlater_common_SRCS) -ecm_qt_declare_logging_category(sendlater_common_SRCS HEADER libsendlater_debug.h IDENTIFIER LIBSENDLATER_LOG CATEGORY_NAME org.kde.pim.libsendlater - DESCRIPTION "kdepim-apps-lib (libsendlater)" - OLD_CATEGORY_NAMES log_libsendlater - EXPORT KDEPIMAPPSLIB - ) - - -set(sendlaterlib_SRCS - ${sendlater_common_SRCS} - sendlaterinfo.cpp - sendlaterdialog.cpp - sendlaterutil.cpp - sendlatertimedatewidget.cpp -) - -kconfig_add_kcfg_files(sendlaterlib_SRCS - settings/sendlateragentsettings.kcfgc - ) - -ki18n_wrap_ui(sendlaterlib_SRCS ui/sendlaterwidget.ui) - -add_library( KF5SendLater ${sendlaterlib_SRCS} ) -generate_export_header(KF5SendLater BASE_NAME sendlater) -add_library(KF5::SendLater ALIAS KF5SendLater) -target_link_libraries(KF5SendLater - PUBLIC - KF5::AkonadiCore - PRIVATE - KF5::ConfigCore - KF5::I18n - KF5::WidgetsAddons - KF5::ConfigGui - Qt5::DBus - Qt5::Widgets -) -target_include_directories(KF5SendLater INTERFACE "$") - -set_target_properties(KF5SendLater PROPERTIES - VERSION ${SENDLATER_VERSION_STRING} - SOVERSION ${SENDLATER_SOVERSION} - EXPORT_NAME SendLater -) - -install(TARGETS - KF5SendLater - EXPORT KF5SendLaterTargets ${KF5_INSTALL_TARGETS_DEFAULT_ARGS} ${LIBRARY_NAMELINK} -) - -ecm_generate_headers(SendLater_Camelcase_HEADERS - HEADER_NAMES - SendLaterInfo - SendLaterDialog - SendLaterUtil - REQUIRED_HEADERS SendLater_HEADERS - PREFIX SendLater -) - -ecm_generate_pri_file(BASE_NAME SendLater - LIB_NAME KF5SendLater - DEPS "AkonadiCore" FILENAME_VAR PRI_FILENAME INCLUDE_INSTALL_DIR ${KDE_INSTALL_INCLUDEDIR_KF5}/SendLater -) - - -install(FILES - ${SendLater_Camelcase_HEADERS} - DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/SendLater - COMPONENT Devel -) - -install(FILES - ${SendLater_HEADERS} - ${CMAKE_CURRENT_BINARY_DIR}/sendlater_export.h - ${CMAKE_CURRENT_BINARY_DIR}/sendlateragentsettings.h - DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/sendlater - COMPONENT Devel -) -install(FILES - ${PRI_FILENAME} - DESTINATION ${ECM_MKSPECS_INSTALL_DIR}) - diff --git a/libsendlater/src/Messages.sh b/libsendlater/src/Messages.sh deleted file mode 100755 index e31be62..0000000 --- a/libsendlater/src/Messages.sh +++ /dev/null @@ -1,4 +0,0 @@ -#! /bin/sh -$EXTRACTRC ui/*.ui >> rc.cpp -$XGETTEXT `find . -name '*.h' -o -name '*.cpp' | grep -v '/tests/' | grep -v '/autotests/' ` -o $podir/libsendlater.pot -rm -f rc.cpp diff --git a/libsendlater/src/sendlaterdialog.cpp b/libsendlater/src/sendlaterdialog.cpp deleted file mode 100644 index babed6f..0000000 --- a/libsendlater/src/sendlaterdialog.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/* - Copyright (C) 2013-2020 Laurent Montel - - 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 "sendlaterdialog.h" -#include "sendlaterinfo.h" -#include "sendlatertimedatewidget.h" -#include "ui_sendlaterwidget.h" - -#include -#include -#include - -#include -#include -#include -#include - -using namespace SendLater; - -SendLaterDialog::SendLaterDialog(SendLater::SendLaterInfo *info, QWidget *parent) - : QDialog(parent) - , mInfo(info) -{ - setWindowTitle(i18nc("@title:window", "Send Later")); - setWindowIcon(QIcon::fromTheme(QStringLiteral("kmail"))); - - QVBoxLayout *mainLayout = new QVBoxLayout(this); - - QWidget *sendLaterWidget = new QWidget(this); - mSendLaterWidget = new Ui::SendLaterWidget; - mSendLaterWidget->setupUi(sendLaterWidget); - - QWidget *w = new QWidget(this); - QVBoxLayout *lay = new QVBoxLayout; - lay->setContentsMargins(0, 0, 0, 0); - w->setLayout(lay); - - QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); - mOkButton = buttonBox->button(QDialogButtonBox::Ok); - mOkButton->setObjectName(QStringLiteral("okbutton")); - mOkButton->setDefault(true); - mOkButton->setShortcut(Qt::CTRL | Qt::Key_Return); - connect(buttonBox, &QDialogButtonBox::rejected, this, &SendLaterDialog::reject); - - if (!info) { - mOkButton->setText(i18n("Send Later")); - mDelay = new QCheckBox(i18n("Delay")); - mDelay->setChecked(false); - slotDelay(false); - connect(mDelay, &QCheckBox::clicked, this, &SendLaterDialog::slotDelay); - lay->addWidget(mDelay); - } - - connect(mOkButton, &QPushButton::clicked, this, &SendLaterDialog::slotOkClicked); - - lay->addWidget(sendLaterWidget); - - QDateTime t = QDateTime::currentDateTime(); - t = t.addSecs(60 * 60); - - mSendLaterWidget->mDateTime->setDateTime(t); - connect(mSendLaterWidget->mRecurrence, &QCheckBox::clicked, this, &SendLaterDialog::slotRecurrenceClicked); - const QStringList unitsList = {i18n("Days"), i18n("Weeks"), i18n("Months"), i18n("Years")}; - mSendLaterWidget->mRecurrenceComboBox->addItems(unitsList); - connect(mSendLaterWidget->mDateTime, &SendLaterTimeDateWidget::dateChanged, this, &SendLaterDialog::slotDateChanged); - - lay->addWidget(new KSeparator); - - mainLayout->addWidget(w); - mainLayout->addWidget(buttonBox); - slotRecurrenceClicked(false); - if (info) { - load(info); - } - resize(180, 120); -} - -SendLaterDialog::~SendLaterDialog() -{ - delete mSendLaterWidget; -} - -void SendLaterDialog::slotDateChanged(const QString &date) -{ - mOkButton->setEnabled(!date.isEmpty()); -} - -void SendLaterDialog::slotRecurrenceClicked(bool clicked) -{ - mSendLaterWidget->mRecurrenceValue->setEnabled(clicked); - mSendLaterWidget->mRecurrenceComboBox->setEnabled(clicked); -} - -void SendLaterDialog::load(SendLater::SendLaterInfo *info) -{ - mSendLaterWidget->mDateTime->setDateTime(info->dateTime()); - const bool recurrence = info->isRecurrence(); - mSendLaterWidget->mRecurrence->setChecked(recurrence); - slotRecurrenceClicked(recurrence); - mSendLaterWidget->mRecurrenceValue->setValue(info->recurrenceEachValue()); - mSendLaterWidget->mRecurrenceComboBox->setCurrentIndex(static_cast(info->recurrenceUnit())); -} - -SendLater::SendLaterInfo *SendLaterDialog::info() -{ - if (!mInfo) { - mInfo = new SendLater::SendLaterInfo(); - } - mInfo->setRecurrence(mSendLaterWidget->mRecurrence->isChecked()); - mInfo->setRecurrenceEachValue(mSendLaterWidget->mRecurrenceValue->value()); - mInfo->setRecurrenceUnit(static_cast(mSendLaterWidget->mRecurrenceComboBox->currentIndex())); - if (mSendDateTime.isValid()) { - mInfo->setDateTime(mSendDateTime); - } else { - mInfo->setDateTime(mSendLaterWidget->mDateTime->dateTime()); - } - return mInfo; -} - -SendLaterDialog::SendLaterAction SendLaterDialog::action() const -{ - return mAction; -} - -void SendLaterDialog::slotOkClicked() -{ - if (!mDelay || mDelay->isChecked()) { - mSendDateTime = mSendLaterWidget->mDateTime->dateTime(); - mAction = SendDeliveryAtTime; - } else { - mAction = PutInOutbox; - } - accept(); -} - -void SendLaterDialog::slotDelay(bool delayEnabled) -{ - mSendLaterWidget->mLabel->setEnabled(delayEnabled); - mSendLaterWidget->mDateTime->setEnabled(delayEnabled); - mSendLaterWidget->mRecurrence->setEnabled(delayEnabled); - mSendLaterWidget->mRecurrenceValue->setEnabled(delayEnabled && mSendLaterWidget->mRecurrence->isChecked()); - mSendLaterWidget->mRecurrenceComboBox->setEnabled(delayEnabled && mSendLaterWidget->mRecurrence->isChecked()); -} diff --git a/libsendlater/src/sendlaterdialog.h b/libsendlater/src/sendlaterdialog.h deleted file mode 100644 index 37ca058..0000000 --- a/libsendlater/src/sendlaterdialog.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - Copyright (C) 2013-2020 Laurent Montel - - 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. -*/ - -#ifndef SENDLATERDIALOG_H -#define SENDLATERDIALOG_H - -#include -#include "sendlater_export.h" -#include -class QCheckBox; -class QPushButton; -namespace Ui { -class SendLaterWidget; -} - -namespace SendLater { -class SendLaterInfo; - -/** Send later dialog. */ -class SENDLATER_EXPORT SendLaterDialog : public QDialog -{ - Q_OBJECT -public: - enum SendLaterAction { - Unknown = 0, - SendDeliveryAtTime = 1, - Canceled = 2, - PutInOutbox = 3 - }; - - explicit SendLaterDialog(SendLater::SendLaterInfo *info, QWidget *parent = nullptr); - ~SendLaterDialog(); - - SendLater::SendLaterInfo *info(); - - Q_REQUIRED_RESULT SendLaterAction action() const; - -private: - void slotRecurrenceClicked(bool); - void slotOkClicked(); - void slotDelay(bool delayEnabled); - - void slotDateChanged(const QString &date); - void load(SendLater::SendLaterInfo *info); - -private: - QDateTime mSendDateTime; - SendLaterAction mAction = Unknown; - QCheckBox *mDelay = nullptr; - Ui::SendLaterWidget *mSendLaterWidget = nullptr; - SendLater::SendLaterInfo *mInfo = nullptr; - QPushButton *mOkButton = nullptr; -}; -} -#endif // SENDLATERDIALOG_H diff --git a/libsendlater/src/sendlaterinfo.cpp b/libsendlater/src/sendlaterinfo.cpp deleted file mode 100644 index 5ca6f23..0000000 --- a/libsendlater/src/sendlaterinfo.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/* - Copyright (C) 2013-2020 Laurent Montel - - 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 "sendlaterinfo.h" - -#include - -using namespace SendLater; - -SendLaterInfo::SendLaterInfo() -{ -} - -SendLaterInfo::SendLaterInfo(const KConfigGroup &config) -{ - readConfig(config); -} - -SendLaterInfo::SendLaterInfo(const SendLaterInfo &info) -{ - mId = info.itemId(); - mRecurrenceEachValue = info.recurrenceEachValue(); - mRecurrenceUnit = info.recurrenceUnit(); - mRecurrence = info.isRecurrence(); - mSubject = info.subject(); - mTo = info.to(); - mDateTime = info.dateTime(); - mLastDateTimeSend = info.lastDateTimeSend(); -} - -SendLaterInfo::~SendLaterInfo() -{ -} - -bool SendLaterInfo::isValid() const -{ - return (mId != -1) && mDateTime.isValid(); -} - -bool SendLaterInfo::isRecurrence() const -{ - return mRecurrence; -} - -void SendLaterInfo::setRecurrence(bool b) -{ - mRecurrence = b; -} - -void SendLaterInfo::setRecurrenceUnit(SendLaterInfo::RecurrenceUnit unit) -{ - mRecurrenceUnit = unit; -} - -SendLaterInfo::RecurrenceUnit SendLaterInfo::recurrenceUnit() const -{ - return mRecurrenceUnit; -} - -void SendLaterInfo::setRecurrenceEachValue(int value) -{ - mRecurrenceEachValue = value; -} - -int SendLaterInfo::recurrenceEachValue() const -{ - return mRecurrenceEachValue; -} - -void SendLaterInfo::setItemId(Akonadi::Item::Id id) -{ - mId = id; -} - -Akonadi::Item::Id SendLaterInfo::itemId() const -{ - return mId; -} - -void SendLaterInfo::setDateTime(const QDateTime &time) -{ - mDateTime = time; -} - -QDateTime SendLaterInfo::dateTime() const -{ - return mDateTime; -} - -void SendLaterInfo::setLastDateTimeSend(const QDateTime &dateTime) -{ - mLastDateTimeSend = dateTime; -} - -QDateTime SendLaterInfo::lastDateTimeSend() const -{ - return mLastDateTimeSend; -} - -void SendLaterInfo::setSubject(const QString &subject) -{ - mSubject = subject; -} - -QString SendLaterInfo::subject() const -{ - return mSubject; -} - -void SendLaterInfo::setTo(const QString &to) -{ - mTo = to; -} - -QString SendLaterInfo::to() const -{ - return mTo; -} - -bool SendLaterInfo::operator ==(const SendLaterInfo &other) const -{ - return (itemId() == other.itemId()) - && (recurrenceUnit() == other.recurrenceUnit()) - && (recurrenceEachValue() == other.recurrenceEachValue()) - && (isRecurrence() == other.isRecurrence()) - && (dateTime() == other.dateTime()) - && (lastDateTimeSend() == other.lastDateTimeSend()) - && (subject() == other.subject()) - && (to() == other.to()); -} - -void SendLaterInfo::readConfig(const KConfigGroup &config) -{ - if (config.hasKey(QStringLiteral("lastDateTimeSend"))) { - mLastDateTimeSend = QDateTime::fromString(config.readEntry("lastDateTimeSend"), Qt::ISODate); - } - mDateTime = config.readEntry("date", QDateTime::currentDateTime()); - mRecurrence = config.readEntry("recurrence", false); - mRecurrenceEachValue = config.readEntry("recurrenceValue", 1); - mRecurrenceUnit = static_cast(config.readEntry("recurrenceUnit", static_cast(Days))); - mId = config.readEntry("itemId", -1); - mSubject = config.readEntry("subject"); - mTo = config.readEntry("to"); -} - -void SendLaterInfo::writeConfig(KConfigGroup &config) -{ - if (mLastDateTimeSend.isValid()) { - config.writeEntry("lastDateTimeSend", mLastDateTimeSend.toString(Qt::ISODate)); - } - config.writeEntry("date", mDateTime); - config.writeEntry("recurrence", mRecurrence); - config.writeEntry("recurrenceValue", mRecurrenceEachValue); - config.writeEntry("recurrenceUnit", static_cast(mRecurrenceUnit)); - config.writeEntry("itemId", mId); - config.writeEntry("subject", mSubject); - config.writeEntry("to", mTo); - config.sync(); -} - -QDebug operator<<(QDebug d, const SendLaterInfo &info) -{ - d << "mTo: " << info.to(); - d << "mSubject: " << info.subject(); - d << "mDateTime: " << info.dateTime().toString(); - d << "mLastDateTimeSend: " << info.lastDateTimeSend().toString(); - d << "mId: " << info.itemId(); - d << "mRecurrenceEachValue: " << info.recurrenceEachValue(); - d << "mRecurrenceUnit: " << info.recurrenceUnit(); - d << "mRecurrence: " << info.isRecurrence(); - return d; -} diff --git a/libsendlater/src/sendlaterinfo.h b/libsendlater/src/sendlaterinfo.h deleted file mode 100644 index 58bedcd..0000000 --- a/libsendlater/src/sendlaterinfo.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - Copyright (C) 2013-2020 Laurent Montel - - 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. -*/ - -#ifndef SENDLATERINFO_H -#define SENDLATERINFO_H - -#include -#include -#include "sendlater_export.h" - -class KConfigGroup; - -namespace SendLater { - -/** Send later information. */ -class SENDLATER_EXPORT SendLaterInfo -{ -public: - explicit SendLaterInfo(); - explicit SendLaterInfo(const KConfigGroup &config); - SendLaterInfo(const SendLater::SendLaterInfo &info); - ~SendLaterInfo(); - - enum RecurrenceUnit { - Days = 0, - Weeks, - Months, - Years - }; - - Q_REQUIRED_RESULT bool isValid() const; - - void setItemId(Akonadi::Item::Id id); - Q_REQUIRED_RESULT Akonadi::Item::Id itemId() const; - - void setRecurrenceUnit(RecurrenceUnit unit); - Q_REQUIRED_RESULT RecurrenceUnit recurrenceUnit() const; - - void setRecurrenceEachValue(int value); - Q_REQUIRED_RESULT int recurrenceEachValue() const; - - Q_REQUIRED_RESULT bool isRecurrence() const; - void setRecurrence(bool b); - - void setDateTime(const QDateTime &time); - Q_REQUIRED_RESULT QDateTime dateTime() const; - - void readConfig(const KConfigGroup &config); - void writeConfig(KConfigGroup &config); - - void setLastDateTimeSend(const QDateTime &date); - Q_REQUIRED_RESULT QDateTime lastDateTimeSend() const; - - void setSubject(const QString &subject); - Q_REQUIRED_RESULT QString subject() const; - - void setTo(const QString &to); - Q_REQUIRED_RESULT QString to() const; - - bool operator ==(const SendLaterInfo &other) const; - -private: - QString mTo; - QString mSubject; - QDateTime mDateTime; - QDateTime mLastDateTimeSend; - Akonadi::Item::Id mId = -1; - int mRecurrenceEachValue = 1; - RecurrenceUnit mRecurrenceUnit = Days; - bool mRecurrence = false; -}; -} -SENDLATER_EXPORT QDebug operator<<(QDebug debug, const SendLater::SendLaterInfo &info); -#endif // SENDLATERINFO_H diff --git a/libsendlater/src/sendlatertimedatewidget.cpp b/libsendlater/src/sendlatertimedatewidget.cpp deleted file mode 100644 index befd68b..0000000 --- a/libsendlater/src/sendlatertimedatewidget.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* - Copyright (C) 2013-2020 Laurent Montel - - 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 "sendlatertimedatewidget.h" - -#include -#include -#include -#include - -#include - -using namespace SendLater; - -SendLaterTimeDateWidget::SendLaterTimeDateWidget(QWidget *parent) - : QWidget(parent) -{ - QHBoxLayout *lay = new QHBoxLayout; - lay->setContentsMargins(0, 0, 0, 0); - - QDateTime t = QDateTime::currentDateTime(); - t = t.addSecs(60 * 60); - mTimeComboBox = new KTimeComboBox; - connect(mTimeComboBox, &KTimeComboBox::timeChanged, this, &SendLaterTimeDateWidget::slotDateTimeChanged); - mTimeComboBox->setObjectName(QStringLiteral("time_sendlater")); - - mDateComboBox = new KDateComboBox; - mDateComboBox->setOptions(KDateComboBox::EditDate | KDateComboBox::SelectDate | KDateComboBox::DatePicker | KDateComboBox::DateKeywords | KDateComboBox::WarnOnInvalid); - mDateComboBox->setObjectName(QStringLiteral("date_sendlater")); - connect(mDateComboBox->lineEdit(), &QLineEdit::textChanged, this, &SendLaterTimeDateWidget::dateChanged); - mDateComboBox->setMinimumDate(t.date(), i18n("You cannot select a date prior to the current date.")); - connect(mDateComboBox, &KDateComboBox::dateChanged, this, &SendLaterTimeDateWidget::slotDateTimeChanged); - - lay->addWidget(mDateComboBox); - lay->addWidget(mTimeComboBox); - - setLayout(lay); -} - -SendLaterTimeDateWidget::~SendLaterTimeDateWidget() -{ -} - -void SendLaterTimeDateWidget::slotDateTimeChanged() -{ - QDateTime dt; - dt.setDate(mDateComboBox->date()); - dt.setTime(mTimeComboBox->time()); - Q_EMIT dateTimeChanged(dt); -} - -QDateTime SendLaterTimeDateWidget::dateTime() const -{ - QDateTime dt; - dt.setDate(mDateComboBox->date()); - dt.setTime(mTimeComboBox->time()); - return dt; -} - -void SendLaterTimeDateWidget::setDateTime(const QDateTime &datetime) -{ - mTimeComboBox->setTime(datetime.time()); - mDateComboBox->setDate(datetime.date()); -} diff --git a/libsendlater/src/sendlatertimedatewidget.h b/libsendlater/src/sendlatertimedatewidget.h deleted file mode 100644 index 453b103..0000000 --- a/libsendlater/src/sendlatertimedatewidget.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - Copyright (C) 2013-2020 Laurent Montel - - 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. -*/ - -#ifndef SENDLATERTIMEDATEWIDGET_H -#define SENDLATERTIMEDATEWIDGET_H - -#include -#include - -class KTimeComboBox; -class KDateComboBox; - -namespace SendLater { - -/** Send later date/time widget. */ -class SendLaterTimeDateWidget : public QWidget -{ - Q_OBJECT -public: - explicit SendLaterTimeDateWidget(QWidget *parent = nullptr); - ~SendLaterTimeDateWidget(); - - void setDateTime(const QDateTime &); - Q_REQUIRED_RESULT QDateTime dateTime() const; - -Q_SIGNALS: - void dateTimeChanged(const QDateTime &); - void dateChanged(const QString &); -private: - void slotDateTimeChanged(); - KTimeComboBox *mTimeComboBox = nullptr; - KDateComboBox *mDateComboBox = nullptr; -}; -} - -#endif // SENDLATERTIMEDATEWIDGET_H diff --git a/libsendlater/src/sendlaterutil.cpp b/libsendlater/src/sendlaterutil.cpp deleted file mode 100644 index ef566ac..0000000 --- a/libsendlater/src/sendlaterutil.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/* - Copyright (C) 2013-2020 Laurent Montel - - 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 "sendlaterutil.h" -#include "sendlaterutil_p.h" -#include "sendlaterinfo.h" -#include "sendlateragentsettings.h" -#include "libsendlater_debug.h" -#include -#include - -#include -#include - -namespace { -QString serviceName() -{ - return Akonadi::ServerManager::agentServiceName(Akonadi::ServerManager::Agent, - QStringLiteral("akonadi_sendlater_agent")); -} - -QString dbusPath() -{ - return QStringLiteral("/SendLaterAgent"); -} -} - -bool SendLater::SendLaterUtil::compareSendLaterInfo(SendLater::SendLaterInfo *left, SendLater::SendLaterInfo *right) -{ - if (left->dateTime() == right->dateTime()) { - //Set no recursive first. - if (left->isRecurrence()) { - return false; - } - } - return left->dateTime() < right->dateTime(); -} - -void SendLater::SendLaterUtil::changeRecurrentDate(SendLater::SendLaterInfo *info) -{ - if (info && info->isRecurrence()) { - qCDebug(LIBSENDLATER_LOG) << "BEFORE SendLater::SendLaterUtil::changeRecurrentDate " << info->dateTime().toString(); - QDateTime newInfoDateTime = info->dateTime(); - newInfoDateTime = updateRecurence(info, newInfoDateTime); - qCDebug(LIBSENDLATER_LOG) << " QDateTime::currentDateTime()" << QDateTime::currentDateTime().toString(); - while (newInfoDateTime <= QDateTime::currentDateTime()) { - newInfoDateTime = updateRecurence(info, newInfoDateTime); - } - info->setDateTime(newInfoDateTime); - qCDebug(LIBSENDLATER_LOG) << "AFTER SendLater::SendLaterUtil::changeRecurrentDate " << info->dateTime().toString() << " info" << info << "New date" << newInfoDateTime; - writeSendLaterInfo(defaultConfig(), info, true); - } -} - -QDateTime SendLater::SendLaterUtil::updateRecurence(SendLater::SendLaterInfo *info, QDateTime dateTime) -{ - switch (info->recurrenceUnit()) { - case SendLater::SendLaterInfo::Days: - dateTime = dateTime.addDays(info->recurrenceEachValue()); - break; - case SendLater::SendLaterInfo::Weeks: - dateTime = dateTime.addDays(info->recurrenceEachValue() * 7); - break; - case SendLater::SendLaterInfo::Months: - dateTime = dateTime.addMonths(info->recurrenceEachValue()); - break; - case SendLater::SendLaterInfo::Years: - dateTime = dateTime.addYears(info->recurrenceEachValue()); - break; - } - return dateTime; -} - -KSharedConfig::Ptr SendLater::SendLaterUtil::defaultConfig() -{ - return KSharedConfig::openConfig(QStringLiteral("akonadi_sendlater_agentrc"), KConfig::SimpleConfig); -} - -void SendLater::SendLaterUtil::writeSendLaterInfo(KSharedConfig::Ptr config, SendLater::SendLaterInfo *info, bool forceReload) -{ - if (!info || !info->isValid()) { - return; - } - - const QString groupName = SendLater::SendLaterUtil::sendLaterPattern().arg(info->itemId()); - // first, delete all filter groups: - const QStringList filterGroups = config->groupList(); - for (const QString &group : filterGroups) { - if (group == groupName) { - config->deleteGroup(group); - } - } - KConfigGroup group = config->group(groupName); - info->writeConfig(group); - config->sync(); - config->reparseConfiguration(); - qCDebug(LIBSENDLATER_LOG) << " reparse config"; - if (forceReload) { - reload(); - } -} - -bool SendLater::SendLaterUtil::sentLaterAgentWasRegistered() -{ - QDBusInterface interface(serviceName(), dbusPath()); - return interface.isValid(); -} - -void SendLater::SendLaterUtil::forceReparseConfiguration() -{ - SendLaterAgentSettings::self()->save(); - SendLaterAgentSettings::self()->config()->reparseConfiguration(); -} - -bool SendLater::SendLaterUtil::sentLaterAgentEnabled() -{ - return SendLaterAgentSettings::self()->enabled(); -} - -void SendLater::SendLaterUtil::reload() -{ - qCDebug(LIBSENDLATER_LOG) << " void SendLater::SendLaterUtil::reload()"; - - QDBusInterface interface(serviceName(), dbusPath()); - if (interface.isValid()) { - interface.call(QStringLiteral("reload")); - } else { - qCDebug(LIBSENDLATER_LOG) << " Can not reload list"; - } -} - -void SendLater::SendLaterUtil::removeItem(qint64 item) -{ - qCDebug(LIBSENDLATER_LOG) << " void SendLater::SendLaterUtil::removeItem()" << item; - - QDBusInterface interface(serviceName(), dbusPath()); - if (interface.isValid()) { - interface.call(QStringLiteral("removeItem"), item); - } else { - qCDebug(LIBSENDLATER_LOG) << " Can not remove item"; - } -} - - -QString SendLater::SendLaterUtil::sendLaterPattern() -{ - return QStringLiteral("SendLaterItem %1"); -} diff --git a/libsendlater/src/sendlaterutil.h b/libsendlater/src/sendlaterutil.h deleted file mode 100644 index 6a0ab01..0000000 --- a/libsendlater/src/sendlaterutil.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - Copyright (C) 2013-2020 Laurent Montel - - 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. -*/ - -#ifndef SENDLATERUTIL_H -#define SENDLATERUTIL_H - -#include "sendlater_export.h" -#include - -namespace SendLater { -class SendLaterInfo; - -/** Send later utilities. */ -namespace SendLaterUtil { -Q_REQUIRED_RESULT SENDLATER_EXPORT bool compareSendLaterInfo(SendLater::SendLaterInfo *left, SendLater::SendLaterInfo *right); - -SENDLATER_EXPORT KSharedConfig::Ptr defaultConfig(); - -SENDLATER_EXPORT void writeSendLaterInfo(KSharedConfig::Ptr config, SendLater::SendLaterInfo *info, bool forceReload = true); - -Q_REQUIRED_RESULT SENDLATER_EXPORT bool sentLaterAgentWasRegistered(); - -Q_REQUIRED_RESULT SENDLATER_EXPORT bool sentLaterAgentEnabled(); - -SENDLATER_EXPORT void reload(); - -SENDLATER_EXPORT void changeRecurrentDate(SendLater::SendLaterInfo *info); -SENDLATER_EXPORT void forceReparseConfiguration(); - -Q_REQUIRED_RESULT SENDLATER_EXPORT QString sendLaterPattern(); -SENDLATER_EXPORT void removeItem(qint64 item); -} -} -#endif // SENDLATERUTIL_H diff --git a/libsendlater/src/sendlaterutil_p.h b/libsendlater/src/sendlaterutil_p.h deleted file mode 100644 index 9471474..0000000 --- a/libsendlater/src/sendlaterutil_p.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - Copyright (C) 2013-2020 Laurent Montel - - 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. -*/ - -#ifndef SENDLATERUTIL_P_H -#define SENDLATERUTIL_P_H - -#include "sendlater_export.h" -#include - -namespace SendLater { -class SendLaterInfo; -namespace SendLaterUtil { -Q_REQUIRED_RESULT QDateTime updateRecurence(SendLater::SendLaterInfo *info, QDateTime dateTime); -} -} -#endif // SENDLATERUTIL_P_H diff --git a/libsendlater/src/settings/sendlateragentsettings.kcfg b/libsendlater/src/settings/sendlateragentsettings.kcfg deleted file mode 100644 index b182e5b..0000000 --- a/libsendlater/src/settings/sendlateragentsettings.kcfg +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - true - - - diff --git a/libsendlater/src/settings/sendlateragentsettings.kcfgc b/libsendlater/src/settings/sendlateragentsettings.kcfgc deleted file mode 100644 index 9593b52..0000000 --- a/libsendlater/src/settings/sendlateragentsettings.kcfgc +++ /dev/null @@ -1,7 +0,0 @@ -# Code generation options for kconfig_compiler -File=sendlateragentsettings.kcfg -ClassName=SendLaterAgentSettings -Singleton=true -Mutators=true -Visibility=SENDLATER_EXPORT -IncludeFiles=sendlater_export.h diff --git a/libsendlater/src/ui/sendlaterwidget.ui b/libsendlater/src/ui/sendlaterwidget.ui deleted file mode 100644 index 4bab07f..0000000 --- a/libsendlater/src/ui/sendlaterwidget.ui +++ /dev/null @@ -1,67 +0,0 @@ - - - SendLaterWidget - - - - 0 - 0 - 452 - 85 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Send at: - - - - - - - - - - Repeat every: - - - - - - - 1 - - - 365 - - - - - - - - - - - SendLater::SendLaterTimeDateWidget - QWidget -
sendlatertimedatewidget.h
-
-
- - -
diff --git a/metainfo.yaml b/metainfo.yaml index deaf438..b1ad930 100644 --- a/metainfo.yaml +++ b/metainfo.yaml @@ -1,21 +1,18 @@ description: KDE PIM application libraries tier: 3 type: solution platforms: - name: Linux portingAid: false deprecated: false libraries: - cmake: "KF5::KaddressbookGrantlee" - cmake: "KF5::KaddressbookImportExport" - - cmake: "KF5::SendLater" public_lib: true group: kdepim irc: akonadi public_source_dirs: - kaddressbookgrantlee - kaddressbookimportexport - - libfollowupreminder - - libsendlater