#include "popup-common.h"
#include <app.h>
-
+#include "system_info_type.h"
#define SYSTEMD_STOP_POWER_OFF 4
#define POWER_METHOD "reboot"
#define POWER_OPERATION_OFF "poweroff"
#define TIMEOUT_POWEROFF 5 /* seconds */
+#define TELEPHONY_PATH "tizen.org/feature/network.telephony"
extern appdata_s *app_info;
+extern int system_info_get_platform_bool(const char *key, bool *value);
+
static Evas_Object *flight_icon = NULL;
enum {
static __attribute__ ((constructor)) void powerkey_register_popup(void);
static const struct popup_ops powerkey_ops;
static const struct popup_ops flightmode_ops;
+static const struct popup_ops poweroff_ops;
+
+static int is_supported(const char *path)
+{
+ bool res;
+
+ if (system_info_get_platform_bool(path, &res) != SYSTEM_INFO_ERROR_NONE) {
+ _E("Fail to get TELEPHONY INFO");
+ return -1;
+ }
+
+ return res;
+}
static void
win_delete_request_cb(void *data, Evas_Object *obj, void *event_info)
unregister_handlers(ops);
}
+static void remove_other_poweroff_popups(const struct popup_ops *ops)
+{
+ if (ops != &poweroff_ops)
+ unload_simple_popup(&poweroff_ops);
+}
+
+static int poweroff_launch(bundle *b, const struct popup_ops *ops)
+{
+ remove_other_poweroff_popups(ops);
+ register_handlers(ops);
+ return 0;
+}
+
+static void poweroff_terminate(const struct popup_ops *ops)
+{
+ unregister_handlers(ops);
+}
+
static const struct popup_ops powerkey_ops = {
.name = "powerkey",
.show = powerkey_list,
.terminate = flight_mode_terminate,
};
+static const struct popup_ops poweroff_ops = {
+ .name = "powerkey",
+ .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 __attribute__ ((constructor)) void powerkey_register_popup(void)
{
- register_popup(&powerkey_ops);
- register_popup(&flightmode_ops);
+ int telephony_supported = -1;
+
+ telephony_supported = is_supported(TELEPHONY_PATH);
+ _I("TELEPHONY = %d", telephony_supported);
+ if (telephony_supported > 1 || telephony_supported < 0) {
+ _E("Cannot decide powerkey type!");
+ telephony_supported = 0;
+ }
+
+ if (telephony_supported) {
+ register_popup(&powerkey_ops);
+ register_popup(&flightmode_ops);
+ } else
+ register_popup(&poweroff_ops);
}