summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorYunjin Lee <yunjin-.lee@samsung.com>2016-09-28 19:34:19 +0900
committerYunjin Lee <yunjin-.lee@samsung.com>2016-09-28 19:41:32 +0900
commit978e0b9ff3e3743035e5a1a9608433a24cb60d2d (patch)
tree78e61562c1bc54104b4d1f30d62888735f31f280 /ui
parentc44fbbb29abed0383e1b389dc704c6d461567a66 (diff)
downloadprivacy-setting-978e0b9ff3e3743035e5a1a9608433a24cb60d2d.tar.gz
privacy-setting-978e0b9ff3e3743035e5a1a9608433a24cb60d2d.tar.bz2
privacy-setting-978e0b9ff3e3743035e5a1a9608433a24cb60d2d.zip
Change-Id: I7fc4ad3960eec31ac15054f6c5b1b666dfdd8485 Signed-off-by: Yunjin Lee <yunjin-.lee@samsung.com>
Diffstat (limited to 'ui')
-rwxr-xr-xui/include/privacy_view.h3
-rw-r--r--ui/src/privacy_list_view.c3
-rw-r--r--ui/src/privacy_package_list_view.c164
3 files changed, 62 insertions, 108 deletions
diff --git a/ui/include/privacy_view.h b/ui/include/privacy_view.h
index fe9ad46..8ef8f2a 100755
--- a/ui/include/privacy_view.h
+++ b/ui/include/privacy_view.h
@@ -34,13 +34,12 @@
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 {
+typedef struct {
int index;
char *title;
char *pkgid;
diff --git a/ui/src/privacy_list_view.c b/ui/src/privacy_list_view.c
index f2d8225..fc547c4 100644
--- a/ui/src/privacy_list_view.c
+++ b/ui/src/privacy_list_view.c
@@ -44,7 +44,6 @@ 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);
@@ -63,7 +62,6 @@ 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");
@@ -113,7 +111,6 @@ 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 9d461ec..fc7d3ad 100644
--- a/ui/src/privacy_package_list_view.c
+++ b/ui/src/privacy_package_list_view.c
@@ -56,8 +56,6 @@ 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);
}
@@ -79,55 +77,49 @@ static void __get_package_privacy_status(pkg_data_s* pkg_data, char* privilege_n
{
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]);
+ char* pkgid = strdup(pkg_data->pkgid);
- if (pkg_data->status == EINA_TRUE)
+ /* 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;
+ }
}
+
+ /* 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]);
+
}
static Eina_Bool get_package_privacy_status(char* package)
{
@@ -208,42 +200,35 @@ static void privacy_package_check_changed_cb(void *data, Evas_Object *obj, void
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);
+ int entry_num = g_list_length(pkg_data->privlist);
+ LOGD("entry_num = %d", 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 */
+ /* Make policy entries to update according to the number of privilege */
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++;
- }
+ 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++;
}
/* Send policy update request */
ret = security_manager_policy_update_send(policy_update_request);
@@ -259,19 +244,6 @@ 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);
@@ -308,14 +280,9 @@ 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;
@@ -370,11 +337,6 @@ 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;
@@ -390,7 +352,6 @@ 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 */
@@ -458,9 +419,6 @@ 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);