Release version 0.5.14
[platform/core/appfw/librua.git] / include / rua_manager.h
1 /*
2  * Copyright (c) 2019 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 #ifndef __RUA_MANAGER_H__
18 #define __RUA_MANAGER_H__
19
20 #include <app_control.h>
21 #include <rua_context.h>
22 #include <rua_info.h>
23 #include <rua_types.h>
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 /**
30  * @brief Called to get the RUA information once for each launched application.
31  * @since_tizen 5.5
32  * @remarks After this callback returns, the handle of the RUA information handle is freed.
33  *          Therefore, if you want to use the handle after returning this callback, you MUST copy it by using rua_info_clone() function.
34  *
35  * @param[in]   info            The RUA information handle
36  * @param[in]   user_data       The user data passed from the foreach function
37  * @return      @c true to continue with the next iteration of the loop, \n
38  *              otherwise @c false to break out of the loop
39  *
40  * @see rua_manager_foreach_rua_info()
41  * @see rua_manager_foreach_all_rua_info()
42  */
43 typedef bool (*rua_manager_rua_info_cb)(rua_info_h info, void *user_data);
44
45 /**
46  * @brief Retrieves all launched applications information.
47  * @since_tizen 5.5
48  * @privlevel public
49  * @privilege %http://tizen.org/privilege/packagemanager.info
50  *
51  * @param[in]   callback        The callback function to invoke
52  * @param[in]   user_data       The user data to be passed to the callback function
53  * @return      @c 0 on success,
54  *              otherwise a negative error value
55  *
56  * @see rua_info_foreach_cb()
57  */
58 int rua_manager_foreach_rua_info(rua_manager_rua_info_cb callback, void *user_data);
59
60 /**
61  * @brief Deletes the RUA information.
62  * @since_tizen 5.5
63  *
64  * @param[in]   info            The RUA information handle
65  * @return      @c 0 on success,
66  *              otherwise a negative error value
67  *
68  * @remarks This function is only available for platform level signed applications.
69  */
70 int rua_manager_delete_rua_info(rua_info_h info);
71
72 /**
73  * @brief Deletes all RUA informations.
74  * @since_tizen 5.5
75  *
76  * @return      @c 0 on success,
77  *              otherwise a negative error value
78  *
79  * @remarks This function is only available for platform level signed applications.
80  */
81 int rua_manager_delete_all_rua_info(void);
82
83 /**
84  * @brief Gets the app_control handle from the given RUA information handle.
85  * @since_tizen 5.5
86  * @remarks You should release @a app_control using app_control_destroy().
87  *
88  * @param[in]   info            The RUA information handle
89  * @param[out]  app_control     The app_control handle
90  * @return      @c 0 on success,
91  *              otherwise a negative error value
92  *
93  * @see rua_info_foreach()
94  * @see rua_info_usr_foreach()
95  * @see app_control_send_launch_request()
96  * @see app_control_send_launch_request_async()
97  * @see app_control_destroy()
98  */
99 int rua_manager_get_app_control_from_rua_info(rua_info_h info, app_control_h *app_control);
100
101 /**
102  * @brief Gets the RUA context handle from the given RUA information handle.
103  * @since_tizen 5.5
104  * @remarks You should release @a context using rua_context_destroy().
105  *
106  * @param[in]   info            The RUA information handle
107  * @param[out]  context         The RUA context handle
108  * @return      @c 0 on success,
109  *              otherwise a negative error value
110  *
111  * @see rua_info_foreach()
112  * @see rua_info_usr_foreach()
113  * @see rua_context_destroy()
114  */
115 int rua_manager_get_rua_context_from_rua_info(rua_info_h info, rua_context_h *context);
116
117 /**
118  * @brief Checks whether the instance with the given RUA context handle is running or not.
119  * @since_tizen 5.5
120  *
121  * @param[in]   context         The RUA context handle
122  * @param[out]  running         @c true if the instance is running, \n
123  *                              otherwise @c false if not running
124  * @return      @c 0 on success,
125  *              otherwise a negative error value
126  */
127 int rua_manager_is_running(rua_context_h context, bool *running);
128
129 /**
130  * @brief Resumes the instance.
131  * @since_tizen 5.5
132  * @privlevel public
133  * @privilege %http://tizen.org/privilege/appmanager.launch
134  *
135  * @param[in]   context         The RUA context handle
136  * @return      @c 0 on success,
137  *              otherwise a negative error value
138  */
139 int rua_manager_resume(rua_context_h context);
140
141 /**
142  * @brief Terminates the instance.
143  * @since_tizen 5.5
144  * @privlevel platform
145  * @privilege %http://tizen.org/privilege/appmanager.kill
146  *
147  * @param[in]   context         The RUA context handle
148  * @return      @c 0 on succes,
149  *              otherwise a negative error value
150  */
151 int rua_manager_terminate(rua_context_h context);
152
153 #ifdef __cplusplus
154 }
155 #endif
156
157 #endif /*__RUA_MANAGER_H__*/