--#sbs-git:slp/pkgs/a/ail ail 0.2.22 29ac1f2c98453cad647cca6a92abc7da3dbb047b
Name: ail
Summary: Application Information Library
- Version: 0.2.68
+ Version: 0.2.73
Release: 1
Group: System/Libraries
License: Apache License, Version 2.0
Source0: %{name}-%{version}.tar.gz
+Source1001: ail.manifest
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
BuildRequires: cmake
%prep
%setup -q
+cp %{SOURCE1001} .
%build
CFLAGS+=" -fpic"
%install
%make_install
+mkdir -p %{buildroot}/opt/dbspace/
+mkdir -p %{buildroot}/opt/share/applications/
+
%post
- vconftool set -t string db/ail/ail_info "0" -f
- vconftool set -t string db/menuscreen/desktop "0" -f
- vconftool set -t string db/menu_widget/language "en_US.utf8" -f
+ vconftool set -t string db/ail/ail_info "0" -f -s system::vconf_inhouse
+ vconftool set -t string db/menuscreen/desktop "0" -f -s system::vconf_inhouse
++vconftool set -t string db/menu_widget/language "en_US.utf8" -f -s system::vconf_inhouse
CHDBGID="6010"
echo "Failed to change the perms of $@"
fi
}
-mkdir -p /opt/dbspace/
ail_initdb
update_DAC_for_db_file /opt/dbspace/.app_info.db
update_DAC_for_db_file /opt/dbspace/.app_info.db-journal
-chsmack -a 'ail::db' /opt/dbspace/.app_info.db*
%postun
+if [ $1 == 0 ]; then
+rm -f /opt/dbspace/.app_info.db*
+fi
%files
-%manifest ail.manifest
+%manifest %{name}.manifest
%{_libdir}/libail.so.0
%{_libdir}/libail.so.0.1.0
- /opt/dbspace
+/opt/share/applications
/usr/bin/ail_initdb
/usr/share/install-info/*
%files devel
+%manifest %{name}.manifest
/usr/include/ail.h
%{_libdir}/libail.so
%{_libdir}/pkgconfig/ail.pc
.dbrw = NULL
};
+
+static ail_error_e db_do_prepare(sqlite3 *db, const char *query, sqlite3_stmt **stmt)
+{
+ int ret;
+
+ retv_if(!query, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!stmt, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!db, AIL_ERROR_DB_FAILED);
+
+ ret = sqlite3_prepare_v2(db, query, strlen(query), stmt, NULL);
+ if (ret != SQLITE_OK) {
+ _E("%s\n", sqlite3_errmsg(db));
+ return AIL_ERROR_DB_FAILED;
+ } else
+ return AIL_ERROR_OK;
+}
+
ail_error_e db_open(db_open_mode mode)
{
int ret;
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);
- _E("db_open_ro ret=%d", ret);
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);
- _E("db_open_rw ret=%d", ret);
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)
{
- int ret;
-
- retv_if(!query, AIL_ERROR_INVALID_PARAMETER);
- retv_if(!stmt, AIL_ERROR_INVALID_PARAMETER);
- retv_if(!db_info.dbro, AIL_ERROR_DB_FAILED);
+ return db_do_prepare(db_info.dbro, query, stmt);
+}
- ret = sqlite3_prepare_v2(db_info.dbro, query, strlen(query), stmt, NULL);
- if (ret != SQLITE_OK) {
- _E("%s\n", sqlite3_errmsg(db_info.dbro));
- return AIL_ERROR_DB_FAILED;
- } else
- return AIL_ERROR_OK;
+ail_error_e db_prepare_rw(const char *query, sqlite3_stmt **stmt)
+{
+ return db_do_prepare(db_info.dbrw, query, stmt);
}
return AIL_ERROR_OK;
}
+ail_error_e db_bind_text(sqlite3_stmt *stmt, int idx, char* value)
+{
+ int ret;
+
+ retv_if(!stmt, AIL_ERROR_INVALID_PARAMETER);
+
+ ret = sqlite3_bind_text(stmt, idx, value, strlen(value), 0);
+ retv_with_dbmsg_if(ret != SQLITE_OK, AIL_ERROR_DB_FAILED);
+
+ return AIL_ERROR_OK;
+}
ail_error_e db_step(sqlite3_stmt *stmt)
#define whitespace(c) (((c) == ' ') || ((c) == '\t'))
#define argsdelimiter " \t"
+#define SQL_INSERT_LOCALNAME_STR "insert into localname (package, locale, name) values "
+#define SQL_INSERT_LOCALNAME_STR_LEN (sizeof(SQL_INSERT_LOCALNAME_STR)-1)
+
+#define SQL_INSERT_LOCALNAME_INIT_STR SQL_INSERT_LOCALNAME_STR"( ?, ?, ?) "
+
+#define SQL_LOCALNAME_TRIPLET_STR ", ( ?, ?, ?)"
+#define SQL_LOCALNAME_TRIPLET_STR_LEN (sizeof(SQL_LOCALNAME_TRIPLET_STR)-1)
+
typedef enum {
NOTI_ADD,
NOTI_UPDATE,
return desktop;
}
+static inline int _bind_local_info(desktop_info_s* info, sqlite3_stmt * stmt)
+{
+ int ret = 0;
+ unsigned long i = 0;
+ struct name_item *item;
+ GSList* localname;
+ retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!info->localname, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!stmt, AIL_ERROR_INVALID_PARAMETER);
+ localname = info->localname;
+ while (localname) {
+ item = (struct name_item *) localname->data;
+ if (item && item->locale && item->name) {
+ // Bind values for a triplet : package, locale, name
+ retv_if(db_bind_text(stmt, i+1, info->package) != AIL_ERROR_OK, AIL_ERROR_DB_FAILED);
+ retv_if(db_bind_text(stmt, i+2, item->locale) != AIL_ERROR_OK, AIL_ERROR_DB_FAILED);
+ retv_if(db_bind_text(stmt, i+3, item->name) != AIL_ERROR_OK, AIL_ERROR_DB_FAILED);
+ i += 3;
+ }
+ localname = g_slist_next(localname);
+ }
+ return AIL_ERROR_OK;
+}
+
+
+static inline int _len_local_info(desktop_info_s* info)
+{
+ int len = 0;
+ struct name_item *item;
+ GSList* localname;
+ retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
+ if(info->localname) {
+ localname = info->localname;
+ while (localname) {
+ item = (struct name_item *) localname->data;
+ if (item && item->locale && item->name)
+ len ++;
+ localname = g_slist_next(localname);
+ }
+ }
+ return len;
+}
+
+
+static inline int _insert_local_info(desktop_info_s* info)
+{
+ int len_query = SQL_INSERT_LOCALNAME_STR_LEN;
+ int nb_locale_args;
+ char *query;
+ int ret = AIL_ERROR_OK;
+ sqlite3_stmt *stmt = NULL;
+ int i = 0;
+ retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!info->localname, AIL_ERROR_INVALID_PARAMETER);
+ nb_locale_args = _len_local_info(info);
+
+ retv_if(!nb_locale_args, AIL_ERROR_INVALID_PARAMETER);
+
+ len_query += SQL_LOCALNAME_TRIPLET_STR_LEN*nb_locale_args +1;
+
+ query = (char *) malloc(len_query);
+ retv_if(!query, AIL_ERROR_OUT_OF_MEMORY);
+ stpncpy(query, SQL_INSERT_LOCALNAME_INIT_STR, len_query);
+ for (i = 0; i < nb_locale_args - 1; i++)
+ strcat(query, SQL_LOCALNAME_TRIPLET_STR);
+
+ do {
+ ret = db_prepare_rw(query, &stmt);
+ if (ret < 0) break;
+
+ ret = _bind_local_info(info, stmt);
+ if (ret < 0) {
+ _E("Can't bind locale information to this query - %s. ",query);
+ db_finalize(stmt);
+ break;
+ }
+ ret = db_step(stmt);
+ if (ret != AIL_ERROR_NO_DATA) {
+ /* Insert Request doesn't return any data.
+ * db_step should returns AIL_ERROR_NO_DATA in this case. */
+ _E("Can't execute this query - %s. ",query);
+ db_finalize(stmt);
+ break;
+ }
+ ret = db_finalize(stmt);
+ } while(0);
+
+ free(query);
+ return ret;
+}
static inline int _strlen_desktop_info(desktop_info_s* info)
{
"desktop TEXT UNIQUE NOT NULL);",
"CREATE TABLE localname (package TEXT NOT NULL, "
"locale TEXT NOT NULL, "
- "name TEXT NOT NULL, PRIMARY KEY (package, locale));",
+ "name TEXT NOT NULL, "
+ "x_slp_pkgid TEXT NOT NULL, PRIMARY KEY (package, locale));",
+
NULL
};
struct name_item *item = (struct name_item *)data;
desktop_info_s *info = (desktop_info_s *)user_data;
- snprintf(query, sizeof(query), "insert into localname (package, locale, name) "
- "values ('%s', '%s', '%s');",
- info->package, item->locale, item->name);
+ snprintf(query, sizeof(query), "insert into localname (package, locale, name, x_slp_pkgid) "
+ "values ('%s', '%s', '%s', '%s');",
+ info->package, item->locale, item->name, info->x_slp_pkgid);
if (db_exec(query) < 0)
_E("Failed to insert local name of package[%s]",info->package);
}
}
ret = db_exec(query);
+ free(query);
retv_if(ret != AIL_ERROR_OK, AIL_ERROR_DB_FAILED);
if (info->localname)
- g_slist_foreach(info->localname, _insert_localname, info);
+ _insert_local_info(info);
_D("Add (%s).", info->package);
}
if (info->localname)
- g_slist_foreach(info->localname, _insert_localname, info);
+ _insert_local_info(info);
_D("Update (%s).", info->package);
return AIL_ERROR_OK;
}
+ static ail_error_e _clean_pkgid_data(const char* pkgid)
+ {
+ char *query;
+ int size;
+
+ retv_if(!pkgid, AIL_ERROR_INVALID_PARAMETER);
+
+ if (db_open(DB_OPEN_RW) < 0) {
+ return AIL_ERROR_DB_FAILED;
+ }
+
+ size = strlen(pkgid) + (0x01 << 10);
+ query = calloc(1, size);
+ retv_if(!query, AIL_ERROR_OUT_OF_MEMORY);
+
+ snprintf(query, size, "delete from app_info where x_slp_pkgid = '%s'", pkgid);
+
+ if (db_exec(query) < 0) {
+ free(query);
+ return AIL_ERROR_DB_FAILED;
+ }
+
+ snprintf(query, size, "delete from localname where x_slp_pkgid = '%s'", pkgid);
+ _D("query=%s",query);
+
+ if (db_exec(query) < 0) {
+ free(query);
+ return AIL_ERROR_DB_FAILED;
+ }
+
+ _D("Clean pkgid data (%s).", pkgid);
+ free(query);
+
+ return AIL_ERROR_OK;
+ }
static ail_error_e _send_db_done_noti(noti_type type, const char *package)
return AIL_ERROR_OK;
}
+ EXPORT_API ail_error_e ail_desktop_clean(const char *pkgid)
+ {
+ ail_error_e ret;
+
+ retv_if(!pkgid, AIL_ERROR_INVALID_PARAMETER);
+ if (!__is_authorized()) {
+ _E("You are not an authorized user on removing!\n");
+ return -1;
+ }
+
+ _D("ail_desktop_clean=%s",pkgid);
+
+ ret = _clean_pkgid_data(pkgid);
+ retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
+
+ return AIL_ERROR_OK;
+ }
+
EXPORT_API ail_error_e ail_desktop_appinfo_modify_bool(const char *appid,
const char *property,