Verified Commit 6d660f8b authored by Daniel Vrátil's avatar Daniel Vrátil 🤖
Browse files

Kill libKF5SendLater library

The code has been dissolved into messagelib and the agent
implementation in KMail. The client code now talks to the agent
through DBus interface rather than modifying a shared config file.
parent 96c2f8d2
......@@ -71,7 +71,6 @@ 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_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)
@PACKAGE_INIT@
include(CMakeFindDependencyMacro)
find_dependency(KF5Akonadi "@AKONADI_VERSION@")
include("${CMAKE_CURRENT_LIST_DIR}/KF5SendLaterTargets.cmake")
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 "$<INSTALL_INTERFACE:${KDE_INSTALL_INCLUDEDIR_KF5}/SendLater/;${KDE_INSTALL_INCLUDEDIR_KF5}/sendlater>")
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})
#! /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
/*
Copyright (C) 2013-2020 Laurent Montel <montel@kde.org>
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 <KLocalizedString>
#include <KSeparator>
#include <QIcon>
#include <QVBoxLayout>
#include <QCheckBox>
#include <QDialogButtonBox>
#include <QPushButton>
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<int>(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<SendLater::SendLaterInfo::RecurrenceUnit>(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());
}
/*
Copyright (C) 2013-2020 Laurent Montel <montel@kde.org>
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 <QDialog>
#include "sendlater_export.h"
#include <QDateTime>
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
/*
Copyright (C) 2013-2020 Laurent Montel <montel@kde.org>
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 <KConfigGroup>
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<RecurrenceUnit>(config.readEntry("recurrenceUnit", static_cast<int>(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<int>(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;
}
/*
Copyright (C) 2013-2020 Laurent Montel <montel@kde.org>
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 <item.h>
#include <QDateTime>
#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;