Sync to the latest code 90/17790/1
authorjunsuk77.oh <junsuk77.oh@samsung.com>
Mon, 12 Aug 2013 02:34:25 +0000 (11:34 +0900)
committerSemun Lee <sm79.lee@samsung.com>
Tue, 11 Mar 2014 01:33:38 +0000 (10:33 +0900)
Change-Id: I538f71d0461cc85172c9d041e6bf077d951bfdf3
Signed-off-by: junsuk77.oh <junsuk77.oh@samsung.com>
Sync to the latest code

Change-Id: I594952c13734ec3710a7b0e1479d331af405040f
Signed-off-by: junsuk77.oh <junsuk77.oh@samsung.com>
add git license file

Change-Id: Id051f1a9b2d7a108c8d6cadfa9c8853bc0ab9f13
Signed-off-by: junsuk77.oh <junsuk77.oh@samsung.com>
delete license path

Change-Id: Id42fe2ac15c7acc7f90555f5cd41bcdc5ae26263
Signed-off-by: junsuk77.oh <junsuk77.oh@samsung.com>
sync with private master

Change-Id: I97cede33cc084ccb04921008511d3aed469bdd58
Signed-off-by: junsuk77.oh <junsuk77.oh@samsung.com>
fix ail filter query

Change-Id: I2b17f22629db41ca065e535304ccbeda608c67d4
Signed-off-by: junsuk77.oh <junsuk77.oh@samsung.com>
remove  keyword check

Change-Id: I035e723ad1787e33f3101f58052b12880e0a6a6b

add Apache boiler plate

Change-Id: If39b5d58ffc7c633a6eeeff71cae7a787b938afb

20 files changed:
CMakeLists.txt
include/ail.h
initdb/src/initdb.c
packaging/ail.spec
src/ail_convert.c
src/ail_db.c
src/ail_desktop.c
src/ail_filter.c
src/ail_package.c
src/ail_private.h
src/ail_sql.c
src/ail_sql.h
tool/CMakeLists.txt [new file with mode: 0755]
tool/src/ail_desktop.c [new file with mode: 0644]
tool/src/ail_filter.c [new file with mode: 0644]
tool/src/ail_fota.c [new file with mode: 0644]
tool/src/ail_package.c [new file with mode: 0644]
tool/src/initdb.c [new file with mode: 0755]
tool/src/main.c.head [new file with mode: 0644]
tool/src/main.c.tail [new file with mode: 0644]

index 88081ae..1a8f40e 100644 (file)
@@ -55,5 +55,4 @@ INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/ail.h DESTINATION include)
 INSTALL(FILES ${CMAKE_SOURCE_DIR}/desktop.conf DESTINATION share/install-info)
 
 # AIL init database
-ADD_SUBDIRECTORY(initdb)
-
+ADD_SUBDIRECTORY(tool)
index 51f32b8..1a81250 100755 (executable)
@@ -73,6 +73,7 @@ extern "C" {
 #define        AIL_PROP_X_SLP_PKGID_STR                "AIL_PROP_X_SLP_PKGID_STR"
 #define        AIL_PROP_X_SLP_DOMAIN_STR               "AIL_PROP_X_SLP_DOMAIN_STR"
 #define        AIL_PROP_X_SLP_SUBMODEMAINID_STR                "AIL_PROP_X_SLP_SUBMODEMAINID_STR"
+#define        AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR             "AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR"
 
 /**
  * @brief integer type properties
index e5dae3f..e9847d3 100755 (executable)
@@ -175,14 +175,14 @@ static int initdb_change_perm(const char *db_file)
        snprintf(journal_file, sizeof(journal_file), "%s%s", db_file, "-journal");
 
        for (i = 0; files[i]; i++) {
-               ret = chown(files[i], OWNER_ROOT, GROUP_MENU);
+               ret = chown(files[i], OWNER_ROOT, OWNER_ROOT);
                if (ret == -1) {
                        strerror_r(errno, buf, sizeof(buf));
-                       _E("FAIL : chown %s %d.%d, because %s", db_file, OWNER_ROOT, GROUP_MENU, buf);
+                       _E("FAIL : chown %s %d.%d, because %s", db_file, OWNER_ROOT, OWNER_ROOT, buf);
                        return AIL_ERROR_FAIL;
                }
 
-               ret = chmod(files[i], S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
+               ret = chmod(files[i], S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
                if (ret == -1) {
                        strerror_r(errno, buf, sizeof(buf));
                        _E("FAIL : chmod %s 0664, because %s", db_file, buf);
index ec73767..18b7c9b 100755 (executable)
@@ -1,5 +1,5 @@
 Name:           ail
-Version:        0.2.73
+Version:        0.2.80
 Release:        1
 License:        Apache-2.0
 Summary:        Application Information Library
@@ -31,6 +31,13 @@ cp %{SOURCE1001} .
 
 %build
 CFLAGS+=" -fpic"
+
+%if 0%{?tizen_build_binary_release_type_eng}
+export CFLAGS="$CFLAGS -DTIZEN_ENGINEER_MODE"
+export CXXFLAGS="$CXXFLAGS ?DTIZEN_ENGINEER_MODE"
+export FFLAGS="$FFLAGS -DTIZEN_ENGINEER_MODE"
+%endif
+
 %cmake .  -DBUILD_PKGTYPE=rpm \
                  -DSMACK=Off
 
@@ -66,6 +73,10 @@ update_DAC_for_db_file()
         fi
 }
 ail_initdb
+mkdir -p /usr/share/applications
+mkdir -p /opt/share/applications
+mkdir -p /opt/dbspace/
+
 update_DAC_for_db_file /opt/dbspace/.app_info.db
 update_DAC_for_db_file /opt/dbspace/.app_info.db-journal
 
@@ -84,7 +95,12 @@ fi
 %{_datadir}/install-info/*
 %{_libdir}/libail.so.0
 %{_libdir}/libail.so.0.1.0
-
+/usr/bin/ail_initdb
+/usr/bin/ail_fota
+/usr/bin/ail_desktop
+/usr/bin/ail_filter
+/usr/bin/ail_package
+/usr/share/install-info/*
 
 %files devel
 %manifest %{name}.manifest
index 8bcde5f..21cfcc1 100755 (executable)
@@ -53,7 +53,8 @@ static struct _ail_str_map_t str_prop_map[] = {
        {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},
-       {E_AIL_PROP_X_SLP_SUBMODEMAINID_STR,    AIL_PROP_X_SLP_SUBMODEMAINID_STR}
+       {E_AIL_PROP_X_SLP_SUBMODEMAINID_STR,    AIL_PROP_X_SLP_SUBMODEMAINID_STR},
+       {E_AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR, AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR}
 };
 
 
index 69aa3bf..8f24689 100755 (executable)
@@ -72,14 +72,15 @@ ail_error_e db_open(db_open_mode mode)
 
        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_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);
                }
        }
 
        if(mode & DB_OPEN_RW) {
                if (!db_info.dbrw) {
-                       ret = db_util_open(APP_INFO_DB, &db_info.dbrw, DB_UTIL_REGISTER_HOOK_METHOD);
+                       ret = db_util_open(APP_INFO_DB, &db_info.dbrw, 0);
                        retv_with_dbmsg_if(ret != SQLITE_OK, AIL_ERROR_DB_FAILED);
                }
        }
index cf00547..6fd4fa1 100755 (executable)
@@ -112,6 +112,7 @@ typedef struct {
        char*           x_slp_pkgid;
        char*           x_slp_domain;
        char*           x_slp_submodemainid;
+       char*           x_slp_installedstorage;
        int             x_slp_baselayoutwidth;
        int             x_slp_installedtime;
        int             nodisplay;
@@ -253,6 +254,8 @@ _get_icon_with_path(char* icon)
                package = _get_package_from_icon(icon);
                retv_if(!package, NULL);
 
+/* "db/setting/theme" is not exist */
+#if 0
                theme = vconf_get_str("db/setting/theme");
                if (!theme) {
                        theme = strdup("default");
@@ -261,6 +264,9 @@ _get_icon_with_path(char* icon)
                                return NULL;
                        }
                }
+#else
+               theme = strdup("default");
+#endif
 
                len = (0x01 << 7) + strlen(icon) + strlen(package) + strlen(theme);
                icon_with_path = malloc(len);
