Added Restart option to long pressed power key 15/68915/4 submit/tizen/20160512.081115
authorchangjoo.lee <changjoo.lee@samsung.com>
Tue, 10 May 2016 10:17:43 +0000 (19:17 +0900)
committerchangjoo.lee <changjoo.lee@samsung.com>
Wed, 11 May 2016 05:15:16 +0000 (14:15 +0900)
Change-Id: Ic391a4bffe25202c747d7041e409a75c7ccb14a5
Signed-off-by: changjoo.lee <changjoo.lee@samsung.com>
15 files changed:
CMakeLists.txt
packaging/org.tizen.powerkey-syspopup.manifest [new file with mode: 0755]
packaging/system-servant.spec
src/battery/battery-mobile.c
src/common/macro.h
src/launcher/launcher.c
src/launcher/launcher.h
src/launcher/popup.c
src/po/en.po
src/po/en_PH.po
src/po/en_US.po
src/powerkey/CMakeLists.txt [new file with mode: 0755]
src/powerkey/org.tizen.powerkey-syspopup.xml [new file with mode: 0755]
src/powerkey/powerkey.c [new file with mode: 0755]
src/usb/usb-device.c

index c0ce5f90c251019e7007174d3e23d81bac29f948..615bcc921b095b2c35873a30945dc5187eff3194 100644 (file)
@@ -56,8 +56,8 @@ SET(COMMON_SRCS ${COMMON_SRCS}
 ENDIF()
 
 ADD_SUBDIRECTORY(src)
+ADD_SUBDIRECTORY(src/powerkey)
 ADD_SUBDIRECTORY(src/crash)
 ADD_SUBDIRECTORY(src/launcher)
 ADD_SUBDIRECTORY(src/po)
-ADD_SUBDIRECTORY(src/poweroff)
 ADD_SUBDIRECTORY(signal-sender)
\ No newline at end of file
diff --git a/packaging/org.tizen.powerkey-syspopup.manifest b/packaging/org.tizen.powerkey-syspopup.manifest
new file mode 100755 (executable)
index 0000000..75b0fa5
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+    <request>
+        <domain name="_"/>
+    </request>
+</manifest>
index 5c51b04e65d990f5d8f06b57cc96a86f81fdcdec..04c2b1e860789f861ce8b30c94f65cbabd361c79 100755 (executable)
@@ -6,7 +6,7 @@
 %define FORMFACTOR none
 
 #Main applications
-%define poweroff_popup off
+%define powerkey_popup off
 %define crash_popup off
 %define system_popup off
 %define notification_service off
@@ -22,7 +22,7 @@
 %if "%{?profile}" == "mobile"
 %define PROFILE mobile
 #Main applicaitons
-%define poweroff_popup on
+%define powerkey_popup on
 %define crash_popup on
 %define system_popup on
 %define notification_service on
@@ -44,7 +44,7 @@
        %define FORMFACTOR rectangle
 %endif
 #Main applicaitons
-%define poweroff_popup on
+%define powerkey_popup on
 %define crash_popup on
 %define system_popup on
 #sub-popups of system-popup
@@ -68,7 +68,7 @@ Group:      System/Utilities
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
 Source1:    %{name}.manifest
-Source1001:    org.tizen.poweroff-syspopup.manifest
+Source1001:    org.tizen.powerkey-syspopup.manifest
 Source1015:    org.tizen.crash-syspopup.manifest
 Source2001:    org.tizen.system-syspopup.manifest
 Source2003:    org.tizen.system-signal-sender.manifest
@@ -78,7 +78,7 @@ BuildRequires:  pkgconfig(elementary)
 BuildRequires:  pkgconfig(appcore-efl)
 BuildRequires:  pkgconfig(syspopup)
 BuildRequires:  pkgconfig(syspopup-caller)
-BuildRequires:  pkgconfig(notification) 
+BuildRequires:  pkgconfig(notification)
 BuildRequires:  pkgconfig(vconf)
 BuildRequires:  pkgconfig(glib-2.0)
 BuildRequires:  pkgconfig(dlog)
@@ -110,15 +110,15 @@ to inform user crash information. It is activated
 when crash event is happend
 %endif
 
-%if %{?poweroff_popup} == on
-%package -n org.tizen.poweroff-syspopup
-Summary:    Poweroff-popup application
+%if %{?powerkey_popup} == on
+%package -n org.tizen.powerkey-syspopup
+Summary:    Powerkey-popup application
 Group:      System/Utilities
 Requires:   %{name} = %{version}-%{release}
 
-%description -n org.tizen.poweroff-syspopup
-to inform user poweroff information. It is activated
-when user power event is happened
+%description -n org.tizen.powerkey-syspopup
+to inform user powerkey information. It is activated
+when user power key event is happened
 %endif
 
 %if %{?signal_sender} == on
@@ -151,7 +151,7 @@ when system event is happend
 chmod 0644 %{SOURCE1}
 cp %{SOURCE1} .
 
-%if %{poweroff_popup} == on
+%if %{powerkey_popup} == on
 chmod 0644 %{SOURCE1001}
 cp %{SOURCE1001} .
 %endif
@@ -191,7 +191,7 @@ cp %{SOURCE2003} .
                -DTZ_SYS_SHARE=%{TZ_SYS_SHARE} \
                -DTZ_SYS_RO_SHARE=%{TZ_SYS_RO_SHARE} \
                -DTZ_SYS_RO_APP=%{TZ_SYS_RO_APP} \
-               -DPOWEROFF_POPUP=%{poweroff_popup} \
+               -DPOWERKEY_POPUP=%{powerkey_popup} \
                -DCRASH_POPUP=%{crash_popup} \
                -DNOTIFICATION_SERVICE=%{notification_service} \
                -DBATTERY_POPUP=%{battery_popup} \
@@ -302,15 +302,15 @@ rm -rf %{buildroot}
 %{TZ_SYS_RO_SHARE}/packages/org.tizen.system-syspopup.xml
 %endif
 
-%if %{poweroff_popup} == on
-%files -n org.tizen.poweroff-syspopup
-%manifest org.tizen.poweroff-syspopup.manifest
+%if %{powerkey_popup} == on
+%files -n org.tizen.powerkey-syspopup
+%manifest org.tizen.powerkey-syspopup.manifest
 %license LICENSE
 %defattr(-,root,root,-)
-%{TZ_SYS_RO_APP}/org.tizen.poweroff-syspopup/bin/poweroff-popup
-%{TZ_SYS_RO_SHARE}/packages/org.tizen.poweroff-syspopup.xml
-%{TZ_SYS_RO_APP}/org.tizen.poweroff-syspopup/res/circle_btn_check.png
-%{TZ_SYS_RO_APP}/org.tizen.poweroff-syspopup/res/circle_btn_delete.png
+%{TZ_SYS_RO_APP}/org.tizen.powerkey-syspopup/bin/powerkey-popup
+%{TZ_SYS_RO_SHARE}/packages/org.tizen.powerkey-syspopup.xml
+%{TZ_SYS_RO_APP}/org.tizen.powerkey-syspopup/res/circle_btn_check.png
+%{TZ_SYS_RO_APP}/org.tizen.powerkey-syspopup/res/circle_btn_delete.png
 %endif
 
 %if %{signal_sender} == on
index d69d2192ba5194a9f388de3ccfc8310ab6225821..afc67eb2e067073015b0a004621e249d4fadc269 100755 (executable)
@@ -23,9 +23,9 @@
 #define SIGNAL_CHARGEERR_RESPONSE   "ChargeErrResponse"
 
 #define SYSTEMD_STOP_POWER_OFF 4
-#define POWER_BUS_NAME        "org.tizen.system.deviced"
+#define DEVICED_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_INTERFACE_NAME  DEVICED_BUS_NAME".power"
 #define POWER_METHOD            "reboot"
 #define POWER_OPERATION_OFF     "poweroff"
 
@@ -89,14 +89,12 @@ static void charger_status_changed(keynode_t *key, void *data)
 
 static void unregister_charger_status_handler(void)
 {
-       _D("unregister_charger_status_handler() is finished");
        vconf_ignore_key_changed(VCONFKEY_SYSMAN_CHARGER_STATUS,
                                charger_status_changed);
 }
 
 static void register_charger_status_handler(const struct popup_ops *ops)
 {
-       _D("register_charger_status_handler() is finished");
        if (vconf_notify_key_changed(VCONFKEY_SYSMAN_CHARGER_STATUS,
                                charger_status_changed, (void *)ops) < 0)
                _E("Failed to register vconf key handler");
@@ -104,17 +102,15 @@ static void register_charger_status_handler(const struct popup_ops *ops)
 
 static int lowbattery_launch(bundle *b, const struct popup_ops *ops)
 {
-       _D("lowbattery_launch() is finished");
        unregister_charger_status_handler();
        remove_other_lowbattery_popups(ops);
        register_charger_status_handler(ops);
-       
+
        return 0;
 }
 
 static void lowbattery_terminate(const struct popup_ops *ops)
 {
-       _D("lowbattery_terminate() is finished");
        unregister_charger_status_handler();
 }
 
@@ -127,7 +123,6 @@ static void poweroff_clicked(const struct popup_ops *ops)
        char data[8];
        int ret;
 
-       _D("poweroff_clicked() is finished");
        if (bPowerOff == 1)
                return;
        bPowerOff = 1;
@@ -151,7 +146,7 @@ static void poweroff_clicked(const struct popup_ops *ops)
        param[0] = POWER_OPERATION_OFF;
        snprintf(data, sizeof(data), "0");
        param[1] = data;
-       ret = popup_dbus_method_sync(POWER_BUS_NAME,
+       ret = popup_dbus_method_sync(DEVICED_BUS_NAME,
                        POWER_OBJECT_PATH,
                        POWER_INTERFACE_NAME,
                        POWER_METHOD,
index 3227d95747e85dae83311886c972d60fd65da161..7726620bcae0a7433ecf322dcdde7e59ed0d1a12 100755 (executable)
@@ -57,8 +57,8 @@
 #define POPUP_PATH_SYSTEM              POPUP_DBUS_PATH"/System"
 #define POPUP_IFACE_SYSTEM             BUS_NAME".System"
 
-#define POPUP_PATH_POWEROFF            POPUP_DBUS_PATH"/Poweroff"
-#define POPUP_IFACE_POWEROFF   BUS_NAME".Poweroff"
+#define POPUP_PATH_POWERKEY            POPUP_DBUS_PATH"/Powerkey"
+#define POPUP_IFACE_POWERKEY   BUS_NAME".Powerkey"
 
 #define POPUP_PATH_CRASH               POPUP_DBUS_PATH"/Crash"
 #define POPUP_IFACE_CRASH              BUS_NAME".Crash"
index 3fe888aab594b5894f649304dfe4e47f66addaa8..5e85ccd275fe11b3b4d15b46be92ff306b871eea 100755 (executable)
@@ -77,11 +77,11 @@ dbus_system_methods[] = {
        /* Add methods here */
 };
 
-/* Poweroff popup */
-static DBusMessage *poweroff_popup(E_DBus_Object *obj, DBusMessage *msg)
+/* Powerkey popup */
+static DBusMessage *powerkey_popup(E_DBus_Object *obj, DBusMessage *msg)
 {
        set_timer_to_terminate();
-       return launch_poweroff_popup(obj, msg, POWEROFF_SYSPOPUP);
+       return launch_powerkey_popup(obj, msg, POWERKEY_SYSPOPUP);
 }
 
 /* Crash popup */
@@ -152,8 +152,8 @@ static DBusMessage *usb_device_noti_update(E_DBus_Object *obj, DBusMessage *msg)
 }
 
 static const struct edbus_method
-dbus_poweroff_methods[] = {
-       { "PopupLaunch", NULL, "i", poweroff_popup },
+dbus_powerkey_methods[] = {
+       { "PopupLaunch", NULL, "i", powerkey_popup },
        /* Add methods here */
 };
 
@@ -186,8 +186,8 @@ static struct edbus_object
 edbus_objects[]= {
        { POPUP_PATH_SYSTEM             , POPUP_IFACE_SYSTEM    , NULL  , NULL  ,
                dbus_system_methods     , ARRAY_SIZE(dbus_system_methods)               },
-       { POPUP_PATH_POWEROFF   , POPUP_IFACE_POWEROFF  , NULL  , NULL  ,
-               dbus_poweroff_methods   , ARRAY_SIZE(dbus_poweroff_methods)     },
+       { POPUP_PATH_POWERKEY   , POPUP_IFACE_POWERKEY  , NULL  , NULL  ,
+               dbus_powerkey_methods   , ARRAY_SIZE(dbus_powerkey_methods)     },
        { POPUP_PATH_NOTI               , POPUP_IFACE_NOTI              , NULL  , NULL  ,
                dbus_noti_methods               , ARRAY_SIZE(dbus_noti_methods)                 },
        { POPUP_PATH_CRASH              , POPUP_IFACE_CRASH             , NULL  , NULL  ,
index 81c8ff769753474276d91599a3e9db495a12c236..6e3d8474741d7bad03b5dfeeaf978df0d9cb27a7 100755 (executable)
@@ -30,7 +30,7 @@
 #include "macro.h"
 
 /* Popup names */
-#define POWEROFF_SYSPOPUP  "poweroff-syspopup"
+#define POWERKEY_SYSPOPUP  "powerkey-syspopup"
 #define SYSTEM_SYSPOPUP    "system-syspopup"
 #define CRASH_SYSPOPUP     "crash-syspopup"
 
@@ -108,7 +108,7 @@ struct edbus_object {
 /* launch popup */
 DBusMessage *launch_popup(E_DBus_Object *obj,
                                DBusMessage *msg, char *name);
-DBusMessage *launch_poweroff_popup(E_DBus_Object *obj,
+DBusMessage *launch_powerkey_popup(E_DBus_Object *obj,
                                DBusMessage *msg, char *name);
 
 #endif /* __LAUNCHER_H__ */
index 9ccfa0cd90c6ca603bc93d526b459875fd10c042..8d9f72df9d6f6a22957239023182732972c27e11 100755 (executable)
@@ -21,7 +21,7 @@
 #include "launcher.h"
 
 #define POPUP_CONTENT          "_SYSPOPUP_CONTENT_"
-#define POPUP_NAME_POWEROFF    "poweroff"
+#define POPUP_NAME_POWERKEY    "powerkey"
 
 DBusMessage *launch_popup(E_DBus_Object *obj,
                                DBusMessage *msg, char *name)
@@ -80,7 +80,7 @@ out:
        return reply;
 }
 
-DBusMessage *launch_poweroff_popup(E_DBus_Object *obj,
+DBusMessage *launch_powerkey_popup(E_DBus_Object *obj,
                                DBusMessage *msg, char *name)
 {
        DBusMessage *reply;
@@ -101,9 +101,9 @@ DBusMessage *launch_poweroff_popup(E_DBus_Object *obj,
                goto out;
        }
 
-       ret = bundle_add(b, POPUP_CONTENT, POPUP_NAME_POWEROFF);
+       ret = bundle_add(b, POPUP_CONTENT, POPUP_NAME_POWERKEY);
        if (ret < 0) {
-               _E("Failed to add bundle (%s,%s) (ret:%d)", POPUP_CONTENT, POPUP_NAME_POWEROFF, ret);
+               _E("Failed to add bundle (%s,%s) (ret:%d)", POPUP_CONTENT, POPUP_NAME_POWERKEY, ret);
                goto out;
        }
 
index 23de7e127e5299ea9ce21a582db08d54e5a84eae..21e1dcd3101d555cf4e878f3c86364877c78dac1 100755 (executable)
@@ -107,7 +107,7 @@ msgid "IDS_IDLE_POP_BATTERY_FULLY_CAHRGED"
 msgstr "Battery fully charged."
 
 msgid "IDS_MF_BODY_MMC_DATA_IS_INITIALIZING_ING"
-msgstr "MMC data is initialising..."
+msgstr "MMC data is initializing..."
 
 msgid "IDS_QP_BODY_ASSISTIVE_LIGHT_IS_ON"
 msgstr "Assistive light is on."
@@ -206,7 +206,7 @@ msgid "IDS_SYNCML_POP_DM_REMOVE_CHARGER"
 msgstr "Remove charger."
 
 msgid "IDS_TPLATFORM_BODY_POWER_OFF_THE_DEVICE_Q"
-msgstr "Power off the device?"
+msgstr "Your device will power off"
 
 msgid "IDS_USB_BODY_BROWSE_CAMERA_CONNECTED_VIA_USB_Q"
 msgstr "Browse camera connected via USB?"
@@ -243,3 +243,12 @@ msgstr "%s is not responding. Close %s?"
 
 msgid "IDS_DAV_BODY_LOW_MEMORY_LEFT_ORANGE"
 msgstr "Low memory left"
+
+msgid "IDS_COM_SK_RESTART"
+msgstr "Restart"
+
+msgid "IDS_HS_BUTTON_RESTART_ABB2"
+msgstr "Restart"
+
+msgid "IDS_ST_POP_DEVICE_WILL_RESTART"
+msgstr "Device will restart."
index 4c2f51dd58c85f5644ee0426228fe41096ad5edc..dca55dba417af662fde3d40bb91e78da039c523b 100755 (executable)
@@ -98,7 +98,7 @@ msgid "IDS_DN_POP_ENCRYPTING_SD_CARD_ING"
 msgstr "Encrypting SD card..."
 
 msgid "IDS_DN_POP_FAILED_TO_MOUNT_SD_CARD_REINSERT_OR_FORMAT_SD_CARD"
-msgstr "Failed to mount SD card. Reinsert or format SD card"
+msgstr "Failed to mount SD card. Reinsert or format SD card."
 
 msgid "IDS_HS_BUTTON_POWER_OFF_ABB2"
 msgstr "Power off"
@@ -113,10 +113,10 @@ msgid "IDS_QP_BODY_ASSISTIVE_LIGHT_IS_ON"
 msgstr "Assistive light is on."
 
 msgid "IDS_QP_BODY_CHARGING_PAUSED_BATTERY_TEMPERATURE_TOO_HIGH"
-msgstr "Charging paused. Battery temperature too high"
+msgstr "Charging paused. Battery temperature too high."
 
 msgid "IDS_QP_BODY_CHARGING_PAUSED_BATTERY_TEMPERATURE_TOO_LOW"
-msgstr "Charging paused. Battery temperature too low"
+msgstr "Charging paused. Battery temperature too low."
 
 msgid "IDS_QP_BUTTON_DO_NOT_POWER_OFF_ABB"
 msgstr "Do not power off"
@@ -140,7 +140,7 @@ msgid "IDS_ST_BODY_POWER_OFF"
 msgstr "Power off"
 
 msgid "IDS_ST_BODY_READ_ONLY_USB_DEV_CONNECTED_M_NOUN_ABB"
-msgstr "Read-only USB dev. connected"
+msgstr "Read-only USB dev. connected."
 
 msgid "IDS_ST_BODY_SD_CARD_DECRYPTED"
 msgstr "SD card decrypted."
@@ -161,10 +161,10 @@ msgid "IDS_ST_BODY_TAP_TO_TURN_OFF_ASSISTIVE_LIGHT"
 msgstr "Tap to turn off assistive light."
 
 msgid "IDS_ST_BODY_UNABLE_TO_DECRYPT_SD_CARD_NOT_ENOUGH_SPACE_ON_CARD_APPROXIMATELY_P2F_MB_NEEDED_DELETE_SOME_FILES"
-msgstr "Unable to decrypt SD card. Not enough space on card. Approximately %.2f MB needed. Delete some files"
+msgstr "Unable to decrypt SD card. Not enough space on card. Approximately %.2f MB needed. Delete some files."
 
 msgid "IDS_ST_BODY_UNABLE_TO_ENCRYPT_SD_CARD_NOT_ENOUGH_SPACE_ON_CARD_APPROXIMATELY_P2F_MB_NEEDED_DELETE_SOME_FILES"
-msgstr "Unable to encrypt SD card. Not enough space on card. Approximately %.2f MB needed. Delete some files"
+msgstr "Unable to encrypt SD card. Not enough space on card. Approximately %.2f MB needed. Delete some files."
 
 msgid "IDS_ST_BODY_USB_STORAGE_ABB"
 msgstr "USB storage"
@@ -191,7 +191,7 @@ msgid "IDS_COM_HEADER_BATTERY_CRITICALLY_LOW"
 msgstr "Battery critically low"
 
 msgid "IDS_COM_POP_BATTERY_LOW_RECHARGE_ABB"
-msgstr "Battery low. Recharge"
+msgstr "Battery low. Recharge."
 
 msgid "IDS_ST_POP_TO_USE_YOUR_SD_CARD_IT_MUST_BE_DECRYPTED_DECRYPT_SD_CARD_OR_ENABLE_DEVICE_ENCRYPTION_Q"
 msgstr "To use your SD card, it must be decrypted. Decrypt SD card or enable device encryption?"
@@ -206,7 +206,7 @@ msgid "IDS_SYNCML_POP_DM_REMOVE_CHARGER"
 msgstr "Remove charger."
 
 msgid "IDS_TPLATFORM_BODY_POWER_OFF_THE_DEVICE_Q"
-msgstr "Power off the device?"
+msgstr "Your device will power off"
 
 msgid "IDS_USB_BODY_BROWSE_CAMERA_CONNECTED_VIA_USB_Q"
 msgstr "Browse camera connected via USB?"
@@ -227,7 +227,7 @@ msgid "IDS_USB_MBODY_USB_DEVICES"
 msgstr "USB devices"
 
 msgid "IDS_USB_POP_USB_CONNECTION_FAILED"
-msgstr "USB connection failed"
+msgstr "USB connection failed."
 
 msgid "IDS_VPL_POP_HDMI_CABLE_CONNECTED"
 msgstr "HDMI cable connected."
@@ -243,3 +243,12 @@ msgstr "%s is not responding. Close %s?"
 
 msgid "IDS_DAV_BODY_LOW_MEMORY_LEFT_ORANGE"
 msgstr "Low memory left"
+
+msgid "IDS_COM_SK_RESTART"
+msgstr "Restart"
+
+msgid "IDS_HS_BUTTON_RESTART_ABB2"
+msgstr "Restart"
+
+msgid "IDS_ST_POP_DEVICE_WILL_RESTART"
+msgstr "Device will restart."
index 86dacab8ab0cd0fda759d274f3769291bfaf59df..a6343ac0c643f22f044e4c45bae7eed484e0e9e2 100755 (executable)
@@ -140,7 +140,7 @@ msgid "IDS_ST_BODY_POWER_OFF"
 msgstr "Power off"
 
 msgid "IDS_ST_BODY_READ_ONLY_USB_DEV_CONNECTED_M_NOUN_ABB"
-msgstr "Read-only USB dev. connected"
+msgstr "Read-only USB dev. connected."
 
 msgid "IDS_ST_BODY_SD_CARD_DECRYPTED"
 msgstr "SD card decrypted."
@@ -206,7 +206,7 @@ msgid "IDS_SYNCML_POP_DM_REMOVE_CHARGER"
 msgstr "Remove charger."
 
 msgid "IDS_TPLATFORM_BODY_POWER_OFF_THE_DEVICE_Q"
-msgstr "Turn off the device?"
+msgstr "Your device will power off."
 
 msgid "IDS_USB_BODY_BROWSE_CAMERA_CONNECTED_VIA_USB_Q"
 msgstr "Browse camera connected via USB?"
@@ -227,7 +227,7 @@ msgid "IDS_USB_MBODY_USB_DEVICES"
 msgstr "USB devices"
 
 msgid "IDS_USB_POP_USB_CONNECTION_FAILED"
-msgstr "USB connection failed"
+msgstr "USB connection failed."
 
 msgid "IDS_VPL_POP_HDMI_CABLE_CONNECTED"
 msgstr "HDMI cable connected."
@@ -243,3 +243,12 @@ msgstr "%s is not responding. Close %s?"
 
 msgid "IDS_DAV_BODY_LOW_MEMORY_LEFT_ORANGE"
 msgstr "Low memory left"
+
+msgid "IDS_COM_SK_RESTART"
+msgstr "Restart"
+
+msgid "IDS_HS_BUTTON_RESTART_ABB2"
+msgstr "Restart"
+
+msgid "IDS_ST_POP_DEVICE_WILL_RESTART"
+msgstr "Device will restart."
diff --git a/src/powerkey/CMakeLists.txt b/src/powerkey/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..a6ff523
--- /dev/null
@@ -0,0 +1,68 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+IF("${POWERKEY_POPUP}" STREQUAL "off")
+       RETURN()
+ENDIF("${POWERKEY_POPUP}" STREQUAL "off")
+
+SET(POWERKEY_SRCS ${COMMON_SRCS} powerkey.c)
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
+INCLUDE_DIRECTORIES(${COMMON_DIR})
+
+SET(VENDOR "tizen")
+SET(PACKAGE "powerkey-syspopup")
+SET(EXECNAME "powerkey-popup")
+SET(PKGNAME "org.${VENDOR}.${PACKAGE}")
+SET(POWERKEY_PREFIX "${TZ_SYS_RO_APP}/${PKGNAME}")
+SET(BINDIR "${POWERKEY_PREFIX}/bin")
+SET(RESDIR "${POWERKEY_PREFIX}/res")
+SET(MANIFESTDIR "${TZ_SYS_RO_SHARE}/packages")
+
+SET(PKG_MODULES
+               appcore-efl
+               elementary
+               dlog
+               deviced
+               evas
+               ecore
+               edbus
+               glib-2.0
+               vconf
+               syspopup
+               syspopup-caller
+               feedback
+               efl-extension
+)
+
+IF("${DPMS}" STREQUAL "x")
+SET(PKG_MODULES ${PKG_MODULES}
+               ecore-x
+               utilX
+)
+ENDIF("${DPMS}" STREQUAL "x")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(powerkey_pkgs REQUIRED ${PKG_MODULES})
+
+FOREACH(flag ${powerkey_pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -O2 -g -Wall -fpie")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g -fpie")
+SET(CMAKE_C_FLAGS_RELEASE "-O2 -fpie")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE}\"")
+ADD_DEFINITIONS("-DRESDIR=\"${RESDIR}\"")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
+
+ADD_EXECUTABLE(${EXECNAME} ${POWERKEY_SRCS})
+TARGET_LINK_LIBRARIES(${EXECNAME} ${powerkey_pkgs_LDFLAGS})
+
+INSTALL(TARGETS ${EXECNAME} DESTINATION ${TZ_SYS_RO_APP}/${PKGNAME}/bin)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/src/powerkey/${PKGNAME}.xml DESTINATION ${MANIFESTDIR})
+
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/circle_btn_check.png DESTINATION ${RESDIR})
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/circle_btn_delete.png DESTINATION ${RESDIR})
diff --git a/src/powerkey/org.tizen.powerkey-syspopup.xml b/src/powerkey/org.tizen.powerkey-syspopup.xml
new file mode 100755 (executable)
index 0000000..237eaf1
--- /dev/null
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns="http://tizen.org/ns/packages" package="org.tizen.powerkey-syspopup" api-version="3.0" version="0.2.0" install-location="internal-only">
+       <label>Power key system popup</label>
+       <author email="changjoo.lee@samsung.com" href="www.samsung.com">ChangJoo Lee</author>
+       <description>System popup application (power key system popup)</description>
+       <ui-application appid="org.tizen.powerkey-syspopup" exec="/usr/apps/org.tizen.powerkey-syspopup/bin/powerkey-popup" nodisplay="true" multiple="false" type="capp" taskmanage="false">
+               <label>Power key system popup</label>
+       </ui-application>
+       <privileges>
+               <privilege>http://tizen.org/privilege/power</privilege>
+               <privilege>http://tizen.org/privilege/window.priority.set</privilege>
+               <privilege>http://tizen.org/privilege/haptic</privilege>
+       </privileges>
+</manifest>
diff --git a/src/powerkey/powerkey.c b/src/powerkey/powerkey.c
new file mode 100755 (executable)
index 0000000..97ea8d7
--- /dev/null
@@ -0,0 +1,360 @@
+/*
+ *  powerkey-popup
+ *
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+*/
+
+#include "popup-common.h"
+
+#define SYSTEMD_STOP_POWER_OFF 4
+
+#define DEVICED_BUS_NAME        "org.tizen.system.deviced"
+#define POWER_OBJECT_PATH     "/Org/Tizen/System/DeviceD/Power"
+#define POWER_INTERFACE_NAME  DEVICED_BUS_NAME".power"
+
+#define POWER_METHOD            "reboot"
+#define POWER_OPERATION_OFF     "poweroff"
+#define POWER_OPERATION_RESTART     "reboot"
+#define TIMEOUT_POWEROFF 5 /* seconds */
+
+#define DEVICED_OBJECT_PATH            "/Org/Tizen/System/DeviceD"
+#define DEVICED_INTERFACE_NAME DEVICED_BUS_NAME
+
+int clicked_index = 0;
+
+static void remove_popup(const struct popup_ops *ops);
+static void pm_state_changed(keynode_t *key, void *data);
+static void event_back_key_up(void *data, Evas_Object *obj, void *event_info);
+static void register_handlers(const struct popup_ops *ops);
+static void unregister_handlers(const struct popup_ops *ops);
+static int poweroff_launch(bundle *b, const struct popup_ops *ops);
+static void poweroff_terminate(const struct popup_ops *ops);
+static void poweroff_clicked(const struct popup_ops *ops);
+static __attribute__ ((constructor)) void poweroff_register_popup(void);
+static const struct popup_ops powerkey_ops;
+static const struct popup_ops poweroff_ops;
+static const struct popup_ops restart_ops;
+
+static char *items[] = {
+       "IDS_ST_BODY_POWER_OFF",
+       "IDS_COM_SK_RESTART"
+};
+
+static int restart_launch(bundle *b, const struct popup_ops *ops)
+{
+       return 0;
+}
+
+static void restart_terminate(const struct popup_ops *ops)
+{
+       return 0;
+}
+
+static void restart_clicked(const struct popup_ops *ops)
+{
+       Evas_Object *rect, *win;
+       Evas_Coord w, h, size;
+       static int bReset = 0;
+       char *param[2];
+       char data[8];
+       int ret;
+
+       if (bReset == 1)
+               return;
+       bReset = 1;
+
+       unload_simple_popup(ops);
+
+       win = get_window();
+       if (!win)
+               popup_terminate();
+
+       rect = evas_object_rectangle_add(evas_object_evas_get(win));
+       evas_object_geometry_get(win, NULL, NULL, &w, &h);
+       size = max(w, h);
+       evas_object_resize(rect, size, size);
+       evas_object_color_set(rect, 0, 0, 0, 255);
+       evas_object_show(rect);
+
+       param[0] = POWER_OPERATION_RESTART;
+       snprintf(data, sizeof(data), "0");
+       param[1] = data;
+
+       ret = popup_dbus_method_sync(DEVICED_BUS_NAME,
+                       POWER_OBJECT_PATH,
+                       POWER_INTERFACE_NAME,
+                       POWER_METHOD,
+                       "si", param);
+
+       if (ret < 0)
+               _E("Failed to request restart to deviced (%d)", ret);
+}
+
+static char*
+gl_text_get_cb(void *data, Evas_Object *obj, const char *part)
+{
+       int index = (int) data;
+
+       return strdup(_(items[index]));
+}
+
+static void _popup_hide_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       evas_object_del(obj);
+}
+
+static void _popup_hide_finished_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       evas_object_del(obj);
+}
+
+static void gl_sel_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       Evas_Object *popup = data;
+       Elm_Object_Item *item = event_info;
+       bundle *b = NULL;
+
+       clicked_index = (int)elm_object_item_data_get(item);
+       evas_object_del(popup);
+
+       if(clicked_index == 0 )
+       {
+               _D("poweroff is chosen");
+               load_simple_popup(b, &poweroff_ops);
+               register_handlers(&poweroff_ops);
+       }
+       else if(clicked_index == 1 )
+       {
+               _D("restart is chosen");
+               load_simple_popup(b, &restart_ops);
+               register_handlers(&restart_ops);
+       }
+}
+
+int powerkey_list(bundle *b, const struct popup_ops *ops)
+{
+       static Elm_Genlist_Item_Class itc;
+       Evas_Object *popup;
+       Evas_Object *box;
+       Evas_Object *genlist;
+       struct object_ops *obj;
+       int i;
+       Evas_Object *win;
+       int ret;
+
+       if (!ops)
+               return -EINVAL;
+
+       ret = get_object_by_ops(ops, &obj);
+       if (ret < 0) {
+               _E("Failed to get object (%d)", ret);
+               return -EINVAL;
+       }
+
+       win = get_window();
+       if (!win)
+               return -ENOMEM;
+
+       evas_object_show(win);
+
+       popup = elm_popup_add(win);
+       if (!popup)
+               return -ENOMEM;
+
+       elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
+       evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+       eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, _popup_hide_cb, NULL);
+       evas_object_smart_callback_add(popup, "dismissed", _popup_hide_finished_cb, NULL);
+
+       /* box */
+       box = elm_box_add(popup);
+       evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+       /* genlist */
+       genlist = elm_genlist_add(box);
+       evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+       itc.item_style = "default";
+       itc.func.text_get = gl_text_get_cb;
+       itc.func.content_get = NULL;
+       itc.func.state_get = NULL;
+       itc.func.del = NULL;
+
+       for (i = 0; i < 2; i++) {
+               elm_genlist_item_append(genlist, &itc, (void *) i, NULL, ELM_GENLIST_ITEM_NONE, gl_sel_cb, popup);
+       }
+       evas_object_show(genlist);
+       elm_box_pack_end(box, genlist);
+       evas_object_size_hint_min_set(box, -1, 250);
+       elm_object_content_set(popup, box);
+
+       evas_object_show(popup);
+       obj->popup = popup;
+
+       return 0;
+}
+
+
+static void remove_popup(const struct popup_ops *ops)
+{
+       static bool terminating = false;
+
+       if (terminating)
+               return;
+
+       terminating = true;
+
+       unload_simple_popup(ops);
+       popup_terminate();
+}
+
+static void pm_state_changed(keynode_t *key, void *data)
+{
+       const struct popup_ops *ops = data;
+
+       if (!key)
+               return;
+
+       if (vconf_keynode_get_int(key) != VCONFKEY_PM_STATE_LCDOFF)
+               return;
+
+       remove_popup(ops);
+}
+
+static void event_back_key_up(void *data, Evas_Object *obj, void *event_info)
+{
+       const struct popup_ops *ops = data;
+       remove_popup(ops);
+}
+
+static void register_handlers(const struct popup_ops *ops)
+{
+       Evas_Object *win;
+
+       if (vconf_notify_key_changed(
+               VCONFKEY_PM_STATE,
+               pm_state_changed,
+               (void *)ops) != 0)
+               _E("Failed to register vconf");
+
+       win = get_window();
+       if (win)
+               eext_object_event_callback_add(win, EEXT_CALLBACK_BACK, event_back_key_up, (void*)ops);
+}
+
+static void unregister_handlers(const struct popup_ops *ops)
+{
+       Evas_Object *win;
+
+       vconf_ignore_key_changed(VCONFKEY_PM_STATE, pm_state_changed);
+
+       win = get_window();
+       if (win)
+               eext_object_event_callback_del(win, EEXT_CALLBACK_BACK, event_back_key_up);
+}
+
+static int poweroff_launch(bundle *b, const struct popup_ops *ops)
+{
+       register_handlers(ops);
+       return 0;
+}
+
+static void poweroff_terminate(const struct popup_ops *ops)
+{
+       unregister_handlers(ops);
+}
+
+static void powerkey_terminate(const struct popup_ops *ops)
+{
+       unregister_handlers(ops);
+}
+
+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;
+       bPowerOff = 1;
+
+       unload_simple_popup(ops);
+
+       win = get_window();
+       if (!win)
+               popup_terminate();
+
+       rect = evas_object_rectangle_add(evas_object_evas_get(win));
+       evas_object_geometry_get(win, NULL, NULL, &w, &h);
+       size = max(w, h);
+       evas_object_resize(rect, size, size);
+       evas_object_color_set(rect, 0, 0, 0, 255);
+       evas_object_show(rect);
+
+       param[0] = POWER_OPERATION_OFF;
+       snprintf(data, sizeof(data), "0");
+       param[1] = data;
+       ret = popup_dbus_method_sync(DEVICED_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 restart_ops = {
+       .name                           = "restart",
+       .show                           = load_simple_popup,
+       .title                          = "IDS_COM_SK_RESTART",
+       .content                        = "IDS_ST_POP_DEVICE_WILL_RESTART",
+       .left_text                      = "IDS_COM_SK_CANCEL",
+       .right_text                     = "IDS_HS_BUTTON_RESTART_ABB2",
+       .right                          = restart_clicked,
+       .pre                            = restart_launch,
+       .terminate                      = restart_terminate,
+};
+
+static const struct popup_ops poweroff_ops = {
+       .name           = "poweroff",
+       .show           = load_simple_popup,
+       .title          = "IDS_ST_BODY_POWER_OFF",
+       .content        = "IDS_TPLATFORM_BODY_POWER_OFF_THE_DEVICE_Q",
+       .left_text      = "IDS_COM_SK_CANCEL",
+       .right_text     = "IDS_HS_BUTTON_POWER_OFF_ABB2",
+       .right          = poweroff_clicked,
+       .pre            = poweroff_launch,
+       .terminate      = poweroff_terminate,
+};
+
+static const struct popup_ops powerkey_ops = {
+       .name           = "powerkey",
+       .show           = powerkey_list,
+       .terminate      = powerkey_terminate,
+};
+
+static __attribute__ ((constructor)) void poweroff_register_popup(void)
+{
+       register_popup(&powerkey_ops);
+       register_popup(&poweroff_ops);
+       register_popup(&restart_ops);
+}
index 7bd0a718cb8ec6eb238a85f0b7bedf38a1431067..8588259f64f32d229bf67024dd504d82de2e2e52 100755 (executable)
@@ -49,33 +49,24 @@ static void send_result_dbus_signal(int result)
 static void usb_device_confirm_ok_clicked(const struct popup_ops *ops)
 {
        _I("OK is selected");
-
        unload_simple_popup(ops);
-
        send_result_dbus_signal(USB_DEVICE_CONFIRM_OK);
-
        terminate_if_no_popup();
 }
 
 static void usb_device_confirm_cancel_clicked(const struct popup_ops *ops)
 {
        _I("CANCEL is selected");
-
        unload_simple_popup(ops);
-
        send_result_dbus_signal(USB_DEVICE_CONFIRM_NOK);
-
        terminate_if_no_popup();
 }
 
 static void usb_device_confirm_terminate(const struct popup_ops *ops)
 {
        _I("terminate usb device confirm popup");
-
        unload_simple_popup(ops);
-
        send_result_dbus_signal(USB_DEVICE_CONFIRM_NOK);
-
        terminate_if_no_popup();
 }