poweroff: use dbus method call to turn off device 44/63844/1 accepted/tizen/common/20160406.144502 accepted/tizen/common/20160411.125459 accepted/tizen/mobile/20160411.005711 accepted/tizen/tv/20160411.005537 accepted/tizen/wearable/20160411.005613 submit/tizen/20160406.042324 submit/tizen/20160411.001916
authorTaeyoung Kim <ty317.kim@samsung.com>
Mon, 28 Mar 2016 05:42:28 +0000 (14:42 +0900)
committerTaeyoung Kim <ty317.kim@samsung.com>
Mon, 28 Mar 2016 05:42:28 +0000 (14:42 +0900)
- Previously, vconf key is used to power off. deviced notified
  the vconf key and turned off the device.
- Now, dbus method call is used to turn off device.

Change-Id: I04e8e0c35bcaad134887b0f68f31f2cfa2e8feae
Signed-off-by: Taeyoung Kim <ty317.kim@samsung.com>
src/poweroff/org.tizen.poweroff-syspopup.xml
src/poweroff/poweroff.c

index 2b2eb0920ff257734fdd53568c006d9b6871f4bc..a10e18839413a7587950c467f17bcdfab5f5079c 100755 (executable)
@@ -6,4 +6,7 @@
        <ui-application appid="org.tizen.poweroff-syspopup" exec="/usr/apps/org.tizen.poweroff-syspopup/bin/poweroff-popup" nodisplay="true" multiple="false" type="capp" taskmanage="false">
                <label>Power off system popup</label>
        </ui-application>
+       <privileges>
+               <privilege>http://tizen.org/privilege/power</privilege>
+       </privileges>
 </manifest>
index 6f821c2ca40a081da6b5f20b6bd8b4783a5734b4..7f73c7e35acad4c8e153872280f07f3da30645d3 100755 (executable)
 
 #define SYSTEMD_STOP_POWER_OFF 4
 
+#define POWER_BUS_NAME        "org.tizen.system.deviced"
+#define POWER_OBJECT_PATH     "/Org/Tizen/System/DeviceD/Power"
+#define POWER_INTERFACE_NAME  POWER_BUS_NAME".power"
+
+#define POWER_METHOD            "reboot"
+#define POWER_OPERATION_OFF     "poweroff"
+
 static void remove_popup(const struct popup_ops *ops)
 {
        static bool terminating = false;
@@ -95,6 +102,9 @@ static void poweroff_clicked(const struct popup_ops *ops)
        Evas_Object *rect, *win;
        Evas_Coord w, h, size;
        static int bPowerOff = 0;
+       char *param[2];
+       char data[8];
+       int ret;
 
        if (bPowerOff == 1)
                return;
@@ -115,6 +125,17 @@ static void poweroff_clicked(const struct popup_ops *ops)
 
        if (vconf_set_int(VCONFKEY_SYSMAN_POWER_OFF_STATUS, SYSTEMD_STOP_POWER_OFF) != 0)
                _E("Failed to request poweroff to deviced");
+
+       param[0] = POWER_OPERATION_OFF;
+       snprintf(data, sizeof(data), "0");
+       param[1] = data;
+       ret = popup_dbus_method_sync(POWER_BUS_NAME,
+                       POWER_OBJECT_PATH,
+                       POWER_INTERFACE_NAME,
+                       POWER_METHOD,
+                       "si", param);
+       if (ret < 0)
+               _E("Failed to request poweroff to deviced (%d)", ret);
 }
 
 static const struct popup_ops poweroff_ops = {