implement csc path, is_update status
authorjunsuk77.oh <junsuk77.oh@samsung.com>
Wed, 29 May 2013 03:48:32 +0000 (12:48 +0900)
committerjunsuk77.oh <junsuk77.oh@samsung.com>
Wed, 29 May 2013 03:48:32 +0000 (12:48 +0900)
Change-Id: I5e5fe08c1c7c16a0890fca6b72ca562336acbf1f
Signed-off-by: junsuk77.oh <junsuk77.oh@samsung.com>
include/pkgmgr-info.h
packaging/pkgmgr-info.spec
parser/manifest.xsd.in
parser/pkgmgr_parser.c
parser/pkgmgr_parser.h
parser/pkgmgr_parser_db.c
src/pkgmgr-info.c

index 6703c52..4db5042 100755 (executable)
@@ -1280,6 +1280,43 @@ static int get_root_path(const char *pkgid)
  */
 int pkgmgrinfo_pkginfo_get_root_path(pkgmgrinfo_pkginfo_h handle, char **path);
 
+
+/**
+ * @fn int pkgmgrinfo_pkginfo_get_csc_path(pkgmgrinfo_pkginfo_h handle, char **path)
+ * @brief      This API gets the csc path of package
+ *
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @param[in] handle           pointer to package info handle
+ * @param[out] path            pointer to hold csc path of package
+ * @return     0 if success, error code(<0) if fail
+ * @retval     PMINFO_R_OK     success
+ * @retval     PMINFO_R_EINVAL invalid argument
+ * @retval     PMINFO_R_ERROR  internal error
+ * @code
+static int get_csc_path(const char *pkgid)
+{
+       int ret = 0;
+       char *path = 0;
+       pkgmgrinfo_pkginfo_h handle;
+       ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
+       if (ret != PMINFO_R_OK)
+               return -1;
+
+       ret = pkgmgrinfo_pkginfo_get_csc_path(handle, &path);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+               return -1;
+       }
+       printf("path : %s\n", path);
+       pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+
+       return 0;
+}
+ * @endcode
+ */
+int pkgmgrinfo_pkginfo_get_csc_path(pkgmgrinfo_pkginfo_h handle, char **path);
+
 /**
  * @fn int pkgmgrinfo_pkginfo_compare_pkg_cert_info(const char *lhs_package_id, const char *rhs_package_id, pkgmgrinfo_cert_compare_result_type_e *compare_result)
  * @brief      This API compare the cert information from given package id
index 183fedc..71e063a 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       pkgmgr-info
 Summary:    Packager Manager infomation api for package
-Version:    0.0.114
+Version:    0.0.117
 Release:    1
 Group:      Application Framework/Package Management
 License:    Apache-2.0
index 5d71090..72d7431 100755 (executable)
@@ -31,6 +31,7 @@
       <xs:attribute name="version" use="required" type="xs:NMTOKEN"/>
       <xs:attribute name="size" type="xs:NMTOKEN"/>
          <xs:attribute name="root_path" type="xs:string"/>
+         <xs:attribute name="csc_path" type="xs:string"/>
          <xs:attribute name="appsetting" type="xs:boolean"/>
          <xs:attribute name="nodisplay-setting" type="xs:boolean"/>
          <xs:attribute name="url" type="xs:string"/>
index eb73e69..1ded904 100755 (executable)
@@ -3240,6 +3240,8 @@ static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx)
                                mfx->type = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("type")));
                        if (xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")))
                                mfx->root_path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("root_path")));
+                       if (xmlTextReaderGetAttribute(reader, XMLCHAR("csc_path")))
+                               mfx->csc_path = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("csc_path")));
                        if (xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting"))) {
                                mfx->appsetting = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("appsetting")));
                                if (mfx->appsetting == NULL)
@@ -3263,6 +3265,7 @@ static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx)
                        mfx->preload = strdup("False");
                        mfx->removable = strdup("True");
                        mfx->readonly = strdup("False");
+                       mfx->update = strdup("False");
                        char buf[PKG_STRING_LEN_MAX] = {'\0'};
                        char *val = NULL;
                        time_t current_time;
@@ -3284,6 +3287,7 @@ static int __process_manifest(xmlTextReaderPtr reader, manifest_x * mfx)
 
 #define DESKTOP_RW_PATH "/opt/share/applications/"
 #define DESKTOP_RO_PATH "/usr/share/applications/"
+#define MANIFEST_RO_PREFIX "/usr/share/packages/"
 
 static char* __convert_to_system_locale(const char *mlocale)
 {
@@ -3360,7 +3364,7 @@ END:
 /* desktop shoud be generated automatically based on manifest */
 /* Currently removable, taskmanage, etc fields are not considerd. it will be decided soon.*/
 #define BUFMAX 1024*128
