| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 | 
							- /*
 
-  * Copyright (C) 2015  Malte Veerman <maldela@halloarsch.de>
 
-  *
 
-  * This program is free software; you can redistribute it and/or modify
 
-  * it under the terms of the GNU Lesser General Public License as published by
 
-  * the Free Software Foundation; either version 2 of the License, or
 
-  * (at your option) any later version.
 
-  *
 
-  * This program is distributed in the hope that it will be useful,
 
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
-  * GNU Lesser General Public License for more details.
 
-  *
 
-  * You should have received a copy of the GNU Lesser General Public License along
 
-  * with this program; if not, write to the Free Software Foundation, Inc.,
 
-  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
-  *
 
-  */
 
- #include "helper.h"
 
- #include <QFile>
 
- #include <QTextStream>
 
- #ifndef NO_SYSTEMD
 
- #include <QtDBus>
 
- #endif
 
- ActionReply Helper::action(const QVariantMap &arguments)
 
- {
 
-     ActionReply reply;
 
- #ifndef NO_SYSTEMD
 
-     if (arguments["action"] == "dbusaction")
 
-     {
 
-         QString method = arguments["method"].toString();
 
-         QVariantList argsForCall = arguments["arguments"].toList();
 
-         QDBusConnection systembus = QDBusConnection::systemBus();
 
-         QDBusInterface *iface = new QDBusInterface ("org.freedesktop.systemd1",
 
-                                                     "/org/freedesktop/systemd1",
 
-                                                     "org.freedesktop.systemd1.Manager",
 
-                                                     systembus,
 
-                                                     this);
 
-         QDBusMessage dbusreply;
 
-         if (iface->isValid())
 
-             dbusreply = iface->callWithArgumentList(QDBus::AutoDetect, method, argsForCall);
 
-         delete iface;
 
-         if (method != "Reexecute")
 
-         {
 
-             if (dbusreply.type() == QDBusMessage::ErrorMessage)
 
-             {
 
-                 reply.setErrorCode(ActionReply::DBusError);
 
-                 reply.setErrorDescription(dbusreply.errorMessage());
 
-             }
 
-         }
 
-     }
 
-     else
 
- #endif
 
-     if (arguments["action"] == "read")
 
-     {
 
-         QString filename = arguments["filename"].toString();
 
-         QFile file(filename);
 
-         if (!file.open(QIODevice::ReadOnly))
 
-         {
 
-            reply = ActionReply::HelperErrorType;
 
-            reply.setErrorCode(ActionReply::AuthorizationDeniedError);
 
-            return reply;
 
-         }
 
-         QTextStream stream(&file);
 
-         QString content = stream.readAll();
 
-         QVariantMap retdata;
 
-         retdata["content"] = content;
 
-         reply.setData(retdata);
 
-     }
 
-     else if (arguments["action"] == "write")
 
-     {
 
-         QString filename = arguments["filename"].toString();
 
-         QFile file(filename);
 
-         if (!file.open(QIODevice::WriteOnly))
 
-         {
 
-            reply = ActionReply::HelperErrorType;
 
-            reply.addData("errorDescription", file.errorString());
 
-            return reply;
 
-         }
 
-         QTextStream stream(&file);
 
-         stream << arguments["content"].toString();
 
-     }
 
-     return reply;
 
- }
 
- KAUTH_HELPER_MAIN("fancontrol.gui.helper", Helper)
 
 
  |