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
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_"/>
+ </request>
+</manifest>
%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
%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
%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
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
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)
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
chmod 0644 %{SOURCE1}
cp %{SOURCE1} .
-%if %{poweroff_popup} == on
+%if %{powerkey_popup} == on
chmod 0644 %{SOURCE1001}
cp %{SOURCE1001} .
%endif
-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} \
%{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
#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"
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");
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();
}
char data[8];
int ret;
- _D("poweroff_clicked() is finished");
if (bPowerOff == 1)
return;
bPowerOff = 1;
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,
#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"
/* 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 */
}
static const struct edbus_method
-dbus_poweroff_methods[] = {
- { "PopupLaunch", NULL, "i", poweroff_popup },
+dbus_powerkey_methods[] = {
+ { "PopupLaunch", NULL, "i", powerkey_popup },
/* Add methods here */
};
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 ,
#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"
/* 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__ */
#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)
return reply;
}
-DBusMessage *launch_poweroff_popup(E_DBus_Object *obj,
+DBusMessage *launch_powerkey_popup(E_DBus_Object *obj,
DBusMessage *msg, char *name)
{
DBusMessage *reply;
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;
}
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."
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?"
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."
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"
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"
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."
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"
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?"
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?"
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."
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."
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."
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?"
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."
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."
--- /dev/null
+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})
--- /dev/null
+<?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>
--- /dev/null
+/*
+ * 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);
+}
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();
}