INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED sqlite3 db-util libtzplatform-config bundle aul gio-2.0)
+pkg_check_modules(pkgs REQUIRED sqlite3 db-util libtzplatform-config bundle aul gio-2.0 glib-2.0)
FOREACH(flag ${pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${FULLVER})
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
-CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
-#CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc @ONLY)
+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY)
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/rua_internal.h DESTINATION include/${PROJECT_NAME})
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/rua_stat.h DESTINATION include/${PROJECT_NAME})
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/rua_stat_internal.h DESTINATION include/${PROJECT_NAME})
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/rua_util.h DESTINATION include/${PROJECT_NAME})
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/rua_dbus.h DESTINATION include/${PROJECT_NAME})
-
ADD_SUBDIRECTORY(test)
#ifndef __RUA_H__
#define __RUA_H__
-#include <sqlite3.h>
-#include <bundle.h>
#include <time.h>
-#include <unistd.h>
#include <sys/types.h>
-#include <dlog.h>
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-
-#define LOG_TAG "RUA"
-
-#ifndef API
-#define API __attribute__ ((visibility("default")))
-#endif
-
#ifdef __cplusplus
extern "C" {
#endif
* @retval 0 on successful
* @retval -1 on failed
*/
-API int rua_add_history_for_uid(char *pkg_name, char *app_path, char *arg, uid_t uid);
+int rua_add_history_for_uid(char *pkg_name, char *app_path, char *arg, uid_t uid);
/**
* @brief Delete history with pkg_name
* @retval 0 on successful
* @retval -1 on failed
*/
-API int rua_delete_history_with_pkgname(char *pkg_name);
-API int rua_delete_history_with_pkgname_for_uid(char *pkg_name, uid_t uid);
+int rua_delete_history_with_pkgname(char *pkg_name);
+int rua_delete_history_with_pkgname_for_uid(char *pkg_name, uid_t uid);
/**
* @brief Delete history with app_path
* @retval 0 on successful
* @retval -1 on failed
*/
-API int rua_delete_history_with_apppath(char *app_path);
-API int rua_delete_history_with_apppath_for_uid(char *app_path, uid_t uid);
+int rua_delete_history_with_apppath(char *app_path);
+int rua_delete_history_with_apppath_for_uid(char *app_path, uid_t uid);
/**
* @brief Clear history
* @retval 0 on successful
* @retval -1 on failed
*/
-API int rua_clear_history(void);
-API int rua_clear_history_for_uid(uid_t uid);
+int rua_clear_history(void);
+int rua_clear_history_for_uid(uid_t uid);
/**
* @brief Load recently used application history db.
* @retval 0 on successful
* @retval -1 on failed
*/
-API int rua_history_load_db(char ***table, int *nrows, int *ncols);
-API int rua_history_load_db_for_uid(char ***table, int *nrows, int *ncols, uid_t uid);
+int rua_history_load_db(char ***table, int *nrows, int *ncols);
+int rua_history_load_db_for_uid(char ***table, int *nrows, int *ncols, uid_t uid);
/**
* @brief Unload recently used application history db.
* @retval 0 on successful
* @retval -1 on failed
*/
-API int rua_history_unload_db(char ***table);
+int rua_history_unload_db(char ***table);
/**
* @brief Load recently used application record.
* @retval 0 on successful
* @retval -1 on failed
*/
-API int rua_history_get_rec(struct rua_rec *rec, char **table,
+int rua_history_get_rec(struct rua_rec *rec, char **table,
int nrows, int ncols, int row);
/**
* @retval 0 if given pkg_name is lastest application
* @retval -1 if not lastest applicaton or on failed
*/
-API int rua_is_latest_app(const char *pkg_name);
-API int rua_is_latest_app_for_uid(const char *pkg_name, uid_t uid);
+int rua_is_latest_app(const char *pkg_name);
+int rua_is_latest_app_for_uid(const char *pkg_name, uid_t uid);
/**
* @brief Delete rua history with instance id
* @param[in] instance_id The instance ID
* @return 0 on success, otherwise a negative error value
*/
-API int rua_delete_history_with_instance_id(const char *app_id,
+int rua_delete_history_with_instance_id(const char *app_id,
const char *instance_id);
/**
* @retval 0 if on successful
* @retval -1 if it is already registered or on failed
*/
-API int rua_register_update_cb(rua_history_update_cb callback,
+int rua_register_update_cb(rua_history_update_cb callback,
void *user_data, int *callback_id);
-API int rua_register_update_cb_for_uid(rua_history_update_cb callback,
+int rua_register_update_cb_for_uid(rua_history_update_cb callback,
void *user_data, int *callback_id, uid_t uid);
/**
* @retval 0 if on successful
* @retval -1 if the callback was not registered or on failed
*/
-API int rua_unregister_update_cb(int callback_id);
-API int rua_unregister_update_cb_for_uid(int callback_id, uid_t uid);
+int rua_unregister_update_cb(int callback_id);
+int rua_unregister_update_cb_for_uid(int callback_id, uid_t uid);
/**
* @brief Initialize rua
* @retval 0 on successful
* @retval -1 on failed
*/
-API int rua_init(void);
+int rua_init(void);
/**
* @brief Finalize rua
* @retval 0 on successful
* @retval -1 on failed
*/
-API int rua_fini(void);
+int rua_fini(void);
#ifdef __cplusplus
}
#ifndef __RUA_INTERNAL_H__
#define __RUA_INTERNAL_H__
-#include <unistd.h>
#include <sys/types.h>
-#include <sqlite3.h>
#include <bundle.h>
-#include <time.h>
-#include <dlog.h>
#include "rua.h"
-#ifndef API
-#define API __attribute__ ((visibility("default")))
-#endif
-
#ifdef __cplusplus
extern "C" {
#endif
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-
-#define LOG_TAG "RUA"
-#define RUA_DB_NAME ".rua.db"
-#define RUA_HISTORY "rua_history"
-#define QUERY_MAXLEN 4096
-#define MAX_UID_STR_BUFSZ 20
-
/**
* @brief Delete history from DB
* @return 0 on success, otherwise a nagative error value
* @retval 0 on successful
* @retval -1 on failed
*/
-API int rua_db_delete_history(bundle *b);
-API int rua_usr_db_delete_history(bundle *b, uid_t uid);
+int rua_db_delete_history(bundle *b);
+int rua_usr_db_delete_history(bundle *b, uid_t uid);
/**
* @brief Add application to recently used application list
* @retval 0 on successful
* @retval -1 on failed
*/
-API int rua_db_add_history(struct rua_rec *rec);
-API int rua_usr_db_add_history(struct rua_rec *rec, 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);
#ifdef __cplusplus
}
#ifndef __RUA_STAT_H__
#define __RUA_STAT_H__
-#include <unistd.h>
#include <sys/types.h>
-#include <sqlite3.h>
-#include <bundle.h>
-
-#ifndef API
-#define API __attribute__ ((visibility("default")))
-#endif
#ifdef __cplusplus
extern "C" {
* @retval 0 on successful
* @retval -1 on failed
*/
-API int rua_stat_update_for_uid(char *caller, char *tag, uid_t uid);
+int rua_stat_update_for_uid(char *caller, char *tag, uid_t uid);
/**
* @brief Get rua status tag list
* @retval 0 on successful
* @retval -1 on failed
*/
-API int rua_stat_get_stat_tags(char *caller,
+int rua_stat_get_stat_tags(char *caller,
int (*rua_stat_tag_iter_fn)(const char *rua_stat_tag, void *data), void *data);
-API int rua_stat_get_stat_tags_for_uid(char *caller,
+int rua_stat_get_stat_tags_for_uid(char *caller,
int (*rua_stat_tag_iter_fn)(const char *rua_stat_tag, void *data),
void *data, uid_t uid);
#ifdef __cplusplus
#ifndef __RUA_STAT_INTERNAL_H__
#define __RUA_STAT_INTERNAL_H__
-#include <sqlite3.h>
-#include <dlog.h>
-
-#ifndef API
-#define API __attribute__ ((visibility("default")))
-#endif
-
#ifdef __cplusplus
extern "C" {
#endif
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-
-#define LOG_TAG "RUA"
-
-#define RUA_STAT_DB_NAME ".rua_stat.db"
-#define QUERY_MAXLEN 4096
-#define WIN_SCORE 100
-#define LOSE_SCORE_RATE 0.7f
-
-int _rua_stat_init(sqlite3 **db, char *db_name, int flags, uid_t uid);
-
/**
* @brief Add application launch status.
* @param[in] caller, rua_stat_tag
* @retval 0 on successful
* @retval -1 on failed
*/
-API int rua_stat_db_update(char *caller, char *rua_stat_tag);
-API int rua_stat_usr_db_update(char *caller, char *rua_stat_tab, uid_t uid);
+int rua_stat_db_update(char *caller, char *rua_stat_tag);
+int rua_stat_usr_db_update(char *caller, char *rua_stat_tab, uid_t uid);
#ifdef __cplusplus
}
BuildRequires: pkgconfig(sqlite3)
BuildRequires: pkgconfig(libtzplatform-config)
BuildRequires: pkgconfig(gio-2.0)
+BuildRequires: pkgconfig(glib-2.0)
%define upgrade_script_path /usr/share/upgrade/scripts
Name: rua
Description: recently used application library
Version: @VERSION@
-Requires: sqlite3
+Requires: bundle
Libs: -L${libdir} -lrua
Cflags: -I${includedir}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
+
#include <db-util.h>
#include <aul.h>
+#include <dlog.h>
#include "rua_util.h"
-#include "rua_internal.h"
#include "rua.h"
#include "db-schema.h"
#include "rua_dbus.h"
+#include "rua_private.h"
-int rua_add_history_for_uid(char *pkg_name, char *app_path, char *arg, uid_t uid)
+API int rua_add_history_for_uid(char *pkg_name, char *app_path, char *arg, uid_t uid)
{
int r;
char time_str[32] = {0,};
return r;
}
-int rua_delete_history_with_pkgname(char *pkg_name)
-{
- return rua_delete_history_with_pkgname_for_uid(pkg_name, getuid());
-}
-
-int rua_delete_history_with_pkgname_for_uid(char *pkg_name, uid_t uid)
+API int rua_delete_history_with_pkgname_for_uid(char *pkg_name, uid_t uid)
{
int r;
bundle *b;
return r;
}
-int rua_delete_history_with_apppath(char *app_path)
+API int rua_delete_history_with_pkgname(char *pkg_name)
{
- return rua_delete_history_with_apppath_for_uid(app_path, getuid());
+ return rua_delete_history_with_pkgname_for_uid(pkg_name, getuid());
}
-int rua_delete_history_with_apppath_for_uid(char *app_path, uid_t uid)
+API int rua_delete_history_with_apppath_for_uid(char *app_path, uid_t uid)
{
int r;
bundle *b;
return r;
}
-int rua_clear_history(void)
+API int rua_delete_history_with_apppath(char *app_path)
{
- return rua_clear_history_for_uid(getuid());
+ return rua_delete_history_with_apppath_for_uid(app_path, getuid());
}
-int rua_clear_history_for_uid(uid_t uid)
+API int rua_clear_history_for_uid(uid_t uid)
{
int r;
return r;
}
-int rua_history_load_db(char ***table, int *nrows, int *ncols)
+API int rua_clear_history(void)
{
- return rua_history_load_db_for_uid(table, nrows, ncols, getuid());
+ return rua_clear_history_for_uid(getuid());
}
-int rua_history_load_db_for_uid(char ***table, int *nrows, int *ncols, uid_t uid)
+API int rua_history_load_db_for_uid(char ***table, int *nrows, int *ncols, uid_t uid)
{
int r;
char query[QUERY_MAXLEN];
return r;
}
-int rua_register_update_cb(rua_history_update_cb callback, void *user_data, int *callback_id)
+API int rua_history_load_db(char ***table, int *nrows, int *ncols)
{
- return rua_register_update_cb_for_uid(callback, user_data, callback_id, getuid());
+ return rua_history_load_db_for_uid(table, nrows, ncols, getuid());
}
-int rua_register_update_cb_for_uid(rua_history_update_cb callback, void *user_data, int *callback_id, uid_t uid)
+API int rua_register_update_cb_for_uid(rua_history_update_cb callback, void *user_data, int *callback_id, uid_t uid)
{
int r;
return r;
}
-int rua_unregister_update_cb(int callback_id)
+API int rua_register_update_cb(rua_history_update_cb callback, void *user_data, int *callback_id)
{
- return rua_unregister_update_cb_for_uid(callback_id, getuid());
+ return rua_register_update_cb_for_uid(callback, user_data, callback_id, getuid());
}
-int rua_unregister_update_cb_for_uid(int callback_id, uid_t uid)
+API int rua_unregister_update_cb_for_uid(int callback_id, uid_t uid)
{
int r;
return r;
}
-int rua_history_unload_db(char ***table)
+API int rua_unregister_update_cb(int callback_id)
{
- if (*table) {
- sqlite3_free_table(*table);
- *table = NULL;
- return 0;
- }
- return -1;
+ return rua_unregister_update_cb_for_uid(callback_id, getuid());
}
-int rua_history_get_rec(struct rua_rec *rec, char **table, int nrows, int ncols,
+API int rua_history_get_rec(struct rua_rec *rec, char **table, int nrows, int ncols,
int row)
{
char **db_result = NULL;
return 0;
}
-int rua_is_latest_app(const char *pkg_name)
+API int rua_history_unload_db(char ***table)
{
- return rua_is_latest_app_for_uid(pkg_name, getuid());
+ if (*table) {
+ sqlite3_free_table(*table);
+ *table = NULL;
+ return 0;
+ }
+ return -1;
}
-int rua_is_latest_app_for_uid(const char *pkg_name, uid_t uid)
+API int rua_is_latest_app_for_uid(const char *pkg_name, uid_t uid)
{
int r = -1;
sqlite3_stmt *stmt;
return r;
}
-int rua_init(void)
+API int rua_is_latest_app(const char *pkg_name)
+{
+ return rua_is_latest_app_for_uid(pkg_name, getuid());
+}
+
+API int rua_init(void)
{
return 0;
}
-int rua_fini(void)
+API int rua_fini(void)
{
return 0;
}
-int rua_delete_history_with_instance_id(const char *app_id,
+API int rua_delete_history_with_instance_id(const char *app_id,
const char *instance_id)
{
int ret;
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <glib.h>
#include <gio/gio.h>
+#include <dlog.h>
#include "rua.h"
#include "rua_dbus.h"
+#include "rua_private.h"
#define RUA_INTERFACE "org.tizen.rua"
#define RUA_PATH "/org/tizen/rua"
* limitations under the License.
*/
-/**
- * @file rua_dbus.h
- * @brief RUA DBUS API declaration header file.
- * @version 0.1
- * @history 0.1: RUA DBUS API Declarations, structure declaration
- */
-
#ifndef __RUA_DBUS_H__
#define __RUA_DBUS_H__
-#include <unistd.h>
-#include <stdlib.h>
-#include <dlog.h>
-
-#ifndef API
-#define API __attribute__ ((visibility("default")))
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-
-#define LOG_TAG "RUA"
-
typedef enum
{
ADD,
void *user_data, int *callback_id);
int rua_dbus_signal_unsubscribe(int callback_id);
-#ifdef __cplusplus
-}
-#endif
#endif /*__RUA_DBUS_H__*/
* limitations under the License.
*/
+#include <stdio.h>
+#include <sys/types.h>
+#include <unistd.h>
+
#include <db-util.h>
#include <aul.h>
+#include <dlog.h>
+#include <sqlite3.h>
#include "rua_internal.h"
#include "db-schema.h"
#include "rua_util.h"
#include "rua_dbus.h"
+#include "rua_private.h"
static int __exec(sqlite3 *db, char *query)
{
return db;
}
-int rua_db_delete_history(bundle *b)
+API int rua_db_delete_history(bundle *b)
{
return rua_usr_db_delete_history(b, getuid());
}
-int rua_usr_db_delete_history(bundle *b, uid_t uid)
+API int rua_usr_db_delete_history(bundle *b, uid_t uid)
{
int r;
sqlite3 *db = NULL;
return result;
}
-int rua_db_add_history(struct rua_rec *rec)
+API int rua_db_add_history(struct rua_rec *rec)
{
return rua_usr_db_add_history(rec, getuid());
}
-int rua_usr_db_add_history(struct rua_rec *rec, uid_t uid)
+API int rua_usr_db_add_history(struct rua_rec *rec, uid_t uid)
{
int r;
char query[QUERY_MAXLEN];
--- /dev/null
+/*
+ * Copyright (c) 2017 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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_PRIVATE_H__
+#define __RUA_PRIVATE_H__
+
+#include <sqlite3.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "RUA"
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+#define RUA_DB_NAME ".rua.db"
+#define RUA_HISTORY "rua_history"
+#define RUA_STAT_DB_NAME ".rua_stat.db"
+#define QUERY_MAXLEN 4096
+
+int _rua_stat_init(sqlite3 **db, char *db_name, int flags, uid_t uid);
+
+#endif /*__RUA_H__*/
#include <db-util.h>
#include <aul.h>
+#include <dlog.h>
-#include "rua_stat_internal.h"
-#include "rua_stat.h"
#include "rua_util.h"
+#include "rua_private.h"
-int rua_stat_update_for_uid(char *caller, char *tag, uid_t uid)
+API int rua_stat_update_for_uid(char *caller, char *tag, uid_t uid)
{
int r;
bundle *b = NULL;
return r;
}
-int rua_stat_get_stat_tags(char *caller,
- int (*rua_stat_tag_iter_fn)(const char *rua_stat_tag, void *data),
- void *data)
-{
- return rua_stat_get_stat_tags_for_uid(caller, rua_stat_tag_iter_fn, data, getuid());
-}
-
-int rua_stat_get_stat_tags_for_uid(char *caller,
+API int rua_stat_get_stat_tags_for_uid(char *caller,
int (*rua_stat_tag_iter_fn)(const char *rua_stat_tag, void *data),
void *data, uid_t uid)
{
return r;
}
+
+API int rua_stat_get_stat_tags(char *caller,
+ int (*rua_stat_tag_iter_fn)(const char *rua_stat_tag, void *data),
+ void *data)
+{
+ return rua_stat_get_stat_tags_for_uid(caller, rua_stat_tag_iter_fn, data, getuid());
+}
#include <string.h>
#include <db-util.h>
+#include <dlog.h>
+#include <sqlite3.h>
#include "db-schema.h"
-#include "rua_stat_internal.h"
#include "rua_util.h"
+#include "rua_private.h"
+
+#define WIN_SCORE 100
+#define LOSE_SCORE_RATE 0.7f
int __rua_stat_insert(sqlite3 *db, char *caller, char *rua_stat_tag)
{
return 0;
}
-int rua_stat_db_update(char *caller, char *rua_stat_tag)
-{
- return rua_stat_usr_db_update(caller, rua_stat_tag, getuid());
-}
-
-int rua_stat_usr_db_update(char *caller, char *rua_stat_tag, uid_t uid)
+API int rua_stat_usr_db_update(char *caller, char *rua_stat_tag, uid_t uid)
{
int r;
int affected_rows = 0;
return r;
}
+API int rua_stat_db_update(char *caller, char *rua_stat_tag)
+{
+ return rua_stat_usr_db_update(caller, rua_stat_tag, getuid());
+}
#include <sys/stat.h>
#include <db-util.h>
#include <tzplatform_config.h>
+#include <dlog.h>
#include "rua_util.h"
-#include "rua_internal.h"
+#include "rua_private.h"
+
+#define BASE_UID 5000
char *_rua_util_get_db_path(uid_t uid, char *db_name)
{
#ifndef __RUA_UTIL_H__
#define __RUA_UTIL_H__
-#include <unistd.h>
-#include <stdlib.h>
-#include <sqlite3.h>
-#include <dlog.h>
-
-#ifndef API
-#define API __attribute__ ((visibility("default")))
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include <sys/types.h>
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-
-#define LOG_TAG "RUA"
-#define BASE_UID 5000
+#include <sqlite3.h>
char *_rua_util_get_db_path(uid_t uid, char *db_name);
int _rua_util_open_db(sqlite3 **db, int flags, uid_t uid, char *db_name);
int _rua_util_check_uid(uid_t target_uid);
-#ifdef __cplusplus
-}
-#endif
#endif /*__RUA_UTIL_H__*/