common: divide common functions from each popup 46/17046/1
authorTaeyoung Kim <ty317.kim@samsung.com>
Mon, 3 Mar 2014 07:45:42 +0000 (16:45 +0900)
committerTaeyoung Kim <ty317.kim@samsung.com>
Mon, 3 Mar 2014 07:47:20 +0000 (16:47 +0900)
Signed-off-by: Taeyoung Kim <ty317.kim@samsung.com>
Change-Id: I8c28871eb1899060a8e8a8e4f8212ba02d4e0ee7

12 files changed:
lowbatt-popup/CMakeLists.txt
lowbatt-popup/src/lowbatt.c
lowmem-popup/CMakeLists.txt
lowmem-popup/src/lowmem.c
mmc-popup/CMakeLists.txt
mmc-popup/src/mmc.c
mmc-popup/src/mmc.h
poweroff-popup/CMakeLists.txt
poweroff-popup/src/poweroff.c
share/common.c [deleted file]
share/src/common.c [new file with mode: 0755]
share/src/common.h [moved from share/common.h with 59% similarity]

index c355ee0..ef792e6 100755 (executable)
@@ -4,7 +4,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 PROJECT(lowbatt-popup C)
 
 SET(SRCS ${CMAKE_SOURCE_DIR}/lowbatt-popup/src/lowbatt.c
-                ${CMAKE_SOURCE_DIR}/share/common.c)
+                ${CMAKE_SOURCE_DIR}/share/src/common.c)
 
 IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
        SET(CMAKE_BUILD_TYPE "Release")
@@ -12,8 +12,8 @@ ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
 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(${CMAKE_SOURCE_DIR}/lowbatt-popup/src)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/share/src)
 INCLUDE_DIRECTORIES(/usr/include/svi)
 
 INCLUDE(FindPkgConfig)
index f1e2402..6b52d96 100755 (executable)
 
 
 #include <stdio.h>
-#include <appcore-efl.h>
-#include <sensor.h>
 #include "lowbatt.h"
 #include <vconf.h>
-#include <vconf-keys.h>
-#include <Ecore_X.h>
 #include <utilX.h>
 #include <notification.h>
-#include <syspopup.h>
 #include <svi.h>
-//#include <dd-display.h>
 #include "common.h"
 
 #define CHECK_ACT                      0
@@ -61,30 +55,6 @@ static void win_del(void *data, Evas_Object * obj, void *event)
        popup_terminate();
 }
 
-/* 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) {
-               elm_win_title_set(eo, name);
-               elm_win_borderless_set(eo, EINA_TRUE);
-               evas_object_smart_callback_add(eo, "delete,request", win_del, NULL);
-               elm_win_alpha_set(eo, EINA_TRUE);
-               ecore_x_window_size_get(ecore_x_window_root_first_get(), &w,
-                                       &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;
-}
-
 /* Cleanup objects to avoid mem-leak */
 void lowbatt_cleanup(struct appdata *ad)
 {
index 727186d..94cab42 100755 (executable)
@@ -4,7 +4,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 PROJECT(lowmem-popup C)
 
 SET(SRCS ${CMAKE_SOURCE_DIR}/lowmem-popup/src/lowmem.c
-                ${CMAKE_SOURCE_DIR}/share/common.c)
+                ${CMAKE_SOURCE_DIR}/share/src/common.c)
 
 IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
        SET(CMAKE_BUILD_TYPE "Release")
@@ -12,8 +12,8 @@ ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
 MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
 
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lowmem-popup)
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/share)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lowmem-popup/src)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/share/src)
 INCLUDE_DIRECTORIES(/usr/include/svi)
 
 INCLUDE(FindPkgConfig)
index 6c410cf..64e897c 100755 (executable)
 
 
 #include <stdio.h>
-#include <appcore-efl.h>
-#include <sensor.h>
 #include "lowmem.h"
-#include <Ecore_X.h>
 #include <utilX.h>
