gdbus: Move dbus interface definition to one header file 22/184522/1
authorChanwoo Choi <cw00.choi@samsung.com>
Thu, 17 May 2018 04:02:10 +0000 (13:02 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Wed, 18 Jul 2018 11:04:20 +0000 (20:04 +0900)
Move dbus interface definition to gdbus-util.h header file
and clean-up code as following:
- Rename dbus definition from PASS_DBUS_BUS_NAME to DBUS_CORE_BUS_NAME
- Use ARRAY_SIZE() macro and then remove unnecessary following definitions:
  : DBUS_CORE_I_NUM_SIGNALS
  : DBUS_PMQOS_I_NUM_SIGNALS

Change-Id: Ic3f78d84b353bfe382330366d10292711de8c5fa
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
include/pass/gdbus-util.h
src/core/main.c
src/pass/pass.c
src/pmqos/pmqos.c
src/thermal/thermal.c

index eaa09ead590b1f5ffdcc9a5466c4326fc9192fcf..1eb349e0d2683676b9e6dca0d161c60127c98447 100644 (file)
 #include "pmqos/pmqos-dbus-stub.h"
 #include "thermal/thermal-dbus-stub.h"
 
+/* Dbus definition for PASS */
+#define DBUS_PASS_BUS_NAME                     "org.tizen.system.pass"
+
+#define DBUS_CORE_INTERFACE                    "org.tizen.system.pass.core"
+#define DBUS_CORE_PATH                         "/Org/Tizen/System/Pass/Core"
+#define DBUS_CORE_I_START_HANDLER              "handle_start"
+#define DBUS_CORE_I_STOP_HANDLER               "handle_stop"
+
+#define DBUS_PMQOS_INTERFACE                   "org.tizen.system.pass.pmqos"
+#define DBUS_PMQOS_PATH                                "/Org/Tizen/System/Pass/Pmqos"
+#define DBUS_PMQOS_I_START_HANDLER             "handle_start"
+#define DBUS_PMQOS_I_STOP_HANDLER              "handle_stop"
+#define DBUS_PMQOS_I_APPLAUNCH_HANDLER         "handle_app_launch"
+#define DBUS_PMQOS_I_ULTRAPOWERSAVING_HANDLER  "handle_ultra_power_saving"
+
+#define DBUS_THERMAL_INTERFACE                 "org.tizen.system.pass.monitor.thermal"
+#define DBUS_THERMAL_PATH                      "/Org/Tizen/System/Pass/Monitor/Thermal"
+#define DBUS_THERMAL_I_START_HANDLER           "handle_start"
+#define DBUS_THERMAL_I_STOP_HANDLER            "handle_stop"
+#define DBUS_THERMAL_METHOD                    "thermal_scenario"
+
+/* Dbus definition for systemd */
 #define SYSTEMD_DBUS_NAME                      "org.freedesktop.systemd1"
 #define SYSTEMD_DBUS_OBJECT_PATH               "/org/freedesktop/systemd1"
 #define SYSTEMD_DBUS_IFACE_FOR_PROPS           "org.freedesktop.DBus.Properties"
index a3c2542747ebd5c0f446192022136a1d1ee40114..b86224d46f9f3387c3b5836b715e47c724465b9c 100644 (file)
@@ -29,8 +29,6 @@
 #include <pass/gdbus-util.h>
 #include <pass/log.h>
 
-#define PASS_DBUS_BUS_NAME     "org.tizen.system.pass"
-
 unsigned int g_startup_cb_id;
 GMainLoop *g_mainloop;
 
@@ -97,7 +95,7 @@ static int late_init(void)
        signal(SIGTERM, sig_quit);
        signal(SIGUSR1, sig_usr1);
 
-       ret = pass_gdbus_get_name(PASS_DBUS_BUS_NAME);
+       ret = pass_gdbus_get_name(DBUS_PASS_BUS_NAME);
        if (ret < 0)
                return ret;
 
index aa86b14209ecab45194e33c55de02a30cfeb1251..378ca9e62968719a639a8dcae1fcb57120c4a0dc 100644 (file)
 #include "pass-parser.h"
 #include "pass-hal.h"
 
-#define DBUS_CORE_I_START_HANDLER              "handle_start"
-#define DBUS_CORE_I_STOP_HANDLER               "handle_stop"
-#define DBUS_CORE_I_NUM_SIGNALS                        2
-#define DBUS_CORE_INTERFACE                    "org.tizen.system.pass.core"
-#define DBUS_CORE_PATH                         "/Org/Tizen/System/Pass/Core"
 #define PASS_CONF_PATH                         "/etc/pass/pass.conf"
 
 static uint64 supported_module[] = {
@@ -411,7 +406,7 @@ static void pass_exit(void *data)
                        pass_init_done, NULL);
 
        pass_gdbus_disconnect_signal(g_gdbus_instance,
-                       DBUS_CORE_I_NUM_SIGNALS, g_gdbus_signal_infos);
+                       ARRAY_SIZE(g_gdbus_signal_infos), g_gdbus_signal_infos);
        pass_gdbus_put_instance_core(&g_gdbus_instance);
 
        pass_exit_done();