-static int __ps_make_nativeapp_desktop(manifest_x * mfx, bool is_update)
+static int __ps_make_nativeapp_desktop(manifest_x * mfx, const char *manifest, bool is_update)
 {
         FILE* file = NULL;
         int fd = 0;
@@ -3384,8 +3388,17 @@ static int __ps_make_nativeapp_desktop(manifest_x * mfx, bool is_update)
 
        for(; mfx->uiapplication; mfx->uiapplication=mfx->uiapplication->next) {
 
+               if (manifest != NULL) {
+                       /* skip making a deskfile and update ail, if preload app is updated */
+                       if(strstr(manifest, MANIFEST_RO_PREFIX)) {
+                               __ail_change_info(AIL_INSTALL, mfx->uiapplication->appid);
+                   DBGE("preload app is update : skip and update ail : %s", manifest);
+                               continue;
+                       }
+               }
+
                if(mfx->readonly && !strcasecmp(mfx->readonly, "True"))
-                       snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RO_PATH, mfx->uiapplication->appid);
+                       snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RO_PATH, mfx->uiapplication->appid);
                else
                        snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, mfx->uiapplication->appid);
 
@@ -3760,7 +3773,6 @@ END:
        return ret;
 }
 
-#define MANIFEST_RO_PREFIX "/usr/share/packages/"
 #define PRELOAD_PACKAGE_LIST "/usr/etc/package-manager/preload/preload_list.txt"
 static int __add_preload_info(manifest_x * mfx, const char *manifest)
 {
@@ -3831,16 +3843,20 @@ static int __check_preload_updated(manifest_x * mfx, const char *manifest)
        uiapplication_x *uiapplication = mfx->uiapplication;
 
        if(strstr(manifest, MANIFEST_RO_PREFIX)) {
-/* if preload app is updated, then remove previous desktop file on RW*/
+               /* if preload app is updated, then remove previous desktop file on RW*/
                for(; uiapplication; uiapplication=uiapplication->next) {
                                snprintf(filepath, sizeof(filepath),"%s%s.desktop", DESKTOP_RW_PATH, uiapplication->appid);
                        ret = remove(filepath);
                        if (ret <0)
                                return -1;
                }
-
-               return 0;
+       } else {
+               /* if downloaded app is updated, then update tag set true*/
+               free((void *)mfx->update);
+               mfx->update = strdup("true");
        }
+
+       return 0;
 }
 
 API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
@@ -3911,6 +3927,10 @@ API void pkgmgr_parser_free_manifest_xml(manifest_x *mfx)
                free((void *)mfx->root_path);
                mfx->root_path = NULL;
        }
+       if (mfx->csc_path) {
+               free((void *)mfx->csc_path);
+               mfx->csc_path = NULL;
+       }
        if (mfx->appsetting) {
                free((void *)mfx->appsetting);
                mfx->appsetting = NULL;
@@ -4116,12 +4136,6 @@ API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char
        __add_preload_info(mfx, manifest);
        DBG("Added preload infomation\n");
 
-       snprintf(roxml_check, PKG_STRING_LEN_MAX, MANIFEST_RO_DIRECTORY "/%s.xml", mfx->package);
-       if (access(roxml_check, F_OK) == 0)
-               mfx->update = strdup("true");
-       else
-               mfx->update = strdup("false");
-
        __ps_process_tag(mfx, tagv);
 
        ret = pkgmgr_parser_insert_manifest_info_in_db(mfx);
@@ -4130,7 +4144,7 @@ API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char
        else
                DBG("DB Insert Success\n");
 
-       ret = __ps_make_nativeapp_desktop(mfx, 0);
+       ret = __ps_make_nativeapp_desktop(mfx, NULL, 0);
        if (ret == -1)
                DBG("Creating desktop file failed\n");
        else
@@ -4150,7 +4164,7 @@ API int pkgmgr_parser_create_desktop_file(manifest_x *mfx)
                DBG("Manifest pointer is NULL\n");
                return -1;
        }
-        ret = __ps_make_nativeapp_desktop(mfx, 0);
+        ret = __ps_make_nativeapp_desktop(mfx, NULL, 0);
         if (ret == -1)
                 DBG("Creating desktop file failed\n");
         else
@@ -4196,14 +4210,13 @@ API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *con
                mfx->preload = strdup("true");
        }
 
-       mfx->update = strdup("true");
        ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
        if (ret == -1)
                DBG("DB Update failed\n");
        else
                DBG("DB Update Success\n");
 
-       ret = __ps_make_nativeapp_desktop(mfx, 1);
+       ret = __ps_make_nativeapp_desktop(mfx, manifest, 1);
        if (ret == -1)
                DBG("Creating desktop file failed\n");
        else
