generic: adjust to KAuthorization changes

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2022-12-12 08:27:34 +02:00
parent c8991662be
commit 1e2511421c
8 changed files with 62 additions and 41 deletions

View file

@ -57,6 +57,34 @@ static QString findNtpUtility()
return QString(); return QString();
} }
ClockHelper::ClockHelper(const char* const helper, QObject *parent)
: KAuthorization(helper, parent)
{
}
int ClockHelper::save(const QVariantMap &args)
{
bool _ntp = args.value("ntp").toBool();
bool _date = args.value("date").toBool();
bool _tz = args.value("tz").toBool();
bool _tzreset = args.value("tzreset").toBool();
KComponentData data( "kcmdatetimehelper" );
int ret = NoError; // error code
// The order here is important
if( _ntp )
ret |= ntp( args.value("ntpServers").toStringList(), args.value("ntpEnabled").toBool());
if( _date )
ret |= date( args.value("newdate").toString(), args.value("olddate").toString() );
if( _tz )
ret |= tz( args.value("tzone").toString() );
if( _tzreset )
ret |= tzreset();
return ret;
}
ClockHelper::CH_Error ClockHelper::ntp( const QStringList& ntpServers, bool ntpEnabled ) ClockHelper::CH_Error ClockHelper::ntp( const QStringList& ntpServers, bool ntpEnabled )
{ {
// write to the system config file // write to the system config file
@ -142,27 +170,4 @@ ClockHelper::CH_Error ClockHelper::tzreset()
return NoError; return NoError;
} }
int ClockHelper::save(const QVariantMap &args)
{
bool _ntp = args.value("ntp").toBool();
bool _date = args.value("date").toBool();
bool _tz = args.value("tz").toBool();
bool _tzreset = args.value("tzreset").toBool();
KComponentData data( "kcmdatetimehelper" );
int ret = NoError; // error code
// The order here is important
if( _ntp )
ret |= ntp( args.value("ntpServers").toStringList(), args.value("ntpEnabled").toBool());
if( _date )
ret |= date( args.value("newdate").toString(), args.value("olddate").toString() );
if( _tz )
ret |= tz( args.value("tzone").toString() );
if( _tzreset )
ret |= tzreset();
return ret;
}
K_AUTH_MAIN("org.kde.kcontrol.kcmclock", ClockHelper) K_AUTH_MAIN("org.kde.kcontrol.kcmclock", ClockHelper)

View file

@ -27,23 +27,25 @@ class ClockHelper : public KAuthorization
{ {
Q_OBJECT Q_OBJECT
public: public:
enum CH_Error { enum CH_Error {
NoError = 0, NoError = 0,
CallError = 1, CallError = 1,
TimezoneError = 2, TimezoneError = 2,
NTPError = 4, NTPError = 4,
DateError = 8 DateError = 8
}; };
public slots: ClockHelper(const char* const helper, QObject *parent = nullptr);
int save(const QVariantMap &map);
private: public slots:
CH_Error ntp(const QStringList& ntpServers, bool ntpEnabled); int save(const QVariantMap &map);
CH_Error date(const QString& newdate, const QString& olddate);
CH_Error tz(const QString& selectedzone); private:
CH_Error tzreset(); CH_Error ntp(const QStringList& ntpServers, bool ntpEnabled);
CH_Error date(const QString& newdate, const QString& olddate);
CH_Error tz(const QString& selectedzone);
CH_Error tzreset();
}; };
#endif // CLOCK_HELPER_H #endif // CLOCK_HELPER_H

View file

@ -23,6 +23,11 @@
#include "config-workspace.h" #include "config-workspace.h"
KGreeterHelper::KGreeterHelper(const char* const helper, QObject *parent)
: KAuthorization(helper, parent)
{
}
int KGreeterHelper::save(const QVariantMap &parameters) int KGreeterHelper::save(const QVariantMap &parameters)
{ {
if (!parameters.contains("font") || !parameters.contains("style") if (!parameters.contains("font") || !parameters.contains("style")

View file

@ -24,6 +24,8 @@
class KGreeterHelper : public KAuthorization class KGreeterHelper : public KAuthorization
{ {
Q_OBJECT Q_OBJECT
public:
KGreeterHelper(const char* const helper, QObject *parent = nullptr);
public slots: public slots:
int save(const QVariantMap &parameters); int save(const QVariantMap &parameters);
}; };

View file

@ -23,7 +23,8 @@
#include "helper.h" #include "helper.h"
#include "processes_local_p.h" #include "processes_local_p.h"
KSysGuardProcessListHelper::KSysGuardProcessListHelper() KSysGuardProcessListHelper::KSysGuardProcessListHelper(const char* const helper, QObject *parent)
: KAuthorization(helper, parent)
{ {
qRegisterMetaType<QList<long long> >(); qRegisterMetaType<QList<long long> >();
} }

View file

@ -28,8 +28,7 @@ class KSysGuardProcessListHelper : public KAuthorization
{ {
Q_OBJECT Q_OBJECT
public: public:
KSysGuardProcessListHelper(); KSysGuardProcessListHelper(const char* const helper, QObject *parent = nullptr);
public Q_SLOTS: public Q_SLOTS:
int renice(QVariantMap parameters); int renice(QVariantMap parameters);
int changecpuscheduler(QVariantMap parameters); int changecpuscheduler(QVariantMap parameters);

View file

@ -30,6 +30,11 @@
# include <errno.h> # include <errno.h>
#endif #endif
SolidUiServerHelper::SolidUiServerHelper(const char* const helper, QObject *parent)
: KAuthorization(helper, parent)
{
}
int SolidUiServerHelper::cryptopen(const QVariantMap &parameters) int SolidUiServerHelper::cryptopen(const QVariantMap &parameters)
{ {
if (!parameters.contains("device") || !parameters.contains("name") || !parameters.contains("password")) { if (!parameters.contains("device") || !parameters.contains("name") || !parameters.contains("password")) {

View file

@ -24,6 +24,8 @@
class SolidUiServerHelper : public KAuthorization class SolidUiServerHelper : public KAuthorization
{ {
Q_OBJECT Q_OBJECT
public:
SolidUiServerHelper(const char* const helper, QObject *parent = nullptr);
public Q_SLOTS: public Q_SLOTS:
int cryptopen(const QVariantMap &parameters); int cryptopen(const QVariantMap &parameters);
int cryptclose(const QVariantMap &parameters); int cryptclose(const QVariantMap &parameters);