Remove Unnecessary codes of low battery popup 99/15799/1
authorTaeyoung Kim <ty317.kim@samsung.com>
Tue, 28 Jan 2014 12:04:39 +0000 (21:04 +0900)
committerTaeyoung Kim <ty317.kim@samsung.com>
Tue, 28 Jan 2014 12:05:37 +0000 (21:05 +0900)
Signed-off-by: Taeyoung Kim <ty317.kim@samsung.com>
Change-Id: I065494164747f1cedb9e18582c7decd85a7a5d6f

lowbatt-popup/CMakeLists.txt
lowbatt-popup/src/lowbatt.c
lowbatt-popup/src/lowbatt.h
packaging/system-popup.spec

index 242a11db547a6e4a405a82f3c56b4fa4c2e47620..c355ee07a7554886ec05fd464906c0e01730cbad 100755 (executable)
@@ -3,7 +3,8 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 PROJECT(lowbatt-popup C)
 
-SET(SRCS ${CMAKE_SOURCE_DIR}/lowbatt-popup/src/lowbatt.c)
+SET(SRCS ${CMAKE_SOURCE_DIR}/lowbatt-popup/src/lowbatt.c
+                ${CMAKE_SOURCE_DIR}/share/common.c)
 
 IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
        SET(CMAKE_BUILD_TYPE "Release")
@@ -12,10 +13,11 @@ MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
 
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lowbatt-popup)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/share)
 INCLUDE_DIRECTORIES(/usr/include/svi)
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED appcore-efl elementary devman devman_haptic mm-sound notification sysman)
+pkg_check_modules(pkgs REQUIRED appcore-efl elementary notification deviced dlog)
 
 FOREACH(flag ${pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag} -g")
@@ -41,7 +43,7 @@ ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
 TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} "-lsvi")
 
 ADD_CUSTOM_TARGET(lowbatt.edj
-               COMMAND edje_cc -id ${CMAKE_SOURCE_DIR}/../images
+               COMMAND edje_cc -id ${CMAKE_SOURCE_DIR}/edcs/icons
                ${CMAKE_SOURCE_DIR}/edcs/lowbatt.edc ${CMAKE_BINARY_DIR}/${PROJECT_NAME}/lowbatt.edj
                DEPENDS ${CMAKE_SOURCE_DIR}/edcs/lowbatt.edc
 )
index eb0653ea14bb640a3cf928161cb7f3d80dc92e97..f1e2402f606a34e95efb0ad8559132098131959f 100755 (executable)
@@ -1,5 +1,7 @@
 /*
- * 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;
 
@@ -45,7 +47,6 @@ int myterm(bundle *b, void *data)
 
 int mytimeout(bundle *b, void *data)
 {
-       lowbatt_timeout_func(data);
        return 0;
 }
 
@@ -54,66 +55,19 @@ syspopup_handler handler = {
        .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) {
@@ -125,106 +79,12 @@ static Evas_Object *create_win(const char *name)
                                        &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)
 {
@@ -237,40 +97,19 @@ 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();
 }
@@ -284,7 +123,7 @@ static int lowbatt_create_and_show_basic_popup(struct appdata *ad)
        /* 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);
@@ -293,13 +132,19 @@ static int lowbatt_create_and_show_basic_popup(struct appdata *ad)
        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"));
@@ -322,16 +167,16 @@ static int lowbatt_svi_play(void)
        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;
                }
        }
@@ -348,7 +193,7 @@ int lowbatt_start(void *data)
                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;
 
@@ -373,6 +218,74 @@ int app_create(void *data)
        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;
@@ -389,13 +302,5 @@ int main(int argc, char *argv[])
        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);
 }
index 69e3b18eec9843c41989ec30f7c7d69789030db0..b72d075b8e049353c7f875d2eacf749b533624af 100644 (file)
@@ -1,6 +1,8 @@
 /*
- * 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.
  * You may obtain a copy of the License at
@@ -12,6 +14,7 @@
  * 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.
+ *
  */
 
 
@@ -27,8 +30,6 @@
 #define TEMP_DIR                       "/tmp"
 #define PACKAGE                                "lowbatt-popup"
 #define APPNAME                                "lowbatt-popup"
-#define ICON_DIR                       PREFIX"/apps/org.tizen.lowbat-syspopup/res/images"
-#define BG_IMAGE                       TEMP_DIR"/01_popup_bg.jpg"
 #define MAIN_W                         (480)
 #define MAIN_H                         (800)
 #define EDJ_PATH                       PREFIX"/apps/org.tizen.lowbat-syspopup/res/edje/lowbatt"
@@ -42,7 +43,7 @@
 #ifndef PREDEF_POWEROFF
 #define PREDEF_POWEROFF                        "poweroff"
 #endif /* PREFEF_POWEROFF */
-       
+
 #define BEAT
 
 /* Acct profiling support */
 #include <sys/acct.h>
 #endif /* ACCT_PROF */
 
-/* Text layout */
-struct text_part {
-       char *part;
-       char *msgid;
-};
-
-/* Main text */
-struct text_part main_txt[] = {
-       {"txt_title", N_("Lowbatt"),},
-       {"txt_mesg", N_(""),},
-};
-
-struct appdata {
-       Evas *evas;
-       Evas_Object *win_main;
-       Evas_Object *popup;
-       Evas_Object *layout_main;
-
-       Evas_Object *root_w;
-       Evas_Object *root_h;
-       Evas_Object *bg;
-       Evas_Object *indicator;
-
-       double w_ratio;
-       double h_ratio;
-
-};
-
 #endif                         /* __DEF_lowbatt_H__ */
index 2d6cb4dce9943e16a02eeb4650d0394257be0020..37cc55de2b3f39966478450e82a6481f628e8456 100755 (executable)
@@ -23,6 +23,7 @@ BuildRequires:  pkgconfig(ecore-input)
 BuildRequires:  pkgconfig(ethumb)
 BuildRequires:  pkgconfig(elementary)
 BuildRequires:  pkgconfig(efreet)
+BuildRequires:  pkgconfig(deviced)
 BuildRequires:  pkgconfig(sysman)
 BuildRequires:  pkgconfig(mm-sound)
 BuildRequires:  pkgconfig(sensor)