summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYunjin Lee <yunjin-.lee@samsung.com>2017-07-18 13:48:00 +0900
committerYunjin Lee <yunjin-.lee@samsung.com>2017-07-18 19:48:18 +0900
commit0ecd04ff180e383716e5fc34e8cc26cc0b436323 (patch)
tree26a09c4394daab7f7792e57d72c587a61e0a9b14
parentffecd04044d2955469f918403a128977849114f1 (diff)
downloadprivacy-setting-0ecd04ff180e383716e5fc34e8cc26cc0b436323.tar.gz
privacy-setting-0ecd04ff180e383716e5fc34e8cc26cc0b436323.tar.bz2
privacy-setting-0ecd04ff180e383716e5fc34e8cc26cc0b436323.zip
Apply new privacy setting UX
- Shows package list with privacy privilege first: Shows package label and enabled privacy list - Change privacy setting after selecting package Change-Id: I5c4e7e88a7d5794ae15d8d1309f477891fbbd05b Signed-off-by: Yunjin Lee <yunjin-.lee@samsung.com>
-rw-r--r--common/include/common_utils.h36
-rw-r--r--common/src/common_utils.c79
-rwxr-xr-xpackaging/org.tizen.privacy-setting.spec3
-rwxr-xr-xui/CMakeLists.txt4
-rwxr-xr-xui/include/privacy_view.h24
-rw-r--r--ui/src/main_privacy_setting.c11
-rw-r--r--ui/src/package_list_view.c282
-rw-r--r--ui/src/package_privacy_list_view.c221
-rw-r--r--ui/src/privacy_list_view.c122
-rw-r--r--ui/src/privacy_package_list_view.c475
10 files changed, 619 insertions, 638 deletions
diff --git a/common/include/common_utils.h b/common/include/common_utils.h
index 6cda564..5743da2 100644
--- a/common/include/common_utils.h
+++ b/common/include/common_utils.h
@@ -62,29 +62,45 @@ extern "C" {
} \
}
-typedef struct _app_data_s{
- Evas_Object *parent_layout;
+typedef struct {
+ char* privacy;
+ GList* privilege_list;
+ bool status;
+} priv_data_s;
+
+typedef struct {
+ char* pkgid;
+ char* pkg_label;
+ GList* app_list;
+ GList* pd_list;
+} app_priv_data_s;
+
+typedef struct _app_data_s {
Evas_Object *win;
Evas_Object *conform;
- Evas_Object *bg;
Evas_Object *layout;
Evas_Object *nf;
- void *data;
- Elm_Theme *theme;
Eext_Circle_Surface *circle_surface;
- Evas_Coord root_w;
- Evas_Coord root_h;
- GList *privacy_list;
- char* privacy;
+ GList *package_list;
+ char* pkgid;
+ char* pkg_label;
+ GList* apd_list;
+ Elm_Object_Item* selected_item;
} app_data_s;
Evas_Object *common_genlist_add(Evas_Object *parent);
Evas_Object *common_back_btn_add(app_data_s *ad);
+
void connect_genlist_to_wheel(Evas_Object *genlist, app_data_s *ad);
-app_data_s *get_app_data();
+void back_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info);
+
+priv_data_s* new_priv_data();
+app_priv_data_s* new_app_priv_data();
+
+void free_app_data(app_data_s *ad);
#ifdef _cplusplus
}
diff --git a/common/src/common_utils.c b/common/src/common_utils.c
index 28cc50b..e2daf01 100644
--- a/common/src/common_utils.c
+++ b/common/src/common_utils.c
@@ -48,10 +48,14 @@ void connect_genlist_to_wheel(Evas_Object *genlist, app_data_s *ad)
evas_object_show(circle_genlist);
}
-static void back_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
+void back_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
{
app_data_s *ad = (app_data_s *)data;
return_if(!ad, , , "ad is null");
+
+ if (ad->selected_item != NULL)
+ elm_genlist_item_update(ad->selected_item);
+
elm_naviframe_item_pop(ad->nf);
}
@@ -63,3 +67,76 @@ Evas_Object *common_back_btn_add(app_data_s *ad)
return btn;
}
+
+priv_data_s* new_priv_data()
+{
+ priv_data_s* pd = (priv_data_s*)malloc(sizeof(priv_data_s));
+ if (pd == NULL)
+ return NULL;
+ pd->privacy = NULL;
+ pd->privilege_list = NULL;
+ pd->status = false;
+ return pd;
+}
+
+app_priv_data_s* new_app_priv_data()
+{
+ app_priv_data_s* apd = (app_priv_data_s*)malloc(sizeof(app_priv_data_s));
+ if (apd == NULL)
+ return NULL;
+ apd->pkgid = NULL;
+ apd->pkg_label = NULL;
+ apd->app_list = NULL;
+ apd->pd_list = NULL;
+ return apd;
+}
+
+void init_app_data(app_data_s* ad)
+{
+ ad->package_list = NULL;
+ ad->pkgid = NULL;
+ ad->pkg_label = NULL;
+ ad->apd_list = NULL;
+}
+
+static void __free_priv_data(priv_data_s* pd)
+{
+ if (pd->privacy)
+ free(pd->privacy);
+ if (pd->privilege_list)
+ g_list_free_full(pd->privilege_list, free);
+}
+
+static void free_priv_data(gpointer pd)
+{
+ __free_priv_data((priv_data_s*) pd);
+}
+
+static void __free_app_priv_data(app_priv_data_s* apd)
+{
+ if (apd->pkgid != NULL)
+ free(apd->pkgid);
+ if (apd->pkg_label != NULL)
+ free(apd->pkg_label);
+ if (apd->app_list != NULL)
+ g_list_free_full(apd->app_list, free);
+ if (apd->pd_list != NULL)
+ g_list_free_full(apd->pd_list, free_priv_data);
+}
+
+static void free_app_priv_data(gpointer apd)
+{
+ __free_app_priv_data((app_priv_data_s*) apd);
+}
+
+void free_app_data(app_data_s* ad)
+{
+ if (ad->pkgid != NULL)
+ free(ad->pkgid);
+ if (ad->pkg_label != NULL)
+ free(ad->pkg_label);
+ if (ad->package_list != NULL)
+ g_list_free_full(ad->package_list, free);
+ if (ad->apd_list != NULL)
+ g_list_free_full(ad->apd_list, free_app_priv_data);
+}
diff --git a/packaging/org.tizen.privacy-setting.spec b/packaging/org.tizen.privacy-setting.spec
index 15bdbde..fed647f 100755
--- a/packaging/org.tizen.privacy-setting.spec
+++ b/packaging/org.tizen.privacy-setting.spec
@@ -64,7 +64,8 @@ make %{?_smp_mflags}
%post
/sbin/ldconfig
# Only for testing -> Fllowing single line must be removed
-cyad -s -k MANIFESTS -c User::Pkg::org.tizen.privacy-setting -u 5001 -p http://tizen.org/privilege/notexist -t ALLOW
+cyad -s -k MANIFESTS_GLOBAL -c User::Pkg::org.tizen.privacy-setting -u 5001 -p http://tizen.org/privilege/notexist -t ALLOW
+cyad -s -k MANIFESTS_GLOBAL -c User::Pkg::org.tizen.privacy-setting -u 5001 -p http://tizen.org/privilege/internal/usermanagement -t ALLOW
echo "cyad done"
%postun -p /sbin/ldconfig
diff --git a/ui/CMakeLists.txt b/ui/CMakeLists.txt
index d27cf83..fc967c0 100755
--- a/ui/CMakeLists.txt
+++ b/ui/CMakeLists.txt
@@ -6,8 +6,8 @@ pkg_check_modules(${pkg_name} REQUIRED glib-2.0 ui-gadget-1 evas elementary edje
SET(SRCS
${CMAKE_SOURCE_DIR}/common/src/common_utils.c
src/main_privacy_setting.c
- src/privacy_list_view.c
- src/privacy_package_list_view.c
+ src/package_list_view.c
+ src/package_privacy_list_view.c
)
FOREACH(flag ${${pkg_name}_CFLAGS})
diff --git a/ui/include/privacy_view.h b/ui/include/privacy_view.h
index fe9ad46..c650906 100755
--- a/ui/include/privacy_view.h
+++ b/ui/include/privacy_view.h
@@ -31,26 +31,8 @@
#define PRIVACY_MENU_SETTING "IDS_ST_HEADER_PRIVACY_SETTINGS_ABB"
-typedef struct {
- char* pkgid;
- char* label;
- GList* applist; /* TBD: Modify appid to pkgid : remove item */
- GList* privlist;
- bool status; /* original status */
- bool is_global;
-} pkg_data_s;
-
-typedef struct item_data {
- int index;
- char *title;
- char *pkgid;
- char *privacy;
- char *menu;
- bool status;
-} item_data_s;
-
-void create_privacy_package_list_view(app_data_s *ad);
-
-void create_privacy_list_view(app_data_s *ad);
+void create_package_privacy_list_view(app_data_s *ad);
+
+void create_package_list_view(app_data_s *ad);
diff --git a/ui/src/main_privacy_setting.c b/ui/src/main_privacy_setting.c
index a7e69b9..40e70b4 100644
--- a/ui/src/main_privacy_setting.c
+++ b/ui/src/main_privacy_setting.c
@@ -31,6 +31,7 @@
static void win_delete_request_cb(void *data, Evas_Object * obj, void *event_info)
{
+ LOGD("win del req");
ui_app_exit();
}
@@ -61,11 +62,12 @@ static void app_start(void* data)
elm_object_part_content_set(ad->layout, "elm.swallow.content", ad->nf);
elm_naviframe_event_enabled_set(ad->nf, EINA_TRUE);
- eext_object_event_callback_add(ad->nf, EEXT_CALLBACK_BACK, eext_naviframe_back_cb, NULL);
+ //eext_object_event_callback_add(ad->nf, EEXT_CALLBACK_BACK, eext_naviframe_back_cb, NULL);
+ eext_object_event_callback_add(ad->nf, EEXT_CALLBACK_BACK, back_btn_clicked_cb, ad);
eext_object_event_callback_add(ad->nf, EEXT_CALLBACK_MORE, eext_naviframe_more_cb, NULL);
- /* Get privacy list view */
- create_privacy_list_view(ad);
+ /* Get package list view */
+ create_package_list_view(ad);
evas_object_show(ad->win);
return ;
@@ -88,11 +90,8 @@ static bool app_create(void * data)
evas_object_smart_callback_add(ad->win, "delete,request", win_delete_request_cb, NULL);
app_start(ad);
-
evas_object_show(ad->win);
- //app_start(ad);
-
return true;
}
diff --git a/ui/src/package_list_view.c b/ui/src/package_list_view.c
new file mode 100644
index 0000000..da64a17
--- /dev/null
+++ b/ui/src/package_list_view.c
@@ -0,0 +1,282 @@
+/**
+ * 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.
+ */
+/*
+ * @file privacy_list_view.c
+ * @author Yunjin Lee (yunjin-.lee@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+
+#include <efl_extension.h>
+
+#include "common_utils.h"
+#include "privacy_view.h"
+#include <privilege_info.h>
+#include <privilege_package_info.h>
+#include <policy-manager.h>
+#include <glib.h>
+#include <pkgmgr-info.h>
+#include <string.h>
+
+static void gl_realized_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ app_data_s* ad = data;
+ Elm_Object_Item *item = (Elm_Object_Item *)event_info;
+ elm_object_item_signal_emit(item, "elm,action,title,slide,start", "elm");
+}
+
+static char* gl_text_get_cb(void *data, Evas_Object *obj, const char *part)
+{
+ app_priv_data_s* apd = (app_priv_data_s*)data;
+
+ int ret;
+ if (!strcmp(part, "elm.text")) {
+ return strdup(apd->pkg_label);
+ } else if (!strcmp(part, "elm.text.1")) {
+ char privacy_list_string[512];
+ memset(privacy_list_string, 0x00, 512);
+ int len = 0;
+ GList* l;
+ for (l = apd->pd_list; l != NULL; l = l->next) {
+ priv_data_s* pd = (priv_data_s*)l->data;
+ if (pd->status) {
+ char* privacy_display;
+ ret = privilege_info_get_privacy_display(pd->privacy, &privacy_display);
+ if (ret != PRVMGR_ERR_NONE)
+ LOGE("file to get privacy display for %s", pd->privacy);
+
+ if (len == 0) {
+ len += snprintf(privacy_list_string, 512, "%s", privacy_display);;
+ } else {
+ len += snprintf(privacy_list_string+len, 512, ", %s", privacy_display);
+ }
+ }
+ }
+ if (strlen(privacy_list_string) == 0)
+ return strdup("None granted");
+
+ return strdup(privacy_list_string);
+ }
+ return "FAIL";
+}
+
+static char* gl_title_text_get_cb(void *data, Evas_Object *obj, const char *part)
+{
+ return strdup(dgettext("privacy-setting", PRIVACY_MENU_SETTING));
+}
+
+static void gl_del_cb(void *data, Evas_Object *obj)
+{
+ app_data_s* ad = (app_data_s*)data;
+ if (ad == NULL)
+ LOGE("ad is null. can not free null.");
+ free_app_data(ad);
+ ui_app_exit();
+}
+
+static void package_selected_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ /* Get selected privacy */
+ Elm_Object_Item *ei = event_info;
+ app_priv_data_s* apd = elm_object_item_data_get(ei);
+
+ /* Unhighlight selected item */
+ elm_genlist_item_selected_set(ei, EINA_FALSE);
+
+ app_data_s *ad = (app_data_s *)data;
+
+ ad->pkgid = apd->pkgid;
+ ad->selected_item = ei;
+
+ create_package_privacy_list_view(ad);
+}
+
+static void __get_package_privacy_privilege_status(bool* status, const char* privilege_name, GList* app_list)
+{
+ GList* l;
+
+ for (l = app_list; l != NULL; l = l->next) {
+ char* appid = (char*)l->data;
+
+ /* Make policy filter to get specific uid, appid and privilege's status */
+ policy_entry* p_filter;
+ int ret = 0;
+ ret = security_manager_policy_entry_new(&p_filter);
+ log_if(ret != SECURITY_MANAGER_SUCCESS, 1, "security_manager_policy_entry_new failed. ret = %s", ret);
+ log_if(p_filter == NULL, 1, "security_manager_policy_entry_new failed failed. creation of new policy entry did not allocate memory");
+
+ ret = security_manager_policy_entry_set_application(p_filter, appid);
+ log_if(ret != SECURITY_MANAGER_SUCCESS, 1, "security_manager_policy_entry_set_application failed. ret = %d", ret);
+
+ security_manager_policy_entry_set_privilege(p_filter, privilege_name);
+ log_if(ret != SECURITY_MANAGER_SUCCESS, 1, "security_manager_policy_entry_set_privilege failed. ret = %d", ret);
+
+ /* Get policy filtered by p_filter */
+ policy_entry **pp_policy = NULL;
+ size_t pp_policy_size = 0;
+ ret = security_manager_get_policy(p_filter, &pp_policy, &pp_policy_size);
+ log_if(ret != SECURITY_MANAGER_SUCCESS || pp_policy_size <= 0, 1, "security_manager_get_policy failed. ret = %d, pp_policy_size = %d", ret, pp_policy_size);
+
+ /* Get level from policy */
+ unsigned int i = 0;
+ for (i = 0; i < pp_policy_size; ++i) {
+ char* result = (char*)security_manager_policy_entry_get_level(pp_policy[i]);
+ log_if(result == NULL, 1, "security_manager_policy_entry_get_level failed. No policy is declared for appid: %s, privilege: %s", appid, privilege_name);
+ if (strcmp("Allow", result) == 0) {
+ *status = EINA_TRUE;
+ break;
+ } else if (strcmp("Deny", result) == 0 || strcmp("Ask user", result) == 0) {
+ *status = EINA_FALSE;
+ break;
+ } else {
+ LOGE("Unknown policy level: %s", result);
+ break;
+ }
+ }
+
+ /* Free policy entries */
+ security_manager_policy_entry_free(p_filter);
+ for (i = 0; i < pp_policy_size ; ++i)
+ security_manager_policy_entry_free(pp_policy[i]);
+
+ if (*status == EINA_TRUE)
+ break;
+ }
+}
+
+static int pkg_app_list_cb(pkgmgrinfo_appinfo_h pkg_handle, void* user_data)
+{
+ char* appid = NULL;
+ app_priv_data_s* apd = (app_priv_data_s*)user_data;
+ int ret = pkgmgrinfo_appinfo_get_appid(pkg_handle, &appid);
+ return_if(ret != PMINFO_R_OK, , -1, "pkgmgrinfo_appinfo_get_appid failed");
+ char* appidd = strdup(appid);
+ apd->app_list = g_list_append(apd->app_list, appidd);
+ return ret;
+}
+
+static void get_app_priv_data(app_data_s *ad)
+{
+ GList *package_list = NULL;
+ int ret = privilege_package_info_get_all_privacy_package_list(getuid(), &package_list);
+ log_if(ret != PRVMGR_ERR_NONE, 1, "Failed to get privacy_list");
+ GList* l;
+ for (l = package_list; l != NULL; l = l->next) {
+ /* package id */
+ char* pkgid = (char*)l->data;
+ app_priv_data_s* apd = new_app_priv_data();
+ apd->pkgid = strdup(pkgid);
+ /* package label */
+ pkgmgrinfo_pkginfo_h handle;
+ ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
+ log_if(ret != PMINFO_R_OK, 1, "pkgmgrinfo_pkginfo_get_pkginfo failed");
+ char* label = NULL;
+ ret = pkgmgrinfo_pkginfo_get_label(handle, &label);
+ if (ret != PMINFO_R_OK)
+ LOGE("pkgmgrinfo_pkginfo_get_label failed");
+ apd->pkg_label = strdup(label);
+ /* package app list */
+ apd->app_list = NULL;
+ ret = pkgmgrinfo_appinfo_get_list(handle, PMINFO_ALL_APP, pkg_app_list_cb, apd);
+ if (ret != PMINFO_R_OK)
+ LOGE("pkgmgrinfo_appinfo_get_list failed");
+
+ /* Get package privacy info */
+ /* package privacy list */
+ uid_t uid = getuid();
+ GList* privacy_list = NULL;
+ ret = privilege_package_info_get_privacy_list_by_pkgid(uid, pkgid, &privacy_list);
+ if (ret != PRVMGR_ERR_NONE || privacy_list == NULL)
+ LOGE("failed to get packge privacy list");
+
+ GList* ll;
+ GList* lll;
+ for (ll = privacy_list; ll != NULL; ll = ll->next) {
+ char* privacy = (char*)ll->data;
+ priv_data_s* pd = new_priv_data();
+ pd->privacy = strdup(privacy);
+ GList* privilege_list = NULL;
+ /* privilege list */
+ ret = privilege_package_info_get_privilege_list_by_pkgid_and_privacy(uid, pkgid, privacy, &privilege_list);
+ if (ret != PRVMGR_ERR_NONE)
+ LOGE("privilege_package_info_get_privilege_list_by_pkgid_and_privacy failed");
+ pd->privilege_list = privilege_list;
+ /* package privacy status */
+ for (lll = privilege_list; lll != NULL; lll = lll->next) {
+ char* privilege = (char*)lll->data;
+ if (!pd->status)
+ __get_package_privacy_privilege_status(&(pd->status), privilege, apd->app_list);
+ }
+ apd->pd_list = g_list_append(apd->pd_list, pd);
+ }
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+ g_list_free(privacy_list);
+ ad->apd_list = g_list_append(ad->apd_list, apd);
+ }
+}
+
+/*Privacy List*/
+void create_package_list_view(app_data_s *ad)
+{
+ LOGD("package_list_view");
+ int ret = privilege_package_info_get_all_privacy_package_list(getuid(), &(ad->package_list));
+ log_if(ret != PRVMGR_ERR_NONE, 1, "Failed to get privacy_list");
+
+ get_app_priv_data(ad);
+ ad->selected_item = NULL;
+
+ Evas_Object *genlist = common_genlist_add(ad->nf);
+ connect_genlist_to_wheel(genlist, ad);
+
+ Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
+ Elm_Genlist_Item_Class *ttc = elm_genlist_item_class_new();
+ Elm_Genlist_Item_Class *ptc = elm_genlist_item_class_new();
+
+ itc->item_style = "2text";
+ itc->func.text_get = gl_text_get_cb;
+ itc->func.del = NULL;
+
+ ttc->item_style = "title";
+ ttc->func.text_get = gl_title_text_get_cb;
+ ttc->func.del = gl_del_cb;
+
+ ptc->item_style = "padding";
+ ptc->func.del = NULL;
+
+ Elm_Object_Item *it = NULL;
+
+ evas_object_smart_callback_add(genlist, "realized", gl_realized_cb, ad);
+
+ elm_genlist_item_append(genlist, ttc, ad, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
+ int i = 0;
+ for (i = 0; i < (int)g_list_length(ad->apd_list); ++i) {
+ it = elm_genlist_item_append(genlist, itc, (char*)g_list_nth_data(ad->apd_list, i), NULL, ELM_GENLIST_ITEM_NONE, package_selected_cb, ad);
+ log_if(it == NULL, 1, "Error in elm_genlist_item_append");
+ }
+
+ /* Add empty line at bottom of the genlist for usability */
+ elm_genlist_item_append(genlist, ptc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
+
+ elm_genlist_item_class_free(itc);
+ elm_genlist_item_class_free(ttc);
+ elm_genlist_item_class_free(ptc);
+ evas_object_show(genlist);
+
+ Elm_Object_Item *nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, genlist, "empty");
+
+ elm_object_item_domain_text_translatable_set(nf_it, PACKAGE, EINA_TRUE);
+}
+
diff --git a/ui/src/package_privacy_list_view.c b/ui/src/package_privacy_list_view.c
new file mode 100644
index 0000000..e942ed5
--- /dev/null
+++ b/ui/src/package_privacy_list_view.c
@@ -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.
+ */
+/*
+ * @file privacy_package_list_view.c
+ * @author Yunjin Lee (yunjin-.lee@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+
+#include <efl_extension.h>
+#include <policy-manager.h>
+#include <privilege_info.h>
+#include <privilege_package_info.h>
+#include <glib.h>
+#include <pkgmgr-info.h>
+#include <tzplatform_config.h>
+
+#include "common_utils.h"
+#include "privacy_view.h"
+
+app_priv_data_s* pp_apd;
+static GList* pp_app_list;
+
+static void package_privacy_check_changed_cb(void *data, Evas_Object *obj, void *event_info);
+
+static void gl_title_text_del_cb(void *data, Evas_Object *obj)
+{
+ if (data) {
+ LOGD("gl_title_text_del : %s", data);
+ free(data);
+ }
+}
+
+static char* gl_text_get_cb(void *data, Evas_Object *obj, const char *part)
+{
+ priv_data_s* pd = (priv_data_s*)data;
+ char* privacy_display = NULL;
+ privilege_info_get_privacy_display(pd->privacy, &privacy_display);
+ lreturn_if(!strcmp(part, "elm.text"), , privacy_display, "privacy: %s", pd->privacy);
+ return "FAIL";
+}
+
+static char* gl_title_text_get_cb(void *data, Evas_Object *obj, const char *part)
+{
+ return strdup(pp_apd->pkg_label);
+}
+
+static Evas_Object* gl_content_get_cb(void *data, Evas_Object *obj, const char *part)
+{
+ Evas_Object *check;
+ priv_data_s *pd = (priv_data_s*)data;
+ Eina_Bool status = pd->status;
+
+ if (strcmp(part, "elm.icon"))
+ return NULL;
+
+ check = elm_check_add(obj);
+
+ elm_object_style_set(check, "on&off");
+ elm_check_state_set(check, status);
+ evas_object_propagate_events_set(check, EINA_FALSE);
+ evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_smart_callback_add(check, "changed", package_privacy_check_changed_cb, pd);
+ evas_object_show(check);
+
+ return check;
+}
+
+static void gl_realized_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ Evas_Object *genlist = data;
+ Elm_Object_Item *item = (Elm_Object_Item *)event_info;
+ Elm_Object_Item *first = elm_genlist_first_item_get(genlist);
+ if (first == item)
+ elm_object_item_signal_emit(first, "elm,action,title,slide,start", "elm");
+}
+
+static void package_privacy_check_changed_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ Elm_Object_Item *ei = event_info;
+ elm_genlist_item_selected_set(ei, EINA_FALSE);
+ elm_genlist_item_update(ei);
+ priv_data_s* pd = (priv_data_s*)data;
+ Eina_Bool status;
+
+ /* Send policy change request to security-manager */
+ GList* l;
+ GList* ll;
+ GList* lll;
+ int ret = 0;
+ char* level;
+ if (pd->status) {
+ level = "Ask user";
+ pd->status = false;
+ } else {
+ level = "Allow";
+ pd->status = true;
+ }
+
+
+ LOGD("%s will be changed to %s", pd->privacy, level);
+
+ int priv_num = g_list_length(pd->privilege_list);
+ int app_num = g_list_length(pp_app_list);
+ int entry_num = priv_num*app_num;
+
+ /* Make policy update request */
+ policy_update_req *policy_update_request;
+ ret = security_manager_policy_update_req_new(&policy_update_request);
+ log_if(ret != SECURITY_MANAGER_SUCCESS, 1, "security_manager_policy_update_req_new failed. ret = %d", ret);
+ log_if(policy_update_request == NULL, 1, "security_manager_policy_entry_new failed failed. creation of new policy request did not allocate memory");
+ /* Make policy entries to update according to the number of privilege and appid of package */
+ policy_entry *entry[entry_num];
+ int entry_index = 0;
+ for (ll = pp_app_list; ll != NULL; ll = ll->next) {
+ char* appid = (char*)ll->data;
+ for (lll = pd->privilege_list; lll != NULL; lll = lll->next) {
+ char* privilege_name = (char*)lll->data;
+ LOGD("%d: Change to %s => appid: %s, privilege_name: %s", entry_index, level, appid, privilege_name);
+ /* Make entries by each appid, and privilege_name */
+ ret = security_manager_policy_entry_new(&entry[entry_index]);
+ log_if(ret != SECURITY_MANAGER_SUCCESS, 1, "security_manager_policy_entry_new failed. ret = %d", ret);
+ log_if(entry[entry_index] == NULL, 1, "security_manager_policy_entry_new failed failed. creation of new policy entry did not allocate memory");
+ ret = security_manager_policy_entry_set_application(entry[entry_index], appid);
+ log_if(ret != SECURITY_MANAGER_SUCCESS, 1, "security_manager_policy_entry_set_application failed. ret = %d", ret);
+ ret = security_manager_policy_entry_set_privilege(entry[entry_index], privilege_name);
+ log_if(ret != SECURITY_MANAGER_SUCCESS, 1, "security_manager_policy_entry_set_privilege failed. ret = %d", ret);
+ ret = security_manager_policy_entry_set_level(entry[entry_index], level);
+ log_if(ret != SECURITY_MANAGER_SUCCESS, 1, "security_manager_policy_entry_set_level failed. ret = %d", ret);
+
+ /* Add entry to policy update request */
+ ret = security_manager_policy_update_req_add_entry(policy_update_request, entry[entry_index]);
+ log_if(ret != SECURITY_MANAGER_SUCCESS, 1, "security_manager_policy_update_req_add_entry failed. ret = %d", ret);
+ entry_index++;
+ }
+ }
+ /* Send policy update request */
+ ret = security_manager_policy_update_send(policy_update_request);
+ log_if(ret != SECURITY_MANAGER_SUCCESS, 1, "security-manager update req failed. ret = %d", ret);
+
+ /* Free policy entries */
+ for (--entry_index; entry_index >= 0; --entry_index)
+ security_manager_policy_entry_free(entry[entry_index]);
+
+ security_manager_policy_update_req_free(policy_update_request);
+}
+
+void create_package_privacy_list_view(app_data_s* ad)
+{
+ /* Add genlist */
+ Evas_Object *genlist = common_genlist_add(ad->nf);
+ connect_genlist_to_wheel(genlist, ad);
+
+ /* Get pkg label and app list */
+ LOGD("selected pkgid : %s", ad->pkgid);
+ GList* l;
+ for (l = ad->apd_list; l != NULL; l = l->next) {
+ app_priv_data_s* apd = (app_priv_data_s*)l->data;
+ if (!strcmp(ad->pkgid, apd->pkgid)) {
+ pp_apd = apd;
+ pp_app_list = apd->app_list;
+ break;
+ }
+ }
+
+ /* Set itc */
+ Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
+ Elm_Genlist_Item_Class *ttc = elm_genlist_item_class_new();
+ Elm_Genlist_Item_Class *ptc = elm_genlist_item_class_new();
+
+ itc->item_style = "1text.1icon.1";
+ itc->func.content_get = gl_content_get_cb;
+ itc->func.text_get = gl_text_get_cb;
+ itc->func.del = NULL;
+
+ ttc->item_style = "title";
+ ttc->func.text_get = gl_title_text_get_cb;
+ ttc->func.del = gl_title_text_del_cb;
+
+ ptc->item_style = "padding";
+ ptc->func.del = NULL;
+
+ /* Add title */
+ elm_genlist_item_append(genlist, ttc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
+
+ /* Add privacy data */
+ Elm_Object_Item *it = NULL;
+ for (l = pp_apd->pd_list; l != NULL; l = l->next) {
+ priv_data_s* pd = (priv_data_s*)l->data;
+ it = elm_genlist_item_append(genlist, itc, pd, NULL, ELM_GENLIST_ITEM_NONE, package_privacy_check_changed_cb, pd);
+ log_if(it == NULL, 1, "Error in elm_genlist_item_append");
+ }
+
+ /* Add empty line at bottom of the genlist for usability */
+ elm_genlist_item_append(genlist, ptc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
+
+ elm_genlist_item_class_free(itc);
+ elm_genlist_item_class_free(ttc);
+ elm_genlist_item_class_free(ptc);
+
+ evas_object_smart_callback_add(genlist, "realized", gl_realized_cb, NULL);
+
+ /* Push naviframe item */
+ Elm_Object_Item *nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, genlist, "empty");
+
+ elm_object_item_domain_text_translatable_set(nf_it, PACKAGE, EINA_TRUE);
+}
diff --git a/ui/src/privacy_list_view.c b/ui/src/privacy_list_view.c
deleted file mode 100644
index f2d8225..0000000
--- a/ui/src/privacy_list_view.c
+++ /dev/null
@@ -1,122 +0,0 @@
-/**
- * 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.
- */
-/*
- * @file privacy_list_view.c
- * @author Yunjin Lee (yunjin-.lee@samsung.com)
- * @version 1.0
- * @brief
- */
-
-#include <efl_extension.h>
-
-#include "common_utils.h"
-#include "privacy_view.h"
-#include <privilege_info.h>
-
-static char* gl_text_get_cb(void *data, Evas_Object *obj, const char *part)
-{
- item_data_s *id = data;
- lreturn_if(!strcmp(part, "elm.text"), , strdup(id->title), "privacy = %s", id->title);
- return "FAIL";
-}
-static char* gl_title_text_get_cb(void *data, Evas_Object *obj, const char *part)
-{
- return strdup(dgettext("privacy-setting", PRIVACY_MENU_SETTING));
-}
-static void gl_del_cb(void *data, Evas_Object *obj)
-{
- ui_app_exit();
-}
-
-static void privacy_selected_cb(void *data, Evas_Object *obj, void *event_info)
-{
- /* Get selected privacy */
- LOGD("privacy selected!!!!!!!!!!!!!!!!!!!!!!!");
- Elm_Object_Item *ei = event_info;
- item_data_s *selected_id = elm_object_item_data_get(ei);
- LOGD("%s is selected, index = %d", selected_id->title, selected_id->index);
-
- /* Unhighlight selected item */
- elm_genlist_item_selected_set(ei, EINA_FALSE);
-
- app_data_s *ad = (app_data_s *)data;
- return_if(ad == NULL, , , "ad is null");
-
- ad->privacy = (char*)selected_id->privacy;
-
- create_privacy_package_list_view(ad);
-}
-
-/*Privacy List*/
-void create_privacy_list_view(app_data_s *ad)
-{
- LOGD("privacy_list_view");
- int ret = privilege_info_get_privacy_list(&(ad->privacy_list));
- log_if(ret != PRVMGR_ERR_NONE, 1, "Failed to get privacy_list");
-
- Evas_Object *genlist = common_genlist_add(ad->nf);
- connect_genlist_to_wheel(genlist, ad);
-
- Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
- Elm_Genlist_Item_Class *ttc = elm_genlist_item_class_new();
- Elm_Genlist_Item_Class *ptc = elm_genlist_item_class_new();
-
- itc->item_style = "default";
- itc->func.text_get = gl_text_get_cb;
- itc->func.del = gl_del_cb;
-
- ttc->item_style = "title";
- ttc->func.text_get = gl_title_text_get_cb;
- ttc->func.del = gl_del_cb;
-
- ptc->item_style = "padding";
- ptc->func.del = gl_del_cb;
-
- Elm_Object_Item *it = NULL;
- if (ad->privacy != NULL) {
- free(ad->privacy);
- ad->privacy = NULL;
- }
-
- elm_genlist_item_append(genlist, ttc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
-
- int i = 0;
- for (i = 0; i < (int)g_list_length(ad->privacy_list); ++i) {
- item_data_s *id = calloc(sizeof(item_data_s), 1);
- id->index = i;
- char* privacy_display = NULL;
- id->privacy = strdup((char*)g_list_nth_data(ad->privacy_list, i));
- LOGD("privacy = %s", id->privacy);
- int ret = privilege_info_get_privacy_display(id->privacy, &privacy_display);
- log_if(ret != PRVMGR_ERR_NONE, 1, "privacy_display = %s", privacy_display);
- id->title = strdup(privacy_display);
- it = elm_genlist_item_append(genlist, itc, id, NULL, ELM_GENLIST_ITEM_NONE, privacy_selected_cb, ad);
- log_if(it == NULL, 1, "Error in elm_genlist_item_append");
- }
-
- /* Add empty line at bottom of the genlist for usability */
- elm_genlist_item_append(genlist, ptc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
-
- elm_genlist_item_class_free(itc);
- elm_genlist_item_class_free(ttc);
- elm_genlist_item_class_free(ptc);
- //evas_object_show(genlist);
-
- Elm_Object_Item *nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, genlist, "empty");
-
- elm_object_item_domain_text_translatable_set(nf_it, PACKAGE, EINA_TRUE);
-}
-
diff --git a/ui/src/privacy_package_list_view.c b/ui/src/privacy_package_list_view.c
deleted file mode 100644
index 9d461ec..0000000
--- a/ui/src/privacy_package_list_view.c
+++ /dev/null
@@ -1,475 +0,0 @@
-/**
- * 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.
- */
-/*
- * @file privacy_package_list_view.c
- * @author Yunjin Lee (yunjin-.lee@samsung.com)
- * @version 1.0
- * @brief
- */
-
-#include <efl_extension.h>
-#include <policy-manager.h>
-#include <privilege_info.h>
-#include <glib.h>
-#include <pkgmgr-info.h>
-#include <tzplatform_config.h>
-
-#include "common_utils.h"
-#include "privacy_view.h"
-
-static GList* pkg_list;
-static GList* privilege_list;
-static GList* pkg_data_list;
-static char* privacy_display = NULL;
-
-#define UIDMAXLEN 10
-
-static void privacy_package_check_changed_cb(void *data, Evas_Object *obj, void *event_info);
-
-static void gl_del_cb(void *data, Evas_Object *obj)
-{
- /* Unrealized callback can be called after this. */
- /* Accessing item_data_s can be dangerous on unrealized callback. */
- item_data_s *id = data;
- free(id);
-}
-
-static char* gl_text_get_cb(void *data, Evas_Object *obj, const char *part)
-{
- item_data_s *id = data;
- lreturn_if(!strcmp(part, "elm.text"), , strdup(id->title), "privacy-package item = %s", id->title);
- return "FAIL";
-}
-
-static char* gl_title_text_get_cb(void *data, Evas_Object *obj, const char *part)
-{
- //char *privacy_display = data;
- //LOGD("privacy_display = %s", privacy_display);
- return strdup(privacy_display);
-}
-
-static void back_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info)
-{
- app_data_s *ad = (app_data_s *)data;
- return_if(!ad, , , "ad is null");
- elm_naviframe_item_pop(ad->nf);
-}
-
-static char* gl_multi_text_get_cb(void *data, Evas_Object *obj, const char *part)
-{
- char temp[256] = {0,};
- snprintf(temp, sizeof(temp), "No applications using %s privacy", privacy_display);
- return strdup(temp);
-}
-
-static void __get_package_privacy_status(pkg_data_s* pkg_data, char* privilege_name)
-{
- GList* l;
-
- /* TBD: Modify appid to pkgid : remove for loop */
- for (l = pkg_data->applist; l != NULL; l = l->next) {
- char* appid = (char*)l->data;
-
- /* Make policy filter to get specific uid, appid and privilege's status */
- policy_entry* p_filter;
- int ret = 0;
- ret = security_manager_policy_entry_new(&p_filter);
- log_if(ret != SECURITY_MANAGER_SUCCESS, 1, "security_manager_policy_entry_new failed. ret = %s", ret);
- log_if(p_filter == NULL, 1, "security_manager_policy_entry_new failed failed. creation of new policy entry did not allocate memory");
-
- /* TBD: Modify appid to pkgid */
- ret = security_manager_policy_entry_set_application(p_filter, appid);
- log_if(ret != SECURITY_MANAGER_SUCCESS, 1, "security_manager_policy_entry_set_application failed. ret = %d", ret);
-
- security_manager_policy_entry_set_privilege(p_filter, privilege_name);
- log_if(ret != SECURITY_MANAGER_SUCCESS, 1, "security_manager_policy_entry_set_privilege failed. ret = %d", ret);
-
- /* Get policy filtered by p_filter */
- policy_entry **pp_policy = NULL;
- size_t pp_policy_size = 0;
- ret = security_manager_get_policy(p_filter, &pp_policy, &pp_policy_size);
- log_if(ret != SECURITY_MANAGER_SUCCESS || pp_policy_size <= 0, 1, "security_manager_get_policy failed. ret = %d, pp_policy_size = %d", ret, pp_policy_size);
-
- /* Get level from policy */
- unsigned int i = 0;
- for (i = 0; i < pp_policy_size; ++i) {
- char* result = (char*)security_manager_policy_entry_get_level(pp_policy[i]);
- log_if(result == NULL, 1, "security_manager_policy_entry_get_level failed. No policy is declared for pkgid: %s, appid: %s, privilege: %s", pkg_data->pkgid, appid, privilege_name);
- if (strcmp("Allow", result) == 0) {
- pkg_data->status = EINA_TRUE;
- break;
- } else if (strcmp("Deny", result) == 0) {/* TBD: Handle AskUser case? */
- pkg_data->status = EINA_FALSE;
- break;
- } else {
- LOGE("Unknown policy level: %s", result);
- break;
- }
- }
-
- /* Free policy entries */
- security_manager_policy_entry_free(p_filter);
- for (i = 0; i < pp_policy_size ; ++i)
- security_manager_policy_entry_free(pp_policy[i]);
-
- if (pkg_data->status == EINA_TRUE)
- break;
- }
-}
-static Eina_Bool get_package_privacy_status(char* package)
-{
- Eina_Bool status = EINA_FALSE;
-
- GList* l;
- for (l = pkg_data_list; l != NULL; l = l->next) {
- pkg_data_s* pkg_data = (pkg_data_s*)l->data;
- if (strcmp(pkg_data->pkgid, package) == 0) {
- status = pkg_data->status;
- break;
- }
- }
-
- return status;
-}
-
-static Evas_Object* gl_content_get_cb(void *data, Evas_Object *obj, const char *part)
-{
- Evas_Object *check;
- item_data_s *id = (item_data_s*)data;
- Eina_Bool status = id->status;
-
- if (strcmp(part, "elm.icon"))
- return NULL;
-
- if (!strcmp(id->pkgid, ""))
- return NULL;
-
- check = elm_check_add(obj);
-
- elm_object_style_set(check, "on&off");
- elm_check_state_set(check, status);
- evas_object_repeat_events_set(check, EINA_FALSE);
- evas_object_propagate_events_set(check, EINA_FALSE);
- evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL);
- evas_object_smart_callback_add(check, "changed", privacy_package_check_changed_cb, data);
- evas_object_show(check);
-
- return check;
-}
-
-static void gl_realized_cb(void *data, Evas_Object *obj, void *event_info)
-{
- Evas_Object *genlist = data;
- Elm_Object_Item *item = (Elm_Object_Item *)event_info;
- Elm_Object_Item *first = elm_genlist_first_item_get(genlist);
- if (first == item)
- elm_object_item_signal_emit(first, "elm,action,title,slide,start", "elm");
-}
-
-static void privacy_package_check_changed_cb(void *data, Evas_Object *obj, void *event_info)
-{
- Elm_Object_Item *ei = event_info;
- elm_genlist_item_selected_set(ei, EINA_FALSE);
- Eina_Bool status;
- item_data_s *id = (item_data_s*)data;
-
- /* Send policy change request to security-manager */
- GList* l;
- GList* ll;
- GList* lll;
- int ret = 0;
- for (l = pkg_data_list; l != NULL; l = l->next) {
- pkg_data_s* pkg_data = (pkg_data_s*)l->data;
- char* pkgid = (char*)pkg_data->pkgid;
- if (!strcmp(id->pkgid, pkgid)) {
-
- char* level;
- if (id->status) {
- level = "Deny";
- id->status = false;
- } else {
- level = "Allow";
- id->status = true;
- }
-
- LOGD("%s will be changed to %s", pkgid, level);
-
- int priv_num = g_list_length(pkg_data->privlist);
- int app_num = g_list_length(pkg_data->applist);
- int entry_num = priv_num*app_num;
- LOGD("priv_num = %d, app_num = %d, entry_num = %d", priv_num, app_num, entry_num);
-
- /* Make policy update request */
- policy_update_req *policy_update_request;
- ret = security_manager_policy_update_req_new(&policy_update_request);
- log_if(ret != SECURITY_MANAGER_SUCCESS, 1, "security_manager_policy_update_req_new failed. ret = %d", ret);
- log_if(policy_update_request == NULL, 1, "security_manager_policy_entry_new failed failed. creation of new policy request did not allocate memory");
- /* Make policy entries to update according to the number of privilege and appid of package */
- policy_entry *entry[entry_num];
- int entry_index = 0;
- /* TBD: Modify appid to pkgid : remove for loop */
- for (ll = pkg_data->applist; ll != NULL; ll = ll->next) {
- char* appid = (char*)ll->data;
- for (lll = pkg_data->privlist; lll != NULL; lll = lll->next) {
- char* privilege_name = (char*)lll->data;
- LOGD("%d: Change to %s => appid: %s, privilege_name: %s", entry_index, level, appid, privilege_name);
- /* Make entries by each appid, and privilege_name */
- ret = security_manager_policy_entry_new(&entry[entry_index]);
- log_if(ret != SECURITY_MANAGER_SUCCESS, 1, "security_manager_policy_entry_new failed. ret = %d", ret);
- log_if(entry[entry_index] == NULL, 1, "security_manager_policy_entry_new failed failed. creation of new policy entry did not allocate memory");
- /* TBD: Modify appid to pkgid */
- ret = security_manager_policy_entry_set_application(entry[entry_index], appid);
- log_if(ret != SECURITY_MANAGER_SUCCESS, 1, "security_manager_policy_entry_set_application failed. ret = %d", ret);
- ret = security_manager_policy_entry_set_privilege(entry[entry_index], privilege_name);
- log_if(ret != SECURITY_MANAGER_SUCCESS, 1, "security_manager_policy_entry_set_privilege failed. ret = %d", ret);
- ret = security_manager_policy_entry_set_level(entry[entry_index], level);
- log_if(ret != SECURITY_MANAGER_SUCCESS, 1, "security_manager_policy_entry_set_level failed. ret = %d", ret);
-
- /* Add entry to policy update request */
- ret = security_manager_policy_update_req_add_entry(policy_update_request, entry[entry_index]);
- log_if(ret != SECURITY_MANAGER_SUCCESS, 1, "security_manager_policy_update_req_add_entry failed. ret = %d", ret);
- entry_index++;
- }
- }
- /* Send policy update request */
- ret = security_manager_policy_update_send(policy_update_request);
- log_if(ret != SECURITY_MANAGER_SUCCESS, 1, "security-manager update req failed. ret = %d", ret);
-
- /* Free policy entries */
- for (--entry_index; entry_index >= 0; --entry_index)
- security_manager_policy_entry_free(entry[entry_index]);
-
- security_manager_policy_update_req_free(policy_update_request);
- break;
- }
- }
-}
-
-/* TBD: Modify appid to pkgid : remove following function */
-static int pkg_app_list_cb(pkgmgrinfo_appinfo_h pkg_handle, void* user_data)
-{
- char* appid = NULL;
- pkg_data_s* pkg_data = (pkg_data_s*)user_data;
- int ret = pkgmgrinfo_appinfo_get_appid(pkg_handle, &appid);
- return_if(ret != PMINFO_R_OK, , -1, "pkgmgrinfo_appinfo_get_appid failed");
- char* appidd = strdup(appid);
- return_if(appid == NULL, , -1, "appid strdup failed");
- pkg_data->applist = g_list_append(pkg_data->applist, appidd);
- return ret;
-}
-
-static int pkg_list_cb(pkgmgrinfo_pkginfo_h filter_handle, void *user_data)
-{
- char* privilege_name = strdup((char*)user_data);
- char *pkgid = NULL;
- int ret = pkgmgrinfo_pkginfo_get_pkgid(filter_handle, &pkgid);
- char *pkgidd = strdup(pkgid);
- return_if(ret != PMINFO_R_OK, , -1, "pkgmgrinfo_pkginfo_get_pkgname failed");
- GList* find = g_list_find_custom(pkg_list, pkgid, (GCompareFunc)strcmp);
- if (find != NULL) {
- /* Add privilege info to package data list */
- GList* l;
- for (l = pkg_data_list; l != NULL; l = l->next) {
- pkg_data_s* temp = (pkg_data_s*)l->data;
- char* temp_pkgid = (char*)temp->pkgid;
- if (strcmp(temp_pkgid, pkgid) == 0) {
- temp->privlist = g_list_append(temp->privlist, privilege_name);
- if (!temp->status) /* If any privilege is allowed then status of privacy should be displayed as on hence previously checked staus is off then do check again. */
- __get_package_privacy_status(temp, privilege_name);
- break;
- }
- }
- return ret;
- }
-
- pkg_list = g_list_append(pkg_list, pkgidd);
-
- /* Make package data item */
- pkg_data_s *pkg_data = (pkg_data_s *)malloc(sizeof(pkg_data_s));
-
- /* Add pkg id to package data item */
- pkg_data->pkgid = strdup(pkgid);
-
- /* Add privilege info to package data item */
- pkg_data->privlist = NULL;
- pkg_data->privlist = g_list_append(pkg_data->privlist, privilege_name);
-
- /* Add app list to package data item */
- pkg_data->applist = NULL;
- pkgmgrinfo_pkginfo_h pkg_handle;
- ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &pkg_handle);
- return_if(ret != PMINFO_R_OK, , -1, "pkgmgrinfo_pkginfo_get_pkginfo failed");
- /* TBD: Modify appid to pkgid : remove following lines */
- ret = pkgmgrinfo_appinfo_get_list(pkg_handle, PMINFO_ALL_APP, pkg_app_list_cb, pkg_data);
- return_if(ret != PMINFO_R_OK, pkgmgrinfo_pkginfo_destroy_pkginfo(pkg_handle), -1, "pkgmgrinfo_appinfo_get_list failed");
-
- /* See if the package is global. TBD: If notion for handling of global app is required. */
- pkg_data->is_global = false;
- ret = pkgmgrinfo_pkginfo_is_global(pkg_handle, &pkg_data->is_global);
- return_if(ret != PMINFO_R_OK, pkgmgrinfo_pkginfo_destroy_pkginfo(pkg_handle), -1, "pkgmgrinfo_pkginfo_is_global failed");
-
- /* Get package label */
- char* label = NULL;
- ret = pkgmgrinfo_pkginfo_get_label(pkg_handle, &label);
- return_if(ret != PMINFO_R_OK, pkgmgrinfo_pkginfo_destroy_pkginfo(pkg_handle), -1, "pkgmgrinfo_pkginfo_get_label failed");
- pkg_data->label = strdup(label);
- pkgmgrinfo_pkginfo_destroy_pkginfo(pkg_handle);
-
- /* Get package privacy status */
- pkg_data->status = false;
- __get_package_privacy_status(pkg_data, privilege_name);
-
- /* Append package data item to package_data_list */
- pkg_data_list = g_list_append(pkg_data_list, pkg_data);
- return ret;
-}
-static int get_uniq_pkg_list_by_privacy(const char* privacy)
-{
- int ret = 0;
- /* For privilege list loop -> Get pkg_list by privilege */
- if (pkg_list != NULL) {
- g_list_free(pkg_list);
- pkg_list = NULL;
- }
- if (pkg_data_list != NULL) {
- g_list_free(pkg_data_list);
- pkg_data_list = NULL;
- }
- GList* l;
- int uid = getuid();
- for (l = privilege_list; l != NULL; l = l->next) {
- char* privilege_name = (char*)l->data;
- /* For each privilege */
- pkgmgrinfo_pkginfo_filter_h filter_handle;
- ret = pkgmgrinfo_pkginfo_filter_create(&filter_handle);
- return_if(ret != PMINFO_R_OK, , -1, "pkgmgrinfo_pkginfo_filter_create failed");
- ret = pkgmgrinfo_pkginfo_filter_add_string(filter_handle, PMINFO_PKGINFO_PROP_PACKAGE_PRIVILEGE, privilege_name);
- LOGD("uid: %d, privacy: %s, privilege: %s", uid, privacy, privilege_name);
- return_if(ret != PMINFO_R_OK, pkgmgrinfo_pkginfo_filter_destroy(filter_handle), -1, "pkgmgrinfo_pkginfo_filter_add_string failed");
- /* Get uniq pkg list */
- ret = pkgmgrinfo_pkginfo_usr_filter_foreach_pkginfo(filter_handle, pkg_list_cb, privilege_name, uid);
- return_if(ret != PMINFO_R_OK, pkgmgrinfo_pkginfo_filter_destroy(filter_handle), -1, "pkgmgrinfo_pkginfo_usr_filter_foreach_pkginfo failed");
- }
-
- /* To check : each privacy related package's app, privilege info
- for (l = pkg_data_list; l != NULL; l = l->next) {
- pkg_data_s* temp = (pkg_data_s*)l->data;
- LOGD(" * PACKAGE ID : %s LABEL: %s is global? %d", temp->pkgid, temp->label, temp->is_global);
- GList* ll;
- LOGD(" * APP ID");
- for (ll = temp->applist; ll != NULL; ll = ll->next) {
- char* temp_appid = (char*)ll->data;
- LOGD(" - %s", temp_appid);
- }
- LOGD(" * PRIVILEGE");
- for (ll = temp->privlist; ll != NULL; ll = ll->next) {
- char* temp_privname = (char*)ll->data;
- LOGD(" - %s", temp_privname);
- }
- } */
-
- return ret;
-}
-void create_privacy_package_list_view(app_data_s* ad)
-{
- /* Add genlist */
- Evas_Object *genlist = common_genlist_add(ad->nf);
- connect_genlist_to_wheel(genlist, ad);
-
- //char* privacy_display = NULL;
- log_if(privilege_info_get_privacy_display(ad->privacy, &privacy_display) != PRVMGR_ERR_NONE, 1, "Couldn't get privacy display : %s", ad->privacy);
-
- /* Set itc */
- Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
- Elm_Genlist_Item_Class *ttc = elm_genlist_item_class_new();
- Elm_Genlist_Item_Class *ptc = elm_genlist_item_class_new();
- Elm_Genlist_Item_Class *mtc = elm_genlist_item_class_new();
-
- itc->item_style = "1text.1icon.1";
- itc->func.content_get = gl_content_get_cb;
- itc->func.text_get = gl_text_get_cb;
- itc->func.del = gl_del_cb;
-
- ttc->item_style = "title";
- ttc->func.text_get = gl_title_text_get_cb;
- ttc->func.del = gl_del_cb;
-
- ptc->item_style = "padding";
- ptc->func.del = gl_del_cb;
-
- mtc->item_style = "multiline";
- mtc->func.text_get = gl_multi_text_get_cb;
- ttc->func.del = gl_del_cb;
-
- /* Get privilege list by privacy */
- if (privilege_list != NULL) {
- g_list_free(privilege_list);
- privilege_list = NULL;
- }
- int ret = privilege_info_get_privilege_list_by_privacy(ad->privacy, &privilege_list);
- log_if(ret != PRVMGR_ERR_NONE, 1, "Couldn't get privilege list of privacy: %s", ad->privacy);
-
- /* Get unique package list filtered by given privacy related privileges */
- ret = get_uniq_pkg_list_by_privacy(ad->privacy);
- log_if(ret != 0, 1, "get_unique_pkg_list_by_privacy failed");
- pkg_list = g_list_sort(pkg_list, (GCompareFunc)strcmp);
-
- /* Add title */
- elm_genlist_item_append(genlist, ttc, privacy_display, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
-
- /* Append privacy related package as genlist item */
- GList* l;
- int i = 0;
- Elm_Object_Item *it = NULL;
- if (!pkg_data_list) {
- LOGD("No apps using %s", privacy_display);
-
- it = elm_genlist_item_append(genlist, mtc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
- log_if(it == NULL, 1, "Error in elm_genlist_item_append");
- elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
- } else {
- for (l = pkg_data_list; l != NULL; l = l->next) {
- item_data_s *id = calloc(sizeof(item_data_s), 1);
- id->index = i++;
- pkg_data_s* pkg_data = (pkg_data_s*)l->data;
- id->pkgid = strdup(pkg_data->pkgid);
- id->title = pkg_data->label;
- /* Get privacy status of given package */
- id->status = get_package_privacy_status(pkg_data->pkgid);
- LOGD("status = %d", id->status);
- it = elm_genlist_item_append(genlist, itc, id, NULL, ELM_GENLIST_ITEM_NONE, privacy_package_check_changed_cb, id);
- log_if(it == NULL, 1, "Error in elm_genlist_item_append");
- }
- /* Add empty line at bottom of the genlist for usability */
- elm_genlist_item_append(genlist, ptc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
- }
-
- /* Add empty line at bottom of the genlist for usability */
- //elm_genlist_item_append(genlist, ptc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
-
- elm_genlist_item_class_free(itc);
- elm_genlist_item_class_free(ttc);
- elm_genlist_item_class_free(ptc);
- elm_genlist_item_class_free(mtc);
-
- evas_object_smart_callback_add(genlist, "realized", gl_realized_cb, NULL);
-
- /* Push naviframe item */
- Elm_Object_Item *nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, genlist, "empty");
-
- elm_object_item_domain_text_translatable_set(nf_it, PACKAGE, EINA_TRUE);
-}