|
@@ -24,81 +24,81 @@
|
|
|
|
|
|
#ifndef NO_SYSTEMD
|
|
#ifndef NO_SYSTEMD
|
|
#include <QtDBus>
|
|
#include <QtDBus>
|
|
|
|
+#endif
|
|
|
|
|
|
-ActionReply Helper::dbusaction(const QVariantMap &arguments)
|
|
|
|
|
|
+ActionReply Helper::action(const QVariantMap &arguments)
|
|
{
|
|
{
|
|
- QString method = arguments["method"].toString();
|
|
|
|
- QVariantList argsForCall = arguments["arguments"].toList();
|
|
|
|
-
|
|
|
|
ActionReply reply;
|
|
ActionReply reply;
|
|
|
|
|
|
- QDBusConnection systembus = QDBusConnection::systemBus();
|
|
|
|
|
|
+#ifndef NO_SYSTEMD
|
|
|
|
+ if (arguments["action"] == "dbusaction")
|
|
|
|
+ {
|
|
|
|
+ QString method = arguments["method"].toString();
|
|
|
|
+ QVariantList argsForCall = arguments["arguments"].toList();
|
|
|
|
|
|
- QDBusInterface *iface = new QDBusInterface ("org.freedesktop.systemd1",
|
|
|
|
- "/org/freedesktop/systemd1",
|
|
|
|
- "org.freedesktop.systemd1.Manager",
|
|
|
|
- systembus,
|
|
|
|
- this);
|
|
|
|
|
|
+ QDBusConnection systembus = QDBusConnection::systemBus();
|
|
|
|
|
|
- QDBusMessage dbusreply;
|
|
|
|
|
|
+ QDBusInterface *iface = new QDBusInterface ("org.freedesktop.systemd1",
|
|
|
|
+ "/org/freedesktop/systemd1",
|
|
|
|
+ "org.freedesktop.systemd1.Manager",
|
|
|
|
+ systembus,
|
|
|
|
+ this);
|
|
|
|
|
|
- if (iface->isValid())
|
|
|
|
- dbusreply = iface->callWithArgumentList(QDBus::AutoDetect, method, argsForCall);
|
|
|
|
- delete iface;
|
|
|
|
|
|
+ QDBusMessage dbusreply;
|
|
|
|
|
|
- if (method != "Reexecute")
|
|
|
|
- {
|
|
|
|
- if (dbusreply.type() == QDBusMessage::ErrorMessage)
|
|
|
|
|
|
+ if (iface->isValid())
|
|
|
|
+ dbusreply = iface->callWithArgumentList(QDBus::AutoDetect, method, argsForCall);
|
|
|
|
+ delete iface;
|
|
|
|
+
|
|
|
|
+ if (method != "Reexecute")
|
|
{
|
|
{
|
|
- reply.setErrorCode(ActionReply::DBusError);
|
|
|
|
- reply.setErrorDescription(dbusreply.errorMessage());
|
|
|
|
|
|
+ if (dbusreply.type() == QDBusMessage::ErrorMessage)
|
|
|
|
+ {
|
|
|
|
+ reply.setErrorCode(ActionReply::DBusError);
|
|
|
|
+ reply.setErrorDescription(dbusreply.errorMessage());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- return reply;
|
|
|
|
-}
|
|
|
|
|
|
+ else
|
|
#endif
|
|
#endif
|
|
-
|
|
|
|
-ActionReply Helper::read(const QVariantMap &args)
|
|
|
|
-{
|
|
|
|
- ActionReply reply;
|
|
|
|
- QString filename = args["filename"].toString();
|
|
|
|
- QFile file(filename);
|
|
|
|
-
|
|
|
|
- if (!file.open(QIODevice::ReadOnly))
|
|
|
|
|
|
+ if (arguments["action"] == "read")
|
|
{
|
|
{
|
|
- reply = ActionReply::HelperErrorType;
|
|
|
|
- reply.setErrorCode(ActionReply::AuthorizationDeniedError);
|
|
|
|
|
|
+ QString filename = arguments["filename"].toString();
|
|
|
|
+ QFile file(filename);
|
|
|
|
|
|
- return reply;
|
|
|
|
- }
|
|
|
|
|
|
+ if (!file.open(QIODevice::ReadOnly))
|
|
|
|
+ {
|
|
|
|
+ reply = ActionReply::HelperErrorType;
|
|
|
|
+ reply.setErrorCode(ActionReply::AuthorizationDeniedError);
|
|
|
|
|
|
- QTextStream stream(&file);
|
|
|
|
- QString content = stream.readAll();
|
|
|
|
|
|
+ return reply;
|
|
|
|
+ }
|
|
|
|
|
|
- QVariantMap retdata;
|
|
|
|
- retdata["content"] = content;
|
|
|
|
|
|
+ QTextStream stream(&file);
|
|
|
|
+ QString content = stream.readAll();
|
|
|
|
|
|
- reply.setData(retdata);
|
|
|
|
- return reply;
|
|
|
|
-}
|
|
|
|
|
|
+ QVariantMap retdata;
|
|
|
|
+ retdata["content"] = content;
|
|
|
|
|
|
-ActionReply Helper::write(const QVariantMap &args)
|
|
|
|
-{
|
|
|
|
- ActionReply reply;
|
|
|
|
- QString filename = args["filename"].toString();
|
|
|
|
- QFile file(filename);
|
|
|
|
|
|
+ reply.setData(retdata);
|
|
|
|
+ }
|
|
|
|
|
|
- if (!file.open(QIODevice::WriteOnly))
|
|
|
|
|
|
+ else if (arguments["action"] == "write")
|
|
{
|
|
{
|
|
- reply = ActionReply::HelperErrorType;
|
|
|
|
- reply.addData("errorDescription", file.errorString());
|
|
|
|
|
|
+ QString filename = arguments["filename"].toString();
|
|
|
|
+ QFile file(filename);
|
|
|
|
|
|
- return reply;
|
|
|
|
- }
|
|
|
|
|
|
+ if (!file.open(QIODevice::WriteOnly))
|
|
|
|
+ {
|
|
|
|
+ reply = ActionReply::HelperErrorType;
|
|
|
|
+ reply.addData("errorDescription", file.errorString());
|
|
|
|
|
|
- QTextStream stream(&file);
|
|
|
|
- stream << args["content"].toString();
|
|
|
|
|
|
+ return reply;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ QTextStream stream(&file);
|
|
|
|
+ stream << arguments["content"].toString();
|
|
|
|
+ }
|
|
|
|
|
|
return reply;
|
|
return reply;
|
|
}
|
|
}
|