tizen 2.3 release tizen_2.3 submit/tizen_2.3/20150202.061210 tizen_2.3_release
authorjk7744.park <jk7744.park@samsung.com>
Sun, 1 Feb 2015 04:33:08 +0000 (13:33 +0900)
committerjk7744.park <jk7744.park@samsung.com>
Sun, 1 Feb 2015 04:33:08 +0000 (13:33 +0900)
21 files changed:
CMakeLists.txt
ail-mobile.manifest [deleted file]
ail.manifest [moved from ail-wearable.manifest with 100% similarity]
include/ail.h
packaging/ail.spec
src/ail_convert.c
src/ail_db.c
src/ail_db.h
src/ail_desktop.c
src/ail_filter.c
src/ail_package.c
src/ail_package.h
src/ail_private.h
src/ail_sql.c
src/ail_sql.h
test/CMakeLists.txt [new file with mode: 0755]
test/src/ail_test.c [new file with mode: 0644]
tool/src/ail_desktop.c
tool/src/ail_filter.c
tool/src/ail_package.c
tool/src/initdb.c

index 6725c88..08590a7 100644 (file)
@@ -53,3 +53,4 @@ INSTALL(FILES ${CMAKE_SOURCE_DIR}/desktop.conf DESTINATION share/install-info)
 
 # AIL init database
 ADD_SUBDIRECTORY(tool)
+ADD_SUBDIRECTORY(test)
diff --git a/ail-mobile.manifest b/ail-mobile.manifest
deleted file mode 100644 (file)
index 0b1e3f9..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-<manifest>
-       <define>
-               <domain name="ail"/>
-               <provide>
-                       <label name="ail::db"/>
-               </provide>
-       </define>
-       <request>
-               <domain name="_"/>
-       </request>
-</manifest>
similarity index 100%
rename from ail-wearable.manifest
rename to ail.manifest
index 1a81250..f08d7e0 100755 (executable)
@@ -67,6 +67,7 @@ extern "C" {
 #define        AIL_PROP_X_SLP_PACKAGETYPE_STR          "AIL_PROP_X_SLP_PACKAGETYPE_STR"
 #define        AIL_PROP_X_SLP_PACKAGECATEGORIES_STR    "AIL_PROP_X_SLP_PACKAGECATEGORIES_STR"
 #define        AIL_PROP_X_SLP_PACKAGEID_STR            "AIL_PROP_X_SLP_PACKAGEID_STR"
+#define        AIL_PROP_X_SLP_URI_STR                  "AIL_PROP_X_SLP_URI_STR"
 #define        AIL_PROP_X_SLP_SVC_STR                  "AIL_PROP_X_SLP_SVC_STR"
 #define        AIL_PROP_X_SLP_EXE_PATH                 "AIL_PROP_X_SLP_EXE_PATH"
 #define        AIL_PROP_X_SLP_APPID_STR                "AIL_PROP_X_SLP_APPID_STR"
@@ -103,7 +104,7 @@ typedef struct ail_filter *ail_filter_h;
 typedef struct ail_appinfo *ail_appinfo_h;
 
 /**
- * @brief return values 
+ * @brief return values
  */
 typedef enum {
        AIL_ERROR_OK = 0,                                               /**< General success */
@@ -493,7 +494,7 @@ int list_apps()
        ail_filter_list_appinfo_foreach(filter, appinfo_func, (void *)&i);
 
        ail_filter_destroy(filter);
-       
+
        return 0;
 }
  * @endcode
@@ -957,7 +958,8 @@ static ail_error_e _get_name(const char *appid)
 }
  * @endcode
  */
-ail_error_e ail_destroy_appinfo(const ail_appinfo_h handle);
+
+ail_error_e ail_destroy_appinfo(ail_appinfo_h ai);
 
 /**
  * @fn ail_error_e ail_close_appinfo_db(void)
index a5d5087..47c010c 100755 (executable)
@@ -1,7 +1,7 @@
 #sbs-git:slp/pkgs/a/ail ail 0.2.22 29ac1f2c98453cad647cca6a92abc7da3dbb047b
 Name:       ail
 Summary:    Application Information Library
-Version:    0.2.87
+Version:    0.2.95
 Release:    1
 Group:      System/Libraries
 License:    Apache License, Version 2.0
@@ -80,16 +80,13 @@ update_DAC_for_db_file /opt/dbspace/.app_info.db-journal
 %postun
 
 %files
-%if %{_repository} == "wearable"
-%manifest ail-wearable.manifest
-%else
-%manifest ail-mobile.manifest
-%endif
+%manifest ail.manifest
 %{_libdir}/libail.so.0
 %{_libdir}/libail.so.0.1.0
 /usr/bin/ail_initdb
 /usr/bin/ail_desktop
 /usr/bin/ail_filter
+/usr/bin/ail_test
 /usr/bin/ail_package
 /usr/share/install-info/*
 /usr/share/license/%{name}
index 21cfcc1..fb2820b 100755 (executable)
@@ -47,7 +47,7 @@ static struct _ail_str_map_t str_prop_map[] = {
        {E_AIL_PROP_X_SLP_PACKAGETYPE_STR,      AIL_PROP_X_SLP_PACKAGETYPE_STR},
        {E_AIL_PROP_X_SLP_PACKAGECATEGORIES_STR, AIL_PROP_X_SLP_PACKAGECATEGORIES_STR},
        {E_AIL_PROP_X_SLP_PACKAGEID_STR,        AIL_PROP_X_SLP_PACKAGEID_STR},
-/*     {E_AIL_PROP_X_SLP_URI_STR,              AIL_PROP_X_SLP_URI_STR}, */
+       {E_AIL_PROP_X_SLP_URI_STR,              AIL_PROP_X_SLP_URI_STR},
        {E_AIL_PROP_X_SLP_SVC_STR,              AIL_PROP_X_SLP_SVC_STR},
        {E_AIL_PROP_X_SLP_EXE_PATH,             AIL_PROP_X_SLP_EXE_PATH},
        {E_AIL_PROP_X_SLP_APPID_STR,            AIL_PROP_X_SLP_APPID_STR},
@@ -79,7 +79,7 @@ static struct _ail_bool_map_t bool_prop_map[] = {
        {E_AIL_PROP_X_SLP_TASKMANAGE_BOOL, AIL_PROP_X_SLP_TASKMANAGE_BOOL},
        {E_AIL_PROP_X_SLP_MULTIPLE_BOOL, AIL_PROP_X_SLP_MULTIPLE_BOOL},
        {E_AIL_PROP_X_SLP_REMOVABLE_BOOL, AIL_PROP_X_SLP_REMOVABLE_BOOL},
-/*     {E_AIL_PROP_X_SLP_ISHORIZONTALSCALE_BOOL, AIL_PROP_X_SLP_ISHORIZONTALSCALE_BOOL}, */
+       {E_AIL_PROP_X_SLP_ISHORIZONTALSCALE_BOOL, AIL_PROP_X_SLP_ISHORIZONTALSCALE_BOOL},
        {E_AIL_PROP_X_SLP_ENABLED_BOOL, AIL_PROP_X_SLP_ENABLED_BOOL},
        {E_AIL_PROP_X_SLP_SUBMODE_BOOL, AIL_PROP_X_SLP_SUBMODE_BOOL}
 };
index 1a05639..d5135b1 100755 (executable)
@@ -54,12 +54,10 @@ static __thread struct {
 
 ail_error_e db_open(db_open_mode mode)
 {
-       int ret;
-       int changed = 0;
+       int ret = AIL_ERROR_OK;
 
        if(mode & DB_OPEN_RO) {
                if (!db_info.dbro) {
-                       //ret = db_util_open_with_options(APP_INFO_DB, &db_info.dbro, SQLITE_OPEN_READONLY, NULL);
                        ret = db_util_open(APP_INFO_DB, &db_info.dbro, 0);
                        retv_with_dbmsg_if(ret != SQLITE_OK, AIL_ERROR_DB_FAILED);
                }
@@ -76,6 +74,28 @@ ail_error_e db_open(db_open_mode mode)
 }
 
 
+ail_error_e db_open_pkg_mgr(db_open_mode mode)
+{
+       int ret = AIL_ERROR_OK;
+
+       if(mode & DB_OPEN_RO) {
+               if (!db_info.dbro) {
+                       ret = db_util_open(PKGMGR_PARSER_DB, &db_info.dbro, 0);
+                       retv_with_dbmsg_if(ret != SQLITE_OK, AIL_ERROR_DB_FAILED);
+               }
+       }
+
+       if(mode & DB_OPEN_RW) {
+               if (!db_info.dbrw) {
+                       ret = db_util_open(PKGMGR_PARSER_DB, &db_info.dbrw, 0);
+                       retv_with_dbmsg_if(ret != SQLITE_OK, AIL_ERROR_DB_FAILED);
+               }
+       }
+
+       return AIL_ERROR_OK;
+}
+
+
 
 ail_error_e db_prepare(const char *query, sqlite3_stmt **stmt)
 {
@@ -90,7 +110,7 @@ ail_error_e db_prepare(const char *query, sqlite3_stmt **stmt)
                _E("%s\n", sqlite3_errmsg(db_info.dbro));
                _E("%d\n", sqlite3_extended_errcode(db_info.dbro));
                return AIL_ERROR_DB_FAILED;
-       } else 
+       } else
                return AIL_ERROR_OK;
 }
 
