Adjust coding rule and remove compile warning messages
[platform/core/appfw/librua.git] / include / rua.h
1 /*
2  * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 /**
18  * @file        rua.h
19  * @brief       RUA API declaration header file.
20  * @author      Jinwoo Nam (jwoo.nam@samsung.com)
21  * @version     0.1
22  * @history     0.1: RUA API Declarations, structure declaration
23  */
24
25 #ifndef __RUA_H__
26 #define __RUA_H__
27
28 #include <sqlite3.h>
29 #include <bundle.h>
30 #include <time.h>
31
32 #ifndef API
33 #define API __attribute__ ((visibility("default")))
34 #endif
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
40 /**
41  * @defgroup RUA rua
42  * @{
43  */
44
45 /**
46  * @}
47  */
48
49 /**
50  * @addtogroup RUA
51  * @{
52  */
53
54 /**
55  * @struct rua_rec
56  * @brief RUA record info structure
57  */
58 struct rua_rec {
59         int id;         /**<  primary key */
60         char *pkg_name;         /**< package name */
61         char *app_path;         /**< application path */
62         char *arg;              /**< application launching argument */
63         time_t launch_time;             /**< application launching time */
64 };
65
66 /**
67  * @brief       Delete history from DB
68  * @return      0 on success, otherwise a nagative error value
69  * @retval      0 on successful
70  * @retval      -1 on failed
71  */
72 API int rua_delete_history_from_db(bundle *b);
73
74 /**
75  * @brief       Clear history
76  * @return      0 on success, otherwise a nagative error value
77  * @retval      0 on successful
78  * @retval      -1 on failed
79  */
80 API int rua_clear_history(void);
81
82 /**
83  * @brief       Delete history with pkg_name
84  * @param[in]   pkg_name package name to delete history
85  * @return      0 on success, otherwise a nagative error value
86  * @retval      0 on successful
87  * @retval      -1 on failed
88  */
89 API int rua_delete_history_with_pkgname(char *pkg_name);
90
91 /**
92  * @brief       Delete history with app_path
93  * @param[in]   app_path package name to delete history
94  * @return      0 on success, otherwise a nagative error value
95  * @retval      0 on successful
96  * @retval      -1 on failed
97  */
98 API int rua_delete_history_with_apppath(char *app_path);
99
100 /**
101  * @brief       Add application to recently used application list
102  * @param[in]   rec  record to add history
103  * @return      0 on success, otherwise a nagative error value
104  * @retval      0 on successful
105  * @retval      -1 on failed
106  */
107 API int rua_add_history(struct rua_rec *rec);
108
109 /**
110  * @brief       Load recently used application history db.
111  * @param[out]  table db table pointer
112  * @param[out]  nrows the number of record
113  * @param[out]  ncols the number of field
114  * @return      0 on success, otherwise a nagative error value
115  * @retval      0 on successful
116  * @retval      -1 on failed
117  */
118 API int rua_history_load_db(char ***table, int *nrows, int *ncols);
119
120 /**
121  * @brief       Unload recently used application history db.
122  * @param[in]   table db table pointer to unload
123  * @return      0 on success, otherwise a nagative error value
124  * @retval      0 on successful
125  * @retval      -1 on failed
126  */
127 API int rua_history_unload_db(char ***table);
128
129 /**
130  * @brief       Load recently used application record.
131  * @param[out]  rec record to load
132  * @param[in]   table db table pointer
133  * @param[in]   nrows the number of record
134  * @param[in]   ncols the number of field
135  * @param[in]   row record index to load
136  * @return      0 on success, otherwise a nagative error value
137  * @retval      0 on successful
138  * @retval      -1 on failed
139  */
140 API int rua_history_get_rec(struct rua_rec *rec, char **table,
141                                 int nrows, int ncols, int row);
142
143 /**
144  * @brief       Check some package is latest or not with package name
145  * @param[in]   pkg_name package name
146  * @return      0 on success, otherwise a nagative error value
147  * @retval      0 if given pkg_name is lastest application
148  * @retval      -1 if not lastest applicaton or on failed
149  */
150 API int rua_is_latest_app(const char *pkg_name);
151
152 /**
153  * @brief       Initialize rua
154  * @return      0 on success, otherwise a nagative error value
155  * @retval      0 on successful
156  * @retval      -1 on failed
157  */
158 API int rua_init(void);
159
160 /**
161  * @brief       Finalize rua
162  * @return      0 on success, otherwise a nagative error value
163  * @retval      0 on successful
164  * @retval      -1 on failed
165  */
166 API int rua_fini(void);
167
168 #ifdef __cplusplus
169 }
170 #endif
171 #endif                          /*__RUA_H__*/