Commit 6273f0ba authored by David Edmundson's avatar David Edmundson
Browse files

[kcms/activities] Fixup DBus path usage

In a code cleanup the path name got corrupted. The use of macros
obfuscates what can be done with a simple string. This code takes it
back to what's helpful.

Whilst we're at it, ResourceScoring was using QDBusInterface and string
based method names. This means syncrononous calls, and also can get
easily broken in future porting, so this is switched to using the
generated interface.

BUG: 433203


(cherry picked from commit 8e45efdc)
parent 0517d44b
......@@ -49,6 +49,14 @@ qt5_add_dbus_interface (
features_interface
)
qt5_add_dbus_interface (
KAMD_KCM_SRCS
common/dbus/org.kde.ActivityManager.ResourceScoring.xml
resourcescoring_interface
)
kcmutils_generate_module_data(
KAMD_KCM_SRCS
MODULE_DATA_HEADER kactivitiesdata.h
......
......@@ -39,7 +39,7 @@ class ExtraActivitiesInterface::Private
{
public:
Private(ExtraActivitiesInterface *q)
: features(new KAMD_DBUS_CLASS_INTERFACE(Features, Features, q))
: features(new org::kde::ActivityManager::Features(QStringLiteral(KAMD_DBUS_SERVICE), QStringLiteral(KAMD_DBUS_FEATURES_PATH), QDBusConnection::sessionBus(), q))
, activitiesActionCollection(new KActionCollection(q, QStringLiteral("ActivityManager")))
{
activitiesActionCollection->setComponentDisplayName(i18n("Activities"));
......
......@@ -21,8 +21,11 @@
#include "PrivacyTab.h"
#include "kactivitymanagerd_plugins_settings.h"
#include "kactivitymanagerd_settings.h"
#include "resourcescoring_interface.h"
#include <QDBusPendingCall>
#include <QDBusConnection>
#include <QMenu>
#include <QQmlComponent>
#include <QQmlContext>
......@@ -135,9 +138,8 @@ void PrivacyTab::save()
void PrivacyTab::forget(int count, const QString &what)
{
KAMD_DBUS_DECL_INTERFACE(rankingsservice, Resources / Scoring, ResourcesScoring);
rankingsservice.asyncCall(QStringLiteral("DeleteRecentStats"), QString(), count, what);
org::kde::ActivityManager::ResourcesScoring rankingsservice(QStringLiteral(KAMD_DBUS_SERVICE), QStringLiteral(KAMD_DBUS_RESOURCES_SCORING_PATH), QDBusConnection::sessionBus());
rankingsservice.DeleteRecentStats(QString(), count, what);
d->messageWidget->animatedShow();
}
......
......@@ -21,22 +21,13 @@
#ifndef DBUS_COMMON_H
#define DBUS_COMMON_H
#include <QDBusConnection>
#include <QDBusInterface>
#define KAMD_DBUS_SERVICE "org.kde.ActivityManager"
#define KAMD_DBUS_SERVICE QStringLiteral("org.kde.ActivityManager")
#define KAMD_DBUS_ACTIVITYMANAGER_PATH "/ActivityManager"
#define KAMD_DBUS_OBJECT_PATH(A) (sizeof(#A) > 2 ? QLatin1String("/ActivityManager/" #A) : QLatin1String("/ActivityManager"))
#define KAMD_DBUS_FEATURES_PATH KAMD_DBUS_ACTIVITYMANAGER_PATH"/Features"
#define KAMD_DBUS_OBJECT(A) QLatin1String("org.kde.ActivityManager." #A)
#define KAMD_DBUS_INTERFACE(OBJECT_PATH, OBJECT, PARENT) \
QDBusInterface(KAMD_DBUS_SERVICE, KAMD_DBUS_OBJECT_PATH(OBJECT_PATH), KAMD_DBUS_OBJECT(OBJECT), QDBusConnection::sessionBus(), PARENT)
#define KAMD_DBUS_DECL_INTERFACE(VAR, OBJECT_PATH, OBJECT) \
QDBusInterface VAR(KAMD_DBUS_SERVICE, KAMD_DBUS_OBJECT_PATH(OBJECT_PATH), KAMD_DBUS_OBJECT(OBJECT), QDBusConnection::sessionBus(), nullptr)
#define KAMD_DBUS_CLASS_INTERFACE(OBJECT_PATH, OBJECT, PARENT) \
org::kde::ActivityManager::OBJECT(KAMD_DBUS_SERVICE, KAMD_DBUS_OBJECT_PATH(OBJECT_PATH), QDBusConnection::sessionBus(), PARENT)
#define KAMD_DBUS_RESOURCES_PATH KAMD_DBUS_ACTIVITYMANAGER_PATH"/Resources"
#define KAMD_DBUS_RESOURCES_SCORING_PATH KAMD_DBUS_RESOURCES_PATH"/Scoring"
#endif // DBUS_COMMON_H
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.kde.ActivityManager.ResourcesScoring">
<signal name="ResourceScoreUpdated">
<arg direction="out" type="s" name="activity"/>
<arg direction="out" type="s" name="client"/>
<arg direction="out" type="s" name="resource"/>
<arg direction="out" type="d" name="score"/>
<arg direction="out" type="u" name="lastUpdate"/>
<arg direction="out" type="u" name="firstUpdate"/>
</signal>
<signal name="ResourceScoreDeleted">
<arg direction="out" type="s" name="activity"/>
<arg direction="out" type="s" name="client"/>
<arg direction="out" type="s" name="resource"/>
</signal>
<signal name="RecentStatsDeleted">
<arg direction="out" type="s" name="activity"/>
<arg direction="out" type="i" name="count"/>
<arg direction="out" type="s" name="what"/>
</signal>
<signal name="EarlierStatsDeleted">
<arg direction="out" type="s" name="activity"/>
<arg direction="out" type="i" name="months"/>
</signal>
<method name="DeleteStatsForResource">
<arg direction="in" type="s" name="activity"/>
<arg direction="in" type="s" name="client"/>
<arg direction="in" type="s" name="resource"/>
</method>
<method name="DeleteRecentStats">
<arg direction="in" type="s" name="activity"/>
<arg direction="in" type="i" name="count"/>
<arg direction="in" type="s" name="what"/>
</method>
<method name="DeleteEarlierStats">
<arg direction="in" type="s" name="activity"/>
<arg direction="in" type="i" name="months"/>
</method>
</interface>
</node>
......@@ -59,7 +59,7 @@ public:
, activityWallpaper(QStringLiteral("activityWallpaper"))
, activityIsPrivate(true)
, activityShortcut(QStringLiteral("activityShortcut"))
, features(new KAMD_DBUS_CLASS_INTERFACE(Features, Features, q))
, features(new org::kde::ActivityManager::Features(QStringLiteral(KAMD_DBUS_SERVICE), QStringLiteral(KAMD_DBUS_FEATURES_PATH), QDBusConnection::sessionBus(), q))
{
}
......
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