Refactoring rua api
[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 with pkg_name
68  * @param[in]   pkg_name package name to delete history
69  * @return      0 on success, otherwise a nagative error value
70  * @retval      0 on successful
71  * @retval      -1 on failed
72  */
73 API int rua_delete_history_with_pkgname(char *pkg_name);
74
75 /**
76  * @brief       Delete history with app_path
77  * @param[in]   app_path package name to delete history
78  * @return      0 on success, otherwise a nagative error value
79  * @retval      0 on successful
80  * @retval      -1 on failed
81  */
82 API int rua_delete_history_with_apppath(char *app_path);
83
84 /**
85  * @brief       Clear history
86  * @return      0 on success, otherwise a nagative error value
87  * @retval      0 on successful
88  * @retval      -1 on failed
89  */
90 API int rua_clear_history(void);
91
92 /**
93  * @brief       Load recently used application history db.
94  * @param[out]  table db table pointer
95  * @param[out]  nrows the number of record
96  * @param[out]  ncols the number of field
97  * @return      0 on success, otherwise a nagative error value
98  * @retval      0 on successful
99  * @retval      -1 on failed
100  */
101 API int rua_history_load_db(char ***table, int *nrows, int *ncols);
102
103 /**
104  * @brief       Unload recently used application history db.
105  * @param[in]   table db table pointer to unload
106  * @return      0 on success, otherwise a nagative error value
107  * @retval      0 on successful
108  * @retval      -1 on failed
109  */
110 API int rua_history_unload_db(char ***table);
111
112 /**
113  * @brief       Load recently used application record.
114  * @param[out]  rec record to load
115  * @param[in]   table db table pointer
116  * @param[in]   nrows the number of record
117  * @param[in]   ncols the number of field
118  * @param[in]   row record index to load
119  * @return      0 on success, otherwise a nagative error value
120  * @retval      0 on successful
121  * @retval      -1 on failed
122  */
123 API int rua_history_get_rec(struct rua_rec *rec, char **table,
124                                 int nrows, int ncols, int row);
125
126 /**
127  * @brief       Check some package is latest or not with package name
128  * @param[in]   pkg_name package name
129  * @return      0 on success, otherwise a nagative error value
130  * @retval      0 if given pkg_name is lastest application
131  * @retval      -1 if not lastest applicaton or on failed
132  */
133 API int rua_is_latest_app(const char *pkg_name);
134
135 /**
136  * @brief       Initialize rua
137  * @return      0 on success, otherwise a nagative error value
138  * @retval      0 on successful
139  * @retval      -1 on failed
140  */
141 API int rua_init(void);
142
143 /**
144  * @brief       Finalize rua
145  * @return      0 on success, otherwise a nagative error value
146  * @retval      0 on successful
147  * @retval      -1 on failed
148  */
149 API int rua_fini(void);
150
151 #ifdef __cplusplus
152 }
153 #endif
154 #endif                          /*__RUA_H__*/