Refactor dpm-syspopup and remove password bundle data accepted/tizen/3.0/common/20161227.101800 accepted/tizen/3.0/ivi/20161227.005549 accepted/tizen/3.0/mobile/20161227.005347 accepted/tizen/3.0/tv/20161227.005510 accepted/tizen/3.0/wearable/20161227.005528 submit/tizen_3.0/20161226.022346
authorseolheui,kim <s414.kim@samsung.com>
Tue, 20 Dec 2016 06:20:06 +0000 (15:20 +0900)
committerJaemin Ryu <jm77.ryu@samsung.com>
Mon, 26 Dec 2016 02:01:32 +0000 (11:01 +0900)
Change-Id: I41205fc9c8df85e9337aeef479f204605cd9a5fb
Signed-off-by: seolheui,kim <s414.kim@samsung.com>
19 files changed:
packaging/device-policy-manager.spec
server/krate.cpp
server/password.cpp
tools/syspopup/CMakeLists.txt
tools/syspopup/include/dpm-syspopup.h
tools/syspopup/include/widget.h [new file with mode: 0644]
tools/syspopup/src/appcontrol.c [new file with mode: 0644]
tools/syspopup/src/circle-ui.c [deleted file]
tools/syspopup/src/main.c
tools/syspopup/src/mobile/default.c [new file with mode: 0644]
tools/syspopup/src/mobile/password-enforce-change.c [new file with mode: 0644]
tools/syspopup/src/mobile/toast.c [new file with mode: 0644]
tools/syspopup/src/notification.c [new file with mode: 0644]
tools/syspopup/src/popup-list.c
tools/syspopup/src/ui.c [changed mode: 0755->0644]
tools/syspopup/src/wearable/default.c [new file with mode: 0644]
tools/syspopup/src/wearable/password-enforce-change.c [new file with mode: 0644]
tools/syspopup/src/wearable/toast.c [new file with mode: 0644]
tools/syspopup/src/widget.c [new file with mode: 0644]

index 6a23b6c..e28998b 100755 (executable)
@@ -160,6 +160,7 @@ BuildRequires: pkgconfig(elementary)
 BuildRequires: pkgconfig(capi-appfw-application)
 BuildRequires: pkgconfig(capi-system-system-settings)
 BuildRequires: pkgconfig(capi-ui-efl-util)
+BuildRequires: pkgconfig(capi-system-info)
 
 %description -n org.tizen.dpm-syspopup
 Tizen DPM system popup interface package
