summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorInkyun Kil <inkyun.kil@samsung.com>2017-04-18 17:01:35 +0900
committerInkyun Kil <inkyun.kil@samsung.com>2017-04-18 17:51:57 +0900
commit1b03e41c0ed9ee3add6722e0addb170021fb92cc (patch)
treecc7fece64d3c456e61be9532762a20d2a3a44174 /src
parentc800203e1f51383f1e832ea314f2e71f341a679c (diff)
downloadlibrua-1b03e41c0ed9ee3add6722e0addb170021fb92cc.tar.gz
librua-1b03e41c0ed9ee3add6722e0addb170021fb92cc.tar.bz2
librua-1b03e41c0ed9ee3add6722e0addb170021fb92cc.zip
Fix bug for deleting history from previous patch
Change-Id: I313e491ae27aa620f6422f8c2c358c24754b473f Signed-off-by: Inkyun Kil <inkyun.kil@samsung.com>
Diffstat (limited to 'src')
-rw-r--r--src/rua_internal.c39
1 files changed, 33 insertions, 6 deletions
diff --git a/src/rua_internal.c b/src/rua_internal.c
index b3b94af..f39df16 100644
--- a/src/rua_internal.c
+++ b/src/rua_internal.c
@@ -88,12 +88,11 @@ static int __delete_history_with_pkg_name(sqlite3 *db, const char *pkg_name,
r = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
if (r != SQLITE_OK) {
LOGE("prepare failed: %s", sqlite3_errmsg(db));
- sqlite3_close_v2(db);
return -1;
}
__BIND_TEXT(db, stmt, idx++, pkg_name);
- __BIND_TEXT(db, stmt, idx++, instance_id);
+ __BIND_TEXT(db, stmt, idx++, instance_id ? instance_id : "");
r = sqlite3_step(stmt);
if (r != SQLITE_DONE) {
@@ -119,12 +118,35 @@ static int __delete_history_with_app_path(sqlite3 *db, const char *app_path,
r = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
if (r != SQLITE_OK) {
LOGE("prepare failed: %s", sqlite3_errmsg(db));
- sqlite3_close_v2(db);
return -1;
}
__BIND_TEXT(db, stmt, idx++, app_path);
- __BIND_TEXT(db, stmt, idx++, instance_id);
+ __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;
+}
+
+static int __clear_history(sqlite3 *db)
+{
+ static const char query[] = "DELETE FROM rua_history";
+ sqlite3_stmt *stmt;
+ 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;
+ }
r = sqlite3_step(stmt);
if (r != SQLITE_DONE) {
@@ -165,12 +187,17 @@ API int rua_usr_db_delete_history(bundle *b, uid_t uid)
LOGI("rua_delete_history_from_db : %s", app_path);
r = __delete_history_with_app_path(db, app_path, instance_id);
} else {
- LOGE("No data to delete history");
- return -1;
+ LOGI("rua clear history");
+ r = __clear_history(db);
}
sqlite3_close_v2(db);
+ if (r == -1) {
+ LOGE("Failed to delete history");
+ return -1;
+ }
+
r = rua_dbus_send_update_signal(DELETE);
if (r == -1) {
LOGE("[RUA SEND SIGNAL ERROR] \n");