@@ -507,6 +513,18 @@ static ail_error_e _read_x_slp_submodemainid(void *data, char *tag, char *value)
        return AIL_ERROR_OK;
 }
 
+static ail_error_e _read_x_slp_installedstorage(void *data, char *tag, char *value)
+{
+       desktop_info_s *info = data;
+
+       retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
+       retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
+
+       SAFE_FREE_AND_STRDUP(value, info->x_slp_installedstorage);
+       retv_if(!info->x_slp_installedstorage, AIL_ERROR_OUT_OF_MEMORY);
+
+       return AIL_ERROR_OK;
+}
 
 static ail_error_e _read_x_slp_uri(void *data, char *tag, char *value)
 {
@@ -696,6 +714,10 @@ static struct entry_parser entry_parsers[] = {
                .value_cb = _read_x_slp_submodemainid,
        },
        {
+               .field = "x-tizen-installedstorage",
+               .value_cb = _read_x_slp_installedstorage,
+       },
+       {
                .field = "x-tizen-uri",
                .value_cb = _read_x_slp_uri,
        },
@@ -907,6 +929,7 @@ static inline int _strlen_desktop_info(desktop_info_s* info)
        if (info->x_slp_appid) len += strlen(info->x_slp_appid);
        if (info->desktop) len += strlen(info->desktop);
        if (info->x_slp_submodemainid) len += strlen(info->x_slp_submodemainid);
+       if (info->x_slp_installedstorage) len += strlen(info->x_slp_installedstorage);
 
        return len;
 }
@@ -1076,6 +1099,7 @@ static ail_error_e _retrieve_all_column_to_desktop_info(desktop_info_s* info, sq
        SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_PKGID_STR], info->x_slp_pkgid);
        SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_DOMAIN_STR], info->x_slp_domain);
        SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_SUBMODEMAINID_STR], info->x_slp_submodemainid);
+       SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR], info->x_slp_installedstorage);
 
        info->x_slp_installedtime = atoi(values[E_AIL_PROP_X_SLP_INSTALLEDTIME_INT]);
 
@@ -1192,7 +1216,12 @@ static ail_error_e _modify_desktop_info_str(desktop_info_s* info,
                        SAFE_FREE_AND_STRDUP(value, info->x_slp_svc);
                        retv_if (!info->x_slp_svc, AIL_ERROR_OUT_OF_MEMORY);
                        break;
+               case E_AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR:
+                       SAFE_FREE_AND_STRDUP(value, info->x_slp_installedstorage);
+                       retv_if (!info->x_slp_installedstorage, AIL_ERROR_OUT_OF_MEMORY);
+                       break;
                default:
+                       _E("prop[%d] is not defined\n", prop);
                        return AIL_ERROR_FAIL;
        }
 
@@ -1227,6 +1256,7 @@ static ail_error_e _create_table(void)
                "x_slp_pkgid TEXT, "
                "x_slp_domain TEXT, "
                "x_slp_submodemainid TEXT, "
+               "x_slp_installedstorage TEXT, "
                "x_slp_baselayoutwidth INTEGER DEFAULT 0, "
                "x_slp_installedtime INTEGER DEFAULT 0, "
                "nodisplay INTEGER DEFAULT 0, "
@@ -1300,6 +1330,7 @@ static ail_error_e _insert_desktop_info(desktop_info_s *info)
                "x_slp_pkgid, "
                "x_slp_domain, "
                "x_slp_submodemainid, "
+               "x_slp_installedstorage, "
                "x_slp_baselayoutwidth, "
                "x_slp_installedtime, "
                "nodisplay, "
@@ -1314,7 +1345,7 @@ static ail_error_e _insert_desktop_info(desktop_info_s *info)
                "('%q', '%q', '%q', '%q', '%q', "
                "'%q', '%q', '%q', '%q', '%q', "
                "'%q', '%q', '%q', '%q', '%q', "
-               "'%q', '%q', '%q', '%q',"
+               "'%q', '%q', '%q', '%q', '%q', "
                "%d, %d, %d, %d, %d, %d, %d,"
                "%d, %d, "
                "'%q');",
@@ -1337,6 +1368,7 @@ static ail_error_e _insert_desktop_info(desktop_info_s *info)
                info->x_slp_pkgid,
                info->x_slp_domain,
                info->x_slp_submodemainid,
+               info->x_slp_installedstorage,
                info->x_slp_baselayoutwidth,
                info->x_slp_installedtime,
                info->nodisplay,
@@ -1363,7 +1395,7 @@ static ail_error_e _insert_desktop_info(desktop_info_s *info)
        if (info->localname)
                _insert_local_info(info);
 
-       _D("Add (%s).", info->package);
+       _D("Add (%s).", query);
 
        return AIL_ERROR_OK;
 }
@@ -1404,6 +1436,7 @@ static ail_error_e _update_desktop_info(desktop_info_s *info)
                "x_slp_pkgid='%q', "
                "x_slp_domain='%q', "
                "x_slp_submodemainid='%q', "
+               "x_slp_installedstorage='%q', "
                "x_slp_baselayoutwidth=%d, "
                "x_slp_installedtime=%d, "
                "nodisplay=%d, "
@@ -1433,6 +1466,7 @@ static ail_error_e _update_desktop_info(desktop_info_s *info)
                info->x_slp_pkgid,
                info->x_slp_domain,
                info->x_slp_submodemainid,
+               info->x_slp_installedstorage,
                info->x_slp_baselayoutwidth,
                info->x_slp_installedtime,
                info->nodisplay,
@@ -1610,6 +1644,7 @@ static void _fini_desktop_info(desktop_info_s *info)
        SAFE_FREE(info->x_slp_pkgid);
        SAFE_FREE(info->x_slp_domain);
        SAFE_FREE(info->x_slp_submodemainid);
+       SAFE_FREE(info->x_slp_installedstorage);
        SAFE_FREE(info->desktop);
        if (info->localname) {
                g_slist_free_full(info->localname, _name_item_free_func);
index 3c4bb2f..1c64201 100755 (executable)
@@ -234,7 +234,7 @@ char *_get_where_clause(ail_filter_h filter)
                }
        }
 
-       _D("where = %s", w);
+//     _D("where = %s", w);
 
        return strdup(w);
 }
@@ -245,16 +245,17 @@ EXPORT_API ail_error_e ail_filter_count_appinfo(ail_filter_h filter, int *cnt)
        char *w;
        char *tmp_q;
        char *l;
-       int r;
-       int n;
+       ail_cb_ret_e r;
        sqlite3_stmt *stmt;
+       ail_appinfo_h ai;
+       int filter_count = 0;
 
        retv_if(!cnt, AIL_ERROR_INVALID_PARAMETER);
 
        if (db_open(DB_OPEN_RO) != AIL_ERROR_OK)
                return AIL_ERROR_DB_FAILED;
 
-       snprintf(q, sizeof(q), "SELECT COUNT (*) FROM %s", SQL_TBL_APP_INFO_WITH_LOCALNAME);
+       snprintf(q, sizeof(q), "SELECT %s FROM %s", SQL_FLD_APP_INFO_WITH_LOCALNAME, SQL_TBL_APP_INFO_WITH_LOCALNAME);
 
        tmp_q = strdup(q);
        retv_if (NULL == tmp_q, AIL_ERROR_OUT_OF_MEMORY);
@@ -268,32 +269,39 @@ EXPORT_API ail_error_e ail_filter_count_appinfo(ail_filter_h filter, int *cnt)
        free(l);
        free(tmp_q);
 
-       if (filter && filter->list) { 
+       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);
        }
-
-       _D("Query = %s",q);
+       else
+               _D("No filter exists. All records are retreived");
 
        if (db_prepare(q, &stmt) != AIL_ERROR_OK) {
+               _E("db_prepare fail for query = %s",q);
                return AIL_ERROR_DB_FAILED;
        }
 
-       r = db_step(stmt);
-       if (r == AIL_ERROR_OK) {
-               db_column_int(stmt, 0, &n);
-               *cnt = n;
+       ai = appinfo_create();
+
+       appinfo_set_stmt(ai, stmt);
+       while (db_step(stmt) == AIL_ERROR_OK) {
+
+               if(_appinfo_check_installed_storage(ai) != AIL_ERROR_OK)
+                       continue;
+
+               filter_count++;
        }
 
        db_finalize(stmt);
 
-       return r;
-}
-
+       appinfo_destroy(ai);
+       *cnt = filter_count;
 
