Multi user features : 22/25722/2 submit/tizen_common/20140811.160835 submit/tizen_common/20140811.161134
authorSabera Djelti (sdi2) <sabera.djelti@open.eurogiciel.org>
Tue, 1 Jul 2014 13:19:35 +0000 (15:19 +0200)
committerSabera Djelti (sdi2) <sabera.djelti@open.eurogiciel.org>
Mon, 11 Aug 2014 13:48:52 +0000 (15:48 +0200)
    ->Add/Use Usr App related fonctions instead of Global App related Functions

Change-Id: I7c5cfb48ed6725f118c0117cc0482cccaf333669
Signed-off-by: Sabera Djelti (sdi2) <sabera.djelti@open.eurogiciel.org>
Signed-off-by: Baptiste DURAND <baptiste.durand@open.eurogiciel.org>
am_daemon/amd_appinfo.c
am_daemon/amd_launch.c
am_daemon/amd_main.c
include/menu_db_util.h
include/simple_util.h
src/mime.c
src/service.c

index 6109cc4..805899c 100755 (executable)
@@ -105,7 +105,6 @@ static int __app_info_insert_handler (const pkgmgrinfo_appinfo_h handle, void *d
                _E("null app handle");
                return -1;
        }
-
        ret = pkgmgrinfo_appinfo_get_appid(handle, &appid);
        if (ret < 0) {
                _E("fail to get appinfo");
@@ -217,12 +216,13 @@ static int __app_info_delete_handler (const pkgmgrinfo_appinfo_h handle, void *d
        return 0;
 }
 
-static int _read_pkg_info(struct appinfomgr *cf)
+static int _read_pkg_info(struct appinfomgr *cf, uid_t uid)
 {
        int r;
-
-       r = pkgmgrinfo_appinfo_get_install_list(__app_info_insert_handler, cf);
-
+       if(uid != GLOBAL_USER)
+               r = pkgmgrinfo_appinfo_get_usr_install_list(__app_info_insert_handler, uid, cf);
+       else
+               r = pkgmgrinfo_appinfo_get_install_list(__app_info_insert_handler, cf);
        return r;
 }
 
@@ -269,7 +269,11 @@ static void __vconf_cb(keynode_t *key, void *data)
        _D("appid: [%s]\n", appid);
        _D("uid: %d\n", uid);
        if ( strncmp(type_string, "create", 6) == 0) {
-               ret = pkgmgrinfo_appinfo_get_appinfo_user(appid, uid, &handle);
+               //is_admin
+               if (uid != GLOBAL_USER)
+                 ret = pkgmgrinfo_appinfo_get_usr_appinfo(appid, uid, &handle);
+               else
+                 ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle);
                if(ret < 0) {
                        _E("pkgmgrinfo_appinfo_get_appinfo fail");
                }
@@ -284,7 +288,7 @@ static void __vconf_cb(keynode_t *key, void *data)
        } else if (strncmp(type_string, "update", 6) == 0){
                /*REMOVE EXISTING ENTRY & CREATE AGAIN*/
                if (g_hash_table_remove(cf->tbl, appid)){
-                       if (pkgmgrinfo_appinfo_get_appinfo_user(appid, uid, &handle) == PMINFO_R_OK){
+                       if (pkgmgrinfo_appinfo_get_usr_appinfo(appid, uid, &handle) == PMINFO_R_OK){
                                __app_info_insert_handler(handle, data);
                                pkgmgrinfo_appinfo_destroy_appinfo(handle);
                        }
@@ -368,7 +372,7 @@ int appinfo_init(struct appinfomgr **cf)
        if (!_cf)
                return -1;
 
-       r = _read_pkg_info(_cf);
+       r = _read_pkg_info(_cf, getuid());
        if (r != PMINFO_R_OK) {
                _fini(_cf);
                return -1;
@@ -436,7 +440,7 @@ const struct appinfo *appinfo_find(uid_t caller_uid, const char *appid)
        pkgmgrinfo_permission_type permission;
        int ret;
 
-       ret = pkgmgrinfo_appinfo_get_appinfo( appid, &handle);
+       ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle);
        if (ret != PMINFO_R_OK){
                ret = pkgmgrinfo_appinfo_get_appinfo_user(appid , caller_uid , &handle);
                if (ret != PMINFO_R_OK){
index 2bf833b..5e50ad5 100755 (executable)
@@ -58,6 +58,7 @@
 #define SDK_CODE_COVERAGE "CODE_COVERAGE"
 #define SDK_DYNAMIC_ANALYSIS "DYNAMIC_ANALYSIS"
 #define PATH_DA_SO "/home/developer/sdk_tools/da/da_probe.so"
+#define GLOBAL_USER    0 //#define     tzplatform_getenv(TZ_GLOBAL) //TODO
 
 struct appinfomgr *_laf;
 struct cginfo *_lcg;
@@ -748,7 +749,11 @@ int _start_app(char* appid, bundle* kb, int cmd, int caller_pid, uid_t caller_ui
                        caller_ai = appinfo_find(caller_uid, caller_appid);
                        preload = appinfo_get_value(caller_ai, AIT_PRELOAD);
                        if( preload && strncmp(preload, "true", 4) != 0 ) {
-                               pkgmgrinfo_pkginfo_compare_app_cert_info(caller_appid, appid, &compare_result);
+                               //is admin is global
+                               if(caller_uid != GLOBAL_USER)
+                                       pkgmgrinfo_pkginfo_compare_usr_app_cert_info(caller_appid, appid, caller_uid, &compare_result);
+                               else
+                                       pkgmgrinfo_pkginfo_compare_app_cert_info(caller_appid, appid, &compare_result);
                                if(compare_result != PMINFO_CERT_COMPARE_MATCH) {
                                        pid = -EILLEGALACCESS;
                                        __real_send(fd, pid);
index 2c477ec..9dc4aed 100755 (executable)
@@ -156,8 +156,9 @@ gboolean __add_item_running_list(gpointer user_data)
                if(limit>0) __kill_bg_apps(limit-1);
                return false;
        }
-
-       ail_ret = ail_package_get_appinfo(pkgname, &handle);
+       //is admin is global
+       ail_ret = ail_package_get_usr_appinfo(pkgname, user, &handle);
+       //ail_ret = ail_package_get_appinfo(pkgname, &handle);
        if (ail_ret != AIL_ERROR_OK) {
                _E("ail_get_appinfo with %s failed", pkgname);
                return false;
index 4bf2c21..954c279 100755 (executable)
@@ -120,20 +120,30 @@ static inline app_info_from_db *_get_app_info_from_db_by_pkgname(
        if (menu_info == NULL) {
                return NULL;
        }
-
-       ret = ail_get_appinfo(pkgname, &handle);
+       //is_admin is global
+       if (getuid() != GLOBAL_USER)
+               ret = ail_get_usr_appinfo(pkgname, getuid(), &handle);
+       else
+               ret = ail_get_appinfo(pkgname, &handle);
+    
        if (ret != AIL_ERROR_OK) {
                _free_app_info_from_db(menu_info);
                return NULL;
        }
-
-       ret = ail_appinfo_get_str(handle, AIL_PROP_PACKAGE_STR, &str);
+//is admin is global
+       if (getuid() != GLOBAL_USER)
+               ret = ail_appinfo_get_usr_str(handle, AIL_PROP_PACKAGE_STR, getuid(), &str);
+       else
+               ret = ail_appinfo_get_str(handle, AIL_PROP_PACKAGE_STR, &str);
        if (str) {
                menu_info->pkg_name = strdup(str);      
                str = NULL;
        }
-
-       ret = ail_appinfo_get_str(handle, AIL_PROP_EXEC_STR, &str);
+       //is_admin is global
+       if (getuid() != GLOBAL_USER)
+               ret = ail_appinfo_get_usr_str(handle, AIL_PROP_EXEC_STR, getuid(), &str);
+       else
+               ret = ail_appinfo_get_str(handle, AIL_PROP_EXEC_STR, &str);
        if (str) {
                menu_info->app_path = strdup(str);
                str = NULL;
@@ -141,8 +151,12 @@ static inline app_info_from_db *_get_app_info_from_db_by_pkgname(
 
        if (menu_info->app_path != NULL)
                menu_info->original_app_path = strdup(menu_info->app_path);
-
-       ret = ail_appinfo_get_str(handle, AIL_PROP_X_SLP_PACKAGETYPE_STR, &str);
+       //is_admin is gobal
+       if (getuid() != GLOBAL_USER)
+       ret = ail_appinfo_get_usr_str(handle, AIL_PROP_X_SLP_PACKAGETYPE_STR, getuid(), &str);
+  else
+               ret = ail_appinfo_get_str(handle, AIL_PROP_X_SLP_PACKAGETYPE_STR, &str);
+       
        if (str) {
                menu_info->pkg_type = strdup(str);
                str = NULL;
@@ -169,8 +183,11 @@ static inline ail_cb_ret_e __appinfo_func(const ail_appinfo_h appinfo, void *use
 
        if (!menu_info)
                return ret;
-
-       ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &package);
+       //is_admin is global
+       if (getuid() != GLOBAL_USER)
+               ail_appinfo_get_usr_str(appinfo, AIL_PROP_PACKAGE_STR, getuid(), &package);
+       else
+               ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &package);
        if (package) {
                menu_info->pkg_name = strdup(package);
                ret = AIL_CB_RET_CANCEL;
@@ -207,7 +224,10 @@ static inline app_info_from_db *_get_app_info_from_db_by_apppath(
                return NULL;
        }
 
-       ret = ail_filter_count_appinfo(filter, &count);
+       if (getuid() != GLOBAL_USER)
+               ret = ail_filter_count_usr_appinfo(filter, &count, getuid());
+       else
+               ret = ail_filter_count_appinfo(filter, &count);
        if (ret != AIL_ERROR_OK) {
                ail_filter_destroy(filter);
                _free_app_info_from_db(menu_info);
@@ -218,8 +238,11 @@ static inline app_info_from_db *_get_app_info_from_db_by_apppath(
                _free_app_info_from_db(menu_info);
                return NULL;
        }
-
-       ail_filter_list_appinfo_foreach(filter, __appinfo_func, (void *)menu_info);
+//is_admin is global
+       if (getuid() != GLOBAL_USER)
+    ail_filter_list_usr_appinfo_foreach(filter, __appinfo_func, (void *)menu_info, getuid());
+       else
+               ail_filter_list_appinfo_foreach(filter, __appinfo_func, (void *)menu_info);
 
        ail_filter_destroy(filter);
 
index 600ab94..efd01ad 100755 (executable)
@@ -27,6 +27,9 @@
 #include <ctype.h>
 #include <dlog.h>
 
+#define GLOBAL_USER    0 //#define     tzplatform_getenv(TZ_GLOBAL) //TODO
+
+
 #undef LOG_TAG
 #define LOG_TAG "AUL"
 
index 0715a74..9beb917 100755 (executable)
@@ -224,9 +224,11 @@ static ail_cb_ret_e __defapp_with_mime_func(
 {
        char **package = (char **)user_data;
        char *str;
-
-       ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &str);
-
+//is_admin is_global
+  if (getuid() != GLOBAL_USER)
+               ail_appinfo_get_usr_str(appinfo, AIL_PROP_PACKAGE_STR, getuid(), &str);
+       else
+               ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &str);
        _D("defapp from desktop = %s", str);
 
        *package = strdup(str);
@@ -250,14 +252,22 @@ static int get_defapp_from_desktop(const char *mimetype, char *defapp, int len)
                ret = -1;
                goto out;
        }
-       
-       ail_filter_count_appinfo(filter, &pkg_count);
+
+  if (getuid() != GLOBAL_USER)
+               ail_filter_count_usr_appinfo(filter, &pkg_count, getuid());
+       else
+               ail_filter_count_appinfo(filter, &pkg_count);
 
        if (pkg_count == 1) {
-               ail_filter_list_appinfo_foreach(filter, 
-                       __defapp_with_mime_func, (void *)&tmp);
 
-               if(tmp) {
+  if (getuid() != GLOBAL_USER)
+                       ail_filter_list_usr_appinfo_foreach(filter,
+                               __defapp_with_mime_func, (void *)&tmp, getuid());
+       else
+                       ail_filter_list_appinfo_foreach(filter,
+                               __defapp_with_mime_func, (void *)&tmp);
+
+       if(tmp) {
                        strncpy(defapp,tmp,len);
                        _D("defapp from desktop = %s", defapp);
                        aul_set_defapp_with_mime(mimetype, defapp);
@@ -361,7 +371,11 @@ static int __launch_with_defapp(const char *mime_type, const char *mime_content)
                if (ret > 0)
                        ret = 0;
        } else {
-               ail_ret = ail_get_appinfo(defapp, &handle);
+
+  if (getuid() != GLOBAL_USER)
+    ail_ret = ail_get_usr_appinfo(defapp, getuid(), &handle);
+  else
+         ail_ret = ail_get_appinfo(defapp, &handle);
 
                if (ail_ret == AIL_ERROR_OK) {
                        ail_destroy_appinfo(handle);
index 6634d23..53ad802 100755 (executable)
@@ -63,7 +63,10 @@ static ail_cb_ret_e __defapp_with_service_func(
        char **package = (char **)user_data;
        char *str;
 
-       ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &str);
+  if (getuid() != GLOBAL_USER)
+               ail_appinfo_get_usr_str(appinfo, AIL_PROP_PACKAGE_STR, getuid(), &str);
+       else
+               ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &str);
 
        _D("defapp from desktop = %s", str);
 
@@ -92,14 +95,19 @@ static int __get_defapp_from_desktop(const char *svcname, char *defapp, int len)
                _E("ail_filter_add_str failed");
                goto out;
        }
-
-       ail_filter_count_appinfo(filter, &pkg_count);
-
-       
+  if (getuid() != GLOBAL_USER)
+               ail_filter_count_usr_appinfo(filter, &pkg_count, getuid());
+       else
+               ail_filter_count_appinfo(filter, &pkg_count);
        /* TODO: Prioritizing inhouse app depending on the UX policy */
        if (pkg_count == 1) {
-               ail_filter_list_appinfo_foreach(filter, 
-                       __defapp_with_service_func, (void *)&pkgname);
+
+    if (getuid() != GLOBAL_USER)
+       ail_filter_list_usr_appinfo_foreach(filter,
+                               __defapp_with_service_func, (void *)&pkgname, getuid());
+               else
+                       ail_filter_list_appinfo_foreach(filter,
+                               __defapp_with_service_func, (void *)&pkgname);
 
                if(pkgname) {
                        strncpy(defapp,pkgname,len);
@@ -172,6 +180,10 @@ SLPAPI int aul_open_service(const char *svcname, bundle *kb,
                }
                return ret;
        } else {
+
+  if (getuid() != GLOBAL_USER)
+         ail_ret = ail_get_usr_appinfo(defapp, getuid(), &handle);
+       else
                ail_ret = ail_get_appinfo(defapp, &handle);
 
                if (ail_ret == AIL_ERROR_OK) {