index 310a78a..3e4e151 100644 (file)
@@ -90,12 +90,9 @@ int KratePolicy::createKrate(const std::string& name, const std::string& setupWi
        }
 
        try {
-               std::vector<std::string> data = {"app-id", "org.tizen.krate-setup-wizard",
-                                                                                "mode", "create",
-                                                                                "krate", name};
                Bundle bundle;
                bundle.add("id", "krate-create");
-               bundle.add("user-data", data);
+               bundle.add("user-data", name);
 
                Launchpad launchpad(context.getPeerUid());
                launchpad.launch("org.tizen.dpm-syspopup", bundle);
@@ -114,12 +111,9 @@ int KratePolicy::removeKrate(const std::string& name)
        }
 
        try {
-               std::vector<std::string> data = {"app-id", "org.tizen.krate-setup-wizard",
-                                                                                "mode", "remove",
-                                                                                "krate", name};
                Bundle bundle;
                bundle.add("id", "krate-remove");
-               bundle.add("user-data", data);
+               bundle.add("user-data", name);
 
                Launchpad launchpad(context.getPeerUid());
                launchpad.launch("org.tizen.dpm-syspopup", bundle);
index 8a648e9..d42dc3d 100644 (file)
@@ -296,10 +296,7 @@ int PasswordPolicy::enforceChange()
 {
        int ret = 0;
        bundle *b = ::bundle_create();
-       const char *user_data[4] = {"app-id", "org.tizen.setting-password", "caller", "DPM"};
-
        ::bundle_add_str(b, "id", "password-enforce-change");
-       ::bundle_add_str_array(b, "user-data", user_data, 4);
 
        ret = ::aul_launch_app_for_uid("org.tizen.dpm-syspopup", b, context.getPeerUid());
        ::bundle_free(b);
index ae9d5d2..4faf085 100644 (file)
@@ -14,6 +14,7 @@ PKG_CHECK_MODULES(dpm_syspopup_pkgs REQUIRED
        capi-ui-efl-util
        notification
        vconf
+       capi-system-info
 )
 
 INCLUDE_DIRECTORIES(${dpm_syspopup_pkgs_INCLUDE_DIRS} ${DPM_LIBS})
@@ -21,12 +22,20 @@ LINK_DIRECTORIES(${dpm_syspopup_pkgs_LIBRARY_DIRS})
 
 SET(PKG_NAME "${PROJECT_NAME}")
 SET(PKG_SRC    src/main.c
-               src/popup-list.c)
+               src/ui.c
+               src/widget.c
+               src/popup-list.c
+               src/appcontrol.c
+               src/notification.c)
 
 IF (${TIZEN_PROFILE_NAME} MATCHES "wearable")
-       SET(PKG_SRC ${PKG_SRC} src/circle-ui.c)
+       SET(PKG_SRC ${PKG_SRC}  src/wearable/default.c
+                               src/wearable/toast.c
+                               src/wearable/password-enforce-change.c)
 ELSE (${TIZEN_PROFILE_NAME} MATCHES "wearable")
-       SET(PKG_SRC ${PKG_SRC} src/ui.c)
+       SET(PKG_SRC ${PKG_SRC}  src/mobile/default.c
+                               src/mobile/toast.c
+                               src/mobile/password-enforce-change.c)
 ENDIF (${TIZEN_PROFILE_NAME} MATCHES "wearable")
 
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIE")
index 21a4c42..7bae5c0 100644 (file)
@@ -1,5 +1,4 @@
 /*
- * Tizen DPM Syspopup
  *
  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
  *
 #include <system_settings.h>
 #include <dlog.h>
 #include <Elementary.h>
+#include <notification.h>
+#include <app_control_internal.h>
+
+#include "widget.h"
 
 #ifdef  LOG_TAG
 #undef  LOG_TAG
 
 #define __(str) dgettext("dpm-syspopup", str)
 
-#define DPM_SYSPOPUP_DEFAULT_STATUS "stop"
-#define DPM_SYSPOPUP_ICON_PATH "/usr/share/icons/default/small/org.tizen.dpm-syspopup.png"
+#define ARRAY_SIZE(_array_) \
+        (sizeof(_array_) / sizeof(_array_[0]))
+
+typedef enum {
+       DPM_SYSPOPUP_DEFAULT = 0,
+       DPM_SYSPOPUP_TOAST,
+} viewtype_e;
 
 typedef struct {
-       char *title;
-       char *content;
-} noti_info_s;
+        char *key;
+        char *value;
+} appdata_s;
+
+typedef struct {
+        const char *id;
+        char *app_id;
+        appdata_s *data;
+       int data_size;
+} appcontrol_s;
 
 typedef struct {
        const char *id;
-       bool text_prefix;
        char *title;
        char *content;
-       char *style;
+       const char *image;
+} notification_s;
+
+typedef struct {
+       const char *id;
+       viewtype_e viewtype;
+       bool prefix;
+       char *header;
+       char *body;
        char *left_btn;
        char *right_btn;
-       char *noti_title;
-       char *noti_content;
 } popup_info_s;
 
+app_control_h create_syspopup_app_control(appcontrol_s *list, const char *id);
+int create_syspopup_notification(notification_s *list, const char *id, app_control_h app_control);
 popup_info_s *get_popup_info(const char *id);
-int get_popup_text(const char *id, const char *status, char *header, char *body);
 
-void create_syspopup(const char *id, char *style, const char *status, app_control_h svc);
+Evas_Object *create_default_popup(Evas_Object *parent, popup_info_s *info, void *user_data);
+Evas_Object *create_toast_popup(Evas_Object *parent, popup_info_s *body, void *user_data);
+Evas_Object *create_password_enforce_change_popup(Evas_Object *parent, popup_info_s *info, void *user_data);
+
+void create_syspopup(const char *id, void *user_data);
 
 #endif /* __DPM_SYSPOPUP_H__ */
diff --git a/tools/syspopup/include/widget.h b/tools/syspopup/include/widget.h
new file mode 100644 (file)
index 0000000..6a3fee0
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ *
+ * Copyright (c) 2016 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.
+ *
+ */
+
+#ifndef __DPM_SYSPOPUP_WIDGET_H__
+#define __DPM_SYSPOPUP_WIDGET_H__
+
+#include <app.h>
+#include <app_common.h>
+#include <Elementary.h>
+
+Evas_Object *create_window(const char *pkg_name);
+Evas_Object *create_popup(Evas_Object *parent, const char *style);
+Evas_Object *create_button(Evas_Object *parent, const char *style, const char *text, Evas_Smart_Cb callback, void *data);
+Evas_Object *create_image(Evas_Object *parent, const char *path);
+
+#endif /* __DPM_SYSPOPUP_WIDGET_H__ */
diff --git a/tools/syspopup/src/appcontrol.c b/tools/syspopup/src/appcontrol.c
new file mode 100644 (file)
index 0000000..6f2d687
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ *
+ * Copyright (c) 2016 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 "dpm-syspopup.h"
+
+static appcontrol_s *get_appcontrol_info(appcontrol_s *list, const char *id)
+{
+       while (list->id != NULL) {
+               if (!strcmp(list->id, id)) {
+                       return list;
+               }
+               list++;
+       }
+       return NULL;
+}
+
+app_control_h create_syspopup_app_control(appcontrol_s *list, const char *id)
+{
+       int i = 0, ret = 0;
+       app_control_h app_control = NULL;
+       appcontrol_s *info = NULL;
+       appdata_s *appdata = NULL;
+       int appdata_size = 0;
+
+       info = get_appcontrol_info(list, id);
+       if (info == NULL) {
+               dlog_print(DLOG_ERROR, LOG_TAG, "cannot find launch request");
+               return NULL;
+       }
+
+       ret = app_control_create(&app_control);
+       if (ret != APP_CONTROL_ERROR_NONE) {
+               return NULL;
+       }
+
+       ret = app_control_set_app_id(app_control, info->app_id);
+       if (ret != APP_CONTROL_ERROR_NONE) {
+               app_control_destroy(app_control);
+               return NULL;
+       }
+
+       appdata = info->data;
+       appdata_size = info->data_size;
+
+       for (i = 0; i < appdata_size; i++) {
+               ret = app_control_add_extra_data(app_control, appdata[i].key, appdata[i].value);
+               if (ret != APP_CONTROL_ERROR_NONE) {
+                       app_control_destroy(app_control);
+                       return NULL;
+               }
+       }
+
+       return app_control;
+}
diff --git a/tools/syspopup/src/circle-ui.c b/tools/syspopup/src/circle-ui.c
deleted file mode 100755 (executable)
index b414dee..0000000
+++ /dev/null
@@ -1,365 +0,0 @@
-/*
- * Tizen DPM Syspopup
- *
- * Copyright (c) 2016 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 <notification.h>
-#include <app_control_internal.h>
-#include <efl_util.h>
-#include <vconf.h>
-
-#include "dpm-syspopup.h"
-
-#define ICON_DIR "/usr/apps/org.tizen.dpm-syspopup/res/images"
-
-static Evas_Object *main_window;
-
-static void win_delete_request_cb(void *data, Evas_Object *obj, void *event_info)
-{
-       ui_app_exit();
-}
-
-static void create_window(const char *pkg_name)
-{
-       int rots[] = {0, 90, 180, 270};
-       main_window = elm_win_add(NULL, pkg_name, ELM_WIN_NOTIFICATION);
-       efl_util_set_notification_window_level(main_window, EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT);
-
-       if (elm_win_wm_rotation_supported_get(main_window))
-               elm_win_wm_rotation_available_rotations_set(main_window, rots, 4);
-
-       elm_win_title_set(main_window, pkg_name);
-       elm_win_borderless_set(main_window, EINA_TRUE);
-       elm_win_alpha_set(main_window, EINA_TRUE);
-
-       evas_object_smart_callback_add(main_window, "delete,request", win_delete_request_cb, NULL);
-       evas_object_show(main_window);
-}
-
-static void toast_delete_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
-       ui_app_exit();
-}
-
-static void popup_timeout_cb(void *data, Evas_Object *obj, void *event_info)
-{
-       evas_object_del(obj);
-       return;
-}
-
-static void block_clicked_cb(void *data, Evas_Object *obj, void *event_info)
-{
-       evas_object_del(obj);
-       return;
-}
-
-static void syspopup_confirm_button_cb(void *data, Evas_Object *obj, void *event_info)
-{
-       Evas_Object *popup = (Evas_Object *) data;
-       evas_object_data_set(popup, "selected", "ok");
-
-       /* call application */
-       app_control_h app_control = NULL;
-       app_control = (app_control_h)evas_object_data_get(popup, "app-control");
-       if (app_control) {
-               if (app_control_send_launch_request(app_control, NULL, NULL) != APP_CONTROL_ERROR_NONE)
-                       dlog_print(DLOG_ERROR, LOG_TAG, "failed to send launch request");
-       }
-       evas_object_del(popup);
-       return;
-}
-
-static void reply_password_enforce_event_handler(app_control_h ug, app_control_h reply, app_control_result_e result, void *data)
-{
-       Evas_Object *popup = (Evas_Object *) data;
-       char *result_string = NULL;
-       char *current = NULL;
-
-       if (result != APP_CONTROL_RESULT_SUCCEEDED) {
-               dlog_print(DLOG_ERROR, LOG_TAG, "failed to launch app");
-               evas_object_del(popup);
-               return;
-       }
-
-       app_control_get_extra_data(reply, "result", &result_string);
-       if (result_string == NULL) {
-               dlog_print(DLOG_ERROR, LOG_TAG, "failed to get reply.");
-               evas_object_del(popup);
-               return;
-       }
-
-       if (!strcmp(result_string, "SETTING_PW_TYPE_ENTER_LOCK_TYPE") ||
-                       !strcmp(result_string, "SETTING_PW_TYPE_VERIFY_FP_ALT_PASSWORD")) {
-
-               free(result_string);
-               app_control_get_extra_data(reply, "current", &current);
-               if (current != NULL) {
-                       app_control_h app_control;
-                       if (app_control_create(&app_control) != APP_CONTROL_ERROR_NONE) {
-                               dlog_print(DLOG_ERROR, LOG_TAG, "faild to create app_control context");
-                               evas_object_del(popup);
-                               return;
-                       }
-
-                       app_control_add_extra_data(app_control, "current", current);
-                       app_control_add_extra_data(app_control, "caller", "DPM");
-                       app_control_set_app_id(app_control, "org.tizen.setting-locktype");
-                       app_control_send_launch_request(app_control, NULL, NULL);
-                       app_control_destroy(app_control);
-                       free(current);
-               } else {
-                       dlog_print(DLOG_ERROR, LOG_TAG, "failed to get current password.");
-               }
-               evas_object_del(popup);
-       }
-}
-
-static void password_enforce_event_handler(void *data, Evas_Object *obj, void *event_info)
-{
-       int lock_type = 0;
-       Evas_Object *popup = (Evas_Object *) data;
-       app_control_h app_control = NULL;
-
-       evas_object_data_set(popup, "selected", "ok");
-
-       app_control = (app_control_h)evas_object_data_get(popup, "app-control");
-       app_control_add_extra_data(app_control, APP_CONTROL_DATA_SHIFT_WINDOW, "true");
-
-       vconf_get_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &lock_type);
-
-       if (lock_type == SETTING_SCREEN_LOCK_TYPE_PASSWORD || lock_type == SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD) {
-               app_control_add_extra_data(app_control, "viewtype", "SETTING_PW_TYPE_ENTER_LOCK_TYPE");
-               app_control_send_launch_request(app_control, reply_password_enforce_event_handler, popup);
-       } else {
-               app_control_set_app_id(app_control, "org.tizen.setting-locktype");
-               app_control_send_launch_request(app_control, NULL, NULL);
-               evas_object_del(popup);
-       }
-}
-
-static int set_notification(notification_h noti_handle, app_control_h app_control, char *title, char *content)
-{
-       int ret = NOTIFICATION_ERROR_NONE;
-
-       ret = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_TITLE, __(title), NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
-       if (ret != NOTIFICATION_ERROR_NONE)
-               return -1;
-
-       ret = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_CONTENT, __(content), NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
-       if (ret != NOTIFICATION_ERROR_NONE)
-               return -1;
-
-       ret = notification_set_display_applist(noti_handle, NOTIFICATION_DISPLAY_APP_ALL);
-       if (ret != NOTIFICATION_ERROR_NONE)
-               return -1;
-
-       ret = notification_set_image(noti_handle, NOTIFICATION_IMAGE_TYPE_THUMBNAIL, DPM_SYSPOPUP_ICON_PATH);
-       if (ret != NOTIFICATION_ERROR_NONE)
-               return -1;
-
-       ret = notification_set_launch_option(noti_handle, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, app_control);
-       if (ret != NOTIFICATION_ERROR_NONE)
-               return -1;
-
-       return ret;
-}
-
-static void cancel_button_cb(void *data, Evas_Object *obj, void *event_info)
-{
-       Evas_Object *popup = (Evas_Object *) data;
-       evas_object_data_set(popup, "selected", "cancel");
-       evas_object_del(popup);
-       return;
-}
-
-static void syspopup_delete_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
-       popup_info_s *info = (popup_info_s *)data;
-       char *selected = NULL;
-       app_control_h app_control = NULL;
-
-       app_control = (app_control_h)evas_object_data_get(obj, "app-control");
-       selected = (char *)evas_object_data_get(obj, "selected");
-
-       if (!strcmp(selected, "cancel")) {
-               int ret = NOTIFICATION_ERROR_NONE;
-
-               /* create notification */
-               notification_h noti_handle = NULL;
-               noti_handle = notification_create(NOTIFICATION_TYPE_NOTI);
-
-               ret = set_notification(noti_handle, app_control, info->noti_title, info->noti_content);
-               if (ret != NOTIFICATION_ERROR_NONE) {
-                       notification_free(noti_handle);
-                       app_control_destroy(app_control);
-                       return;
-               }
-               notification_post(noti_handle);
-               notification_free(noti_handle);
-       }
-
-       if (app_control) {
-               app_control_destroy(app_control);
-       }
-       ui_app_exit();
-}
-
-static Eina_Bool key_event_cb(void *data, int type, void *event)
-{
-       Evas_Object *popup = (Evas_Object *)data;
-       Evas_Event_Key_Down *ev = event;
-
-       evas_object_data_set(popup, "selected", "cancel");
-
-       if (!strcmp(ev->keyname, "XF86Home") || !strcmp(ev->keyname, "XF86BACK")) {
-               evas_object_del(popup);
-       }
-
-       return EINA_TRUE;
-}
-
-static void create_popup_bottom_button(Evas_Object *popup, const char *part, char *text, Evas_Smart_Cb callback)
-{
-       Evas_Object *button = NULL;
-
-       button = elm_button_add(popup);
-       elm_object_style_set(button, "bottom");
-       elm_object_text_set(button, __(text));
-       elm_object_part_content_set(popup, part, button);
-       evas_object_smart_callback_add(button, "clicked", callback, popup);
-
-       return;
-}
-
-static void create_popup_left_button(Evas_Object *popup, Evas_Smart_Cb callback)
-{
-       Evas_Object *button = NULL;
-       Evas_Object *icon = NULL;
-
-       button = elm_button_add(popup);
-       elm_object_style_set(button, "popup/circle/left");
-
-       icon = elm_image_add(button);
-       elm_image_file_set(icon, ICON_DIR"/tw_ic_popup_btn_delete.png", NULL);
-       evas_object_size_hint_weight_set(icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-       elm_object_part_content_set(button, "elm.swallow.content", icon);
-       evas_object_show(icon);
-
-       elm_object_part_content_set(popup, "button1", button);
-       evas_object_smart_callback_add(button, "clicked", callback, popup);
-       return;
-}
-
-static void create_popup_right_button(Evas_Object *popup, Evas_Smart_Cb callback)
-{
-       Evas_Object *button = NULL;
-       Evas_Object *icon = NULL;
-
-       button = elm_button_add(popup);
-       elm_object_style_set(button, "popup/circle/right");
-
-       icon = elm_image_add(button);
-       elm_image_file_set(icon, ICON_DIR"/tw_ic_popup_btn_check.png", NULL);
-       evas_object_size_hint_weight_set(icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-       elm_object_part_content_set(button, "elm.swallow.content", icon);
-       evas_object_show(icon);
-
-       elm_object_part_content_set(popup, "button2", button);
-       evas_object_smart_callback_add(button, "clicked", callback, popup);
-       return;
-}
-
-void create_syspopup(const char *id, char *style, const char *status, app_control_h svc)
-{
-       Evas_Object *popup = NULL;
-       Evas_Smart_Cb confirm_button_cb = NULL;
-       popup_info_s *info = NULL;
-       int ret = 0;
-       char header[PATH_MAX] = "";
-       char body[PATH_MAX] = "";
-
-       if (!strcmp(id, "password-enforce-change"))
-               confirm_button_cb = password_enforce_event_handler;
-       else
-               confirm_button_cb = syspopup_confirm_button_cb;
-
-       info = get_popup_info(id);
-       if (info == NULL)
-               return;
-
-       ret = get_popup_text(id, status, header, body);
-       if (ret != 0) {
-               dlog_print(DLOG_ERROR, LOG_TAG, "failed to get popup text");
-               return;
-       }
-
-       create_window("dpm-syspopup");
-       popup = elm_popup_add(main_window);
-       evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-
-       if (style != NULL)
-               info->style = style;
-
-       elm_object_style_set(popup, "circle");
-
-       Evas_Object *layout = elm_layout_add(popup);
-
-       if (!strcmp(info->style, "default")) {
-               if (info->left_btn != NULL) {
-                       elm_layout_theme_set(layout, "layout", "popup", "content/circle/buttons2");
-               } else {
-                       elm_layout_theme_set(layout, "layout", "popup", "content/circle/buttons1");
-               }
-
-               elm_object_content_set(popup, layout);
-
-               if (strcmp(header, "")) {
-                       elm_object_part_text_set(layout, "elm.text.title", header);
-               }
-
-               if (strcmp(body, "")) {
-                       elm_object_part_text_set(layout, "elm.text", body);
-               }
-
-               elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
-               evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, syspopup_delete_cb, info);
-
-               if (svc) {
-                       evas_object_data_set(popup, "app-control", svc);
-               }
-
-               if (info->left_btn != NULL) {
-                       ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, key_event_cb, popup);
-                       create_popup_left_button(popup, cancel_button_cb);
-                       create_popup_right_button(popup, confirm_button_cb);
-               } else {
-                       create_popup_bottom_button(popup, "button1", __(info->right_btn), confirm_button_cb);
-               }
-       } else {
-               elm_object_style_set(popup, "toast/circle");
-               elm_popup_orient_set(popup, ELM_POPUP_ORIENT_CENTER);
-               elm_object_part_text_set(popup, "elm.text", body);
-               elm_popup_timeout_set(popup, 3.0);
-               evas_object_smart_callback_add(popup, "timeout", popup_timeout_cb, NULL);
-               evas_object_smart_callback_add(popup, "block,clicked", block_clicked_cb, NULL);
-               evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, toast_delete_cb, NULL);
-               ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, key_event_cb, popup);
-       }
-
-       evas_object_show(popup);
-       return;
-}
index 510053c..a45f5cc 100644 (file)
 
 #include "dpm-syspopup.h"
 