+       return AIL_ERROR_OK;
+}
 
 EXPORT_API ail_error_e ail_filter_list_appinfo_foreach(ail_filter_h filter, ail_list_appinfo_cb cb, void *user_data)
 {
@@ -336,9 +344,10 @@ EXPORT_API ail_error_e ail_filter_list_appinfo_foreach(ail_filter_h filter, ail_
        else
                _D("No filter exists. All records are retreived");
 
-       _D("Query = %s",q);
+//     _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;
        }
 
@@ -347,6 +356,9 @@ 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;
+
                r = cb(ai, user_data);
                if (AIL_CB_RET_CANCEL == r)
                        break;
index b12aa84..711c8de 100755 (executable)
@@ -37,6 +37,8 @@
 #define LANGUAGE_LENGTH 2
 #define DEFAULT_LOCALE         "No Locale"
 #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'"
 
 struct ail_appinfo {
        char **values;
@@ -166,30 +168,7 @@ static char* __get_app_locale_by_fallback(const char *appid, const char *sysloca
        return  strdup(DEFAULT_LOCALE);
 }
 
-void appinfo_set_stmt(ail_appinfo_h ai, sqlite3_stmt *stmt)
-{
-       ai->stmt = stmt;
-}
-
-ail_appinfo_h appinfo_create(void)
-{
-       ail_appinfo_h ai;
-       ai = calloc(1, sizeof(struct ail_appinfo));
-       retv_if (NULL == ai, NULL);
-       ai->stmt = NULL;
-
-       return ai;
-}
-
-void appinfo_destroy(ail_appinfo_h ai)
-{
-       if (ai) 
-               free(ai);
-}
-
-
-
-static ail_error_e _retrieve_all_column(ail_appinfo_h ai)
+static ail_error_e __retrieve_all_column(ail_appinfo_h ai)
 {
        int i, j;
        ail_error_e err;
@@ -229,6 +208,67 @@ static ail_error_e _retrieve_all_column(ail_appinfo_h ai)
                return AIL_ERROR_OK;
 }
 
+int _appinfo_check_installed_storage(ail_appinfo_h ai)
+{
+       int index = 0;
+       ail_prop_str_e prop = -1;
+       char *pkgid = NULL;
+       char *installed_storage = NULL;
+       char buf[AIL_SQL_QUERY_MAX_LEN] = {'\0'};
+
+       retv_if(!ai, AIL_ERROR_OK);
+
+       if (ai->stmt) {
+               prop = _ail_convert_to_prop_str(AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR);
+               index = sql_get_app_info_idx(prop);
+               if (db_column_str(ai->stmt, index, &installed_storage) < 0){
+                       return AIL_ERROR_OK;
+               }
+
+               prop = _ail_convert_to_prop_str(AIL_PROP_X_SLP_PKGID_STR);
+               index = sql_get_app_info_idx(prop);
+               if (db_column_str(ai->stmt, index, &pkgid) < 0){
+                       return AIL_ERROR_OK;
+               }
+       } else {
+               prop = _ail_convert_to_prop_str(AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR);
+               installed_storage = ai->values[prop];
+
+               prop = _ail_convert_to_prop_str(AIL_PROP_X_SLP_PKGID_STR);
+               pkgid = ai->values[prop];
+       }
+
+       if (strcmp(installed_storage, "installed_external") == 0) {
+               snprintf(buf, AIL_SQL_QUERY_MAX_LEN - 1, "%s%s", PKG_SD_PATH, pkgid);
+               if (access(buf, R_OK) != 0) {
+                       _E("can not access [%s]", buf);
+                       return AIL_ERROR_OK;//tmep, it will be fixed to ::  return AIL_ERROR_FAIL;
+               }
+       }
+
+       return AIL_ERROR_OK;
+}
+
+void appinfo_set_stmt(ail_appinfo_h ai, sqlite3_stmt *stmt)
+{
+       ai->stmt = stmt;
+}
+
+ail_appinfo_h appinfo_create(void)
+{
+       ail_appinfo_h ai;
+       ai = calloc(1, sizeof(struct ail_appinfo));
+       retv_if (NULL == ai, NULL);
+       ai->stmt = NULL;
+
+       return ai;
+}
+
+void appinfo_destroy(ail_appinfo_h ai)
+{
+       if (ai)
+               free(ai);
+}
 
 EXPORT_API ail_error_e ail_package_destroy_appinfo(ail_appinfo_h ai)
 {
@@ -261,7 +301,6 @@ EXPORT_API ail_error_e ail_package_get_appinfo(const char *package, ail_appinfo_
        return ail_get_appinfo(package, ai);
 }
 
-
 EXPORT_API ail_error_e ail_get_appinfo(const char *appid, ail_appinfo_h *ai)
 {
        ail_error_e ret;
@@ -294,7 +333,13 @@ EXPORT_API ail_error_e ail_get_appinfo(const char *appid, ail_appinfo_h *ai)
 
                (*ai)->stmt = stmt;
 
-               ret = _retrieve_all_column(*ai);
+               ret = _appinfo_check_installed_storage(*ai);
+               if (ret < 0) {
+                       db_finalize((*ai)->stmt);
+                       break;
+               }
+
+               ret = __retrieve_all_column(*ai);
                if (ret < 0) {
                        db_finalize((*ai)->stmt);
                        break;
@@ -365,8 +410,6 @@ EXPORT_API ail_error_e ail_appinfo_get_int(const ail_appinfo_h ai, const char *p
        return AIL_ERROR_OK;
 }
 
-#define QUERY_GET_LOCALNAME "select name from localname where package='%s' and locale='%s'"
-
 char *appinfo_get_localname(const char *package, char *locale)
 {
        db_open(DB_OPEN_RO);
@@ -377,7 +420,7 @@ char *appinfo_get_localname(const char *package, char *locale)
        
        snprintf(query, sizeof(query), QUERY_GET_LOCALNAME, package, locale);
 
-       _D("Query = %s",query);
+//     _D("Query = %s",query);
        retv_if (db_prepare(query, &stmt) < 0, NULL);
 
        do {
index fc6fb7c..4891c82 100755 (executable)
@@ -133,7 +133,8 @@ typedef enum {
        E_AIL_PROP_X_SLP_PKGID_STR,
        E_AIL_PROP_X_SLP_DOMAIN_STR,
        E_AIL_PROP_X_SLP_SUBMODEMAINID_STR,
-       E_AIL_PROP_STR_MAX = E_AIL_PROP_X_SLP_SUBMODEMAINID_STR,
+       E_AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR,
+       E_AIL_PROP_STR_MAX = E_AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR,
 } ail_prop_str_e;
 
 
index edfdb34..bd24355 100755 (executable)
@@ -50,6 +50,7 @@ static const char *filter[] = {
        "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",
index 39372c3..37eb0ee 100755 (executable)
@@ -50,6 +50,7 @@
                        "app_info.X_SLP_PKGID," \
                        "app_info.X_SLP_DOMAIN," \
                        "app_info.X_SLP_SUBMODEMAINID," \
+                       "app_info.X_SLP_INSTALLEDSTORAGE," \
                        "app_info.X_SLP_BASELAYOUTWIDTH," \
                        "app_info.X_SLP_INSTALLEDTIME," \
                        "app_info.NODISPLAY," \
diff --git a/tool/CMakeLists.txt b/tool/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..e898c7e
--- /dev/null
@@ -0,0 +1,57 @@
+#AIL init DB build script
+
+SET(INITDB ail_initdb)
+SET(SRCS src/initdb.c)
+
+SET(FOTA ail_fota)
+SET(FOTASRCS src/ail_fota.c)
+
+SET(DESKTOP ail_desktop)
+SET(DESKSRCS src/ail_desktop.c)
+
+SET(FILTER ail_filter)
+SET(FILTERSRCS src/ail_filter.c)
+
+SET(PKG ail_package)
+SET(PKGSRCS src/ail_package.c)
+
+pkg_check_modules(INITDB_PKGS REQUIRED vconf dlog db-util sqlite3)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src)
+
+STRING(REPLACE ";" " " EXTRA_CFLAGS "${INITDB_PKGS_CFLAGS}")
+
+ADD_EXECUTABLE(${INITDB} ${SRCS})
+TARGET_LINK_LIBRARIES(${INITDB} ${LIBNAME} ${INITDB_PKGS_LIBRARIES})
+SET_TARGET_PROPERTIES(${INITDB} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS}")
+SET_TARGET_PROPERTIES(${INITDB} PROPERTIES SKIP_BUILD_RPATH true)
+
+INSTALL(TARGETS ${INITDB} DESTINATION ${BINDIR})
+
+ADD_EXECUTABLE(${FOTA} ${FOTASRCS})
+TARGET_LINK_LIBRARIES(${FOTA} ${LIBNAME} ${INITDB_PKGS_LIBRARIES})
+SET_TARGET_PROPERTIES(${FOTA} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS}")
+SET_TARGET_PROPERTIES(${FOTA} PROPERTIES SKIP_BUILD_RPATH true)
+
+INSTALL(TARGETS ${FOTA} DESTINATION ${BINDIR})
+
+ADD_EXECUTABLE(${DESKTOP} ${DESKSRCS})
+TARGET_LINK_LIBRARIES(${DESKTOP} ${LIBNAME} ${INITDB_PKGS_LIBRARIES})
+SET_TARGET_PROPERTIES(${DESKTOP} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS}")
+SET_TARGET_PROPERTIES(${DESKTOP} PROPERTIES SKIP_BUILD_RPATH true)
+
+INSTALL(TARGETS ${DESKTOP} DESTINATION ${BINDIR})
+
+ADD_EXECUTABLE(${FILTER} ${FILTERSRCS})
+TARGET_LINK_LIBRARIES(${FILTER} ${LIBNAME} ${INITDB_PKGS_LIBRARIES})
+SET_TARGET_PROPERTIES(${FILTER} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS}")
+SET_TARGET_PROPERTIES(${FILTER} PROPERTIES SKIP_BUILD_RPATH true)
+
+INSTALL(TARGETS ${FILTER} DESTINATION ${BINDIR})
+
+ADD_EXECUTABLE(${PKG} ${PKGSRCS})
+TARGET_LINK_LIBRARIES(${PKG} ${LIBNAME} ${INITDB_PKGS_LIBRARIES})
+SET_TARGET_PROPERTIES(${PKG} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS}")
+SET_TARGET_PROPERTIES(${PKG} PROPERTIES SKIP_BUILD_RPATH true)
+
+INSTALL(TARGETS ${PKG} DESTINATION ${BINDIR})
\ No newline at end of file
diff --git a/tool/src/ail_desktop.c b/tool/src/ail_desktop.c
new file mode 100644 (file)
index 0000000..0140d20
--- /dev/null
@@ -0,0 +1,136 @@
+/*
+ * ail
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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>
+
+
+static void _print_help(const char *cmd)
+{
+       fprintf(stderr, "Usage:\n");
+       fprintf(stderr, "\n");
+       fprintf(stderr, "[Add a desktop]\n");
+       fprintf(stderr, "       %s add <PACKAGE NAME>\n", cmd);
+       fprintf(stderr, "\n");
+       fprintf(stderr, "       Ex) %s add com.samsung.menu-screen\n", cmd);
+       fprintf(stderr, "\n");
+       fprintf(stderr, "[Update a desktop]\n");
+       fprintf(stderr, "       %s update <PACKAGE NAME>\n", cmd);
+       fprintf(stderr, "\n");
+       fprintf(stderr, "       Ex) %s update com.samsung.menu-screen\n", cmd);
+       fprintf(stderr, "\n");
+       fprintf(stderr, "[Remove a desktop]\n");
+       fprintf(stderr, "       %s remove <PACKAGE NAME>\n", cmd);
+       fprintf(stderr, "\n");
+       fprintf(stderr, "       Ex) %s remove com.samsung.menu-screen\n", cmd);
+       fprintf(stderr, "\n");
+}
+
+
+
+static ail_error_e _add_desktop(const char *package)
+{
+       ail_error_e ret;
+
+       if (!package) {
+               return AIL_ERROR_FAIL;
+       }
+
+       ret = ail_desktop_add(package);
+       if (ret != AIL_ERROR_OK) {
+               return AIL_ERROR_FAIL;
+       }
+
+       return AIL_ERROR_OK;
+}
+
+
+
+static ail_error_e _update_desktop(const char *package)
+{
+       ail_error_e ret;
+
+       if (!package) {
+               return AIL_ERROR_FAIL;
+       }
+
+       ret = ail_desktop_update(package);
+       if (ret != AIL_ERROR_OK) {
+               return AIL_ERROR_FAIL;
+       }
+
+       return AIL_ERROR_OK;
+}
+
+
+
+static ail_error_e _remove_desktop(const char *package)
+{
+       ail_error_e ret;
+
+       if (!package) {
+               return AIL_ERROR_FAIL;
+       }
+
+       ret = ail_desktop_remove(package);
+       if (ret != AIL_ERROR_OK) {
+               return AIL_ERROR_FAIL;
+       }
+
+       return AIL_ERROR_OK;
+}
+
+
+
+int main(int argc, char** argv)
+{
+       ail_error_e ret = AIL_ERROR_OK;
+
+       if (3 == argc) {
+               if (!strncmp(argv[1], "add", 3)) {
+                       ret = _add_desktop(argv[2]);
+               } else if (!strncmp(argv[1], "update", 6)) {
+                       ret = _update_desktop(argv[2]);
+               } else if (!strncmp(argv[1], "remove", 6)) {
+                       ret = _remove_desktop(argv[2]);
+               } else {
+                       fprintf(stderr, "%s is a invalid command\n", argv[1]);
+               }
+       }
+       else {
+               _print_help(argv[0]);
+               return EXIT_FAILURE;
+       }
+
+       if (ret != AIL_ERROR_OK) {
+               fprintf(stderr, "There are some problems\n");
+       }
+
+       return EXIT_SUCCESS;
+}
+
diff --git a/tool/src/ail_filter.c b/tool/src/ail_filter.c
new file mode 100644 (file)
index 0000000..c5d1a29
--- /dev/null
@@ -0,0 +1,320 @@
+/*
+ * ail
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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 <getopt.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include "ail.h"
+#include "ail_private.h"
+
+enum {
+       _CMD_UNKNOWN,
+       _CMD_COUNT,
+       _CMD_FILTER,
+};
+
+static void usage(const char *name)
+{
+       fprintf(stderr, "\n");
+       fprintf(stderr, "  Usage: %s -c command [options]\n", name);
+       fprintf(stderr, "    command:\n");
+       fprintf(stderr, "      c : count appinfos by option\n");
+       fprintf(stderr, "      f : filter appinfos by option\n");
+       fprintf(stderr, "\n");
+       fprintf(stderr, "    option:\n");
+       fprintf(stderr, "      --package=<pacakge name>\n");
+       fprintf(stderr, "      --exec=<exec file>\n");
+       fprintf(stderr, "      --name=<title name>\n");
+       fprintf(stderr, "      --type=<type>\n");
+       fprintf(stderr, "      --icon=<icon file>\n");
+       fprintf(stderr, "      --category=<category>\n");
+       fprintf(stderr, "      --version=<version>\n");
+       fprintf(stderr, "      --mimetype=<mimetype>\n");
+       fprintf(stderr, "      --nodisplay=<{0|1}>\n");
+       fprintf(stderr, "      --service=<service>\n");
+       fprintf(stderr, "      --packagetype=<package type>\n");
+       fprintf(stderr, "      --packagecategories=<package category>\n");
+       fprintf(stderr, "      --packageid=<package id>\n");
+       fprintf(stderr, "      --svc=<action:scheme:mime>\n");
+       fprintf(stderr, "      --taskmanage=<{true|false}>\n");
+       fprintf(stderr, "      --multiple=<{true|false}>\n");
+       fprintf(stderr, "      --removable=<{true|false}>\n");
+       fprintf(stderr, "\n");
+       fprintf(stderr, "    Example:\n");
+       fprintf(stderr, "       %s -n menu-screen -r 1\n", name);
+       fprintf(stderr, "\n");
+}
+
+struct _ail_map_t {
+       int prop;
+       const char *property;
+};
+
+static struct _ail_map_t prop_map[] = {
+       {E_AIL_PROP_PACKAGE_STR,                AIL_PROP_PACKAGE_STR},
+       {E_AIL_PROP_EXEC_STR,                   AIL_PROP_EXEC_STR},
+       {E_AIL_PROP_NAME_STR,                   AIL_PROP_NAME_STR},
+       {E_AIL_PROP_TYPE_STR,                   AIL_PROP_TYPE_STR},
+       {E_AIL_PROP_ICON_STR,                   AIL_PROP_ICON_STR},
+       {E_AIL_PROP_CATEGORIES_STR,             AIL_PROP_CATEGORIES_STR},
+       {E_AIL_PROP_VERSION_STR,                AIL_PROP_VERSION_STR},
+       {E_AIL_PROP_MIMETYPE_STR,               AIL_PROP_MIMETYPE_STR},
+       {E_AIL_PROP_X_SLP_SERVICE_STR,          AIL_PROP_X_SLP_SERVICE_STR},
+       {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_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},
+       {E_AIL_PROP_X_SLP_SUBMODEMAINID_STR, AIL_PROP_X_SLP_SUBMODEMAINID_STR},
+       {E_AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR, AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR},
+       {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_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_ENABLED_BOOL, AIL_PROP_X_SLP_ENABLED_BOOL},
+       {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;
+
+       if (prop < E_AIL_PROP_STR_MIN || prop > E_AIL_PROP_BOOL_MAX)
+               return NULL;
+
+       for (i=0 ; i < (E_AIL_PROP_BOOL_MAX + 1) ; i++) {
+               if (prop == prop_map[i].prop) {
+                       return prop_map[i].property;
+               }
+       }
+
+       return NULL;
+}
+
+
+
+static int _get_cmd(const char *arg)
+{
+       int r;
+       int a;
+
+       if(!arg)
+               a = 0;
+       else
+               a = (int)*arg;
+
+       switch (a) {
+       case 'c':
+       case 'C':
+               r = _CMD_COUNT;
+               break;
+       case 'f':
+       case 'F':
+               r = _CMD_FILTER;
+               break;
+       default:
+               r = _CMD_UNKNOWN;
+               break;
+       }
+
+       return r;
+}
+
+ail_cb_ret_e appinfo_list_func(const ail_appinfo_h appinfo, void *user_data)
+{
+       char *rs = NULL;
+       int t=-1;
+       bool b = 0;
+       int n = 0;
+       struct element e;
+       int i=0;
+       struct element *p;
+       ail_error_e error = AIL_ERROR_OK;
+       ail_cb_ret_e ret = AIL_CB_RET_CONTINUE;
+       p = &e;
+
+       bool err = false;
+       ret = AIL_CB_RET_CONTINUE;
+       for(i = 0; i< E_AIL_PROP_BOOL_MAX+1 && err==false; i ++) {
+               e.prop = i;
+               ELEMENT_TYPE(p, t);
+               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;
+                               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;
+                               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;
+                               printf("%s|", rs);
+                               break;
+                       default:
+                               fprintf(stderr, "$$$\n");
+                               err = true;
+                               break;
+               }
+       }
+       printf("\n");
+       return ret;
+}
+
+
+
+int main(int argc, char *argv[])
+{
+       int o;
+       bool err;
+       ail_filter_h f;
+       int oi;
+       int c;
+       static struct element e;
+       int t;
+
+       f = NULL;
+       oi = -1;
+       c = _CMD_UNKNOWN;
+
+       static const struct option longopts[] = {
+               { "help", 0, NULL, 'h' },
+               { "command", 1, NULL, 'c' },
+               { "package", 1, &(e.prop), E_AIL_PROP_PACKAGE_STR},
+               { "name", 1, &(e.prop), E_AIL_PROP_NAME_STR },
+               { "mimetype", 1, &(e.prop), E_AIL_PROP_MIMETYPE_STR},
+               { "removable", 1, &(e.prop), E_AIL_PROP_X_SLP_REMOVABLE_BOOL },
+               { "exec", 1, &(e.prop), E_AIL_PROP_EXEC_STR},
+               { "type", 1, &(e.prop), E_AIL_PROP_TYPE_STR},
+               { "icon", 1, &(e.prop), E_AIL_PROP_ICON_STR},
+               { "categories", 1, &(e.prop), E_AIL_PROP_CATEGORIES_STR},
+               { "version", 1, &(e.prop), E_AIL_PROP_VERSION_STR},
+               { "mimetype", 1, &(e.prop), E_AIL_PROP_MIMETYPE_STR},
+               { "nodisplay", 1, &(e.prop), E_AIL_PROP_NODISPLAY_BOOL},
+               { "service", 1, &(e.prop), E_AIL_PROP_X_SLP_SERVICE_STR},
+               { "packagetype", 1, &(e.prop), E_AIL_PROP_X_SLP_PACKAGETYPE_STR},
+               { "packagecategories", 1, &(e.prop), E_AIL_PROP_X_SLP_PACKAGECATEGORIES_STR},
+               { "packageid", 1, &(e.prop), E_AIL_PROP_X_SLP_PACKAGEID_STR},
+               { "svc", 1, &(e.prop), E_AIL_PROP_X_SLP_SVC_STR},
+               { "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},
+               { "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},
+               { 0, 0, 0, 0 },
+       };
+
+       if (ail_filter_new(&f) != AIL_ERROR_OK)
+               return -1;
+
+       err = false;
+
+       while (!err && (o = getopt_long(argc, argv, "c:", longopts, &oi)) >= 0) {
+               bool b;
+               struct element *p = &e;
+
+               ELEMENT_TYPE(p, t);
+
+               switch (o) {
+                       case 'c':
+                               c = _get_cmd(optarg);
+                               break;
+                       case 0:
+                               switch (t) {
+                                       case VAL_TYPE_BOOL:
+                                               if(!strcasecmp(optarg, "true") || !strcasecmp(optarg, "1"))
+                                                       b = true;
+                                               else if (!strcasecmp(optarg, "false") || !strcasecmp(optarg, "0"))
+                                                       b = false;
+                                               else {
+                                                       err = true;
+                                                       break;
+                                               }
+                                               if (ail_filter_add_bool(f, _ail_convert_to_property(e.prop), b) != AIL_ERROR_OK)
+                                                       err = true;
+                                               break;
+
+                                       case VAL_TYPE_INT:
+                                               if (ail_filter_add_int(f, _ail_convert_to_property(e.prop), atoi(optarg)) != AIL_ERROR_OK)
+                                                       err = true;
+                                               break;
+
+                                       case VAL_TYPE_STR:
+                                               if (ail_filter_add_str(f, _ail_convert_to_property(e.prop), optarg) != AIL_ERROR_OK)
+                                                       err = true;
+                                               break;
+
+                                       default:
+                                               err = true;
+                                               break;
+                               }
+                               break;
+                       default:
+                               err = true;
+                               break;
+               }
+       }
+
+       if (err) {
+               usage(argv[0]);
+       }
+       else {
+               int n = -1;
+               switch (c) {
+                       case _CMD_COUNT:
+                               if (ail_filter_count_appinfo(f, &n) != AIL_ERROR_OK){
+                                       fprintf(stderr, "Error: failed to count appinfo\n");
+                               }
+                               else
+                                       fprintf(stderr, "count=%d\n", n);
+                               break;
+                       case _CMD_FILTER:
+                               ail_filter_list_appinfo_foreach(f, appinfo_list_func, NULL);
+                               break;
+                       default:
+                               break;
+               }
+       }
+
+       if (f)
+               ail_filter_destroy(f);
+
+       return 0;
+}
diff --git a/tool/src/ail_fota.c b/tool/src/ail_fota.c
new file mode 100644 (file)
index 0000000..334388f
--- /dev/null
@@ -0,0 +1,289 @@
+/*
+ * ail
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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 <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <dirent.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <errno.h>
+
+#include "ail.h"
+#include "ail_private.h"
+
+#define OWNER_ROOT 0
+#define GROUP_MENU 6010
+#define BUFSZE 1024
+#define OPT_DESKTOP_DIRECTORY "/opt/share/applications"
+#define USR_DESKTOP_DIRECTORY "/usr/share/applications"
+#define APP_INFO_DB_FILE "/opt/dbspace/.app_info.db"
+#define APP_INFO_DB_FILE_JOURNAL "/opt/dbspace/.app_info.db-journal"
+#define APP_INFO_DB_LABEL "ail::db"
+
+#ifdef _E
+#undef _E
+#endif
+#define _E(fmt, arg...) fprintf(stderr, "[AIL_INITDB][E][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg);
+
+#ifdef _D
+#undef _D
+#endif
+#define _D(fmt, arg...) fprintf(stderr, "[AIL_INITDB][D][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg);
+
+static int initdb_count_app(void)
+{
+       ail_filter_h filter;
+       ail_error_e ret;
+       int total = 0;
+
+       ret = ail_filter_new(&filter);
+       if (ret != AIL_ERROR_OK) {
+               return -1;
+       }
+
+       ret = ail_filter_add_bool(filter, AIL_PROP_NODISPLAY_BOOL, false);
+       if (ret != AIL_ERROR_OK) {
+               ail_filter_destroy(filter);
+               return -1;
+       }
+
+       ret = ail_filter_count_appinfo(filter, &total);
+       if (ret != AIL_ERROR_OK) {
+               ail_filter_destroy(filter);
+               return -1;
+       }
+
+       ail_filter_destroy(filter);
+
+       return total;
+}
+
+
+
+char* _desktop_to_package(const char* desktop)
+{
+       char *package, *tmp;
+
+       retv_if(!desktop, NULL);
+
+       package = strdup(desktop);
+       retv_if(!package, NULL);
+
+       tmp = strrchr(package, '.');
+       if(tmp == NULL) {
+               _E("[%s] is not a desktop file", package);
+               free(package);
+               return NULL;
+       }
+
+       if (strcmp(tmp, ".desktop")) {
+               _E("%s is not a desktop file", desktop);
+               free(package);
+               return NULL;
+       }
+
+       *tmp = '\0';
+
+       return package;
+}
+
+
+
+int initdb_load_directory(const char *directory)
+{
+       DIR *dir;
+       struct dirent entry, *result;
+       int len, ret;
+       char buf[BUFSZE];
+       int total_cnt = 0;
+       int ok_cnt = 0;
+
+       // desktop file
+       dir = opendir(directory);
+       if (!dir) {
+               if (strerror_r(errno, buf, sizeof(buf)) == 0)
+                       _E("Failed to access the [%s] because %s\n", directory, buf);
+               return AIL_ERROR_FAIL;
+       }
+
+       len = strlen(directory) + 1;
+       _D("Loading desktop files from %s", directory);
+
+       for (ret = readdir_r(dir, &entry, &result);
+                       ret == 0 && result != NULL;
+                       ret = readdir_r(dir, &entry, &result)) {
+               char *package;
+
+               if (entry.d_name[0] == '.') continue;
+               total_cnt++;
+               package = _desktop_to_package(entry.d_name);
+               if (!package) {
+                       _E("Failed to convert file to package[%s]", entry.d_name);
+                       continue;
+               }
+
+               if (ail_desktop_fota(package) != AIL_ERROR_OK) {
+                       _E("Failed to add a package[%s]", package);
+               } else {
+                       ok_cnt++;
+               }
+               free(package);
+       }
+
+       _D("Application-Desktop process : Success [%d], fail[%d], total[%d] \n", ok_cnt, total_cnt-ok_cnt, total_cnt);
+       closedir(dir);
+
+       return AIL_ERROR_OK;
+}
+
+
+
+static int initdb_change_perm(const char *db_file)
+{
+       char buf[BUFSZE];
+       char journal_file[BUFSZE];
+       char *files[3];
+       int ret, i;
+
+       files[0] = (char *)db_file;
+       files[1] = journal_file;
+       files[2] = NULL;
+
+       retv_if(!db_file, AIL_ERROR_FAIL);
+
+       snprintf(journal_file, sizeof(journal_file), "%s%s", db_file, "-journal");
+
+       for (i = 0; files[i]; i++) {
+               ret = chown(files[i], OWNER_ROOT, OWNER_ROOT);
+               if (ret == -1) {
+                       strerror_r(errno, buf, sizeof(buf));
+                       _E("FAIL : chown %s %d.%d, because %s", db_file, OWNER_ROOT, OWNER_ROOT, buf);
+                       return AIL_ERROR_FAIL;
+               }
+
+               ret = chmod(files[i], S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+               if (ret == -1) {
+                       strerror_r(errno, buf, sizeof(buf));
+                       _E("FAIL : chmod %s 0664, because %s", db_file, buf);
+                       return AIL_ERROR_FAIL;
+               }
+       }
+
+       return AIL_ERROR_OK;
+}
+
+
+static int __is_authorized()
+{
+       /* ail_init db should be called by as root privilege. */
+
+       uid_t uid = getuid();
+       if ((uid_t) 0 == uid)
+               return 1;
+       else
+               return 0;
+}
+
+int xsystem(const char *argv[])
+{
+       int status = 0;
+       pid_t pid;
+       pid = fork();
+       switch (pid) {
+       case -1:
+               perror("fork failed");
+               return -1;
+       case 0:
+               /* child */
+               execvp(argv[0], (char *const *)argv);
+               _exit(-1);
+       default:
+               /* parent */
+               break;
+       }
+       if (waitpid(pid, &status, 0) == -1) {
+               perror("waitpid failed");
+               return -1;
+       }
+       if (WIFSIGNALED(status)) {
+               perror("signal");
+               return -1;
+       }
+       if (!WIFEXITED(status)) {
+               /* shouldn't happen */
+               perror("should not happen");
+               return -1;
+       }
+       return WEXITSTATUS(status);
+}
+
+int main(int argc, char *argv[])
+{
+       int ret;
+
+       if (!__is_authorized()) {
+               fprintf(stderr, "You are not an authorized user!\n");
+               _D("You are not an authorized user!\n");
+               return AIL_ERROR_FAIL;
+       }
+
+       const char *argv_rm[] = { "/bin/rm", APP_INFO_DB_FILE, NULL };
+       xsystem(argv_rm);
+       const char *argv_rmjn[] = { "/bin/rm", APP_INFO_DB_FILE_JOURNAL, NULL };
+       xsystem(argv_rmjn);
+
+       ret = setenv("AIL_INITDB", "1", 1);
+       _D("AIL_INITDB : %d", ret);
+
+       ret = initdb_count_app();
+       if (ret > 0) {
+               _D("Some Apps in the App Info DB.");
+       }
+
+       ret = initdb_load_directory(OPT_DESKTOP_DIRECTORY);
+       if (ret == AIL_ERROR_FAIL) {
+               _E("cannot load opt desktop directory.");
+       }
+
+       ret = initdb_load_directory(USR_DESKTOP_DIRECTORY);
+       if (ret == AIL_ERROR_FAIL) {
+               _E("cannot load usr desktop directory.");
+       }
+
+       ret = initdb_change_perm(APP_INFO_DB_FILE);
+       if (ret == AIL_ERROR_FAIL) {
+               _E("cannot chown.");
+       }
+
+       const char *argv_smack[] = { "/usr/bin/chsmack", "-a", APP_INFO_DB_LABEL, APP_INFO_DB_FILE, NULL };
+       xsystem(argv_smack);
+       const char *argv_smackjn[] = { "/usr/bin/chsmack", "-a", APP_INFO_DB_LABEL, APP_INFO_DB_FILE_JOURNAL, NULL };
+       xsystem(argv_smackjn);
+
+       return AIL_ERROR_OK;
+}
+
+
+
+// END
diff --git a/tool/src/ail_package.c b/tool/src/ail_package.c
new file mode 100644 (file)
index 0000000..8a2a717
--- /dev/null
@@ -0,0 +1,181 @@
+/*
+ * ail
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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"
+
+char *prop_tbl[] = {
+       AIL_PROP_PACKAGE_STR,
+       AIL_PROP_EXEC_STR,
+       AIL_PROP_NAME_STR,
+       AIL_PROP_TYPE_STR,
+       AIL_PROP_ICON_STR,
+       AIL_PROP_CATEGORIES_STR,
+       AIL_PROP_VERSION_STR,
+       AIL_PROP_MIMETYPE_STR,
+       AIL_PROP_X_SLP_SERVICE_STR,
+       AIL_PROP_X_SLP_PACKAGETYPE_STR,
+       AIL_PROP_X_SLP_PACKAGECATEGORIES_STR,
+       AIL_PROP_X_SLP_PACKAGEID_STR,
+       AIL_PROP_X_SLP_SVC_STR,
+       AIL_PROP_X_SLP_EXE_PATH,
+       AIL_PROP_X_SLP_APPID_STR,
+       AIL_PROP_X_SLP_PKGID_STR,
+       AIL_PROP_X_SLP_DOMAIN_STR,
+       AIL_PROP_X_SLP_SUBMODEMAINID_STR,
+       AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR,
+       AIL_PROP_NODISPLAY_BOOL,
+       AIL_PROP_X_SLP_TASKMANAGE_BOOL,
+       AIL_PROP_X_SLP_MULTIPLE_BOOL,
+       AIL_PROP_X_SLP_REMOVABLE_BOOL,
+       AIL_PROP_X_SLP_SUBMODE_BOOL,
+       NULL
+};
+
+
+static void _print_help(const char *cmd)
+{
+       int i;
+
+       fprintf(stderr, "Usage:\n");
+       fprintf(stderr, "\n");
+       fprintf(stderr, "[Get appinfo value]\n");
+       fprintf(stderr, "       %s get <PACKAGE NAME> <COLUMN NAME>\n", cmd);
+       fprintf(stderr, "\n");
+       fprintf(stderr, "       <COLUMN NAME>\n");
+
+       for (i = 0; prop_tbl[i]; i++) {
+               fprintf(stderr, "          %s\n", prop_tbl[i]);
+       }
+
+       fprintf(stderr, "\n");
+       fprintf(stderr, "       Ex) %s get com.samsung.menu-screen X_SLP_SERVICE\n", cmd);
+       fprintf(stderr, "\n");
+}
+
+
+
+static int _get_property(const char *property)
+{
+       int i;
+
+       if (!property) {
+               return 0;
+       }
+
+       for (i = 0; prop_tbl[i]; i++) {
+               if (!strcasecmp(prop_tbl[i], property)) {
+                       return i;
+               }
+       }
+
+       fprintf(stderr, "%s is not found\n", property);
+
+       return -1;
+}
+
+
+
+static ail_error_e _get_appinfo(const char *package, const char *property)
+{
+       ail_appinfo_h handle;
+       ail_error_e ret;
+       int prop, ival;
+       bool bval;
+       char *str;
+       struct element e;
+       struct element *p;
+       int t;
+
+       ret = ail_package_get_appinfo(package, &handle);
+       if (ret != AIL_ERROR_OK) {
+               return AIL_ERROR_FAIL;
+       }
+
+       prop = _get_property(property);
+       if (prop < 0) {
+               goto END;
+       }
+
+       e.prop = prop;
+       p = &e;
+       ELEMENT_TYPE(p,t);
+
+       if (t == VAL_TYPE_STR) {
+               ret = ail_appinfo_get_str(handle, property, &str);
+               if (ret != AIL_ERROR_OK) {
+                       goto END;
+               }
+               fprintf(stderr, "Package[%s], Property[%s] : %s\n", package, property, str);
+       } else if (t == VAL_TYPE_INT) {
+               ret = ail_appinfo_get_int(handle, property, &ival);
+               if (ret != AIL_ERROR_OK) {
+                       goto END;
+               }
+               fprintf(stderr, "Package[%s], Property[%s] : %d\n", package, property, ival);
+       } else if (t == VAL_TYPE_BOOL) {
+               ret = ail_appinfo_get_bool(handle, property, &bval);
+               if (ret != AIL_ERROR_OK) {
+                       goto END;
+               }
+               fprintf(stderr, "Package[%s], Property[%s] : %d\n", package, property, bval);
+       }
+
+END:
+       ret = ail_package_destroy_appinfo(handle);
+       if (ret != AIL_ERROR_OK) {
+               return AIL_ERROR_FAIL;
+       }
+
+       return AIL_ERROR_OK;
+}
+
+int main(int argc, char** argv)
+{
+       ail_error_e ret = AIL_ERROR_OK;
+
+
+       if (4 == argc) {
+               if (!strncmp(argv[1], "get", 3)) {
+                       ret = _get_appinfo(argv[2], argv[3]);
+               }
+       }
+       else {
+               _print_help(argv[0]);
+               return EXIT_FAILURE;
+       }
+
+       if (ret != AIL_ERROR_OK) {
+               fprintf(stderr, "There are some problems\n");
+       }
+
+       return EXIT_SUCCESS;
+}
+
+
diff --git a/tool/src/initdb.c b/tool/src/initdb.c
new file mode 100755 (executable)
index 0000000..1bba847
--- /dev/null
@@ -0,0 +1,289 @@
+/*
+ * ail
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * 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 <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <dirent.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <errno.h>
+
+#include "ail.h"
+#include "ail_private.h"
+
+#define OWNER_ROOT 0
+#define GROUP_MENU 6010
+#define BUFSZE 1024
+#define OPT_DESKTOP_DIRECTORY "/opt/share/applications"
+#define USR_DESKTOP_DIRECTORY "/usr/share/applications"
+#define APP_INFO_DB_FILE "/opt/dbspace/.app_info.db"
+#define APP_INFO_DB_FILE_JOURNAL "/opt/dbspace/.app_info.db-journal"
+#define APP_INFO_DB_LABEL "ail::db"
+
+#ifdef _E
+#undef _E
+#endif
+#define _E(fmt, arg...) fprintf(stderr, "[AIL_INITDB][E][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg);
+
+#ifdef _D
+#undef _D
+#endif
+#define _D(fmt, arg...) fprintf(stderr, "[AIL_INITDB][D][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg);
+
+static int initdb_count_app(void)
+{
+       ail_filter_h filter;
+       ail_error_e ret;
+       int total = 0;
+
+       ret = ail_filter_new(&filter);
+       if (ret != AIL_ERROR_OK) {
+               return -1;
+       }
+
+       ret = ail_filter_add_bool(filter, AIL_PROP_NODISPLAY_BOOL, false);
+       if (ret != AIL_ERROR_OK) {
+               ail_filter_destroy(filter);
+               return -1;
+       }
+
+       ret = ail_filter_count_appinfo(filter, &total);
+       if (ret != AIL_ERROR_OK) {
+               ail_filter_destroy(filter);
+               return -1;
+       }
+
+       ail_filter_destroy(filter);
+
+       return total;
+}
+
+
+
+char* _desktop_to_package(const char* desktop)
+{
+       char *package, *tmp;
+
+       retv_if(!desktop, NULL);
+
+       package = strdup(desktop);
+       retv_if(!package, NULL);
+
+       tmp = strrchr(package, '.');
+       if(tmp == NULL) {
+               _E("[%s] is not a desktop file", package);
+               free(package);
+               return NULL;
+       }
+
+       if (strcmp(tmp, ".desktop")) {
+               _E("%s is not a desktop file", desktop);
+               free(package);
+               return NULL;
+       }
+
+       *tmp = '\0';
+
+       return package;
+}
+
+
+
+int initdb_load_directory(const char *directory)
+{
+       DIR *dir;
+       struct dirent entry, *result;
+       int len, ret;
+       char buf[BUFSZE];
+       int total_cnt = 0;
+       int ok_cnt = 0;
+
+       // desktop file
+       dir = opendir(directory);
+       if (!dir) {
+               if (strerror_r(errno, buf, sizeof(buf)) == 0)
+                       _E("Failed to access the [%s] because %s\n", directory, buf);
+               return AIL_ERROR_FAIL;
+       }
+
+       len = strlen(directory) + 1;
+       _D("Loading desktop files from %s", directory);
+
+       for (ret = readdir_r(dir, &entry, &result);
+                       ret == 0 && result != NULL;
+                       ret = readdir_r(dir, &entry, &result)) {
+               char *package;
+
+               if (entry.d_name[0] == '.') continue;
+               total_cnt++;
+               package = _desktop_to_package(entry.d_name);
+               if (!package) {
+                       _E("Failed to convert file to package[%s]", entry.d_name);
+                       continue;
+               }
+
+               if (ail_desktop_add(package) != AIL_ERROR_OK) {
+                       _E("Failed to add a package[%s]", package);
+               } else {
+                       ok_cnt++;
+               }
+               free(package);
+       }
+
+       _D("Application-Desktop process : Success [%d], fail[%d], total[%d] \n", ok_cnt, total_cnt-ok_cnt, total_cnt);
+       closedir(dir);
+
+       return AIL_ERROR_OK;
+}
+
+
+
+static int initdb_change_perm(const char *db_file)
+{
+       char buf[BUFSZE];
+       char journal_file[BUFSZE];
+       char *files[3];
+       int ret, i;
+
+       files[0] = (char *)db_file;
+       files[1] = journal_file;
+       files[2] = NULL;
+
+       retv_if(!db_file, AIL_ERROR_FAIL);
+
+       snprintf(journal_file, sizeof(journal_file), "%s%s", db_file, "-journal");
+
+       for (i = 0; files[i]; i++) {
+               ret = chown(files[i], OWNER_ROOT, OWNER_ROOT);
+               if (ret == -1) {
+                       strerror_r(errno, buf, sizeof(buf));
+                       _E("FAIL : chown %s %d.%d, because %s", db_file, OWNER_ROOT, OWNER_ROOT, buf);
+                       return AIL_ERROR_FAIL;
+               }
+
+               ret = chmod(files[i], S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+               if (ret == -1) {
+                       strerror_r(errno, buf, sizeof(buf));
+                       _E("FAIL : chmod %s 0664, because %s", db_file, buf);
+                       return AIL_ERROR_FAIL;
+               }
+       }
+
+       return AIL_ERROR_OK;
+}
+
+
+static int __is_authorized()
+{
+       /* ail_init db should be called by as root privilege. */
+
+       uid_t uid = getuid();
+       if ((uid_t) 0 == uid)
+               return 1;
+       else
+               return 0;
+}
+
+int xsystem(const char *argv[])
+{
+       int status = 0;
+       pid_t pid;
+       pid = fork();
+       switch (pid) {
+       case -1:
+               perror("fork failed");
+               return -1;
+       case 0:
+               /* child */
+               execvp(argv[0], (char *const *)argv);
+               _exit(-1);
+       default:
+               /* parent */
+               break;
+       }
+       if (waitpid(pid, &status, 0) == -1) {
+               perror("waitpid failed");
+               return -1;
+       }
+       if (WIFSIGNALED(status)) {
+               perror("signal");
+               return -1;
+       }
+       if (!WIFEXITED(status)) {
+               /* shouldn't happen */
+               perror("should not happen");
+               return -1;
+       }
+       return WEXITSTATUS(status);
+}
+
+int main(int argc, char *argv[])
+{
+       int ret;
+
+       if (!__is_authorized()) {
+               fprintf(stderr, "You are not an authorized user!\n");
+               _D("You are not an authorized user!\n");
+               return AIL_ERROR_FAIL;
+       }
+
+       const char *argv_rm[] = { "/bin/rm", APP_INFO_DB_FILE, NULL };
+       xsystem(argv_rm);
+       const char *argv_rmjn[] = { "/bin/rm", APP_INFO_DB_FILE_JOURNAL, NULL };
+       xsystem(argv_rmjn);
+
+       ret = setenv("AIL_INITDB", "1", 1);
+       _D("AIL_INITDB : %d", ret);
+
+       ret = initdb_count_app();
+       if (ret > 0) {
+               _D("Some Apps in the App Info DB.");
+       }
+
+       ret = initdb_load_directory(OPT_DESKTOP_DIRECTORY);
+       if (ret == AIL_ERROR_FAIL) {
+               _E("cannot load opt desktop directory.");
+       }
+
+       ret = initdb_load_directory(USR_DESKTOP_DIRECTORY);
+       if (ret == AIL_ERROR_FAIL) {
+               _E("cannot load usr desktop directory.");
+       }
+
+       ret = initdb_change_perm(APP_INFO_DB_FILE);
+       if (ret == AIL_ERROR_FAIL) {
+               _E("cannot chown.");
+       }
+
+       const char *argv_smack[] = { "/usr/bin/chsmack", "-a", APP_INFO_DB_LABEL, APP_INFO_DB_FILE, NULL };
+       xsystem(argv_smack);
+       const char *argv_smackjn[] = { "/usr/bin/chsmack", "-a", APP_INFO_DB_LABEL, APP_INFO_DB_FILE_JOURNAL, NULL };
+       xsystem(argv_smackjn);
+
+       return AIL_ERROR_OK;
+}
+
+
+
+// END
diff --git a/tool/src/main.c.head b/tool/src/main.c.head
new file mode 100644 (file)
index 0000000..fd2da68
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics, Inc.
+ * All rights reserved.
+ *
+ * This software is a confidential and proprietary information
+ * of Samsung Electronics, Inc. ("Confidential Information").  You
+ * shall not disclose such Confidential Information and shall use
+ * it only in accordance with the terms of the license agreement
+ * you entered into with Samsung Electronics.
+ */
+
+#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"
+
diff --git a/tool/src/main.c.tail b/tool/src/main.c.tail
new file mode 100644 (file)
index 0000000..271f1ad
--- /dev/null
@@ -0,0 +1,121 @@
+
+
+static void _print_help(const char *cmd)
+{
+       int i;
+
+       fprintf(stderr, "Usage:\n");
+       fprintf(stderr, "\n");
+       fprintf(stderr, "[Get appinfo value]\n");
+       fprintf(stderr, "       %s get <PACKAGE NAME> <COLUMN NAME>\n", cmd);
+       fprintf(stderr, "\n");
+       fprintf(stderr, "       <COLUMN NAME>\n");
+
+       for (i = 0; prop_tbl[i]; i++) {
+               fprintf(stderr, "          %s\n", prop_tbl[i]);
+       }
+
+       fprintf(stderr, "\n");
+       fprintf(stderr, "       Ex) %s get com.samsung.menu-screen X_SLP_SERVICE\n", cmd);
+       fprintf(stderr, "\n");
+}
+
+
+
+static int _get_property(const char *property)
+{
+       int i;
+
+       if (!property) {
+               return 0;
+       }
+
+       for (i = 0; prop_tbl[i]; i++) {
+               if (!strcasecmp(prop_tbl[i], property)) {
+                       return i;
+               }
+       }
+
+       fprintf(stderr, "%s is not found\n", property);
+
+       return -1;
+}
+
+
+
+static ail_error_e _get_appinfo(const char *package, const char *property)
+{
+       ail_appinfo_h handle;
+       ail_error_e ret;
+       int prop, ival;
+       bool bval;
+       char *str;
+       struct element e;
+       struct element *p;
+       int t;
+
+       ret = ail_package_get_appinfo(package, &handle);
+       if (ret != AIL_ERROR_OK) {
+               return AIL_ERROR_FAIL;
+       }
+
+       prop = _get_property(property);
+       if (prop < 0) {
+               return AIL_ERROR_FAIL;
+       }
+
+       e.prop = prop;
+       p = &e;
+       ELEMENT_TYPE(p,t);
+
+       if (t == VAL_TYPE_STR) {
+               ret = ail_appinfo_get_str(handle, prop, &str);
+               if (ret != AIL_ERROR_OK) {
+                       return AIL_ERROR_FAIL;
+               }
+               fprintf(stderr, "Package[%s], Property[%s] : %s\n", package, property, str);
+       } else if (t == VAL_TYPE_INT) {
+               ret = ail_appinfo_get_int(handle, prop, &ival);
+               if (ret != AIL_ERROR_OK) {
+                       return AIL_ERROR_FAIL;
+               }
+               fprintf(stderr, "Package[%s], Property[%s] : %d\n", package, property, ival);
+       } else if (t == VAL_TYPE_BOOL) {
+               ret = ail_appinfo_get_bool(handle, prop, &bval);
+               if (ret != AIL_ERROR_OK) {
+                       return AIL_ERROR_FAIL;
+               }
+               fprintf(stderr, "Package[%s], Property[%s] : %d\n", package, property, bval);
+       }
+
+       ret = ail_package_destroy_appinfo(handle);
+       if (ret != AIL_ERROR_OK) {
+               return AIL_ERROR_FAIL;
+       }
+
+       return AIL_ERROR_OK;
+}
+
+int main(int argc, char** argv)
+{
+       ail_error_e ret = AIL_ERROR_OK;
+
+       
+       if (4 == argc) {
+               if (!strncmp(argv[1], "get", 3)) {
+                       ret = _get_appinfo(argv[2], argv[3]);
+               }
+       }
+       else {
+               _print_help(argv[0]);
+               return EXIT_FAILURE;
+       }
+
+       if (ret != AIL_ERROR_OK) {
+               fprintf(stderr, "There are some problems\n");
+       }
+
+       return EXIT_SUCCESS;
+}
+
+