From ff0f4203667c73b3fcb43ba8c421b31c47c284c2 Mon Sep 17 00:00:00 2001 From: "jk7744.park" Date: Sat, 24 Oct 2015 16:34:27 +0900 Subject: [PATCH] tizen 2.4 release --- CMakeLists.txt | 2 +- TC/build.sh | 20 --- TC/execute.sh | 19 --- TC/tet_code | 12 -- TC/tet_scen | 7 - TC/tetbuild.cfg | 3 - TC/tetclean.cfg | 2 - TC/tetexec.cfg | 1 - TC/unit/Makefile | 21 --- TC/unit/tc_gen.sh | 28 ---- TC/unit/tslist | 1 - TC/unit/utc_MODULE_API_func.c.in | 64 --------- data/mobile/syspopup_db.sql | 14 +- data/wearable/syspopup_db.sql | 1 - packaging/syspopup.spec | 15 +- src/syspopup_core.c | 71 ++++------ syspopup-app/CMakeLists.txt | 2 +- syspopup-app/syspopup-app.c | 279 ++++++++++++++++++-------------------- syspopup-app/syspopup-app.h | 23 +++- syspopup-caller/CMakeLists.txt | 2 +- syspopup-caller/syspopup_caller.c | 146 ++++++++++++++++---- syspopup/CMakeLists.txt | 2 +- syspopup/syspopup.c | 4 +- syspopup/syspopup.pc.in | 4 +- syspopup/syspopup_efl.c | 1 - test/test.c | 1 + 26 files changed, 321 insertions(+), 424 deletions(-) delete mode 100755 TC/build.sh delete mode 100755 TC/execute.sh delete mode 100755 TC/tet_code delete mode 100755 TC/tet_scen delete mode 100755 TC/tetbuild.cfg delete mode 100755 TC/tetclean.cfg delete mode 100755 TC/tetexec.cfg delete mode 100644 TC/unit/Makefile delete mode 100755 TC/unit/tc_gen.sh delete mode 100644 TC/unit/tslist delete mode 100644 TC/unit/utc_MODULE_API_func.c.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 9bbf853..bb5ab34 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ MESSAGE("Build type: ${CMAKE_BUILD_TYPE}") # Set required packages INCLUDE(FindPkgConfig) -pkg_check_modules(libpkgs REQUIRED aul dlog bundle sqlite3 glib-2.0 dbus-glib-1) +pkg_check_modules(libpkgs REQUIRED aul dlog bundle sqlite3 glib-2.0 gio-2.0 capi-system-info) FOREACH(flag ${libpkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") diff --git a/TC/build.sh b/TC/build.sh deleted file mode 100755 index 98ebeff..0000000 --- a/TC/build.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -export TET_INSTALL_PATH=/scratchbox/tetware # local tetware path -export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target -export PATH=$TET_TARGET_PATH/bin:$PATH -export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH -export TET_ROOT=$TET_TARGET_PATH - -export TET_SUITE_ROOT=`pwd` -FILE_NAME_EXTENSION=`date +%s` - -RESULT_DIR=results -HTML_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.html -JOURNAL_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.journal - -mkdir -p $RESULT_DIR - -tcc -c -p ./ -tcc -b -j $JOURNAL_RESULT -p ./ -grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT diff --git a/TC/execute.sh b/TC/execute.sh deleted file mode 100755 index 6720da0..0000000 --- a/TC/execute.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh -export TET_INSTALL_PATH=/mnt/nfs/tetware -export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target -export PATH=$TET_TARGET_PATH/bin:$PATH -export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH - -export TET_ROOT=$TET_TARGET_PATH - -export TET_SUITE_ROOT=`pwd` -FILE_NAME_EXTENSION=`date +%s` - -RESULT_DIR=results -HTML_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.html -JOURNAL_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.journal - -mkdir -p $RESULT_DIR - -tcc -e -j $JOURNAL_RESULT -p ./ -grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT diff --git a/TC/tet_code b/TC/tet_code deleted file mode 100755 index a2cf6c1..0000000 --- a/TC/tet_code +++ /dev/null @@ -1,12 +0,0 @@ -# TET reserved codes -0 "PASS" -1 "FAIL" -2 "UNRESOLVED" -3 "NOTINUSE" -4 "UNSUPPORTED" -5 "UNTESTED" -6 "UNINITIATED" -7 "NORESULT" - -# Test suite additional codes -33 "INSPECT" diff --git a/TC/tet_scen b/TC/tet_scen deleted file mode 100755 index 43cbc9b..0000000 --- a/TC/tet_scen +++ /dev/null @@ -1,7 +0,0 @@ -all - ^TEST -##### Scenarios for TEST ##### - -# Test scenario -TEST - :include:/unit/tslist diff --git a/TC/tetbuild.cfg b/TC/tetbuild.cfg deleted file mode 100755 index 6192c78..0000000 --- a/TC/tetbuild.cfg +++ /dev/null @@ -1,3 +0,0 @@ -TET_OUTPUT_CAPTURE=False -TET_BUILD_TOOL=make -TET_PASS_TC_NAME=True diff --git a/TC/tetclean.cfg b/TC/tetclean.cfg deleted file mode 100755 index c66eda4..0000000 --- a/TC/tetclean.cfg +++ /dev/null @@ -1,2 +0,0 @@ -TET_OUTPUT_CAPTURE=False -TET_CLEAN_TOOL=make clean diff --git a/TC/tetexec.cfg b/TC/tetexec.cfg deleted file mode 100755 index 0d9d39a..0000000 --- a/TC/tetexec.cfg +++ /dev/null @@ -1 +0,0 @@ -TET_OUTPUT_CAPTURE=False diff --git a/TC/unit/Makefile b/TC/unit/Makefile deleted file mode 100644 index 631550c..0000000 --- a/TC/unit/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -CC ?= gcc - -TARGETS = -PKGS = syspopup - -LDFLAGS = `pkg-config --libs $(PKGS)` -LDFLAGS += $(TET_ROOT)/lib/tet3/tcm_s.o -LDFLAGS += -L$(TET_ROOT)/lib/tet3 -ltcm_s -LDFLAGS += -L$(TET_ROOT)/lib/tet3 -lapi_s - -CFLAGS = -I. `pkg-config --cflags $(PKGS)` -CFLAGS += -I$(TET_ROOT)/inc/tet3 -CFLAGS += -Wall - -all: $(TARGETS) - -$(TARGET): %: %.c - $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS) - -clean: - rm -f $(TARGETS) diff --git a/TC/unit/tc_gen.sh b/TC/unit/tc_gen.sh deleted file mode 100755 index 54f482d..0000000 --- a/TC/unit/tc_gen.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh - -TMPSTR=$0 -SCRIPT=${TMPSTR##*/} - -if [ $# -lt 2 ]; then - echo "Usage) $SCRIPT module_name api_name" - exit 1 -fi - -MODULE=$1 -API=$2 -TEMPLATE=utc_MODULE_API_func.c.in -TESTCASE=utc_${MODULE}_${API}_func - -sed -e ' - s^@API@^'"$API"'^g - s^@MODULE@^'"$MODULE"'^g - ' $TEMPLATE > $TESTCASE.c - -if [ ! -e "$TESTCASE.c" ]; then - echo "Failed" - exit 1 -fi -echo "Testcase file is $TESTCASE.c" -echo "Done" -echo "please put \"$TESTCASE\" as Target in Makefile" -echo "please put \"/unit/$TESTCASE\" in tslist" diff --git a/TC/unit/tslist b/TC/unit/tslist deleted file mode 100644 index 8b13789..0000000 --- a/TC/unit/tslist +++ /dev/null @@ -1 +0,0 @@ - diff --git a/TC/unit/utc_MODULE_API_func.c.in b/TC/unit/utc_MODULE_API_func.c.in deleted file mode 100644 index 0227150..0000000 --- a/TC/unit/utc_MODULE_API_func.c.in +++ /dev/null @@ -1,64 +0,0 @@ -#include - -static void startup(void); -static void cleanup(void); - -void (*tet_startup)(void) = startup; -void (*tet_cleanup)(void) = cleanup; - -static void utc_@MODULE@_@API@_func_01(void); -static void utc_@MODULE@_@API@_func_02(void); - -enum { - POSITIVE_TC_IDX = 0x01, - NEGATIVE_TC_IDX, -}; - -struct tet_testlist tet_testlist[] = { - { utc_@MODULE@_@API@_func_01, POSITIVE_TC_IDX }, - { utc_@MODULE@_@API@_func_02, NEGATIVE_TC_IDX }, -}; - -static void startup(void) -{ -} - -static void cleanup(void) -{ -} - -/** - * @brief Positive test case of @API@() - */ -static void utc_@MODULE@_@API@_func_01(void) -{ - int r = 0; - char buf[MAX_LOCAL_BUFSZ]; - - r = @API@(...); - - if (r<0) { - tet_infoline("@API@() failed in positive test case"); - tet_result(TET_FAIL); - return; - } - tet_result(TET_PASS); -} - -/** - * @brief Negative test case of ug_init @API@() - */ -static void utc_@MODULE@_@API@_func_02(void) -{ - int r = 0; - char buf[MAX_LOCAL_BUFSZ]; - - r = @API@(...); - - if (r>=0) { - tet_infoline("@API@() failed in negative test case"); - tet_result(TET_FAIL); - return; - } - tet_result(TET_PASS); -} diff --git a/data/mobile/syspopup_db.sql b/data/mobile/syspopup_db.sql index f4623ca..f544c38 100755 --- a/data/mobile/syspopup_db.sql +++ b/data/mobile/syspopup_db.sql @@ -24,17 +24,17 @@ INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"poweroff-syspopup", 2,0,-1, INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"lowmem-syspopup", 0,0,5,0,0,"org.tizen.lowmem-syspopup"); INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"lowbat-syspopup", 1,0,5,0,0,"org.tizen.lowbat-syspopup"); INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"net-popup", 0,0,-1,0,0,"net.netpopup"); -INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"usb-syspopup", 1,0,-1,2,2,"org.tizen.usb-syspopup"); -INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"usbotg-syspopup", 0,1,-1,0,0,"org.tizen.usbotg-syspopup"); -INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"mmc-syspopup", 0,0,-1,0,0,"org.tizen.mmc-syspopup"); +INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"usb-syspopup", 1,0,-1,2,2,"org.tizen.usb-syspopup"); +INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"usbotg-syspopup", 0,1,-1,0,0,"org.tizen.usbotg-syspopup"); +INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"mmc-syspopup", 0,0,-1,0,0,"org.tizen.mmc-syspopup"); INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"mobileap-syspopup", 0,0,-1,0,0,"org.tizen.mobileap-syspopup"); -INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"telephony-syspopup", 1,1,5,0,0,"org.tizen.telephony-syspopup"); +INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"telephony-syspopup", 1,1,5,0,0,"org.tizen.telephony-syspopup"); INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"system-syspopup", 2,0,-1,0,0,"org.tizen.system-syspopup"); INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"safetyvolume-syspopup", 1,0,-1,0,0,"org.tizen.safetyvolume-syspopup"); INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"datausage-syspopup", 1,0,-1,0,0,"org.tizen.datausage-syspopup"); -INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"crash-popup", 1,0,-1,0,0,"org.tizen.crash-popup"); -INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"gps-syspopup", 0,0,-1,0,0,"org.tizen.gps-syspopup"); -INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"mode-syspopup", 1,0,-1,0,0,"org.tizen.mode-syspopup"); +INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"crash-popup", 1,0,-1,0,0,"org.tizen.crash-popup"); +INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"gps-syspopup", 0,0,-1,0,0,"org.tizen.gps-syspopup"); +INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"mode-syspopup", 1,0,-1,0,0,"org.tizen.mode-syspopup"); /* INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"drm", 0,0,5,0,0,"com.samsung.drm-popup"); INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"incoming_call", 2,0,-1,2,2,"com.samsung.incoming_call"); diff --git a/data/wearable/syspopup_db.sql b/data/wearable/syspopup_db.sql index 99128ee..1a88d96 100755 --- a/data/wearable/syspopup_db.sql +++ b/data/wearable/syspopup_db.sql @@ -24,4 +24,3 @@ INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"system-syspopup", INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"safetyvolume-syspopup", 2,1,-1,0,0,"org.tizen.safetyvolume-syspopup"); INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"crash-popup", 1,0,-1,0,0,"org.tizen.crash-popup"); INSERT OR REPLACE INTO "syspopup_info" VALUES(NULL,"wc-syspopup", 0,0,-1,0,0,"net.wc-syspopup"); - diff --git a/packaging/syspopup.spec b/packaging/syspopup.spec index e4e0a64..45b7198 100755 --- a/packaging/syspopup.spec +++ b/packaging/syspopup.spec @@ -1,7 +1,7 @@ Name: syspopup Summary: syspopup package -Version: 0.0.134 +Version: 0.0.135 Release: 1 Group: System/Libraries License: Apache-2.0 @@ -14,12 +14,13 @@ BuildRequires: pkgconfig(sqlite3) BuildRequires: pkgconfig(bundle) BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(utilX) -BuildRequires: pkgconfig(dbus-glib-1) BuildRequires: pkgconfig(x11) BuildRequires: pkgconfig(aul) BuildRequires: pkgconfig(evas) BuildRequires: pkgconfig(appcore-efl) -BuildRequires: pkgconfig(capi-appfw-application) +BuildRequires: pkgconfig(vasum) +BuildRequires: pkgconfig(appsvc) +BuildRequires: pkgconfig(capi-system-info) %description syspopup package for popup @@ -65,7 +66,13 @@ org.tizen.syspopup-app test app package %if "%{?tizen_profile_name}" == "wearable" export CFLAGS="$CFLAGS –D_WEARABLE" %else +%if "%{?tizen_profile_name}" == "mobile" export CFLAGS="$CFLAGS -D_MOBILE" +%else +%if "%{?tizen_profile_name}" == "tv" +export CFLAGS="$CFLAGS -D_TV" +%endif +%endif %endif %if 0%{?sec_build_binary_debug_enable} @@ -75,7 +82,7 @@ export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE" %endif export CFLAGS="$CFLAGS -Wall -Werror -Wno-unused-function" CFLAGS=${_cflags} cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DEXTRA_CFLAGS=-fPIC \ - -D_WEARABLE:BOOL=${_WEARABLE} -D_MOBILE:BOOL=${_MOBILE} \ + -D_WEARABLE:BOOL=${_WEARABLE} -D_MOBILE:BOOL=${_MOBILE} -D_TV:BOOL=${_TV} \ . make %{?jobs:-j%jobs} diff --git a/src/syspopup_core.c b/src/syspopup_core.c index dc76dca..5ff2d5e 100755 --- a/src/syspopup_core.c +++ b/src/syspopup_core.c @@ -24,17 +24,16 @@ #include #include #include -#include -#include #include "syspopup_core.h" #include "simple_util.h" +#include +#include #define SYSPOPUP_NAME "_INTERNAL_SYSPOPUP_NAME_" static syspopup *syspopup_head = NULL; static int initialized = 0; -static DBusConnection *bus; static int noti_fd = -1; static int sp_id = 0; @@ -120,41 +119,28 @@ void _syspopup_del(int id) } } - -static DBusHandlerResult -__sys_popup_dbus_signal_filter(DBusConnection *conn, DBusMessage *message, - void *user_data) +void __sys_popup_dbus_signal_filter(GDBusConnection *conn, + const gchar *sender_name, + const gchar *object_path, + const gchar *interface_name, + const gchar *signal_name, + GVariant *parameters, + gpointer user_data) { const char *sender; const char *interface; int dead_pid; - - DBusError error; - dbus_error_init(&error); - - interface = dbus_message_get_interface(message); - if (interface == NULL) { - _E("reject by security issue - no interface\n"); - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; - } - - if (dbus_message_is_signal(message, interface, - SYSPOPUP_DBUS_SP_TERM_SIGNAL)) { + if(!strcmp(signal_name, SYSPOPUP_DBUS_SP_TERM_SIGNAL)) { if (_term_handler) _term_handler(NULL); _D("term handler has been called"); } - - return DBUS_HANDLER_RESULT_HANDLED; } - - int _syspopup_init(void (*term_handler) (void *), gboolean(*timeout_handler) (void *)) { - DBusError error; char rule[MAX_LOCAL_BUFSZ]; if (initialized) @@ -163,30 +149,31 @@ int _syspopup_init(void (*term_handler) (void *), _term_handler = term_handler; _timeout_handler = timeout_handler; - dbus_error_init(&error); - bus = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error); - if (!bus) { - _E("Failed to connect to the D-BUS daemon: %s", error.message); - dbus_error_free(&error); + GDBusConnection *conn = NULL; + GError *err = NULL; + g_type_init(); + + conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM,NULL,&err); + + if (err) { + _E("gdbus connection error (%s)", err->message); + g_error_free(err); return -1; } - dbus_connection_setup_with_g_main(bus, NULL); - - snprintf(rule, MAX_LOCAL_BUFSZ, - "path='%s',type='signal',interface='%s'", SYSPOPUP_DBUS_PATH, - SYSPOPUP_DBUS_SIGNAL_INTERFACE); - /* listening to messages */ - dbus_bus_add_match(bus, rule, &error); - if (dbus_error_is_set(&error)) { - _E("Fail to rule set: %s", error.message); - dbus_error_free(&error); + if (NULL == conn) { + _E("gdbus connection is not set, even gdbus error isn't raised"); return -1; } - if (dbus_connection_add_filter(bus, - __sys_popup_dbus_signal_filter, NULL, NULL) == FALSE) - return -1; + /* Add a filter for signal */ + guint conn_subsc_id = g_dbus_connection_signal_subscribe(conn, + NULL, SYSPOPUP_DBUS_SIGNAL_INTERFACE, + NULL, NULL, NULL, G_DBUS_SIGNAL_FLAGS_NONE, + __sys_popup_dbus_signal_filter, NULL, NULL); + if (conn_subsc_id == 0) { + _E("Error in subscribing to the signal"); + } _D("syspopup signal initialized"); initialized = 1; diff --git a/syspopup-app/CMakeLists.txt b/syspopup-app/CMakeLists.txt index 09370e4..9504c17 100644 --- a/syspopup-app/CMakeLists.txt +++ b/syspopup-app/CMakeLists.txt @@ -22,7 +22,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/syspopup) INCLUDE(FindPkgConfig) -pkg_check_modules(syspopup_app_pkgs REQUIRED appcore-efl capi-appfw-application) +pkg_check_modules(syspopup_app_pkgs REQUIRED appcore-efl) FOREACH(flag ${syspopup_app_pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") diff --git a/syspopup-app/syspopup-app.c b/syspopup-app/syspopup-app.c index 11ea84a..b1e4a25 100755 --- a/syspopup-app/syspopup-app.c +++ b/syspopup-app/syspopup-app.c @@ -20,30 +20,34 @@ * */ -#include -#include + +#include +#include +#include +#include + #include "syspopup.h" #include "syspopup-app.h" -typedef struct appdata { - Evas_Object *win; - Evas_Object *conform; - Evas_Object *label; - Evas_Object *popup; - bundle *b; - char title[TITLE_BUF_LEN]; - char content[CONTENT_BUF_LEN]; -} appdata_s; +#include + +#include + +#undef LOG_TAG +#define LOG_TAG "SYSPOPUP-APP" + +#define _E(fmt, arg...) LOGE(fmt,##arg) +#define _D(fmt, arg...) LOGD(fmt,##arg) int myterm(bundle *b, void *data) { - dlog_print(DLOG_DEBUG, LOG_TAG, "myterm called"); + _D("myterm called"); return 0; } int mytimeout(bundle *b, void* data) { - dlog_print(DLOG_DEBUG, LOG_TAG, "mytimeout called"); + _D("mytimeout called"); return 0; } @@ -52,212 +56,191 @@ syspopup_handler handler = { .def_timeout_fn = mytimeout }; -static bool _app_control_extra_data_cb(app_control_h app_control, const char *key, void *user_data) +static void __win_del(void *data, Evas_Object * obj, void *event) { - int ret; - char *value; - appdata_s *ad = user_data; - - ret = app_control_get_extra_data(app_control, key, &value); - if (ret != APP_CONTROL_ERROR_NONE) - { - dlog_print(DLOG_ERROR, LOG_TAG, "app_control_get_extra_data() is failed. err = %d", ret); - } + _D("__win_del called"); + elm_exit(); +} - if (bundle_add(ad->b, key, value) != BUNDLE_ERROR_NONE) { - free(value); - return APP_CONTROL_ERROR_INVALID_PARAMETER; - } +static Evas_Object *__create_win(const char *name) +{ + Evas_Object *eo; + int w; + int h; - free(value); + 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); - return true; -} + elm_win_alpha_set(eo, EINA_TRUE); -static void win_delete_request_cb(void *data , Evas_Object *obj , void *event_info) -{ - ui_app_exit(); + 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); + } + + return eo; } -static void win_back_cb(void *data, Evas_Object *obj, void *event_info) +static int __app_create(void *data) { - appdata_s *ad = data; - /* Let window go to hide state. */ - elm_win_lower(ad->win); + struct appdata *ad = data; + Evas_Object *win; + int r; + + _D("__app_create called"); + + /* create window */ + win = __create_win(PACKAGE); + if (win == NULL) + return -1; + ad->win = win; + /* evas_object_show(win);*/ + + /* init internationalization */ + r = appcore_set_i18n(PACKAGE, LOCALEDIR); + if(r) + return -1; + + /* appcore_set_rotation_cb(rotate, ad);*/ + + appcore_measure_start(); + return 0; } -static void response_cb(void *data, Evas_Object * obj, void *event_info) +static int __app_terminate(void *data) { - dlog_print(DLOG_DEBUG, LOG_TAG, "response_cb called"); + struct appdata *ad = data; - if ((int)event_info != 5) - evas_object_del(obj); - elm_exit(); + _D("__app_terminate called"); + + if (ad->win) + evas_object_del(ad->win); + + return 0; } -static void block_clicked_cb(void *data, Evas_Object *obj, void *event_info) +static int __app_pause(void *data) { - dlog_print(DLOG_DEBUG, LOG_TAG, "block_clicked_cb called"); - evas_object_del(obj); -} + struct appdata *ad = data; -static void create_base_gui(appdata_s *ad) { + _D("__app_pause called"); - int w; - int h; + return 0; +} - ad->win = elm_win_add(NULL, PACKAGE, ELM_WIN_DIALOG_BASIC); - if (ad->win) { - elm_win_title_set(ad->win, PACKAGE); - elm_win_borderless_set(ad->win, EINA_TRUE); - elm_win_alpha_set(ad->win, EINA_TRUE); - ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h); - evas_object_resize(ad->win, w, h); - } +static int __app_resume(void *data) +{ + struct appdata *ad = data; - elm_win_autodel_set(ad->win, EINA_TRUE); - evas_object_smart_callback_add(ad->win, "delete,request", win_delete_request_cb, NULL); + _D("__app_resume called"); + return 0; } -static bool app_create(void *data) +static void __prt_recvd_bundle(const char *key, const char *value, void *d) { - appdata_s *ad = data; + _D("recvd - key: %s, value: %s\n", key, value); +} - create_base_gui(ad); +static void __response_cb(void *data, Evas_Object * obj, void *event_info) +{ + _D("__response_cb called"); - return true; + if ((int)event_info != 5) + evas_object_del(obj); + elm_exit(); } -static void app_control(app_control_h app_control, void *data) +static void _block_clicked_cb(void *data, Evas_Object *obj, void *event_info) { - /* Handle the launch request. */ - appdata_s *ad = data; + _D("_block_clicked_cb called"); + evas_object_del(obj); +} +static int __app_reset(bundle *b, void *data) +{ + struct appdata *ad = data; Evas_Object *popup; const char *val; int ret = 0; - if(ad->b == NULL) - ad->b = bundle_create(); + _D("__app_reset called"); + + ad->b = bundle_dup(b); - ret = app_control_foreach_extra_data(app_control, _app_control_extra_data_cb, data); - if (ret != APP_CONTROL_ERROR_NONE) - dlog_print(DLOG_ERROR, LOG_TAG, "app_control_foreach_extra_data() is failed. err = %d", ret); + bundle_iterate(b, __prt_recvd_bundle, NULL); - if (syspopup_has_popup(ad->b)) { - syspopup_reset(ad->b); + if (syspopup_has_popup(b)) { + syspopup_reset(b); } else { popup = elm_popup_add(ad->win); if (popup != NULL) { - ret = syspopup_create(ad->b, &handler, ad->win, ad); + ret = syspopup_create(b, &handler, ad->win, ad); evas_object_show(ad->win); if (ret == 0) { - val = bundle_get_val(ad->b, "_SYSPOPUP_TITLE_"); + val = bundle_get_val(b, "_SYSPOPUP_TITLE_"); if (val) { snprintf(ad->title, TITLE_BUF_LEN, "%s", - val); + val); } else { snprintf(ad->title, TITLE_BUF_LEN, "%s", - "Unknown Title"); + "Unknown Title"); } - val = bundle_get_val(ad->b, "_SYSPOPUP_CONTENT_"); + val = bundle_get_val(b, "_SYSPOPUP_CONTENT_"); if (val) { snprintf(ad->content, CONTENT_BUF_LEN, - "%s", val); + "%s", val); } else { snprintf(ad->content, CONTENT_BUF_LEN, - "%s", "Unknown Content"); + "%s", "Unknown Content"); } elm_object_style_set(popup, "char_wrap_style"); evas_object_size_hint_weight_set(popup, - EVAS_HINT_EXPAND, - EVAS_HINT_EXPAND); - evas_object_smart_callback_add(popup, "block,clicked", block_clicked_cb, NULL); + EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_smart_callback_add(popup, "block,clicked", _block_clicked_cb, NULL); elm_object_part_text_set(popup, "title,text", ad->title); elm_object_text_set(popup, ad->content); evas_object_smart_callback_add(popup, - "response", - response_cb, - NULL); + "response", + __response_cb, + NULL); evas_object_show(popup); } } } - bundle_free(ad->b); -} - -static void app_pause(void *data) -{ - /* Take necessary actions when application becomes invisible. */ -} -static void app_resume(void *data) -{ - /* Take necessary actions when application becomes visible. */ -} - -static void app_terminate(void *data) -{ - /* Release all resources. */ -} - -static void ui_app_lang_changed(app_event_info_h event_info, void *user_data) -{ - /* APP_EVENT_LANGUAGE_CHANGED*/ - return; -} - -static void ui_app_orient_changed(app_event_info_h event_info, void *user_data) -{ - /* APP_EVENT_DEVICE_ORIENTATION_CHANGED*/ - return; -} - -static void ui_app_region_changed(app_event_info_h event_info, void *user_data) -{ - /* APP_EVENT_REGION_FORMAT_CHANGED*/ -} - -static void ui_app_low_battery(app_event_info_h event_info, void *user_data) -{ - /* APP_EVENT_LOW_BATTERY*/ -} - -static void ui_app_low_memory(app_event_info_h event_info, void *user_data) -{ - /* APP_EVENT_LOW_MEMORY*/ + return 0; } int main(int argc, char *argv[]) { - appdata_s ad = {0,}; - int ret = 0; + struct appdata ad; + struct appcore_ops ops = { + .create = __app_create, + .terminate = __app_terminate, + .pause = __app_pause, + .resume = __app_resume, + .reset = __app_reset, + }; - ui_app_lifecycle_callback_s event_callback = {0,}; - app_event_handler_h handlers[5] = {NULL, }; + //unsetenv("ELM_SCALE"); - event_callback.create = app_create; - event_callback.terminate = app_terminate; - event_callback.pause = app_pause; - event_callback.resume = app_resume; - event_callback.app_control = app_control; + /* appcore measure time example */ + _D("from AUL to %s(): %d msec\n", __func__, + appcore_measure_time_from("APP_START_TIME")); - ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, ui_app_low_battery, &ad); - ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, ui_app_low_memory, &ad); - ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, ui_app_orient_changed, &ad); - ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, ui_app_lang_changed, &ad); - ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, ui_app_region_changed, &ad); - - ret = ui_app_main(argc, argv, &event_callback, &ad); - if (ret != APP_ERROR_NONE) { - dlog_print(DLOG_ERROR, LOG_TAG, "app_main() is failed. err = %d", ret); - } + memset(&ad, 0x0, sizeof(struct appdata)); + ops.data = &ad; - return ret; + return appcore_efl_main(PACKAGE, &argc, &argv, &ops); } diff --git a/syspopup-app/syspopup-app.h b/syspopup-app/syspopup-app.h index c77c4c7..b16cd62 100755 --- a/syspopup-app/syspopup-app.h +++ b/syspopup-app/syspopup-app.h @@ -24,20 +24,29 @@ #ifndef __SYSPOPUP_APP_H__ #define __SYSPOPUP_APP_H__ -#include #include -#ifdef LOG_TAG -#undef LOG_TAG -#endif -#define LOG_TAG "syspopup-app" - #if !defined(PACKAGE) -#define PACKAGE "syspopup-app" +# define PACKAGE "syspopup-app" #endif +#define NAME_BUF_LEN 256 #define TITLE_BUF_LEN 256 #define CONTENT_BUF_LEN 256 +#define QP_BUF_LEN 10 +#define QP_PRIVID 1 +#define QP_TERM 1 +#define QP_TIMEOUT 1 + +struct appdata { + Evas_Object *win; + Evas_Object *popup; + bundle *b; + char title[TITLE_BUF_LEN]; + char content[CONTENT_BUF_LEN]; + /* add more variables here */ +}; + #endif /* __SYSPOPUP_APP_H__ */ diff --git a/syspopup-caller/CMakeLists.txt b/syspopup-caller/CMakeLists.txt index 47ffb1d..77b0826 100644 --- a/syspopup-caller/CMakeLists.txt +++ b/syspopup-caller/CMakeLists.txt @@ -20,7 +20,7 @@ MESSAGE("Build type: ${CMAKE_BUILD_TYPE}") # Set required packages INCLUDE(FindPkgConfig) -pkg_check_modules(spcpkgs REQUIRED dlog bundle sqlite3 glib-2.0 aul dbus-glib-1) +pkg_check_modules(spcpkgs REQUIRED dlog bundle sqlite3 glib-2.0 aul gio-2.0 vasum appsvc capi-system-info) FOREACH(flag ${spcpkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") diff --git a/syspopup-caller/syspopup_caller.c b/syspopup-caller/syspopup_caller.c index c5eca62..6dab1c8 100755 --- a/syspopup-caller/syspopup_caller.c +++ b/syspopup-caller/syspopup_caller.c @@ -25,25 +25,45 @@ #include #include #include -#include +#include #include +#include +#include +#include #include "syspopup_core.h" #include "syspopup_db.h" #include "syspopup_api.h" #include "simple_util.h" +static int __initialized = 0; +static bool __zone_armed = 0; + +#define TIZEN_ZONE_CONFIG_KEY "tizen.org/feature/container" + API int syspopup_launch(char *popup_name, bundle *b) { syspopup_info_t *info = NULL; int ret; int is_bundle = 0; + vsm_context_h vsm_ctx = NULL; + vsm_zone_h fg_zone = NULL; + const char *fg_zone_name = NULL; if (popup_name == NULL) { _E("popup_name is NULL"); return -1; } + if (!__initialized) { + ret = system_info_get_platform_bool(TIZEN_ZONE_CONFIG_KEY, &__zone_armed); + if (ret != SYSTEM_INFO_ERROR_NONE) { + _E("failed to get zone status, set zone status to disarmed"); + __zone_armed = 0; + } + __initialized = 1; + } + info = _syspopup_info_get(popup_name); if (info == NULL || info->pkgname == NULL) { _E("info or info->pkgname is NULL"); @@ -58,7 +78,7 @@ API int syspopup_launch(char *popup_name, bundle *b) } if (_syspopup_set_name_to_bundle(b, popup_name) < 0) { - _E("bundle set error\n"); + _E("bundle set error"); _syspopup_info_free(info); if (is_bundle == 1) { @@ -67,9 +87,67 @@ API int syspopup_launch(char *popup_name, bundle *b) return -1; } - ret = aul_launch_app(info->pkgname, b); - if (ret < 0) { - _E("aul launch error - %d", ret); + if (__zone_armed) { + if (vsm_is_virtualized()) { + ret = aul_launch_app(info->pkgname, b); + if (ret < 0) + _E("aul launch error - %d", ret); + + goto out; + } +#if !GLIB_CHECK_VERSION(2, 35, 0) + g_type_init(); +#endif + vsm_ctx = vsm_create_context(); + if (vsm_ctx) { + fg_zone = vsm_get_foreground(vsm_ctx); + if (fg_zone == NULL) { + _E("failed to get foreground zone"); + ret = -1; + goto out; + } + + if (vsm_is_host_zone(fg_zone) == 1) { + _E("can not launch syspopup. foreground zone is host"); + ret = -1; + goto out; + } + + fg_zone_name = vsm_get_zone_name(fg_zone); + _D("foreground zone: %s", fg_zone_name); + } else { + _E("failed to create vsm_context"); + ret = -1; + goto out; + } + + if (fg_zone_name) { + appsvc_set_operation(b, APP_SVC_OPERATION_JUMP); + appsvc_add_data(b, APP_SVC_K_JUMP_ORIGIN_OPERATION, APPSVC_OPERATION_DEFAULT); + appsvc_add_data(b, APP_SVC_K_JUMP_ZONE_NAME, fg_zone_name); + appsvc_set_appid(b, info->pkgname); + ret = appsvc_run_service(b, 0, NULL, NULL); + if (ret < 0) { + _E("syspopup launch error - %d", ret); + } + } else { + _E("failed to get foreground zone name"); + ret = -1; + goto out; + } + + } + else { + ret = aul_launch_app(info->pkgname, b); + if (ret < 0) + _E("aul launch error - %d", ret); + + goto out; + } + +out: + if (vsm_ctx) { + vsm_cleanup_context(vsm_ctx); } if (is_bundle == 1) { @@ -83,34 +161,48 @@ API int syspopup_launch(char *popup_name, bundle *b) API int syspopup_destroy_all() { - DBusMessage *message; - DBusError error; - DBusConnection *bus = NULL; - - dbus_error_init(&error); - bus = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error); - if (bus == NULL) { - _E("Failed to connect to the D-BUS daemon: %s", error.message); - dbus_error_free(&error); - return -1; - } + GDBusConnection *conn = NULL; + GError *err = NULL; + int ret = 0; - message = dbus_message_new_signal(SYSPOPUP_DBUS_PATH, - SYSPOPUP_DBUS_SIGNAL_INTERFACE, - SYSPOPUP_DBUS_SP_TERM_SIGNAL); + g_type_init(); - if (dbus_connection_send(bus, message, NULL) == FALSE) { - _E("dbus send error"); - return -1; - } + conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM,NULL,&err); - dbus_connection_flush(bus); - dbus_message_unref(message); + if (err) { + _E("gdbus connection error (%s)", err->message); + ret = -1; + goto out; + } + if (NULL == conn) { + _E("gdbus connection is not set, even gdbus error isn't raised"); + ret = -1; + goto out; + } - dbus_connection_close(bus); + if(!g_dbus_connection_emit_signal(conn,NULL, + SYSPOPUP_DBUS_PATH, + SYSPOPUP_DBUS_SIGNAL_INTERFACE, + SYSPOPUP_DBUS_SP_TERM_SIGNAL, + NULL, + &err)) { + _E("Error emitting the signal: %s",err->message); + ret = -1; + goto out; + } +out : _D("send signal done\n"); + if (err) { + g_error_free(err); + err = NULL; + } - return 0; + if (conn) { + g_object_unref(conn); + conn = NULL; + } + + return ret; } diff --git a/syspopup/CMakeLists.txt b/syspopup/CMakeLists.txt index 72a0929..e372521 100644 --- a/syspopup/CMakeLists.txt +++ b/syspopup/CMakeLists.txt @@ -20,7 +20,7 @@ MESSAGE("Build type: ${CMAKE_BUILD_TYPE}") # Set required packages INCLUDE(FindPkgConfig) -pkg_check_modules(sppkgs REQUIRED dlog bundle sqlite3 glib-2.0 evas elementary utilX ecore-x x11 ecore ecore-input dbus-glib-1) +pkg_check_modules(sppkgs REQUIRED dlog bundle sqlite3 glib-2.0 evas elementary utilX ecore-x x11 ecore ecore-input gio-2.0) FOREACH(flag ${sppkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") diff --git a/syspopup/syspopup.c b/syspopup/syspopup.c index 12d9995..f5a30b1 100755 --- a/syspopup/syspopup.c +++ b/syspopup/syspopup.c @@ -199,8 +199,6 @@ int X_syspopup_rotation_get(Display *dpy, Window win) int rotation = -1; int ret; - int angles[2]; - Atom atom_active_win; Atom atom_win_rotate_angle; @@ -293,7 +291,7 @@ static void __efl_rotation_set(Evas_Object* win, Ecore_X_Window xwin) ecore_x_icccm_name_class_set(xwin, WIN_PROP_NAME, WIN_PROP_NAME); if (elm_win_wm_rotation_supported_get(win)) { int rots[4] = { 0, 90, 180, 270 }; - elm_win_wm_rotation_available_rotations_set(win, &rots, 4); + elm_win_wm_rotation_available_rotations_set(win, (const int*)(&rots), 4); } else { _E("win rotation no supported"); } diff --git a/syspopup/syspopup.pc.in b/syspopup/syspopup.pc.in index 8d5f38a..544b8c1 100644 --- a/syspopup/syspopup.pc.in +++ b/syspopup/syspopup.pc.in @@ -6,8 +6,8 @@ libdir=@LIBDIR@ includedir=@INCLUDEDIR@ Name: libsyspopup -Description: system popup library for ui +Description: system popup library for ui Version: @VERSION@ -Requires: dlog bundle sqlite3 glib-2.0 elementary utilX ecore-x dbus-glib-1 +Requires: dlog bundle sqlite3 glib-2.0 elementary utilX ecore-x Libs: -L${libdir} -lsyspopup Cflags: -I${includedir} diff --git a/syspopup/syspopup_efl.c b/syspopup/syspopup_efl.c index 7767d2f..5b45d05 100755 --- a/syspopup/syspopup_efl.c +++ b/syspopup/syspopup_efl.c @@ -89,7 +89,6 @@ API int syspopup_create(bundle *b, syspopup_handler *handler, syspopup *sp = NULL; int id; XWindowAttributes attr; - int is_unviewable = 0; popup_name = _syspopup_get_name_from_bundle(b); if (popup_name == NULL || handler == NULL) { diff --git a/test/test.c b/test/test.c index ea23627..2b23abb 100755 --- a/test/test.c +++ b/test/test.c @@ -24,6 +24,7 @@ #include #include #include "syspopup_caller.h" +#include void usage() { -- 2.7.4