Multi user features :
authorSabera Djelti (sdi2) <sabera.djelti@open.eurogiciel.org>
Fri, 22 Aug 2014 08:46:41 +0000 (10:46 +0200)
committerSabera Djelti (sdi2) <sabera.djelti@open.eurogiciel.org>
Thu, 18 Sep 2014 13:50:56 +0000 (15:50 +0200)
->Use Usr App related fonctions instead of Global App related Functions

Change-Id: I85dc3729d79dd35eeea77216b3f199266a896a29
Signed-off-by: Sabera Djelti (sdi2) <sabera.djelti@open.eurogiciel.org>
application/application_information.cc
application/application_manager.cc
common/virtual_fs.cc

index a7c6db6..1b43894 100644 (file)
@@ -8,6 +8,8 @@
 #include <package_manager.h>
 #include <package-manager.h>
 #include <pkgmgr-info.h>
+#include <tzplatform_config.h>
+#include <unistd.h>
 
 #include <memory>
 #include <utility>
@@ -18,6 +20,8 @@
 
 namespace {
 
+const uid_t GLOBAL_USER = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
+
 void SetErrorMessage(picojson::object& error,
                      const std::string& property_name) {
   std::string error_message = "Fail to get " + property_name;
@@ -40,7 +44,12 @@ class PkgMgrHandle {
   static PkgMgrHandle* Create(const std::string& app_id,
                               picojson::object& error) {
     pkgmgrinfo_appinfo_h appinfo_handle;
-    int ret = pkgmgrinfo_appinfo_get_appinfo(app_id.c_str(), &appinfo_handle);
+    uid_t uid = getuid();
+    int ret = (uid != GLOBAL_USER) ?
+              pkgmgrinfo_appinfo_get_usr_appinfo(app_id.c_str(),
+                                                 uid, &appinfo_handle) :
+              pkgmgrinfo_appinfo_get_appinfo(app_id.c_str(),
+                                             &appinfo_handle);
     if (ret != PMINFO_R_OK) {
       SetErrorMessage(error, "appinfo");
       return NULL;
@@ -151,13 +160,15 @@ class PkgMgrHandle {
     }
 
     pkgmgrinfo_pkginfo_h pkginfo_handle;
-    ret = pkgmgrinfo_pkginfo_get_pkginfo(pkg_id, &pkginfo_handle);
+    uid_t uid = getuid();
+    ret = (uid != GLOBAL_USER) ?
+           pkgmgrinfo_pkginfo_get_usr_pkginfo(pkg_id, uid, &pkginfo_handle) :
+           pkgmgrinfo_pkginfo_get_pkginfo(pkg_id, &pkginfo_handle);
     if (ret != PMINFO_R_OK) {
       SetErrorMessage(error, "pkginfo");
       pkgmgrinfo_appinfo_destroy_appinfo(appinfo_handle);
       return NULL;
     }
-
     return new PkgMgrHandle(app_id, pkg_id, appinfo_handle,
                             pkginfo_handle, owns_appinfo_handle);
   }
@@ -247,7 +258,12 @@ int GetAllAppInfoCallback(pkgmgrinfo_appinfo_h appinfo_handle,
 
 void RetrieveAllInstalledAppInfo(picojson::array& data,
                                  picojson::object& error) {
-  int ret = pkgmgrinfo_appinfo_get_installed_list(GetAllAppInfoCallback, &data);
+  uid_t uid = getuid();
+  int ret = (uid != GLOBAL_USER) ?
+             pkgmgrinfo_appinfo_get_usr_installed_list(GetAllAppInfoCallback,
+                                                       uid, &data) :
+             pkgmgrinfo_appinfo_get_installed_list(GetAllAppInfoCallback,
+                                                   &data);
   if (ret != PMINFO_R_OK) {
     SetErrorMessage(error, "installed");
     return;
index a78f50d..312d69f 100644 (file)
@@ -7,6 +7,7 @@
 #include <app_manager.h>
 #include <aul.h>
 #include <pkgmgr-info.h>
+#include <tzplatform_config.h>
 #include <unistd.h>
 
 #include <algorithm>
@@ -22,6 +23,8 @@
 
 namespace {
 
+const uid_t GLOBAL_USER = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
+
 // Application information events.
 const char kOkayEvent[] = "ok";
 const char kInstallEvent[] = "install";
@@ -175,13 +178,17 @@ picojson::value* ApplicationManager::LaunchApp(const std::string& app_id) {
 
 picojson::value* ApplicationManager::GetAppMetaData(const std::string& app_id) {
   pkgmgrinfo_appinfo_h handle;
-  if (pkgmgrinfo_appinfo_get_appinfo(app_id.c_str(), &handle) != PMINFO_R_OK)
+  uid_t uid = getuid();
+  int ret = (uid != GLOBAL_USER) ?
+             pkgmgrinfo_appinfo_get_usr_appinfo(app_id.c_str(),
+                                                uid, &handle) :
+             pkgmgrinfo_appinfo_get_appinfo(app_id.c_str(),
+                                            &handle);
+  if (ret != PMINFO_R_OK)
     return CreateResultMessage(WebApiAPIErrors::NOT_FOUND_ERR);
-
   // The first boolean will set to false if AppMetaDataCallback fail.
   auto data = std::make_tuple(true, picojson::array());
-  int ret = pkgmgrinfo_appinfo_foreach_metadata(
-      handle, AppMetaDataCallback, &data);
+  ret = pkgmgrinfo_appinfo_foreach_metadata(handle, AppMetaDataCallback, &data);
   pkgmgrinfo_appinfo_destroy_appinfo(handle);
   if (ret != PMINFO_R_OK || !std::get<0>(data))
     return CreateResultMessage(WebApiAPIErrors::UNKNOWN_ERR);
index 93984a0..6bf8335 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <pkgmgr-info.h>
 #include <tzplatform_config.h>
+#include <unistd.h>
 
 #include <cassert>
 #include <algorithm>
@@ -20,6 +21,8 @@
 
 namespace {
 
+const uid_t GLOBAL_USER = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
+
 const char kInternalStorage[] = "internal";
 const char kRemovableStorage[] = "removable";
 
@@ -140,7 +143,12 @@ int VirtualFS::GetDirEntryCount(const char* path) {
 std::string VirtualFS::GetAppId(const std::string& package_id) {
   char* appid = NULL;
   pkgmgrinfo_pkginfo_h pkginfo_handle;
-  int ret = pkgmgrinfo_pkginfo_get_pkginfo(package_id.c_str(), &pkginfo_handle);
+  uid_t uid = getuid();
+  int ret = (uid != GLOBAL_USER) ?
+             pkgmgrinfo_pkginfo_get_usr_pkginfo(package_id.c_str(),
+                                                uid, &pkginfo_handle) :
+             pkgmgrinfo_pkginfo_get_pkginfo(package_id.c_str(),
+                                            &pkginfo_handle);
   if (ret != PMINFO_R_OK)
     return std::string();
   ret = pkgmgrinfo_pkginfo_get_mainappid(pkginfo_handle, &appid);
@@ -157,7 +165,12 @@ std::string VirtualFS::GetAppId(const std::string& package_id) {
 std::string VirtualFS::GetExecPath(const std::string& app_id) {
   char* exec_path = NULL;
   pkgmgrinfo_appinfo_h appinfo_handle;
-  int ret = pkgmgrinfo_appinfo_get_appinfo(app_id.c_str(), &appinfo_handle);
+  uid_t uid = getuid();
+  int ret = (uid != GLOBAL_USER) ?
+             pkgmgrinfo_appinfo_get_usr_appinfo(app_id.c_str(),
+                                                uid, &appinfo_handle) :
+             pkgmgrinfo_appinfo_get_appinfo(app_id.c_str(),
+                                            &appinfo_handle);
   if (ret != PMINFO_R_OK)
     return std::string();
   ret = pkgmgrinfo_appinfo_get_exec(appinfo_handle, &exec_path);