-#include <syspopup.h>
 #include <svi.h>
-//#include <dd-display.h>
-//#include <dd-deviced.h>
-#include <vconf.h>
 #include "common.h"
 
 #define APPLICATION_BG         1
 #define INDICATOR_HEIGHT       (38)    /* the case of 480*800 */
 #define NEW_INDI
 
-#define ACCT_PROF
-#ifdef ACCT_PROF
-#include <sys/acct.h>
-#endif /* ACCT_PROF */
-
 #define PROCESS_NOTI_ACT       0
 #define LOWMEM_NOTI_ACT                1
 #define LOWMEM_LEVEL_WARNING   "warning"
@@ -77,30 +65,6 @@ static void win_del(void *data, Evas_Object *obj, void *event)
        popup_terminate();
 }
 
-/* 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) {
-               elm_win_title_set(eo, name);
-               elm_win_borderless_set(eo, EINA_TRUE);
-               evas_object_smart_callback_add(eo, "delete,request", win_del, NULL);
-               elm_win_alpha_set(eo, EINA_TRUE);
-               ecore_x_window_size_get(ecore_x_window_root_first_get(), &w,
-                               &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;
-}
-
 /* Cleanup objects to avoid mem-leak */
 void lowmem_cleanup(struct appdata *ad)
 {
index 0dc2459..7575170 100755 (executable)
@@ -3,7 +3,8 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 PROJECT(mmc-popup C)
 
-SET(SRCS ${CMAKE_SOURCE_DIR}/mmc-popup/src/mmc.c)
+SET(SRCS ${CMAKE_SOURCE_DIR}/mmc-popup/src/mmc.c
+                ${CMAKE_SOURCE_DIR}/share/src/common.c)
 
 IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
        SET(CMAKE_BUILD_TYPE "Release")
@@ -11,7 +12,8 @@ ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
 MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
 
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/mmc-popup)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/mmc-popup/src)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/share/src)
 INCLUDE_DIRECTORIES(/usr/include/svi)
 
 INCLUDE(FindPkgConfig)
index 5fcd43d..fe5e346 100755 (executable)
 
 
 #include <stdio.h>
-#include <appcore-efl.h>
-#include <sensor.h>
 #include <devman.h>
 #include <pmapi.h>
 #include <sysman.h>
 #include "mmc.h"
-#include <vconf.h>
-#include <vconf-keys.h>
-#include <Ecore_X.h>
+#include "common.h"
 #include <utilX.h>
 #include <notification.h>
 #include <syspopup.h>
@@ -52,46 +48,12 @@ 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();
 }
 
-/* Create main window */
-static Evas_Object *create_win(const char *name)
-{
-       Evas_Object *eo;
-       int w, h;
-
-       eo = elm_win_add(NULL, name, ELM_WIN_DIALOG_BASIC);
-       if (eo) {
-               elm_win_title_set(eo, name);
-               elm_win_borderless_set(eo, EINA_TRUE);
-               evas_object_smart_callback_add(eo, "delete,request", win_del, NULL);
-               elm_win_alpha_set(eo, EINA_TRUE);
-               ecore_x_window_size_get(ecore_x_window_root_first_get(), &w,
-                                       &h);
-               evas_object_resize(eo, w, h);
-       }
-
-       return eo;
-}
-
 /* Terminate noti handler */
 static int app_terminate(void *data)
 {
index bf39dbf..2a614e5 100644 (file)
 
 #define BEAT
 
-/* Acct profiling support */
-#define  ACCT_PROF
-#ifdef   ACCT_PROF
-#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_("Mmc"),},
-       {"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_mmc_H__ */
index 593d317..60bd863 100755 (executable)
@@ -4,7 +4,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 PROJECT(poweroff-popup C)
 
 SET(SRCS ${CMAKE_SOURCE_DIR}/poweroff-popup/src/poweroff.c
-                ${CMAKE_SOURCE_DIR}/share/common.c)
+                ${CMAKE_SOURCE_DIR}/share/src/common.c)
 
 IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
        SET(CMAKE_BUILD_TYPE "Release")
@@ -12,8 +12,8 @@ ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
 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(${CMAKE_SOURCE_DIR}/poweroff-popup/src)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/share/src)
 INCLUDE_DIRECTORIES(/usr/include/svi)
 
 INCLUDE(FindPkgConfig)
