Bladeren bron

Added STANDARD_HELPER_ID cmake variable

Malte Veerman 6 jaren geleden
bovenliggende
commit
eb2288b767
4 gewijzigde bestanden met toevoegingen van 17 en 16 verwijderingen
  1. 2 1
      CMakeLists.txt
  2. 2 2
      helper/fancontrol.gui.helper.conf
  3. 6 11
      helper/src/helper.cpp
  4. 7 2
      import/src/fancontrolaction.h

+ 2 - 1
CMakeLists.txt

@@ -13,9 +13,10 @@ option(INSTALL_SHARED "Install the shared parts" ON)
 #variables
 set(STANDARD_SERVICE_NAME "fancontrol" CACHE STRING "The name of the systemd service for the fancontrol script")
 set(STANDARD_CONFIG_FILE "/etc/fancontrol" CACHE STRING "The location of the standard config file for the fancontrol script")
+set(STANDARD_HELPER_ID "fancontrol.gui.helper" CACHE STRING "The standard id for the KAuth helper")
 add_definitions(-DSTANDARD_SERVICE_NAME="${STANDARD_SERVICE_NAME}")
 add_definitions(-DSTANDARD_CONFIG_FILE="${STANDARD_CONFIG_FILE}")
-
+add_definitions(-DSTANDARD_HELPER_ID="${STANDARD_HELPER_ID}")
 
 #KCM can't be build without systemd support
 if(BUILD_KCM AND NO_SYSTEMD)

+ 2 - 2
helper/fancontrol.gui.helper.conf

@@ -2,10 +2,10 @@
  "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
  "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
 <busconfig>
- 
+
   <!-- Only user root can own the foo helper -->
   <policy user="root">
     <allow own="fancontrol.gui.helper"/>
   </policy>
- 
+
 </busconfig>

+ 6 - 11
helper/src/helper.cpp

@@ -34,6 +34,11 @@
 #include <QtDBus/QDBusVariant>
 
 
+#ifndef STANDARD_HELPER_ID
+#define STANDARD_HELPER_ID "fancontrol.gui.helper"
+#endif
+
+
 using namespace KAuth;
 
 struct StringStruct
@@ -99,7 +104,6 @@ ActionReply Helper::action(const QVariantMap &arguments)
                 if (dbusmessage.type() == QDBusMessage::ErrorMessage)
                 {
                     reply = ActionReply::HelperErrorReply();
-                    reply.setErrorCode(ActionReply::DBusError);
                     reply.setErrorDescription(dbusmessage.errorMessage());
                 }
                 else if (dbusmessage.type() == QDBusMessage::ReplyMessage)
@@ -118,7 +122,6 @@ ActionReply Helper::action(const QVariantMap &arguments)
                         else
                         {
                             reply = ActionReply::HelperErrorReply();
-                            reply.setErrorCode(ActionReply::DBusError);
                             reply.setErrorDescription(dbusreply.error().message());
                         }
                     }
@@ -138,7 +141,6 @@ ActionReply Helper::action(const QVariantMap &arguments)
                         else
                         {
                             reply = ActionReply::HelperErrorReply();
-                            reply.setErrorCode(ActionReply::DBusError);
                             reply.setErrorDescription(dbusreply.error().message());
                         }
                     }
@@ -154,7 +156,6 @@ ActionReply Helper::action(const QVariantMap &arguments)
                         else
                         {
                             reply = ActionReply::HelperErrorReply();
-                            reply.setErrorCode(ActionReply::DBusError);
                             reply.setErrorDescription(dbusreply.error().message());
                         }
                     }
@@ -164,7 +165,6 @@ ActionReply Helper::action(const QVariantMap &arguments)
         else
         {
             reply = ActionReply::HelperErrorReply();
-            reply.setErrorCode(ActionReply::DBusError);
             reply.setErrorDescription(i18n("Could not create dbus interface"));
         }
         delete iface;
@@ -186,7 +186,6 @@ ActionReply Helper::action(const QVariantMap &arguments)
         else
         {
             reply = ActionReply::HelperErrorReply();
-            reply.setErrorCode(ActionReply::InvalidActionError);
             reply.setErrorDescription(file.errorString());
         }
     }
@@ -204,7 +203,6 @@ ActionReply Helper::action(const QVariantMap &arguments)
         else
         {
             reply = ActionReply::HelperErrorReply();
-            reply.setErrorCode(ActionReply::InvalidActionError);
             reply.setErrorDescription(file.errorString());
         }
     }
@@ -220,13 +218,11 @@ ActionReply Helper::action(const QVariantMap &arguments)
         if (!process.waitForStarted(1000))
         {
             reply = ActionReply::HelperErrorReply();
-            reply.setErrorCode(ActionReply::InvalidActionError);
             reply.setErrorDescription(process.errorString());
         }
         else if (!process.waitForFinished(10000))
         {
             reply = ActionReply::HelperErrorReply();
-            reply.setErrorCode(ActionReply::InvalidActionError);
             reply.setErrorDescription(process.errorString());
         }
     }
@@ -234,11 +230,10 @@ ActionReply Helper::action(const QVariantMap &arguments)
     else
     {
         reply = ActionReply::HelperErrorReply();
-        reply.setErrorCode(ActionReply::NoSuchActionError);
         reply.setErrorDescription(i18n("This action does not exist!"));
     }
 
     return reply;
 }
 
-KAUTH_HELPER_MAIN("fancontrol.gui.helper", Helper)
+KAUTH_HELPER_MAIN(STANDARD_HELPER_ID, Helper)

+ 7 - 2
import/src/fancontrolaction.h

@@ -27,13 +27,18 @@
 #include <KAuth/KAuthAction>
 
 
+#ifndef STANDARD_HELPER_ID
+#define STANDARD_HELPER_ID "fancontrol.gui.helper"
+#endif
+
+
 namespace Fancontrol
 {
 
 inline KAuth::Action newFancontrolAction()
 {
-    KAuth::Action action(QStringLiteral("fancontrol.gui.helper.action"));
-    action.setHelperId(QStringLiteral("fancontrol.gui.helper"));
+    KAuth::Action action(QStringLiteral(STANDARD_HELPER_ID) + ".action");
+    action.setHelperId(QStringLiteral(STANDARD_HELPER_ID));
 
     return action;
 }