-typedef struct {
-       char *id;
-       char *style;
-       char *status;
-       char **user_data;
-       int data_size;
-} bundle_data_s;
-
-static bundle_data_s bundle_data = {NULL, NULL, NULL, NULL, 0};
-
-static int create_app_control(app_control_h svc)
-{
-       int i;
-
-       for (i = 0; i < bundle_data.data_size - 1; i++) {
-               char *key = NULL;
-               char *value = NULL;
-
-               key = bundle_data.user_data[i++];
-               value = bundle_data.user_data[i];
-
-               if (!strcmp(key, "app-id")) {
-                       if (app_control_set_app_id(svc, value) != APP_CONTROL_ERROR_NONE)
-                               return -1;
-               } else {
-                       if (app_control_add_extra_data(svc, key, value) != APP_CONTROL_ERROR_NONE)
-                               return -1;
-               }
-       }
-
-       return 0;
-}
-
 static bool app_create(void *data)
 {
        return true;
 }
 
-static void free_data(void)
-{
-       int i = 0;
-
-       free(bundle_data.id);
-       free(bundle_data.style);
-       free(bundle_data.status);
-
-       if (bundle_data.user_data != NULL) {
-               for (i = 0; i < bundle_data.data_size; i++) {
-                       free(bundle_data.user_data[i]);
-               }
-       }
-
-       return;
-}
-
 static void app_control(app_control_h app_control, void *data)
 {
        int ret = 0;
-       app_control_h svc = NULL;
+       char *id = NULL;
+       char *user_data = NULL;
 
-       ret = app_control_get_extra_data(app_control, "id", &bundle_data.id);
+       ret = app_control_get_extra_data(app_control, "id", &id);
        if (ret != APP_CONTROL_ERROR_NONE) {
                dlog_print(DLOG_ERROR, LOG_TAG, "failed to get popup id");
                ui_app_exit();
                return;
        }
 
-       ret = app_control_get_extra_data(app_control, "viewtype", &bundle_data.style);
+       ret = app_control_get_extra_data(app_control, "user-data", &user_data);
        if (ret == APP_CONTROL_ERROR_KEY_NOT_FOUND) {
-               bundle_data.style = NULL;
+               user_data = NULL;
        } else if (ret != APP_CONTROL_ERROR_NONE) {
-               dlog_print(DLOG_ERROR, LOG_TAG, "failed to get popup style");
+               dlog_print(DLOG_ERROR, LOG_TAG, "failed to get user-data");
+               free(id);
                ui_app_exit();
                return;
        }
 
-       ret = app_control_get_extra_data(app_control, "status", &bundle_data.status);
-       if (ret == APP_CONTROL_ERROR_KEY_NOT_FOUND) {
-               bundle_data.status = strdup(DPM_SYSPOPUP_DEFAULT_STATUS);
-       } else if (ret != APP_CONTROL_ERROR_NONE) {
-               dlog_print(DLOG_ERROR, LOG_TAG, "failed to get popup status");
-               ui_app_exit();
-               return;
-       }
-
-       ret = app_control_get_extra_data_array(app_control, "user-data", &bundle_data.user_data, &bundle_data.data_size);
-       if (ret != APP_CONTROL_ERROR_KEY_NOT_FOUND && ret != APP_CONTROL_ERROR_NONE) {
-               dlog_print(DLOG_ERROR, LOG_TAG, "failed to get popup user data");
-               ui_app_exit();
-               return;
-       }
-
-       ret = app_control_create(&svc);
-       if (ret != APP_CONTROL_ERROR_NONE) {
-               dlog_print(DLOG_ERROR, LOG_TAG, "failed to create app_control handler");
-               ui_app_exit();
-               return;
-       }
-
-       if (create_app_control(svc) != 0) {
-               dlog_print(DLOG_ERROR, LOG_TAG, "failed to set app_control handler");
-               app_control_destroy(svc);
-               ui_app_exit();
-               return;
-       }
+       create_syspopup(id, user_data);
 
-       create_syspopup(bundle_data.id, bundle_data.style, bundle_data.status, svc);
+       free(id);
+       free(user_data);
 
        return;
 }
 
 static void app_terminate(void *data)
 {
-       free_data();
        return;
 }
 
