Commit fc980e2d authored by Volker Krause's avatar Volker Krause
Browse files

Remove unused D-Bus interface of the alarm daemon

That provided 4 methods:
- quit() is already exposed via KDBusService, and isn't really necessary
as we have no transient state anymore, so just terminating the process
is safe.
- forceAlarmCheck() calls a method that runs every minute anyway.
- dumpDebug() just prints a value from the config file, so you could just
look there...
- dumpAlarms() is the only one actually doing something, but it's not
dependent on any state or functionality of the alarm daemon itself, a
simple test program running stand-alone could do the same if necessary.

Ie. there is no loss of useful functionality here I think, even for
development. Instead this further simplifies the code.
parent 58f4c1e6
Pipeline #107732 passed with stage
in 5 minutes and 19 seconds
......@@ -9,8 +9,6 @@ set(kalendarac_SRCS
kalendaracmain.cpp
)
qt5_add_dbus_adaptor(kalendarac_SRCS org.kde.kalendarac.xml kalendaralarmclient.h KalendarAlarmClient)
add_executable(kalendarac ${kalendarac_SRCS} ${RESOURCES})
target_link_libraries(kalendarac
......
......@@ -3,7 +3,6 @@
#include "kalendaralarmclient.h"
#include "alarmnotification.h"
#include "kalendaracadaptor.h"
#include "notificationhandler.h"
#include <KCheckableProxyModel>
......@@ -12,15 +11,13 @@
#include <KSharedConfig>
#include <QDateTime>
#include <QFileInfo>
using namespace KCalendarCore;
KalendarAlarmClient::KalendarAlarmClient(QObject *parent)
: QObject(parent)
{
new KalendaracAdaptor(this);
QDBusConnection::sessionBus().registerObject(QStringLiteral("/ac"), this);
m_notificationHandler = new NotificationHandler(this);
connect(m_notificationHandler, &NotificationHandler::notificationUpdated, this, &KalendarAlarmClient::storeNotification);
connect(m_notificationHandler, &NotificationHandler::notificationRemoved, this, &KalendarAlarmClient::removeNotification);
......@@ -206,50 +203,3 @@ void KalendarAlarmClient::saveLastCheckTime()
cg.writeEntry("CalendarsLastChecked", mLastChecked);
KSharedConfig::openConfig()->sync();
}
void KalendarAlarmClient::quit()
{
// qCDebug(KOALARMCLIENT_LOG);
qApp->quit();
}
void KalendarAlarmClient::forceAlarmCheck()
{
checkAlarms();
saveLastCheckTime();
}
QString KalendarAlarmClient::dumpDebug() const
{
KConfigGroup cfg(KSharedConfig::openConfig(), "Alarms");
const QDateTime lastChecked = cfg.readEntry("CalendarsLastChecked", QDateTime());
const QString str = QStringLiteral("Last Check: %1").arg(lastChecked.toString());
return str;
}
QStringList KalendarAlarmClient::dumpAlarms() const
{
const QDateTime start = QDateTime(QDate::currentDate(), QTime(0, 0), Qt::LocalTime);
const QDateTime end = start.addDays(1).addSecs(-1);
QStringList lst;
const Alarm::List alarms = mCalendar->alarms(start, end);
lst.reserve(1 + (alarms.isEmpty() ? 1 : alarms.count()));
// Don't translate, this is for debugging purposes.
lst << QStringLiteral("dumpAlarms() from ") + start.toString() + QLatin1String(" to ") + end.toString();
if (alarms.isEmpty()) {
lst << QStringLiteral("No alarm found.");
} else {
for (const Alarm::Ptr &alarm : alarms) {
const QString uid = alarm->customProperty("ETMCalendar", "parentUid");
const Incidence::Ptr incidence = mCalendar->incidence(uid);
const QString summary = incidence->summary();
const QDateTime time = incidence->dateTime(Incidence::RoleAlarm);
lst << QStringLiteral("%1: \"%2\" (alarm text \"%3\")").arg(time.toString(Qt::ISODate), summary, alarm->text());
}
}
return lst;
}
......@@ -21,18 +21,11 @@ class NotificationHandler;
class KalendarAlarmClient : public QObject
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.kalendarac")
public:
explicit KalendarAlarmClient(QObject *parent = nullptr);
~KalendarAlarmClient() override;
// DBUS interface
void quit();
void forceAlarmCheck();
Q_REQUIRED_RESULT QString dumpDebug() const;
Q_REQUIRED_RESULT QStringList dumpAlarms() const;
private:
void deferredInit();
void restoreSuspendedFromConfig();
......
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<!-- SPDX-FileCopyrightText: 2021 Claudio Cambra <claudio.cambra@gmail.com> -->
<!-- SPDX-License-Identifier: CC0-1.0 -->
<node>
<interface name="org.kde.kalendarac">
<method name="quit">
</method>
<method name="forceAlarmCheck">
</method>
<method name="dumpAlarms">
<arg type="as" direction="out"/>
</method>
</interface>
</node>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment