insert broadcast signal to power off notification 94/15194/1
authorgiyeol.ok <giyeol.ok@samsung.com>
Tue, 18 Jun 2013 09:16:26 +0000 (18:16 +0900)
committerKrzysztof Sasiak <k.sasiak@samsung.com>
Thu, 16 Jan 2014 17:07:14 +0000 (18:07 +0100)
Change-Id: I0abbc007fb08bebd05c54b6c29bbf7fb2e2482b3
Signed-off-by: giyeol.ok <giyeol.ok@samsung.com>
src/core/edbus-handler.h
src/power/power-handler.c

index c02d123..533ce25 100644 (file)
 #define DEVICED_PATH_LOWMEM            OBJECT_PATH"/Lowmem"
 #define DEVICED_INTERFACE_LOWMEM       INTERFACE_NAME".lowmem"
 
+/*
+ * Poweroff service
+ *   get power off status
+ *   operations about Poweroff
+ */
+#define DEVICED_PATH_POWEROFF          OBJECT_PATH"/PowerOff"
+#define DEVICED_INTERFACE_POWEROFF     INTERFACE_NAME".PowerOff"
+
 int register_edbus_signal_handler(const char *path, const char *interface,
                const char *name, E_DBus_Signal_Cb cb);
 E_DBus_Interface *get_edbus_interface(const char *path);
index 6618eed..0d4f1b6 100755 (executable)
@@ -64,6 +64,8 @@
 #define POWEROFF_DURATION              2
 #define MAX_RETRY                      2
 
+#define SIGNAL_POWEROFF_STATE  "ChangeState"
+
 static struct timeval tv_start_poweroff;
 
 static Ecore_Timer *poweroff_timer_id = NULL;
@@ -101,11 +103,34 @@ static void poweroff_popup_edbus_signal_handler(void *data, DBusMessage *msg)
        vconf_set_int(VCONFKEY_SYSMAN_POWER_OFF_STATUS, val);
 }
 
+static void poweroff_send_broadcast(int status)
+{
+       static int old = 0;
+       char *arr[1];
+       char str_status[32];
+
+       if (old == status)
+               return;
+
+       _D("broadcast poweroff %d", status);
+
+       old = status;
+       snprintf(str_status, sizeof(str_status), "%d", status);
+       arr[0] = str_status;
+
+       broadcast_edbus_signal(DEVICED_PATH_POWEROFF, DEVICED_INTERFACE_POWEROFF,
+                       SIGNAL_POWEROFF_STATE, "i", arr);
+}
+
 static void poweroff_control_cb(keynode_t *in_key, struct ss_main_data *ad)
 {
        int val;
        if (vconf_get_int(VCONFKEY_SYSMAN_POWER_OFF_STATUS, &val) != 0)
                return;
+
+       if (val == VCONFKEY_SYSMAN_POWER_OFF_DIRECT || val == VCONFKEY_SYSMAN_POWER_OFF_RESTART)
+               poweroff_send_broadcast(val);
+
        switch (val) {
        case VCONFKEY_SYSMAN_POWER_OFF_DIRECT:
                action_entry_call_internal(PREDEF_POWEROFF, 0);