index 56b1b2a..1058e5e 100755 (executable)
@@ -37,6 +37,7 @@ typedef enum {
 typedef int (*sqlite_query_callback)(void *data, int ncols, char **coltxt, char **colname);
 
 ail_error_e db_open(db_open_mode mode);
+ail_error_e db_open_pkg_mgr(db_open_mode mode);
 ail_error_e db_prepare(const char *query, sqlite3_stmt **stmt);
 
 ail_error_e db_bind_bool(sqlite3_stmt *stmt, int idx, bool value);
index dd7ccb8..2505cc9 100755 (executable)
@@ -38,6 +38,7 @@
 #include "ail_db.h"
 #include "ail_sql.h"
 #include "ail.h"
+#include "ail_convert.h"
 
 #define OPT_DESKTOP_DIRECTORY "/opt/share/applications"
 #define USR_DESKTOP_DIRECTORY "/usr/share/applications"
@@ -362,7 +363,10 @@ static ail_error_e _read_mimetype(void *data, char *tag, char *value)
 {
        desktop_info_s *info = data;
        int size, total_len = 0;
-       char *mimes_origin, *mimes_changed, *token_unalias, *save_ptr;
+       char *mimes_origin = NULL;
+       char *mimes_changed = NULL;
+       char *token_unalias = NULL;
+       char *save_ptr = NULL;
 
        retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
        retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
@@ -398,6 +402,10 @@ static ail_error_e _read_mimetype(void *data, char *tag, char *value)
                        tmp = realloc(mimes_changed, size);
                        if(!tmp) {
                                free(mimes_changed);
+
+                               if (mimes_origin)
+                                       free(mimes_origin);
+
                                return AIL_ERROR_OUT_OF_MEMORY;
                        }
                        mimes_changed = tmp;
@@ -415,6 +423,9 @@ static ail_error_e _read_mimetype(void *data, char *tag, char *value)
        SAFE_FREE(info->mimetype);
        info->mimetype = mimes_changed;
 
+       if (mimes_origin)
+               free(mimes_origin);
+
        return AIL_ERROR_OK;
 }
 
@@ -1073,7 +1084,6 @@ static ail_error_e _modify_desktop_info_bool(desktop_info_s* info,
                                                  bool value)
 {
        ail_prop_bool_e prop;
-       int val;
 
        retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
        retv_if(!property, AIL_ERROR_INVALID_PARAMETER);
@@ -1099,8 +1109,7 @@ static ail_error_e _modify_desktop_info_str(desktop_info_s* info,
                                                  const char *property,
                                                  const char *value)
 {
-       ail_prop_bool_e prop;
-       int val;
+       ail_prop_str_e prop;
 
        retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
        retv_if(!property, AIL_ERROR_INVALID_PARAMETER);
@@ -1207,10 +1216,8 @@ static inline void _insert_localname(gpointer data, gpointer user_data)
 
 static ail_error_e _insert_desktop_info(desktop_info_s *info)
 {
-       int len;
        ail_error_e ret;
 
-       len = _strlen_desktop_info(info) + (0x01 << 10);
 
        char *query = sqlite3_mprintf("insert into app_info ("
                "package, "
@@ -1309,7 +1316,6 @@ static ail_error_e _insert_desktop_info(desktop_info_s *info)
 
 static ail_error_e _update_desktop_info(desktop_info_s *info)
 {
-       int len;
 
        retv_if (NULL == info, AIL_ERROR_INVALID_PARAMETER);
 
@@ -1318,7 +1324,6 @@ static ail_error_e _update_desktop_info(desktop_info_s *info)
                return AIL_ERROR_DB_FAILED;
        }
 
-       len = _strlen_desktop_info(info) + (0x01 << 10);
 
        char *query = sqlite3_mprintf("update app_info set "
                "exec=%Q, "
@@ -1410,7 +1415,6 @@ static ail_error_e _update_desktop_info(desktop_info_s *info)
 
 static ail_error_e _remove_package(const char* package)
 {
-       int size;
        char *query = NULL;
 
        retv_if(!package, AIL_ERROR_INVALID_PARAMETER);
@@ -1419,7 +1423,6 @@ static ail_error_e _remove_package(const char* package)
                return AIL_ERROR_DB_FAILED;
        }
 
-       size = strlen(package) + (0x01 << 10);
 
        query = sqlite3_mprintf("delete from app_info where package = %Q", package);
 
@@ -1447,7 +1450,6 @@ static ail_error_e _remove_package(const char* package)
 
 static ail_error_e _clean_pkgid_data(const char* pkgid)
 {
-       int size;
        char *query = NULL;
 
        retv_if(!pkgid, AIL_ERROR_INVALID_PARAMETER);
@@ -1456,7 +1458,6 @@ static ail_error_e _clean_pkgid_data(const char* pkgid)
                return AIL_ERROR_DB_FAILED;
        }
 
-       size = strlen(pkgid) + (0x01 << 10);
 
        query = sqlite3_mprintf("delete from app_info where x_slp_pkgid = %Q", pkgid);
        if (db_exec(query) < 0) {
@@ -1573,8 +1574,8 @@ static int __is_authorized()
 EXPORT_API ail_error_e ail_desktop_add(const char *appid)
 {
        desktop_info_s info = {0,};
-       ail_error_e ret;
-       int count;
+       ail_error_e ret = AIL_ERROR_OK;
+       int count = 0;
 
        retv_if(!appid, AIL_ERROR_INVALID_PARAMETER);
        if (!__is_authorized()) {
@@ -1583,7 +1584,7 @@ EXPORT_API ail_error_e ail_desktop_add(const char *appid)
        }
 
        count = _count_all();
-       if (count <= 0) {
+       if (count >= 0) {
                ret = _create_table();
                if (ret != AIL_ERROR_OK) {
                        _D("Cannot create a table. Maybe there is already a table.");
@@ -1591,18 +1592,28 @@ EXPORT_API ail_error_e ail_desktop_add(const char *appid)
        }
 
        ret = _init_desktop_info(&info, appid);
-       retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
+       if(ret != AIL_ERROR_OK) {
+               goto err_check;
+       }
 
        ret = _read_desktop_info(&info);
-       retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
+       if(ret != AIL_ERROR_OK) {
+               goto err_check;
+       }
 
        ret = _insert_desktop_info(&info);
-       retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
+       if(ret != AIL_ERROR_OK) {
+               goto err_check;
+       }
 
        ret = _send_db_done_noti(NOTI_ADD, appid);
-       retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
+       if(ret != AIL_ERROR_OK) {
+               goto err_check;
+       }
 
+err_check:
        _fini_desktop_info(&info);
+       retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
 
        return AIL_ERROR_OK;
 }
@@ -1612,7 +1623,7 @@ EXPORT_API ail_error_e ail_desktop_add(const char *appid)
 EXPORT_API ail_error_e ail_desktop_update(const char *appid)
 {
        desktop_info_s info = {0,};
-       ail_error_e ret;
+       ail_error_e ret = AIL_ERROR_OK;
 
        retv_if(!appid, AIL_ERROR_INVALID_PARAMETER);
        if (!__is_authorized()) {
@@ -1621,18 +1632,28 @@ EXPORT_API ail_error_e ail_desktop_update(const char *appid)
        }
 
        ret = _init_desktop_info(&info, appid);
-       retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
+       if(ret != AIL_ERROR_OK) {
+               goto err_check;
+       }
 
        ret = _read_desktop_info(&info);
-       retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
+       if(ret != AIL_ERROR_OK) {
+               goto err_check;
+       }
 
        ret = _update_desktop_info(&info);
-       retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
+       if(ret != AIL_ERROR_OK) {
+               goto err_check;
+       }
 
        ret = _send_db_done_noti(NOTI_UPDATE, appid);
-       retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
+       if(ret != AIL_ERROR_OK) {
+               goto err_check;
+       }
 
+err_check:
        _fini_desktop_info(&info);
+       retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
 
        return AIL_ERROR_OK;
 }
@@ -1698,15 +1719,23 @@ EXPORT_API ail_error_e ail_desktop_fota(const char *appid)
        }
 
        ret = _init_desktop_info(&info, appid);
-       retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
+       if(ret != AIL_ERROR_OK) {
+               goto err_check;
+       }
 
        ret = _read_desktop_info(&info);
-       retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
+       if(ret != AIL_ERROR_OK) {
+               goto err_check;
+       }
 
        ret = _insert_desktop_info(&info);
-       retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
+       if(ret != AIL_ERROR_OK) {
+               goto err_check;
+       }
 
+err_check:
        _fini_desktop_info(&info);
+       retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
 
        return AIL_ERROR_OK;
 }
@@ -1725,23 +1754,35 @@ EXPORT_API ail_error_e ail_desktop_appinfo_modify_bool(const char *appid,
                AIL_ERROR_INVALID_PARAMETER);
 
        ret = _init_desktop_info(&info, appid);
-       retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
+       if(ret != AIL_ERROR_OK) {
+               goto err_check;
+       }
 
        ret = _load_desktop_info(&info);
-       retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
+       if(ret != AIL_ERROR_OK) {
+               goto err_check;
+       }
 
        ret = _modify_desktop_info_bool(&info, property, value);
-       retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
+       if(ret != AIL_ERROR_OK) {
+               goto err_check;
+       }
 
        ret = _update_desktop_info(&info);
-       retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
+       if(ret != AIL_ERROR_OK) {
+               goto err_check;
+       }
 
        if (broadcast) {
                ret = _send_db_done_noti(NOTI_UPDATE, appid);
-               retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
+               if(ret != AIL_ERROR_OK) {
+                       goto err_check;
+               }
        }
 
+err_check:
        _fini_desktop_info(&info);
+       retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
 
        return AIL_ERROR_OK;
 }
@@ -1752,31 +1793,27 @@ EXPORT_API ail_error_e ail_desktop_appinfo_modify_str(const char *appid,
                                                             const char *value,
                                                             bool broadcast)
 {
-       desktop_info_s info = {0,};
-       ail_error_e ret;
-
        retv_if(!appid, AIL_ERROR_INVALID_PARAMETER);
 
-       ret = _init_desktop_info(&info, appid);
-       retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
+       ail_error_e ret = 0;
+       sqlite3_stmt *stmt = NULL;
+       sqlite3 *appinfo_db = NULL;
 
-       ret = _load_desktop_info(&info);
-       retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
+       _D("appinfo_modify_str : %s,  %s", appid, value);
 
-       _D("info.name [%s], value [%s]", info.name, value);
-       ret = _modify_desktop_info_str(&info, property, value);
-       retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
-       _D("info.name [%s], value [%s]", info.name, value);
+       ret = db_util_open(PKGMGR_PARSER_DB, &appinfo_db, 0);
+       retv_if(ret != AIL_ERROR_OK, AIL_ERROR_DB_FAILED);
 
-       ret = _update_desktop_info(&info);
-       retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
+       char *query = sqlite3_mprintf("delete from package_app_app_control where app_id=%Q", appid);
+       ret = sqlite3_exec(appinfo_db, query, NULL, NULL, NULL);
+       sqlite3_free(query);
 
-       if (broadcast) {
-               ret = _send_db_done_noti(NOTI_UPDATE, appid);
-               retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
-       }
+       query = sqlite3_mprintf("insert into package_app_app_control(app_id, app_control) values('%s', '%s')", appid, value);
+       ret = sqlite3_exec(appinfo_db, query, NULL, NULL, NULL);
+       sqlite3_free(query);
+       retv_if(ret != AIL_ERROR_OK, AIL_ERROR_DB_FAILED);
 
-       _fini_desktop_info(&info);
+       sqlite3_close(appinfo_db);
 
        return AIL_ERROR_OK;
 }
index 1c64201..9e4a800 100755 (executable)
@@ -25,6 +25,7 @@
 #include <glib.h>
 #include <string.h>
 #include <stdio.h>
+#include <ctype.h>
 #include "ail.h"
 #include "ail_private.h"
 #include "ail_convert.h"
@@ -174,23 +175,29 @@ EXPORT_API ail_error_e ail_filter_add_str(ail_filter_h filter, const char *prope
 static void _get_condition(gpointer data, char **condition)
 {
        struct element *e = (struct element *)data;
-       const char *f;
-       char buf[AIL_SQL_QUERY_MAX_LEN];
+       const char *f = NULL;
+       char buf[AIL_SQL_QUERY_MAX_LEN] = {0};
+       char *b_value = NULL;
+       int t = 0;
 
        f =  sql_get_filter(e->prop);
-       int t;
        ELEMENT_TYPE(e, t);
 
        switch (t) {
                case VAL_TYPE_BOOL:
-                       snprintf(buf, sizeof(buf), f, ELEMENT_BOOL(e)->value);
+                       if(ELEMENT_BOOL(e)->value)
+                               b_value = strdup("true");
+                       else
+                               b_value = strdup("false");
+
+                       snprintf(buf, sizeof(buf), f, b_value);
                        break;
                case VAL_TYPE_INT:
                        snprintf(buf, sizeof(buf), f, ELEMENT_INT(e)->value);
                        break;
                case VAL_TYPE_STR:
                        if (E_AIL_PROP_NAME_STR == e->prop) {
-                               snprintf(buf, sizeof(buf), f, ELEMENT_STR(e)->value, ELEMENT_STR(e)->value);
+                               snprintf(buf, sizeof(buf), f, ELEMENT_STR(e)->value);
                        } else {
                                snprintf(buf, sizeof(buf), f, ELEMENT_STR(e)->value);
                        }
@@ -200,6 +207,8 @@ static void _get_condition(gpointer data, char **condition)
                        *condition = NULL;
                        return;
        }
+       if(b_value)
+               free(b_value);
 
        *condition = strdup(buf);
 
@@ -208,12 +217,12 @@ static void _get_condition(gpointer data, char **condition)
 
 char *_get_where_clause(ail_filter_h filter)
 {
-       char *c;
+       char *c = NULL;
        char w[AIL_SQL_QUERY_MAX_LEN] = {0,};
        c = NULL;
 
        GSList *l;
-       
+
        snprintf(w, AIL_SQL_QUERY_MAX_LEN, " WHERE ");
 
        for (l = filter->list; l; l = g_slist_next(l)) {
@@ -234,28 +243,26 @@ char *_get_where_clause(ail_filter_h filter)
                }
        }
 
-//     _D("where = %s", w);
-
        return strdup(w);
 }
 
 EXPORT_API ail_error_e ail_filter_count_appinfo(ail_filter_h filter, int *cnt)
 {
-       char q[AIL_SQL_QUERY_MAX_LEN];
-       char *w;
-       char *tmp_q;
-       char *l;
-       ail_cb_ret_e r;
-       sqlite3_stmt *stmt;
-       ail_appinfo_h ai;
+       char q[AIL_SQL_QUERY_MAX_LEN] = {0};
+       char *w = NULL;
+       char *tmp_q = NULL;
+       char *l = NULL;
+       sqlite3_stmt *stmt = NULL;
+       ail_appinfo_h ai = NULL;
        int filter_count = 0;
+       char *locale = NULL;
 
        retv_if(!cnt, AIL_ERROR_INVALID_PARAMETER);
 
-       if (db_open(DB_OPEN_RO) != AIL_ERROR_OK)
+       if (db_open_pkg_mgr(DB_OPEN_RO) != AIL_ERROR_OK)
                return AIL_ERROR_DB_FAILED;
 
-       snprintf(q, sizeof(q), "SELECT %s FROM %s", SQL_FLD_APP_INFO_WITH_LOCALNAME, SQL_TBL_APP_INFO_WITH_LOCALNAME);
+       snprintf(q, sizeof(q), "SELECT * FROM (SELECT %s FROM %s)", SQL_FLD_PKG_APP_INFO_FILTER, SQL_TBL_APP_INFO_FILTER);
 
        tmp_q = strdup(q);
        retv_if (NULL == tmp_q, AIL_ERROR_OUT_OF_MEMORY);
@@ -265,13 +272,26 @@ EXPORT_API ail_error_e ail_filter_count_appinfo(ail_filter_h filter, int *cnt)
                free(tmp_q);
                return AIL_ERROR_FAIL;
        }
-       snprintf(q, sizeof(q), tmp_q, l);
+       locale = (char*) calloc(strlen(l)+1,1);
+       if(locale == NULL) {
+               free(tmp_q);
+               free(l);
+               return AIL_ERROR_OUT_OF_MEMORY;
+       }
+       strncpy(locale ,l, 2);
+       strncat(locale,"-",1);
+       locale[3] = tolower(l[3]);
+       locale[4] = tolower(l[4]);
        free(l);
+
+       snprintf(q, sizeof(q), tmp_q, locale);
+       free(locale);
        free(tmp_q);
 
        if (filter && filter->list) {
                w = _get_where_clause(filter);
                retv_if (NULL == w, AIL_ERROR_FAIL);
+
                strncat(q, w, sizeof(q)-strlen(q)-1);
                q[sizeof(q)-1] = '\0';
                free(w);
@@ -287,8 +307,8 @@ EXPORT_API ail_error_e ail_filter_count_appinfo(ail_filter_h filter, int *cnt)
        ai = appinfo_create();
 
        appinfo_set_stmt(ai, stmt);
-       while (db_step(stmt) == AIL_ERROR_OK) {
 
+       while (db_step(stmt) == AIL_ERROR_OK) {
                if(_appinfo_check_installed_storage(ai) != AIL_ERROR_OK)
                        continue;
 
@@ -305,20 +325,21 @@ EXPORT_API ail_error_e ail_filter_count_appinfo(ail_filter_h filter, int *cnt)
 
 EXPORT_API ail_error_e ail_filter_list_appinfo_foreach(ail_filter_h filter, ail_list_appinfo_cb cb, void *user_data)
 {
-       char q[AIL_SQL_QUERY_MAX_LEN];
-       char *tmp_q;
-       char *w;
-       char *l;
+       char q[AIL_SQL_QUERY_MAX_LEN] = {0};
+       char *tmp_q = NULL;
+       char *w = NULL;
+       char *l = NULL;
        ail_cb_ret_e r;
-       sqlite3_stmt *stmt;
-       ail_appinfo_h ai;
+       sqlite3_stmt *stmt = NULL;
+       ail_appinfo_h ai = NULL;
+       char *locale = NULL;
 
        retv_if (NULL == cb, AIL_ERROR_INVALID_PARAMETER);
 
-       if (db_open(DB_OPEN_RO) != AIL_ERROR_OK)
+       if (db_open_pkg_mgr(DB_OPEN_RO) != AIL_ERROR_OK)
                return AIL_ERROR_DB_FAILED;
 
-       snprintf(q, sizeof(q), "SELECT %s FROM %s", SQL_FLD_APP_INFO_WITH_LOCALNAME, SQL_TBL_APP_INFO_WITH_LOCALNAME);
+       snprintf(q, sizeof(q), "SELECT * FROM (SELECT %s FROM %s)", SQL_FLD_PKG_APP_INFO_FILTER, SQL_TBL_APP_INFO_FILTER);
 
        tmp_q = strdup(q);
        retv_if (NULL == tmp_q, AIL_ERROR_OUT_OF_MEMORY);
@@ -328,8 +349,21 @@ EXPORT_API ail_error_e ail_filter_list_appinfo_foreach(ail_filter_h filter, ail_
                free(tmp_q);
                return AIL_ERROR_FAIL;
        }
-       snprintf(q, sizeof(q), tmp_q, l);
+
+       locale = (char*) calloc(strlen(l)+1,1);
+       if(locale == NULL) {
+               free(tmp_q);
+               free(l);
+               return AIL_ERROR_OUT_OF_MEMORY;
+       }
+       strncpy(locale ,l, 2);
+       strncat(locale,"-",1);
+       locale[3] = tolower(l[3]);
+       locale[4] = tolower(l[4]);
        free(l);
+
+       snprintf(q, sizeof(q), tmp_q, locale);
+       free(locale);
        free(tmp_q);
 
        if (filter && filter->list) {
@@ -337,15 +371,11 @@ EXPORT_API ail_error_e ail_filter_list_appinfo_foreach(ail_filter_h filter, ail_
                retv_if (NULL == w, AIL_ERROR_FAIL);
                strncat(q, w, sizeof(q)-strlen(q)-1);
                q[sizeof(q)-1] = '\0';
-               strncat(q, " order by app_info.package", sizeof(q)-strlen(q)-1);
-               q[sizeof(q)-1] = '\0';
                free(w);
        }
        else
                _D("No filter exists. All records are retreived");
 
-//     _D("Query = %s",q);
-
        if (db_prepare(q, &stmt) != AIL_ERROR_OK) {
                _E("db_prepare fail for query = %s",q);
                return AIL_ERROR_DB_FAILED;
@@ -355,7 +385,6 @@ EXPORT_API ail_error_e ail_filter_list_appinfo_foreach(ail_filter_h filter, ail_
 
        appinfo_set_stmt(ai, stmt);
        while (db_step(stmt) == AIL_ERROR_OK) {
-
                if(_appinfo_check_installed_storage(ai) != AIL_ERROR_OK)
                        continue;
 
@@ -363,10 +392,7 @@ EXPORT_API ail_error_e ail_filter_list_appinfo_foreach(ail_filter_h filter, ail_
                if (AIL_CB_RET_CANCEL == r)
                        break;
        }
-       appinfo_destroy(ai);
-
        db_finalize(stmt);
-
+       appinfo_destroy(ai);
        return AIL_ERROR_OK;
 }
-
index 760b88b..a542137 100755 (executable)
@@ -23,6 +23,7 @@
 
 #include <string.h>
 #include <stdlib.h>
+#include <ctype.h>
 #include <db-util.h>
 #include <vconf.h>
 #include "ail.h"
@@ -39,6 +40,7 @@
 #define MAX_QUERY_LEN  4096
 #define PKG_SD_PATH "/opt/storage/sdcard/app2sd/"
 #define QUERY_GET_LOCALNAME "select name from localname where package='%s' and locale='%s'"
+#define MAX_SIZE 80000
 
 struct ail_appinfo {
        char **values;
@@ -49,6 +51,144 @@ typedef struct _pkgmgr_locale_x {
        char *locale;
 } pkgmgr_locale_x;
 
+static char * __get_package(const char *appid);
+
+char* _get_icon_from_package_localized_info(const char *appid)
+{
+       if (db_open_pkg_mgr(DB_OPEN_RO) < 0) {
+               _E("pkg_mgr_db_open fail [%s]",appid);
+               return NULL;
+       }
+       sqlite3_stmt *stmt = NULL;
+       char *str = NULL;
+       char *icon = NULL;
+       char *package = NULL;
+       package = __get_package(appid);
+
+       char *query = sqlite3_mprintf("select package_localized_info.package_icon from package_localized_info where package_localized_info.package=%Q and package_localized_info.package_locale='No Locale'", package);
+       if (NULL == query){
+               _E("Memory allocation failed");
+               free(package);
+               return NULL;
+       }
+       free(package);
+
+       retv_if (db_prepare(query, &stmt) < 0, NULL);
+
+       do {
+               if (db_step(stmt) < 0){
+                       goto end;
+                       }
+               if (db_column_str(stmt, 0, &str) < 0)
+                       goto end;
+               if (str)
+                       icon = strdup(str);
+               else
+                       icon = NULL;
+
+
+       } while(0);
+
+end:
+       db_finalize(stmt);
+       sqlite3_free(query);
+       return icon;
+
+}
+
+char* _get_icon_from_package_app_localized_info(const char *appid)
+{
+       if (db_open_pkg_mgr(DB_OPEN_RO) < 0) {
+               _E("pkg_mgr_db_open fail [%s]",appid);
+               return NULL;
+       }
+       sqlite3_stmt *stmt = NULL;
+       char *str = NULL;
+       char *icon = NULL;
+
+
+       char *query = sqlite3_mprintf("select package_app_localized_info.app_icon from package_app_localized_info where package_app_localized_info.app_id=%Q and package_app_localized_info.app_locale='No Locale'", appid);
+       if (NULL == query){
+               _E("Memory allocation failed");
+               return NULL;
+       }
+
+       retv_if (db_prepare(query, &stmt) < 0, NULL);
+
+       do {
+               if (db_step(stmt) < 0){
+                       goto end;
+                       }
+               if (db_column_str(stmt, 0, &str) < 0)
+                       goto end;
+               if (str)
+                       icon = strdup(str);
+               else
+                       icon = NULL;
+
+
+       } while(0);
+
+end:
+       db_finalize(stmt);
+       sqlite3_free(query);
+       return icon;
+
+}
+
+char* _get_mimetype_from_package_app_app_svc(const char *appid)
+{
+
+       if (db_open_pkg_mgr(DB_OPEN_RO) < 0) {
+               _E("pkg_mgr_db_open fail [%s]",appid);
+               return NULL;
+       }
+       sqlite3_stmt *stmt = NULL;
+       int col = 0;
+       char *val = NULL;
+       char *ptr = NULL;
+       char *del = ";";
+       char tmp_mime[MAX_SIZE] = {0};
+       int len = 0;
+       char *mime = NULL;
+
+       char *query = sqlite3_mprintf("select package_app_app_svc.mime_type from package_app_app_svc where package_app_app_svc.app_id=%Q", appid);
+       if (NULL == query){
+               _E("Memory allocation failed");
+               return NULL;
+       }
+       retv_if (db_prepare(query, &stmt) < 0, NULL);
+
+       while (db_step(stmt) == AIL_ERROR_OK){
+               val = (char*)sqlite3_column_text(stmt, col);
+
+               if (!strlen(val) )
+                       continue;
+
+               strcat(tmp_mime, val);
+               if(strlen(tmp_mime))
+                       strcat(tmp_mime, del);
+       }
+
+       len = strlen(tmp_mime);
+       ptr = tmp_mime;
+       ptr[len -1] = '\0';
+
+       db_finalize(stmt);
+       sqlite3_free(query);
+       if(len >0){
+               mime = strdup(tmp_mime);
+               if(NULL == mime){
+                       _E("Memory Allocation Failed");
+                       return NULL;
+               }else{
+                       return mime;
+               }
+       }else{
+               return NULL;
+       }
+}
+
 
 /* get the first locale value*/
 static int __fallback_locale_cb(void *data, int ncols, char **coltxt, char **colname)
@@ -74,7 +214,11 @@ static int __check_app_locale_from_app_localized_info_by_exact(const char *appid
 {
        int result_query = -1;
 
-       char *query = sqlite3_mprintf("select exists(select locale from localname where package=%Q and locale=%Q)", appid, locale);
+       char *query = sqlite3_mprintf("select exists(select app_locale from package_app_localized_info where app_id=%Q and app_locale=%Q)", appid, locale);
+       if (NULL == query){
+               _E("Memory allocation failed");
+               return AIL_ERROR_OUT_OF_MEMORY;
+       }
 
        db_exec_sqlite_query(query, __check_validation_of_qurey_cb, (void *)&result_query);
        sqlite3_free(query);
@@ -85,11 +229,14 @@ static int __check_app_locale_from_app_localized_info_by_exact(const char *appid
 static int __check_app_locale_from_app_localized_info_by_fallback(const char *appid, const char *locale)
 {
        int result_query = -1;
-       char wildcard[2] = {'%','\0'};
        char lang[3] = {'\0'};
        strncpy(lang, locale, LANGUAGE_LENGTH);
 
-       char *query = sqlite3_mprintf("select exists(select locale from localname where package=%Q and locale like %Q%Q)", appid, lang, locale);
+       char *query = sqlite3_mprintf("select exists(select app_locale from package_app_localized_info where app_id=%Q and app_locale like %Q%Q)", appid, lang, locale);
+       if (NULL == query){
+               _E("Memory allocation failed");
+               return AIL_ERROR_OUT_OF_MEMORY;
+       }
 
        db_exec_sqlite_query(query, __check_validation_of_qurey_cb, (void *)&result_query);
        sqlite3_free(query);
@@ -109,10 +256,15 @@ static char* __get_app_locale_from_app_localized_info_by_fallback(const char *ap
                _E("Out of Memory!!!\n");
                return NULL;
        }
-       memset(info, NULL, sizeof(*info));
+       memset(info, 0, sizeof(*info));
 
        strncpy(lang, locale, 2);
-       char *query = sqlite3_mprintf("select locale from localname where package=%Q and locale like %Q%Q", appid, lang, wildcard);
+       char *query = sqlite3_mprintf("select app_locale from package_app_localized_info where app_id=%Q and app_locale like %Q%Q", appid, lang, wildcard);
+       if (NULL == query){
+               _E("Memory allocation failed");
+               free(info);
+               return NULL;
+       }
        db_exec_sqlite_query(query, __fallback_locale_cb, (void *)info);
        locale_new = info->locale;
        free(info);
@@ -129,7 +281,7 @@ static char* __convert_syslocale_to_manifest_locale(char *syslocale)
                return NULL;
        }
 
-       sprintf(locale, "%c%c_%c%c", syslocale[0], syslocale[1], toupper(syslocale[3]), toupper(syslocale[4]));
+       sprintf(locale, "%c%c-%c%c", syslocale[0], syslocale[1], tolower(syslocale[3]), tolower(syslocale[4]));
        return locale;
 }
 
@@ -145,7 +297,7 @@ static char* __get_app_locale_by_fallback(const char *appid, const char *sysloca
                return  strdup(DEFAULT_LOCALE);
        }
 
-       locale = __convert_syslocale_to_manifest_locale(syslocale);
+       locale = __convert_syslocale_to_manifest_locale((char*)syslocale);
 
        /*check exact matching */
        check_result = __check_app_locale_from_app_localized_info_by_exact(appid, locale);
@@ -175,9 +327,10 @@ static char* __get_app_locale_by_fallback(const char *appid, const char *sysloca
 
 static ail_error_e __retrieve_all_column(ail_appinfo_h ai)
 {
-       int i, j;
-       ail_error_e err;
-       char *col;
+       int i = 0;
+       int j = 0;
+       ail_error_e err = AIL_ERROR_OK;
+       char *col = NULL;
 
        retv_if(!ai, AIL_ERROR_INVALID_PARAMETER);
        retv_if(!ai->stmt, AIL_ERROR_INVALID_PARAMETER);
@@ -187,7 +340,7 @@ static ail_error_e __retrieve_all_column(ail_appinfo_h ai)
 
        for (i = 0; i < NUM_OF_PROP; i++) {
                err = db_column_str(ai->stmt, i, &col);
-               if (AIL_ERROR_OK != err) 
+               if (AIL_ERROR_OK != err)
                        break;
 
                if (!col) {
@@ -282,18 +435,25 @@ EXPORT_API ail_error_e ail_package_destroy_appinfo(ail_appinfo_h ai)
 
 EXPORT_API ail_error_e ail_destroy_appinfo(ail_appinfo_h ai)
 {
-       int i;
+       int i = 0;
 
        retv_if(!ai, AIL_ERROR_INVALID_PARAMETER);
        retv_if(!ai->values, AIL_ERROR_INVALID_PARAMETER);
 
        for (i = 0; i < NUM_OF_PROP; i++) {
-               if (strcmp(ai->values[i], AIL_EMPTY_STR) != 0) {
+               if ( ai->values[i] && strcmp(ai->values[i], AIL_EMPTY_STR) != 0){
                        free(ai->values[i]);
+                       ai->values[i] = NULL;
                }
        }
+       if(ai->values[E_AIL_PROP_MIMETYPE_STR]){
+               free((void*)ai->values[E_AIL_PROP_MIMETYPE_STR]);
+               ai->values[E_AIL_PROP_MIMETYPE_STR] = NULL;
+       }
+
+       if(ai->values)
+               free(ai->values);
 
-       free(ai->values);
        free(ai);
        db_close();
 
@@ -306,11 +466,178 @@ EXPORT_API ail_error_e ail_package_get_appinfo(const char *package, ail_appinfo_
        return ail_get_appinfo(package, ai);
 }
 
+static char * __get_package(const char *appid)
+{
+       retv_if(!appid, NULL);
+
+       sqlite3_stmt *stmt = NULL;
+       char *str = NULL;
+       char *package = NULL;
+       char *query = NULL;
+
+       query = sqlite3_mprintf("SELECT package_app_info.PACKAGE FROM package_app_info WHERE package_app_info.APP_ID=%Q", appid);
+       if (NULL == query){
+               _E("Memory allocation failed");
+               return NULL;
+       }
+
+       retv_if (db_prepare(query, &stmt) < 0, NULL);
+       do {
+               if (db_step(stmt) < 0)
+                       goto end;
+               if (db_column_str(stmt, 0, &str) < 0)
+                       goto end;
+               if (str)
+               {
+                       package = strdup(str);
+                       if (!package){
+                               _E("Memory allocation failed");
+                               return NULL;
+                       }
+               }
+               else
+                       package = NULL;
+
+       } while(0);
+
+end:
+       sqlite3_free(query);
+       db_finalize(stmt);
+       return package;
+
+}
+
+static ail_error_e __ail_get_appinfo_new_icon(const char *appid, ail_appinfo_h ai)
+{
+
+       char query[AIL_SQL_QUERY_MAX_LEN] = {0};
+       sqlite3_stmt *stmt = NULL;
+       char *val = NULL;
+       int ret = AIL_ERROR_OK;
+       char *package = NULL;
+       char *w = NULL;
+
+       retv_if(!appid, AIL_ERROR_INVALID_PARAMETER);
+       retv_if(!ai, AIL_ERROR_INVALID_PARAMETER);
+       package = __get_package(appid);
+
+
+       w = sqlite3_mprintf("package_localized_info.PACKAGE=%Q and package_localized_info.package_locale='No Locale'", package);
+       if (NULL == w){
+               _E("Memory allocation failed");
+               free(package);
+               return AIL_ERROR_OUT_OF_MEMORY;
+       }
+
+       free(package);
+
+       snprintf(query, AIL_SQL_QUERY_MAX_LEN, "SELECT %s FROM %s WHERE %s",SQL_FLD_PKG_APP_INFO_ICON, SQL_TBL_PKG_APP_INFO_ICON, w);
+
+       if (db_prepare(query, &stmt) != AIL_ERROR_OK) {
+               _E("db_prepare fail for query = %s",query);
+               ret =  AIL_ERROR_DB_FAILED;
+               goto end;
+       }
+       appinfo_set_stmt(ai, stmt);
+
+       if(ai->values[E_AIL_PROP_ICON_STR]){
+               free((void*)ai->values[E_AIL_PROP_ICON_STR]);
+               ai->values[E_AIL_PROP_ICON_STR] = NULL;
+       }
+
+       do{
+               if (db_step(stmt) < 0)
+                       break;
+               if (db_column_str(stmt, 0, &val) < 0)
+                       break;
+               if (strcmp(val, "(NULL)")){
+                       ai->values[E_AIL_PROP_ICON_STR] = strdup(val);
+                       if (!ai->values[E_AIL_PROP_ICON_STR]){
+                               _E("Memory allocation failed");
+                               return AIL_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else{
+                       ai->values[E_AIL_PROP_ICON_STR] = strdup(AIL_EMPTY_STR);
+               }
+       }while(0);
+
+       if (db_finalize(ai->stmt) != AIL_ERROR_OK){
+               ret =  AIL_ERROR_DB_FAILED;
+               goto end;
+       }
+end:
+       (ai)->stmt = NULL;
+       sqlite3_free(w);
+       return ret;
+}
+
+static ail_error_e __ail_get_appinfo_new_mimetype(const char *appid, ail_appinfo_h ai)
+{
+       char query[AIL_SQL_QUERY_MAX_LEN] = {0};
+       sqlite3_stmt *stmt = NULL;
+       int col = 0;
+       char *val = NULL;
+       char *del = ";" ;
+       int ret = AIL_ERROR_OK;
+
+       retv_if(!appid, AIL_ERROR_INVALID_PARAMETER);
+       retv_if(!ai, AIL_ERROR_INVALID_PARAMETER);
+
+       char *w = sqlite3_mprintf("package_app_app_svc.APP_ID=%Q", appid);
+       if (NULL == w){
+               _E("Memory allocation failed");
+               return AIL_ERROR_OUT_OF_MEMORY;
+       }
+
+       snprintf(query, AIL_SQL_QUERY_MAX_LEN, "SELECT %s FROM %s WHERE %s",SQL_FLD_PKG_APP_INFO_MIME, SQL_TBL_PKG_APP_INFO_SVC, w);
+       if (db_prepare(query, &stmt) != AIL_ERROR_OK) {
+               _E("db_prepare fail for query = %s",query);
+               ret =  AIL_ERROR_DB_FAILED;
+               goto end;
+       }
+
+       appinfo_set_stmt(ai, stmt);
+
+       if(ai->values[E_AIL_PROP_MIMETYPE_STR]){
+               free((void*)ai->values[E_AIL_PROP_MIMETYPE_STR]);
+               ai->values[E_AIL_PROP_MIMETYPE_STR] = NULL;
+       }
+       ai->values[E_AIL_PROP_MIMETYPE_STR] = (char*) calloc(MAX_SIZE,1);
+       if (NULL == ai->values[E_AIL_PROP_MIMETYPE_STR]){
+               _E("Memory allocation failed");
+               ret = AIL_ERROR_OUT_OF_MEMORY;
+               goto end;
+       }
+
+       while (db_step(stmt) == AIL_ERROR_OK){
+               val = (char*)sqlite3_column_text(stmt, col);
+
+               if (!strlen(val) )
+                       continue;
+
+               strcat(ai->values[E_AIL_PROP_MIMETYPE_STR], val);
+               if(strlen(ai->values[E_AIL_PROP_MIMETYPE_STR]))
+               strcat(ai->values[E_AIL_PROP_MIMETYPE_STR], del);
+       }
+
+       if (db_finalize(ai->stmt) != AIL_ERROR_OK){
+               ret =  AIL_ERROR_DB_FAILED;
+               goto end;
+       }
+
+end:
+       (ai)->stmt = NULL;
+       sqlite3_free(w);
+       return ret;
+}
+
 EXPORT_API ail_error_e ail_get_appinfo(const char *appid, ail_appinfo_h *ai)
 {
-       ail_error_e ret;
-       char query[AIL_SQL_QUERY_MAX_LEN];
+       ail_error_e ret = AIL_ERROR_OK;
+       char query[AIL_SQL_QUERY_MAX_LEN] = {0};
        sqlite3_stmt *stmt = NULL;
+       char *w = NULL;
 
        retv_if(!appid, AIL_ERROR_INVALID_PARAMETER);
        retv_if(!ai, AIL_ERROR_INVALID_PARAMETER);
@@ -318,12 +645,18 @@ EXPORT_API ail_error_e ail_get_appinfo(const char *appid, ail_appinfo_h *ai)
        *ai = appinfo_create();
        retv_if(!*ai, AIL_ERROR_OUT_OF_MEMORY);
 
-       char *w = sqlite3_mprintf("app_info.X_SLP_APPID=%Q", appid);
+       w = sqlite3_mprintf("PACKAGE=%Q", appid);
+       if (NULL == w){
+               _E("Memory allocation failed");
+               if (*ai)
+                       appinfo_destroy(*ai);
+               return AIL_ERROR_OUT_OF_MEMORY;
+       }
 
-       snprintf(query, sizeof(query), "SELECT %s FROM %s WHERE %s",SQL_FLD_APP_INFO, SQL_TBL_APP_INFO, w);
+       snprintf(query, AIL_SQL_QUERY_MAX_LEN, "SELECT * FROM (SELECT %s FROM %s) WHERE %s", SQL_FLD_PKG_APP_INFO_FILTER, SQL_TBL_APP_INFO_PKG, w);
 
        do {
-               ret = db_open(DB_OPEN_RO);
+               ret = db_open_pkg_mgr(DB_OPEN_RO);
                if (ret < 0) break;
 
                ret = db_prepare(query, &stmt);
@@ -357,19 +690,28 @@ EXPORT_API ail_error_e ail_get_appinfo(const char *appid, ail_appinfo_h *ai)
                break;
        } while(0);
 
-       if(ret != AIL_ERROR_OK)
+       sqlite3_free(w);
+       if(ret != AIL_ERROR_OK){
                appinfo_destroy(*ai);
+       }else{
+               if (!(strcmp((*ai)->values[E_AIL_PROP_ICON_STR], "(NULL)"))){
+                       ret = __ail_get_appinfo_new_icon(appid, *ai);
+                       if(ret != AIL_ERROR_OK)
+                               _E("icon not retrieved");
+               }
 
-       sqlite3_free(w);
+               ret = __ail_get_appinfo_new_mimetype(appid, *ai);
+               if(ret != AIL_ERROR_OK)
+                       _E("Mimetype not retrieved");
+       }
 
        return ret;
 }
 
-
 EXPORT_API ail_error_e ail_appinfo_get_bool(const ail_appinfo_h ai, const char *property, bool *value)
 {
-       ail_prop_bool_e prop;
-       int val;
+       ail_prop_bool_e prop = 0;
+       int index = 0;
 
        retv_if(!ai, AIL_ERROR_INVALID_PARAMETER);
        retv_if(!property, AIL_ERROR_INVALID_PARAMETER);
@@ -379,15 +721,16 @@ EXPORT_API ail_error_e ail_appinfo_get_bool(const ail_appinfo_h ai, const char *
 
        if (prop < E_AIL_PROP_BOOL_MIN || prop > E_AIL_PROP_BOOL_MAX)
                return AIL_ERROR_INVALID_PARAMETER;
-       
+
        if (ai->stmt) {
-               int index;
                index = sql_get_app_info_idx(prop);
                if (db_column_bool(ai->stmt, index, value) < 0)
                        return AIL_ERROR_DB_FAILED;
        } else {
-               val = atoi(ai->values[prop]);
-               *value = (val == 0? false : true);
+       if (strncmp(ai->values[prop], "true", strlen("true")) == 0 || strncmp(ai->values[prop], "True", strlen("True")) == 0 || strncmp(ai->values[prop], "TRUE", strlen("TRUE")) == 0)
+               *value = true;
+       else
+               *value = false;
        }
        return AIL_ERROR_OK;
 }
@@ -396,7 +739,8 @@ EXPORT_API ail_error_e ail_appinfo_get_bool(const ail_appinfo_h ai, const char *
 
 EXPORT_API ail_error_e ail_appinfo_get_int(const ail_appinfo_h ai, const char *property, int *value)
 {
-       ail_prop_int_e prop;
+       ail_prop_int_e prop = 0;
+       int index = 0;
 
        retv_if(!ai, AIL_ERROR_INVALID_PARAMETER);
        retv_if(!property, AIL_ERROR_INVALID_PARAMETER);
@@ -408,61 +752,91 @@ EXPORT_API ail_error_e ail_appinfo_get_int(const ail_appinfo_h ai, const char *p
                return AIL_ERROR_INVALID_PARAMETER;
 
        if (ai->stmt) {
-               int index; 
                index = sql_get_app_info_idx(prop);
-               if (db_column_int(ai->stmt, index, value) < 0)
+               if (db_column_int(ai->stmt, index, value) < 0){
                        return AIL_ERROR_DB_FAILED;
-       } else
+                       }
+       } else{
                *value = atoi(ai->values[prop]);
+       }
 
        return AIL_ERROR_OK;
 }
 
 char *appinfo_get_localname(const char *package, char *locale)
 {
-       if (db_open(DB_OPEN_RO) < 0) {
+       if (db_open_pkg_mgr(DB_OPEN_RO) < 0) {
                _E("db_open fail %s",package);
                return NULL;
        }
-       sqlite3_stmt *stmt;
+       sqlite3_stmt *stmt = NULL;
        char *str = NULL;
-       char *localname;
-       
-       char *query = sqlite3_mprintf("select name from localname where package=%Q and locale=%Q", package, locale);
+       char *localname = NULL;
+       char  del;
+
+       if(locale == NULL)
+       {
+               locale = strdup("No Locale");
+               if(locale == NULL)
+               {
+                       _E("Malloc failed!!");
+                       return NULL;
+               }
+       }
+
+       /*
+       Change locale format if it is not correct.
+       Example change 'ko_KR' to 'ko-kr'.
+       */
+       if(strncmp(locale,"No Locale",strlen("No Locale")))
+       {
+               del = locale[2];
+               if(del == '_')
+               {
+                       locale[2] = '-';
+                       locale[3] = tolower(locale[3]);
+                       locale[4] = tolower(locale[4]);
+               }
+       }
+
+       char *query = sqlite3_mprintf("select app_label from package_app_localized_info where app_id=%Q and app_locale=%Q", package, locale);
+       if (NULL == query){
+               _E("Memory allocation failed");
+               return NULL;
+       }
 
-//     _D("Query = %s",query);
        retv_if (db_prepare(query, &stmt) < 0, NULL);
 
        do {
-               if (db_step(stmt) < 0)
-                       break;
+               if (db_step(stmt) < 0){
+                       goto end;
+                       }
                if (db_column_str(stmt, 0, &str) < 0)
-                       break;
+                       goto end;
                if (str)
                        localname = strdup(str);
                else
                        localname = NULL;
 
-               db_finalize(stmt);
 
-               sqlite3_free(query);
-               return localname;
        } while(0);
 
+end:
        db_finalize(stmt);
-       return NULL;
+       sqlite3_free(query);
+       return localname;
 }
 
-
 EXPORT_API ail_error_e ail_appinfo_get_str(const ail_appinfo_h ai, const char *property, char **str)
 {
-       int index;
-       char *value;
-       char *pkg;
-       char *pkg_type;
-       char *locale, *localname;
-       ail_prop_str_e prop;
-       char *locale_new;
+       int index = 0;
+       char *value = NULL;
+       char *pkg = NULL;
+       char *pkg_type = NULL;
+       char *locale = NULL;
+       char *localname = NULL;
+       ail_prop_str_e prop = 0;
+       char *locale_new = NULL;
 
        retv_if(!ai, AIL_ERROR_INVALID_PARAMETER);
        retv_if(!property, AIL_ERROR_INVALID_PARAMETER);
@@ -473,75 +847,153 @@ EXPORT_API ail_error_e ail_appinfo_get_str(const ail_appinfo_h ai, const char *p
        if (prop < E_AIL_PROP_STR_MIN || prop > E_AIL_PROP_STR_MAX)
                return AIL_ERROR_INVALID_PARAMETER;
 
-       localname = NULL;
 
-       if (E_AIL_PROP_NAME_STR == prop) {
-               if (ai->stmt) {
-                       if (db_column_str(ai->stmt, E_AIL_PROP_X_SLP_PACKAGETYPE_STR, &pkg_type) < 0)
-                               return AIL_ERROR_DB_FAILED;
-                       if(pkg_type && (strcasecmp(pkg_type, "tpk") ==0))
-                       {
+       switch(prop){
+               case E_AIL_PROP_NAME_STR:
+                       if(ai->stmt){
+                               if (db_column_str(ai->stmt, E_AIL_PROP_X_SLP_PACKAGETYPE_STR, &pkg_type) < 0)
+                                       return AIL_ERROR_DB_FAILED;
+                               if(pkg_type && (strcasecmp(pkg_type, "tpk") ==0))
+                               {
+                                       locale = sql_get_locale();
+                                       retv_if (NULL == locale, AIL_ERROR_FAIL);
+
+                                       if (db_column_str(ai->stmt, E_AIL_PROP_PACKAGE_STR, &pkg) < 0){
+                                               free(locale);
+                                               return AIL_ERROR_DB_FAILED;
+                                       }
+                                       if (pkg == NULL){
+                                               free(locale);
+                                               return AIL_ERROR_DB_FAILED;
+                                       }
+                                       locale_new = __get_app_locale_by_fallback(pkg, locale);
+                                       localname = (char *)appinfo_get_localname(pkg,locale_new);
+                                       free(locale);
+                                       free(locale_new);
+                               } else {
+                                       if (db_column_str(ai->stmt, E_AIL_PROP_NAME_STR, &localname) < 0)
+                                               return AIL_ERROR_DB_FAILED;
+                                       if(!localname){
+                                               if (db_column_str(ai->stmt, E_AIL_PROP_PACKAGE_STR, &pkg) < 0){
+                                                       return AIL_ERROR_DB_FAILED;
+                                               }
+                                               if (pkg == NULL){
+                                                       return AIL_ERROR_DB_FAILED;
+                                               }
+                                               locale_new = strdup(DEFAULT_LOCALE);
+                                               if(locale_new == NULL){
+                                                       _E("STRDUP: OUT OF MEMORY");
+                                                       return AIL_ERROR_OUT_OF_MEMORY;
+                                               }
+                                               localname = (char*)appinfo_get_localname(pkg,locale_new);
+                                               free(locale_new);
+                                       }
+                               }
+                       }else{
+                               pkg_type = ai->values[E_AIL_PROP_X_SLP_PACKAGETYPE_STR];
+                               pkg = ai->values[E_AIL_PROP_PACKAGE_STR];
+                               retv_if (NULL == pkg, AIL_ERROR_FAIL);
+
                                locale = sql_get_locale();
                                retv_if (NULL == locale, AIL_ERROR_FAIL);
 
-                               if (db_column_str(ai->stmt, E_AIL_PROP_PACKAGE_STR, &pkg) < 0){
+                               if(pkg_type && (strcasecmp(pkg_type, "tpk") ==0))
+                               {
+                                       locale_new = __get_app_locale_by_fallback(pkg, locale);
+                                       localname = (char *)appinfo_get_localname(pkg,locale_new);
                                        free(locale);
-                                       return AIL_ERROR_DB_FAILED;
-                               }
-                               if (pkg == NULL){
+                                       free(locale_new);
+                               } else {
+                                       localname = (char *)appinfo_get_localname(pkg,locale);
                                        free(locale);
-                                       return AIL_ERROR_DB_FAILED;
+                                       if(!localname){
+                                               localname = (char*) appinfo_get_localname(pkg,DEFAULT_LOCALE);
+                                       }
                                }
 
-                               locale_new = __get_app_locale_by_fallback(pkg, locale);
-                               localname = (char *)appinfo_get_localname(pkg,locale_new);
-                               free(locale);
-                               free(locale_new);
-                       } else {
-                               if (db_column_str(ai->stmt, SQL_LOCALNAME_IDX, &localname) < 0)
-                                       return AIL_ERROR_DB_FAILED;
                        }
-               } else {
-                       pkg_type = ai->values[E_AIL_PROP_X_SLP_PACKAGETYPE_STR];
-                       pkg = ai->values[E_AIL_PROP_PACKAGE_STR];
-                       retv_if (NULL == pkg, AIL_ERROR_FAIL);
-
-                       locale = sql_get_locale();
-                       retv_if (NULL == locale, AIL_ERROR_FAIL);
-
-                       if(pkg_type && (strcasecmp(pkg_type, "tpk") ==0))
-                       {
-                               locale_new = __get_app_locale_by_fallback(pkg, locale);
-                               localname = (char *)appinfo_get_localname(pkg,locale_new);
-                               free(locale);
-                               free(locale_new);
-                       } else {
-                               localname = (char *)appinfo_get_localname(pkg,locale);
-                               free(locale);
+
+                       if (localname) {
+                               if (!ai->stmt) {
+                                       if (ai->values) {
+                                               if (strcmp(ai->values[prop], AIL_EMPTY_STR) != 0)
+                                                       free(ai->values[prop]);
+                                               ai->values[prop] = localname;
+                                       }
+                               }
+                               *str = localname;
+                               return AIL_ERROR_OK;
                        }
-               }
 
-               if (localname) {
-                       if (!ai->stmt) {
-                               if (ai->values) {
-                                       if (strcmp(ai->values[prop], AIL_EMPTY_STR) != 0)
-                                               free(ai->values[prop]);
-                                       ai->values[prop] = localname;
+                       break;
+
+               case E_AIL_PROP_ICON_STR:
+                       if(ai->stmt){
+                               index = sql_get_app_info_idx(prop);
+                               if (db_column_str(ai->stmt, index, &value) < 0){
+                                       return AIL_ERROR_DB_FAILED;
+                               }
+                               if((value == NULL) || (strcmp(value,AIL_EMPTY_STR) == 0)){
+                                       if (db_column_str(ai->stmt, E_AIL_PROP_PACKAGE_STR, &pkg) < 0){
+                                               free(locale);
+                                               return AIL_ERROR_DB_FAILED;
+                                       }
+                                       if (pkg == NULL){
+                                               free(locale);
+                                               return AIL_ERROR_DB_FAILED;
+                                       }
+                                       value =  _get_icon_from_package_app_localized_info(pkg);
+                                       if((value == NULL) || (strcmp(value,AIL_EMPTY_STR) == 0)){
+                                               if(value != NULL){
+                                                       free(value);
+                                                       value = NULL;
+                                                       }
+                                               value = _get_icon_from_package_localized_info(pkg);
+                                       }
                                }
+                               *str = value;
+
+                       }else{
+                               *str = ai->values[prop];
                        }
-                       *str = localname;
-                       return AIL_ERROR_OK;
-               }
-       }
+                       break;
 
-       if (ai->stmt) {
-               index = sql_get_app_info_idx(prop);
-               if (db_column_str(ai->stmt, index, &value) < 0){
-                       return AIL_ERROR_DB_FAILED;
+               case E_AIL_PROP_MIMETYPE_STR:
+                       if(ai->stmt){
+                               index = sql_get_app_info_idx(prop);
+                               if (db_column_str(ai->stmt, index, &value) < 0){
+                                       return AIL_ERROR_DB_FAILED;
+                               }
+                               if ((value == NULL) || (strcmp(value,AIL_EMPTY_STR) == 0)){
+                                       if (db_column_str(ai->stmt, E_AIL_PROP_PACKAGE_STR, &pkg) < 0){
+                                               free(locale);
+                                               return AIL_ERROR_DB_FAILED;
+                                       }
+                                       if (pkg == NULL){
+                                               free(locale);
+                                               return AIL_ERROR_DB_FAILED;
+                                       }
+                                       value =  _get_mimetype_from_package_app_app_svc(pkg);
+                               }
+                               *str = value;
+
+                       }else{
+                               *str = ai->values[prop];
+                       }
+                       break;
+
+               default:
+                       if(ai->stmt){
+                               index = sql_get_app_info_idx(prop);
+                               if (db_column_str(ai->stmt, index, &value) < 0){
+                                       return AIL_ERROR_DB_FAILED;
+                               }
+                               *str = value;
+                       }else{
+                               *str = ai->values[prop];
+
+                       }
                }
-               *str = value;
-       } else
-               *str = ai->values[prop];
 
        return AIL_ERROR_OK;
 }
index 9270334..c4326c8 100755 (executable)
@@ -31,5 +31,6 @@
 ail_appinfo_h appinfo_create(void);
 void appinfo_destroy(ail_appinfo_h ai);
 void appinfo_set_stmt(ail_appinfo_h ai, sqlite3_stmt *stmt);
+int _appinfo_check_installed_storage(ail_appinfo_h ai);
 
 #endif  /* __AIL_PACKAGE_H__ */
index 327e5fb..af4d1fe 100755 (executable)
@@ -94,6 +94,7 @@ enum {
 
 #define AIL_SQL_QUERY_MAX_LEN  2048
 #define APP_INFO_DB "/opt/dbspace/.app_info.db"
+#define PKGMGR_PARSER_DB "/opt/dbspace/.pkgmgr_parser.db"
 
 #define ELEMENT_TYPE(e, t) do { \
        if(e->prop >= E_AIL_PROP_STR_MIN && e->prop <= E_AIL_PROP_STR_MAX) t= (int)VAL_TYPE_STR; \
index bd24355..877792c 100755 (executable)
 #include "ail_private.h"
 
 static const char *filter[] = {
-       "app_info.PACKAGE='%s'",
-       "app_info.EXEC='%s'",
-       "((localname.name is NULL and app_info.name like '%%%s%%') or (localname.name like '%%%s%%'))",
-       "app_info.TYPE like '%%%s%%'",
-       "app_info.ICON='%s'",
-       "app_info.CATEGORIES like '%%%s%%'",
-       "app_info.VERSION='%s'",
-       "app_info.MIMETYPE like '%%%s%%'",
-       "app_info.X_SLP_SERVICE like '%%%s%%'",
-       "app_info.X_SLP_PACKAGETYPE='%s'",
-       "app_info.X_SLP_PACKAGECATEGORIES like '%%%s%%'",
-       "app_info.X_SLP_PACKAGEID='%s'",
-       "app_info.X_SLP_URI='%s'",
-       "app_info.X_SLP_SVC like '%%%s%%'",
-       "app_info.X_SLP_EXE_PATH='%s'",
-       "app_info.X_SLP_APPID='%s'",
-       "app_info.X_SLP_PKGID='%s'",
-       "app_info.X_SLP_DOMAIN='%s'",
-       "app_info.X_SLP_SUBMODEMAINID='%s'",
-       "app_info.X_SLP_INSTALLEDSTORAGE='%s'",
-       "app_info.X_SLP_BASELAYOUTWIDTH=%d",
-       "app_info.X_SLP_INSTALLEDTIME=%d",
-       "app_info.NODISPLAY=%d",
-       "app_info.X_SLP_TASKMANAGE=%d",
-       "app_info.X_SLP_MULTIPLE=%d",
-       "app_info.X_SLP_REMOVABLE=%d",
-       "app_info.X_SLP_ISHORIZONTALSCALE=%d",
-       "app_info.X_SLP_ENABLED=%d",
-       "app_info.X_SLP_SUBMODE=%d",
+       "PACKAGE='%s'",
+       "EXEC='%s'",
+       "NAME like '%%%s%%'",
+       "TYPE like '%%%s%%'",
+       "ICON='%s'",
+       "CATEGORIES like '%%%s%%'",
+       "VERSION='%s'",
+       "MIMETYPE like '%%%s%%'",
+       "X_SLP_SERVICE like '%%%s%%'",
+       "X_SLP_PACKAGETYPE='%s'",
+       "X_SLP_PACKAGECATEGORIES like '%%%s%%'",
+       "X_SLP_PACKAGEID='%s'",
+       "X_SLP_URI='%s'",
+       "X_SLP_SVC like '%%%s%%'",
+       "X_SLP_EXE_PATH='%s'",
+       "X_SLP_APPID='%s'",
+       "X_SLP_PKGID='%s'",
+       "X_SLP_DOMAIN='%s'",
+       "X_SLP_SUBMODEMAINID='%s'",
+       "X_SLP_INSTALLEDSTORAGE='%s'",
+       "X_SLP_BASELAYOUTWIDTH=%d",
+       "X_SLP_INSTALLEDTIME=%d",
+       "NODISPLAY like '%s'",
+       "X_SLP_TASKMANAGE like '%s'",
+       "X_SLP_MULTIPLE like '%s'",
+       "X_SLP_REMOVABLE like '%s'",
+       "X_SLP_ISHORIZONTALSCALE=%d",
+       "X_SLP_ENABLED like '%s'",
+       "X_SLP_SUBMODE like '%s'",
        NULL,
 };
 
index 37eb0ee..f7521c9 100755 (executable)
 #include "ail.h"
 
 #define SQL_TBL_APP_INFO "app_info"
+#define SQL_TBL_PKG_APP_INFO "package_app_info,package_app_localized_info,package_info"
+#define SQL_TBL_PKG_APP_INFO_SVC "package_app_app_svc"
+#define SQL_TBL_PKG_APP_INFO_ICON "package_localized_info"
 #define SQL_TBL_APP_INFO_WITH_LOCALNAME "app_info LEFT OUTER JOIN localname " \
                                        "ON app_info.package=localname.package " \
                                        "and locale='%s'"
 
+#define SQL_TBL_APP_INFO_FILTER "package_info a LEFT OUTER JOIN package_app_info b ON a.package = b.package LEFT OUTER JOIN package_app_localized_info c ON c.app_id = b.app_id and c.app_locale='%s' LEFT OUTER JOIN package_app_app_control d ON d.app_id = b.app_id"
+
+#define SQL_TBL_APP_INFO_PKG "package_info a LEFT OUTER JOIN package_app_info b ON a.package = b.package LEFT OUTER JOIN package_app_localized_info c ON c.app_id = b.app_id and c.app_locale='No Locale' LEFT OUTER JOIN package_app_app_control d ON d.app_id = b.app_id"
+
+#define SQL_TBL_PKG_APP_INFO_WITH_LOCALNAME "package_app_info LEFT OUTER JOIN package_app_localized_info" \
+                                       "ON package_app_info.app_id=package_app_localized_info.app_id" \
+                                       "and package_app_localized_info.locale='%s'" \
+                                       "LEFT OUTER JOIN package_info" \
+                                       "ON package_app_info.package=package_info.package"
+
 #define SQL_FLD_APP_INFO "app_info.PACKAGE," \
                        "app_info.EXEC," \
                        "app_info.NAME," \
                        "app_info.X_SLP_ENABLED," \
                        "app_info.X_SLP_SUBMODE" \
 
+#define SQL_FLD_PKG_APP_INFO_FILTER "b.app_id as package," \
+                       "b.app_exec as exec," \
+                       "c.app_label as name," \
+                       "'Application' as type," \
+                       "c.app_icon as icon," \
+                       "'' as categories," \
+                       "a.package_version as version," \
+                       "'' as mimetype," \
+                       "'' as x_slp_service," \
+                       "a.package_type as x_slp_packagetype," \
+                       "'' as x_slp_package_categories," \
+                       "b.app_id as x_slp_packageid," \
+                       "'' as x_slp_uri," \
+                       "d.app_control as x_slp_svc," \
+                       "b.app_exec as x_slp_exe_path," \
+                       "b.app_id as x_slp_appid," \
+                       "b.package as x_slp_pkgid," \
+                       "'' as x_slp_domain," \
+                       "b.app_submode_mainid as x_slp_submodemainid," \
+                       "b.app_installed_storage as x_slp_installedstorage," \
+                       "0 as x_slp_baselayoutwidth," \
+                       "a.installed_time as x_slp_installedtime," \
+                       "b.app_nodisplay as nodisplay," \
+                       "b.app_taskmanage as x_slp_taskmanage," \
+                       "b.app_multiple as x_slp_muliple," \
+                       "a.package_removable as x_slp_removable," \
+                       "0 as x_slp_ishorizontalscale," \
+                       "b.app_enabled as x_slp_enabled," \
+                       "b.app_submode as x_slp_submode" \
+
+#define SQL_FLD_PKG_APP_INFO "package_app_info.APP_ID," \
+                       "package_app_info.APP_EXEC," \
+                       "package_app_localized_info.APP_LABEL," \
+                       "package_app_info.APP_SUBMODE_MAINID," \
+                       "package_app_localized_info.APP_ICON," \
+                       "package_app_info.APP_SUBMODE_MAINID," \
+                       "package_info.PACKAGE_VERSION," \
+                       "package_app_info.APP_SUBMODE_MAINID," \
+                       "package_app_info.APP_SUBMODE_MAINID," \
+                       "package_info.PACKAGE_TYPE," \
+                       "package_app_info.APP_SUBMODE_MAINID," \
+                       "package_app_info.APP_ID," \
+                       "package_app_info.APP_SUBMODE_MAINID," \
+                       "package_app_info.APP_SUBMODE_MAINID," \
+                       "package_app_info.APP_EXEC," \
+                       "package_app_info.APP_ID," \
+                       "package_app_info.PACKAGE," \
+                       "package_app_info.APP_SUBMODE_MAINID," \
+                       "package_app_info.APP_SUBMODE_MAINID," \
+                       "package_app_info.APP_INSTALLED_STORAGE," \
+                       "package_app_info.APP_SUBMODE_MAINID," \
+                       "package_info.INSTALLED_TIME," \
+                       "package_app_info.APP_NODISPLAY," \
+                       "package_app_info.APP_TASKMANAGE," \
+                       "package_app_info.APP_MULTIPLE," \
+                       "package_info.PACKAGE_REMOVABLE," \
+                       "package_app_info.APP_SUBMODE_MAINID," \
+                       "package_app_info.APP_ENABLED," \
+                       "package_app_info.APP_SUBMODE" \
+
+#define FILTER_QUERY_LIST_PACKAGE_APP_INFO     "select DISTINCT package_info.package " \
+                               "from package_info LEFT OUTER JOIN package_localized_info " \
+                               "ON package_info.package=package_localized_info.package " \
+                               "and package_localized_info.package_locale='%s'"
+
+#define SQL_FLD_PKG_APP_INFO_MIME "package_app_app_svc.MIME_TYPE" \
+
+#define SQL_FLD_PKG_APP_INFO_ICON "package_localized_info.PACKAGE_ICON" \
+
+#define SQL_FLD_PKG_APP_INFO_SVC "package_app_app_svc.OPERATION," \
+                                                                        "package_app_app_svc.URI_SCHEME," \
+                                                                        "package_app_app_svc.MIME_TYPE," \
+                                                                        "package_app_app_svc.SUBAPP_NAME" \
+
 
 #define SQL_FLD_APP_INFO_WITH_LOCALNAME SQL_FLD_APP_INFO",""localname.name"
 #define SQL_LOCALNAME_IDX NUM_OF_PROP + 0
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..cc571d0
--- /dev/null
@@ -0,0 +1,17 @@
+#AIL init DB build script
+
+SET(AILTEST ail_test)
+SET(SRCS src/ail_test.c)
+
+pkg_check_modules(AILTEST_PKGS REQUIRED vconf dlog db-util sqlite3)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src)
+
+STRING(REPLACE ";" " " EXTRA_CFLAGS "${AILTEST_PKGS_CFLAGS}")
+
+ADD_EXECUTABLE(${AILTEST} ${SRCS})
+TARGET_LINK_LIBRARIES(${AILTEST} ${LIBNAME} ${AILTEST_PKGS_LIBRARIES})
+SET_TARGET_PROPERTIES(${AILTEST} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS}")
+SET_TARGET_PROPERTIES(${AILTEST} PROPERTIES SKIP_BUILD_RPATH true)
+
+INSTALL(TARGETS ${AILTEST} DESTINATION ${BINDIR})
diff --git a/test/src/ail_test.c b/test/src/ail_test.c
new file mode 100644 (file)
index 0000000..63e5b80
--- /dev/null
@@ -0,0 +1,783 @@
+/*
+ * ail
+ *
+ * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <fcntl.h>
+
+#include <ail.h>
+#include "ail_private.h"
+
+struct _ail_map_t {
+       int prop;
+       const char *property;
+};
+
+
+
+static ail_cb_ret_e appinfo_func(const ail_appinfo_h appinfo, void *user_data)
+{
+       char *rs = NULL;
+       ail_cb_ret_e ret = AIL_CB_RET_CONTINUE;
+
+       ret = AIL_CB_RET_CONTINUE;
+
+       ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &rs);
+       printf("%s|", rs);
+       printf("\n");
+       return ret;
+}
+
+int main(int argc, char** argv)
+{
+       ail_error_e ret = AIL_ERROR_OK;
+       ail_appinfo_h handle;
+       ail_filter_h filter;
+       int i;
+       int retval;
+
+       int ivalue = -1;
+       bool bvalue = false;
+       char *svalue = NULL;
+       char *appid=NULL;
+       char line[256] = {0,};
+
+       FILE *fp = NULL;
+
+       if (argc != 3){
+               fprintf(stdout, "Usage: ail_test <api_type> <file_name>\n");
+               fprintf(stdout, "api_type : 1 for get_appinfo APIs, 2 for filter APIs\n");
+               fprintf(stdout,"file_name: file containing list of APPs\n");
+               return -1;
+       }
+
+       fp = fopen(argv[2], "r");
+       if (!fp){
+               fprintf(stderr, "Unable to file containing app-id list\n");
+               return -1;
+       }
+
+
+       while (fgets(line, sizeof(line), fp)) {
+               appid = line;
+               line[strlen(appid)-1] = '\0';
+
+               switch(atoi(argv[1])){
+               case 1:
+                       /*****************ail_get_appinfo start******************/
+                       fprintf(stdout, "Test ail_get_appinfo Begin for appid=%s\n",appid);
+                       /*****************ail_get_appinfo_new end******************/
+
+                       ret = ail_get_appinfo(appid, &handle);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_get_appinfo failed\n");
+                               return AIL_ERROR_FAIL;
+                       }else{
+                               fprintf(stdout, "Test ail_get_appinfo Pass\n");
+                       }
+                       fprintf(stdout, "Test ail_get_appinfo End\n");
+
+                       ret = ail_appinfo_get_int(handle, AIL_PROP_X_SLP_INSTALLEDTIME_INT, &ivalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_int failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_X_SLP_INSTALLEDTIME_INT [%s] : %d\n", appid, ivalue);
+
+                       ret = ail_appinfo_get_str(handle, AIL_PROP_NAME_STR, &svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_NAME_STR[%s] : %s\n", appid, svalue);
+
+                       ret = ail_appinfo_get_str(handle, AIL_PROP_PACKAGE_STR, &svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_PACKAGE_STR [%s] : %s\n", appid, svalue);
+
+                       ret = ail_appinfo_get_str(handle, AIL_PROP_EXEC_STR, &svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_EXEC_STR [%s] : %s\n", appid, svalue);
+
+                       ret = ail_appinfo_get_str(handle, AIL_PROP_TYPE_STR, &svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_TYPE_STR [%s] : %s\n", appid, svalue);
+
+                       ret = ail_appinfo_get_str(handle, AIL_PROP_ICON_STR, &svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_ICON_STR [%s] : %s\n", appid, svalue);
+
+                       ret = ail_appinfo_get_str(handle, AIL_PROP_VERSION_STR, &svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_VERSION_STR [%s] : %s\n", appid, svalue);
+
+                       ret = ail_appinfo_get_str(handle, AIL_PROP_MIMETYPE_STR, &svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_MIMETYPE_STR Type [%s] : %s\n", appid, svalue);
+
+                       ret = ail_appinfo_get_str(handle, AIL_PROP_X_SLP_SERVICE_STR, &svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_X_SLP_SERVICE_STR [%s] : %s\n", appid, svalue);
+
+                       ret = ail_appinfo_get_str(handle, AIL_PROP_X_SLP_PACKAGETYPE_STR, &svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_X_SLP_PACKAGECATEGORIES_STR [%s] : %s\n", appid, svalue);
+
+                       ret = ail_appinfo_get_str(handle, AIL_PROP_X_SLP_PACKAGECATEGORIES_STR, &svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_X_SLP_PACKAGECATEGORIES_STR [%s] : %s\n", appid, svalue);
+
+                       ret = ail_appinfo_get_str(handle, AIL_PROP_X_SLP_PACKAGEID_STR, &svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_X_SLP_PACKAGEID_STR [%s] : %s\n", appid, svalue);
+
+                       ret = ail_appinfo_get_str(handle, AIL_PROP_X_SLP_SVC_STR, &svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_X_SLP_SVC_STR [%s] : %s\n", appid, svalue);
+
+                       ret = ail_appinfo_get_str(handle, AIL_PROP_X_SLP_EXE_PATH, &svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_X_SLP_EXE_PATH [%s] : %s\n", appid, svalue);
+
+                       ret = ail_appinfo_get_str(handle, AIL_PROP_X_SLP_APPID_STR, &svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_X_SLP_APPID_STR [%s] : %s\n", appid, svalue);
+
+                       ret = ail_appinfo_get_str(handle, AIL_PROP_X_SLP_PKGID_STR, &svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_X_SLP_PKGID_STR [%s] : %s\n", appid, svalue);
+
+                       ret = ail_appinfo_get_str(handle, AIL_PROP_X_SLP_DOMAIN_STR, &svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_X_SLP_DOMAIN_STR [%s] : %s\n", appid, svalue);
+
+                       ret = ail_appinfo_get_str(handle, AIL_PROP_X_SLP_SUBMODEMAINID_STR, &svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_X_SLP_SUBMODEMAINID_STR, [%s] : %s\n", appid, svalue);
+
+                       ret = ail_appinfo_get_str(handle, AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR, &svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR [%s] : %s\n", appid, svalue);
+
+                       ret = ail_appinfo_get_bool(handle, AIL_PROP_X_SLP_TASKMANAGE_BOOL, &bvalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_X_SLP_TASKMANAGE_BOOL [%s] : %d\n", appid, bvalue);
+
+                       ret = ail_appinfo_get_bool(handle, AIL_PROP_X_SLP_MULTIPLE_BOOL, &bvalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_X_SLP_MULTIPLE_BOOL [%s] : %d\n", appid, bvalue);
+
+                       ret = ail_appinfo_get_bool(handle, AIL_PROP_X_SLP_REMOVABLE_BOOL, &bvalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_X_SLP_REMOVABLE_BOOL [%s] : %d\n", appid, bvalue);
+
+                       ret = ail_appinfo_get_bool(handle, AIL_PROP_X_SLP_SUBMODE_BOOL, &bvalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_X_SLP_SUBMODE_BOOL [%s] : %d\n", appid, bvalue);
+
+                       ret = ail_appinfo_get_bool(handle, AIL_PROP_X_SLP_ISHORIZONTALSCALE_BOOL, &bvalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_X_SLP_ISHORIZONTALSCALE_BOOL [%s] : %d\n", appid, bvalue);
+
+                       ret = ail_appinfo_get_bool(handle, AIL_PROP_X_SLP_ENABLED_BOOL, &bvalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_bool failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_X_SLP_ENABLED_BOOL [%s] : %d\n", appid, bvalue);
+
+                       ret = ail_appinfo_get_int(handle, AIL_PROP_X_SLP_TEMP_INT, &ivalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_int failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_X_SLP_TEMP_INT [%s] : %d\n", appid, ivalue);
+                       ail_destroy_appinfo(handle);
+                       break;
+               case 2:
+                               ret = ail_get_appinfo(appid, &handle);
+                               if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_get_appinfo failed\n");
+                               return AIL_ERROR_FAIL;
+                       }else{
+                               fprintf(stdout, "Test ail_get_appinfo Pass\n");
+                       }
+
+                       ret = ail_filter_new(&filter);
+                        if (ret != AIL_ERROR_OK) {
+                            return -1;
+                        }
+
+
+                       ret = ail_appinfo_get_int(handle, AIL_PROP_X_SLP_INSTALLEDTIME_INT, &ivalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_int failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_X_SLP_INSTALLEDTIME_INT [%s] : %d\n", appid, ivalue);
+                       ret = ail_filter_add_int(filter, AIL_PROP_X_SLP_INSTALLEDTIME_INT, ivalue);
+                       if (ret != AIL_ERROR_OK) {
+                               return -1;
+                       }
+
+                       ret = ail_filter_list_appinfo_foreach(filter, appinfo_func, (void *)&i);
+                        if (ret != AIL_ERROR_OK){
+                               return -1;
+                       }
+                       ail_filter_destroy(filter);
+                       ret = ail_filter_new(&filter);
+                        if (ret != AIL_ERROR_OK) {
+                            return -1;
+                        }
+
+
+                       ret = ail_appinfo_get_str(handle, AIL_PROP_PACKAGE_STR, &svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_PACKAGE_STR [%s] : %s\n", appid, svalue);
+                       ret = ail_filter_add_str(filter, AIL_PROP_PACKAGE_STR, svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               return -1;
+                       }
+
+                       ret = ail_filter_list_appinfo_foreach(filter, appinfo_func, (void *)&i);
+                        if (ret != AIL_ERROR_OK){
+                               return -1;
+                       }
+                       ail_filter_destroy(filter);
+                       ret = ail_filter_new(&filter);
+                        if (ret != AIL_ERROR_OK) {
+                            return -1;
+                        }
+
+/*                     ret = ail_appinfo_get_str(handle, AIL_PROP_EXEC_STR, &svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_EXEC_STR [%s] : %s\n", appid, svalue);
+                       ret = ail_filter_add_str(filter, AIL_PROP_EXEC_STR, svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               return -1;
+                       }
+
+                       ret = ail_filter_list_appinfo_foreach(filter, appinfo_func, (void *)&i);
+                        if (ret != AIL_ERROR_OK){
+                               return -1;
+                       }
+                       ail_filter_destroy(filter);
+                       ret = ail_filter_new(&filter);
+                        if (ret != AIL_ERROR_OK) {
+                            return -1;
+                        }
+
+                       ret = ail_appinfo_get_str(handle, AIL_PROP_TYPE_STR, &svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_TYPE_STR [%s] : %s\n", appid, svalue);
+                       ret = ail_filter_add_str(filter, AIL_PROP_TYPE_STR, svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               return -1;
+                       }
+
+                       ret = ail_filter_list_appinfo_foreach(filter, appinfo_func, (void *)&i);
+                       if (ret != AIL_ERROR_OK){
+                               return -1;
+                       }
+                       ail_filter_destroy(filter);
+                       ret = ail_filter_new(&filter);
+                        if (ret != AIL_ERROR_OK) {
+                            return -1;
+                       }*/
+       /*              ret = ail_appinfo_get_str(handle, AIL_PROP_ICON_STR, &svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_ICON_STR [%s] : %s\n", appid, svalue);
+                       ret = ail_filter_add_str(filter, AIL_PROP_ICON_STR, svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               return -1;
+                       }
+
+                       ret = ail_filter_list_appinfo_foreach(filter, appinfo_func, (void *)&i);
+                       if (ret != AIL_ERROR_OK){
+                               return -1;
+                       }
+                       ail_filter_destroy(filter); */
+       /*              ret = ail_filter_new(&filter);
+                        if (ret != AIL_ERROR_OK) {
+                            return -1;
+                        }
+                       ret = ail_appinfo_get_str(handle, AIL_PROP_VERSION_STR, &svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_VERSION_STR [%s] : %s\n", appid, svalue);
+                       ret = ail_filter_add_str(filter, AIL_PROP_VERSION_STR, svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               return -1;
+                       }
+
+                       ret = ail_filter_list_appinfo_foreach(filter, appinfo_func, (void *)&i);
+                       if (ret != AIL_ERROR_OK){
+                               return -1;
+                       }
+                       ail_filter_destroy(filter);
+                       ret = ail_filter_new(&filter);
+                        if (ret != AIL_ERROR_OK) {
+                            return -1;
+                        }
+
+                       ret = ail_appinfo_get_str(handle, AIL_PROP_X_SLP_PACKAGETYPE_STR, &svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_X_SLP_PACKAGETYPE_STR [%s] : %s\n", appid, svalue);
+
+                       ret = ail_filter_add_str(filter, AIL_PROP_X_SLP_PACKAGETYPE_STR, svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               return -1;
+                       }
+
+                       ret = ail_filter_list_appinfo_foreach(filter, appinfo_func, (void *)&i);
+                       if (ret != AIL_ERROR_OK){
+                               return -1;
+                       }
+
+                       ail_filter_destroy(filter);
+
+                       ret = ail_filter_new(&filter);
+                       if (ret != AIL_ERROR_OK) {
+                               return -1;
+                       }
+
+                       ret = ail_appinfo_get_str(handle, AIL_PROP_X_SLP_PACKAGEID_STR, &svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_X_SLP_PACKAGEID_STR [%s] : %s\n", appid, svalue);
+
+                       ret = ail_filter_add_str(filter, AIL_PROP_X_SLP_PACKAGEID_STR, svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               return -1;
+                       }
+
+                       ret = ail_filter_list_appinfo_foreach(filter, appinfo_func, (void *)&i);
+                       if (ret != AIL_ERROR_OK){
+                               return -1;
+                       }
+
+                       ail_filter_destroy(filter);
+
+                       ret = ail_filter_new(&filter);
+                       if (ret != AIL_ERROR_OK) {
+                               return -1;
+                       }
+
+                       ret = ail_appinfo_get_str(handle, AIL_PROP_X_SLP_EXE_PATH, &svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_X_SLP_EXE_PATH [%s] : %s\n", appid, svalue);
+
+                       ret = ail_filter_add_str(filter, AIL_PROP_X_SLP_EXE_PATH, svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               return -1;
+                       }
+
+                       ret = ail_filter_list_appinfo_foreach(filter, appinfo_func, (void *)&i);
+                       if (ret != AIL_ERROR_OK){
+                               return -1;
+                       }
+
+                       ail_filter_destroy(filter);
+
+                       ret = ail_filter_new(&filter);
+                       if (ret != AIL_ERROR_OK) {
+                               return -1;
+                       }
+                       ret = ail_appinfo_get_str(handle, AIL_PROP_X_SLP_APPID_STR, &svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_X_SLP_APPID_STR [%s] : %s\n", appid, svalue);
+
+                       ret = ail_filter_add_str(filter, AIL_PROP_X_SLP_APPID_STR, svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               return -1;
+                       }
+
+                       ret = ail_filter_list_appinfo_foreach(filter, appinfo_func, (void *)&i);
+                       if (ret != AIL_ERROR_OK){
+                               return -1;
+                       }
+
+                       ail_filter_destroy(filter);
+
+                       ret = ail_filter_new(&filter);
+                       if (ret != AIL_ERROR_OK) {
+                               return -1;
+                       }
+                       ret = ail_appinfo_get_str(handle, AIL_PROP_X_SLP_PKGID_STR, &svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_X_SLP_PKGID_STR [%s] : %s\n", appid, svalue);
+
+                       ret = ail_filter_add_str(filter, AIL_PROP_X_SLP_PKGID_STR, svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               return -1;
+                       }
+
+                       ret = ail_filter_list_appinfo_foreach(filter, appinfo_func, (void *)&i);
+                       if (ret != AIL_ERROR_OK){
+                               return -1;
+                       }
+
+                       ail_filter_destroy(filter);
+
+                       ret = ail_filter_new(&filter);
+                       if (ret != AIL_ERROR_OK) {
+                               return -1;
+                       }*/
+/*                     ret = ail_appinfo_get_str(handle, AIL_PROP_X_SLP_DOMAIN_STR, &svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_X_SLP_DOMAIN_STR [%s] : %s\n", appid, svalue);
+
+                       ret = ail_filter_add_str(filter, AIL_PROP_X_SLP_DOMAIN_STR, svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               return -1;
+                       }
+
+                       ret = ail_filter_list_appinfo_foreach(filter, appinfo_func, (void *)&i);
+                       if (ret != AIL_ERROR_OK){
+                               return -1;
+                       }
+
+                       ail_filter_destroy(filter);
+
+                       ret = ail_filter_new(&filter);
+                       if (ret != AIL_ERROR_OK) {
+                               return -1;
+                       }
+                       ret = ail_appinfo_get_str(handle, AIL_PROP_X_SLP_SUBMODEMAINID_STR, &svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_X_SLP_SUBMODEMAINID_STR, [%s] : %s\n", appid, svalue);
+
+                       ret = ail_filter_add_str(filter, AIL_PROP_X_SLP_SUBMODEMAINID_STR, svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               return -1;
+                       }
+
+                       ret = ail_filter_list_appinfo_foreach(filter, appinfo_func, (void *)&i);
+                       if (ret != AIL_ERROR_OK){
+                               return -1;
+                       }
+
+                       ail_filter_destroy(filter);
+
+                       ret = ail_filter_new(&filter);
+                       if (ret != AIL_ERROR_OK) {
+                               return -1;
+                       }
+*/     /*              ret = ail_appinfo_get_str(handle, AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR, &svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR [%s] : %s\n", appid, svalue);
+
+                       ret = ail_filter_add_str(filter, AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR, svalue);
+                       if (ret != AIL_ERROR_OK) {
+                               return -1;
+                       }
+
+                       ret = ail_filter_list_appinfo_foreach(filter, appinfo_func, (void *)&i);
+                       if (ret != AIL_ERROR_OK){
+                               return -1;
+                       }
+
+                       ail_filter_destroy(filter);
+
+                       ret = ail_filter_new(&filter);
+                       if (ret != AIL_ERROR_OK) {
+                               return -1;
+                       }*/
+/*                     ret = ail_appinfo_get_bool(handle, AIL_PROP_X_SLP_TASKMANAGE_BOOL, &bvalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_X_SLP_TASKMANAGE_BOOL [%s] : %d\n", appid, bvalue);
+
+                       ail_filter_add_bool(filter, AIL_PROP_X_SLP_TASKMANAGE_BOOL, bvalue);
+                       if (ret != AIL_ERROR_OK) {
+                               return -1;
+                       }
+
+                       ret = ail_filter_list_appinfo_foreach(filter, appinfo_func, (void *)&i);
+                       if (ret != AIL_ERROR_OK){
+                               return -1;
+                       }
+
+                       ail_filter_destroy(filter);
+
+                       ret = ail_filter_new(&filter);
+                       if (ret != AIL_ERROR_OK) {
+                               return -1;
+                       }
+                       ret = ail_appinfo_get_bool(handle, AIL_PROP_X_SLP_MULTIPLE_BOOL, &bvalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_X_SLP_MULTIPLE_BOOL [%s] : %d\n", appid, bvalue);
+
+                       ret = ail_filter_add_bool(filter, AIL_PROP_X_SLP_MULTIPLE_BOOL, bvalue);
+                       if (ret != AIL_ERROR_OK) {
+                               return -1;
+                       }
+
+                       ret = ail_filter_list_appinfo_foreach(filter, appinfo_func, (void *)&i);
+                       if (ret != AIL_ERROR_OK){
+                               return -1;
+                       }
+
+                       ail_filter_destroy(filter);
+
+                       ret = ail_filter_new(&filter);
+                       if (ret != AIL_ERROR_OK) {
+                               return -1;
+                       }
+*/                     ret = ail_appinfo_get_bool(handle, AIL_PROP_X_SLP_REMOVABLE_BOOL, &bvalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_X_SLP_REMOVABLE_BOOL [%s] : %d\n", appid, bvalue);
+
+                       ret = ail_filter_add_bool(filter, AIL_PROP_X_SLP_REMOVABLE_BOOL, bvalue);
+                       if (ret != AIL_ERROR_OK) {
+                               return -1;
+                       }
+
+                       ret = ail_filter_list_appinfo_foreach(filter, appinfo_func, (void *)&i);
+                       if (ret != AIL_ERROR_OK){
+                               return -1;
+                       }
+
+                       ail_filter_destroy(filter);
+
+       /*              ret = ail_filter_new(&filter);
+                       if (ret != AIL_ERROR_OK) {
+                               return -1;
+                       }
+                       ret = ail_appinfo_get_bool(handle, AIL_PROP_X_SLP_SUBMODE_BOOL, &bvalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_X_SLP_SUBMODE_BOOL [%s] : %d\n", appid, bvalue);
+
+                       ret = ail_filter_add_bool(filter, AIL_PROP_X_SLP_SUBMODE_BOOL, bvalue);
+                       if (ret != AIL_ERROR_OK) {
+                               return -1;
+                       }
+
+                       ret = ail_filter_list_appinfo_foreach(filter, appinfo_func, (void *)&i);
+                       if (ret != AIL_ERROR_OK){
+                               return -1;
+                       }
+
+                       ail_filter_destroy(filter);
+
+                       ret = ail_filter_new(&filter);
+                       if (ret != AIL_ERROR_OK) {
+                               return -1;
+                       }
+                       ret = ail_appinfo_get_bool(handle, AIL_PROP_X_SLP_ISHORIZONTALSCALE_BOOL, &bvalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_str failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_X_SLP_ISHORIZONTALSCALE_BOOL [%s] : %d\n", appid, bvalue);
+
+                       ret = ail_filter_add_bool(filter, AIL_PROP_X_SLP_ISHORIZONTALSCALE_BOOL, bvalue);
+                       if (ret != AIL_ERROR_OK) {
+                               return -1;
+                       }
+
+                       ret = ail_filter_list_appinfo_foreach(filter, appinfo_func, (void *)&i);
+                       if (ret != AIL_ERROR_OK){
+                               return -1;
+                       }
+
+                       ail_filter_destroy(filter);
+
+                       ret = ail_filter_new(&filter);
+                       if (ret != AIL_ERROR_OK) {
+                               return -1;
+                       }
+                       ret = ail_appinfo_get_bool(handle, AIL_PROP_X_SLP_ENABLED_BOOL, &bvalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_bool failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_X_SLP_ENABLED_BOOL [%s] : %d\n", appid, bvalue);
+
+                       ret = ail_filter_add_bool(filter, AIL_PROP_X_SLP_ENABLED_BOOL, bvalue);
+                       if (ret != AIL_ERROR_OK) {
+                               return -1;
+                       }
+
+                       ret = ail_filter_list_appinfo_foreach(filter, appinfo_func, (void *)&i);
+                       if (ret != AIL_ERROR_OK){
+                               return -1;
+                       }
+
+                       ail_filter_destroy(filter);
+
+                       ret = ail_filter_new(&filter);
+                       if (ret != AIL_ERROR_OK) {
+                               return -1;
+                       }
+                       ret = ail_appinfo_get_int(handle, AIL_PROP_X_SLP_TEMP_INT, &ivalue);
+                       if (ret != AIL_ERROR_OK) {
+                               fprintf(stderr, "Test ail_appinfo_get_int failed\n");
+                               return AIL_ERROR_FAIL;
+                       }
+                       fprintf(stdout, "AIL_PROP_X_SLP_TEMP_INT [%s] : %d\n", appid, ivalue);
+
+                       ret = ail_filter_add_int(filter, AIL_PROP_X_SLP_TEMP_INT, ivalue);
+                       if (ret != AIL_ERROR_OK) {
+                               return -1;
+                       }
+
+                       ret = ail_filter_list_appinfo_foreach(filter, appinfo_func, (void *)&i);
+                       if (ret != AIL_ERROR_OK){
+                               return -1;
+                       }
+
+                       ail_filter_destroy(filter);
+*/
+                       ail_destroy_appinfo(handle);
+
+
+
+
+
+
+                       break;
+               default:
+                       return -1;
+               }
+               memset(line, '\0', 256);
+       }
+       retval = fclose(fp);
+       if (retval)
+               printf("Closing of file failed");
+       return EXIT_SUCCESS;
+}
index a061814..9d7ed84 100644 (file)
@@ -106,8 +106,6 @@ static ail_error_e _remove_desktop(const char *package)
 int main(int argc, char** argv)
 {
        ail_error_e ret = AIL_ERROR_OK;
-       int len = 0;
-       char *appid = NULL;
 
        if (3 == argc) {
                if (!strncmp(argv[1], "add", 3)) {
@@ -115,13 +113,7 @@ int main(int argc, char** argv)
                } else if (!strncmp(argv[1], "update", 6)) {
                        ret = _update_desktop(argv[2]);
                } else if (!strncmp(argv[1], "remove", 6)) {
-                       len = (strlen(argv[2]) + 1);
-                       appid = (char *)calloc(len, sizeof(char));
-                       if(appid == NULL)
-                               return EXIT_FAILURE;
-                       strncpy(appid, argv[2], len - 1);
-                       ret = _remove_desktop(appid);
-                       free(appid);
+                       ret = _remove_desktop(argv[2]);
                } else {
                        fprintf(stderr, "%s is a invalid command\n", argv[1]);
                }
index dc58e8c..39bb15f 100644 (file)
@@ -80,12 +80,9 @@ static struct _ail_map_t prop_map[] = {
        {E_AIL_PROP_X_SLP_PACKAGETYPE_STR,      AIL_PROP_X_SLP_PACKAGETYPE_STR},
        {E_AIL_PROP_X_SLP_PACKAGECATEGORIES_STR, AIL_PROP_X_SLP_PACKAGECATEGORIES_STR},
        {E_AIL_PROP_X_SLP_PACKAGEID_STR,        AIL_PROP_X_SLP_PACKAGEID_STR},
+       {E_AIL_PROP_X_SLP_URI_STR, AIL_PROP_X_SLP_URI_STR},
        {E_AIL_PROP_X_SLP_SVC_STR,              AIL_PROP_X_SLP_SVC_STR},
        {E_AIL_PROP_X_SLP_EXE_PATH,             AIL_PROP_X_SLP_EXE_PATH},
-       {E_AIL_PROP_NODISPLAY_BOOL, AIL_PROP_NODISPLAY_BOOL},
-       {E_AIL_PROP_X_SLP_TASKMANAGE_BOOL, AIL_PROP_NODISPLAY_BOOL},
-       {E_AIL_PROP_X_SLP_MULTIPLE_BOOL, AIL_PROP_X_SLP_MULTIPLE_BOOL},
-       {E_AIL_PROP_X_SLP_REMOVABLE_BOOL, AIL_PROP_X_SLP_REMOVABLE_BOOL},
        {E_AIL_PROP_X_SLP_APPID_STR, AIL_PROP_X_SLP_APPID_STR},
        {E_AIL_PROP_X_SLP_PKGID_STR, AIL_PROP_X_SLP_PKGID_STR},
        {E_AIL_PROP_X_SLP_DOMAIN_STR, AIL_PROP_X_SLP_DOMAIN_STR},
@@ -94,7 +91,7 @@ static struct _ail_map_t prop_map[] = {
        {E_AIL_PROP_X_SLP_TEMP_INT, AIL_PROP_X_SLP_TEMP_INT},
        {E_AIL_PROP_X_SLP_INSTALLEDTIME_INT, AIL_PROP_X_SLP_INSTALLEDTIME_INT},
        {E_AIL_PROP_NODISPLAY_BOOL, AIL_PROP_NODISPLAY_BOOL},
-       {E_AIL_PROP_X_SLP_TASKMANAGE_BOOL, AIL_PROP_X_SLP_TASKMANAGE_BOOL},
+       {E_AIL_PROP_X_SLP_TASKMANAGE_BOOL, AIL_PROP_NODISPLAY_BOOL},
        {E_AIL_PROP_X_SLP_MULTIPLE_BOOL, AIL_PROP_X_SLP_MULTIPLE_BOOL},
        {E_AIL_PROP_X_SLP_REMOVABLE_BOOL, AIL_PROP_X_SLP_REMOVABLE_BOOL},
        {E_AIL_PROP_X_SLP_ISHORIZONTALSCALE_BOOL, AIL_PROP_X_SLP_ISHORIZONTALSCALE_BOOL},
@@ -102,6 +99,7 @@ static struct _ail_map_t prop_map[] = {
        {E_AIL_PROP_X_SLP_SUBMODE_BOOL, AIL_PROP_X_SLP_SUBMODE_BOOL}
 };
 
+
 static const char *_ail_convert_to_property(int prop)
 {
        int i = 0;
@@ -168,17 +166,17 @@ ail_cb_ret_e appinfo_list_func(const ail_appinfo_h appinfo, void *user_data)
                switch(t) {
                        case VAL_TYPE_BOOL:
                                error = ail_appinfo_get_bool(appinfo, _ail_convert_to_property(i), &b);
-                               if (error) ret = AIL_CB_RET_CANCEL;
+                               if (error != AIL_ERROR_OK) ret = AIL_CB_RET_CANCEL;
                                printf("%s|",b?"true":"false");
                                break;
                        case VAL_TYPE_INT:
-                               ail_appinfo_get_int(appinfo, _ail_convert_to_property(i), &n);
-                               if (error) ret = AIL_CB_RET_CANCEL;
+                               error = ail_appinfo_get_int(appinfo, _ail_convert_to_property(i), &n);
+                               if (error != AIL_ERROR_OK) ret = AIL_CB_RET_CANCEL;
                                printf("%d|", n);
                                break;
                        case VAL_TYPE_STR:
-                               ail_appinfo_get_str(appinfo, _ail_convert_to_property(i), &rs);
-                               if (error) ret = AIL_CB_RET_CANCEL;
+                               error = ail_appinfo_get_str(appinfo, _ail_convert_to_property(i), &rs);
+                               if (error != AIL_ERROR_OK) ret = AIL_CB_RET_CANCEL;
                                printf("%s|", rs);
                                break;
                        default:
@@ -229,12 +227,12 @@ int main(int argc, char *argv[])
                { "taskmanage", 1, &(e.prop), E_AIL_PROP_X_SLP_TASKMANAGE_BOOL},
                { "multiple", 1, &(e.prop), E_AIL_PROP_X_SLP_MULTIPLE_BOOL},
                { "removable", 1, &(e.prop), E_AIL_PROP_X_SLP_REMOVABLE_BOOL},
-               { "appid", 1, &(e.prop), AIL_PROP_X_SLP_APPID_STR},
-               { "pkgid", 1, &(e.prop), AIL_PROP_X_SLP_PKGID_STR},
+               { "appid", 1, &(e.prop), E_AIL_PROP_X_SLP_APPID_STR},
+               { "pkgid", 1, &(e.prop), E_AIL_PROP_X_SLP_PKGID_STR},
                { "submode", 1, &(e.prop), E_AIL_PROP_X_SLP_SUBMODE_BOOL},
-               { "submodemainid", 1, &(e.prop), AIL_PROP_X_SLP_SUBMODEMAINID_STR},
-               { "installedstorage", 1, &(e.prop), AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR},
-               { "domain", 1, &(e.prop), AIL_PROP_X_SLP_DOMAIN_STR},
+               { "submodemainid", 1, &(e.prop), E_AIL_PROP_X_SLP_SUBMODEMAINID_STR},
+               { "installedstorage", 1, &(e.prop), E_AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR},
+               { "domain", 1, &(e.prop), E_AIL_PROP_X_SLP_DOMAIN_STR},
                { 0, 0, 0, 0 },
        };
 
index 897c1fb..b0fdf18 100644 (file)
@@ -111,7 +111,7 @@ static ail_error_e _get_appinfo(const char *package, const char *property)
 
        ret = ail_package_get_appinfo(package, &handle);
        if (ret != AIL_ERROR_OK) {
-               return AIL_ERROR_FAIL;
+               goto END;
        }
 
        prop = _get_property(property);
@@ -154,31 +154,12 @@ END:
 
 int main(int argc, char** argv)
 {
-       int len = 0;
        ail_error_e ret = AIL_ERROR_OK;
-       char *appid = NULL;
-       char *property = NULL;
+
 
        if (4 == argc) {
                if (!strncmp(argv[1], "get", 3)) {
-
-                       len = (strlen(argv[2]) + 1);
-                       appid = (char *)calloc(len, sizeof(char));
-                       if(appid == NULL)
-                               return EXIT_FAILURE;
-                       strncpy(appid, argv[2], len - 1);
-
-                       len = (strlen(argv[3]) + 1);
-                       property = (char *)calloc(len, sizeof(char));
-                       if(property == NULL) {
-                               free(appid);
-                               return EXIT_FAILURE;
-                       }
-                       strncpy(property, argv[3], len - 1);
-
-                       ret = _get_appinfo(appid, property);
-                       free(appid);
-                       free(property);
+                       ret = _get_appinfo(argv[2], argv[3]);
                }
        }
        else {
index 1bba847..94805ef 100755 (executable)
@@ -27,6 +27,8 @@
 #include <dirent.h>
 #include <unistd.h>
 #include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/wait.h>
 #include <errno.h>
 
 #include "ail.h"
@@ -114,7 +116,7 @@ int initdb_load_directory(const char *directory)
 {
        DIR *dir;
        struct dirent entry, *result;
-       int len, ret;
+       int ret;
        char buf[BUFSZE];
        int total_cnt = 0;
        int ok_cnt = 0;
@@ -127,7 +129,6 @@ int initdb_load_directory(const char *directory)
                return AIL_ERROR_FAIL;
        }
 
-       len = strlen(directory) + 1;
        _D("Loading desktop files from %s", directory);
 
        for (ret = readdir_r(dir, &entry, &result);