libgdbus: modify code style 70/212970/1 accepted/tizen/unified/20191113.123522 submit/tizen/20191113.004655
authorsanghyeok.oh <sanghyeok.oh@samsung.com>
Wed, 28 Aug 2019 06:11:04 +0000 (15:11 +0900)
committersanghyeok.oh <sanghyeok.oh@samsung.com>
Thu, 29 Aug 2019 03:21:38 +0000 (12:21 +0900)
Change-Id: Iea0fa1803e7d59bbdfdea54124cebd9d17c26858
Signed-off-by: sanghyeok.oh <sanghyeok.oh@samsung.com>
src/libgdbus/dbus-systemd.c
src/libgdbus/dbus-systemd.h

index d77f733..4fd961b 100644 (file)
@@ -25,9 +25,9 @@
 
 #include "shared/log.h"
 
-#define SYSTEMD_DBUS_SERVICE   "org.freedesktop.systemd1"
+#define SYSTEMD_DBUS_SERVICE           "org.freedesktop.systemd1"
 #define SYSTEMD_DBUS_PATH              "/org/freedesktop/systemd1"
-#define SYSTEMD_DBUS_UNIT_PATH "/org/freedesktop/systemd1/unit/"
+#define SYSTEMD_DBUS_UNIT_PATH         "/org/freedesktop/systemd1/unit/"
 
 #define SYSTEMD_DBUS_MANAGER_IFACE     "org.freedesktop.systemd1.Manager"
 #define SYSTEMD_DBUS_UNIT_IFACE                "org.freedesktop.systemd1.Unit"
 
 #define DBUS_IFACE_DBUS_PROPERTIES     "org.freedesktop.DBus.Properties"
 
-#define SUFFIX_SERVICE ".service"
-#define SUFFIX_SOCKET ".socket"
-#define SUFFIX_BUSNAME ".busname"
-#define SUFFIX_TARGET ".target"
-#define SUFFIX_DEVICE ".device"
-#define SUFFIX_MOUNT ".mount"
-#define SUFFIX_SWAP ".swap"
-#define SUFFIX_TIMER ".timer"
-#define SUFFIX_PATH ".path"
-#define SUFFIX_SLICE ".slice"
-#define SUFFIX_SCOPE ".scope"
+#define SUFFIX_SERVICE ".service"
+#define SUFFIX_SOCKET  ".socket"
+#define SUFFIX_BUSNAME ".busname"
+#define SUFFIX_TARGET  ".target"
+#define SUFFIX_DEVICE  ".device"
+#define SUFFIX_MOUNT   ".mount"
+#define SUFFIX_SWAP    ".swap"
+#define SUFFIX_TIMER   ".timer"
+#define SUFFIX_PATH    ".path"
+#define SUFFIX_SLICE   ".slice"
+#define SUFFIX_SCOPE   ".scope"
 
 #define UNIT_NAME_MAX 256
 
@@ -56,12 +56,12 @@ typedef struct {
 } unitinfo;
 
 static void _cb_JobRemoved(GDBusConnection *conn,
-       const char *sender,
-       const char *path,
-       const char *iface,
-       const char *name,
-       GVariant *param,
-       gpointer data)
+                       const char *sender,
+                       const char *path,
+                       const char *iface,
+                       const char *name,
+                       GVariant *param,
+                       gpointer data)
 {
        sig_ctx *ctx = data;
        gchar *job_id = NULL;
@@ -102,7 +102,9 @@ err:
        g_free(unit_name);
 }
 
