Remove Unnecessary codes of poweroff popup 03/15803/1
authorTaeyoung Kim <ty317.kim@samsung.com>
Tue, 28 Jan 2014 13:04:45 +0000 (22:04 +0900)
committerTaeyoung Kim <ty317.kim@samsung.com>
Tue, 28 Jan 2014 13:05:32 +0000 (22:05 +0900)
Signed-off-by: Taeyoung Kim <ty317.kim@samsung.com>
Change-Id: I2490be4a5cb0482699c531fac4bd2e1ecb26c412

poweroff-popup/CMakeLists.txt
poweroff-popup/src/poweroff.c
poweroff-popup/src/poweroff.h

index 3228329..593d317 100755 (executable)
@@ -3,7 +3,8 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 PROJECT(poweroff-popup C)
 
-SET(SRCS ${CMAKE_SOURCE_DIR}/poweroff-popup/src/poweroff.c)
+SET(SRCS ${CMAKE_SOURCE_DIR}/poweroff-popup/src/poweroff.c
+                ${CMAKE_SOURCE_DIR}/share/common.c)
 
 IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
        SET(CMAKE_BUILD_TYPE "Release")
@@ -12,10 +13,12 @@ MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
 
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/poweroff-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 syspopup syspopup-caller
-mm-keysound sysman utilX bundle pmapi evas ecore-evas notification vconf ecore-input appsvc)
+pkg_check_modules(pkgs REQUIRED appcore-efl elementary syspopup syspopup-caller dlog devman sysman pmapi
+deviced utilX bundle evas ecore-evas notification vconf ecore-input appsvc)
 
 FOREACH(flag ${pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag} -g")
@@ -38,10 +41,10 @@ ADD_DEFINITIONS("-DSLP_DEBUG")
 SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
 
 ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} "-lsvi")
 
 ADD_CUSTOM_TARGET(poweroff.edj
-               COMMAND edje_cc -id ${CMAKE_SOURCE_DIR}/images
+               COMMAND edje_cc -id ${CMAKE_SOURCE_DIR}/edcs/icons
                ${CMAKE_SOURCE_DIR}/edcs/poweroff.edc ${CMAKE_BINARY_DIR}/${PROJECT_NAME}/poweroff.edj
                DEPENDS ${CMAKE_SOURCE_DIR}/edcs/poweroff.edc
 )
index 33f9ae0..7c06de0 100755 (executable)
@@ -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
  * 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 <devman_haptic.h>
-#include <pmapi.h>
+//#include <dd-deviced.h>
+//#include <dd-display.h>
+#include <svi.h>
 #include <sysman.h>
 #include "poweroff.h"
+#include "common.h"
 
 #include <Ecore_X.h>
 #include <Ecore_Input.h>
 #include <vconf.h>
 
 int create_and_show_basic_popup_min(struct appdata *ad);
