Commit d36ae107 authored by David Jarvie's avatar David Jarvie

Update RTC wake to KF5

parent ad60a339
/*
* functions.cpp - miscellaneous functions
* Program: kalarm
* Copyright © 2001-2017 by David Jarvie <djarvie@kde.org>
* Copyright © 2001-2018 by David Jarvie <djarvie@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -1066,38 +1066,26 @@ void Private::cancelRtcWake()
*/
bool setRtcWakeTime(unsigned triggerTime, QWidget* parent)
{
#if 0 //QT5
QVariantMap args;
args[QLatin1String("time")] = triggerTime;
KAuth::Action action(QLatin1String("org.kde.kalarmrtcwake.settimer"));
action.setHelperID(QLatin1String("org.kde.kalarmrtcwake"));
KAuth::Action action(QStringLiteral("org.kde.kalarmrtcwake.settimer"));
action.setHelperId(QStringLiteral("org.kde.kalarmrtcwake"));
action.setParentWidget(parent);
action.setArguments(args);
KAuth::ActionReply reply = action.execute();
if (reply.failed())
KAuth::ExecuteJob* job = action.execute();
if (!job->exec())
{
QString errmsg = reply.errorDescription();
qCDebug(KALARM_LOG) << "Error code=" << reply.errorCode() << errmsg;
QString errmsg = job->errorString();
qCDebug(KALARM_LOG) << "Error code=" << job->error() << errmsg;
if (errmsg.isEmpty())
{
int errcode = reply.errorCode();
switch (reply.type())
int errcode = job->error();
switch (errcode)
{
case KAuth::ActionReply::KAuthErrorType:
case KAuth::ActionReply::AuthorizationDeniedError:
case KAuth::ActionReply::UserCancelledError:
qCDebug(KALARM_LOG) << "Authorization error:" << errcode;
switch (errcode)
{
case KAuth::ActionReply::AuthorizationDeniedError:
case KAuth::ActionReply::UserCancelledError:
return false; // the user should already know about this
default:
break;
}
break;
case KAuth::ActionReply::HelperErrorType:
qCDebug(KALARM_LOG) << "Helper error:" << errcode;
errcode += 100; // make code distinguishable from KAuthError type
break;
return false; // the user should already know about this
default:
break;
}
......@@ -1106,7 +1094,6 @@ bool setRtcWakeTime(unsigned triggerTime, QWidget* parent)
KAMessageBox::information(parent, errmsg);
return false;
}
#endif
return true;
}
......
/*
* rtcwakeaction.cpp - KAuth helper application to execute rtcwake commands
* Program: kalarm
* Copyright © 2011 by David Jarvie <djarvie@kde.org>
* Copyright © 2011,2018 by David Jarvie <djarvie@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -88,7 +88,7 @@ ActionReply RtcWakeAction::settimer(const QVariantMap& args)
switch (result)
{
case 0:
return ActionReply::SuccessType;
return ActionReply::SuccessReply();
case -2:
errmsg = xi18nc("@text/plain", "Could not run <command>%1</command> to set wake from suspend", QStringLiteral("rtcwake"));
break;
......@@ -96,15 +96,10 @@ ActionReply RtcWakeAction::settimer(const QVariantMap& args)
errmsg = xi18nc("@text/plain", "Error setting wake from suspend.<nl/>Command was: <command>%1 %2</command><nl/>Error code: %3.", proc.program(), proc.arguments().join(QStringLiteral(" ")), result);
break;
}
#if 0 //QT5
ActionReply reply(ActionReply::HelperErrorReply);
reply.setErrorCode(result);
ActionReply reply = ActionReply::HelperErrorReply(result);
reply.setErrorDescription(errmsg);
qCDebug(KALARM_LOG) , "RtcWakeAction::settimer: Code=" , reply.errorCode() , reply.errorDescription();
qCDebug(KALARM_LOG) << "RtcWakeAction::settimer: Code=" << reply.errorCode() << reply.errorDescription();
return reply;
#else
return 0;
#endif
}
KAUTH_HELPER_MAIN("org.kde.kalarmrtcwake", RtcWakeAction)
......
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