led: Add new APIs that control multiple LEDs 98/169098/12
authorsanghyeok.oh <sanghyeok.oh@samsung.com>
Fri, 2 Feb 2018 07:20:58 +0000 (16:20 +0900)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Tue, 6 Feb 2018 01:24:45 +0000 (10:24 +0900)
Change-Id: I48de38bcedb527148cf1f63a34adb54143b43a9c
Signed-off-by: sanghyeok.oh <sanghyeok.oh@samsung.com>
Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
Signed-off-by: Hyotaek Shim <hyotaek.shim@samsung.com>
src/led/rgb.c [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 3e5747f..8d9096d
@@ -169,9 +169,9 @@ static void add_timer_to_check_invalid_req(void)
                _E("Failed to add timer");
 }
 
-static GVariant *edbus_playcustom(GDBusConnection *conn,
-                                                                       const gchar *sender, const gchar *path, const gchar *iface, const gchar *name,
-                                                                       GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data)
+static GVariant *dbus_playcustom(GDBusConnection *conn,
+               const gchar *sender, const gchar *path, const gchar *iface, const gchar *name,
+               GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data)
 {
        int ret;
        int on, off;
@@ -206,9 +206,9 @@ out:
        return g_variant_new("(i)", ret);
 }
 
-static GVariant *edbus_stopcustom(GDBusConnection *conn,
-                                                                       const gchar *sender, const gchar *path, const gchar *iface, const gchar *name,
-                                                                       GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data)
+static GVariant *dbus_stopcustom(GDBusConnection *conn,
+               const gchar *sender, const gchar *path, const gchar *iface, const gchar *name,
+               GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data)
 {
        int ret;
        pid_t pid;
@@ -235,9 +235,77 @@ out:
        return g_variant_new("(i)", ret);
 }
 
+static GVariant *dbus_multi_playcustom(GDBusConnection *conn,
+               const gchar *sender, const gchar *path, const gchar *iface, const gchar *name,
+               GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data)
+{
+       int ret = 0;
+       int *led;
+       unsigned int *color;
+       int num_of_leds;
+       struct led_state state;
+       pid_t pid;
+       GVariantIter *iter;
+       int i;
+
+       g_variant_get(param, "(a(bu))", &iter);
+       num_of_leds = g_variant_iter_n_children(iter);
+
+       led = (int*)malloc(sizeof(int) * num_of_leds);
+       color = (unsigned int*)malloc(sizeof(unsigned int) * num_of_leds);
+
+       i = 0;
+       while (g_variant_iter_loop(iter, "(bu)", &led[i], &color[i]))
+               ++i;
+
+       g_variant_iter_free(iter);
+
+       pid = dbus_connection_get_sender_pid(conn, sender);
+
+       /* To be implemented */
+out:
+       free(led);
+       free(color);
+
+       return g_variant_new("(i)", ret);
+}
+
+static GVariant *dbus_multi_stopcustom(GDBusConnection *conn,
+               const gchar *sender, const gchar *path, const gchar *iface, const gchar *name,
+               GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data)
+{
+       pid_t pid;
+       int *led;
+       int ret = 0;
+       int i;
+       int num_of_leds;
+       GVariantIter *iter;
+
+       g_variant_get(param, "(ab)", &iter);
+       num_of_leds = g_variant_iter_n_children(iter);
+
+       led = (int*)malloc(sizeof(int) * num_of_leds);
+       i = 0;
+
+       while (g_variant_iter_loop(iter, "b", &led[i++]))
+               ;
+       g_variant_iter_free(iter);
+
+       pid = dbus_connection_get_sender_pid(conn, sender);
+
+       _I("pid %d led stop custom", pid);
+
+       /* To be implemented */
+out:
+       free(led);
+       return g_variant_new("(i)", ret);
+}
+
 static const dbus_method_s dbus_methods[] = {
-       { "playcustom",     "iiuu",  "i",  edbus_playcustom },
-       { "stopcustom",     NULL,    "i",  edbus_stopcustom },
+       { "playcustom",        "iiuu",  "i",  dbus_playcustom },
+       { "stopcustom",        NULL,    "i",  dbus_stopcustom },
+       { "multi_playcustom",  "a(bu)", "i",  dbus_multi_playcustom },
+       { "multi_stopcustom",  "ab",    "i",  dbus_multi_stopcustom },
        /* Add methods here */
 };