Clean up repository 57/124657/6
authorSangyoon Jang <s89.jang@samsung.com>
Wed, 12 Apr 2017 05:22:38 +0000 (14:22 +0900)
committerSangyoon Jang <s89.jang@samsung.com>
Wed, 12 Apr 2017 05:57:21 +0000 (14:57 +0900)
- Don't export internal headers
- Remove declares for internal purpose from public headers
- Remove unnecessary includes
- Remove explicit dependency of sqlite3
- Add explicit dependency of bundle
- Add build dependency to glib-2.0
- Set api visibility at implementation part
- Remove unnecessary excutable bits

Change-Id: I180582538aad08cae70b29e5d713b86208b408e6
Signed-off-by: Sangyoon Jang <s89.jang@samsung.com>
20 files changed:
CMakeLists.txt
include/db-schema.h [deleted file]
include/rua.h [changed mode: 0755->0644]
include/rua_dbus.h [deleted file]
include/rua_internal.h
include/rua_stat.h [changed mode: 0755->0644]
include/rua_stat_internal.h
include/rua_util.h [deleted file]
packaging/librua.spec
rua.pc.in
src/db-schema.h [new file with mode: 0644]
src/rua.c
src/rua_dbus.c
src/rua_dbus.h [new file with mode: 0644]
src/rua_internal.c
src/rua_private.h [new file with mode: 0644]
src/rua_stat.c [changed mode: 0755->0644]
src/rua_stat_internal.c
src/rua_util.c
src/rua_util.h [new file with mode: 0644]

index cca43665b0d1e04cc21c742e3c377e39cbc8d5f2..3a9639f9f173663b7548a2ca2b0021e91f82efca 100644 (file)
@@ -10,7 +10,7 @@ AUX_SOURCE_DIRECTORY(src SRCS)
 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}")
@@ -29,8 +29,7 @@ SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${MAJORVER})
 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)
@@ -38,8 +37,5 @@ INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/rua.h DESTINATION include/${PR
 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)
diff --git a/include/db-schema.h b/include/db-schema.h
deleted file mode 100644 (file)
index b2e322b..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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.
- * 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_SCHEMA_H__
-#define __RUA_SCHEMA_H__
-
-#define CREATE_RUA_HISTORY_TABLE " \
-PRAGMA journal_mode = OFF; \
-\
-CREATE TABLE IF NOT EXISTS rua_history ( \
-       pkg_name TEXT, \
-       app_path TEXT, \
-       arg TEXT, \
-       launch_time INTEGER, \
-       instance_id TEXT, \
-       instance_name TEXT, \
-       icon TEXT, \
-       uri TEXT, \
-       PRIMARY KEY(pkg_name, instance_id) \
-);"
-
-#define CREATE_RUA_STAT_TABLE " \
-PRAGMA journal_mode = OFF; \
-\
-CREATE TABLE if not exists rua_panel_stat ( \
-       caller_panel TEXT NOT NULL, \
-       rua_stat_tag TEXT NOT NULL, \
-       score INTEGER DEFAULT 0, \
-       PRIMARY KEY(rua_stat_tag, caller_panel) \
-);"
-
-/* table index */
-enum {
-       RUA_COL_PKGNAME,
-       RUA_COL_APPPATH,
-       RUA_COL_ARG,
-       RUA_COL_LAUNCHTIME,
-       RUA_COL_INSTANCE_ID,
-       RUA_COL_INSTANCE_NAME,
-       RUA_COL_ICON,
-       RUA_COL_URI,
-};
-
-enum {
-       RUA_STAT_COL_CALLER_PANEL = 0x00,
-       RUA_STAT_COL_RUA_STAT_TAG,
-       RUA_SATA_COL_SCORE
-};
-
-#endif /* __RUA_SCHEMA_H__ */
old mode 100755 (executable)
new mode 100644 (file)
index ad38464..eb27c07
 #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