-static int _systemd_control_unit_wait(const char *method, const char *name, int timeout_msec)
+static int _systemd_control_unit_wait(const char *method,
+                                       const char *name,
+                                       int timeout_msec)
 {
        GVariant *reply = NULL;
        gchar *objpath = NULL;
@@ -118,17 +120,23 @@ static int _systemd_control_unit_wait(const char *method, const char *name, int
        _I("Starting: %s %s", method, name);
 
        /* synchronous signal subscription */
-       ret = subscribe_dbus_signal_ctx(NULL, ctx, SYSTEMD_DBUS_SERVICE, SYSTEMD_DBUS_PATH, SYSTEMD_DBUS_IFACE_MANAGER, "JobRemoved", _cb_JobRemoved);
+       ret = subscribe_dbus_signal_ctx(NULL,
+                                       ctx,
+                                       SYSTEMD_DBUS_SERVICE,
+                                       SYSTEMD_DBUS_PATH,
+                                       SYSTEMD_DBUS_IFACE_MANAGER,
+                                       "JobRemoved",
+                                       _cb_JobRemoved);
        if (ret == 0) {
                ret = -1;
                goto finish;
        }
 
        reply = dbus_handle_method_sync_with_reply_var(SYSTEMD_DBUS_DEST,
-               SYSTEMD_DBUS_PATH,
-               SYSTEMD_DBUS_MANAGER_IFACE,
-               method,
-               g_variant_new("(ss)", name, "replace"));
+                                                       SYSTEMD_DBUS_PATH,
+                                                       SYSTEMD_DBUS_MANAGER_IFACE,
+                                                       method,
+                                                       g_variant_new("(ss)", name, "replace"));
        if (!reply || !dh_get_param_from_var(reply, "(o)", &objpath)) {
                _E("fail (%s): no message", method);
                ret = -EBADMSG;
@@ -175,10 +183,10 @@ static int _systemd_control_unit_async(const char *method, const char *name)
        _I("Starting: %s %s", method, name);
 
        reply = dbus_handle_method_sync_with_reply_var(SYSTEMD_DBUS_DEST,
-               SYSTEMD_DBUS_PATH,
-               SYSTEMD_DBUS_MANAGER_IFACE,
-               method,
-               g_variant_new("(ss)", name, "replace"));
+                                                       SYSTEMD_DBUS_PATH,
+                                                       SYSTEMD_DBUS_MANAGER_IFACE,
+                                                       method,
+                                                       g_variant_new("(ss)", name, "replace"));
 
        if (!reply || !dh_get_param_from_var(reply, "(o)", &objpath)) {
                _E("fail (%s): no message", method);
@@ -195,7 +203,9 @@ finish:
        return ret;
 }
 
-static int _change_suffix(const char *name, const char *suffix, char **new_name)
+static int _change_suffix(const char *name,
+                       const char *suffix,
+                       char **new_name)
 {
        char *buf = NULL;
        char *ext = NULL;
@@ -275,11 +285,14 @@ Start or Stop systemd unit.
 @param suffix: (nullable): change extension of unit name, or %NULL
 @param timeout_msec: the timeout in milliseconds, -1 to use the default
 @param method: method name, "StartUnit" or "StopUnit"
-@param sync: %TRUE
+@param wait: %TRUE
 Returns: the exit status
 */
-static int _systemd_control_unit(const char *name, const char *suffix,
-               int timeout_msec, const char *method, int wait)
+static int _systemd_control_unit(const char *name,
+                               const char *suffix,
+                               int timeout_msec,
+                               const char *method,
+                               int wait)
 {
        char *new_name = NULL;
        int ret = 0;
@@ -395,10 +408,10 @@ GVariant *systemd_get_manager_property(const char *property)
                return NULL;
 
        reply = dbus_handle_method_sync_with_reply_var(SYSTEMD_DBUS_DEST,
-                                       SYSTEMD_DBUS_PATH,
-                                       DBUS_IFACE_DBUS_PROPERTIES,
-                                       "Get",
-                                       g_variant_new("(ss)", SYSTEMD_DBUS_MANAGER_IFACE, property));
+                                                       SYSTEMD_DBUS_PATH,
+                                                       DBUS_IFACE_DBUS_PROPERTIES,
+                                                       "Get",
+                                                       g_variant_new("(ss)", SYSTEMD_DBUS_MANAGER_IFACE, property));
        if (!reply || !dh_get_param_from_var(reply, "(v)", &val))
                _E("Failed to get variant");
        if (reply)
@@ -407,8 +420,7 @@ GVariant *systemd_get_manager_property(const char *property)
        return val;
 }
 
-GVariant *systemd_get_unit_property(const char *unit,
-                                     const char *property)
+GVariant *systemd_get_unit_property(const char *unit, const char *property)
 {
        char *escaped;
        GVariant *reply = NULL;
@@ -420,10 +432,10 @@ GVariant *systemd_get_unit_property(const char *unit,
        escaped = systemd_get_unit_dbus_path(unit);
 
        reply = dbus_handle_method_sync_with_reply_var(SYSTEMD_DBUS_DEST,
-                                       escaped,
-                                       DBUS_IFACE_DBUS_PROPERTIES,
-                                       "Get",
-                                       g_variant_new("(ss)", SYSTEMD_DBUS_UNIT_IFACE, property));
+                                                       escaped,
+                                                       DBUS_IFACE_DBUS_PROPERTIES,
+                                                       "Get",
+                                                       g_variant_new("(ss)", SYSTEMD_DBUS_UNIT_IFACE, property));
 
        if (!reply || !dh_get_param_from_var(reply, "(v)", &val))
                _E("Failed to get variant");
@@ -434,8 +446,7 @@ GVariant *systemd_get_unit_property(const char *unit,
        return val;
 }
 
-GVariant *systemd_get_service_property(const char *unit,
-                                        const char *property)
+GVariant *systemd_get_service_property(const char *unit, const char *property)
 {
        char *escaped;
        GVariant *reply = NULL;
@@ -447,10 +458,10 @@ GVariant *systemd_get_service_property(const char *unit,
        escaped = systemd_get_unit_dbus_path(unit);
 
        reply = dbus_handle_method_sync_with_reply_var(SYSTEMD_DBUS_DEST,
-                                       escaped,
-                                       DBUS_IFACE_DBUS_PROPERTIES,
-                                       "Get",
-                                       g_variant_new("(ss)", SYSTEMD_DBUS_SERVICE_IFACE, property));
+                                                       escaped,
+                                                       DBUS_IFACE_DBUS_PROPERTIES,
+                                                       "Get",
+                                                       g_variant_new("(ss)", SYSTEMD_DBUS_SERVICE_IFACE, property));
        if (!reply || !dh_get_param_from_var(reply, "(v)", &val))
                _E("Failed to get variant");
        if (reply)
index b10e4af..4d15200 100644 (file)
 extern "C" {
 #endif
 
-int systemd_start_unit_wait_started(const char *name, const char *suffix, int timeout_msec);
-int systemd_stop_unit_wait_stopped(const char *name, const char *suffix, int timeout_msec);
+int systemd_start_unit_wait_started    (const char *name,
+                                       const char *suffix,
+                                       int timeout_msec);
 
-int systemd_start_unit_async(const char *name, const char *suffix);
-int systemd_stop_unit_async(const char *name, const char *suffix);
+int systemd_stop_unit_wait_stopped     (const char *name,
+                                       const char *suffix,
+                                       int timeout_msec);
+
+int systemd_start_unit_async           (const char *name,
+                                       const char *suffix);
+
+int systemd_stop_unit_async            (const char *name,
+                                       const char *suffix);
+
+GVariant *systemd_get_manager_property (const char *property);
+
+
+GVariant *systemd_get_unit_property    (const char *unit,
+                                       const char *property);
+
+GVariant *systemd_get_service_property (const char *unit,
+                                       const char *property);
 
-GVariant *systemd_get_manager_property(const char *property);
-GVariant *systemd_get_unit_property(const char *unit,
-                                     const char *property);
-GVariant *systemd_get_service_property(const char *unit,
-                                        const char *property);
 
 #ifdef __cplusplus
 }