index 401e32c..126f191 100755 (executable)
@@ -459,6 +459,7 @@ typedef struct manifest_x {
        const char *mainapp_id;         /**< app id of main application*/
        const char *package_url;                /**< app id of main application*/
        const char *root_path;          /**< package root path*/
+       const char *csc_path;           /**< package csc path*/
        const char *nodisplay_setting;          /**< package no display setting menu*/
        struct icon_x *icon;            /**< package icon*/
        struct label_x *label;          /**< package label*/
index 5348ddb..ba0568c 100755 (executable)
@@ -63,7 +63,8 @@ char *prev = NULL;
                                                "storeclient_id text," \
                                                "mainapp_id text," \
                                                "package_url text," \
-                                               "root_path text)"
+                                               "root_path text," \
+                                               "csc_path text)"
 
 #define QUERY_CREATE_TABLE_PACKAGE_LOCALIZED_INFO "create table if not exists package_localized_info " \
                                                "(package text not null, " \
@@ -1502,10 +1503,12 @@ static int __insert_manifest_info_in_db(manifest_x *mfx)
        }
        snprintf(query, MAX_QUERY_LEN,
                 "insert into package_info(package, package_type, package_version, install_location, package_size, " \
-               "package_removable, package_preload, package_readonly, package_update, package_appsetting, package_nodisplay, author_name, author_email, author_href, installed_time, installed_storage, storeclient_id, mainapp_id, package_url, root_path) " \
-               "values('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",\
+               "package_removable, package_preload, package_readonly, package_update, package_appsetting, package_nodisplay, " \
+               "author_name, author_email, author_href, installed_time, installed_storage, storeclient_id, mainapp_id, package_url, root_path, csc_path) " \
+               "values('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",\
                 mfx->package, type, mfx->version, mfx->installlocation, mfx->package_size, mfx->removable, mfx->preload,
-                mfx->readonly, mfx->update, mfx->appsetting, mfx->nodisplay_setting, auth_name, auth_email, auth_href, mfx->installed_time, mfx->installed_storage, mfx->storeclient_id, mfx->mainapp_id, mfx->package_url, path);
+                mfx->readonly, mfx->update, mfx->appsetting, mfx->nodisplay_setting,
+                auth_name, auth_email, auth_href, mfx->installed_time, mfx->installed_storage, mfx->storeclient_id, mfx->mainapp_id, mfx->package_url, path, mfx->csc_path);
        ret = __exec_query(query);
        if (ret == -1) {
                DBG("Package Info DB Insert Failed\n");
index 28d9720..8866341 100755 (executable)
@@ -1060,6 +1060,11 @@ static int __pkginfo_cb(void *data, int ncols, char **coltxt, char **colname)
                                info->manifest_info->root_path = strdup(coltxt[i]);
                        else
                                info->manifest_info->root_path = NULL;
+               } else if (strcmp(colname[i], "csc_path") == 0 ){
+                       if (coltxt[i])
+                               info->manifest_info->csc_path = strdup(coltxt[i]);
+                       else
+                               info->manifest_info->csc_path = NULL;
                } else if (strcmp(colname[i], "privilege") == 0 ){
                        if (coltxt[i])
                                info->manifest_info->privileges->privilege->text = strdup(coltxt[i]);
@@ -2880,6 +2885,19 @@ API int pkgmgrinfo_pkginfo_get_root_path(pkgmgrinfo_pkginfo_h handle, char **pat
        return PMINFO_R_OK;
 }
 
+API int pkgmgrinfo_pkginfo_get_csc_path(pkgmgrinfo_pkginfo_h handle, char **path)
+{
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+       retvm_if(path == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+       pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+       if (info->manifest_info->csc_path)
+               *path = (char *)info->manifest_info->csc_path;
+       else
+               *path = (char *)info->manifest_info->csc_path;
+
+       return PMINFO_R_OK;
+}
 
 API int pkgmgrinfo_pkginfo_compare_pkg_cert_info(const char *lhs_package_id, const char *rhs_package_id, pkgmgrinfo_cert_compare_result_type_e *compare_result)
 {
@@ -3669,9 +3687,11 @@ API int pkgmgrinfo_pkginfo_foreach_privilege(pkgmgrinfo_pkginfo_h handle,
        pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
        ptr = info->manifest_info->privileges->privilege;
        for (; ptr; ptr = ptr->next) {
-               ret = privilege_func(ptr->text, user_data);
-               if (ret < 0)
-                       break;
+               if (ptr->text){
+                       ret = privilege_func(ptr->text, user_data);
+                       if (ret < 0)
+                               break;
+               }
        }
        return PMINFO_R_OK;
 }