@@ -97,7 +82,7 @@ typedef void (*rua_history_update_cb) (
  * @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
@@ -106,8 +91,8 @@ API int rua_add_history_for_uid(char *pkg_name, char *app_path, char *arg, uid_t
  * @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
@@ -116,8 +101,8 @@ API int rua_delete_history_with_pkgname_for_uid(char *pkg_name, uid_t uid);
  * @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
@@ -125,8 +110,8 @@ API int rua_delete_history_with_apppath_for_uid(char *app_path, uid_t uid);
  * @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.
@@ -137,8 +122,8 @@ API int rua_clear_history_for_uid(uid_t uid);
  * @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.
@@ -147,7 +132,7 @@ API int rua_history_load_db_for_uid(char ***table, int *nrows, int *ncols, uid_t
  * @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.
@@ -160,7 +145,7 @@ API int rua_history_unload_db(char ***table);
  * @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);
 
 /**
@@ -170,8 +155,8 @@ API int rua_history_get_rec(struct rua_rec *rec, char **table,
  * @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
@@ -179,7 +164,7 @@ API int rua_is_latest_app_for_uid(const char *pkg_name, uid_t uid);
  * @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);
 
 /**
@@ -191,9 +176,9 @@ API int rua_delete_history_with_instance_id(const char *app_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);
 
 /**
@@ -203,8 +188,8 @@ API int rua_register_update_cb_for_uid(rua_history_update_cb callback,
  * @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
@@ -212,7 +197,7 @@ API int rua_unregister_update_cb_for_uid(int callback_id, uid_t uid);
  * @retval     0 on successful
  * @retval     -1 on failed
  */
-API int rua_init(void);
+int rua_init(void);
 
 /**
  * @brief      Finalize rua
@@ -220,7 +205,7 @@ API int rua_init(void);
  * @retval     0 on successful
  * @retval     -1 on failed
  */
-API int rua_fini(void);
+int rua_fini(void);
 
 #ifdef __cplusplus
 }
diff --git a/include/rua_dbus.h b/include/rua_dbus.h
deleted file mode 100644 (file)
index f0110ae..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * @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,
-       DELETE
-} update_type;
-
-int rua_dbus_send_update_signal(update_type type);
-int rua_dbus_signal_subscribe(rua_history_update_cb callback,
-               void *user_data, int *callback_id);
-int rua_dbus_signal_unsubscribe(int callback_id);
-
-#ifdef __cplusplus
-}
-#endif
-#endif                         /*__RUA_DBUS_H__*/
index 619c9625754ab1602b6f49483d8a4184555fe384..4140a25e2b1035360b92bb75f5e77a2dd213dc4c 100644 (file)
 #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
@@ -68,8 +50,8 @@ API int rua_usr_db_delete_history(bundle *b, uid_t uid);
  * @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
 }
old mode 100755 (executable)
new mode 100644 (file)
index 03fb90b..6a78ba8
 #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" {
@@ -45,7 +38,7 @@ 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
@@ -54,9 +47,9 @@ API int rua_stat_update_for_uid(char *caller, char *tag, uid_t uid);
  * @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
index 082a3ca419f94ef48b4065745eb50a74213c01e1..4b5addc5d9045cd881d8917f62259791465d59f2 100644 (file)
 #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
@@ -56,8 +36,8 @@ int _rua_stat_init(sqlite3 **db, char *db_name, int flags, uid_t uid);
  * @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
 }
diff --git a/include/rua_util.h b/include/rua_util.h
deleted file mode 100644 (file)
index 260e47f..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 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.
- * 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.
- */
-
-/**
- * @file        rua_util.h
- * @brief       RUA UTIL API declaration header file.
- * @author      Hyunho Kang (hhstark.kang@samsung.com)
- * @version     0.1
- * @history     0.1: RUA UTIL API Declarations, structure declaration
- */
-
-#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
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-
-#define LOG_TAG "RUA"
-#define BASE_UID 5000
-
-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__*/
index d2c78f6be42ee53850c2108c129e725cf060c3bd..d8cbdb54d3faa877e21051916d97cd3bd3da5484 100644 (file)
@@ -14,6 +14,7 @@ BuildRequires:  pkgconfig(db-util)
 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
 
index 55aeb04b788bf90ee50b77fa5ddfa43dbf715d53..91050a1f5ba36511bbda0c5f6043f3ffea11dc58 100644 (file)
--- a/rua.pc.in
+++ b/rua.pc.in
@@ -6,6 +6,6 @@ includedir=@INCLUDEDIR@
 Name: rua
 Description: recently used application library
 Version: @VERSION@
-Requires: sqlite3
+Requires: bundle
 Libs: -L${libdir} -lrua
 Cflags: -I${includedir}
diff --git a/src/db-schema.h b/src/db-schema.h
new file mode 100644 (file)
index 0000000..b2e322b
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * 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.
+ * 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_SCHEMA_H__
+#define __RUA_SCHEMA_H__
+
+#define CREATE_RUA_HISTORY_TABLE " \
+PRAGMA journal_mode = OFF; \
+\
+CREATE TABLE IF NOT EXISTS rua_history ( \
+       pkg_name TEXT, \
+       app_path TEXT, \
+       arg TEXT, \
+       launch_time INTEGER, \
+       instance_id TEXT, \
+       instance_name TEXT, \
+       icon TEXT, \
+       uri TEXT, \
+       PRIMARY KEY(pkg_name, instance_id) \
+);"
+
+#define CREATE_RUA_STAT_TABLE " \
+PRAGMA journal_mode = OFF; \
+\
+CREATE TABLE if not exists rua_panel_stat ( \
+       caller_panel TEXT NOT NULL, \
+       rua_stat_tag TEXT NOT NULL, \
+       score INTEGER DEFAULT 0, \
+       PRIMARY KEY(rua_stat_tag, caller_panel) \
+);"
+
+/* table index */
+enum {
+       RUA_COL_PKGNAME,
+       RUA_COL_APPPATH,
+       RUA_COL_ARG,
+       RUA_COL_LAUNCHTIME,
+       RUA_COL_INSTANCE_ID,
+       RUA_COL_INSTANCE_NAME,
+       RUA_COL_ICON,
+       RUA_COL_URI,
+};
+
+enum {
+       RUA_STAT_COL_CALLER_PANEL = 0x00,
+       RUA_STAT_COL_RUA_STAT_TAG,
+       RUA_SATA_COL_SCORE
+};
+
+#endif /* __RUA_SCHEMA_H__ */
index 6381870340cc978075a4e18be0df6bf6ada7c222..7fef47ac8e6a39595081fd08945038488fa9a210 100644 (file)
--- a/src/rua.c
+++ b/src/rua.c
 #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,};
