diff options
author | Yunjin Lee <yunjin-.lee@samsung.com> | 2016-10-19 14:49:38 +0900 |
---|---|---|
committer | Yunjin Lee <yunjin-.lee@samsung.com> | 2016-10-19 15:06:53 +0900 |
commit | 513e5a0dbce5977c1ed70146e6344ee06fb987f9 (patch) | |
tree | 880843afdbd04b4d4e237bed7ff0fdbbb6291dc7 | |
parent | 978e0b9ff3e3743035e5a1a9608433a24cb60d2d (diff) | |
download | privacy-setting-513e5a0dbce5977c1ed70146e6344ee06fb987f9.tar.gz privacy-setting-513e5a0dbce5977c1ed70146e6344ee06fb987f9.tar.bz2 privacy-setting-513e5a0dbce5977c1ed70146e6344ee06fb987f9.zip |
Revert "Modify appid to pkgid"
This reverts commit 978e0b9ff3e3743035e5a1a9608433a24cb60d2d.
Change-Id: I65ddb3392de176a129c664a08cfa656f44ae75c0
Signed-off-by: Yunjin Lee <yunjin-.lee@samsung.com>
-rw-r--r-- | common/include/common_utils.h | 2 | ||||
-rwxr-xr-x | packaging/org.tizen.privacy-setting.spec | 2 | ||||
-rwxr-xr-x | ui/include/privacy_view.h | 3 | ||||
-rw-r--r-- | ui/src/privacy_list_view.c | 3 | ||||
-rw-r--r-- | ui/src/privacy_package_list_view.c | 164 |
5 files changed, 111 insertions, 63 deletions
diff --git a/common/include/common_utils.h b/common/include/common_utils.h index c056d49..6cda564 100644 --- a/common/include/common_utils.h +++ b/common/include/common_utils.h @@ -73,6 +73,8 @@ typedef struct _app_data_s{ Elm_Theme *theme; Eext_Circle_Surface *circle_surface; + Evas_Coord root_w; + Evas_Coord root_h; GList *privacy_list; char* privacy; diff --git a/packaging/org.tizen.privacy-setting.spec b/packaging/org.tizen.privacy-setting.spec index a4f75f5..75c00f8 100755 --- a/packaging/org.tizen.privacy-setting.spec +++ b/packaging/org.tizen.privacy-setting.spec @@ -61,7 +61,7 @@ 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 -c User::App::org.tizen.privacy-setting -u 5001 -p http://tizen.org/privilege/notexist -t ALLOW echo "cyad done" %postun -p /sbin/ldconfig diff --git a/ui/include/privacy_view.h b/ui/include/privacy_view.h index 8ef8f2a..fe9ad46 100755 --- a/ui/include/privacy_view.h +++ b/ui/include/privacy_view.h @@ -34,12 +34,13 @@ 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 { +typedef struct item_data { int index; char *title; char *pkgid; diff --git a/ui/src/privacy_list_view.c b/ui/src/privacy_list_view.c index fc547c4..f2d8225 100644 --- a/ui/src/privacy_list_view.c +++ b/ui/src/privacy_list_view.c @@ -44,6 +44,7 @@ static void gl_del_cb(void *data, Evas_Object *obj) 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); @@ -62,6 +63,7 @@ static void privacy_selected_cb(void *data, Evas_Object *obj, void *event_info) /*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"); @@ -111,6 +113,7 @@ void create_privacy_list_view(app_data_s *ad) 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"); diff --git a/ui/src/privacy_package_list_view.c b/ui/src/privacy_package_list_view.c index fc7d3ad..9d461ec 100644 --- a/ui/src/privacy_package_list_view.c +++ b/ui/src/privacy_package_list_view.c @@ -56,6 +56,8 @@ static char* gl_text_get_cb(void *data, Evas_Object *obj, const char *part) 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); } @@ -77,49 +79,55 @@ static void __get_package_privacy_status(pkg_data_s* pkg_data, char* privilege_n { GList* l; - char* pkgid = strdup(pkg_data->pkgid); - - /* Make policy filter to get given privilege's status of specific application */ - 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, pkgid); - 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, privilege: %s", pkgid, 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; + /* 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]); + /* 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) { @@ -200,35 +208,42 @@ static void privacy_package_check_changed_cb(void *data, Evas_Object *obj, void LOGD("%s will be changed to %s", pkgid, level); - int entry_num = g_list_length(pkg_data->privlist); - LOGD("entry_num = %d", entry_num); + 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 */ + /* 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 (lll = pkg_data->privlist; lll != NULL; lll = lll->next) { - char* privilege_name = (char*)lll->data; - LOGD("%d: Change to %s => pkgid: %s, privilege_name: %s", entry_index, level, pkgid, privilege_name); - /* Make entries by each 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], pkgid); - 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++; + /* 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); @@ -244,6 +259,19 @@ static void privacy_package_check_changed_cb(void *data, Evas_Object *obj, void } } +/* 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); @@ -280,9 +308,14 @@ static int pkg_list_cb(pkgmgrinfo_pkginfo_h filter_handle, void *user_data) 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; @@ -337,6 +370,11 @@ static int get_uniq_pkg_list_by_privacy(const char* privacy) 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; @@ -352,6 +390,7 @@ void create_privacy_package_list_view(app_data_s* ad) 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 */ @@ -419,6 +458,9 @@ void create_privacy_package_list_view(app_data_s* ad) 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); |