Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Plasma
KSysGuard
Commits
348e452a
Commit
348e452a
authored
Sep 02, 2020
by
David Redondo
🏎
Browse files
Provide a --replace command line option
Useful when developing
parent
88e1ad8a
Changes
5
Hide whitespace changes
Inline
Side-by-side
ksystemstats/CMakeLists.txt
View file @
348e452a
...
...
@@ -8,7 +8,7 @@ set_source_files_properties("ksysguard_iface.xml"
qt5_add_dbus_adaptor
(
SOURCES
"ksysguard_iface.xml"
ksysguarddaemon.h KSysGuardDaemon
)
add_library
(
ksystemstats_core STATIC
${
SOURCES
}
)
target_link_libraries
(
ksystemstats_core PUBLIC Qt5::Core Qt5::DBus KF5::CoreAddons KSysGuard::StatsBackend
)
target_link_libraries
(
ksystemstats_core PUBLIC Qt5::Core Qt5::DBus KF5::CoreAddons
KF5::DBusAddons
KSysGuard::StatsBackend
)
add_executable
(
ksystemstats main.cpp
)
target_link_libraries
(
ksystemstats ksystemstats_core
)
...
...
ksystemstats/autotests/main.cpp
View file @
348e452a
...
...
@@ -72,7 +72,7 @@ public:
protected:
void
loadProviders
()
override
;
private
Q_SLOTS
:
void
init
();
void
init
TestCase
();
void
findById
();
void
update
();
void
subscription
();
...
...
@@ -98,9 +98,11 @@ void KStatsTest::loadProviders()
registerProvider
(
m_testPlugin
);
}
void
KStatsTest
::
init
()
void
KStatsTest
::
init
TestCase
()
{
KSysGuardDaemon
::
init
();
QDBusConnection
::
sessionBus
().
registerObject
(
"/"
,
this
,
QDBusConnection
::
ExportAdaptors
);
loadProviders
();
}
void
KStatsTest
::
findById
()
...
...
@@ -150,7 +152,7 @@ void KStatsTest::changes()
void
KStatsTest
::
dbusApi
()
{
OrgKdeKSysGuardDaemonInterface
iface
(
"org.kde.ksystemstats"
,
OrgKdeKSysGuardDaemonInterface
iface
(
QDBusConnection
::
sessionBus
().
baseService
()
,
"/"
,
QDBusConnection
::
sessionBus
(),
this
);
...
...
ksystemstats/ksysguarddaemon.cpp
View file @
348e452a
/*
Copyright (c) 2019 David Edmundson <davidedmundson@kde.org>
Copyright (c) 2020 David Redondo <kde@david-redondo.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
...
...
@@ -32,6 +33,7 @@
#include
"SensorContainer.h"
#include
"SensorProperty.h"
#include
<KDBusService>
#include
<KPluginLoader>
#include
<KPluginMetaData>
#include
<KPluginFactory>
...
...
@@ -67,14 +69,16 @@ KSysGuardDaemon::~KSysGuardDaemon()
}
}
void
KSysGuardDaemon
::
init
()
void
KSysGuardDaemon
::
init
(
ReplaceIfRunning
replaceIfRunning
)
{
loadProviders
();
QDBusConnection
::
sessionBus
().
registerObject
(
"/"
,
this
,
QDBusConnection
::
ExportAdaptors
);
if
(
!
QDBusConnection
::
sessionBus
().
registerService
(
"org.kde.ksystemstats"
))
{
qCritical
()
<<
"Unable to register DBus service org.kde.ksystemstats. Maybe it is already running?"
;
exit
(
1
);
KDBusService
::
StartupOptions
options
=
KDBusService
::
Unique
;
if
(
replaceIfRunning
==
ReplaceIfRunning
::
Replace
)
{
options
|=
KDBusService
::
Replace
;
}
auto
service
=
new
KDBusService
(
options
,
this
);
service
->
setExitValue
(
1
);
QDBusConnection
::
sessionBus
().
registerObject
(
"/"
,
this
,
QDBusConnection
::
ExportAdaptors
);
}
void
KSysGuardDaemon
::
loadProviders
()
...
...
ksystemstats/ksysguarddaemon.h
View file @
348e452a
...
...
@@ -35,11 +35,15 @@ class QDBusServiceWatcher;
class
KSysGuardDaemon
:
public
QObject
,
public
QDBusContext
{
Q_OBJECT
public:
enum
class
ReplaceIfRunning
{
Replace
,
DoNotReplace
};
KSysGuardDaemon
();
~
KSysGuardDaemon
();
void
init
();
void
init
(
ReplaceIfRunning
replaceIfRunning
);
SensorProperty
*
findSensor
(
const
QString
&
path
)
const
;
public
Q_SLOTS
:
...
...
ksystemstats/main.cpp
View file @
348e452a
/*
Copyright (c) 2019 David Edmundson <davidedmundson@kde.org>
Copyright (c) 2020 David Redondo <kde@david-redondo.de>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
...
...
@@ -18,6 +19,7 @@
*/
#include
<QCoreApplication>
#include
<QCommandLineParser>
#include
<QDebug>
#include
"ksysguarddaemon.h"
...
...
@@ -26,7 +28,13 @@ int main(int argc, char **argv)
{
QCoreApplication
app
(
argc
,
argv
);
app
.
setQuitLockEnabled
(
false
)
;
app
.
setOrganizationDomain
(
QStringLiteral
(
"kde.org"
));
QCommandLineParser
parser
;
parser
.
addOption
(
QCommandLineOption
(
QStringLiteral
(
"replace"
),
QStringLiteral
(
"Replace the running instance"
)));
parser
.
process
(
app
);
KSysGuardDaemon
d
;
d
.
init
();
d
.
init
(
parser
.
isSet
(
QStringLiteral
(
"replace"
))
?
KSysGuardDaemon
::
ReplaceIfRunning
::
Replace
:
KSysGuardDaemon
::
ReplaceIfRunning
::
DoNotReplace
);
app
.
exec
();
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment