From a9dea6ffa6b569708667f2fed302e073c12d0439 Mon Sep 17 00:00:00 2001 From: "sanghyeok.oh" Date: Wed, 27 Feb 2019 11:40:19 +0900 Subject: [PATCH] power: apply modified dbus spec Change-Id: I8dc2d9a78f757d2c187dea2e0747075d4ae90cca Signed-off-by: sanghyeok.oh --- src/battery/battery-mobile.c | 26 ++++++-------------------- src/battery/battery-wearable.c | 24 ++++++------------------ src/common/popup-common.h | 15 +++++++++++++++ src/cooldown/cooldown-wearable.c | 24 ++++++------------------ src/overheat/overheat.c | 22 ++++++---------------- src/powerkey/powerkey-mobile.c | 35 +++++++++++------------------------ src/powerkey/powerkey-tv.c | 20 +++++--------------- src/powerkey/powerkey-wearable.c | 19 +++++-------------- 8 files changed, 60 insertions(+), 125 deletions(-) diff --git a/src/battery/battery-mobile.c b/src/battery/battery-mobile.c index 646df45..625bebc 100644 --- a/src/battery/battery-mobile.c +++ b/src/battery/battery-mobile.c @@ -18,17 +18,6 @@ */ #include "popup-common.h" -#define DEVICED_PATH_SYSNOTI "/Org/Tizen/System/DeviceD/SysNoti" -#define DEVICED_INTERFACE_SYSNOTI "org.tizen.system.deviced.SysNoti" -#define SIGNAL_CHARGEERR_RESPONSE "ChargeErrResponse" - -#define SYSTEMD_STOP_POWER_OFF 4 -#define DEVICED_BUS_NAME "org.tizen.system.deviced" -#define REBOOT_OBJECT_PATH "/Org/Tizen/System/DeviceD/Reboot" -#define REBOOT_INTERFACE_NAME DEVICED_BUS_NAME".reboot" -#define REBOOT_METHOD "reboot" -#define REBOOT_OPERATION_OFF "poweroff" - static const struct popup_ops lowbattery_poweroff_ops; static const struct popup_ops charge_error_low_ops; static const struct popup_ops charge_error_high_ops; @@ -144,8 +133,7 @@ static void lowbattery_terminate(const struct popup_ops *ops) static void poweroff_clicked(const struct popup_ops *ops) { static int bPowerOff = 0; - char *param[2]; - char data[8]; + char *param[1]; int ret; if (bPowerOff == 1) @@ -154,14 +142,12 @@ static void poweroff_clicked(const struct popup_ops *ops) unload_simple_popup(ops); - param[0] = REBOOT_OPERATION_OFF; - snprintf(data, sizeof(data), "0"); - param[1] = data; + param[0] = POWEROFF_OPERATION_OFF; ret = popup_dbus_method_sync(DEVICED_BUS_NAME, - REBOOT_OBJECT_PATH, - REBOOT_INTERFACE_NAME, - REBOOT_METHOD, - "si", param); + POWEROFF_OBJECT_PATH, + POWEROFF_INTERFACE_NAME, + POWEROFF_METHOD, + "s", param); if (ret < 0) _E("Failed to request poweroff to deviced: %d", ret); diff --git a/src/battery/battery-wearable.c b/src/battery/battery-wearable.c index 75df768..fc0f209 100644 --- a/src/battery/battery-wearable.c +++ b/src/battery/battery-wearable.c @@ -19,8 +19,6 @@ #include "popup-common.h" -#define DEVICED_PATH_SYSNOTI "/Org/Tizen/System/DeviceD/SysNoti" -#define DEVICED_INTERFACE_SYSNOTI "org.tizen.system.deviced.SysNoti" #define SIGNAL_CHARGEERR_RESPONSE "ChargeErrResponse" static const struct popup_ops lowbattery_poweroff_ops; @@ -28,13 +26,6 @@ static const struct popup_ops charge_error_low_ops; static const struct popup_ops charge_error_high_ops; static const struct popup_ops battery_disconnected_ops; -#define DEVICED_BUS_NAME "org.tizen.system.deviced" -#define REBOOT_OBJECT_PATH "/Org/Tizen/System/DeviceD/Reboot" -#define REBOOT_INTERFACE_NAME DEVICED_BUS_NAME".reboot" - -#define REBOOT_METHOD "reboot" -#define REBOOT_OPERATION_OFF "poweroff" - static int lowbattery_launch(bundle *b, const struct popup_ops *ops); static int remove_other_lowbattery_popups(const struct popup_ops *ops) @@ -141,8 +132,7 @@ static void lowbattery_terminate(const struct popup_ops *ops) static void poweroff_clicked(const struct popup_ops *ops) { static int bPowerOff = 0; - char *param[2]; - char data[8]; + char *param[1]; int ret; if (bPowerOff == 1) @@ -151,14 +141,12 @@ static void poweroff_clicked(const struct popup_ops *ops) unload_simple_popup(ops); - param[0] = REBOOT_OPERATION_OFF; - snprintf(data, sizeof(data), "0"); - param[1] = data; + param[0] = POWEROFF_OPERATION_OFF; ret = popup_dbus_method_sync(DEVICED_BUS_NAME, - REBOOT_OBJECT_PATH, - REBOOT_INTERFACE_NAME, - REBOOT_METHOD, - "si", param); + POWEROFF_OBJECT_PATH, + POWEROFF_INTERFACE_NAME, + POWEROFF_METHOD, + "s", param); if (ret < 0) _E("Failed to request poweroff to deviced: %d", ret); } diff --git a/src/common/popup-common.h b/src/common/popup-common.h index bd93621..2dbca2f 100644 --- a/src/common/popup-common.h +++ b/src/common/popup-common.h @@ -121,4 +121,19 @@ void notify_feedback(long pattern); /* using thread */ void change_display_state(void); /* using thread */ void event_back_key_up(void *data, Evas_Object *obj, void *event_info); + +/* deviced */ +#define DEVICED_PATH_SYSNOTI "/Org/Tizen/System/DeviceD/SysNoti" +#define DEVICED_INTERFACE_SYSNOTI "org.tizen.system.deviced.SysNoti" +#define SIGNAL_CHARGEERR_RESPONSE "ChargeErrResponse" + +#define SYSTEMD_STOP_POWER_OFF 4 +#define DEVICED_BUS_NAME "org.tizen.system.deviced" +#define POWEROFF_OBJECT_PATH "/Org/Tizen/System/DeviceD/PowerOff" +#define POWEROFF_INTERFACE_NAME DEVICED_BUS_NAME".PowerOff" +#define POWEROFF_METHOD "Poweroff" + +#define POWEROFF_OPERATION_OFF "poweroff" +#define POWEROFF_OPERATION_RESTART "reboot" + #endif /* __POPUP_COMMON_H__ */ diff --git a/src/cooldown/cooldown-wearable.c b/src/cooldown/cooldown-wearable.c index 82815f6..d4692d6 100644 --- a/src/cooldown/cooldown-wearable.c +++ b/src/cooldown/cooldown-wearable.c @@ -21,19 +21,10 @@ #define SYSTEMD_STOP_POWER_OFF 4 -#define DEVICED_PATH_SYSNOTI "/Org/Tizen/System/DeviceD/SysNoti" -#define DEVICED_INTERFACE_SYSNOTI "org.tizen.system.deviced.SysNoti" #define SIGNAL_COOL_DOWN_RESPONSE "CoolDownResponse" #define SIGNAL_COOL_DOWN_CHANGED "CoolDownChanged" #define COOL_DOWN_RELEASE "Release" -#define DEVICED_BUS_NAME "org.tizen.system.deviced" -#define REBOOT_OBJECT_PATH "/Org/Tizen/System/DeviceD/Reboot" -#define REBOOT_INTERFACE_NAME DEVICED_BUS_NAME".reboot" - -#define REBOOT_METHOD "reboot" -#define REBOOT_OPERATION_OFF "poweroff" - #define TIMEOUT_POWEROFF 10 /* seconds */ #define TIMEOUT_BEEP_40 40 /* seconds */ #define TIMEOUT_BEEP_5 5 /* seconds */ @@ -194,22 +185,19 @@ static void cooldown_send_warning_signal(const struct popup_ops *ops) static void cooldown_poweroff(const struct popup_ops *ops) { - char *param[2]; - char data[8]; + char *param[1]; int ret; _I("Poweroff is selected."); unload_simple_popup(ops); - param[0] = REBOOT_OPERATION_OFF; - snprintf(data, sizeof(data), "0"); - param[1] = data; + param[0] = POWEROFF_OPERATION_OFF; ret = popup_dbus_method_sync(DEVICED_BUS_NAME, - REBOOT_OBJECT_PATH, - REBOOT_INTERFACE_NAME, - REBOOT_METHOD, - "si", param); + POWEROFF_OBJECT_PATH, + POWEROFF_INTERFACE_NAME, + POWEROFF_METHOD, + "s", param); if (ret < 0) _E("Failed to request poweroff to deviced: %d", ret); diff --git a/src/overheat/overheat.c b/src/overheat/overheat.c index b712c96..bbb1c69 100644 --- a/src/overheat/overheat.c +++ b/src/overheat/overheat.c @@ -22,13 +22,6 @@ #define BUF_MAX 512 #define SYSTEMD_STOP_POWER_OFF 4 -#define DEVICED_BUS_NAME "org.tizen.system.deviced" -#define REBOOT_OBJECT_PATH "/Org/Tizen/System/DeviceD/Reboot" -#define REBOOT_INTERFACE_NAME DEVICED_BUS_NAME".reboot" - -#define REBOOT_METHOD "reboot" -#define REBOOT_OPERATION_OFF "poweroff" - /* Overheat Timer*/ #define OVERHEAT_BUS_NAME "org.tizen.system.popup" #define OVERHEAT_OBJECT_PATH "/Org/Tizen/System/Popup" @@ -133,8 +126,7 @@ static void register_handlers(const struct popup_ops *ops) static void overheat_poweroff(const struct popup_ops *ops) { static int bPowerOff = 0; - char *param[2]; - char data[8]; + char *param[1]; int ret; if (bPowerOff == 1) @@ -143,14 +135,12 @@ static void overheat_poweroff(const struct popup_ops *ops) unload_simple_popup(ops); - param[0] = REBOOT_OPERATION_OFF; - snprintf(data, sizeof(data), "0"); - param[1] = data; + param[0] = POWEROFF_OPERATION_OFF; ret = popup_dbus_method_sync(DEVICED_BUS_NAME, - REBOOT_OBJECT_PATH, - REBOOT_INTERFACE_NAME, - REBOOT_METHOD, - "si", param); + POWEROFF_OBJECT_PATH, + POWEROFF_INTERFACE_NAME, + POWEROFF_METHOD, + "s", param); if (ret < 0) _E("Failed to request poweroff to deviced: %d", ret); } diff --git a/src/powerkey/powerkey-mobile.c b/src/powerkey/powerkey-mobile.c index 455000a..44e4132 100644 --- a/src/powerkey/powerkey-mobile.c +++ b/src/powerkey/powerkey-mobile.c @@ -21,13 +21,6 @@ #define SYSTEMD_STOP_POWER_OFF 4 -#define DEVICED_BUS_NAME "org.tizen.system.deviced" -#define REBOOT_OBJECT_PATH "/Org/Tizen/System/DeviceD/Reboot" -#define REBOOT_INTERFACE_NAME DEVICED_BUS_NAME".reboot" - -#define REBOOT_METHOD "reboot" -#define REBOOT_OPERATION_OFF "poweroff" -#define REBOOT_OPERATION_RESTART "reboot" #define TIMEOUT_POWEROFF 5 /* seconds */ #define POWEROFF_KEY "XF86PowerOff" @@ -74,8 +67,7 @@ static void restart_terminate(const struct popup_ops *ops) static void restart_clicked(const struct popup_ops *ops) { static int bReset = 0; - char *param[2]; - char data[8]; + char *param[1]; int ret; if (bReset == 1) return; @@ -83,15 +75,13 @@ static void restart_clicked(const struct popup_ops *ops) unload_simple_popup(ops); - param[0] = REBOOT_OPERATION_RESTART; - snprintf(data, sizeof(data), "0"); - param[1] = data; + param[0] = POWEROFF_OPERATION_RESTART; ret = popup_dbus_method_sync(DEVICED_BUS_NAME, - REBOOT_OBJECT_PATH, - REBOOT_INTERFACE_NAME, - REBOOT_METHOD, - "si", param); + POWEROFF_OBJECT_PATH, + POWEROFF_INTERFACE_NAME, + POWEROFF_METHOD, + "s", param); if (ret < 0) _E("Failed to request restart to deviced: %d", ret); } @@ -316,7 +306,6 @@ static void poweroff_clicked(const struct popup_ops *ops) { static int bPowerOff = 0; char *param[2]; - char data[8]; int ret; if (bPowerOff == 1) return; @@ -324,14 +313,12 @@ static void poweroff_clicked(const struct popup_ops *ops) unload_simple_popup(ops); - param[0] = REBOOT_OPERATION_OFF; - snprintf(data, sizeof(data), "0"); - param[1] = data; + param[0] = POWEROFF_OPERATION_OFF; ret = popup_dbus_method_sync(DEVICED_BUS_NAME, - REBOOT_OBJECT_PATH, - REBOOT_INTERFACE_NAME, - REBOOT_METHOD, - "si", param); + POWEROFF_OBJECT_PATH, + POWEROFF_INTERFACE_NAME, + POWEROFF_METHOD, + "s", param); if (ret < 0) _E("Failed to request poweroff to deviced: %d", ret); } diff --git a/src/powerkey/powerkey-tv.c b/src/powerkey/powerkey-tv.c index 6e31c29..047dee2 100644 --- a/src/powerkey/powerkey-tv.c +++ b/src/powerkey/powerkey-tv.c @@ -21,13 +21,6 @@ #define SYSTEMD_STOP_POWER_OFF 4 -#define DEVICED_BUS_NAME "org.tizen.system.deviced" -#define REBOOT_OBJECT_PATH "/Org/Tizen/System/DeviceD/Reboot" -#define REBOOT_INTERFACE_NAME DEVICED_BUS_NAME".reboot" - -#define REBOOT_METHOD "reboot" -#define REBOOT_OPERATION_OFF "poweroff" -#define REBOOT_OPERATION_RESTART "reboot" #define TIMEOUT_POWEROFF 5 /* seconds */ #define POWEROFF_KEY "XF86PowerOff" @@ -106,7 +99,6 @@ static void poweroff_clicked(const struct popup_ops *ops) { static int bPowerOff = 0; char *param[2]; - char data[8]; int ret; if (bPowerOff == 1) return; @@ -114,14 +106,12 @@ static void poweroff_clicked(const struct popup_ops *ops) unload_simple_popup(ops); - param[0] = REBOOT_OPERATION_OFF; - snprintf(data, sizeof(data), "0"); - param[1] = data; + param[0] = POWEROFF_OPERATION_OFF; ret = popup_dbus_method_sync(DEVICED_BUS_NAME, - REBOOT_OBJECT_PATH, - REBOOT_INTERFACE_NAME, - REBOOT_METHOD, - "si", param); + POWEROFF_OBJECT_PATH, + POWEROFF_INTERFACE_NAME, + POWEROFF_METHOD, + "s", param); if (ret < 0) _E("Failed to request poweroff to deviced: %d", ret); } diff --git a/src/powerkey/powerkey-wearable.c b/src/powerkey/powerkey-wearable.c index 13013b9..663c5f3 100644 --- a/src/powerkey/powerkey-wearable.c +++ b/src/powerkey/powerkey-wearable.c @@ -23,12 +23,6 @@ #define SYSTEMD_STOP_POWER_OFF 4 -#define DEVICED_BUS_NAME "org.tizen.system.deviced" -#define REBOOT_OBJECT_PATH "/Org/Tizen/System/DeviceD/Reboot" -#define REBOOT_INTERFACE_NAME DEVICED_BUS_NAME".reboot" - -#define REBOOT_METHOD "reboot" -#define REBOOT_OPERATION_OFF "poweroff" #define TIMEOUT_POWEROFF 5 /* seconds */ #define TELEPHONY_PATH "tizen.org/feature/network.telephony" @@ -242,7 +236,6 @@ static void poweroff_clicked(const struct popup_ops *ops) { static int bPowerOff = 0; char *param[2]; - char data[8]; int ret; if (bPowerOff == 1) return; @@ -251,14 +244,12 @@ static void poweroff_clicked(const struct popup_ops *ops) unload_simple_popup(ops); terminate_if_no_popup(); - param[0] = REBOOT_OPERATION_OFF; - snprintf(data, sizeof(data), "0"); - param[1] = data; + param[0] = POWEROFF_OPERATION_OFF; ret = popup_dbus_method_sync(DEVICED_BUS_NAME, - REBOOT_OBJECT_PATH, - REBOOT_INTERFACE_NAME, - REBOOT_METHOD, - "si", param); + POWEROFF_OBJECT_PATH, + POWEROFF_INTERFACE_NAME, + POWEROFF_METHOD, + "s", param); if (ret < 0) _E("Failed to request poweroff to deviced: %d", ret); } -- 2.7.4