diff --git a/tools/syspopup/src/mobile/default.c b/tools/syspopup/src/mobile/default.c
new file mode 100644 (file)
index 0000000..4e4f3c7
--- /dev/null
@@ -0,0 +1,221 @@
+/*
+ *
+ * Copyright (c) 2016 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 <system_info.h>
+
+#include "dpm-syspopup.h"
+
+static const char icon_path[] = "/usr/share/icons/default/small/org.tizen.dpm-syspopup.png";
+
+static appdata_s krate_create_appdata[] = {
+       {"mode", "create"}
+};
+
+static appdata_s krate_remove_appdata[] = {
+       {"mode", "remove"}
+};
+
+static appdata_s password_enforce_change_appdata[] = {
+       {"caller", "dpm"}
+};
+
+static appcontrol_s z3_appcontrol_list[] = {
+       {
+               "krate-create",
+               "org.tizen.krate-setup-wizard",
+               krate_create_appdata,
+               ARRAY_SIZE(krate_create_appdata)
+       },
+       {
+               "krate-remove",
+               "org.tizen.krate-setup-wizard",
+               krate_remove_appdata,
+               ARRAY_SIZE(krate_remove_appdata)
+       }
+};
+
+static appcontrol_s z2_appcontrol_list[] = {
+       {
+               "krate-create",
+               "com.samsung.krate-setup-wizard",
+               krate_create_appdata,
+               ARRAY_SIZE(krate_create_appdata)
+       },
+       {
+               "krate-remove",
+               "com.samsung.krate-setup-wizard",
+               krate_remove_appdata,
+               ARRAY_SIZE(krate_remove_appdata)
+       },
+       {
+               "password-enforce-change",
+               "com.samsung.setting.locktype",
+               password_enforce_change_appdata,
+               ARRAY_SIZE(password_enforce_change_appdata)
+       }
+};
+
+static notification_s notification_list[] = {
+       {
+               "krate-create",
+               "IDS_DPM_NOTI_KRATE_CREATE",
+               "IDS_DPM_NOTI_BODY_KRATE_CREATE",
+               icon_path
+       },
+       {
+               "krate-remove",
+               "IDS_DPM_NOTI_KRATE_REMOVE",
+               "IDS_DPM_NOTI_BODY_KRATE_REMOVE",
+               icon_path
+       }
+};
+
+static void cancel_button_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       Evas_Object *popup = (Evas_Object *) data;
+       evas_object_data_set(popup, "status", "cancel");
+       evas_object_del(popup);
+       return;
+}
+
+static void confirm_button_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       Evas_Object *popup = (Evas_Object *)data;
+       app_control_h app_control = NULL;
+       int ret = 0;
+
+       /* call application */
+       app_control = (app_control_h)evas_object_data_get(popup, "app-control");
+       if (app_control) {
+               ret = app_control_send_launch_request(app_control, NULL, NULL);
+               if (ret != APP_CONTROL_ERROR_NONE)
+                       dlog_print(DLOG_ERROR, LOG_TAG, "failed to send launch request");
+       }
+
+       evas_object_data_set(popup, "status", "confirm");
+       evas_object_del(popup);
+       return;
+}
+
+static void popup_deleted_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+       int ret = 0;
+       char *status = NULL;
+
+       status = (char *)evas_object_data_get(obj, "status");
+
+       if (status != NULL && !strcmp(status, "cancel")) {
+               popup_info_s *info = (popup_info_s *)data;
+               app_control_h app_control = NULL;
+               app_control = (app_control_h)evas_object_data_get(obj, "app-control");
+
+               /* create notification */
+               ret = create_syspopup_notification(notification_list, info->id, app_control);
+               if (ret != 0) {
+                       dlog_print(DLOG_ERROR, LOG_TAG, "cannot create notification");
+               }
+               if (app_control) {
+                       app_control_destroy(app_control);
+               }
+       }
+       ui_app_exit();
+}
+
+static void create_popup_bottom_button(Evas_Object *popup, char *part, char *text, Evas_Smart_Cb callback)
+{
+       Evas_Object *button = NULL;
+
+       button = create_button(popup, "popup", __(text), callback, popup);
+       elm_object_part_content_set(popup, part, button);
+       return;
+}
+
+static void set_appcontrol(Evas_Object *popup, const char *id, void *user_data)
+{
+       app_control_h app_control = NULL;
+       char *manufacturer = NULL;
+
+       system_info_get_platform_string("tizen.org/system/manufacturer", &manufacturer);
+
+       if (!strcmp(manufacturer, "Tizen")) {
+               app_control = create_syspopup_app_control(z3_appcontrol_list, id);
+       } else if (!strcmp(manufacturer, "Samsung")) {
+               app_control = create_syspopup_app_control(z2_appcontrol_list, id);
+       } else {
+               free(manufacturer);
+               dlog_print(DLOG_ERROR, LOG_TAG, "Invalid manufacturer");
+               return;
+       }
+
+       free(manufacturer);
+
+       if (app_control) {
+               if (!strcmp(id, "krate-create") || !strcmp(id, "krate-remove")) {
+                       app_control_add_extra_data(app_control, "krate", (char *)user_data);
+               }
+               evas_object_data_set(popup, "app-control", app_control);
+       }
+       return;
+}
+
+Evas_Object *create_default_popup(Evas_Object *parent, popup_info_s *info, void *user_data)
+{
+       Evas_Object *popup = NULL;
+       char header[PATH_MAX] = "";
+       char body[PATH_MAX] = "";
+       char *lp_text = NULL;
+
+
+       popup = create_popup(parent, "default");
+       elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
+
+       if (info->header != NULL && info->prefix) {
+               lp_text = __("IDS_IDLE_TPOP_SECURITY_POLICY_RESTRICTS_USE_OF_PS");
+               snprintf(header, PATH_MAX, lp_text, __(info->header));
+       } else if (info->header) {
+               snprintf(header, PATH_MAX, "%s", __(info->header));
+       }
+
+       if (info->body != NULL && info->prefix) {
+               lp_text = __("IDS_IDLE_TPOP_SECURITY_POLICY_RESTRICTS_USE_OF_PS");
+               snprintf(body, PATH_MAX, lp_text, __(info->body));
+       } else if (info->body) {
+               snprintf(body, PATH_MAX, "%s", __(info->body));
+       }
+
+       if (strcmp(header, "")) {
+               elm_object_part_text_set(popup, "title,text", header);
+               elm_object_item_part_text_translatable_set(popup, "title,text", EINA_TRUE);
+       }
+
+       if (strcmp(body, "")) {
+               elm_object_text_set(popup, body);
+       }
+
+       if (info->left_btn) {
+               create_popup_bottom_button(popup, "button1", info->left_btn, cancel_button_cb);
+               create_popup_bottom_button(popup, "button2", info->right_btn, confirm_button_cb);
+       } else {
+               create_popup_bottom_button(popup, "button1", info->right_btn, confirm_button_cb);
+       }
+
+       evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, popup_deleted_cb, info);
+       set_appcontrol(popup, info->id, user_data);
+
+       return popup;
+}
diff --git a/tools/syspopup/src/mobile/password-enforce-change.c b/tools/syspopup/src/mobile/password-enforce-change.c
new file mode 100644 (file)
index 0000000..5edce3f
--- /dev/null
@@ -0,0 +1,173 @@
+/*
+ *
+ * Copyright (c) 2016 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 <vconf.h>
+
+#include "dpm-syspopup.h"
+
+static appdata_s password_enforce_change_appdata[] = {
+       {"caller", "DPM"},
+       {APP_CONTROL_DATA_SHIFT_WINDOW, "true"}
+};
+
+/* Exception case for platform */
+static appdata_s password_verify_appdata[] = {
+       {"caller", "DPM"},
+       {APP_CONTROL_DATA_SHIFT_WINDOW, "true"},
+       {"viewtype", "SETTING_PW_TYPE_ENTER_LOCK_TYPE"}
+};
+
+static appcontrol_s appcontrol_list[] = {
+       {
+               "password-enforce-change",
+               "org.tizen.setting-locktype",
+               password_enforce_change_appdata,
+               ARRAY_SIZE(password_enforce_change_appdata)
+       },
+       /* Exception case for platform */
+       {
+               "password-verify",
+               "org.tizen.setting-password",
+               password_verify_appdata,
+               ARRAY_SIZE(password_verify_appdata)
+       }
+};
+
+static void reply_event_handler(app_control_h ug, app_control_h reply, app_control_result_e result, void *data)
+{
+       Evas_Object *popup = (Evas_Object *) data;
+       char *result_string = NULL;
+       char *current = NULL;
+
+       if (result != APP_CONTROL_RESULT_SUCCEEDED) {
+               dlog_print(DLOG_ERROR, LOG_TAG, "failed to launch app");
+               evas_object_del(popup);
+               return;
+       }
+
+       app_control_get_extra_data(reply, "result", &result_string);
+       if (result_string == NULL) {
+               dlog_print(DLOG_ERROR, LOG_TAG, "failed to get reply.");
+               evas_object_del(popup);
+               return;
+       }
+
+       if (!strcmp(result_string, "SETTING_PW_TYPE_ENTER_LOCK_TYPE") ||
+                       !strcmp(result_string, "SETTING_PW_TYPE_VERIFY_FP_ALT_PASSWORD")) {
+               free(result_string);
+               app_control_get_extra_data(reply, "current", &current);
+               if (current != NULL) {
+                       app_control_h app_control = NULL;
+                       app_control = (app_control_h)evas_object_data_get(popup, "app-control");
+                       if (app_control) {
+                               app_control_add_extra_data(app_control, "current", current);
+                               app_control_send_launch_request(app_control, NULL, NULL);
+                               app_control_destroy(app_control);
+                       }
+                       free(current);
+               } else {
+                       dlog_print(DLOG_ERROR, LOG_TAG, "failed to get current password");
+               }
+       }
+
+       evas_object_del(popup);
+       return;
+}
+
+static void confirm_button_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       Evas_Object *popup = (Evas_Object *) data;
+       int lock_type = 0;
+       app_control_h app_control = NULL;
+
+       evas_object_data_set(popup, "status", "confirm");
+       vconf_get_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &lock_type);
+
+       if (lock_type == SETTING_SCREEN_LOCK_TYPE_PASSWORD
+                       || lock_type == SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD) {
+               app_control = create_syspopup_app_control(appcontrol_list, "password-verify");
+               if (app_control) {
+                       app_control_send_launch_request(app_control, reply_event_handler, popup);
+                       app_control_destroy(app_control);
+               }
+       } else {
+               app_control = (app_control_h)evas_object_data_get(popup, "app-control");
+               if (app_control) {
+                       app_control_send_launch_request(app_control, NULL, NULL);
+                       app_control_destroy(app_control);
+               }
+               evas_object_del(popup);
+       }
+}
+
+static void popup_deleted_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+       ui_app_exit();
+}
+
+static void create_popup_bottom_button(Evas_Object *popup, char *part, char *text, Evas_Smart_Cb callback)
+{
+       Evas_Object *button = NULL;
+
+       button = create_button(popup, "popup", __(text), callback, popup);
+       elm_object_part_content_set(popup, part, button);
+       return;
+}
+
+Evas_Object *create_password_enforce_change_popup(Evas_Object *parent, popup_info_s *info, void *user_data)
+{
+       Evas_Object *popup = NULL;
+       app_control_h app_control = NULL;
+       char header[PATH_MAX] = "";
+       char body[PATH_MAX] = "";
+       char *lp_text = NULL;
+
+       if (info->header != NULL && info->prefix) {
+               lp_text = __("IDS_IDLE_TPOP_SECURITY_POLICY_RESTRICTS_USE_OF_PS");
+               snprintf(header, PATH_MAX, lp_text, __(info->header));
+       } else if (info->header) {
+               snprintf(header, PATH_MAX, "%s", __(info->header));
+       }
+
+       if (info->body != NULL && info->prefix) {
+               lp_text = __("IDS_IDLE_TPOP_SECURITY_POLICY_RESTRICTS_USE_OF_PS");
+               snprintf(body, PATH_MAX, lp_text, __(info->body));
+       } else if (info->body) {
+               snprintf(body, PATH_MAX, "%s", __(info->body));
+       }
+
+       popup = create_popup(parent, "default");
+       elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
+
+       if (strcmp(header, "")) {
+               elm_object_part_text_set(popup, "title,text", header);
+               elm_object_item_part_text_translatable_set(popup, "title,text", EINA_TRUE);
+       }
+
+       if (strcmp(body, "")) {
+               elm_object_text_set(popup, body);
+       }
+
+       create_popup_bottom_button(popup, "button1", info->right_btn, confirm_button_cb);
+       evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, popup_deleted_cb, NULL);
+
+       app_control = create_syspopup_app_control(appcontrol_list, info->id);
+       evas_object_data_set(popup, "app-control", app_control);
+
+       return popup;
+}
diff --git a/tools/syspopup/src/mobile/toast.c b/tools/syspopup/src/mobile/toast.c
new file mode 100644 (file)
index 0000000..e01fce9
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2016 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 "dpm-syspopup.h"
+
+static void popup_timeout_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       evas_object_del(obj);
+       return;
+}
+
+static void block_clicked_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       evas_object_del(obj);
+       return;
+}
+
+static void popup_deleted_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+       ui_app_exit();
+}
+
+Evas_Object *create_toast_popup(Evas_Object *parent, popup_info_s *info, void *user_data)
+{
+       Evas_Object *popup = NULL;
+       char body[PATH_MAX] = "";
+       char *lp_text = NULL;
+
+       if (info->prefix) {
+               lp_text =  __("IDS_IDLE_TPOP_SECURITY_POLICY_RESTRICTS_USE_OF_PS");
+               snprintf(body, PATH_MAX, lp_text, __(info->body));
+       } else {
+               snprintf(body, PATH_MAX, "%s", __(info->body));
+       }
+
+       popup = create_popup(parent, "toast");
+       elm_object_text_set(popup, body);
+       elm_popup_timeout_set(popup, 3.0);
+       evas_object_smart_callback_add(popup, "timeout", popup_timeout_cb, NULL);
+       evas_object_smart_callback_add(popup, "block,clicked", block_clicked_cb, NULL);
+       evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, popup_deleted_cb, NULL);
+       return popup;
+}
diff --git a/tools/syspopup/src/notification.c b/tools/syspopup/src/notification.c
new file mode 100644 (file)
index 0000000..243c8c7
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2016 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 "dpm-syspopup.h"
+
+static notification_s *get_notification_info(notification_s *list, const char *id)
+{
+       while (list->id != NULL) {
+               if (!strcmp(list->id, id)) {
+                       return list;
+               }
+               list++;
+       }
+       return NULL;
+}
+
+static int set_notification(notification_h noti_handle, app_control_h app_control, notification_s *info)
+{
+       int ret = NOTIFICATION_ERROR_NONE;
+
+       ret = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_TITLE, __(info->title), NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+       if (ret != NOTIFICATION_ERROR_NONE)
+               return -1;
+
+       ret = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_CONTENT, __(info->content), NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+       if (ret != NOTIFICATION_ERROR_NONE)
+               return -1;
+
+       ret = notification_set_display_applist(noti_handle, NOTIFICATION_DISPLAY_APP_ALL);
+       if (ret != NOTIFICATION_ERROR_NONE)
+               return -1;
+
+       ret = notification_set_image(noti_handle, NOTIFICATION_IMAGE_TYPE_THUMBNAIL, info->image);
+       if (ret != NOTIFICATION_ERROR_NONE)
+               return -1;
+
+       if (app_control) {
+               ret = notification_set_launch_option(noti_handle, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, app_control);
+               if (ret != NOTIFICATION_ERROR_NONE)
+                       return -1;
+       }
+       return ret;
+}
+
+int create_syspopup_notification(notification_s *list, const char *id, app_control_h app_control)
+{
+       int ret = 0;
+       notification_s *info = NULL;
+       notification_h handle = NULL;
+
+       info = get_notification_info(list, id);
+       if (info == NULL) {
+               return -1;
+       }
+
+       handle = notification_create(NOTIFICATION_TYPE_NOTI);
+       if (handle == NULL) {
+               return -1;
+       }
+
+       ret = set_notification(handle, app_control, info);
+       if (ret != 0) {
+               notification_free(handle);
+               return -1;
+       }
+
+       ret = notification_post(handle);
+       if (ret != NOTIFICATION_ERROR_NONE) {
+               return -1;
+       }
+
+       notification_free(handle);
+       return 0;
+}
index 43fd5b4..3981510 100644 (file)
@@ -1,5 +1,4 @@
 /*
- * Tizen DPM Syspopup
  *
  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
  *
  *
  */
 