@@ -58,12 +61,7 @@ int rua_add_history_for_uid(char *pkg_name, char *app_path, char *arg, uid_t uid
        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;
@@ -84,12 +82,12 @@ int rua_delete_history_with_pkgname_for_uid(char *pkg_name, uid_t uid)
        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;
@@ -110,12 +108,12 @@ int rua_delete_history_with_apppath_for_uid(char *app_path, uid_t uid)
        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;
 
@@ -128,12 +126,12 @@ int rua_clear_history_for_uid(uid_t uid)
        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];
@@ -173,12 +171,12 @@ int rua_history_load_db_for_uid(char ***table, int *nrows, int *ncols, uid_t uid
        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;
 
@@ -194,12 +192,12 @@ int rua_register_update_cb_for_uid(rua_history_update_cb callback, void *user_da
        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;
 
@@ -212,17 +210,12 @@ int rua_unregister_update_cb_for_uid(int callback_id, uid_t uid)
        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;
@@ -281,12 +274,17 @@ int rua_history_get_rec(struct rua_rec *rec, char **table, int nrows, int ncols,
        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;
@@ -334,17 +332,22 @@ out:
        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;
index 132bb4a23fd692cc0c8472f1e9f09e2e0c69f518..1957e4813feb790365c541daa2596a406f1e2318 100644 (file)
 
 #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"
diff --git a/src/rua_dbus.h b/src/rua_dbus.h
new file mode 100644 (file)
index 0000000..1b53963
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * 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_DBUS_H__
+#define __RUA_DBUS_H__
+
+typedef enum
+{
+       ADD,
+       DELETE
+} update_type;
+
+int rua_dbus_send_update_signal(update_type type);
+int rua_dbus_signal_subscribe(rua_history_update_cb callback,
+               void *user_data, int *callback_id);
+int rua_dbus_signal_unsubscribe(int callback_id);
+
+#endif                         /*__RUA_DBUS_H__*/
index bc17818248fd7292dbc3314bb26b7b7298e6cae6..4aa2250d6c6afd02861e6e626c6bedb3a91b833a 100644 (file)
  * 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)
 {
@@ -70,12 +77,12 @@ static sqlite3 *__db_init(uid_t uid)
        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;
@@ -134,12 +141,12 @@ int rua_usr_db_delete_history(bundle *b, uid_t uid)
        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];
diff --git a/src/rua_private.h b/src/rua_private.h
new file mode 100644 (file)
index 0000000..5dec197
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * 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__*/
old mode 100755 (executable)
new mode 100644 (file)
index f6304f4..1c5e8ed
 
 #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;
@@ -60,14 +60,7 @@ int rua_stat_update_for_uid(char *caller, char *tag, uid_t uid)
        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)
 {
@@ -119,3 +112,10 @@ out:
 
        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());
+}
index ee68dd1398609ecbfec9fbe42b7a707003a649da..438117b04f746eed79950713ad7cac6c10ca65fe 100644 (file)
 #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)
 {
@@ -205,12 +210,7 @@ int _rua_stat_init(sqlite3 **db, char *db_name, int flags, uid_t uid)
        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;
@@ -263,3 +263,7 @@ int rua_stat_usr_db_update(char *caller, char *rua_stat_tag, uid_t uid)
        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());
+}
index a5895b9c18a1860f4f4a2749cc2cff7d7c43cc0b..09dd080ab027859f65afc120070e3feaaba74350 100644 (file)
 #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)
 {
diff --git a/src/rua_util.h b/src/rua_util.h
new file mode 100644 (file)
index 0000000..13efffe
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 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.
+ * 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.
+ */
+
+/**
+ * @file        rua_util.h
+ * @brief       RUA UTIL API declaration header file.
+ * @author      Hyunho Kang (hhstark.kang@samsung.com)
+ * @version     0.1
+ * @history     0.1: RUA UTIL API Declarations, structure declaration
+ */
+
+#ifndef __RUA_UTIL_H__
+#define __RUA_UTIL_H__
+
+#include <sys/types.h>
+
+#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);
+
+#endif                         /*__RUA_UTIL_H__*/