/*
- * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ * system-popup
+ *
+ * Copyright (c) 2000 - 2013 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.
* 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 <stdio.h>
#include <appcore-efl.h>
#include <sensor.h>
-#include <devman.h>
-#include <pmapi.h>
-#include <sysman.h>
#include "lowbatt.h"
#include <vconf.h>
#include <vconf-keys.h>
#include <notification.h>
#include <syspopup.h>
#include <svi.h>
+//#include <dd-display.h>
+#include "common.h"
-#define CHECK_ACT 0
-#define WARNING_ACT 1
-#define POWER_OFF_ACT 2
-#define CHARGE_ERROR_ACT 3
-
+#define CHECK_ACT 0
+#define WARNING_ACT 1
+#define POWER_OFF_ACT 2
+#define CHARGE_ERROR_ACT 3
+#define BATTERY_DISCONNECT_ACT 4
static int option = -1;
int mytimeout(bundle *b, void *data)
{
- lowbatt_timeout_func(data);
return 0;
}
.def_timeout_fn = mytimeout
};
-static Eina_Bool exit_idler_cb(void *data)
-{
- elm_exit();
- return ECORE_CALLBACK_CANCEL;
-}
-
-void popup_terminate(void)
-{
- if (ecore_idler_add(exit_idler_cb, NULL))
- return;
-
- exit_idler_cb(NULL);
-}
-
/* App Life cycle funtions */
static void win_del(void *data, Evas_Object * obj, void *event)
{
popup_terminate();
}
-/* Quit */
-static void main_quit_cb(void *data, Evas_Object *obj, const char *emission,
- const char *source)
-{
- popup_terminate();
-}
-
-/* Update text font */
-static void update_ts(Evas_Object *eo, struct text_part *tp, int size)
-{
- int i;
-
- if (eo == NULL || tp == NULL || size < 0)
- return;
-
- for (i = 0; i < size; i++) {
- if (tp[i].part && tp[i].msgid)
- edje_object_part_text_set(eo, tp[i].part,
- _(tp[i].msgid));
- }
-}
-
-/* Language changed noti handler */
-static int lang_changed(void *data)
-{
- struct appdata *ad = data;
-
- if (ad->layout_main == NULL)
- return 0;
-
- update_ts(elm_layout_edje_get(ad->layout_main), main_txt,
- sizeof(main_txt) / sizeof(main_txt[0]));
- return 0;
-}
-
/* Create main window */
static Evas_Object *create_win(const char *name)
{
Evas_Object *eo;
+ Ecore_X_Window xwin;
int w, h;
+ unsigned int val = 1;
eo = elm_win_add(NULL, name, ELM_WIN_DIALOG_BASIC);
if (eo) {
&h);
evas_object_resize(eo, w, h);
}
+ xwin = elm_win_xwindow_get(eo);
+ ecore_x_window_prop_card32_set(xwin, ECORE_X_ATOM_E_ILLUME_ACCESS_CONTROL, &val, 1);
return eo;
}
-/* Read from EDJ file */
-static Evas_Object *load_edj(Evas_Object * parent, const char *file,
- const char *group)
-{
- Evas_Object *eo;
- int r;
-
- eo = elm_layout_add(parent);
- if (eo) {
- r = elm_layout_file_set(eo, file, group);
- if (!r) {
- evas_object_del(eo);
- return NULL;
- }
-
- evas_object_size_hint_weight_set(eo, EVAS_HINT_EXPAND,
- EVAS_HINT_EXPAND);
- }
-
- return eo;
-}
-
-/* Terminate noti handler */
-static int app_terminate(void *data)
-{
- struct appdata *ad = data;
-
- if (ad->layout_main)
- evas_object_del(ad->layout_main);
-
- if (ad->win_main)
- evas_object_del(ad->win_main);
-
- return 0;
-}
-
-/* Pause/background */
-static int app_pause(void *data)
-{
- return 0;
-}
-
-/* Resume */
-static int app_resume(void *data)
-{
- return 0;
-}
-
-
-/* Reset */
-static int app_reset(bundle *b, void *data)
-{
- struct appdata *ad = data;
- char *opt = NULL;
-
- opt = bundle_get_val(b, "_SYSPOPUP_CONTENT_");
- if (opt == NULL)
- option = CHECK_ACT;
- else if (!strcmp(opt,"warning"))
- option = WARNING_ACT;
- else if (!strcmp(opt,"poweroff"))
- option = POWER_OFF_ACT;
- else if (!strcmp(opt,"chargeerr"))
- option = CHARGE_ERROR_ACT;
- else
- option = CHECK_ACT;
-
- if (syspopup_has_popup(b)) {
- if (option == CHECK_ACT) {
- return 0;
- }
- syspopup_reset(b);
- } else {
- if(option == CHECK_ACT) {
- popup_terminate();
- }
- syspopup_create(b, &handler, ad->win_main, ad);
- evas_object_show(ad->win_main);
-
- /* Start Main UI */
- lowbatt_start((void *)ad);
- }
-
- return 0;
-}
-
-/* Customized print */
-void system_print(const char *format, ...)
-{
- /* Un-comment return to disable logs */
- va_list args;
- va_start(args, format);
- vfprintf(stderr, format, args);
- va_end(args);
-}
-
/* Cleanup objects to avoid mem-leak */
void lowbatt_cleanup(struct appdata *ad)
{
evas_object_del(ad->layout_main);
}
-/* Background clicked noti */
-static void bg_clicked_cb(void *data, Evas * e, Evas_Object * obj, void *event_info)
-{
- system_print("\n system-popup : Inside bg clicked \n");
- popup_terminate();
-}
-
-static void bg_noti_cb(void *data)
-{
- ui_bgimg_reload((Evas_Object *) data);
-}
-
-/* Create indicator bar */
-static int lowbatt_create_indicator(struct appdata *ad)
+void lowbatt_timeout_func(void *data, Evas_Object *obj, void *event_info)
{
- elm_win_indicator_mode_set(ad->win_main, ELM_WIN_INDICATOR_HIDE);
- return 0;
-}
-
-
-void lowbatt_timeout_func(void *data)
-{
- system_print("\n System-popup : In Lowbatt timeout\n");
+ _D("System-popup : In Lowbatt timeout");
lowbatt_cleanup(data);
/* If poweroff requested */
- if (option == POWER_OFF_ACT) {
- if (sysman_call_predef_action(PREDEF_POWEROFF, 0) == -1) {
- system_print
- ("System-popup : failed to request poweroff to system_server \n");
- fflush(stdout);
- system("poweroff");
- }
- }
+ if (option != POWER_OFF_ACT)
+ goto LOWBAT_EXIT;
+
+ if (vconf_set_int(VCONFKEY_SYSMAN_POWER_OFF_STATUS, VCONFKEY_SYSMAN_POWER_OFF_DIRECT) != 0)
+ if (system("poweroff") == -1)
+ _E("FAIL: system(\"poweroff\")");
+LOWBAT_EXIT:
/* Now get lost */
popup_terminate();
}
/* No need to pass main window ptr */
ad->popup = elm_popup_add(ad->win_main);
if (ad->popup == NULL) {
- system_print("\n System-popup : Add popup failed \n");
+ _E("System-popup : Add popup failed ");
return -1;
}
evas_object_size_hint_weight_set(ad->popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_popup_timeout_set(ad->layout_main, 3);
/* Check launch option */
- if (option == CHARGE_ERROR_ACT)
+ if (option == CHARGE_ERROR_ACT) {
elm_object_text_set(ad->popup, _("IDS_COM_BODY_CHARGING_PAUSED_DUE_TO_EXTREME_TEMPERATURE"));
- else if (option == WARNING_ACT)
- elm_object_text_set(ad->popup, _("IDS_COM_POP_BATTERYLOW"));
- else
+ elm_object_part_text_set(ad->popup, "title,text", _("IDS_ST_POP_WARNING_MSG"));
+ } else if (option == BATTERY_DISCONNECT_ACT) {
+ elm_object_text_set(ad->popup, _("IDS_COM_POP_BATTERY_DISCONNECTED_ABB"));
+ elm_object_part_text_set(ad->popup, "title,text", _("IDS_COM_BODY_NO_BATTERY"));
+ } else if (option == WARNING_ACT) {
+ elm_object_text_set(ad->popup, _("IDS_COM_POP_LOW_BATTERY_CHARGE_YOUR_PHONE"));
+ elm_object_part_text_set(ad->popup, "title,text", _("IDS_COM_POP_BATTERYLOW"));
+ } else {
elm_object_text_set(ad->popup, _("IDS_COM_POP_LOW_BATTERY_PHONE_WILL_SHUT_DOWN"));
- elm_object_part_text_set(ad->popup, "title,text", _("IDS_COM_BODY_SYSTEM_INFO_ABB"));
+ elm_object_part_text_set(ad->popup, "title,text", _("IDS_COM_POP_BATTERYLOW"));
+ }
btn1 = elm_button_add(ad->popup);
elm_object_text_set(btn1, _("IDS_COM_SK_OK"));
r = svi_init(&handle); //Initialize SVI
if ( r != SVI_SUCCESS ) {
- system_print("Cannot initialize SVI.\n");
+ _E("Cannot initialize SVI.");
return 0;
} else {
r = svi_play(handle, SVI_VIB_OPERATION_LOWBATT, SVI_SND_OPERATION_LOWBATT);
if (r != SVI_SUCCESS) {
- system_print("Cannot play sound or vibration.\n");
+ _E("Cannot play sound or vibration.");
}
r = svi_fini(handle); //Finalize SVI
if (r != SVI_SUCCESS) {
- system_print("Cannot close SVI.\n");
+ _E("Cannot close SVI.");
return 0;
}
}
return -1;
lowbatt_svi_play();
/* Change LCD brightness */
- ret_val = pm_change_state(LCD_NORMAL);
+// ret_val = display_change_state(LCD_NORMAL);
if (ret_val != 0)
return -1;
return 0;
}
+/* Terminate noti handler */
+static int app_terminate(void *data)
+{
+ struct appdata *ad = data;
+
+ if (ad->layout_main)
+ evas_object_del(ad->layout_main);
+
+ if (ad->win_main)
+ evas_object_del(ad->win_main);
+
+ return 0;
+}
+
+/* Pause/background */
+static int app_pause(void *data)
+{
+ return 0;
+}
+
+/* Resume */
+static int app_resume(void *data)
+{
+ return 0;
+}
+
+/* Reset */
+static int app_reset(bundle *b, void *data)
+{
+ struct appdata *ad = data;
+ const char *opt;
+
+ opt = bundle_get_val(b, "_SYSPOPUP_CONTENT_");
+ if (opt == NULL)
+ option = CHECK_ACT;
+ else if (!strcmp(opt,"warning"))
+ option = WARNING_ACT;
+ else if (!strcmp(opt,"poweroff"))
+ option = POWER_OFF_ACT;
+ else if (!strcmp(opt,"chargeerr"))
+ option = CHARGE_ERROR_ACT;
+ else if (!strcmp(opt,"battdisconnect"))
+ option = BATTERY_DISCONNECT_ACT;
+ else
+ option = CHECK_ACT;
+
+ if (syspopup_has_popup(b)) {
+ if (option == CHECK_ACT) {
+ return 0;
+ }
+ syspopup_reset(b);
+ } else {
+ if(option == CHECK_ACT) {
+ popup_terminate();
+ return 0;
+ }
+ syspopup_create(b, &handler, ad->win_main, ad);
+ if (option == BATTERY_DISCONNECT_ACT)
+ syspopup_reset_timeout(b, -1);
+ evas_object_show(ad->win_main);
+
+ /* Start Main UI */
+ lowbatt_start((void *)ad);
+ }
+
+ return 0;
+}
+
int main(int argc, char *argv[])
{
struct appdata ad;
memset(&ad, 0x0, sizeof(struct appdata));
ops.data = &ad;
- int val = -1, ret = -1;
-
- ret = vconf_get_int(VCONFKEY_TESTMODE_LOW_BATT_POPUP, &val);
- if(ret == 0 && val == 1) {
- system_print("Testmode without launching popup");
- return 0;
- }
-
return appcore_efl_main(PACKAGE, &argc, &argv, &ops);
}