summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhyunho <hhstark.kang@samsung.com>2019-06-11 19:22:29 +0900
committerhyunho <hhstark.kang@samsung.com>2019-06-12 11:41:59 +0900
commit94b405cad4e2f5678bbd85bc956fce6874cbb087 (patch)
treec5b95c3ad249e4118394fb7e8c818e9ebfa70ac9 /src
parent2e43df2ca1fb71b58c5f502c4831acda0f191081 (diff)
downloadlibrua-94b405cad4e2f5678bbd85bc956fce6874cbb087.tar.gz
librua-94b405cad4e2f5678bbd85bc956fce6874cbb087.tar.bz2
librua-94b405cad4e2f5678bbd85bc956fce6874cbb087.zip
Add component ID
Change-Id: I9b7c31c8bd518cfe7ada5af1703e9dea6ceeb9c4 Signed-off-by: hyunho <hhstark.kang@samsung.com>
Diffstat (limited to 'src')
-rw-r--r--src/db-schema.h4
-rw-r--r--src/rua.c10
-rw-r--r--src/rua_internal.c26
3 files changed, 26 insertions, 14 deletions
diff --git a/src/db-schema.h b/src/db-schema.h
index eb64cfd..97724b7 100644
--- a/src/db-schema.h
+++ b/src/db-schema.h
@@ -25,12 +25,13 @@ CREATE TABLE IF NOT EXISTS rua_history ( \
app_path TEXT, \
arg TEXT, \
launch_time INTEGER, \
+ comp_id TEXT, \
instance_id TEXT, \
instance_name TEXT, \
icon TEXT, \
uri TEXT, \
image TEXT, \
- PRIMARY KEY(pkg_name, instance_id) \
+ PRIMARY KEY(pkg_name, comp_id, instance_id) \
);"
#define CREATE_RUA_STAT_TABLE " \
@@ -54,6 +55,7 @@ enum {
RUA_COL_ICON,
RUA_COL_URI,
RUA_COL_IMAGE,
+ RUA_COL_COMP_ID,
};
enum {
diff --git a/src/rua.c b/src/rua.c
index 91fd385..a3f24c5 100644
--- a/src/rua.c
+++ b/src/rua.c
@@ -134,8 +134,8 @@ API int rua_clear_history(void)
API int rua_history_load_db_for_uid(char ***table, int *nrows, int *ncols, uid_t uid)
{
static const char query[] =
- "SELECT pkg_name, app_path, arg, launch_time, instance_id,"
- " instance_name, icon, uri, image "
+ "SELECT pkg_name, app_path, arg, launch_time, comp_id,"
+ " instance_id, instance_name, icon, uri, image "
"FROM rua_history ORDER BY launch_time DESC";
int r;
char *db_err = NULL;
@@ -247,6 +247,12 @@ API int rua_history_get_rec(struct rua_rec *rec, char **table, int nrows, int nc
if (tmp)
rec->launch_time = atoi(tmp);
+ tmp = db_result[RUA_COL_COMP_ID];
+ if (tmp && tmp[0] != '\0')
+ rec->comp_id = tmp;
+ else
+ rec->comp_id = NULL;
+
tmp = db_result[RUA_COL_INSTANCE_ID];
if (tmp && tmp[0] != '\0')
rec->instance_id = tmp;
diff --git a/src/rua_internal.c b/src/rua_internal.c
index 808dd96..8f4cf98 100644
--- a/src/rua_internal.c
+++ b/src/rua_internal.c
@@ -217,9 +217,9 @@ static int __insert_history(sqlite3 *db, struct rua_rec *rec)
static const char query[] =
"INSERT OR REPLACE INTO rua_history ("
" pkg_name, app_path, arg, launch_time,"
- " instance_id, instance_name, icon, uri,"
+ " comp_id, instance_id, instance_name, icon, uri,"
" image) "
- "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
int r;
sqlite3_stmt *stmt;
int idx = 1;
@@ -234,6 +234,7 @@ static int __insert_history(sqlite3 *db, struct rua_rec *rec)
__BIND_TEXT(db, stmt, idx++, rec->app_path);
__BIND_TEXT(db, stmt, idx++, rec->arg ? rec->arg : "");
__BIND_INT(db, stmt, idx++, (int)rec->launch_time);
+ __BIND_TEXT(db, stmt, idx++, rec->comp_id ? rec->comp_id : "");
__BIND_TEXT(db, stmt, idx++, rec->instance_id ? rec->instance_id : "");
__BIND_TEXT(db, stmt, idx++,
rec->instance_name ? rec->instance_name : "");
@@ -257,7 +258,7 @@ static int __update_history(sqlite3 *db, struct rua_rec *rec)
{
static const char query[] =
"UPDATE rua_history SET launch_time=? "
- "WHERE pkg_name=? AND instance_id=?";
+ "WHERE pkg_name=? AND comp_id=? AND instance_id=?";
int r;
sqlite3_stmt *stmt;
int idx = 1;
@@ -270,6 +271,7 @@ static int __update_history(sqlite3 *db, struct rua_rec *rec)
__BIND_INT(db, stmt, idx++, (int)rec->launch_time);
__BIND_TEXT(db, stmt, idx++, rec->pkg_name);
+ __BIND_TEXT(db, stmt, idx++, rec->comp_id);
__BIND_TEXT(db, stmt, idx++, rec->instance_id);
r = sqlite3_step(stmt);
@@ -328,12 +330,12 @@ API int rua_db_add_history(struct rua_rec *rec)
return rua_usr_db_add_history(rec, getuid());
}
-static int __update_image(sqlite3 *db, const char *pkg_name,
+static int __update_image(sqlite3 *db, const char *pkg_name, const char *comp_id,
const char *instance_id, const char *image)
{
static const char query[] =
"UPDATE rua_history SET image=? "
- "WHERE pkg_name=? AND instance_id=?";
+ "WHERE pkg_name=? AND comp_id=? AND instance_id=?";
sqlite3_stmt *stmt;
int idx = 1;
int r;
@@ -346,6 +348,7 @@ static int __update_image(sqlite3 *db, const char *pkg_name,
__BIND_TEXT(db, stmt, idx++, image);
__BIND_TEXT(db, stmt, idx++, pkg_name);
+ __BIND_TEXT(db, stmt, idx++, comp_id ? comp_id : "");
__BIND_TEXT(db, stmt, idx++, instance_id ? instance_id : "");
r = sqlite3_step(stmt);
@@ -359,8 +362,8 @@ static int __update_image(sqlite3 *db, const char *pkg_name,
return 0;
}
-API int rua_usr_db_update_image(const char *pkg_name, const char *instance_id,
- const char *image, uid_t uid)
+API int rua_usr_db_update_image(const char *pkg_name, const char *comp_id,
+ const char *instance_id, const char *image, uid_t uid)
{
int r;
sqlite3 *db;
@@ -376,7 +379,7 @@ API int rua_usr_db_update_image(const char *pkg_name, const char *instance_id,
return -1;
}
- r = __update_image(db, pkg_name, instance_id, image);
+ r = __update_image(db, pkg_name, comp_id, instance_id, image);
if (r < 0) {
LOGE("Failed to update image - appid(%s)", pkg_name);
sqlite3_close_v2(db);
@@ -393,8 +396,9 @@ API int rua_usr_db_update_image(const char *pkg_name, const char *instance_id,
return r;
}
-API int rua_db_update_image(const char *pkg_name, const char *instance_id,
- const char *image)
+API int rua_db_update_image(const char *pkg_name, const char *comp_id,
+ const char *instance_id, const char *image)
{
- return rua_usr_db_update_image(pkg_name, instance_id, image, getuid());
+ return rua_usr_db_update_image(
+ pkg_name, comp_id, instance_id, image, getuid());
}