/**
* @brief Update the image of the application
* @param[in] pkg_name The application ID
+ * @param[in] comp_id The component ID
* @param[in] instance_id The instance ID
* @param[in] image The image of the application
* @return 0 on success, otherwise a nagative error value
*/
-int rua_db_update_image(const char *pkg_name, const char *instance_id,
- const char *image);
-int rua_usr_db_update_image(const char *pkg_name, const char *instance_id,
- const char *image, uid_t uid);
+int rua_db_update_image(const char *pkg_name, const char *comp_id,
+ const char *instance_id, const char *image);
+int rua_usr_db_update_image(const char *pkg_name, const char *comp_id,
+ const char *instance_id, const char *image, uid_t uid);
#ifdef __cplusplus
}
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;
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;
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;
__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 : "");
{
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;
__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);
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;
__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);
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;
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);
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());
}