@@ -438,7 +433,7 @@ static int pass_probe(void *data)
        }
 
        ret = pass_gdbus_connect_signal(g_gdbus_instance,
-                       DBUS_CORE_I_NUM_SIGNALS, g_gdbus_signal_infos);
+                       ARRAY_SIZE(g_gdbus_signal_infos), g_gdbus_signal_infos);
        if (ret < 0) {
                _E("cannot register callbacks as the dbus method invocation "
                                "handlers\n");
@@ -473,7 +468,7 @@ static int pass_probe(void *data)
 
 out_disconnect:
        pass_gdbus_disconnect_signal(g_gdbus_instance,
-                       DBUS_CORE_I_NUM_SIGNALS, g_gdbus_signal_infos);
+                       ARRAY_SIZE(g_gdbus_signal_infos), g_gdbus_signal_infos);
 out:
        pass_gdbus_put_instance_core(&g_gdbus_instance);
 
index 6a6a89cc1122c776226c99962483ad67526a8bc9..0c8355b36a0cbfe37ba98db8644832d53edb195e 100644 (file)
 #define MILLISECONDS(tv)       ((tv.tv_sec)*1000 + (tv.tv_nsec)/1000000)
 #define DELTA(a, b)            (MILLISECONDS(a) - MILLISECONDS(b))
 
-#define DBUS_PMQOS_I_APPLAUNCH_HANDLER         "handle_app_launch"
-#define DBUS_PMQOS_I_ULTRAPOWERSAVING_HANDLER  "handle_ultra_power_saving"
-#define DBUS_PMQOS_I_START_HANDLER             "handle_start"
-#define DBUS_PMQOS_I_STOP_HANDLER              "handle_stop"
-#define DBUS_PMQOS_I_NUM_SIGNALS               4
-#define DBUS_PMQOS_INTERFACE                   "org.tizen.system.pass.pmqos"
-#define DBUS_PMQOS_PATH                                "/Org/Tizen/System/Pass/Pmqos"
-
 static SystemPassPmqos *g_gdbus_instance = NULL;
 static struct pmqos_scenario *g_pmqos = NULL;
 
@@ -482,7 +474,7 @@ static void pmqos_exit(void *data)
                        pmqos_init_done, NULL);
 
        pass_gdbus_disconnect_signal(g_gdbus_instance,
-                       DBUS_PMQOS_I_NUM_SIGNALS, g_gdbus_signal_infos);
+                       ARRAY_SIZE(g_gdbus_signal_infos), g_gdbus_signal_infos);
        pass_gdbus_put_instance_pmqos(&g_gdbus_instance);
 
        pmqos_free();
@@ -505,7 +497,7 @@ static int pmqos_probe(void *data)
        }
 
        ret = pass_gdbus_connect_signal(g_gdbus_instance,
-                       DBUS_PMQOS_I_NUM_SIGNALS, g_gdbus_signal_infos);
+                       ARRAY_SIZE(g_gdbus_signal_infos), g_gdbus_signal_infos);
        if (ret < 0) {
                _E("cannot register callbacks as the dbus method invocation "
                                "handlers\n");
@@ -540,7 +532,7 @@ static int pmqos_probe(void *data)
 
 out_disconnect:
        pass_gdbus_disconnect_signal(g_gdbus_instance,
-                       DBUS_PMQOS_I_NUM_SIGNALS, g_gdbus_signal_infos);
+                       ARRAY_SIZE(g_gdbus_signal_infos), g_gdbus_signal_infos);
 out:
        pass_gdbus_put_instance_pmqos(&g_gdbus_instance);
 
index 274635f726d07887fef05210e0470e919f3356e5..8c80aefc6e88216ea674d7554ec2316412f52c2e 100644 (file)
 
 #define THERMAL_CONF_PATH              "/etc/pass/pass-thermal.conf"
 
-#define DBUS_THERMAL_I_START_HANDLER   "handle_start"
-#define DBUS_THERMAL_I_STOP_HANDLER    "handle_stop"
-#define DBUS_THERMAL_INTERFACE         "org.tizen.system.pass.monitor.thermal"
-#define DBUS_THERMAL_PATH              "/Org/Tizen/System/Pass/Monitor/Thermal"
-#define DBUS_THERMAL_METHOD            "thermal_scenario"
-
 static SystemPassMonitorThermal *g_gdbus_instance = NULL;
 static struct thermal_scenario *g_thermal = NULL;