2 * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 * @brief RUA API declaration header file.
20 * @author Jinwoo Nam (jwoo.nam@samsung.com)
22 * @history 0.1: RUA API Declarations, structure declaration
32 #include <sys/types.h>
43 #define API __attribute__ ((visibility("default")))
66 * @brief RUA record info structure
69 int id; /**< primary key */
70 char *pkg_name; /**< package name */
71 char *app_path; /**< application path */
72 char *arg; /**< application launching argument */
73 time_t launch_time; /**< application launching time */
74 char *instance_id; /**< Instance ID */
75 char *instance_name; /**< Instance Name */
76 char *icon; /**< Icon path */
77 char *uri; /**< URI */
81 * @brief Called when the history is updated.
82 * @param[in] table db table pointer
83 * @param[in] nrows the number of record
84 * @param[in] ncols the number of field
85 * @param[in] user_data The user data passed from rua_register_update_cb()
87 typedef void (*rua_history_update_cb) (
95 * @param[in] pkg_name package name to delete history
96 * @return 0 on success, otherwise a nagative error value
97 * @retval 0 on successful
98 * @retval -1 on failed
100 API int rua_add_history_for_uid(char *pkg_name, char *app_path, char *arg, uid_t uid);
103 * @brief Delete history with pkg_name
104 * @param[in] pkg_name package name to delete history
105 * @return 0 on success, otherwise a nagative error value
106 * @retval 0 on successful
107 * @retval -1 on failed
109 API int rua_delete_history_with_pkgname(char *pkg_name);
110 API int rua_delete_history_with_pkgname_for_uid(char *pkg_name, uid_t uid);
113 * @brief Delete history with app_path
114 * @param[in] app_path package name to delete history
115 * @return 0 on success, otherwise a nagative error value
116 * @retval 0 on successful
117 * @retval -1 on failed
119 API int rua_delete_history_with_apppath(char *app_path);
120 API int rua_delete_history_with_apppath_for_uid(char *app_path, uid_t uid);
123 * @brief Clear history
124 * @return 0 on success, otherwise a nagative error value
125 * @retval 0 on successful
126 * @retval -1 on failed
128 API int rua_clear_history(void);
129 API int rua_clear_history_for_uid(uid_t uid);
132 * @brief Load recently used application history db.
133 * @param[out] table db table pointer
134 * @param[out] nrows the number of record
135 * @param[out] ncols the number of field
136 * @return 0 on success, otherwise a nagative error value
137 * @retval 0 on successful
138 * @retval -1 on failed
140 API int rua_history_load_db(char ***table, int *nrows, int *ncols);
141 API int rua_history_load_db_for_uid(char ***table, int *nrows, int *ncols, uid_t uid);
144 * @brief Unload recently used application history db.
145 * @param[in] table db table pointer to unload
146 * @return 0 on success, otherwise a nagative error value
147 * @retval 0 on successful
148 * @retval -1 on failed
150 API int rua_history_unload_db(char ***table);
153 * @brief Load recently used application record.
154 * @param[out] rec record to load
155 * @param[in] table db table pointer
156 * @param[in] nrows the number of record
157 * @param[in] ncols the number of field
158 * @param[in] row record index to load
159 * @return 0 on success, otherwise a nagative error value
160 * @retval 0 on successful
161 * @retval -1 on failed
163 API int rua_history_get_rec(struct rua_rec *rec, char **table,
164 int nrows, int ncols, int row);
167 * @brief Check some package is latest or not with package name
168 * @param[in] pkg_name package name
169 * @return 0 on success, otherwise a nagative error value
170 * @retval 0 if given pkg_name is lastest application
171 * @retval -1 if not lastest applicaton or on failed
173 API int rua_is_latest_app(const char *pkg_name);
174 API int rua_is_latest_app_for_uid(const char *pkg_name, uid_t uid);
177 * @brief Delete rua history with instance id
178 * @param[in] app_id The application ID
179 * @param[in] instance_id The instance ID
180 * @return 0 on success, otherwise a negative error value
182 API int rua_delete_history_with_instance_id(const char *app_id,
183 const char *instance_id);
186 * @brief Registers a callback function to be invoked when the history is updated
187 * @param[in] callback The callback function to be registered
188 * @param[in] user_data The user data passed to rua_register_update_cb()
189 * @param[out] callback_id Added callback id
190 * @return 0 on success, otherwise a nagative error value
191 * @retval 0 if on successful
192 * @retval -1 if it is already registered or on failed
194 API int rua_register_update_cb(rua_history_update_cb callback,
195 void *user_data, int *callback_id);
196 API int rua_register_update_cb_for_uid(rua_history_update_cb callback,
197 void *user_data, int *callback_id, uid_t uid);
200 * @brief Unregisters a callback function
201 * @param[in] callback_id Target callback id
202 * @return 0 on success, otherwise a nagative error value
203 * @retval 0 if on successful
204 * @retval -1 if the callback was not registered or on failed
206 API int rua_unregister_update_cb(int callback_id);
207 API int rua_unregister_update_cb_for_uid(int callback_id, uid_t uid);
210 * @brief Initialize rua
211 * @return 0 on success, otherwise a nagative error value
212 * @retval 0 on successful
213 * @retval -1 on failed
215 API int rua_init(void);
218 * @brief Finalize rua
219 * @return 0 on success, otherwise a nagative error value
220 * @retval 0 on successful
221 * @retval -1 on failed
223 API int rua_fini(void);