-#include <dpm/password.h>
-
 #include "dpm-syspopup.h"
 
-#define ARRAY_SIZE(_array_) \
-       (sizeof(_array_) / sizeof(_array_[0]))
-
 popup_info_s popup_list[] = {
-
-       /* ID | TEXT_PREFIX | TITLE_TEXT | CONTENT_TEXT | POPUP_STYLE | LEFT_BUTTON | RIGHT_BUTTON | NOTI_TITLE | NOTI_CONTENT */
+       /* ID | VIEW_TYPE | TEXT_PREFIX | TITLE_TEXT | CONTENT_TEXT | LEFT_BUTTON | RIGHT_BUTTON */
 
        /* Application Policy */
        {
                "package-installation-mode",
+               DPM_SYSPOPUP_TOAST,
                false,
                NULL,
                "IDS_IDLE_TPOP_SECURITY_POLICY_PREVENTS_INSTALLATION_OF_APPS",
-               "toast",
-               NULL, NULL, NULL, NULL
+               NULL, NULL
        },
        {
                "package-uninstallation-mode",
+               DPM_SYSPOPUP_TOAST,
                false,
                NULL,
                "IDS_IDLE_TPOP_SECURITY_POLICY_PREVENTS_UNINSTALLING_APPS",
-               "toast",
-               NULL, NULL, NULL, NULL
+               NULL, NULL
        },
 
        /* Password Policy */
        {
                "password-enforce-change",
+               DPM_SYSPOPUP_DEFAULT,
                false,
                "IDS_ST_BODY_PASSWORD",
                "IDS_IDLE_POP_THE_SECURITY_POLICY_REQUIRES_YOU_TO_CHANGE_YOUR_PASSWORD",
-               "default",
-               NULL, "IDS_TPLATFORM_BUTTON_OK", NULL, NULL
+               NULL, "IDS_TPLATFORM_BUTTON_OK"
        },
 
        /* Restriction Policy */
        {
                "wifi",
+               DPM_SYSPOPUP_TOAST,
                false,
                NULL,
                "IDS_IDLE_TPOP_SECURITY_POLICY_PREVENTS_USE_OF_WI_FI",
-               "toast",
-               NULL, NULL, NULL, NULL
+               NULL, NULL
        },
        {
                "wifi-hotspot",
+               DPM_SYSPOPUP_TOAST,
                true,
                "IDS_MOBILEAP_MBODY_HOTSPOT_SPRINT",
                "IDS_MOBILEAP_MBODY_HOTSPOT_SPRINT",
-               "toast",
-               NULL, NULL, NULL, NULL
+               NULL, NULL
        },
        {
                "camera",
+               DPM_SYSPOPUP_TOAST,
                true,
                "IDS_IDLE_TAB4_CAMERA",
                "IDS_IDLE_TAB4_CAMERA",
-               "toast",
-               NULL, NULL, NULL, NULL
+               NULL, NULL
        },
        {
                "microphone",
+               DPM_SYSPOPUP_TOAST,
                false,
                NULL,
                "IDS_IDLE_TPOP_SECURITY_POLICY_RESTRICTS_USE_OF_MIC",
-               "toast",
-               NULL, NULL, NULL, NULL
+               NULL, NULL
        },
        {
                "location",
+               DPM_SYSPOPUP_TOAST,
                false,
                NULL,
                "IDS_IDLE_TPOP_SECURITY_POLICY_RESTRICTS_USE_OF_LOCATION_INFO",
-               "toast",
-               NULL, NULL, NULL, NULL
+               NULL, NULL
        },
        {
                "settings-changes",
+               DPM_SYSPOPUP_TOAST,
                false,
                NULL,
                "IDS_IDLE_TPOP_SECURITY_POLICY_PREVENTS_CHANGING_SETTINGS",
-               "toast",
-               NULL, NULL, NULL, NULL
+               NULL, NULL
        },
        {
                "bluetooth",
+               DPM_SYSPOPUP_TOAST,
                false,
                NULL,
                "IDS_IDLE_TPOP_SECURITY_POLICY_PREVENTS_USE_OF_BLUETOOTH",
-               "toast",
-               NULL, NULL, NULL, NULL
+               NULL, NULL
        },
        {
                "clipboard",
+               DPM_SYSPOPUP_TOAST,
                true,
                "IDS_TPLATFORM_OPT_CLIPBOARD",
                "IDS_TPLATFORM_OPT_CLIPBOARD",
-               "toast",
-               NULL, NULL, NULL, NULL
+               NULL, NULL
        },
        {
                "nfc",
+               DPM_SYSPOPUP_TOAST,
                true,
                "IDS_ST_BODY_NFC",
                "IDS_ST_BODY_NFC",
-               "toast",
-               NULL, NULL, NULL, NULL
+               NULL, NULL
        },
        {
                "message-sending",
+               DPM_SYSPOPUP_TOAST,
                false,
                NULL,
                "IDS_IDLE_TPOP_SECURITY_POLICY_PREVENTS_SENDING_MESSAGES",
-               "toast",
-               NULL, NULL, NULL, NULL
+               NULL, NULL
        },
        {
-               "message-receiving",
+               "message-retrieving",
+               DPM_SYSPOPUP_TOAST,
                false,
                NULL,
                "IDS_IDLE_TPOP_SECURITY_POLICY_RESTRICTS_RETRIEVING_MESSAGES",
-               "toast",
-               NULL, NULL, NULL, NULL
+               NULL, NULL
        },
        {
                "browser",
+               DPM_SYSPOPUP_TOAST,
                false,
                NULL,
                "IDS_IDLE_TPOP_SECURITY_POLICY_PREVENTS_USE_OF_BROWSER_APPS",
-               "toast",
-               NULL, NULL, NULL, NULL
+               NULL, NULL
        },
        {
                "screen-capture",
+               DPM_SYSPOPUP_TOAST,
                true,
                "IDS_MF_BODY_SCREEN_CAPTURE_M_NOUN",
                "IDS_MF_BODY_SCREEN_CAPTURE_M_NOUN",
-               "toast",
-               NULL, NULL, NULL, NULL
+               NULL, NULL
        },
 
        /* Storage Policy */
-       {"external-storage",   true, "IDS_DPM_EXTERNAL_STORAGE",   NULL, "toast", NULL, NULL, NULL, NULL},
-       {"storage-decryption", true, "IDS_DPM_STORAGE_DECRYPTION", NULL, "toast", NULL, NULL, NULL, NULL},
+       {
+               "external-storage",
+               DPM_SYSPOPUP_TOAST,
+               true,
+               "IDS_DPM_EXTERNAL_STORAGE",
+               NULL,
+               NULL, NULL
+       },
+       {
+               "storage-decryption",
+               DPM_SYSPOPUP_TOAST,
+               true,
+               "IDS_DPM_STORAGE_DECRYPTION",
+               NULL,
+               NULL, NULL
+       },
 
        /* Krate Policy */
        {
                "krate-create",
+               DPM_SYSPOPUP_DEFAULT,
                false,
                "IDS_DPM_KRATE_CREATE",
                "IDS_DPM_BODY_KRATE_CREATE",
-               "default",
-               "IDS_TPLATFORM_BUTTON2_CANCEL", "IDS_TPLATFORM_BUTTON_OK",
-               "IDS_DPM_NOTI_KRATE_CREATE", "IDS_DPM_NOTI_BODY_KRATE_CREATE"
+               "IDS_TPLATFORM_BUTTON2_CANCEL", "IDS_TPLATFORM_BUTTON_OK"
        },
        {
                "krate-remove",
+               DPM_SYSPOPUP_DEFAULT,
                false,
                "IDS_DPM_KRATE_REMOVE",
                "IDS_DPM_BODY_KRATE_REMOVE",
-               "default",
-               "IDS_TPLATFORM_BUTTON2_CANCEL", "IDS_TPLATFORM_BUTTON_OK",
-               "IDS_DPM_NOTI_KRATE_REMOVE", "IDS_DPM_NOTI_BODY_KRATE_REMOVE"
+               "IDS_TPLATFORM_BUTTON2_CANCEL", "IDS_TPLATFORM_BUTTON_OK"
        },
 };
 
@@ -192,46 +197,16 @@ popup_info_s *get_popup_info(const char *id)
        int i = 0;
 
        if (id == NULL) {
-               dlog_print(DLOG_ERROR, LOG_TAG, "popup_name is NULL");
+               dlog_print(DLOG_ERROR, LOG_TAG, "popup id is NULL");
                return NULL;
        }
 
        for (i = 0; i < ARRAY_SIZE(popup_list); i++) {
-               if (!strcmp(id, popup_list[i].id))
+               if (!strcmp(id, popup_list[i].id)) {
                        return &popup_list[i];
+               }
        }
 
        dlog_print(DLOG_ERROR, LOG_TAG, "[%s] popup is not exist", id);
        return NULL;
 }
