summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHwankyu Jhun <h.jhun@samsung.com>2017-06-28 20:25:54 +0900
committerHwankyu Jhun <h.jhun@samsung.com>2017-06-30 10:20:08 +0900
commitad448ddd37cfaf556cd58d92c5d58c5d0d2edaf4 (patch)
tree0d0a898cfecc93ef97e4bec1d824ca5575f0e6ce
parent5135eccca0b4520db4b9f8e3291d6a1e6e2ddd81 (diff)
downloadlibrua-accepted/tizen_3.0_wearable.tar.gz
librua-accepted/tizen_3.0_wearable.tar.bz2
librua-accepted/tizen_3.0_wearable.zip
- Adds a new column of the image path - Adds a new APIs to update the image path Change-Id: Idd4e4a1e474360ee618c8994059796cbd3dcae34 Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
-rw-r--r--include/rua.h1
-rw-r--r--include/rua_internal.h12
-rw-r--r--src/db-schema.h2
-rw-r--r--src/rua.c8
-rw-r--r--src/rua_dbus.h3
-rw-r--r--src/rua_internal.c77
6 files changed, 99 insertions, 4 deletions
diff --git a/include/rua.h b/include/rua.h
index eb27c07..a2dfe34 100644
--- a/include/rua.h
+++ b/include/rua.h
@@ -60,6 +60,7 @@ struct rua_rec {
char *instance_name; /**< Instance Name */
char *icon; /**< Icon path */
char *uri; /**< URI */
+ char *image; /**< Image path */
};
/**
diff --git a/include/rua_internal.h b/include/rua_internal.h
index 4140a25..ec496d8 100644
--- a/include/rua_internal.h
+++ b/include/rua_internal.h
@@ -53,6 +53,18 @@ int rua_usr_db_delete_history(bundle *b, uid_t uid);
int rua_db_add_history(struct rua_rec *rec);
int rua_usr_db_add_history(struct rua_rec *rec, uid_t uid);
+/**
+ * @brief Update the image of the application
+ * @param[in] pkg_name The application 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);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/db-schema.h b/src/db-schema.h
index b2e322b..eb64cfd 100644
--- a/src/db-schema.h
+++ b/src/db-schema.h
@@ -29,6 +29,7 @@ CREATE TABLE IF NOT EXISTS rua_history ( \
instance_name TEXT, \
icon TEXT, \
uri TEXT, \
+ image TEXT, \
PRIMARY KEY(pkg_name, instance_id) \
);"
@@ -52,6 +53,7 @@ enum {
RUA_COL_INSTANCE_NAME,
RUA_COL_ICON,
RUA_COL_URI,
+ RUA_COL_IMAGE,
};
enum {
diff --git a/src/rua.c b/src/rua.c
index 2612817..ff921b6 100644
--- a/src/rua.c
+++ b/src/rua.c
@@ -135,7 +135,7 @@ API int rua_history_load_db_for_uid(char ***table, int *nrows, int *ncols, uid_t
{
static const char query[] =
"SELECT pkg_name, app_path, arg, launch_time, instance_id,"
- " instance_name, icon, uri "
+ " instance_name, icon, uri, image "
"FROM rua_history ORDER BY launch_time DESC";
int r;
char *db_err = NULL;
@@ -269,6 +269,12 @@ API int rua_history_get_rec(struct rua_rec *rec, char **table, int nrows, int nc
else
rec->uri = NULL;
+ tmp = db_result[RUA_COL_IMAGE];
+ if (tmp && tmp[0] != '\0')
+ rec->image = tmp;
+ else
+ rec->image = NULL;
+
return 0;
}
diff --git a/src/rua_dbus.h b/src/rua_dbus.h
index 1b53963..76789a9 100644
--- a/src/rua_dbus.h
+++ b/src/rua_dbus.h
@@ -20,7 +20,8 @@
typedef enum
{
ADD,
- DELETE
+ DELETE,
+ UPDATE
} update_type;
int rua_dbus_send_update_signal(update_type type);
diff --git a/src/rua_internal.c b/src/rua_internal.c
index f39df16..8ce257c 100644
--- a/src/rua_internal.c
+++ b/src/rua_internal.c
@@ -217,8 +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) "
- "VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
+ " instance_id, instance_name, icon, uri,"
+ " image) "
+ "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
int r;
sqlite3_stmt *stmt;
int idx = 1;
@@ -238,6 +239,7 @@ static int __insert_history(sqlite3 *db, struct rua_rec *rec)
rec->instance_name ? rec->instance_name : "");
__BIND_TEXT(db, stmt, idx++, rec->icon ? rec->icon : "");
__BIND_TEXT(db, stmt, idx++, rec->uri ? rec->uri : "");
+ __BIND_TEXT(db, stmt, idx++, rec->image ? rec->image : "");
r = sqlite3_step(stmt);
if (r != SQLITE_DONE) {
@@ -320,3 +322,74 @@ 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,
+ const char *instance_id, const char *image)
+{
+ static const char query[] =
+ "UPDATE rua_history SET image=? "
+ "WHERE pkg_name=? AND instance_id=?";
+ sqlite3_stmt *stmt;
+ int idx = 1;
+ int r;
+
+ r = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
+ if (r != SQLITE_OK) {
+ LOGE("Prepare failed: %s", sqlite3_errmsg(db));
+ return -1;
+ }
+
+ __BIND_TEXT(db, stmt, idx++, image);
+ __BIND_TEXT(db, stmt, idx++, pkg_name);
+ __BIND_TEXT(db, stmt, idx++, instance_id ? instance_id : "");
+
+ r = sqlite3_step(stmt);
+ if (r != SQLITE_DONE) {
+ LOGE("Step failed: %s", sqlite3_errmsg(db));
+ sqlite3_finalize(stmt);
+ return -1;
+ }
+ sqlite3_finalize(stmt);
+
+ return 0;
+}
+
+API int rua_usr_db_update_image(const char *pkg_name, const char *instance_id,
+ const char *image, uid_t uid)
+{
+ int r;
+ sqlite3 *db;
+
+ if (pkg_name == NULL || image == NULL) {
+ LOGE("Invalid parameter");
+ return -1;
+ }
+
+ db = __db_init(uid);
+ if (db == NULL) {
+ LOGE("Error db null");
+ return -1;
+ }
+
+ r = __update_image(db, pkg_name, instance_id, image);
+ if (r < 0) {
+ LOGE("Failed to update image - appid(%s)", pkg_name);
+ sqlite3_close_v2(db);
+ return -1;
+ }
+ sqlite3_close_v2(db);
+
+ r = rua_dbus_send_update_signal(UPDATE);
+ if (r < 0) {
+ LOGE("[RUA SEND SIGNAL ERROR]");
+ return -1;
+ }
+
+ return r;
+}
+
+API int rua_db_update_image(const char *pkg_name, const char *instance_id,
+ const char *image)
+{
+ return rua_usr_db_update_image(pkg_name, instance_id, image, getuid());
+}