#ifndef __RUA_H__
#define __RUA_H__
-#include <sqlite3.h>
-#include <bundle.h>
#include <time.h>
-
-#ifndef API
-#define API __attribute__ ((visibility("default")))
-#endif
+#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
* @brief RUA record info structure
*/
struct rua_rec {
- int id; /**< primary key */
+ int id; /**< primary key */
char *pkg_name; /**< package name */
char *app_path; /**< application path */
char *arg; /**< application launching argument */
- time_t launch_time; /**< application launching time */
+ time_t launch_time; /**< application launching time */
+ char *instance_id; /**< Instance ID */
+ char *instance_name; /**< Instance Name */
+ char *icon; /**< Icon path */
+ char *uri; /**< URI */
+ char *image; /**< Image path */
};
/**
- * @brief Delete history from DB
- * @return 0 on success, otherwise a nagative error value
- * @retval 0 on successful
- * @retval -1 on failed
+ * @brief Called when the history is updated.
+ * @param[in] table db table pointer
+ * @param[in] nrows the number of record
+ * @param[in] ncols the number of field
+ * @param[in] user_data The user data passed from rua_register_update_cb()
*/
-API int rua_delete_history_from_db(bundle *b);
+typedef void (*rua_history_update_cb) (
+ char **table,
+ int nrows,
+ int ncols,
+ void *user_data);
/**
- * @brief Clear history
- * @return 0 on success, otherwise a nagative error value
+ * @brief Add history
+ * @param[in] pkg_name package name to delete history
+ * @return 0 on success, otherwise a nagative error value
* @retval 0 on successful
* @retval -1 on failed
*/
-API int rua_clear_history(void);
+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);
+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);
+int rua_delete_history_with_apppath(char *app_path);
+int rua_delete_history_with_apppath_for_uid(char *app_path, uid_t uid);
/**
- * @brief Add application to recently used application list
- * @param[in] rec record to add history
+ * @brief Clear history
* @return 0 on success, otherwise a nagative error value
* @retval 0 on successful
* @retval -1 on failed
*/
-API int rua_add_history(struct rua_rec *rec);
+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);
+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);
+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] app_id The application ID
+ * @param[in] instance_id The instance ID
+ * @return 0 on success, otherwise a negative error value
+ */
+int rua_delete_history_with_instance_id(const char *app_id,
+ const char *instance_id);
+
+/**
+ * @brief Registers a callback function to be invoked when the history is updated
+ * @param[in] callback The callback function to be registered
+ * @param[in] user_data The user data passed to rua_register_update_cb()
+ * @param[out] callback_id Added callback id
+ * @return 0 on success, otherwise a nagative error value
+ * @retval 0 if on successful
+ * @retval -1 if it is already registered or on failed
+ */
+int rua_register_update_cb(rua_history_update_cb callback,
+ void *user_data, int *callback_id);
+int rua_register_update_cb_for_uid(rua_history_update_cb callback,
+ void *user_data, int *callback_id, uid_t uid);
+
+/**
+ * @brief Unregisters a callback function
+ * @param[in] callback_id Target callback id
+ * @return 0 on success, otherwise a nagative error value
+ * @retval 0 if on successful
+ * @retval -1 if the callback was not registered or on failed
+ */
+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
}