Plasma5Support

packagekitengine.cpp
1/*
2 SPDX-FileCopyrightText: 2012 Gregor Taetzner <gregor@freenet.de>
3
4 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
5*/
6
7#include "packagekitengine.h"
8#include "packagekitservice.h"
9
10#include <QDBusConnection>
11#include <QDBusMessage>
12
13PackagekitEngine::PackagekitEngine(QObject *parent)
14 : DataEngine(parent)
15 , m_pk_available(false)
16{
17}
18
19void PackagekitEngine::init()
20{
21 QDBusMessage message;
22 message = QDBusMessage::createMethodCall(QStringLiteral("org.freedesktop.DBus"),
23 QStringLiteral("/org/freedesktop/DBus"),
24 QStringLiteral("org.freedesktop.DBus"),
25 QStringLiteral("ListActivatableNames"));
26
28 if (reply.type() == QDBusMessage::ReplyMessage && reply.arguments().size() == 1) {
29 QStringList list = reply.arguments().first().toStringList();
30 if (list.contains(QLatin1String("org.freedesktop.PackageKit"))) {
31 m_pk_available = true;
32 }
33 }
34
35 setData(QStringLiteral("Status"), QStringLiteral("available"), m_pk_available);
36}
37
38Plasma5Support::Service *PackagekitEngine::serviceForSource(const QString &source)
39{
40 if (m_pk_available) {
41 return new PackagekitService(this);
42 }
43
44 // if packagekit not available, return null service
46}
47
48K_PLUGIN_CLASS_WITH_JSON(PackagekitEngine, "plasma-dataengine-packagekit.json")
49
50#include "packagekitengine.moc"
#define K_PLUGIN_CLASS_WITH_JSON(classname, jsonFile)
virtual Q_INVOKABLE Service * serviceForSource(const QString &source)
void setData(const QString &source, const QVariant &value)
Sets a value for a data source.
This class provides a generic API for write access to settings or services.
Definition service.h:78
KIOCORE_EXPORT QStringList list(const QString &fileClass)
QDBusMessage call(const QDBusMessage &message, QDBus::CallMode mode, int timeout) const const
QDBusConnection sessionBus()
QList< QVariant > arguments() const const
QDBusMessage createMethodCall(const QString &service, const QString &path, const QString &interface, const QString &method)
MessageType type() const const
bool contains(QLatin1StringView str, Qt::CaseSensitivity cs) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:59:38 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.