/*
- * RUA
- *
- * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jayoun Lee <airjany@samsung.com>
+ * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
*/
#ifndef __RUA_SCHEMA_H__
-#endif /* __RUA_SCHEMA_H__ */
+#endif /* __RUA_SCHEMA_H__ */
/*
- * RUA
- *
- * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jayoun Lee <airjany@samsung.com>
+ * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
*/
-#ifndef __PERF_MEASURE__
-#define __PERF_MEASURE__
+#ifndef __PERF_MEASURE_H__
+#define __PERF_MEASURE_H__
#include <time.h>
-
-//#define PERF_MEASURE_ENABLE
-
#ifdef __cplusplus
extern "C" {
#endif
#endif
-
-
-
-
-
-
-
-
-
-
-
-
#ifdef __cplusplus
}
#endif
-#endif /*__PERF_MEASURE__*/
+#endif /* __PERF_MEASURE_H__ */
/*
- * RUA
- *
- * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jayoun Lee <airjany@samsung.com>
+ * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
*/
/**
time_t launch_time; /**< application launching time */
};
-
-
/**
* @brief Delete history from DB
* @return 0 on success, otherwise a nagative error value
/*
- * RUA STAT
- *
- * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
*/
/**
#ifdef __cplusplus
}
#endif
-#endif /*__RUA_STAT_H__*/
+#endif /*__RUA_STAT_H__*/
/*
- * RUA
- *
- * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jayoun Lee <airjany@samsung.com>
+ * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
*/
-
#include <stdio.h>
#include <sys/time.h>
/*
- * RUA
- *
- * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jayoun Lee <airjany@samsung.com>
+ * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
- */
-
-/*
- * @file rua.c
- * @version 0.1
*/
#include <stdio.h>
sqlite3_stmt *stmt;
sqlite3 *db = NULL;
- unsigned int timestamp;
- timestamp = PERF_MEASURE_START("RUA");
-
db = __db_init();
if (db == NULL) {
LOGE("Error db null");
RUA_HISTORY,
rec->pkg_name ? rec->pkg_name : "",
rec->app_path ? rec->app_path : "",
- rec->arg ? rec->arg : "", time(NULL));
+ rec->arg ? rec->arg : "", (int)time(NULL));
else
/* update */
snprintf(query, QUERY_MAXLEN,
"update %s set arg='%s', launch_time='%d' where pkg_name = '%s';",
RUA_HISTORY,
- rec->arg ? rec->arg : "", time(NULL), rec->pkg_name);
+ rec->arg ? rec->arg : "", (int)time(NULL), rec->pkg_name);
r = __exec(db, query);
if (r == -1) {
return -1;
}
- PERF_MEASURE_END("RUA", timestamp);
db_util_close(db);
return r;
}
db_result = table + ((row + 1) * ncols);
tmp = db_result[RUA_COL_ID];
- if (tmp) {
+ if (tmp)
rec->id = atoi(tmp);
- }
tmp = db_result[RUA_COL_PKGNAME];
- if (tmp) {
+ if (tmp)
rec->pkg_name = tmp;
- }
tmp = db_result[RUA_COL_APPPATH];
- if (tmp) {
+ if (tmp)
rec->app_path = tmp;
- }
tmp = db_result[RUA_COL_ARG];
- if (tmp) {
+ if (tmp)
rec->arg = tmp;
- }
tmp = db_result[RUA_COL_LAUNCHTIME];
- if (tmp) {
+ if (tmp)
rec->launch_time = atoi(tmp);
- }
return 0;
}
goto out;
}
- if (strncmp(pkg_name, ct, strlen(pkg_name)) == 0) {
+ if (strncmp(pkg_name, (const char *)ct, strlen(pkg_name)) == 0) {
r = 0;
goto out;
}
/*
- * RUA
- *
- * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
*/
/*
return 0;
}
-int __rua_stat_insert(char *caller, char *rua_stat_tag) {
-
+int __rua_stat_insert(char *caller, char *rua_stat_tag)
+{
int r;
char query[QUERY_MAXLEN];
sqlite3_stmt *stmt = NULL;
+
sqlite3_snprintf(QUERY_MAXLEN, query,
"INSERT INTO rua_panel_stat (caller_panel, rua_stat_tag, score) VALUES (?,?,?)");
}
r = sqlite3_bind_text(stmt, 1, caller, strlen(caller), SQLITE_STATIC);
- if(r != SQLITE_OK) {
+ if (r != SQLITE_OK) {
LOGE("caller bind error(%d) \n", r);
goto out;
}
r = sqlite3_bind_text(stmt, 2, rua_stat_tag, strlen(rua_stat_tag), SQLITE_STATIC);
- if(r != SQLITE_OK) {
+ if (r != SQLITE_OK) {
LOGE("rua_stat_tag bind error(%d) \n", r);
goto out;
}
r = sqlite3_bind_int(stmt, 3, WIN_SCORE);
- if(r != SQLITE_OK) {
+ if (r != SQLITE_OK) {
LOGE("arg bind error(%d) \n", r);
goto out;
}
goto out;
}
-
-out :
- if(stmt)
+out:
+ if (stmt)
sqlite3_finalize(stmt);
return r;
}
-int __rua_stat_lose_score_update(char *caller, char *rua_stat_tag) {
-
+int __rua_stat_lose_score_update(char *caller, char *rua_stat_tag)
+{
int r;
char query[QUERY_MAXLEN];
sqlite3_stmt *stmt = NULL;
+
sqlite3_snprintf(QUERY_MAXLEN, query,
"UPDATE rua_panel_stat SET score = score * %f WHERE caller_panel = ? AND rua_stat_tag != ?",
LOSE_SCORE_RATE);
LOGD("lose score update sql : %s", query);
-
r = sqlite3_prepare(_db, query, sizeof(query), &stmt, NULL);
if (r != SQLITE_OK) {
LOGE("sqlite3_prepare error(%d , %d, %s)", r, sqlite3_extended_errcode(_db), sqlite3_errmsg(_db));
}
r = sqlite3_bind_text(stmt, 1, caller, strlen(caller), SQLITE_STATIC);
- if(r != SQLITE_OK) {
+ if (r != SQLITE_OK) {
LOGE("caller bind error(%d) \n", r);
goto out;
}
r = sqlite3_bind_text(stmt, 2, rua_stat_tag, strlen(rua_stat_tag), SQLITE_STATIC);
- if(r != SQLITE_OK) {
+ if (r != SQLITE_OK) {
LOGE("rua_stat_tag bind error(%d) \n", r);
goto out;
}
goto out;
}
-
-out :
- if(stmt)
+out:
+ if (stmt)
sqlite3_finalize(stmt);
return r;
-
}
-int __rua_stat_win_score_update(char *caller, char *rua_stat_tag) {
-
+int __rua_stat_win_score_update(char *caller, char *rua_stat_tag)
+{
int r;
char query[QUERY_MAXLEN];
sqlite3_stmt *stmt = NULL;
+
sqlite3_snprintf(QUERY_MAXLEN, query,
"UPDATE rua_panel_stat SET score = score + %d WHERE caller_panel = ? AND rua_stat_tag = ?",
WIN_SCORE);
}
r = sqlite3_bind_text(stmt, 1, caller, strlen(caller), SQLITE_STATIC);
- if(r != SQLITE_OK) {
+ if (r != SQLITE_OK) {
LOGE("caller bind error(%d) \n", r);
goto out;
}
r = sqlite3_bind_text(stmt, 2, rua_stat_tag, strlen(rua_stat_tag), SQLITE_STATIC);
- if(r != SQLITE_OK) {
+ if (r != SQLITE_OK) {
LOGE("rua_stat_tag bind error(%d) \n", r);
goto out;
}
goto out;
}
-
-out :
- if(stmt)
+out:
+ if (stmt)
sqlite3_finalize(stmt);
return r;
-
}
int rua_stat_update(char *caller, char *rua_stat_tag)
{
int r;
int affected_rows = 0;
- sqlite3_stmt *stmt = NULL;
LOGD("rua_stat_update start");
}
-int rua_stat_get_stat_tags(char *caller, int (*rua_stat_tag_iter_fn)(const char *rua_stat_tag, void *data),
- void *data) {
-
+int rua_stat_get_stat_tags(char *caller,
+ int (*rua_stat_tag_iter_fn)(const char *rua_stat_tag, void *data),
+ void *data)
+{
int r;
sqlite3_stmt *stmt;
char query[QUERY_MAXLEN];
goto out;
}
- while(sqlite3_step(stmt) == SQLITE_ROW) {
-
+ while (sqlite3_step(stmt) == SQLITE_ROW) {
ct = sqlite3_column_text(stmt, 0);
- if (ct == NULL || ct[0] == '\0') {
+ if (ct == NULL || ct[0] == '\0')
LOGW("sqlite3_column_text null");
- }
- rua_stat_tag_iter_fn(ct, data);
+
+ rua_stat_tag_iter_fn((const char *)ct, data);
}
out:
/*
- * RUA
- *
- * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jayoun Lee <airjany@samsung.com>
+ * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
*/
#include <stdio.h>
#include "rua.h"
-int __add_history(char *pkgname)
+static int __add_history(char *pkgname)
{
- int ret = 0;
+ int ret;
struct rua_rec rec;
- const char *apppath = tzplatform_mkpath(TZ_SYS_RW_APP, pkgname);
memset(&rec, 0, sizeof(rec));
rec.pkg_name = pkgname;
- rec.app_path = apppath;
-
- ret = rua_init();
- if (ret) {
- fprintf(stderr, "error rua_init()\n");
- return -1;
- }
+ rec.app_path = (char *)tzplatform_mkpath(TZ_SYS_RW_APP, pkgname);
ret = rua_add_history(&rec);
- rua_fini();
-
return ret;
}