-
-int get_popup_text(const char *id, const char *status, char *header, char *body)
-{
-       popup_info_s *info = NULL;
-       char *lp_header = NULL;
-       char *lp_body = NULL;
-
-       info = get_popup_info(id);
-       if (info == NULL)
-               return -1;
-
-       if (info->title != NULL) {
-               if (info->text_prefix) {
-                       lp_header = __("IDS_IDLE_TPOP_SECURITY_POLICY_RESTRICTS_USE_OF_PS");
-                       snprintf(header, PATH_MAX, lp_header, __(info->title));
-               } else {
-                       snprintf(header, PATH_MAX, "%s", __(info->title));
-               }
-       }
-
-       if (info->content != NULL) {
-               if (info->text_prefix) {
-                       lp_body = __("IDS_IDLE_TPOP_SECURITY_POLICY_RESTRICTS_USE_OF_PS");
-                       snprintf(body, PATH_MAX, lp_body, __(info->content));
-               } else {
-                       snprintf(body, PATH_MAX, "%s", __(info->content));
-               }
-       }
-
-       return 0;
-}
old mode 100755 (executable)
new mode 100644 (file)
index 0865e11..507be65
  *
  */
 
-#include <notification.h>
-#include <app_control_internal.h>
-#include <efl_util.h>
-#include <vconf.h>
+#include <system_info.h>
 
 #include "dpm-syspopup.h"
 
-static Evas_Object *main_window;
-
-static void win_delete_request_cb(void *data, Evas_Object *obj, void *event_info)
-{
-       ui_app_exit();
-}
-
-static void create_window(const char *pkg_name)
-{
-       int rots[] = {0, 90, 180, 270};
-       main_window = elm_win_add(NULL, pkg_name, ELM_WIN_NOTIFICATION);
-       efl_util_set_notification_window_level(main_window, EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT);
-
-       if (elm_win_wm_rotation_supported_get(main_window))
-               elm_win_wm_rotation_available_rotations_set(main_window, rots, 4);
-
-       elm_win_title_set(main_window, pkg_name);
-       elm_win_borderless_set(main_window, EINA_TRUE);
-       elm_win_alpha_set(main_window, EINA_TRUE);
-
-       evas_object_smart_callback_add(main_window, "delete,request", win_delete_request_cb, NULL);
-       evas_object_show(main_window);
-}
-
-static void toast_delete_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
-       ui_app_exit();
-}
-
-static void popup_timeout_cb(void *data, Evas_Object *obj, void *event_info)
-{
-       evas_object_del(obj);
-       return;
-}
-
-static void block_clicked_cb(void *data, Evas_Object *obj, void *event_info)
-{
-       evas_object_del(obj);
-       return;
-}
-
-static void syspopup_confirm_button_cb(void *data, Evas_Object *obj, void *event_info)
-{
-       Evas_Object *popup = (Evas_Object *) data;
-       evas_object_data_set(popup, "selected", "ok");
-
-       /* call application */
-       app_control_h app_control = NULL;
-       app_control = (app_control_h)evas_object_data_get(popup, "app-control");
-       if (app_control) {
-               if (app_control_send_launch_request(app_control, NULL, NULL) != APP_CONTROL_ERROR_NONE)
-                       dlog_print(DLOG_ERROR, LOG_TAG, "failed to send launch request");
-       }
-       evas_object_del(popup);
-       return;
-}
-
-static void reply_password_enforce_event_handler(app_control_h ug, app_control_h reply, app_control_result_e result, void *data)
-{
-       Evas_Object *popup = (Evas_Object *) data;
-       char *result_string = NULL;
-       char *current = NULL;
-
-       if (result != APP_CONTROL_RESULT_SUCCEEDED) {
-               dlog_print(DLOG_ERROR, LOG_TAG, "failed to launch app");
-               evas_object_del(popup);
-               return;
-       }
-
-       app_control_get_extra_data(reply, "result", &result_string);
-       if (result_string == NULL) {
-               dlog_print(DLOG_ERROR, LOG_TAG, "failed to get reply.");
-               evas_object_del(popup);
-               return;
-       }
-
-       if (!strcmp(result_string, "SETTING_PW_TYPE_ENTER_LOCK_TYPE") ||
-                       !strcmp(result_string, "SETTING_PW_TYPE_VERIFY_FP_ALT_PASSWORD")) {
-
-               free(result_string);
-               app_control_get_extra_data(reply, "current", &current);
-               if (current != NULL) {
-                       app_control_h app_control = NULL;
-                       if (app_control_create(&app_control) != APP_CONTROL_ERROR_NONE) {
-                               dlog_print(DLOG_ERROR, LOG_TAG, "failed to create app_control context");
-                               evas_object_del(popup);
-                               return;
-                       }
-
-                       app_control_add_extra_data(app_control, "current", current);
-                       app_control_add_extra_data(app_control, "caller", "DPM");
-                       app_control_set_app_id(app_control, "org.tizen.setting-locktype");
-                       app_control_send_launch_request(app_control, NULL, NULL);
-                       app_control_destroy(app_control);
-                       free(current);
-               } else {
-                       dlog_print(DLOG_ERROR, LOG_TAG, "failed to get current password");
-               }
-       }
-       evas_object_del(popup);
-}
-
-static void password_enforce_event_handler(void *data, Evas_Object *obj, void *event_info)
-{
-       int lock_type = 0;
-       Evas_Object *popup = (Evas_Object *) data;
-       app_control_h app_control = NULL;
-
-       evas_object_data_set(popup, "selected", "ok");
-
-       app_control = (app_control_h)evas_object_data_get(popup, "app-control");
-       app_control_add_extra_data(app_control, APP_CONTROL_DATA_SHIFT_WINDOW, "true");
-
-       vconf_get_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &lock_type);
-
-       if (lock_type == SETTING_SCREEN_LOCK_TYPE_PASSWORD || lock_type == SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD) {
-               app_control_add_extra_data(app_control, "viewtype", "SETTING_PW_TYPE_ENTER_LOCK_TYPE");
-               app_control_send_launch_request(app_control, reply_password_enforce_event_handler, popup);
-       } else {
-               app_control_set_app_id(app_control, "org.tizen.setting-locktype");
-               app_control_send_launch_request(app_control, NULL, NULL);
-               evas_object_del(popup);
-       }
-}
-
-static int set_notification(notification_h noti_handle, app_control_h app_control, char *title, char *content)
-{
-       int ret = NOTIFICATION_ERROR_NONE;
-
-       ret = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_TITLE, __(title), NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
-       if (ret != NOTIFICATION_ERROR_NONE)
-               return -1;
-
-       ret = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_CONTENT, __(content), NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
-       if (ret != NOTIFICATION_ERROR_NONE)
-               return -1;
-
-       ret = notification_set_display_applist(noti_handle, NOTIFICATION_DISPLAY_APP_ALL);
-       if (ret != NOTIFICATION_ERROR_NONE)
-               return -1;
-
-       ret = notification_set_image(noti_handle, NOTIFICATION_IMAGE_TYPE_THUMBNAIL, DPM_SYSPOPUP_ICON_PATH);
-       if (ret != NOTIFICATION_ERROR_NONE)
-               return -1;
-
-       ret = notification_set_launch_option(noti_handle, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, app_control);
-       if (ret != NOTIFICATION_ERROR_NONE)
-               return -1;
-
-       return ret;
-}
-
-static void cancel_button_cb(void *data, Evas_Object *obj, void *event_info)
-{
-       Evas_Object *popup = (Evas_Object *) data;
-       evas_object_data_set(popup, "selected", "cancel");
-       evas_object_del(popup);
-       return;
-}
-
-static void syspopup_delete_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
-{
-       popup_info_s *info = (popup_info_s *)data;
-       char *selected = NULL;
-       app_control_h app_control = NULL;
-
-       app_control = (app_control_h)evas_object_data_get(obj, "app-control");
-       selected = (char *)evas_object_data_get(obj, "selected");
-
-       if (!strcmp(selected, "cancel")) {
-               int ret = NOTIFICATION_ERROR_NONE;
-
-               /* create notification */
-               notification_h noti_handle = NULL;
-               noti_handle = notification_create(NOTIFICATION_TYPE_NOTI);
-
-               ret = set_notification(noti_handle, app_control, info->noti_title, info->noti_content);
-               if (ret != NOTIFICATION_ERROR_NONE) {
-                       notification_free(noti_handle);
-                       app_control_destroy(app_control);
-                       return;
-               }
-               notification_post(noti_handle);
-               notification_free(noti_handle);
-       }
-
-       if (app_control) {
-               app_control_destroy(app_control);
-       }
-       ui_app_exit();
-}
-
 static Eina_Bool key_event_cb(void *data, int type, void *event)
 {
        Evas_Object *popup = (Evas_Object *)data;
        Evas_Event_Key_Down *ev = event;
 
-       evas_object_data_set(popup, "selected", "cancel");
+       evas_object_data_set(popup, "status", "cancel");
 
        if (!strcmp(ev->keyname, "XF86Home") || !strcmp(ev->keyname, "XF86Back")) {
                evas_object_del(popup);
@@ -229,83 +34,51 @@ static Eina_Bool key_event_cb(void *data, int type, void *event)
        return EINA_TRUE;
 }
 
-static void create_popup_bottom_button(Evas_Object *popup, char *part, char *text, Evas_Smart_Cb callback)
-{
-       Evas_Object *button = NULL;
-
-       button = elm_button_add(popup);
-       elm_object_style_set(button, "popup");
-       elm_object_text_set(button, __(text));
-       elm_object_part_content_set(popup, part, button);
-       evas_object_smart_callback_add(button, "clicked", callback, popup);
-
-       return;
-}
-
-void create_syspopup(const char *id, char *style, const char *status, app_control_h svc)
+void create_syspopup(const char *id, void *user_data)
 {
-       Evas_Object *popup = NULL;
-       Evas_Smart_Cb confirm_button_cb = NULL;
+       Evas_Object *window = NULL, *popup = NULL;
        popup_info_s *info = NULL;
+       char *manufacturer = NULL;
        int ret = 0;
-       char header[PATH_MAX] = "";
-       char body[PATH_MAX] = "";
-
-       if (!strcmp(id, "password-enforce-change"))
-               confirm_button_cb = password_enforce_event_handler;
-       else
-               confirm_button_cb = syspopup_confirm_button_cb;
 
        info = get_popup_info(id);
-       if (info == NULL)
-               return;
-
-       ret = get_popup_text(id, status, header, body);
-       if (ret != 0) {
-               dlog_print(DLOG_ERROR, LOG_TAG, "failed to get popup text");
+       if (info == NULL) {
+               dlog_print(DLOG_ERROR, LOG_TAG, "failed to get popup info");
                return;
        }
 
-       create_window("dpm-syspopup");
-       popup = elm_popup_add(main_window);
-       evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-
-       if (style != NULL)
-               info->style = style;
+       window = create_window("dpm-syspopup");
 
-       elm_object_style_set(popup, info->style);
-
-       if (!strcmp(info->style, "default")) {
-               if (strcmp(header, "")) {
-                       elm_object_part_text_set(popup, "title,text", header);
-                       elm_object_item_part_text_translatable_set(popup, "title,text", EINA_TRUE);
+       switch (info->viewtype) {
+       case DPM_SYSPOPUP_DEFAULT:
+               ret = system_info_get_platform_string("tizen.org/system/manufacturer", &manufacturer);
+               if (ret != SYSTEM_INFO_ERROR_NONE) {
+                       dlog_print(DLOG_ERROR, LOG_TAG, "failed to get system info");
+                       break;
                }
 
-               if (strcmp(body, ""))
-                       elm_object_text_set(popup, body);
-
-               elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
-               evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, syspopup_delete_cb, info);
-
-               if (svc)
-                       evas_object_data_set(popup, "app-control", svc);
-
-               if (info->left_btn != NULL) {
-                       ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, key_event_cb, popup);
-                       create_popup_bottom_button(popup, "button1", info->left_btn, cancel_button_cb);
-                       create_popup_bottom_button(popup, "button2", info->right_btn, confirm_button_cb);
+               if (!strcmp(manufacturer, "Tizen") && !strcmp(id, "password-enforce-change")) {
+                       popup = create_password_enforce_change_popup(window, info, NULL);
                } else {
-                       create_popup_bottom_button(popup, "button1", info->right_btn, confirm_button_cb);
+                       popup = create_default_popup(window, info, user_data);
+                       ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, key_event_cb, popup);
                }
-       } else {
-               elm_object_text_set(popup, body);
-               elm_popup_timeout_set(popup, 3.0);
-               evas_object_smart_callback_add(popup, "timeout", popup_timeout_cb, NULL);
-               evas_object_smart_callback_add(popup, "block,clicked", block_clicked_cb, NULL);
-               evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, toast_delete_cb, NULL);
+
+               free(manufacturer);
+               break;
+       case DPM_SYSPOPUP_TOAST:
+               popup = create_toast_popup(window, info, NULL);
                ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, key_event_cb, popup);
+               break;
+       default:
+               dlog_print(DLOG_ERROR, LOG_TAG, "Invalid view type");
+               break;
        }
 
-       evas_object_show(popup);
+       if (popup)
+               evas_object_show(popup);
+       else
+               ui_app_exit();
+
        return;
 }
