From 1a2c3b5a5c1f7a698584fa095e258c6af760b4dd Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Mon, 26 Dec 2016 11:36:40 +0900 Subject: [PATCH] cooldown popup : fix bug in timer and power off process Change-Id: Ide10ff78b9b7f3f80d0384bc2c5b22907d70ab9c Signed-off-by: lokilee73 --- src/cooldown/cooldown-wearable.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/src/cooldown/cooldown-wearable.c b/src/cooldown/cooldown-wearable.c index 02236e0..24ee6e0 100755 --- a/src/cooldown/cooldown-wearable.c +++ b/src/cooldown/cooldown-wearable.c @@ -27,6 +27,13 @@ #define SIGNAL_COOL_DOWN_CHANGED "CoolDownChanged" #define COOL_DOWN_RELEASE "Release" +#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" + #define TIMEOUT_POWEROFF 10 /* seconds */ #define TIMEOUT_BEEP_40 40 /* seconds */ #define TIMEOUT_BEEP_5 5 /* seconds */ @@ -75,6 +82,7 @@ static void remove_dbus_signal_handler(void) if (!release_handler) return; + conn = get_dbus_connection(); if (!conn) { release_handler = NULL; @@ -171,13 +179,22 @@ static void cooldown_send_warning_signal(const struct popup_ops *ops) static void cooldown_poweroff(const struct popup_ops *ops) { - _I("Poweroff is selected"); + char *param[2]; + char data[8]; + int ret; - unload_simple_popup(ops); + param[0] = POWER_OPERATION_OFF; + snprintf(data, sizeof(data), "0"); + param[1] = data; - if (vconf_set_int(VCONFKEY_SYSMAN_POWER_OFF_STATUS, - SYSTEMD_STOP_POWER_OFF) != 0) - _E("Failed to request poweroff to deviced"); + 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); terminate_if_no_popup(); } @@ -222,10 +239,10 @@ static int cooldown_warning_timer(bundle *b, const struct popup_ops *ops) int ret; remove_other_popups(ops); - if (timer) ecore_timer_del(timer); timer = ecore_timer_add(TIMEOUT_BEEP_40, beep_time_expired, ops); + if (!timer) _E("Failed to add timer"); @@ -241,7 +258,6 @@ static Eina_Bool poweroff_time_expired(void *data) const struct popup_ops *ops = data; cooldown_poweroff(ops); - return ECORE_CALLBACK_CANCEL; } @@ -251,6 +267,7 @@ static int cooldown_poweroff_timer(bundle *b, const struct popup_ops *ops) if (timer) ecore_timer_del(timer); + timer = ecore_timer_add(TIMEOUT_POWEROFF, poweroff_time_expired, ops); if (!timer) _E("Failed to add timer"); @@ -277,7 +294,7 @@ static const struct popup_ops cooldown_poweroff_ops = { .get_content = cooldown_poweroff_content, .left_text = "IDS_COM_SK_OK", .left = cooldown_poweroff, - .show = cooldown_poweroff_timer, + .pre = cooldown_poweroff_timer, .terminate = cooldown_poweroff, }; @@ -296,7 +313,7 @@ static const struct popup_ops cooldown_warning_ops = { .get_content = cooldown_warning_content, .left_text = "IDS_COM_SK_OK", .left = cooldown_warning, - .show = cooldown_warning_timer, + .pre = cooldown_warning_timer, .terminate = cooldown_warning, }; -- 2.7.4