2 * Copyright (c) 2011 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.
17 #ifndef __TIZEN_APPFW_APP_MANAGER_H
18 #define __TIZEN_APPFW_APP_MANAGER_H
22 #include <app_context.h>
34 * @addtogroup CAPI_APPLICATION_MANAGER_MODULE
39 * @brief Enumerations for Application Manager Error .
44 APP_MANAGER_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
45 APP_MANAGER_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
46 APP_MANAGER_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
47 APP_MANAGER_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< Internal I/O error */
48 APP_MANAGER_ERROR_NO_SUCH_APP = TIZEN_ERROR_APPLICATION_MANAGER | 0x01, /**< No such application */
50 APP_MANAGER_ERROR_DB_FAILED = TIZEN_ERROR_APPLICATION_MANAGER | 0x03, /**< Database error */
51 APP_MANAGER_ERROR_INVALID_PACKAGE = TIZEN_ERROR_APPLICATION_MANAGER | 0x04, /**< Invalid package name */
52 APP_MANAGER_ERROR_APP_NO_RUNNING = TIZEN_ERROR_APPLICATION_MANAGER | 0x05, /**< App is not running */
53 APP_MANAGER_ERROR_REQUEST_FAILED = TIZEN_ERROR_APPLICATION_MANAGER | 0x06, /**< Internal aul request error */
54 APP_MANAGER_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED /**< Permission denied */
55 } app_manager_error_e;
59 * @brief Called when an application is launched or terminated.
61 * @param[in] app_context The application context of the application launched or terminated
62 * @param[in] event The application context event
63 * @param[in] user_data The user data passed from the foreach function
64 * @pre This function is called when an application gets launched or terminated, after you register this callback using app_manager_set_app_context_event_cb().
65 * @see app_manager_set_app_context_event_cb()
66 * @see app_manager_unset_app_context_event_cb()
68 typedef void (*app_manager_app_context_event_cb) (app_context_h app_context, app_context_event_e event, void *user_data);
71 * @brief Called to get the application context once for each running application.
73 * @param[in] app_context The application context of each running application
74 * @param[in] user_data The user data passed from the foreach function
75 * @return @c true to continue with the next iteration of the loop, \n
76 * otherwise @c false to break out of the loop
77 * @pre app_manager_foreach_app_context() will invoke this callback.
78 * @see app_manager_foreach_app_context()
80 typedef bool (*app_manager_app_context_cb) (app_context_h app_context, void *user_data);
83 * @brief Called to get the application information once for each installed application.
85 * @param[in] app_info The application information of each installed application
86 * @param[in] user_data The user data passed from the foreach function
87 * @return @c true to continue with the next iteration of the loop, \n
88 * otherwise @c false to break out of the loop
89 * @pre app_manager_foreach_app_info() will invoke this callback.
90 * @see app_manager_foreach_app_info()
92 typedef bool (*app_manager_app_info_cb) (app_info_h app_info, void *user_data);
96 * @brief Registers a callback function to be invoked when the applications get launched or terminated.
99 * @privilege %http://tizen.org/privilege/packagemanager.info
100 * @param[in] callback The callback function to register
101 * @param[in] user_data The user data to be passed to the callback function
102 * @return @c 0 on success,
103 * otherwise a negative error value
104 * @retval #APP_MANAGER_ERROR_NONE Successful
105 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
106 * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
107 * @retval #APP_MANAGER_ERROR_PERMISSION_DENIED Permission denied
108 * @post It will invoke app_manager_app_context_event_cb() when the application is launched or terminated.
109 * @see app_manager_unset_app_context_event_cb()
110 * @see app_manager_app_context_event_cb()
112 int app_manager_set_app_context_event_cb(app_manager_app_context_event_cb callback, void *user_data);
116 * @brief Unregisters the callback function.
118 * @see app_manager_set_app_event_cb()
119 * @see app_manager_app_context_event_cb()
121 void app_manager_unset_app_context_event_cb(void);
124 * @brief Retrieves all application contexts of running applications.
127 * @privilege %http://tizen.org/privilege/packagemanager.info
128 * @param[in] callback The callback function to invoke
129 * @param[in] user_data The user data to be passed to the callback function
130 * @return @c 0 on success,
131 * otherwise a negative error value
132 * @retval #APP_MANAGER_ERROR_NONE Successful
133 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
134 * @retval #APP_MANAGER_ERROR_PERMISSION_DENIED Permission denied
135 * @post This function invokes app_manager_app_context_cb() for each application context.
136 * @see app_manager_app_context_cb()
138 int app_manager_foreach_app_context(app_manager_app_context_cb callback, void *user_data);
141 * @brief Gets the application context for the given ID of the application.
144 * @privilege %http://tizen.org/privilege/packagemanager.info
145 * @remarks This function returns #APP_MANAGER_ERROR_NO_SUCH_APP if the application with the given application ID is not running. \n
146 * You must release @a app_context using app_context_destroy().
147 * @param[in] app_id The ID of the application
148 * @param[out] app_context The application context of the given application ID
149 * @return @c 0 on success,
150 * otherwise a negative error value
151 * @retval #APP_MANAGER_ERROR_NONE Successful
152 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
153 * @retval #APP_MANAGER_ERROR_DB_FAILED Database error occurred
154 * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
155 * @retval #APP_MANAGER_ERROR_NO_SUCH_APP No such application
156 * @retval #APP_MANAGER_ERROR_PERMISSION_DENIED Permission denied
158 int app_manager_get_app_context(const char *app_id, app_context_h *app_context);
161 * @brief Gets the ID of the application for the given process ID.
164 * @privilege %http://tizen.org/privilege/packagemanager.info
165 * @remarks This function returns #APP_MANAGER_ERROR_NO_SUCH_APP if the application with the given process ID is not valid. \n
166 * You must release @a app_id using free().
167 * @param[in] pid The process ID of the application
168 * @param[out] app_id The ID of the application
169 * @return @c 0 on success,
170 * otherwise a negative error value
171 * @retval #APP_MANAGER_ERROR_NONE Successful
172 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
173 * @retval #APP_MANAGER_ERROR_DB_FAILED Database error occurred
174 * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
175 * @retval #APP_MANAGER_ERROR_NO_SUCH_APP No such application
176 * @retval #APP_MANAGER_ERROR_PERMISSION_DENIED Permission denied
178 int app_manager_get_app_id(pid_t pid, char **app_id);
181 * @brief Checks whether the application with the given package name is running.
183 * @param[in] app_id The ID of the application
184 * @param[out] running @c true if the application is running, \n
185 * otherwise @c false if not running
186 * @return @c 0 on success,
187 * otherwise a negative error value
188 * @retval #APP_MANAGER_ERROR_NONE Successful
189 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
191 int app_manager_is_running(const char *app_id, bool *running);
194 * @brief Resumes the application.
197 * @privilege %http://tizen.org/privilege/appmanager.launch
198 * @param[in] app_context The application context
199 * @return @c 0 on success,
200 * otherwise a negative error value
201 * @retval #APP_MANAGER_ERROR_NONE Successful
202 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
203 * @retval #APP_MANAGER_ERROR_APP_NO_RUNNING App is not running
204 * @retval #APP_MANAGER_ERROR_REQUEST_FAILED Internal resume error
205 * @retval #APP_MANAGER_ERROR_PERMISSION_DENIED Permission denied
207 int app_manager_resume_app(app_context_h app_context);
211 * @brief Opens the application.
214 * @privilege %http://tizen.org/privilege/appmanager.launch
215 * @param[in] app_id The ID of the application
216 * @return @c 0 on success,
217 * otherwise a negative error value
218 * @retval #APP_MANAGER_ERROR_NONE Successful
219 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
220 * @retval #APP_MANAGER_ERROR_NO_SUCH_APP No such application
221 * @retval #APP_MANAGER_ERROR_REQUEST_FAILED Internal open error
222 * @retval #APP_MANAGER_ERROR_PERMISSION_DENIED Permission denied
224 int app_manager_open_app(const char *app_id);
228 * @brief Terminates the application.
230 * @privlevel platform
231 * @privilege %http://tizen.org/privilege/appmanager.kill
232 * @param[in] app_context The application context
233 * @return @c 0 on success,
234 * otherwise a negative error value
235 * @retval #APP_MANAGER_ERROR_NONE Successful
236 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
237 * @retval #APP_MANAGER_ERROR_REQUEST_FAILED Internal terminate error
238 * @retval #APP_MANAGER_ERROR_PERMISSION_DENIED Permission denied
240 int app_manager_terminate_app(app_context_h app_context);
243 * @brief Retrieves all installed applications information.
246 * @privilege %http://tizen.org/privilege/packagemanager.info
247 * @param[in] callback The callback function to invoke
248 * @param[in] user_data The user data to be passed to the callback function
249 * @return @c 0 on success,
250 * otherwise a negative error value
251 * @retval #APP_MANAGER_ERROR_NONE Successful
252 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
253 * @retval #APP_MANAGER_ERROR_PERMISSION_DENIED Permission denied
254 * @post This function invokes app_manager_app_info_cb() for each application information.
255 * @see app_manager_app_info_cb()
257 int app_manager_foreach_app_info(app_manager_app_info_cb callback, void *user_data);
260 * @brief Gets the application information for the given application ID.
263 * @privilege %http://tizen.org/privilege/packagemanager.info
264 * @remarks You must release @a app_info using app_info_destroy().
265 * @param[in] app_id The ID of the application
266 * @param[out] app_info The application information for the given application ID
267 * @return @c 0 on success,
268 * otherwise a negative error value
269 * @retval #APP_MANAGER_ERROR_NONE Successful
270 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
271 * @retval #APP_MANAGER_ERROR_DB_FAILED Database error occurred
272 * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
273 * @retval #APP_MANAGER_ERROR_PERMISSION_DENIED Permission denied
275 int app_manager_get_app_info(const char *app_id, app_info_h *app_info);
278 * @brief Gets the absolute path to the shared data directory of the application specified
279 * with an application ID.
280 * @details An application can only read the files of other application's shared data directory.
282 * @remarks The specified @a path should be released.
284 * @param[in] app_id The ID of the application
285 * @param[in,out] path The absolute path to the shared data directory of the application
286 * specified with the @a app_id
287 * @return @c 0 on success,
288 * otherwise a negative error value
289 * @retval #APP_MANAGER_ERROR_NONE Successful
290 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
291 * @retval #APP_MANAGER_ERROR_NO_SUCH_APP No such application
292 * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
294 int app_manager_get_shared_data_path(const char *app_id, char **path);
297 * @brief Gets the absolute path to the shared resource directory of the application specified
298 * with an application ID.
299 * @details An application can only read the files of other application's shared resource directory.
301 * @remarks The specified @a path should be released.
303 * @param[in] app_id The ID of the application
304 * @param[in,out] path The absolute path to the shared resource directory of the application
305 * specified with the @a app_id
306 * @return @c 0 on success,
307 * otherwise a negative error value
308 * @retval #APP_MANAGER_ERROR_NONE Successful
309 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
310 * @retval #APP_MANAGER_ERROR_NO_SUCH_APP No such application
311 * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
313 int app_manager_get_shared_resource_path(const char *app_id, char **path);
316 * @brief Gets the absolute path to the shared trusted directory of the application specified
317 * with an application ID.
318 * @details An application signed with the same certificate can read and write the files of
319 * other application's shared trusted directory.
321 * @remarks The specified @a path should be released.
323 * @param[in] app_id The ID of the application
324 * @param[in,out] path The absolute path to the shared trusted directory of the application
325 * specified with the @a app_id
326 * @return @c 0 on success,
327 * otherwise a negative error value
328 * @retval #APP_MANAGER_ERROR_NONE Successful
329 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
330 * @retval #APP_MANAGER_ERROR_NO_SUCH_APP No such application
331 * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
333 int app_manager_get_shared_trusted_path(const char *app_id, char **path);
336 * @brief Gets the absolute path to the shared data directory of the application specified
337 * with an application ID.
338 * @details An application can only read the files of other application's shared data directory.
340 * @remarks The specified @a path should be released.
342 * @param[in] app_id The ID of the application
343 * @param[in,out] path The absolute path to the shared data directory of the application
344 * specified with the @a app_id
345 * @return @c 0 on success,
346 * otherwise a negative error value
347 * @retval #APP_MANAGER_ERROR_NONE Successful
348 * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
349 * @retval #APP_MANAGER_ERROR_NO_SUCH_APP No such application
350 * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory
352 int app_manager_get_external_shared_data_path(const char *app_id, char **path);
362 #endif /* __TIZEN_APPFW_APP_MANAGER_H */