index 7c06de0..9b7f6eb 100755 (executable)
 
 
 #include <stdio.h>
-#include <appcore-efl.h>
-#include <sensor.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 <utilX.h>
 
-/* Time profiling support */
-#ifdef ACCT_PROF
-#include <sys/acct.h>
-#endif /* ACCT_PROF */
-
-#include <syspopup.h>
-#include <vconf.h>
-
 int create_and_show_basic_popup_min(struct appdata *ad);
 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);
@@ -65,38 +52,14 @@ static void win_del(void *data, Evas_Object * obj, void *event)
        popup_terminate();
 }
 
-/* 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) {
-               elm_win_title_set(eo, name);
-               elm_win_borderless_set(eo, EINA_TRUE);
-               evas_object_smart_callback_add(eo, "delete,request", win_del, NULL);
-               elm_win_alpha_set(eo, EINA_TRUE);
-               ecore_x_window_size_get(ecore_x_window_root_first_get(), &w,
-                                       &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;
-}
-
 /* Cleanup objects to avoid mem-leak */
 void poweroff_cleanup(struct appdata *ad)
 {
        if (!ad)
                return;
 
-       if (ad->popup_poweroff)
-               evas_object_del(ad->popup_poweroff);
+       if (ad->popup)
+               evas_object_del(ad->popup);
        if (ad->layout_main)
                evas_object_del(ad->layout_main);
 }
@@ -129,33 +92,33 @@ 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) {
+       ad->popup = elm_popup_add(ad->win_main);
+       if (ad->popup == NULL) {
                _E("System-popup : Add popup failed ");
                return -1;
        }
 
-       evas_object_size_hint_weight_set(ad->popup_poweroff, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-       elm_object_style_set(ad->popup_poweroff, "transparent");
-       elm_object_text_set(ad->popup_poweroff, _("IDS_ST_BODY_POWER_OFF"));
-       elm_object_part_text_set(ad->popup_poweroff, "title,text", _("IDS_COM_BODY_SYSTEM_INFO_ABB"));
+       evas_object_size_hint_weight_set(ad->popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       elm_object_style_set(ad->popup, "transparent");
+       elm_object_text_set(ad->popup, _("IDS_ST_BODY_POWER_OFF"));
+       elm_object_part_text_set(ad->popup, "title,text", _("IDS_COM_BODY_SYSTEM_INFO_ABB"));
 
-       btn1 = elm_button_add(ad->popup_poweroff);
+       btn1 = elm_button_add(ad->popup);
        elm_object_text_set(btn1, _("IDS_COM_SK_CANCEL"));
-       elm_object_part_content_set(ad->popup_poweroff, "button1", btn1);
+       elm_object_part_content_set(ad->popup, "button1", btn1);
        elm_object_style_set (btn1,"popup_button/default");
        evas_object_smart_callback_add(btn1, "clicked", poweroff_response_no_cb, ad);
-       btn2 = elm_button_add(ad->popup_poweroff);
+       btn2 = elm_button_add(ad->popup);
        elm_object_text_set(btn2, _("IDS_COM_SK_OK"));
-       elm_object_part_content_set(ad->popup_poweroff, "button2", btn2);
+       elm_object_part_content_set(ad->popup, "button2", btn2);
        elm_object_style_set (btn2,"popup_button/default");
        evas_object_smart_callback_add(btn2, "clicked", poweroff_response_yes_cb, ad);
 
        Ecore_X_Window xwin;
-       xwin = elm_win_xwindow_get(ad->popup_poweroff);
+       xwin = elm_win_xwindow_get(ad->popup);
        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);
+       evas_object_show(ad->popup);
        return 0;
 }
 
@@ -170,11 +133,6 @@ int poweroff_start(void *data)
        if (ret_val != 0)
                return -1;
 
-       /* Change LCD brightness */
-//     ret_val = display_change_state(LCD_NORMAL);
-       if (ret_val != 0)
-               return -1;
-
        return 0;
 }
 