diff --git a/tools/syspopup/src/wearable/default.c b/tools/syspopup/src/wearable/default.c
new file mode 100644 (file)
index 0000000..d35ffc1
--- /dev/null
@@ -0,0 +1,251 @@
+/*
+ *
+ * Copyright (c) 2016 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 <system_info.h>
+
+#include "dpm-syspopup.h"
+
+static const char icon_path[] = "/usr/share/icons/default/small/org.tizen.dpm-syspopup.png";
+static const char *delete_icon_file = "/usr/apps/org.tizen.dpm-syspopup/res/images/tw_ic_popup_btn_delete.png";
+static const char *check_icon_file = "/usr/apps/org.tizen.dpm-syspopup/res/images/tw_ic_popup_btn_check.png";
+
+static appdata_s krate_create_appdata[] = {
+       {"mode", "create"}
+};
+
+static appdata_s krate_remove_appdata[] = {
+       {"mode", "remove"}
+};
+
+static appdata_s password_enforce_change_appdata[] = {
+       {"caller", "dpm"}
+};
+
+static appcontrol_s z3_appcontrol_list[] = {
+       {
+               "krate-create",
+               "org.tizen.krate-setup-wizard",
+               krate_create_appdata,
+               ARRAY_SIZE(krate_create_appdata)
+       },
+       {
+               "krate-remove",
+               "org.tizen.krate-setup-wizard",
+               krate_remove_appdata,
+               ARRAY_SIZE(krate_remove_appdata)
+       }
+};
+
+static appcontrol_s z2_appcontrol_list[] = {
+       {
+               "krate-create",
+               "com.samsung.krate-setup-wizard",
+               krate_create_appdata,
+               ARRAY_SIZE(krate_create_appdata)
+       },
+       {
+               "krate-remove",
+               "com.samsung.krate-setup-wizard",
+               krate_remove_appdata,
+               ARRAY_SIZE(krate_remove_appdata)
+       },
+       {
+               "password-enforce-change",
+               "com.samsung.setting.locktype",
+               password_enforce_change_appdata,
+               ARRAY_SIZE(password_enforce_change_appdata)
+       }
+};
+
+static notification_s notification_list[] = {
+       {
+               "krate-create",
+               "IDS_DPM_NOTI_KRATE_CREATE",
+               "IDS_DPM_NOTI_BODY_KRATE_CREATE",
+               icon_path
+       },
+       {
+               "krate-remove",
+               "IDS_DPM_NOTI_KRATE_REMOVE",
+               "IDS_DPM_NOTI_BODY_KRATE_REMOVE",
+               icon_path
+       }
+};
+
+static void confirm_button_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       Evas_Object *popup = (Evas_Object *) data;
+
+       /* call application */
+       app_control_h app_control = NULL;
+       app_control = (app_control_h)evas_object_data_get(popup, "app-control");
+       if (app_control) {
+               if (app_control_send_launch_request(app_control, NULL, NULL) != APP_CONTROL_ERROR_NONE)
+                       dlog_print(DLOG_ERROR, LOG_TAG, "failed to send launch request");
+       }
+
+       evas_object_data_set(popup, "status", "confirm");
+       evas_object_del(popup);
+       return;
+}
+
+static void cancel_button_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       Evas_Object *popup = (Evas_Object *) data;
+       evas_object_data_set(popup, "status", "cancel");
+       evas_object_del(popup);
+       return;
+}
+
+static void popup_deleted_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+       int ret = 0;
+       char *status = NULL;
+
+       status = (char *)evas_object_data_get(obj, "status");
+
+       if (status != NULL && !strcmp(status, "cancel")) {
+               popup_info_s *info = (popup_info_s *)data;
+               app_control_h app_control = NULL;
+               app_control = (app_control_h)evas_object_data_get(obj, "app-control");
+
+               /* create notification */
+               ret = create_syspopup_notification(notification_list, info->id, app_control);
+               if (ret != 0) {
+                       dlog_print(DLOG_ERROR, LOG_TAG, "cannot create notification");
+               }
+               if (app_control) {
+                       app_control_destroy(app_control);
+               }
+       }
+       ui_app_exit();
+}
+
+static void create_popup_bottom_button(Evas_Object *popup, const char *part, char *text, Evas_Smart_Cb callback)
+{
+       Evas_Object *button = NULL;
+
+       button = create_button(popup, "bottom", __(text), callback, popup);
+       elm_object_part_content_set(popup, part, button);
+
+       return;
+}
+
+static void create_popup_left_button(Evas_Object *popup, Evas_Smart_Cb callback)
+{
+       Evas_Object *button = NULL;
+       Evas_Object *icon = NULL;
+
+       button = create_button(popup, "popup/circle/left", NULL, callback, popup);
+       icon = create_image(button, delete_icon_file);
+       elm_object_part_content_set(button, "elm.swallow.content", icon);
+       elm_object_part_content_set(popup, "button1", button);
+       return;
+}
+
+static void create_popup_right_button(Evas_Object *popup, Evas_Smart_Cb callback)
+{
+       Evas_Object *button = NULL;
+       Evas_Object *icon = NULL;
+
+       button = create_button(popup, "popup/circle/right", NULL, callback, popup);
+       icon = create_image(button, check_icon_file);
+       elm_object_part_content_set(button, "elm.swallow.content", icon);
+
+       elm_object_part_content_set(popup, "button2", button);
+       return;
+}
+
+static void set_appcontrol(Evas_Object *popup, const char *id, void *user_data)
+{
+       app_control_h app_control = NULL;
+       char *manufacturer = NULL;
+
+       system_info_get_platform_string("tizen.org/system/manufacturer", &manufacturer);
+
+       if (!strcmp(manufacturer, "Tizen")) {
+               app_control = create_syspopup_app_control(z3_appcontrol_list, id);
+       } else if (!strcmp(manufacturer, "Samsung")) {
+               app_control = create_syspopup_app_control(z2_appcontrol_list, id);
+       } else {
+               free(manufacturer);
+               dlog_print(DLOG_ERROR, LOG_TAG, "Invalid manufacturer");
+               return;
+       }
+
+       free(manufacturer);
+
+       if (app_control) {
+               if (!strcmp(id, "krate-create") || !strcmp(id, "krate-remove")) {
+                       app_control_add_extra_data(app_control, "krate", (char *)user_data);
+               }
+               evas_object_data_set(popup, "app-control", app_control);
+       }
+       return;
+}
+
+Evas_Object *create_default_popup(Evas_Object *parent, popup_info_s *info, void *user_data)
+{
+       Evas_Object *popup = NULL;
+       Evas_Object *layout = NULL;
+       char header[PATH_MAX] = "";
+       char body[PATH_MAX] = "";
+       char *lp_text = NULL;
+
+       popup = create_popup(parent, "circle");
+       elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
+
+       layout = elm_layout_add(popup);
+       elm_object_content_set(popup, layout);
+
+       if (info->left_btn != NULL) {
+               elm_layout_theme_set(layout, "layout", "popup", "content/circle/buttons2");
+               create_popup_left_button(popup, cancel_button_cb);
+               create_popup_right_button(popup, confirm_button_cb);
+       } else {
+               elm_layout_theme_set(layout, "layout", "popup", "content/circle/buttons1");
+               create_popup_bottom_button(popup, "button1", __(info->right_btn), confirm_button_cb);
+       }
+
+       if (info->header != NULL && info->prefix) {
+               lp_text = __("IDS_IDLE_TPOP_SECURITY_POLICY_RESTRICTS_USE_OF_PS");
+               snprintf(header, PATH_MAX, lp_text, __(info->header));
+       } else if (info->header) {
+               snprintf(header, PATH_MAX, "%s", __(info->header));
+       }
+
+       if (info->body != NULL && info->prefix) {
+               lp_text = __("IDS_IDLE_TPOP_SECURITY_POLICY_RESTRICTS_USE_OF_PS");
+               snprintf(body, PATH_MAX, lp_text, __(info->body));
+       } else if (info->body) {
+               snprintf(body, PATH_MAX, "%s", __(info->body));
+       }
+
+       if (strcmp(header, "")) {
+               elm_object_part_text_set(layout, "elm.text.title", header);
+       }
+
+       if (strcmp(body, "")) {
+               elm_object_part_text_set(layout, "elm.text", body);
+       }
+
+       evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, popup_deleted_cb, info);
+       set_appcontrol(popup, info->id, user_data);
+
+       return popup;
+}
diff --git a/tools/syspopup/src/wearable/password-enforce-change.c b/tools/syspopup/src/wearable/password-enforce-change.c
new file mode 100644 (file)
index 0000000..8e49e5b
--- /dev/null
@@ -0,0 +1,177 @@
+/*
+ *
+ * Copyright (c) 2016 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 <vconf.h>
+
+#include "dpm-syspopup.h"
+
+static appdata_s password_enforce_change_appdata[] = {
+       {"caller", "DPM"},
+       {APP_CONTROL_DATA_SHIFT_WINDOW, "true"}
+};
+
+/* Exception case for platform */
+static appdata_s password_verify_appdata[] = {
+       {"caller", "DPM"},
+       {APP_CONTROL_DATA_SHIFT_WINDOW, "true"},
+       {"viewtype", "SETTING_PW_TYPE_ENTER_LOCK_TYPE"}
+};
+
+static appcontrol_s appcontrol_list[] = {
+       {
+               "password-enforce-change",
+               "org.tizen.setting-locktype",
+               password_enforce_change_appdata,
+               ARRAY_SIZE(password_enforce_change_appdata)
+       },
+       /* Exception case for platform */
+       {
+               "password-verify",
+               "org.tizen.setting-password",
+               password_verify_appdata,
+               ARRAY_SIZE(password_verify_appdata)
+       }
+};
+
+static void reply_event_handler(app_control_h ug, app_control_h reply, app_control_result_e result, void *data)
+{
+       Evas_Object *popup = (Evas_Object *) data;
+       char *result_string = NULL;
+       char *current = NULL;
+
+       if (result != APP_CONTROL_RESULT_SUCCEEDED) {
+               dlog_print(DLOG_ERROR, LOG_TAG, "failed to launch app");
+               evas_object_del(popup);
+               return;
+       }
+
+       app_control_get_extra_data(reply, "result", &result_string);
+       if (result_string == NULL) {
+               dlog_print(DLOG_ERROR, LOG_TAG, "failed to get reply.");
+               evas_object_del(popup);
+               return;
+       }
+
+       if (!strcmp(result_string, "SETTING_PW_TYPE_ENTER_LOCK_TYPE") ||
+                       !strcmp(result_string, "SETTING_PW_TYPE_VERIFY_FP_ALT_PASSWORD")) {
+               free(result_string);
+               app_control_get_extra_data(reply, "current", &current);
+               if (current != NULL) {
+                       app_control_h app_control = NULL;
+                       app_control = (app_control_h)evas_object_data_get(popup, "app-control");
+                       if (app_control) {
+                               app_control_add_extra_data(app_control, "current", current);
+                               app_control_send_launch_request(app_control, NULL, NULL);
+                               app_control_destroy(app_control);
+                       }
+                       free(current);
+               } else {
+                       dlog_print(DLOG_ERROR, LOG_TAG, "failed to get current password");
+               }
+       }
+
+       evas_object_del(popup);
+       return;
+}
+
+static void confirm_button_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       Evas_Object *popup = (Evas_Object *) data;
+       int lock_type = 0;
+       app_control_h app_control = NULL;
+
+       evas_object_data_set(popup, "status", "confirm");
+       vconf_get_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &lock_type);
+
+       if (lock_type == SETTING_SCREEN_LOCK_TYPE_PASSWORD
+                       || lock_type == SETTING_SCREEN_LOCK_TYPE_SIMPLE_PASSWORD) {
+               app_control = create_syspopup_app_control(appcontrol_list, "password-verify");
+               if (app_control) {
+                       app_control_send_launch_request(app_control, reply_event_handler, popup);
+                       app_control_destroy(app_control);
+               }
+       } else {
+               app_control = (app_control_h)evas_object_data_get(popup, "app-control");
+               if (app_control) {
+                       app_control_send_launch_request(app_control, NULL, NULL);
+                       app_control_destroy(app_control);
+               }
+               evas_object_del(popup);
+       }
+}
+
+static void popup_deleted_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+       ui_app_exit();
+}
+
+static void create_popup_bottom_button(Evas_Object *popup, const char *part, char *text, Evas_Smart_Cb callback)
+{
+       Evas_Object *button = NULL;
+
+       button = create_button(popup, "bottom", __(text), callback, popup);
+       elm_object_part_content_set(popup, part, button);
+       return;
+}
+
+Evas_Object *create_password_enforce_change_popup(Evas_Object *parent, popup_info_s *info, void *user_data)
+{
+       Evas_Object *popup = NULL;
+       Evas_Object *layout = NULL;
+       app_control_h app_control = NULL;
+       char header[PATH_MAX] = "";
+       char body[PATH_MAX] = "";
+       char *lp_text = NULL;
+
+       popup = create_popup(parent, "circle");
+       elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
+
+       layout = elm_layout_add(popup);
+       elm_object_content_set(popup, layout);
+       elm_layout_theme_set(layout, "layout", "popup", "content/circle/buttons1");
+
+       if (info->header != NULL && info->prefix) {
+               lp_text = __("IDS_IDLE_TPOP_SECURITY_POLICY_RESTRICTS_USE_OF_PS");
+               snprintf(header, PATH_MAX, lp_text, __(info->header));
+       } else if (info->header) {
+               snprintf(header, PATH_MAX, "%s", __(info->header));
+       }
+
+       if (info->body != NULL && info->prefix) {
+               lp_text = __("IDS_IDLE_TPOP_SECURITY_POLICY_RESTRICTS_USE_OF_PS");
+               snprintf(body, PATH_MAX, lp_text, __(info->body));
+       } else if (info->body) {
+               snprintf(body, PATH_MAX, "%s", __(info->body));
+       }
+
+       if (strcmp(header, "")) {
+               elm_object_part_text_set(layout, "elm.text.title", header);
+       }
+
+       if (strcmp(body, "")) {
+               elm_object_part_text_set(layout, "elm.text", body);
+       }
+
+       create_popup_bottom_button(popup, "button1", info->right_btn, confirm_button_cb);
+       evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, popup_deleted_cb, NULL);
+
+       app_control = create_syspopup_app_control(appcontrol_list, info->id);
+       evas_object_data_set(popup, "app-control", app_control);
+
+       return popup;
+}
diff --git a/tools/syspopup/src/wearable/toast.c b/tools/syspopup/src/wearable/toast.c
new file mode 100644 (file)
index 0000000..9c5e4e5
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2016 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 "dpm-syspopup.h"
+
+static void popup_timeout_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       evas_object_del(obj);
+       return;
+}
+
+static void block_clicked_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       evas_object_del(obj);
+       return;
+}
+
+static void popup_deleted_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+{
+       ui_app_exit();
+}
+
+Evas_Object *create_toast_popup(Evas_Object *parent, popup_info_s *info, void *user_data)
+{
+       Evas_Object *popup = NULL;
+       char body[PATH_MAX] = "";
+       char *lp_text = NULL;
+
+       if (info->prefix) {
+               lp_text =  __("IDS_IDLE_TPOP_SECURITY_POLICY_RESTRICTS_USE_OF_PS");
+               snprintf(body, PATH_MAX, lp_text, __(info->body));
+       } else {
+               snprintf(body, PATH_MAX, "%s", __(info->body));
+       }
+
+       popup = create_popup(parent, "toast/circle");
+       elm_popup_orient_set(popup, ELM_POPUP_ORIENT_CENTER);
+       elm_object_part_text_set(popup, "elm.text", body);
+       elm_popup_timeout_set(popup, 3.0);
+       evas_object_smart_callback_add(popup, "timeout", popup_timeout_cb, NULL);
+       evas_object_smart_callback_add(popup, "block,clicked", block_clicked_cb, NULL);
+       evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, popup_deleted_cb, NULL);
+
+       return popup;
+}
diff --git a/tools/syspopup/src/widget.c b/tools/syspopup/src/widget.c
new file mode 100644 (file)
index 0000000..33f1bf8
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ *
+ * Copyright (c) 2016 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 <efl_util.h>
+
+#include "dpm-syspopup.h"
+
+static void win_delete_request_cb(void *data, Evas_Object *obj, void *event_info)
+{
+       ui_app_exit();
+}
+
+Evas_Object *create_window(const char *pkg_name)
+{
+       Evas_Object *window = NULL;
+       int rots[] = {0, 90, 180, 270};
+
+       window = elm_win_add(NULL, pkg_name, ELM_WIN_NOTIFICATION);
+       efl_util_set_notification_window_level(window, EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT);
+
+       if (elm_win_wm_rotation_supported_get(window))
+               elm_win_wm_rotation_available_rotations_set(window, rots, 4);
+
+       elm_win_title_set(window, pkg_name);
+       elm_win_borderless_set(window, EINA_TRUE);
+       elm_win_alpha_set(window, EINA_TRUE);
+
+       evas_object_smart_callback_add(window, "delete,request", win_delete_request_cb, NULL);
+       evas_object_show(window);
+
+       return window;
+}
+
+Evas_Object *create_popup(Evas_Object *parent, const char *style)
+{
+       Evas_Object *popup = NULL;
+
+       popup = elm_popup_add(parent);
+       evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       if (style)
+               elm_object_style_set(popup, style);
+
+       return popup;
+}
+
+Evas_Object *create_button(Evas_Object *parent, const char *style, const char *text, Evas_Smart_Cb callback, void *data)
+{
+       Evas_Object *button = NULL;
+
+       button = elm_button_add(parent);
+       if (style)
+               elm_object_style_set(button, style);
+       if (text)
+               elm_object_text_set(button, text);
+       if (callback)
+               evas_object_smart_callback_add(button, "clicked", callback, data);
+
+       return button;
+}
+
+Evas_Object *create_image(Evas_Object *parent, const char *path)
+{
+       Evas_Object *image = NULL;
+
+       if (path == NULL) {
+               return NULL;
+       }
+
+       image = elm_image_add(parent);
+       elm_image_file_set(image, path, NULL);
+       evas_object_size_hint_weight_set(image, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       evas_object_show(image);
+
+       return image;
+}