kupdatenotifier: start the service if it is not registered

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2022-04-07 22:42:34 +03:00
parent 31845025f2
commit 3edfb79f33
3 changed files with 12 additions and 4 deletions

View file

@ -27,9 +27,6 @@
// for reference:
// https://www.freedesktop.org/software/PackageKit/gtk-doc/PackageKit.html
#define PACKAGEKIT_SERVICE "org.freedesktop.PackageKit"
#define PACKAGEKIT_PATH "/org/freedesktop/PackageKit"
#define PACKAGEKIT_IFACE "org.freedesktop.PackageKit"
KUpdateNotifier::KUpdateNotifier(QObject* parent)
: KStatusNotifierItem(parent),

View file

@ -25,6 +25,10 @@
#include <kmenu.h>
#include <khelpmenu.h>
#define PACKAGEKIT_SERVICE "org.freedesktop.PackageKit"
#define PACKAGEKIT_PATH "/org/freedesktop/PackageKit"
#define PACKAGEKIT_IFACE "org.freedesktop.PackageKit"
class KUpdateNotifier : public KStatusNotifierItem
{
Q_OBJECT

View file

@ -16,6 +16,7 @@
Boston, MA 02110-1301, USA.
*/
#include <QDBusConnectionInterface>
#include <kuniqueapplication.h>
#include <klocale.h>
#include <kcmdlineargs.h>
@ -48,10 +49,16 @@ int main(int argc, char** argv)
KUniqueApplication kupdatenotifierapp;
kupdatenotifierapp.setQuitOnLastWindowClosed(false);
if (!KUniqueApplication::start()) {
kWarning() << "kupdatenotifier is already running!";
kDebug() << "kupdatenotifier is already running!";
return 0;
}
QDBusConnectionInterface* systembusiface = QDBusConnection::systemBus().interface();
if (!systembusiface->isServiceRegistered(PACKAGEKIT_SERVICE)) {
kDebug() << "activating" << PACKAGEKIT_SERVICE;
systembusiface->startService(PACKAGEKIT_SERVICE);
}
KUpdateNotifier kupdatenotifier(&kupdatenotifierapp);
return kupdatenotifierapp.exec();