diff --git a/share/common.c b/share/common.c
deleted file mode 100755 (executable)
index dcad9f8..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- *  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
- *
- * 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 "common.h"
-
-/* Terminate popup */
-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);
-}
-
-int load_normal_popup(struct appdata *ad,
-                       char *title,
-                       char *content,
-                       char *lbtnText,
-                       Evas_Smart_Cb lbtn_cb,
-                       char *rbtnText,
-                       Evas_Smart_Cb rbtn_cb)
-{
-       Evas_Object *lbtn;
-       Evas_Object *rbtn;
-       Ecore_X_Window xwin;
-
-       if (!ad || !(ad->win_main) || !content)
-               return -EINVAL;
-
-       evas_object_show(ad->win_main);
-       ad->popup = elm_popup_add(ad->win_main);
-       evas_object_size_hint_weight_set(ad->popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-       elm_object_style_set(ad->popup, "transparent");
-       elm_object_text_set(ad->popup, content);
-
-       if (title) {
-               /* Popup title */
-               elm_object_part_text_set(ad->popup, "title,text", title);
-       }
-
-       if (lbtnText && lbtn_cb) {
-               /* Left button */
-               lbtn = elm_button_add(ad->popup);
-               elm_object_text_set(lbtn, lbtnText);
-               elm_object_part_content_set(ad->popup, "button1", lbtn);
-               evas_object_smart_callback_add(lbtn, "clicked", lbtn_cb, ad);
-       }
-
-       if (rbtnText && rbtn_cb) {
-               /* Right button */
-               rbtn = elm_button_add(ad->popup);
-               elm_object_text_set(rbtn, rbtnText);
-               elm_object_part_content_set(ad->popup, "button2", rbtn);
-               evas_object_smart_callback_add(rbtn, "clicked", rbtn_cb, ad);
-       }
-
-       xwin = elm_win_xwindow_get(ad->popup);
-       ecore_x_netwm_window_type_set(xwin, ECORE_X_WINDOW_TYPE_NOTIFICATION);
-
-       evas_object_show(ad->popup);
-
-       return 0;
-}
-
diff --git a/share/src/common.c b/share/src/common.c
new file mode 100755 (executable)
index 0000000..f6b5eb5
--- /dev/null
@@ -0,0 +1,490 @@
+/*
+ *  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
+ *
+ * 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 <E_DBus.h>
+#include <pthread.h>
+#include <pmapi.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+#include "common.h"
+
+#define RETRY_MAX 10
+#define DBUS_REPLY_TIMEOUT  (-1)
+
+/* Terminate popup */
+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);
+}
+
+/* Release evas object */
+void release_evas_object(Evas_Object **obj)
+{
+       if (!obj || !(*obj))
+               return;
+       evas_object_del(*obj);
+       *obj = NULL;
+}
+
+void object_cleanup(struct appdata *ad)
+{
+       if (!ad)
+               return;
+       release_evas_object(&(ad->popup));
+       release_evas_object(&(ad->layout_main));
+       release_evas_object(&(ad->win_main));
+}
+
+/* Create main window */
+static void win_del(void *data, Evas_Object * obj, void *event)
+{
+       popup_terminate();
+}
+
+Evas_Object *create_win(const char *name)
+{
+       Evas_Object *eo;
+       Ecore_X_Window xwin;
+       unsigned int val = 1;
+       int w;
+       int h;
+
+       if (!name)
+               return NULL;
+
+       eo = elm_win_add(NULL, name, ELM_WIN_DIALOG_BASIC);
+       if (!eo) {
+               _E("FAIL: elm_win_add()");
+               return NULL;
+       }
+
+       elm_win_title_set(eo, name);
+       elm_win_borderless_set(eo, EINA_TRUE);
+       elm_win_alpha_set(eo, EINA_TRUE);
+       elm_win_raise(eo);
+       evas_object_smart_callback_add(eo, "delete,request", win_del, NULL);
+       ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &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;
+}
+
+Evas_Object *load_scrollable_popup(struct appdata *ad,
+                       char *title,
+                       char *content,
+                       char *lbtnText,
+                       Evas_Smart_Cb lbtn_cb,
+                       char *rbtnText,
+                       Evas_Smart_Cb rbtn_cb)
+{
+       Evas_Object *lbtn;
+       Evas_Object *rbtn;
+       Evas_Object *popup;
+       Evas_Object *label;
+       Evas_Object *scroller;
+       char *text;
+
+       if (!ad || !(ad->win_main) || !content)
+               return NULL;
+
+       evas_object_show(ad->win_main);
+       popup = elm_popup_add(ad->win_main);
+       if (!popup)
+               return NULL;
+       evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+       if (title)
+               elm_object_part_text_set(popup, "title,text", title);
+
+       scroller = elm_scroller_add(popup);
+       if (!scroller)
+               return NULL;
+       evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       elm_object_content_set(popup, scroller);
+       evas_object_show(scroller);
+
+       label = elm_label_add(scroller);
+       if (!label)
+               return NULL;
+       elm_object_style_set(label, "popup/default");
+       elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
+
+       text = elm_entry_utf8_to_markup(content);
+       if (!text)
+               return NULL;
+       elm_object_text_set(label, text);
+       free(text);
+       evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
+       elm_object_content_set(scroller, label);
+       evas_object_show(label);
+
+       if (lbtnText && lbtn_cb) {
+               /* Left button */
+               lbtn = elm_button_add(popup);
+               if (lbtn) {
+                       elm_object_text_set(lbtn, lbtnText);
+                       elm_object_style_set(lbtn, "popup");
+                       elm_object_part_content_set(popup, "button1", lbtn);
+                       evas_object_smart_callback_add(lbtn, "clicked", lbtn_cb, ad);
+               }
+       }
+
+       if (rbtnText && rbtn_cb) {
+               /* Right button */
+               rbtn = elm_button_add(popup);
+               if (rbtn) {
+                       elm_object_text_set(rbtn, rbtnText);
+                       elm_object_style_set(rbtn, "popup");
+                       elm_object_part_content_set(popup, "button2", rbtn);
+                       evas_object_smart_callback_add(rbtn, "clicked", rbtn_cb, ad);
+               }
+       }
+
+       evas_object_show(popup);
+
+       return popup;
+}
+
+Evas_Object *load_popup_by_style(struct appdata *ad,
+                       char *style,
+                       char *title,
+                       char *content,
+                       char *lbtnText,
+                       Evas_Smart_Cb lbtn_cb,
+                       char *rbtnText,
+                       Evas_Smart_Cb rbtn_cb)
+{
+       Evas_Object *lbtn;
+       Evas_Object *rbtn;
+       Evas_Object *popup;
+       Ecore_X_Window xwin;
+
+       if (!ad || !(ad->win_main) || !content)
+               return NULL;
+
+       evas_object_show(ad->win_main);
+       popup = elm_popup_add(ad->win_main);
+       evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+       if (style)
+               elm_object_style_set(popup, style);
+
+       elm_object_text_set(popup, content);
+
+       if (title) {
+               /* Popup title */
+               elm_object_part_text_set(popup, "title,text", title);
+       }
+
+       if (lbtnText && lbtn_cb) {
+               /* Left button */
+               lbtn = elm_button_add(popup);
+               elm_object_text_set(lbtn, lbtnText);
+               elm_object_style_set(lbtn, "popup");
+               elm_object_part_content_set(popup, "button1", lbtn);
+               evas_object_smart_callback_add(lbtn, "clicked", lbtn_cb, ad);
+       }
+
+       if (rbtnText && rbtn_cb) {
+               /* Right button */
+               rbtn = elm_button_add(popup);
+               elm_object_text_set(rbtn, rbtnText);
+               elm_object_style_set(rbtn, "popup");
+               elm_object_part_content_set(popup, "button2", rbtn);
+               evas_object_smart_callback_add(rbtn, "clicked", rbtn_cb, ad);
+       }
+
+       xwin = elm_win_xwindow_get(popup);
+       ecore_x_netwm_window_type_set(xwin, ECORE_X_WINDOW_TYPE_NOTIFICATION);
+
+       evas_object_show(popup);
+
+       return popup;
+}
+
+Evas_Object *load_normal_popup(struct appdata *ad,
+                       char *title,
+                       char *content,
+                       char *lbtnText,
+                       Evas_Smart_Cb lbtn_cb,
+                       char *rbtnText,
+                       Evas_Smart_Cb rbtn_cb)
+{
+       return load_popup_by_style(ad,
+                       "transparent",
+                       title, content,
+                       lbtnText, lbtn_cb,
+                       rbtnText, rbtn_cb);
+}
+
+Evas_Object *load_popup_with_vertical_buttons(struct appdata *ad,
+                       char *title,
+                       char *content,
+                       char *ubtnText,
+                       Evas_Smart_Cb ubtn_cb,
+                       char *dbtnText,
+                       Evas_Smart_Cb dbtn_cb)
+{
+       Evas_Object *popup = NULL;
+
+       popup =  load_popup_by_style(ad,
+                       "verticalbuttonstyle",
+                       title, content,
+                       ubtnText, ubtn_cb,
+                       dbtnText, dbtn_cb);
+       if (!popup) {
+               _E("Failed to make popup");
+               return NULL;
+       }
+
+       elm_layout_signal_emit(popup, "elm,state,2button", "elm");
+       return popup;
+}
+
+static int append_variant(DBusMessageIter *iter, const char *sig, char *param[])
+{
+       char *ch;
+       int i;
+       int iValue;
+
+       if (!sig || !param)
+               return 0;
+
+       for (ch = (char*)sig, i = 0; *ch != '\0'; ++i, ++ch) {
+               switch (*ch) {
+               case 'i':
+                       iValue = atoi(param[i]);
+                       dbus_message_iter_append_basic(iter, DBUS_TYPE_INT32, &iValue);
+                       break;
+               case 's':
+                       dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &param[i]);
+                       break;
+               default:
+                       return -EINVAL;
+               }
+       }
+       return 0;
+}
+
+int broadcast_dbus_signal(const char *path, const char *interface,
+               const char *name, const char *sig, char *param[])
+{
+       E_DBus_Connection *conn = NULL;
+       DBusPendingCall *pc;
+       DBusMessageIter iter;
+       DBusMessage *msg;
+       int ret, retry;
+
+       retry = 0;
+       do {
+               ret = e_dbus_init();
+               if (ret > 0)
+                       break;
+               if (retry == RETRY_MAX) {
+                       _E("FAIL: e_dbus_init()");
+                       return -ENOMEM;
+               }
+               retry++;
+       } while (retry < RETRY_MAX);
+
+       if (!path || !interface || !name)
+               return -EINVAL;
+
+       conn = e_dbus_bus_get(DBUS_BUS_SYSTEM);
+       if (!conn) {
+               _E("FAIL: e_dbus_bus_get()");
+               return -ENOENT;
+       }
+
+       msg = dbus_message_new_signal(path, interface, name);
+       if (!msg) {
+               _E("FAIL: dbus_message_new_signal()");
+               ret = -ENOMEM;
+               goto out_conn;
+       }
+
+       dbus_message_iter_init_append(msg, &iter);
+       ret = append_variant(&iter, sig, param);
+       if (ret < 0) {
+               _E("append_variant error(%d)", ret);
+               goto out_msg_conn;
+       }
+
+       pc = e_dbus_message_send(conn, msg, NULL, -1, NULL);
+       if (!pc) {
+               _E("FAIL: e_dbus_message_send()");
+               ret = -ECONNREFUSED;
+               goto out_msg_conn;
+       }
+
+       ret = 0;
+
+out_msg_conn:
+       dbus_message_unref(msg);
+out_conn:
+       e_dbus_connection_close(conn);
+       e_dbus_shutdown();
+       return ret;
+}
+
+static int make_thread(void *data, void *(*start_thread)(void* data))
+{
+       pthread_t th;
+       int ret;
+
+       ret = pthread_create(&th, NULL, start_thread, data);
+       if (ret < 0) {
+               _E("Failed to create pthread(%d)", ret);
+               return ret;
+       }
+       pthread_detach(th);
+
+       return 0;
+}
+
+static void *start_thread_display(void* data)
+{
+       if (pm_change_state(LCD_NORMAL) < 0)
+               _E("FAIL: display_change_state()");
+
+       return NULL;
+}
+
+void set_display(void)
+{
+       if (make_thread(NULL, start_thread_display) < 0)
+               _E("Failed to make thread");
+}
+
+static int dbus_method_sync(const char *dest, const char *path,
+               const char *interface, const char *method,
+               const char *sig, char *param[])
+{
+       DBusConnection *conn = NULL;
+       DBusMessage *msg = NULL;
+       DBusMessageIter iter;
+       DBusMessage *reply = NULL;
+       DBusError err;
+       int ret, result;
+
+       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+       if (!conn) {
+               _E("dbus_bus_get error");
+               return -EPERM;
+       }
+
+       msg = dbus_message_new_method_call(dest, path, interface, method);
+       if (!msg) {
+               _E("dbus_message_new_method_call(%s:%s-%s)", path, interface, method);
+               ret = -EBADMSG;
+               goto out;
+       }
+
+       dbus_message_iter_init_append(msg, &iter);
+       ret = append_variant(&iter, sig, param);
+       if (ret < 0) {
+               _E("append_variant error(%d)", ret);
+               goto out;
+       }
+
+       dbus_error_init(&err);
+
+       reply = dbus_connection_send_with_reply_and_block(conn, msg, DBUS_REPLY_TIMEOUT, &err);
+       if (!reply) {
+               _E("dbus_connection_send error(%s:%s)", err.name, err.message);
+               dbus_error_free(&err);
+               ret = -ECOMM;
+               goto out;
+       }
+
+       ret = dbus_message_get_args(reply, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
+       if (!ret) {
+               _E("no message : [%s:%s]", err.name, err.message);
+               dbus_error_free(&err);
+               ret = -ENOMSG;
+               goto out;
+       }
+
+       ret = result;
+
+out:
+       if (msg)
+               dbus_message_unref(msg);
+       if (reply)
+               dbus_message_unref(reply);
+       if (conn)
+               dbus_connection_unref(conn);
+       return ret;
+}
+
+int reset_window_priority(Evas_Object *win, int priority)
+{
+       Ecore_X_Window xwin;
+       Display *dpy;
+
+       if (priority < 0 || priority > 2)
+               return -EINVAL;
+
+       xwin = elm_win_xwindow_get(win);
+       dpy = ecore_x_display_get();
+
+       utilx_set_system_notification_level(dpy, xwin, priority);
+
+       return 0;
+}
+
+int set_popup_focus(Evas_Object *win, bool focus)
+{
+       XWMHints *hints;
+       Display *dpy;
+       Ecore_X_Window xwin;
+
+       hints = XAllocWMHints();
+       if (!hints) {
+               _E("Failed to allocate WWMHints");
+               return -ENOMEM;
+       }
+
+       dpy = ecore_x_display_get();
+       xwin = elm_win_xwindow_get(win);
+
+       hints->flags = InputHint | StateHint;
+       if (focus)
+               hints->input = 1;
+       else
+               hints->input = 0;
+       hints->initial_state = NormalState;
+       XSetWMHints(dpy, xwin, hints);
+       XFree(hints);
+
+       return 0;
+}
similarity index 59%
rename from share/common.h
rename to share/src/common.h
index c7b5c16..c4deafc 100644 (file)
 #include <appcore-efl.h>
 #include <Elementary.h>
 #include <utilX.h>
-#include <syspopup.h>
 #include <dlog.h>
+#include <bundle.h>
+#include <glib.h>
+#include <syspopup.h>
+#include <syspopup_caller.h>
 
 #undef LOG_TAG
-#define LOG_TAG "SYSTEM_POPUP"
+#define LOG_TAG "SYSTEM_APPS"
 #define _D(fmt, args...)   SLOGD(fmt, ##args)
 #define _E(fmt, args...)   SLOGE(fmt, ##args)
 #define _I(fmt, args...)   SLOGI(fmt, ##args)
 
+#define LANG_DOMAIN "system-apps"
+#define LOCALE_DIR  "/usr/share/locale"
+
 #define FREE(arg) \
        do { \
                if(arg) { \
                } \
        } while (0);
 
+#define ARRAY_SIZE(name) (sizeof(name)/sizeof(name[0]))
+
+#define max(a,b) \
+       ({ __typeof__ (a) _a = (a); \
+          __typeof__ (b) _b = (b);  \
+          _a > _b ? _a : _b; })
+
 struct appdata {
        /* Common */
        Evas_Object *win_main;
        Evas_Object *layout_main;
        Evas_Object *popup;
        bundle      *b;
-       syspopup_handler handler;
 
-       /* For poweroff popup */
-       Evas_Object *popup_poweroff;
-       Evas_Object *popup_access;
-       Evas_Object *popup_notification;
-       Evas_Object *popup_chk;
-       Evas_Object *list;
-       Evas_Object *list_access;
+       syspopup_handler handler;
 
        /* For usbotg popup */
        Evas_Object *storage_added_popup;
@@ -72,7 +78,24 @@ struct appdata {
 };
 
 void popup_terminate(void);
-int load_normal_popup(struct appdata *ad,
+void release_evas_object(Evas_Object **obj);
+void object_cleanup(struct appdata *ad);
+Evas_Object *create_win(const char *name);
+Evas_Object *load_normal_popup(struct appdata *ad,
+               char *title,
+               char *content,
+               char *lbtnText,
+               Evas_Smart_Cb lbtn_cb,
+               char *rbtnText,
+               Evas_Smart_Cb rbtn_cb);
+Evas_Object *load_popup_with_vertical_buttons(struct appdata *ad,
+               char *title,
+               char *content,
+               char *ubtnText,
+               Evas_Smart_Cb ubtn_cb,
+               char *dbtnText,
+               Evas_Smart_Cb dbtn_cb);
+Evas_Object *load_scrollable_popup(struct appdata *ad,
                char *title,
                char *content,
                char *lbtnText,
@@ -80,5 +103,17 @@ int load_normal_popup(struct appdata *ad,
                char *rbtnText,
                Evas_Smart_Cb rbtn_cb);
 
+void set_display(void);
+
+/* Send dbus signal */
+int broadcast_dbus_signal(const char *path,
+               const char *interface,
+               const char *name,
+               const char *sig,
+               char *param[]);
+
+int reset_window_priority(Evas_Object *win, int priority);
+int set_popup_focus(Evas_Object *win, bool focus);
+
 
 #endif                         /* __COMMON_H__ */