modify app initialization logic
authorYoung Ik Cho <youngik.cho@samsung.com>
Mon, 16 Sep 2013 09:25:28 +0000 (18:25 +0900)
committerYoung Ik Cho <youngik.cho@samsung.com>
Mon, 16 Sep 2013 09:25:28 +0000 (18:25 +0900)
Change-Id: I38618d0f3d2fc607e3e64b3004ee3479b79f8f81
Signed-off-by: Young Ik Cho <youngik.cho@samsung.com>
CMakeLists.txt
packaging/osp-env-config.spec
src/osp-env-config.c

index 41aa075..1fbb741 100644 (file)
@@ -5,6 +5,7 @@ SET(this_target osp-env-config)
 INCLUDE_DIRECTORIES(
        /usr/include/vconf
        /usr/include/dlog
+       appinfo
 ) 
 
 SET (${this_target}_SOURCE_FILES
@@ -20,7 +21,11 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
 SET(CMAKE_CXX_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}")
 SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined -Wl,--as-needed")
 
+ADD_DEPENDENCIES(${this_target} appinfo)
+
 TARGET_LINK_LIBRARIES(${this_target} "-ldl -lvconf -ldlog")
+TARGET_LINK_LIBRARIES(${this_target} appinfo)
+
 
 SET_TARGET_PROPERTIES(${this_target}
        PROPERTIES
index c4fef12..c954b6d 100644 (file)
@@ -1,7 +1,7 @@
 Name:          osp-env-config
 Summary:       osp application environment cofiguration serivce
 Version:       1.2.2.1
-Release:       3
+Release:       4
 Group:         System/Libraries
 License:       Apache-2.0
 Source0:       %{name}-%{version}.tar.gz
index 74526fe..7c0ea3f 100644 (file)
@@ -35,6 +35,7 @@
 
 #include <dlog.h>
 #include <vconf.h>
+#include <appinfo.h>
 
 #undef LOG_TAG
 #define LOG_TAG "ENV_CONFIG"
 
 static const char _OSP_COMPAT_SHARED_PATH[] = "/opt/usr/share/.osp-compat/\0";
 static const char _EXT_OSP_HOME_PATH[] = "/opt/storage/sdcard/osp/\0";
-static const char OSP_COMPAT_LIB[] = "/usr/lib/osp/libosp-compat.so.1";
+static const char OSP_COMPAT_LIB[] = "/usr/lib/osp/libosp-compat.so";
 
 struct _path_info
 {
        char src_path[PATH_MAX];
-       char dest_path[PATH_MAX];
+       const char dest_path[PATH_MAX];
 };
 
 struct _dir_info
@@ -97,67 +98,6 @@ get_app_rootpath_from_path(const char* bin_path)
        return app_rootpath;
 }
 
-static void
-get_package_id_from_app_rootpath(const char* app_rootpath, char* package_id)
-{
-       const char* p = NULL;
-       if (strncmp(app_rootpath, "/opt/apps/org.tizen.", 19) == 0)
-       {
-               p = strrchr(app_rootpath, '.') + 1;
-       }
-       else
-       {
-               p = strrchr(app_rootpath, '/') + 1;
-       }
-       strncpy(package_id, p, _MAX_PACKAGEID_LENGTH);
-       package_id[_MAX_PACKAGEID_LENGTH] = '\0';
-       _SECURE_LOGI("package id: %s", package_id);
-}
-
-#if 0
-static void
-get_package_id_from_package_name(const char* package_name, char* package_id)
-{
-       char* tmpbuf = NULL;
-
-       if (strncmp(package_name, "com", 3) == 0)
-       {   // in case of com.samsung.#osp#[package_id]#[serviceid]
-               tmpbuf = strstr(package_name, "#osp#");
-               if (tmpbuf != NULL)
-               {
-                       strncpy(package_id, tmpbuf + 5, _MAX_PACKAGEID_LENGTH);
-               }
-       }
-       else if (strncmp(package_name, "osp", 3) == 0)
-       {   // in case of osp.[package_id].#osp#[serviceid]
-               tmpbuf = strstr(package_name, "osp.");
-               if (tmpbuf != NULL)
-               {
-                       strncpy(package_id, tmpbuf + 4, _MAX_PACKAGEID_LENGTH);
-               }
-       }
-       else if (strncmp(package_name, "org.tizen", 9) == 0)
-       {
-               // in case of org.tizen.[package_id]#[serviceid]
-               tmpbuf = strstr(package_name, "org.tizen.");
-               if (tmpbuf != NULL)
-               {
-                       strncpy(package_id, tmpbuf + 10, _MAX_PACKAGEID_LENGTH);
-               }
-       }
-       else if (strlen(package_name) == 10)
-       {
-               strncpy(package_id, package_name, _MAX_PACKAGEID_LENGTH);
-       }
-       else
-       {
-               LOGE("package name is invalid (%s)", package_name);
-       }
-
-       package_id[_MAX_PACKAGEID_LENGTH] = '\0';
-       _SECURE_LOGI("package_id: %s", package_id);
-}
-#endif
 
 static int
 internal_is_mounted(const char* pkgid)
@@ -706,7 +646,6 @@ do_pre_exec(const char* package_name, const char* bin_path)
        char* app_rootpath = NULL;
        char app_compat_path[PATH_MAX] = { 0, };
        const char app_compat_file[] = "/info/compat.info\0";
-       char package_id[_MAX_PACKAGEID_LENGTH + 1] = { 0, };
        char osp_app_data_path[PATH_MAX] = { 0, };
        int osp_compat = 0;
 
@@ -721,7 +660,10 @@ do_pre_exec(const char* package_name, const char* bin_path)
                osp_compat = 1;
        }
 
-       get_package_id_from_app_rootpath(app_rootpath, package_id);
+       appinfo_init(package_name, 0);
+       appinfo_set_compat(osp_compat);
+
+       const char* package_id = appinfo_get_packageid();
 
        _SECURE_LOGI("package id: %s, binary path: %s, OSP compat: %d", package_id, bin_path, osp_compat);
 
@@ -786,3 +728,4 @@ ERROR:
        free(app_rootpath);
        return -1;
 }
+