-void poweroff_response_yes_cb_min(void *data, Evas_Object * obj, void *event_info);
-void poweroff_response_no_cb_min(void *data, Evas_Object * obj, void *event_info);
-static void poweroff_popup_direct_cancel(keynode_t *key, void *data);
-static void poweroff_callstate_changed_cb(keynode_t *key, void *data);
+void poweroff_response_yes_cb(void *data, Evas_Object * obj, void *event_info);
+void poweroff_response_no_cb(void *data, Evas_Object * obj, void *event_info);
 
 int myterm(bundle *b, void *data)
 {
@@ -57,66 +59,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) {
@@ -128,94 +83,15 @@ 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;
-
-       if (syspopup_has_popup(b)) {
-               syspopup_reset(b);
-       } else {
-               syspopup_create(b, &handler, ad->win_main, ad);
-               evas_object_show(ad->win_main);
-
-               /* Start Main UI */
-               poweroff_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 poweroff_cleanup(struct appdata *ad)
 {
-       vconf_ignore_key_changed(VCONFKEY_PM_STATE,(void*)poweroff_popup_direct_cancel);
-       vconf_ignore_key_changed(VCONFKEY_CALL_STATE, poweroff_callstate_changed_cb);
-
        if (!ad)
                return;
 
@@ -225,70 +101,37 @@ void poweroff_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 : In BG Noti \n");
-       fflush(stdout);
-       popup_terminate();
-}
-
-static void poweroff_popup_direct_cancel(keynode_t *key, void *data)
-{
-       int val;
-       struct appdata *ad = data;
-
-       val = vconf_keynode_get_int(key);
-       if (val != VCONFKEY_PM_STATE_LCDOFF)
-               return;
-
-       poweroff_cleanup(ad);
-       popup_terminate();
-}
-void poweroff_response_yes_cb_min(void *data, Evas_Object * obj, void *event_info)
+void poweroff_response_yes_cb(void *data, Evas_Object * obj, void *event_info)
 {
        static int bPowerOff = 0;
        if (1 == bPowerOff)
                return;
        bPowerOff = 1;
-       system_print("System-popup : Switching off phone !! Bye Bye \n");
+       _I("System-popup : Switching off phone !! Bye Bye");
        /* This will cleanup the memory */
        poweroff_cleanup(data);
 
        if (sysman_call_predef_action(PREDEF_POWEROFF, 0) == -1) {
-               system_print("System-popup : failed to request poweroff to system_server \n");
+               _E("System-popup : failed to request poweroff to system_server");
                system("poweroff");
        }
 }
 
-void poweroff_response_no_cb_min(void *data, Evas_Object * obj, void *event_info)
+void poweroff_response_no_cb(void *data, Evas_Object * obj, void *event_info)
 {
-       system_print("\nSystem-popup: Option is Wrong");
+       _I("System-popup: Option is Wrong");
        poweroff_cleanup(data);
        popup_terminate();
 }
 
-static void poweroff_callstate_changed_cb(keynode_t *key, void *data)
-{
-       int state;
-       struct appdata *ad = data;
-
-       state = vconf_keynode_get_int(key);
-       if (state == VCONFKEY_CALL_OFF)
-               return;
-
-       poweroff_cleanup(ad);
-       popup_terminate();
-}
-
-int create_and_show_basic_popup_min(struct appdata *ad)
+int create_and_show_basic_popup(struct appdata *ad)
 {
        Evas_Object *btn1;
        Evas_Object *btn2;
 
        ad->popup_poweroff = elm_popup_add(ad->win_main);
        if (ad->popup_poweroff == NULL) {
-               system_print("\n System-popup : Add popup failed \n");
+               _E("System-popup : Add popup failed ");
                return -1;
        }
 
@@ -301,60 +144,21 @@ int create_and_show_basic_popup_min(struct appdata *ad)
        elm_object_text_set(btn1, _("IDS_COM_SK_CANCEL"));
        elm_object_part_content_set(ad->popup_poweroff, "button1", btn1);
        elm_object_style_set (btn1,"popup_button/default");
-       evas_object_smart_callback_add(btn1, "clicked", poweroff_response_no_cb_min, ad);
+       evas_object_smart_callback_add(btn1, "clicked", poweroff_response_no_cb, ad);
        btn2 = elm_button_add(ad->popup_poweroff);
        elm_object_text_set(btn2, _("IDS_COM_SK_OK"));
        elm_object_part_content_set(ad->popup_poweroff, "button2", btn2);
        elm_object_style_set (btn2,"popup_button/default");
-       evas_object_smart_callback_add(btn2, "clicked", poweroff_response_yes_cb_min, ad);
+       evas_object_smart_callback_add(btn2, "clicked", poweroff_response_yes_cb, ad);
 
        Ecore_X_Window xwin;
        xwin = elm_win_xwindow_get(ad->popup_poweroff);
        ecore_x_netwm_window_type_set(xwin, ECORE_X_WINDOW_TYPE_NOTIFICATION);
        utilx_grab_key(ecore_x_display_get(), xwin, KEY_SELECT, SHARED_GRAB);
        evas_object_show(ad->popup_poweroff);
-       vconf_notify_key_changed(VCONFKEY_PM_STATE, poweroff_popup_direct_cancel, ad);
-       vconf_notify_key_changed(VCONFKEY_CALL_STATE, poweroff_callstate_changed_cb, ad);
-
        return 0;
 }
 
-static void bg_noti_cb(void *data)
-{
-       ui_bgimg_reload((Evas_Object *) data);
-}
-
-/* Create indicator bar */
-static int poweroff_create_indicator(struct appdata *ad)
-{
-
-       elm_win_indicator_mode_set(ad->win_main, ELM_WIN_INDICATOR_HIDE);
-       return 0;
-}
-
-/* Play vibration */
-static int poweroff_play_vibration()
-{
-
-       int ret_val = 0;
-       int dev_handle = 0;
-       int mode = 0;
-
-       /* Open the haptic device */
-       dev_handle = device_haptic_open(DEV_IDX_0, mode);
-       if (dev_handle < 0)
-               return -1;
-
-       /* Play a monotone pattern for 1s */
-       ret_val = device_haptic_play_monotone(dev_handle, 1000);
-       device_haptic_close(dev_handle);
-       if (ret_val < 0)
-               return -1;
-
-       return 0;
-
-}
-
 /* Start UI */
 int poweroff_start(void *data)
 {
@@ -362,20 +166,15 @@ int poweroff_start(void *data)
        int ret_val = 0;
 
        /* Create and show popup */
-       ret_val = create_and_show_basic_popup_min(ad);
+       ret_val = create_and_show_basic_popup(ad);
        if (ret_val != 0)
                return -1;
 
        /* Change LCD brightness */
-       ret_val = pm_change_state(LCD_NORMAL);
+//     ret_val = display_change_state(LCD_NORMAL);
        if (ret_val != 0)
                return -1;
 
-       /* Play a vibration for 1 sec */
-       ret_val = poweroff_play_vibration();
-       if (ret_val == -1)
-               system_print("\n Poweroff : Play vibration Failed \n");
-
        return 0;
 }
 
@@ -398,6 +197,51 @@ 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;
+
+       if (syspopup_has_popup(b)) {
+               syspopup_reset(b);
+       } else {
+               syspopup_create(b, &handler, ad->win_main, ad);
+               evas_object_show(ad->win_main);
+
+               /* Start Main UI */
+               poweroff_start((void *)ad);
+       }
+
+       return 0;
+}
+
 int main(int argc, char *argv[])
 {
        struct appdata ad;
index b9c63f1..4a23e6b 100644 (file)
@@ -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.
@@ -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.
+ *
  */
 
 
 #ifndef PREFIX
 #define PREFIX "/usr"
 #endif
-#define TEMP_DIR "/tmp"
 #define PACKAGE "poweroff-popup"
 #define APPNAME "poweroff-popup"
-#define ICON_DIR PREFIX"/apps/org.tizen.poweroff-syspopup/res/images"
-#define BG_IMAGE TEMP_DIR"/01_popup_bg.jpg"
 #define EDJ_PATH PREFIX"/apps/org.tizen.poweroff-syspopup/res/edje/poweroff"
 #define EDJ_NAME EDJ_PATH"/poweroff.edj"
 #define GRP_MAIN "main"
 #define TITLE_BUF_LEN  128
 #define CONTENT_BUF_LEN        256
 
-/* Popup Response */
-enum {
-       POPUP_RESPONSE_YES = 0,
-       POPUP_RESPONSE_NO,
-       POPUP_RESPONSE_SLEEP
-} response;
-
-/* Text layout */
-struct text_part {
-       char *part;
-       char *msgid;
-};
-
-/* Text part */
-static struct text_part main_txt[] = {
-       {"txt_title", N_("Poweroff"),},
-       {"txt_mesg", N_(""),},
-};
-
-/* Main UI structure */
-struct appdata {
-       Evas *evas;
-       Evas_Object *win_main;
-       Evas_Object *layout_main;
-       Evas_Object *popup;
-       Evas_Object *popup_poweroff;
-       Evas_Object *popup_access;
-       Evas_Object *genlist;
-       Evas_Object *genlist_access;
-
-       Evas_Object *root_w;
-       Evas_Object *root_h;
-       Evas_Object *bg;
-       Evas_Object *indicator;
-       bundle *b;
-
-       /* Added for syspopup */
-       Evas_Object *title;
-       Evas_Object *content;
-
-       Elm_Genlist_Item_Class itc;
-       Elm_Genlist_Item_Class itc1;
-
-       double w_ratio;
-       double h_ratio;
-
-};
-
 #endif                         /* __DEF_poweroff_H__ */