#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-
#include <db-util.h>
+#include <aul.h>
/* For multi-user support */
#include <tzplatform_config.h>
static int __create_table(sqlite3 *db);
static sqlite3 *__db_init();
-int rua_clear_history(void)
+int rua_delete_history_from_db(bundle *b)
{
int r;
- char query[QUERY_MAXLEN];
sqlite3 *db = NULL;
+ char query[QUERY_MAXLEN];
+
+ char *pkg_name = NULL;
+ char *app_path = NULL;
+ char *errmsg = NULL;
+ int result = 0;
db = __db_init();
if (db == NULL) {
return -1;
}
- snprintf(query, QUERY_MAXLEN, "delete from %s;", RUA_HISTORY);
-
- r = __exec(db, query);
- db_util_close(db);
- return r;
-}
+ if (b != NULL) {
+ bundle_get_str(b, AUL_K_RUA_PKGNAME, &pkg_name);
+ bundle_get_str(b, AUL_K_RUA_APPPATH, &app_path);
+ }
-int rua_delete_history_with_pkgname(char *pkg_name)
-{
- int r;
- char query[QUERY_MAXLEN];
+ if (pkg_name != NULL)
+ snprintf(query, QUERY_MAXLEN, "delete from rua_history where pkg_name = '%s';", pkg_name);
+ else if (app_path != NULL)
+ snprintf(query, QUERY_MAXLEN, "delete from rua_history where app_path = '%s';", app_path);
+ else
+ snprintf(query, QUERY_MAXLEN, "delete from rua_history;");
- sqlite3 *db = NULL;
+ LOGI("rua_delete_history_from_db : %s", query);
+ r = sqlite3_exec(db, query, NULL, NULL, &errmsg);
- db = __db_init();
- if (db == NULL) {
- LOGE("Error db null");
- return -1;
+ if (r != SQLITE_OK) {
+ LOGE("fail to exec delete query %s : %s", query, errmsg);
+ sqlite3_free(errmsg);
+ result = -1;
}
- if (pkg_name == NULL) {
+ if (db != NULL)
db_util_close(db);
- return -1;
- }
- snprintf(query, QUERY_MAXLEN, "delete from %s where pkg_name = '%s';",
- RUA_HISTORY, pkg_name);
+ return result;
- r = __exec(db, query);
- db_util_close(db);
- return r;
}
-int rua_delete_history_with_apppath(char *app_path)
+int rua_clear_history(void)
{
int r;
- char query[QUERY_MAXLEN];
- sqlite3 *db = NULL;
+ r = aul_delete_rua_history(NULL);
+ LOGI("rua_clear_history result : %d ", r);
+ return r;
+}
- db = __db_init();
- if (db == NULL) {
- LOGE("Error db null");
+int rua_delete_history_with_pkgname(char *pkg_name)
+{
+ int r;
+ bundle *b = bundle_create();
+ if (b == NULL) {
+ LOGE("bundle_create fail out of memory.");
return -1;
}
- if (app_path == NULL) {
- db_util_close(db);
+ bundle_add_str(b, AUL_K_RUA_PKGNAME, pkg_name);
+ r = aul_delete_rua_history(b);
+ LOGI("rua_delete_history_with_pkgname result : %d ", r);
+ bundle_free(b);
+ return r;
+}
+
+int rua_delete_history_with_apppath(char *app_path)
+{
+ int r;
+ bundle *b = bundle_create();
+ if (b == NULL) {
+ LOGE("bundle_create fail out of memory.");
return -1;
}
- snprintf(query, QUERY_MAXLEN, "delete from %s where app_path = '%s';",
- RUA_HISTORY, app_path);
+ bundle_add_str(b, AUL_K_RUA_APPPATH, app_path);
+ r = aul_delete_rua_history(b);
+ LOGI("rua_delete_history_with_apppath result : %d ", r);
+ bundle_free(b);
- r = __exec(db, query);
- db_util_close(db);
return r;
}