1b4e183660d594be96afd6deeb64059d2861b63c
[platform/core/appfw/aul-1.git] / include / aul.h
1 /*
2  *  aul
3  *
4  * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 #pragma once
21
22 #include <errno.h>
23 #include <bundle.h>
24 #include <sys/types.h>
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 /**
31  * @brief Return values in AUL.
32  */
33 typedef enum _aul_return_val {
34         AUL_R_ENOENT = -15,             /**< App directory entry error */
35         AUL_R_EREJECTED = -14,          /**< App disable for mode */
36         AUL_R_ENOAPP = -13,             /**< Failed to find app ID or pkg ID */
37         AUL_R_EHIDDENFORGUEST = -11,    /**< App hidden for guest mode */
38         AUL_R_ENOLAUNCHPAD = -10,       /**< no launchpad */
39         AUL_R_ETERMINATING = -9,        /**< application terminating */
40         AUL_R_EILLACC = -8,             /**< Illegal Access */
41         AUL_R_LOCAL = -7,               /**< Launch by himself */
42         AUL_R_ETIMEOUT = -6,            /**< Timeout */
43         AUL_R_ECANCELED = -5,           /**< Operation canceled */
44         AUL_R_EINVAL = -4,              /**< Invalid argument */
45         AUL_R_ECOMM = -3,               /**< Comunication Error */
46         AUL_R_ENOINIT = -2,             /**< AUL handler NOT initialized */
47         AUL_R_ERROR = -1,               /**< General error */
48         AUL_R_OK = 0                    /**< General success */
49 } aul_return_val;
50
51 enum app_status {
52         STATUS_LAUNCHING,
53         STATUS_CREATED,
54         STATUS_FOCUS,
55         STATUS_VISIBLE,
56         STATUS_BG,
57         STATUS_DYING,
58         STATUS_HOME,
59         STATUS_NORESTART,
60         STATUS_SERVICE,
61         STATUS_TERMINATE,
62 };
63
64 typedef enum _aul_type {
65         AUL_START,
66         AUL_RESUME,
67         AUL_TERMINATE,
68         AUL_TERMINATE_BGAPP,
69         AUL_PAUSE,
70         AUL_WAKE,
71         AUL_SUSPEND,
72         AUL_WIDGET_CONTENT,
73         AUL_UPDATE_REQUESTED,
74 } aul_type;
75
76 typedef enum aul_widget_lifecycle_event {
77         AUL_WIDGET_LIFE_CYCLE_EVENT_APP_DEAD = 0,
78         AUL_WIDGET_LIFE_CYCLE_EVENT_CREATE  = 1,    /**< The widget is created */
79         AUL_WIDGET_LIFE_CYCLE_EVENT_DESTROY = 2,    /**< The widget is destroyed */
80         AUL_WIDGET_LIFE_CYCLE_EVENT_PAUSE   = 3,    /**< The widget is paused */
81         AUL_WIDGET_LIFE_CYCLE_EVENT_RESUME  = 4    /**< The widget is resumed */
82 } aul_widget_lifecycle_event_e;
83
84 typedef enum aul_widget_instance_event {
85         AUL_WIDGET_INSTANCE_EVENT_CREATE = 0,
86         AUL_WIDGET_INSTANCE_EVENT_DESTROY = 1,
87         AUL_WIDGET_INSTANCE_EVENT_TERMINATE = 2,
88         AUL_WIDGET_INSTANCE_EVENT_PAUSE = 3,
89         AUL_WIDGET_INSTANCE_EVENT_RESUME = 4,
90         AUL_WIDGET_INSTANCE_EVENT_UPDATE = 5,
91         AUL_WIDGET_INSTANCE_EVENT_PERIOD_CHANGED = 6,
92         AUL_WIDGET_INSTANCE_EVENT_SIZE_CHANGED = 7,
93         AUL_WIDGET_INSTANCE_EVENT_EXTRA_UPDATED = 8,
94         AUL_WIDGET_INSTANCE_EVENT_FAULT = 9,
95         AUL_WIDGET_INSTANCE_EVENT_APP_RESTART_REQUEST = 10,
96         AUL_WIDGET_INSTANCE_EVENT_CREATE_ABORTED = 11
97 } aul_widget_instance_event_e;
98
99 /** AUL public key - To check caller's secuirty */
100 #define AUL_K_CALLER_PID        "__AUL_CALLER_PID__"
101 /** AUL public key - To check callee's secuirty */
102 #define AUL_K_CALLEE_PID        "__AUL_CALLEE_PID__"
103 /** AUL public key - added for multiuser mode */
104 #define AUL_K_CALLER_UID        "__AUL_CALLER_UID__"
105 /** AUL public key - added for multiuser mode */
106 #define AUL_K_CALLEE_UID        "__AUL_CALLEE_UID__"
107 /** AUL public key - added for multiuser mode */
108 #define AUL_K_TARGET_UID        "__AUL_TARGET_UID__"
109 /** AUL public key - To check caller's secuirty */
110 #define AUL_K_CALLER_APPID      "__AUL_CALLER_APPID__"
111 /** AUL public key - To check caller's secuirty */
112 #define AUL_K_CALLEE_APPID      "__AUL_CALLEE_APPID__"
113 /** AUL public key - To find argv0 */
114 #define AUL_K_ARGV0             "__AUL_ARGV0__"
115 /** AUL public key - To measure launching time */
116 #define AUL_K_STARTTIME         "__AUL_STARTTIME__"
117 /** AUL public key - To support launching based on mime type */
118 #define AUL_K_MIME_TYPE         "__AUL_MIME_TYPE__"
119 /** AUL public key - To support launching based on mime type */
120 #define AUL_K_UNALIASED_MIME_TYPE               "__AUL_UNALIASED_MIME_TYPE__"
121 /** AUL public key - To support launching based on mime type */
122 #define AUL_K_MIME_CONTENT      "__AUL_MIME_CONTENT__"
123 /** AUL public key - To support launching based on service */
124 #define AUL_K_SERVICE_NAME              "__AUL_SERVICE_NAME__"
125 /** AUL public key - To force launch app selector instead of lauchingn default app */
126 #define AUL_K_FORCE_LAUNCH_APP_SELECTOR "__AUL_FORCE_LAUNCH_APP_SELECTOR__"
127 /** AUL public key - To support debug argument */
128 #define AUL_K_DEBUG     "__AUL_DEBUG__"
129 /** AUL public key - To support SDK */
130 #define AUL_K_SDK       "__AUL_SDK__"
131 /** AUL public key - To support Media key */
132 #define AUL_K_MULTI_KEY "__AUL_MULTI_KEY__"
133 /** AUL public key - To support Media key */
134 #define AUL_K_MULTI_KEY_EVENT   "__AUL_MULTI_KEY_EVENT__"
135 /** AUL public bundle value */
136 #define AUL_K_PRIVACY_APPID             "__AUL_PRIVACY_APPID__"
137 /** AUL public bundle value - To support Media key*/
138 #define AUL_V_KEY_PRESSED       "__AUL_KEY_PRESSED__"
139 /** AUL public bundle value - To support Media key*/
140 #define AUL_V_KEY_RELEASED      "__AUL_KEY_RELEASED__"
141 /** AUL public key - To support rua stat */
142 #define AUL_SVC_K_RUA_STAT_CALLER "__K_RUA_STAT_CALLER__"
143 #define AUL_SVC_K_RUA_STAT_TAG    "__K_RUA_STAT_TAG__"
144 /** AUL public key - To support rua delete */
145 #define AUL_K_RUA_PKGNAME "__K_RUA_PKGNAME"
146 /** AUL public key - To support rua delete */
147 #define AUL_K_RUA_APPPATH "__K_RUA_APPPATH"
148 /** AUL public key - To support rua add */
149 #define AUL_K_RUA_ARG "__K_RUA_ARG"
150 /** AUL public key - To support rua add */
151 #define AUL_K_RUA_TIME "__K_RUA_TIME"
152 /** AUL public bundle value */
153 #define AUL_K_RUA_INSTANCE_ID "__K_RUA_INSTANCE_ID"
154 /** AUL public bundle value */
155 #define AUL_K_RUA_INSTANCE_NAME "__K_RUA_INSTANCE_NAME"
156 /** AUL public bundle value */
157 #define AUL_K_RUA_ICON "__K_RUA_ICON"
158 /** AUL public bundle value */
159 #define AUL_K_RUA_URI "__K_RUA_URI"
160
161 /** AUL internal private key */
162 #define AUL_K_PKG_NAME          "__AUL_PKG_NAME__"
163 /** AUL internal private key */
164 #define AUL_K_WAIT_RESULT       "__AUL_WAIT_RESULT__"
165 /** AUL internal private key */
166 #define AUL_K_SEND_RESULT       "__AUL_SEND_RESULT__"
167 /** AUL internal private key */
168 #define AUL_K_TASK_MANAGE       "__AUL_TASK_MANAGE__"
169 /** AUL internal private key */
170 #define AUL_K_APP_TYPE          "__AUL_APP_TYPE__"
171 /** AUL internal private key - To check original caller's identity */
172 #define AUL_K_ORG_CALLER_PID    "__AUL_ORG_CALLER_PID__"
173 /** AUL internal private key - To check forwarded callee app's pid */
174 #define AUL_K_FWD_CALLEE_PID    "__AUL_FWD_CALLEE_PID__"
175 /** AUL internal private key */
176 #define AUL_K_NO_CANCEL        "__AUL_NO_CANCEL__"
177 /** AUL internal private key */
178 #define AUL_K_EXEC              "__AUL_EXEC__"
179 /** AUL internal private key */
180 #define AUL_K_MULTIPLE          "__AUL_MULTIPLE__"
181 /** AUL internal private key */
182 #define AUL_K_PACKAGETYPE       "__AUL_PACKAGETYPE__"
183 /** AUL internal private key */
184 #define AUL_K_HWACC             "__AUL_HWACC__"
185 /** AUL internal private key */
186 #define AUL_K_APPID             "__AUL_APPID__"
187 /** AUL internal private key */
188 #define AUL_K_PID               "__AUL_PID__"
189 /** AUL internal private key */
190 #define AUL_K_WID               "__AUL_WID__"
191 /** AUL internal private key */
192 #define AUL_K_LEADER_PID        "__AUL_LEADER_PID__"
193 /** AUL internal private key - To support data control */
194 #define AUL_K_DATA_CONTROL_TYPE   "__AUL_DATA_CONTROL_TYPE__"
195 /** AUL internal private key */
196 #define AUL_K_PKGID             "__AUL_PKGID_"
197 /** AUL internal private key */
198 #define AUL_K_INTERNAL_POOL "__AUL_INTERNAL_POOL__"
199 /** AUL internal private key */
200 #define AUL_TEP_PATH            "_AUL_TEP_PATH_"
201 /** AUL internal private key */
202 #define AUL_K_COMP_TYPE         "__AUL_COMP_TYPE__"
203 /** AUL internal private key */
204 #define AUL_K_LOADER_ID         "__AUL_LOADER_ID__"
205 /** AUL internal private key */
206 #define AUL_K_LOADER_PATH       "__AUL_LOADER_PATH__"
207 /** AUL internal private key */
208 #define AUL_K_LOADER_EXTRA      "__AUL_LOADER_EXTRA__"
209 /** AUL internal private key */
210 #define AUL_K_LOADER_NAME       "__AUL_LOADER_NAME__"
211 /** AUL internal private key */
212 #define AUL_K_WAYLAND_DISPLAY   "__AUL_WAYLAND_DISPLAY__"
213 /** AUL internal private key */
214 #define AUL_K_WAYLAND_WORKING_DIR "__AUL_WAYLAND_WORKING_DIR__"
215 /** AUL internal private key */
216 #define AUL_K_COM_SENDER_PID    "__AUL_COM_SENDER_PID__"
217 /** AUL internal private key */
218 #define AUL_K_COM_ENDPOINT      "__AUL_COM_ENDPOINT__"
219 /** AUL internal private key */
220 #define AUL_K_COM_PRIVILEGE     "__AUL_COM_PRIVILEGE__"
221 /** AUL internal private key */
222 #define AUL_K_COM_PROPAGATE     "__AUL_COM_PROPAGATE__"
223 /** AUL internal private key */
224 #define AUL_K_COM_FILTER        "__AUL_COM_FILTER__"
225 /** AUL internal private key */
226 #define AUL_K_COM_RESULT        "__AUL_COM_RESULT__"
227 /** AUL internal private key */
228 #define AUL_K_ROOT_PATH         "__AUL_ROOT_PATH__"
229 /** AUL internal private key */
230 #define AUL_K_SEQ_NUM           "__AUL_SEQ_NUM__"
231 /** AUL internal private key */
232 #define AUL_K_API_VERSION       "__AUL_API_VERSION__"
233 /** AUL internal private key */
234 #define AUL_K_ALLOWED_BG        "__AUL_ALLOWED_BG__"
235 /** AUL internal private key */
236 #define AUL_K_OWNER_PID         "__AUL_OWNER_PID__"
237 /** AUL internal private key */
238 #define AUL_K_CHILD_PID         "__AUL_CHILD_PID__"
239 /** AUL internal private key */
240 #define AUL_K_WIDGET_VIEWER     "__AUL_WIDGET_VIEWER__"
241 /** AUL internal private key */
242 #define AUL_K_WIDGET_ID         "__AUL_WIDGET_ID__"
243 /** AUL internal private key */
244 #define AUL_K_WIDGET_INSTANCE_ID        "__AUL_WIDGET_INSTANCE_ID__"
245 /** AUL internal private key */
246 #define AUL_K_WIDGET_STATUS             "__AUL_WIDGET_STATUS__"
247 /** AUL internal private key */
248 #define AUL_K_WIDGET_CONTENT_INFO       "__AUL_WIDGET_CONTENT_INFO__"
249 /** AUL internal private key */
250 #define AUL_K_TARGET_PID        "__AUL_TARGET_PID__"
251 /** AUL internal private key */
252 #define AUL_K_ALIAS_APPID       "__AUL_ALIAS_APPID__"
253 /** AUL internal private key */
254 #define AUL_K_ORG_APPID         "__AUL_ORG_APPID__"
255 /** AUL internal private key */
256 #define AUL_K_STATUS            "__AUL_STATUS__"
257 /** AUL internal private key */
258 #define AUL_K_IS_SUBAPP         "__AUL_IS_SUBAPP__"
259 /** AUL internal private key */
260 #define AUL_K_INSTANCE_ID       "__AUL_INSTANCE_ID__"
261 /** AUL internal private key */
262 #define AUL_K_ORG_CALLER_UID    "__AUL_ORG_CALLER_UID__"
263 /** AUL internal private key */
264 #define AUL_K_CHECKSUM          "__AUL_CHECKSUM__"
265 /** AUL internal private key */
266 #define AUL_K_PRIVATE           "__AUL_PRIVATE__"
267 /** AUL internal private key */
268 #define AUL_K_SCREEN_TYPE       "__AUL_SCREEN_TYPE__"
269 /** AUL internal private key */
270 #define AUL_K_VIEWER_REF        "__AUL_VIEWER_REF__"
271 /** AUL internal private key */
272 #define AUL_K_PARENT_APPID      "__AUL_PARENT_APPID__"
273 /** AUL internal private key */
274 #define AUL_K_CHILD_APPID       "__AUL_CHILD_APPID__"
275
276
277 /**
278  * @brief       This is callback function for aul_launch_init
279  * @param[in]   type    event's type received from system
280  * @param[in]   b       In case of RESET events, bundle which is received from peer
281  * @param[in]   data    user-supplied data
282  */
283 typedef int (*aul_handler_fn)(aul_type type, bundle *b, void *data);
284
285 /**
286  * @par Description:
287  *      This API install your AUL handler and setup AUL internal connection.
288  * @par Purpose:
289  *      AUL receive START(RESET), RESUME, TERMINATE events from system.\n
290  *      This API use to handle the events. \n
291  * @par Typical use case:
292  *      In general, you need not use this API.
293  *      If you use AppCore, you should NOT use this API.
294  *      AppCore will set default aul_handler.
295  *
296  * @param[in]   handler         aul main callback handler function
297  * @param[in]   data            user-supplied data for start_handler
298  * @return      0 if success, negative value(<0) if fail\n
299  * @retval      AUL_R_OK        - success
300  * @retval      AUL_R_ECANCELD  - aul handler was installed already by others
301  * @retval      AUL_R_ECOMM     - error to create internal ipc
302  * @retval      AUL_R_ERROR     - error to attach glib main loop
303  *
304  * @warning     If you use AppCore, you should NOT use this API.\n
305  *              You need glib main loop.\n
306  * @pre
307  *      you must have aul handler to use this API.
308  *      aul_luanch_init register aul handler.
309  * @code
310  * #include <aul.h>
311  * #include <bundle.h>
312  *
313  * static int aul_handler(aul_type type, bundle *kb,void *data)
314  * {
315  *      switch(type)
316  *      {
317  *              case AUL_START:
318  *                      // process RESET event
319  *                      break;
320  *              case AUL_RESUME:
321  *                      // process RESUME event
322  *                      break;
323  *              case AUL_TERMINATE:
324  *                      // preocess TERMINATE event
325  *                      break;
326  *      }
327  *      return 0;
328  * }
329  *
330  * static GMainLoop *mainloop = NULL;
331  *
332  * int main(int argc, char **argv)
333  * {
334  *      aul_launch_init(aul_handler,NULL);
335  *      aul_launch_argv_handler(argc, argv);
336  *
337  *      mainloop = g_main_loop_new(NULL, FALSE);
338  *      g_main_loop_run(mainloop);
339  * }
340  *
341  * @endcode
342  * @remark
343  *      This API is only available in User Session.
344 */
345 int aul_launch_init(aul_handler_fn handler, void *data);
346
347 /**
348  * @par Description:
349  *      This API create internal RESET events with given argc, argv \n
350  * @par Purpose:
351  *      This API's purpose is to generate reset event.
352  *      If you want to generate local RESET events with argument vector format, use this API
353  * @par Typical use case:
354  *      In general, you need not use this API.
355  *      AppCore use this API to create internal reset event.
356  *
357  * @param[in]   argc    # of args
358  * @param[in]   argv    list of arg strings
359  * @return      0 if success, negative value(<0) if fail
360  * @retval      AUL_R_OK        - success
361  * @retval      AUL_R_ENOINIT   - aul handler was NOT yet installed
362  * @retval      AUL_R_ECANCLED  - error to create internal bundle with given argc,argv.
363  * @retval      AUL_R_ERROR     - general error
364  *
365  * @pre
366  *      you must have aul handler to use this API.
367  *      aul_luanch_init register aul handler.
368  * @see
369  *      aul_launch_init
370  * @code
371  * #include <aul.h>
372  * #include <bundle.h>
373  *
374  * int send_local_reset_event()
375  * {
376  *      int argc=3;
377  *      char* argv[4];
378  *      argv[0] = "local.app";
379  *      argv[1] = "event_type";
380  *      argv[2] = "my_reset";
381  *      argv[3] = NULL;
382  *      aul_launch_argv_handler(argc,argv);
383  * }
384  *
385  * @endcode
386  * @remark
387  *      If you use AppCore, you NEED NOT use this API.
388  *      This API is only available in User Session.
389 */
390 int aul_launch_argv_handler(int argc, char **argv);
391
392 /**
393  * @par Description:
394  *      This API creates internal RESET events with given bundle \n
395  * @par Purpose:
396  *  This API's purpose is to generate reset event.
397  *  If you want to generate local RESET events with argument vector format, first use
398  *  bundle_import_from_argv to create a bundle from the argument vector and then use this API
399  *  Eventually, this API will replace aul_launch_argv_handler().
400  * @par Typical use case:
401  *      In general, you need not use this API.
402  *      AppCore use this API to create internal reset event.
403  *
404  * @param[in]   b       bundle
405  * @return      0 if success, negative value(<0) if fail
406  * @retval      AUL_R_OK        - success
407  * @retval      AUL_R_ENOINIT   - aul handler was NOT yet installed
408  * @retval      AUL_R_ERROR     - general error
409  *
410  * @pre
411  *      you must have aul handler to use this API.
412  *      aul_luanch_init register aul handler.
413  * @post
414  *      None
415  * @see
416  *      aul_launch_init, bundle_import_from_argv
417  * @code
418  * #include <aul.h>
419  * #include <bundle.h>
420  *
421  * int send_local_reset_event()
422  * {
423  *  bundle* b;
424  *      int argc=3;
425  *      char* argv[4];
426  *      argv[0] = "local.app";
427  *      argv[1] = "event_type";
428  *      argv[2] = "my_reset";
429  *      argv[3] = NULL;
430  *
431  *      b = bundle_import_from_argv(argc,argv);
432  *      aul_launch_local(b);
433  * }
434  *
435  * @endcode
436  * @remark
437  *      If you use AppCore, you NEED NOT to use this API.
438  *      This API is only available in User Session.
439 */
440 int aul_launch_local(bundle *b);
441
442 /**
443  * @par Description:
444  *      This API launches application with the given bundle.
445  *  If the application is not running or a multiple-instance one, this API launches with the given bundle.
446  *      If the application is running, this API sends a RESET event to the App.
447  *      While the application is running, if the application cannot receive the RESET event,
448  *      this API returns a general error(AUL_R_ERROR).\n
449  * @par Purpose:
450  *      This API is for caller.
451  *      This API's purpose is to launch/reset application with given bundle.
452  * @par Typical use case:
453  *      If you know the target application's pkgname and bundle types,
454  *      you can use this API to launch/reset the application.
455  *
456  * @param[in]   pkgname         package name to be run as callee
457  * @param[in]   kb              bundle to be passed to callee
458  * @return      callee's pid if success, negative value(<0) if fail
459  * @retval      AUL_R_OK        - success
460  * @retval      AUL_R_EINVAL    - invaild package name
461  * @retval      AUL_R_ECOM      - internal AUL IPC error
462  * @retval      AUL_R_ERROR     - general error
463  *
464  * @see
465  *      aul_open_app
466  * @code
467  * #include <aul.h>
468  * #include <bundle.h>
469  *
470  * int launch_inhouse_contact_app()
471  * {
472  *      bundle *b;
473  *      b = bundle_create();
474  *      bundle_add(b,"type","SIM");
475  *      aul_launch_app("org.tizen.contact",b);
476  * }
477  *
478  * @endcode
479  * @remark
480  *      This API is only available in User Session.
481  */
482 int aul_launch_app(const char *appid, bundle *kb);
483
484 /**
485  * @par Description:
486  *      This API launches application with the given bundle.
487  *  If the application is not running or a multiple-instance one, this API launches with the given bundle.
488  *      If the application is running, this API sends a RESET event to the App.
489  *      While the application is running, if the application cannot receive the RESET event,
490  *      this API returns a general error(AUL_R_ERROR).\n
491  * @par Purpose:
492  *      This API is for caller.
493  *      This API's purpose is to launch/reset application with given bundle.
494  * @par Typical use case:
495  *      If you know the target application's pkgname and bundle types,
496  *      you can use this API to launch/reset the application.
497  *
498  * @param[in]   pkgname         package name to be run as callee
499  * @param[in]   kb              bundle to be passed to callee
500  * @param[in]   uid             User ID to launch
501  * @return      callee's pid if success, negative value(<0) if fail
502  * @retval      AUL_R_OK        - success
503  * @retval      AUL_R_EINVAL    - invaild package name
504  * @retval      AUL_R_ECOM      - internal AUL IPC error
505  * @retval      AUL_R_ERROR     - general error
506  *
507  * @see
508  *      aul_open_app
509  * @remark
510  *      This API is also available in System Session.
511  */
512 int aul_launch_app_for_uid(const char *appid, bundle *kb, uid_t uid);
513
514 /**
515  * @par Description:
516  *  This API launches application, as menu screen launches the app.
517  *  Thus, if the applocation is running, this API sends a RESUME event to the app.
518  *  If the application is not running, this API launches the app.
519  *  While the application is running, if the application cannot receive the RESUME event,
520  *  AUL tries to raise the application's default window.
521  *
522  * @par Purpose:
523  *      This API is for caller.
524  *      This API's purpose is to resume/launch application
525  * @par Typical use case:
526  *      If you only want to show application with previous state or default state, Use this API.
527  *
528  * @param[in]   pkgname         package name to be resume as callee
529  * @return      callee's pid if success, negative value(<0) if fail
530  * @retval      AUL_R_OK        - success
531  * @retval      AUL_R_EINVAL    - invaild package name
532  * @retval      AUL_R_ECOM      - internal AUL IPC error
533  * @retval      AUL_R_ERROR     - general error
534  *
535  * @see
536  *      aul_launch_app, aul_app_is_running, aul_resume_pid
537  * @code
538  * #include <aul.h>
539  * #include <bundle.h>
540  *
541  * int open_inhouse_contact_app()
542  * {
543  *      if(aul_app_is_running("org.tizen.contact"))
544  *              aul_open_app("org.tizen.contact");
545  * }
546  *
547  * @endcode
548  * @remark
549  *      If you don't want to launch the app,
550  *      you should check app's running state with aul_app_is_running.
551  *      This API will launch the application if the application is not running.
552  *      This API is only available in User Session.
553 */
554 int aul_open_app(const char *appid);
555
556 /**
557  * @par Description:
558  *  This API launches application, as menu screen launches the app.
559  *  Thus, if the applocation is running, this API sends a RESUME event to the app.
560  *  If the application is not running, this API launches the app.
561  *  While the application is running, if the application cannot receive the RESUME event,
562  *  AUL tries to raise the application's default window.
563  *
564  * @par Purpose:
565  *      This API is for caller.
566  *      This API's purpose is to resume/launch application
567  * @par Typical use case:
568  *      If you only want to show application with previous state or default state, Use this API.
569  *
570  * @param[in]   pkgname         package name to be resume as callee
571  * @param[in]   uid             User ID
572  * @return      callee's pid if success, negative value(<0) if fail
573  * @retval      AUL_R_OK        - success
574  * @retval      AUL_R_EINVAL    - invaild package name
575  * @retval      AUL_R_ECOM      - internal AUL IPC error
576  * @retval      AUL_R_ERROR     - general error
577  *
578  * @remark
579  *      If you don't want to launch the app,
580  *      you should check app's running state with aul_app_is_running.
581  *      This API will launch the application if the application is not running.
582  *      This API is only available to System user.
583  */
584 int aul_open_app_for_uid(const char *appid, uid_t uid);
585
586 /**
587  * @par Description:
588  *      This API trigger to resume application
589  *      If the application is running, this API send a resume event to the App.
590  *      If the application is not running, this API returns fail.
591  *      Although the application is running, if the application cannot receive resume event,
592  *      AUL try to raise the application's default windows.
593  * @par Purpose:
594  *      This API is for caller.
595  *      This API's purpose is to send resume event.
596  * @par Typical use case:
597  *      If you only want to show application with previous state or default state, Use this API.
598  *
599  * @param[in]   pkgname         package name to be resume as callee
600  * @return      callee's pid if success, negative value(<0) if fail
601  * @retval      AUL_R_OK        - success
602  * @retval      AUL_R_EINVAL    - invaild package name
603  * @retval      AUL_R_ECOM      - internal AUL IPC error
604  * @retval      AUL_R_ERROR     - general error
605  *
606  * @see
607  *      aul_launch_app, aul_app_is_running, aul_resume_pid
608  * @deprecated
609  *  This function will be deprecated. Use aul_open_add() instead.
610  * @code
611  * #include <aul.h>
612  * #include <bundle.h>
613  *
614  * int resume_inhouse_contact_app()
615  * {
616  *      if(aul_app_is_running("org.tizen.contact"))
617  *              aul_resume_app("org.tizen.contact");
618  * }
619  *
620  * @endcode
621  * @remark
622  *      If you don't want to launch the app,
623  *      you should check app's running state with aul_app_is_running.
624  *      This API will launch the application if the application is not running.
625  *      If you want to only resume without launching in multiple instance application model,
626  *      you should use aul_resume_pid.
627  *      This API is only available in User Session.
628 */
629 int aul_resume_app(const char *appid);
630
631 /**
632  * @par Description:
633  *      This API trigger to resume application
634  *      If the application is running, this API send a resume event to the App.
635  *      If the application is not running, this API returns fail.
636  *      Although the application is running, if the application cannot receive resume event,
637  *      AUL try to raise the application's default windows.
638  * @par Purpose:
639  *      This API is for caller.
640  *      This API's purpose is to send resume event.
641  * @par Typical use case:
642  *      If you only want to show application with previous state or default state, Use this API.
643  *
644  * @param[in]   pkgname         package name to be resume as callee
645  * @param[in]   uid             User ID
646  * @return      callee's pid if success, negative value(<0) if fail
647  * @retval      AUL_R_OK        - success
648  * @retval      AUL_R_EINVAL    - invaild package name
649  * @retval      AUL_R_ECOM      - internal AUL IPC error
650  * @retval      AUL_R_ERROR     - general error
651  *
652  * @remark
653  *      If you don't want to launch the app,
654  *      you should check app's running state with aul_app_is_running.
655  *      This API will launch the application if the application is not running.
656  *      If you want to only resume without launching in multiple instance application model,
657  *      you should use aul_resume_pid.
658  *      This API is only available to System user.
659  */
660 int aul_resume_app_for_uid(const char *appid, uid_t uid);
661
662 /**
663  * @par Description:
664  *      This API trigger to resume application
665  *      If the application is running, this API send a resume event to the App.
666  *      If the application is not running, this API return AUL_R_ERROR.
667  *      Although the application is running, if the application cannot receive resume event,
668  *      AUL try to raise the application's default windows.
669  * @par Purpose:
670  *      This API is for caller.
671  *      This API's purpose is to send resume event.
672  * @par Typical use case:
673  *      In multiple application model, If you want to only resume specific application, Use this API
674  *
675  * @param[in]   pid     application's pid to be resumed
676  * @return      0 if success, negative value(<0) if fail
677  * @retval      AUL_R_OK        - success
678  * @retval      AUL_R_EINVAL    - invaild pid
679  * @retval      AUL_R_ECOM      - internal AUL IPC error
680  * @retval      AUL_R_ERROR     - general error (include application is not running)
681  * @warning     This API need to require root or inhouse permisssion \n
682  *              If you have not the permission, this API return AUL_R_ERROR. \n
683  * @see
684  *      aul_launch_app
685  * @code
686  * #include <aul.h>
687  * #include <bundle.h>
688  *
689  * int iterfunc(const aul_app_info *info, void *data)
690  * {
691  *      if(strcmp(info->pkg_name,"org.tizen.contact")==0)
692  *              aul_resume_pid(info->pid);
693  * }
694  *
695  * int iterate_running_apps()
696  * {
697  *      return aul_app_get_running_app_info(iterfunc,NULL);
698  * }
699  *
700  * @endcode
701  * @remark
702  *      This API is only available in User Session.
703 */
704 int aul_resume_pid(int pid);
705
706 /**
707  * @par Description:
708  *      This API trigger to resume application
709  *      If the application is running, this API send a resume event to the App.
710  *      If the application is not running, this API return AUL_R_ERROR.
711  *      Although the application is running, if the application cannot receive resume event,
712  *      AUL try to raise the application's default windows.
713  * @par Purpose:
714  *      This API is for caller.
715  *      This API's purpose is to send resume event.
716  * @par Typical use case:
717  *      In multiple application model, If you want to only resume specific application, Use this API
718  *
719  * @param[in]   pid     application's pid to be resumed
720  * @param[in]   uid     User ID
721  * @return      0 if success, negative value(<0) if fail
722  * @retval      AUL_R_OK        - success
723  * @retval      AUL_R_EINVAL    - invaild pid
724  * @retval      AUL_R_ECOM      - internal AUL IPC error
725  * @retval      AUL_R_ERROR     - general error (include application is not running)
726  * @warning     This API need to require root or inhouse permisssion \n
727  *              If you have not the permission, this API return AUL_R_ERROR. \n
728  * @remark
729  *      This API is only available to System user.
730 */
731 int aul_resume_pid_for_uid(int pid, uid_t uid);
732
733 /**
734  * @par Description:
735  *      This API trigger to terminate application
736  *
737  *      If the application is running, this API send a terminate event to the App. \n
738  *      If the app cannot receive the event, AUL kill forcely the application.\n
739  * @par Purpose:
740  *      This API's purpose is to kill application
741  * @par Typical use case:
742  *      In general, Application like Task Manager use this API.
743  *
744  *              This API need to require root or inhouse permisssion. \n
745  *
746  * @param[in]   pid     application's pid to be terminated
747  * @return      0 if success, negative value(<0) if fail
748  * @retval      AUL_R_OK        - success
749  * @retval      AUL_R_EINVAL    - invaild pid
750  * @retval      AUL_R_ECOM      - internal AUL IPC error
751  * @retval      AUL_R_ERROR     - general error
752  * @warning     This API need to require root or inhouse permisssion. \n
753  *
754  * @code
755  * #include <aul.h>
756  * #include <bundle.h>
757  *
758  * int iterfunc(const aul_app_info *info, void *data)
759  * {
760  *      if(strcmp(info->pkg_name,"org.tizen.contact")==0)
761  *              aul_terminate_pid(info->pid);
762  * }
763  *
764  * int iterate_running_apps()
765  * {
766  *      return aul_app_get_running_app_info(iterfunc,NULL);
767  * }
768  *
769  * @endcode
770  * @remark
771  *      If you have not the permission, this API return AUL_R_ERROR. \n
772  *      This API is only available in User Session.
773 */
774 int aul_terminate_pid(int pid);
775
776 /**
777  * @par Description:
778  *      This API trigger to terminate application
779  *
780  *      If the application is running, this API send a terminate event to the App. \n
781  *      If the app cannot receive the event, AUL kill forcely the application.\n
782  * @par Purpose:
783  *      This API's purpose is to kill application
784  * @par Typical use case:
785  *      In general, Application like Task Manager use this API.
786  *
787  *              This API need to require root or inhouse permisssion. \n
788  *
789  * @param[in]   pid     application's pid to be terminated
790  * @param[in]   uid     User ID
791  * @return      0 if success, negative value(<0) if fail
792  * @retval      AUL_R_OK        - success
793  * @retval      AUL_R_EINVAL    - invaild pid
794  * @retval      AUL_R_ECOM      - internal AUL IPC error
795  * @retval      AUL_R_ERROR     - general error
796  * @warning     This API need to require root or inhouse permisssion. \n
797  *
798  * @remark
799  *      If you have not the permission, this API return AUL_R_ERROR. \n
800  *      This API is only available to System user.
801  */
802 int aul_terminate_pid_for_uid(int pid, uid_t uid);
803
804 /**
805  * @par Description:
806  *      This API trigger to terminate application asynchronously
807  *
808  *      If the application is running, this API send a terminate event to the App. \n
809  *      If the app cannot receive the event, AUL kill forcely the application.\n
810  * @par Purpose:
811  *      This API's purpose is to kill application
812  * @par Typical use case:
813  *      In general, Application like Task Manager use this API.
814  *
815  *              This API need to require root or inhouse permisssion. \n
816  *
817  * @param[in]   pid     application's pid to be terminated
818  * @return      0 if success, negative value(<0) if fail
819  * @retval      AUL_R_OK        - success
820  * @retval      AUL_R_EINVAL    - invaild pid
821  * @retval      AUL_R_ECOM      - internal AUL IPC error
822  * @retval      AUL_R_ERROR     - general error
823  * @warning     This API need to require root or inhouse permisssion. \n
824  * @remark
825  *      If you have not the permission, this API return AUL_R_ERROR. \n
826  *      This API is only available in User Session.
827 */
828 int aul_terminate_pid_async(int pid);
829
830 /**
831  * @par Description:
832  *      This API trigger to terminate application asynchronously
833  *
834  *      If the application is running, this API send a terminate event to the App. \n
835  *      If the app cannot receive the event, AUL kill forcely the application.\n
836  * @par Purpose:
837  *      This API's purpose is to kill application
838  * @par Typical use case:
839  *      In general, Application like Task Manager use this API.
840  *
841  *              This API need to require root or inhouse permisssion. \n
842  *
843  * @param[in]   pid     application's pid to be terminated
844  * @param[in]   uid     User ID
845  * @return      0 if success, negative value(<0) if fail
846  * @retval      AUL_R_OK        - success
847  * @retval      AUL_R_EINVAL    - invaild pid
848  * @retval      AUL_R_ECOM      - internal AUL IPC error
849  * @retval      AUL_R_ERROR     - general error
850  * @warning     This API need to require root or inhouse permisssion. \n
851  * @remark
852  *      If you have not the permission, this API return AUL_R_ERROR. \n
853  *      This API is only available to System user.
854  */
855 int aul_terminate_pid_async_for_uid(int pid, uid_t uid);
856
857 /**
858  * @par Description:
859  *      This API trigger to terminate application synchronously
860  *
861  *      If the application is running, this API sends a terminate event to the application. \n
862  *      And then, this API waits until the application is terminated successfully. \n
863  *      If the app cannot receive the event, AUL kill forcely the application. \n
864  * @par Purpose:
865  *      This API's purpose is to kill application
866  * @par Typical use case:
867  *      In general, Application like Task Manager use this API.
868  *
869  *              This API need to require root or platform level permisssion. \n
870  *
871  * @param[in]   pid     application's pid to be terminated
872  * @return      0 if success, negative value(<0) if fail
873  * @retval      AUL_R_OK        - success
874  * @retval      AUL_R_EINVAL    - invaild pid
875  * @retval      AUL_R_ECOM      - internal AUL IPC error
876  * @retval      AUL_R_ERROR     - general error
877  * @warning     This API need to require root or platform level permisssion. \n
878  * @remark
879  *      If you have not the permission, this API return AUL_R_ERROR. \n
880  *      This API is only available in User Session.
881 */
882 int aul_terminate_pid_sync(int pid);
883
884 /**
885  * @par Description:
886  *      This API trigger to terminate application synchronously
887  *
888  *      If the application is running, this API send a terminate event to the application. \n
889  *      And then, this API waits until the application is terminated successfully. \n
890  *      If the app cannot receive the event, AUL kill forcely the application. \n
891  * @par Purpose:
892  *      This API's purpose is to kill application
893  * @par Typical use case:
894  *      In general, Application like Task Manager use this API.
895  *
896  *              This API need to require root or platform level permisssion. \n
897  *
898  * @param[in]   pid     application's pid to be terminated
899  * @param[in]   uid     User ID
900  * @return      0 if success, negative value(<0) if fail
901  * @retval      AUL_R_OK        - success
902  * @retval      AUL_R_EINVAL    - invaild pid
903  * @retval      AUL_R_ECOM      - internal AUL IPC error
904  * @retval      AUL_R_ERROR     - general error
905  * @warning     This API need to require root or platform level permisssion. \n
906  * @remark
907  *      If you have not the permission, this API return AUL_R_ERROR. \n
908  *      This API is only available to System user.
909  */
910 int aul_terminate_pid_sync_for_uid(int pid, uid_t uid);
911
912 /**
913  *@brief Running application's information structure retrieved by AUL
914  */
915 typedef struct _aul_app_info {
916         int pid;                /**< app's pid if running*/
917         char *pkg_name;         /**< application id */
918         char *app_path;         /**< application excutable path */
919         char *appid;
920         char *pkgid;            /**< package id */
921         int status;             /**< app's status */
922         int is_sub_app;         /**< state whether sub app of app group */
923         char *instance_id;
924 } aul_app_info;
925
926 /**
927  * @brief iterator function running with aul_app_get_running_app_info
928  * @param[out]  ainfo   aul_app_info retreived by aul_app_get_running_app_info
929  * @param[out]  data    user-supplied data
930 */
931 typedef int (*aul_app_info_iter_fn)(const aul_app_info *ainfo, void *data);
932
933 /**
934  * @par Description:
935  *      This API ask a application is running by application package name.
936  * @par Purpose:
937  *      To know whether some application is running or not, use this API
938  * @par Typical use case:
939  *      For example, If you want to know browser application running,
940  *      you can check it by using this API.
941  *
942  * @param[in]   pkgname application package name
943  * @return      true / false
944  * @retval      1       app_name is running now.
945  * @retval      0       app_name is NOT running now.
946  *
947  * @code
948  * #include <aul.h>
949  *
950  * int is_running_browser_app()
951  * {
952  *      return aul_app_is_running("org.tizen.browser");
953  * }
954  *
955  * @endcode
956  * @remark
957  *      This API is only available in User Session.
958  *
959  */
960 int aul_app_is_running(const char *appid);
961
962 /**
963  * @par Description:
964  *      This API ask a application is running by application package name.
965  * @par Purpose:
966  *      To know whether some application is running or not, use this API
967  * @par Typical use case:
968  *      For example, If you want to know browser application running,
969  *      you can check it by using this API.
970  *
971  * @param[in]   pkgname application package name
972  * @param[in]   uid     User ID
973  * @return      true / false
974  * @retval      1       app_name is running now.
975  * @retval      0       app_name is NOT running now.
976  *
977  * @endcode
978  * @remark
979  *      This API is only available to System User.
980  */
981 int aul_app_is_running_for_uid(const char *appid, uid_t uid);
982
983 /**
984  * @par Description:
985  *      This API use to get running application list.
986  *      This API call iter_fn with each aul_app_info of running apps when running application is found.
987  * @par Purpose:
988  *      If you want to get running application list, use this API
989  * @par Typical use case:
990  *      In general, this API is used by task manager appllication. (running application list viewer)
991  *
992  * @param[in]   iter_fn         iterator function
993  * @param[in]   user_data       user-supplied data for iter_fn
994  * @return      0 if success, negative value(<0) if fail
995  * @retval      AUL_R_OK        - success
996  * @retval      AUL_R_ERROR     - internal error
997  *
998  * @code
999  * #include <aul.h>
1000  *
1001  * int iterfunc(const aul_app_info* info, void* data)
1002  * {
1003  *      printf("\t==========================\n");
1004  *      printf("\t pkg_name: %s\n", info->appid);
1005  *      printf("\t app_path: %s\n", info->app_path);
1006  *      printf("\t running pid: %d\n", info->pid);
1007  *      printf("\t==========================\n");
1008  *      return 0;
1009  * }
1010  *
1011  * int iterate_running_apps()
1012  * {
1013  *      return aul_app_get_running_app_info(iterfunc,NULL);
1014  * }
1015  *
1016  * @endcode
1017  * @remark
1018  *      This API should use if you want to know running application which has desktop files.
1019  *      If you want to get all process list, you must iterate process information by using proc filesystem
1020  *      Or, If you want to get all window list, you must iterate XWindows by using XWindow APIs
1021  *      This API is only available in User Session.
1022  */
1023 int aul_app_get_running_app_info(aul_app_info_iter_fn iter_fn, void *user_data);
1024
1025 /**
1026  * @par Description:
1027  *      This API use to get running application list.
1028  *      This API call iter_fn with each aul_app_info of running apps when running application is found.
1029  * @par Purpose:
1030  *      If you want to get running application list, use this API
1031  * @par Typical use case:
1032  *      In general, this API is used by task manager appllication. (running application list viewer)
1033  *
1034  * @param[in]   iter_fn         iterator function
1035  * @param[in]   user_data       user-supplied data for iter_fn
1036  * @param[in]   uid             User ID
1037  * @return      0 if success, negative value(<0) if fail
1038  * @retval      AUL_R_OK        - success
1039  * @retval      AUL_R_ERROR     - internal error
1040  *
1041  * @remark
1042  *      This API should use if you want to know running application which has desktop files.
1043  *      If you want to get all process list, you must iterate process information by using proc filesystem
1044  *      Or, If you want to get all window list, you must iterate XWindows by using XWindow APIs
1045  *      This API is only available to System user.
1046  */
1047 int aul_app_get_running_app_info_for_uid(aul_app_info_iter_fn iter_fn, void *user_data, uid_t uid);
1048
1049 /**
1050  * @par Description:
1051  *      This API use to get all running application list, including sub app.
1052  *      This API call iter_fn with each aul_app_info of running apps when running application is found.
1053  * @par Purpose:
1054  *      If you want to get all running application list, use this API
1055  * @par Typical use case:
1056  *      In general, this API is used by task manager application. (running application list viewer)
1057  *
1058  * @param[in]   iter_fn         iterator function
1059  * @param[in]   user_data       user-supplied data for iter_fn
1060  * @return      0 if success, negative value(<0) if fail
1061  * @retval      AUL_R_OK        - success
1062  * @retval      AUL_R_ERROR     - internal error
1063  *
1064  * @code
1065  * #include <aul.h>
1066  *
1067  * int iterfunc_status(const aul_app_info *info, void *data)
1068  * {
1069  *      printf("\t==========================\n");
1070  *      printf("\t pid: %d\n", info->pid);
1071  *      printf("\t appid: %s\n", info->appid);
1072  *      printf("\t app_path: %s\n", info->app_path);
1073  *      printf("\t pkgid: %s\n", info->pkgid);
1074  *      printf("\t status: %d\n", info->status);
1075  *      printf("\t is_sub_app : %d\n", info->is_sub_app);
1076  *      printf("\t==========================\n");
1077  *      return 0;
1078  * }
1079  *
1080  * int iterate_running_apps()
1081  * {
1082  *      return aul_app_get_all_running_app_info(iterfunc_status,NULL);
1083  * }
1084  *
1085  * @endcode
1086  * @remark
1087  *      This API should use if you want to know running application which has desktop files.
1088  *      If you want to get all process list, you must iterate process information by using proc filesystem
1089  *      Or, If you want to get all window list, you must iterate XWindows by using XWindow APIs
1090  *      This API is only available in User Session.
1091  */
1092 int aul_app_get_all_running_app_info(aul_app_info_iter_fn iter_fn, void *user_data);
1093
1094 /**
1095  * @par Description:
1096  *      This API use to get all running application list, including sub app.
1097  *      This API call iter_fn with each aul_app_info of running apps when running application is found.
1098  * @par Purpose:
1099  *      If you want to get all running application list, use this API
1100  * @par Typical use case:
1101  *      In general, this API is used by task manager application. (running application list viewer)
1102  *
1103  * @param[in]   iter_fn         iterator function
1104  * @param[in]   user_data       user-supplied data for iter_fn
1105  * @param[in]   uid             User ID
1106  * @return      0 if success, negative value(<0) if fail
1107  * @retval      AUL_R_OK        - success
1108  * @retval      AUL_R_ERROR     - internal error
1109  *
1110  * @remark
1111  *      This API should use if you want to know running application which has desktop files.
1112  *      If you want to get all process list, you must iterate process information by using proc filesystem
1113  *      Or, If you want to get all window list, you must iterate XWindows by using XWindow APIs
1114  *      This API is only available to System user.
1115  */
1116 int aul_app_get_all_running_app_info_for_uid(aul_app_info_iter_fn iter_fn, void *user_data, uid_t uid);
1117
1118 /**
1119  * @par Description:
1120  *      This API get application package name by pid
1121  * @par Purpose:
1122  *      If you want to get package name of running application, use this API
1123  * @par Typical use case:
1124  *      In general, You can use this API when you want to know caller's information.
1125  *
1126  * @param[in]   pid             given pid
1127  * @param[out]  pkgname         pkgname to be get
1128  * @param[in]   len             length of pkgname
1129  * @return      0 if success, negative value(<0) if fail
1130  * @retval      AUL_R_OK        - success
1131  * @retval      AUL_R_ERROR     - no such a package name
1132  * @code
1133  * #include <aul.h>
1134  * #include <bundle.h>
1135  *
1136  * static int app_reset(bundle *b, void *data)
1137  * {
1138  *      int pid;
1139  *      char appname[255];
1140  *
1141  *      pid = atoi(bundle_get_val(b,AUL_K_CALLER_PID));
1142  *      aul_app_get_pkgname_bypid(pid, appname, sizeof(appname));
1143  * }
1144  *
1145  * @endcode
1146  * @remark
1147  *      This API is only available in User Session.
1148 */
1149 int aul_app_get_pkgname_bypid(int pid, char *pkgname, int len);
1150
1151 /**
1152  * @par Description:
1153  *      This API get application pkgid by pid
1154  * @par Purpose:
1155  *      If you want to get pkgid of running application, use this API
1156  * @par Typical use case:
1157  *      In general, You can use this API when you want to know caller's information.
1158  *
1159  * @param[in]   pid             given pid
1160  * @param[out]  pkgid           package id
1161  * @param[in]   len             length of pkgid
1162  * @return      0 if success, negative value(<0) if fail
1163  * @retval      AUL_R_OK        - success
1164  * @retval      AUL_R_ERROR     - no such a appid
1165  *
1166  * @code
1167  * #include <aul.h>
1168  * #include <bundle.h>
1169  *
1170  * static int app_reset(bundle *b, void *data)
1171  * {
1172  *      int pid;
1173  *      char pkgid[255];
1174  *
1175  *      pid = atoi(bundle_get_val(b, AUL_K_CALLER_PID));
1176  *      aul_app_get_pkgid_bypid(pid, pkgid, sizeof(pkgid));
1177  * }
1178  *
1179  * @endcode
1180  * @remark
1181  *      This API is only available in User Session.
1182 */
1183 int aul_app_get_pkgid_bypid(int pid, char *pkgid, int len);
1184
1185 /**
1186  * @par Description:
1187  *      This API get application pkgid by pid
1188  * @par Purpose:
1189  *      If you want to get pkgid of running application, use this API
1190  * @par Typical use case:
1191  *      In general, You can use this API when you want to know caller's information.
1192  *
1193  * @param[in]   pid             given pid
1194  * @param[out]  pkgid           package id
1195  * @param[in]   len             length of pkgid
1196  * @param[in]   uid             User ID
1197  * @return      0 if success, negative value(<0) if fail
1198  * @retval      AUL_R_OK        - success
1199  * @retval      AUL_R_ERROR     - no such a appid
1200  *
1201  * @remark
1202  *      This API is also available to System user.
1203 */
1204 int aul_app_get_pkgid_bypid_for_uid(int pid, char *pkgid, int len, uid_t uid);
1205
1206 /**
1207  * @par Description:
1208  *      This API get application appid by pid
1209  * @par Purpose:
1210  *      If you want to get appid of running application, use this API
1211  * @par Typical use case:
1212  *      In general, You can use this API when you want to know caller's information.
1213  *
1214  * @param[in]   pid             given pid
1215  * @param[out]  appid           application id
1216  * @param[in]   len             length of pkgname
1217  * @return      0 if success, negative value(<0) if fail
1218  * @retval      AUL_R_OK        - success
1219  * @retval      AUL_R_ERROR     - no such a appid
1220  * @code
1221  * #include <aul.h>
1222  * #include <bundle.h>
1223  *
1224  * static int app_reset(bundle *b, void *data)
1225  * {
1226  *      int pid;
1227  *      char appid[255];
1228  *
1229  *      pid = atoi(bundle_get_val(b,AUL_K_CALLER_PID));
1230  *      aul_app_get_appid_bypid(pid, appid, sizeof(appid));
1231  * }
1232  *
1233  * @endcode
1234  * @remark
1235  *      This API is only available in User Session.
1236 */
1237 int aul_app_get_appid_bypid(int pid, char *appid, int len);
1238
1239 /**
1240  * @par Description:
1241  *      This API get application appid by pid
1242  * @par Purpose:
1243  *      If you want to get appid of running application, use this API
1244  * @par Typical use case:
1245  *      In general, You can use this API when you want to know caller's information.
1246  *
1247  * @param[in]   pid             given pid
1248  * @param[out]  appid           application id
1249  * @param[in]   len             length of pkgname
1250  * @param[in]   uid             User ID
1251  * @return      0 if success, negative value(<0) if fail
1252  * @retval      AUL_R_OK        - success
1253  * @retval      AUL_R_ERROR     - no such a appid
1254  * @remark
1255  *      This API is also available to System user.
1256 */
1257 int aul_app_get_appid_bypid_for_uid(int pid, char *appid, int len, uid_t uid);
1258
1259 /**
1260  * @par Description:
1261  *      This API launch application associated with given filename
1262  * @par Purpose:
1263  *      This API is for caller.
1264  *      This API launch application based on mime type.
1265  *      This API find mime_type associated with file name,
1266  *      and then find default app associated with found mime_type
1267  *      and then launch the app with filename argument.
1268  * @par Typical use case:
1269  *      You can launch application to process given filename.
1270  *      That is, Even if you don't know the specific application's pkgname,
1271  *      you can launch the applicaiton processing given filename .
1272  *      For example, If you want to process image file, you can simply launch image viewer.
1273  *      At that time, you can use this APIs like aul_open_file("myimage.jpg");
1274  *
1275  * @param[in]   filename        filename
1276  * @return      callee's pid or 0 if success, negative value if fail\n
1277  *              (when no found default app, return 0)
1278  * @retval      AUL_R_OK        - success
1279  * @retval      AUL_R_EINVAL    - invalid argument(filename)
1280  * @retval      AUL_R_ECOM      - internal AUL IPC error
1281  * @retval      AUL_R_ERROR     - general error
1282  *
1283  * @code
1284  * #include <aul.h>
1285  *
1286  * int view_image_file(char *filename)
1287  * {
1288  *      aul_open_file(filename);
1289  * }
1290  *
1291  * @endcode
1292  * @remark
1293  *      This API is only available in User Session.
1294  *
1295  */
1296 int aul_open_file(const char* filename);
1297
1298 /**
1299  * @par Description:
1300  *      This API launch application associated with given specific mimetype
1301  * @par Purpose:
1302  *      This API is for caller.
1303  *      This API launch application based on mime type like aul_open_file API.
1304  *      But, This API don't find mime_type associated with file name.
1305  *      This API use mimetype given by user. By using given mimetype, find default application.
1306  *      and then launch the app with filename argument.
1307  * @par Typical use case:
1308  *      Some files cannot extract exact mimetype automatically.
1309  *      For example, To know mime type of files with DRM lock, first we should unlock DRM file.
1310  *      In this case, You can use this API.
1311  *      First, unlock DRM file, and extract mimetype from unlock file by using aul_get_mime_from_file,
1312  *      and then, use this API with DRM file and extracted mime type.
1313  *
1314  * @param[in]   filename        filename
1315  * @param[in]   mimetype        specific mimetype
1316  * @return      callee's pid or 0 if success, negative value if fail\n
1317  *              (when no found default app, return 0)
1318  * @retval      AUL_R_OK        - success
1319  * @retval      AUL_R_EINVAL    - invalid argument(filename,mimetype)
1320  * @retval      AUL_R_ECOM      - internal AUL IPC error
1321  * @retval      AUL_R_ERROR     - general error
1322  *
1323  * @see
1324  *      aul_open_file, aul_get_mime_from_file
1325  * @code
1326  * #include <aul.h>
1327  *
1328  * int view_drm_image_file(char *drm_filename)
1329  * {
1330  *      char* mimetype;
1331  *      // you must implement this function
1332  *      mimetype = get_mimetype_from_drmfile(drm_filename);
1333  *
1334  *      aul_open_file_with_mimetype(drm_filename,mimetype);
1335  * }
1336  *
1337  * @endcode
1338  * @remark
1339  *      This API is only available in User Session.
1340  */
1341 int aul_open_file_with_mimetype(const char *filename, const char *mimetype);
1342
1343 /**
1344  * @par Description:
1345  *      This API launch application associated with content like "http://www.samsung.com"
1346  * @par Purpose:
1347  *      This API is for caller.
1348  *      This API launch application based on mime type.
1349  *      This API find mime_type associated with content,
1350  *      and then find default app associated with found mime_type,
1351  *      and then launch the app with content argument.
1352  * @par Typical use case:
1353  *      You can launch application to process given content.
1354  *      That is, Even if you don't know the specific application's pkgname,
1355  *      you can launch the applicaiton processing given content.
1356  *      For example, If you want to process URL "http://www.samsung.com",
1357  *      you can simply launch browser.
1358  *      At that time, you can use this APIs like aul_open_content("http://www.samsung.com");
1359  *
1360  * @param[in]   content         content
1361  * @return      callee's pid or 0 if success, negative value if fail\n
1362  *              (when no found default app, return 0)
1363  * @retval      AUL_R_OK        - success
1364  * @retval      AUL_R_EINVAL    - invalid argument(content)
1365  * @retval      AUL_R_ECOM      - internal AUL IPC error
1366  * @retval      AUL_R_ERROR     - general error or no found mimetype
1367  *
1368  * @code
1369  * #include <aul.h>
1370  *
1371  * int view_url(char *url)
1372  * {
1373  *      aul_open_content(url);
1374  * }
1375  *
1376  * @endcode
1377  * @remark
1378  *      This API is only available in User Session.
1379  *
1380  */
1381 int aul_open_content(const char* content);
1382
1383 /**
1384  * @par Description:
1385  *       This API get the default application(appid) associated with MIME type
1386  * @par Purpose:
1387  *      This API use to get default application associteted with mimetype
1388  *      In general, Setting Application need this API.
1389  * @par Typical use case:
1390  *      Setting Application show mapping of default application / mimetype
1391  *
1392  * @param[in]   mimetype        a mime type
1393  * @param[out]  defapp          a application appid of the app
1394  * @param[in]   len             length of defapp
1395  * @return      0 if success, negative value if fail
1396  * @retval      AUL_R_OK        - success
1397  * @retval      AUL_R_EINVAL    - invalid argument(mimetype)
1398  * @retval      AUL_R_ERROR     - general error or no found mimetype
1399  *
1400  * @see
1401  *      aul_set_defapp_with_mime
1402  * @code
1403  * #include <aul.h>
1404  *
1405  * void get_text_html_defapp()
1406  * {
1407  *      char appname[255];
1408  *      aul_get_defapp_from_mime("text/html",appname,sizeof(appname));
1409  * }
1410  *
1411  * @endcode
1412  * @remark
1413  *      This API is only available in User Session.
1414  *
1415  */
1416 int aul_get_defapp_from_mime(const char *mimetype, char *defapp, int len);
1417
1418 /**
1419  * @par Description:
1420  *       This API set the default application(appid) associated with MIME type
1421  * @par Purpose:
1422  *      This API use to change default application associteted with mimetype
1423  *      In general, Setting Application or Installer need this API.
1424  * @par Typical use case:
1425  *      Default Application associated with mimetype can be changed by Setting Application or installer
1426  *      So, application to process specific mimetype can be substituted.
1427  *
1428  * @param[in]   mimetype        a mime type
1429  * @param[in]   defapp          a application appid of the app to be set
1430  * @return      0 if success, negative value if fail
1431  * @retval      AUL_R_OK        - success
1432  * @retval      AUL_R_EINVAL    - invalid argument(mimetype)
1433  * @retval      AUL_R_ERROR     - general error
1434  *
1435  * @see
1436  *      aul_get_defapp_from_mime
1437  * @code
1438  * #include <aul.h>
1439  *
1440  * void set_text_html_defapp()
1441  * {
1442  *      aul_set_defapp_with_mime("text/html","org.tizen.browser");
1443  * }
1444  *
1445  * @endcode
1446  * @remark
1447  *      This API is only available in User Session.
1448 */
1449 int aul_set_defapp_with_mime(const char *mimetype, const char *defapp);
1450
1451 /**
1452  * @par Description:
1453  *      This API get the mimetype associated with filename
1454  * @par Purpose:
1455  *      This API use to get mimetype associteted with given filename
1456  *      In general, This API use when you want to know only mimetype given filename.
1457  * @par Typical use case:
1458  *      For example, In trasfering data through bluetooth,
1459  *      additional information like mimetype should be added.
1460  *      In such situation, You can get mimetype by using this API.
1461  *
1462  * @param[in]   filename        file name
1463  * @param[out]  mimetype        a mime type
1464  * @param[in]   len             length of mimetype
1465  * @return      0 if success, negative value if fail
1466  * @retval      AUL_R_OK        - success
1467  * @retval      AUL_R_EINVAL    - invalid argument(filename)
1468  * @retval      AUL_R_ERROR     - general error
1469  *
1470  * @code
1471  * #include <aul.h>
1472  *
1473  * void get_mimetype()
1474  * {
1475  *      char mimetype[255];
1476  *      aul_get_mime_from_file("image.jpg",mimetype,sizeof(mimetype));
1477  * }
1478  *
1479  * @endcode
1480  * @remark
1481  *      This API is only available in User Session.
1482  */
1483 int aul_get_mime_from_file(const char *filename, char *mimetype, int len);
1484
1485 /**
1486  * @par Description:
1487  *      This API get the mimetype associated with given content
1488  * @par Purpose:
1489  *      This API use to get mimetype associteted with given content
1490  *      In general, This API use when you want to know only mimetype given content
1491  * @par Typical use case:
1492  *      For example, In trasfering data through bluetooth,
1493  *      additional information like mimetype should be added.
1494  *      In such situation, You can get mimetype by using this API.
1495  *
1496  * @param[in]   content         content string like "011-0000-0000"
1497  * @param[out]  mimetype        a mime type
1498  * @param[in]   len             length of mimetype
1499  * @return      0 if success, negative value if fail
1500  * @retval      AUL_R_OK        - success
1501  * @retval      AUL_R_EINVAL    - invalid argument(content)
1502  * @retval      AUL_R_ERROR     - general error
1503  *
1504  * @code
1505  * #include <aul.h>
1506  *
1507  * void get_mimetype()
1508  * {
1509  *      char mimetype[255];
1510  *      aul_get_mime_from_content("http://www.samsung.com",mimetype,sizeof(mimetype));
1511  * }
1512  *
1513  * @endcode
1514  * @remark
1515  *      This API is only available in User Session.
1516 */
1517 int aul_get_mime_from_content(const char *content, char *mimetype, int len);
1518
1519 /**
1520  * @par Description:
1521  *      This API get the icon's name associated with given mimetype
1522  * @par Purpose:
1523  *      This API use to get icon's name associteted with given mimetype
1524  * @par Typical use case:
1525  *      If you want to show mimetype's icon, use this API.
1526  *
1527  * @param[in]   mimetype        a mime type
1528  * @param[out]  iconname        icon's name
1529  * @param[in]   len             length of iconname
1530  * @return      0 if success, negative value if fail
1531  * @retval      AUL_R_OK        - success
1532  * @retval      AUL_R_EINVAL    - invalid argument(content)
1533  * @retval      AUL_R_ERROR     - general error (no such mime type)
1534  *
1535  * @code
1536  * #include <aul.h>
1537  *
1538  * void get_mime_icon()
1539  * {
1540  *      char icon[255];
1541  *      aul_get_mime_icon("text/html",icon,sizeof(icon));
1542  * }
1543  *
1544  * @endcode
1545  * @remark
1546  *      This API is only available in User Session.
1547  */
1548 int aul_get_mime_icon(const char *mimetype, char *iconname, int len);
1549
1550 /**
1551  * @par Description:
1552  *      This API get the extensions associated with given mimetype
1553  * @par Purpose:
1554  *      This API use to get extensions associteted with given mimetype
1555  * @par Typical use case:
1556  *      In general, user is not familiar with mimetype(text/html),
1557  *      user is familiar with extenstions(*.html, *.htm)
1558  *      So, To show mimetype information to user, use this API
1559  *
1560  * @param[in]   mimetype        a mime type
1561  * @param[out]  extlist         extentions (ex> mpeg,mpg,mpe)
1562  * @param[in]   len             length of extlist
1563  * @return      0 if success, negative value if fail
1564  * @retval      AUL_R_OK        - success
1565  * @retval      AUL_R_EINVAL    - invalid argument(mimetype)
1566  * @retval      AUL_R_ERROR     - general error (no mimetype or no extenstion)
1567  *
1568  * @see
1569  *      aul_get_mime_description
1570  * @code
1571  * #include <aul.h>
1572  *
1573  * void get_extension()
1574  * {
1575  *      char extlist[255];
1576  *      aul_get_mime_extension("text/html",extlist,sizeof(extlist));
1577  * }
1578  *
1579  * @endcode
1580  * @remark
1581  *      Some mimetype don't have extension.
1582  *      In that case, You can use aul_get_mime_description.
1583  *      This API is only available in User Session.
1584 */
1585 int aul_get_mime_extension(const char *mimetype, char *extlist, int len);
1586
1587 /**
1588  * @par Description:
1589  *      This API get the description associated with given mimetype
1590  * @par Purpose:
1591  *      This API use to get description associteted with given mimetype
1592  * @par Typical use case:
1593  *      In general, user is not familiar with mimetype(text/html),
1594  *      user is familiar with well-knowing information like extenstions(*.html, *.htm)
1595  *      But, some mimetype don't have extenstion.
1596  *      At that time,to show mimetype information to user, use this API
1597  *
1598  * @param[in]   mimetype        a mime type
1599  * @param[out]  desc            description (ex> Call client)
1600  * @param[in]   len             length of desc
1601  * @return      0 if success, negative value if fail
1602  * @retval      AUL_R_OK        - success
1603  * @retval      AUL_R_EINVAL    - invalid argument(mimetype)
1604  * @retval      AUL_R_ERROR     - general error (no mimetype or no descrition)
1605  *
1606  * @see
1607  *      aul_get_mime_extension
1608  * @code
1609  * #include <aul.h>
1610  *
1611  * void get_information_from_mime()
1612  * {
1613  *      char info[255];
1614  *      if(aul_get_mime_extension("text/html",info,sizeof(info))<0){
1615  *              aul_get_mime_description("text/html",info,sizeof(info));
1616  *      }
1617  * }
1618  *
1619  * @endcode
1620  * @remark
1621  *      This API is only available in User Session.
1622  */
1623 int aul_get_mime_description(const char *mimetype, char *desc, int len);
1624
1625 /**
1626  * @par Description:
1627  *      This API create service result bundle based on bundle received in reset event.
1628  * @par Purpose:
1629  *      This API use to create result bundle to send it to caller.
1630  * @par Typical use case:
1631  *      This API is for callee which provide application service.\n
1632  *      To send result to caller, You must create result bundle. \n
1633  *      Callee(application providing the service) can send result by using this API and aul_send_service_result.
1634  *
1635  * @param[in]   inb             bundle received in reset event
1636  * @param[out]  outb            bundle to use for returning result
1637  * @return      0 if success, negative value(<0) if fail
1638  * @retval      AUL_R_OK        - success
1639  * @retval      AUL_R_EINVAL    - inb is not bundle created by aul_open_service
1640  * @retval      AUL_R_ERROR     - general error
1641  *
1642  * @pre
1643  *      To create result bundle, You need received original bundle.
1644  *      The original bundle can get from app_reset handler.
1645  * @post
1646  *      None
1647  * @see
1648  *      aul_send_service_result
1649  * @code
1650  * #include <aul.h>
1651  * #include <bundle.h>
1652  *
1653  * int app_reset(bundle *b, void *data)
1654  * {
1655  *      ad->recved_bundle = bundle_dup(b);
1656  * }
1657  *
1658  * int click_ok()
1659  * {
1660  *      bundle* res_bundle;
1661  *      aul_create_result_bundle(ad->recved_bundle,&res_bundle);
1662  *      bundle_add(res_bundle, "result", "1");
1663  *      aul_send_service_result(res_bundle);
1664  * }
1665  * @endcode
1666  * @remark
1667  *      This API is only available in User Session.
1668  *
1669  */
1670 int aul_create_result_bundle(bundle *inb, bundle **outb);
1671
1672 /**
1673  * @par Description:
1674  *      This API send service result to caller with bundle
1675  * @par Purpose:
1676  *      This API is used to send result bundle to caller.
1677  * @par Typical use case:
1678  *      This API is for callee which provide application service.\n
1679  *      To send result to caller, You can use this API after creating result bundle. \n
1680  *      Callee(application to provide service) can send result by using this API and aul_create_result_bundle.
1681  *
1682  * @param[in]   b      Result data in bundle format
1683  * @return      0 if success, negative value(<0) if fail
1684  * @retval      AUL_R_OK        - success
1685  * @retval      AUL_R_EINVAL    - invalid result bundle
1686  * @retval      AUL_R_ECOMM     - internal AUL IPC error
1687  * @retval      AUL_R_ERROR     - general error
1688  *
1689  * @pre
1690  *      To send result bundle, You must create result bundle.
1691  *      see aul_create_result_bundle
1692  * @post
1693  *      None
1694  * @see
1695  *      aul_create_result_bundle
1696  * @code
1697  * #include <aul.h>
1698  * #include <bundle.h>
1699  *
1700  * int app_reset(bundle *b, void *data)
1701  * {
1702  *      ad->recved_bundle = bundle_dup(b);
1703  * }
1704  *
1705  * int click_ok()
1706  * {
1707  *      bundle* res_bundle;
1708  *      aul_create_result_bundle(ad->recved_bundle,&res_bundle);
1709  *      bundle_add(res_bundle, "result", "1");
1710  *      aul_send_service_result(res_bundle);
1711  * }
1712  * @endcode
1713  * @remark
1714  *      This API is only available in User Session.
1715  *
1716  */
1717 int aul_send_service_result(bundle *b);
1718
1719 /**
1720  * @par Description:
1721  *      This API sets callback fuction that will be called when applications die.
1722  * @par Purpose:
1723  *      This API's purpose is to listen the application dead event.
1724  *      In general, task manager Application need this API.
1725  *
1726  * @param[in]   func            callback function
1727  * @param[in]   data            user data
1728  * @return      0 if success, negative value if fail
1729  * @retval      AUL_R_OK        - success
1730  * @retval      AUL_R_ERROR     - general error
1731  *
1732  * @see
1733  *      aul_listen_app_launch_signal
1734  * @code
1735  * #include <aul.h>
1736  *
1737  * int app_dead_handler(int pid, void *data)
1738  * {
1739  *      printf("===> %s : %d\n", __FUNCTION__, pid);
1740  *      return 0;
1741  * }
1742  *
1743  * void dead_listen()
1744  * {
1745  *      aul_listen_app_dead_signal(app_dead_handler, NULL);
1746  * }
1747  *
1748  * @endcode
1749  * @remark
1750  *      This API is only available in User Session.
1751  *
1752  */
1753 int aul_listen_app_dead_signal(int (*func) (int, void *), void *data);
1754
1755 /**
1756  * @par Description:
1757  *      This API sets callback fuction that will be called when applications are launched.
1758  * @par Purpose:
1759  *      This API's purpose is to listen the application launching event.
1760  *      In general, task manager Application need this API.
1761  *
1762  * @param[in]   func            callback function
1763  * @param[in]   data            user data
1764  * @return      0 if success, negative value if fail
1765  * @retval      AUL_R_OK        - success
1766  * @retval      AUL_R_ERROR     - general error
1767  *
1768  * @see
1769  *      aul_listen_app_dead_signal
1770  * @code
1771  * #include <aul.h>
1772  *
1773  * int app_launch_handler(int pid, void *data)
1774  * {
1775  *      printf("===> %s : %d\n", __FUNCTION__, pid);
1776  *      return 0;
1777  * }
1778  *
1779  * void dead_listen()
1780  * {
1781  *      aul_listen_app_launch_signal(app_launch_handler, NULL);
1782  * }
1783  *
1784  * @endcode
1785  * @remark
1786  *      This API is only available in User Session.
1787  *
1788  */
1789 int aul_listen_app_launch_signal(int (*func) (int, void *), void *data);
1790
1791 /**
1792  * @par Description:
1793  *      This API sets callback fuction that will be called when applications are launched.
1794  * @par Purpose:
1795  *      This API's purpose is to listen the application launching event.
1796  *      In general, task manager Application need this API.
1797  *
1798  * @param[in]   func            callback function
1799  * @param[in]   data            user data
1800  * @return      0 if success, negative value if fail
1801  * @retval      AUL_R_OK        - success
1802  * @retval      AUL_R_ERROR     - general error
1803  *
1804  * @see
1805  *      aul_listen_app_dead_signal
1806  * @code
1807  * #include <aul.h>
1808  *
1809  * int app_launch_handler(int pid, const char *app_id, void *data)
1810  * {
1811  *      printf("===> %s : %d, %s\n", __FUNCTION__, pid, app_id);
1812  *      return 0;
1813  * }
1814  *
1815  * void dead_listen()
1816  * {
1817  *      aul_listen_app_launch_signal(app_launch_handler, NULL);
1818  * }
1819  *
1820  * @endcode
1821  * @remark
1822  *      This API is only available in User Session.
1823  *
1824  */
1825 int aul_listen_app_launch_signal_v2(int (*func) (int, const char *, void *), void *data);
1826
1827 /**
1828  * @par Description:
1829  *      This API gets status of specified application process id.
1830  * @par Purpose:
1831  *      This API's purpose is to get the application's status.
1832  *
1833  * @param[in]   pid     pid of application
1834  * @return      0 or greater if success, nagative value if fail
1835  * @retval      STATUS_LAUNCHING
1836  * @retval      STATUS_VISIBLE
1837  * @retval      STATUS_BG
1838  * @retval      STATUS_DYING
1839  * @retval      STATUS_NORESTART
1840  * @see
1841  *      aul_status_update
1842  * @code
1843  * #include <aul.h>
1844  *
1845  * int iterfunc(const aul_app_info *info, void *data)
1846  * {
1847  *      int status;
1848  *      status = aul_app_get_status_bypid(info->pid);
1849  *      if (status == STATUS_VISIBLE) {
1850  *              printf("%s has focus", info->app_id);
1851  *              (int *)data = info->pid;
1852  *              return -1;
1853  *      }
1854  *      return 0;
1855  * }
1856  *
1857  * int find_focus_app_pid()
1858  * {
1859  *      int pid = 0;
1860  *      aul_app_get_running_app_info(iterfunc, &pid);
1861  *      return pid;
1862  * }
1863  * @endcode
1864  * @remark
1865  *      This API is only available in User Session.
1866  */
1867 int aul_app_get_status_bypid(int pid);
1868
1869 /**
1870  * @par Description:
1871  *      This API gets status of specified application process id.
1872  * @par Purpose:
1873  *      This API's purpose is to get the application's status.
1874  *
1875  * @param[in]   pid     pid of application
1876  * @param[in]   uid     User ID
1877  * @return      0 or greater if success, nagative value if fail
1878  * @retval      STATUS_LAUNCHING
1879  * @retval      STATUS_VISIBLE
1880  * @retval      STATUS_BG
1881  * @retval      STATUS_DYING
1882  * @retval      STATUS_NORESTART
1883  *
1884  * @remark
1885  *      This API is only available to System user.
1886  */
1887 int aul_app_get_status_bypid_for_uid(int pid, uid_t uid);
1888
1889 /**
1890  * @par Description:
1891  *      This API gets the status of specified application id.
1892  * @par Purpose:
1893  *      This API's purpose is to get the status of the application.
1894  *
1895  * @param[in]   appid   application ID
1896  * @return      0 or greater if success, nagative value if fail
1897  * @retval      STATUS_LAUNCHING
1898  * @retval      STATUS_FOCUS
1899  * @retval      STATUS_VISIBLE
1900  * @retval      STATUS_BG
1901  * @retval      STATUS_DYING
1902  * @retval      STATUS_NORESTART
1903  * @see
1904  *      aul_status_update
1905  * @code
1906  * #include <aul.h>
1907  *
1908  * int func(void)
1909  * {
1910  *      int status;
1911  *
1912  *      status = aul_app_get_status("org.tizen.helloworld");
1913  *      if (status == STATUS_FOCUS)
1914  *              printf("org.tizen.helloworld has focus");
1915  *
1916  *      return 0;
1917  * }
1918  *
1919  * @endcode
1920  * @remark
1921  *      This API is only available in User Session.
1922  */
1923 int aul_app_get_status(const char *appid);
1924
1925 /**
1926  * @par Description:
1927  *      This API gets the status of specified application id.
1928  * @par Purpose:
1929  *      This API's purpose is to get the status of the application
1930  *
1931  * @param[in]   appid   application ID
1932  * @param[in]   uid     User ID
1933  * @return      0 or greater if success, nagative value if fail
1934  * @retval      STATUS_LAUNCHING
1935  * @retval      STATUS_FOCUS
1936  * @retval      STATUS_VISIBLE
1937  * @retval      STATUS_BG
1938  * @retval      STATUS_DYING
1939  * @retval      STATUS_NORESTART
1940  *
1941  * @remark
1942  *      This API is only available to System user.
1943  */
1944 int aul_app_get_status_for_uid(const char *appid, uid_t uid);
1945
1946 /**
1947  * @par Description
1948  *      This API sets callback function that on application status changed.
1949  * @par Purpose:
1950  *      This API's purpose is to listen the application's status changed within
1951  *      the caller process. In general, a library that required to release resource on
1952  *      application's status may use this API.
1953  *
1954  * @param[in]   func    callback function
1955  * @param[in]   data    user data
1956  * @return      0 if success, negative value if fail
1957  * @retval      AUL_R_OK        - success
1958  * @retval      AUL_R_ERROR     - general error
1959  * @see
1960  *      aul_remove_status_local_cb
1961  * @code
1962  * #include <aul.h>
1963  *
1964  * int status_changed(int status, void *data)
1965  * {
1966  *      if (status == STATUS_VISIBLE)
1967  *              printf("%d resume\n", getpid());
1968  *
1969  *      if (status == STATUS_BG)
1970  *              printf("%d pause\n", getpid());
1971  * }
1972  *
1973  * void listen_app_status()
1974  * {
1975  *      aul_add_status_local_cb(status_changed, NULL);
1976  * }
1977  * @endcode
1978  * @remark
1979  *      This API is only available in User Session.
1980  *
1981  */
1982 int aul_add_status_local_cb(int (*func) (int, void *), void *data);
1983
1984 /**
1985  * @par Description
1986  *      This API unsets callback function that on application status changed.
1987  * @par Purpose:
1988  *      This API's purpose is to remove callback that added by
1989  *      aul_add_status_local_cb.
1990  *
1991  * @param[in]   func    callback function
1992  * @param[in]   data    user data
1993  * @return      0 if success, negative value if fail
1994  * @retval      AUL_R_OK        - success
1995  * @retval      AUL_R_ERROR     - general error
1996  *
1997  * @see
1998  *      aul_add_status_local_cb
1999  * @code
2000  * #include <aul.h>
2001  *
2002  * int status_changed(int status, void *data)
2003  * {
2004  *      if (status == STATUS_VISIBLE)
2005  *              printf("%d resume\n", getpid());
2006  *
2007  *      if (status == STATUS_BG)
2008  *              printf("%d pause\n", getpid());
2009  * }
2010  *
2011  * void listen_app_status()
2012  * {
2013  *      aul_add_status_local_cb(status_changed, NULL);
2014  * }
2015  *
2016  * void ignore_app_status()
2017  * {
2018  *      aul_remove_status_local_cb(status_changed, NULL);
2019  * }
2020  *
2021  * @endcode
2022  * @remark
2023  *      This API is only available in User Session.
2024  *
2025  */
2026 int aul_remove_status_local_cb(int (*func) (int, void *), void *data);
2027
2028 /*
2029  * This API is only for appfw internally.
2030  */
2031 int aul_set_process_group(int parent_pid, int child_pid);
2032
2033 /*
2034  * This API is only for Appfw internally.
2035  */
2036 int aul_terminate_bgapp_pid(int pid);
2037
2038 /*
2039  * This API is only for Appfw internally.
2040  */
2041 int aul_terminate_pid_without_restart(int pid);
2042
2043 /*
2044  * This API is only for Appfw internally.
2045  */
2046 int aul_terminate_pid_sync_without_restart(int pid);
2047
2048 /*
2049  * This API is only for Appfw internally.
2050  */
2051 int aul_terminate_pid_sync_without_restart_for_uid(int pid, uid_t uid);
2052
2053 /*
2054  * This API is only for Appfw internally.
2055  */
2056 const char *aul_get_app_external_root_path(void);
2057
2058 /*
2059  * This API is only for Appfw internally.
2060  */
2061 const char *aul_get_app_root_path(void);
2062
2063 /*
2064  * This API is only for Appfw internally.
2065  */
2066 const char *aul_get_app_data_path(void);
2067
2068 /*
2069  * This API is only for Appfw internally.
2070  */
2071 const char *aul_get_app_cache_path(void);
2072
2073 /*
2074  * This API is only for Appfw internally.
2075  */
2076 const char *aul_get_app_resource_path(void);
2077
2078 /*
2079  * This API is only for Appfw internally.
2080  */
2081 const char *aul_get_app_tep_resource_path(void);
2082
2083 /*
2084  * This API is only for Appfw internally.
2085  */
2086 int aul_get_app_shared_data_path(char **path);
2087
2088 /*
2089  * This API is only for Appfw internally.
2090  */
2091 const char *aul_get_app_shared_resource_path(void);
2092
2093 /*
2094  * This API is only for Appfw internally.
2095  */
2096 const char *aul_get_app_shared_trusted_path(void);
2097
2098 /*
2099  * This API is only for Appfw internally.
2100  */
2101 const char *aul_get_app_external_data_path(void);
2102
2103 /*
2104  * This API is only for Appfw internally.
2105  */
2106 const char *aul_get_app_external_cache_path(void);
2107
2108 /*
2109  * This API is only for Appfw internally.
2110  */
2111 const char *aul_get_app_external_shared_data_path(void);
2112
2113 /*
2114  * This API is only for Appfw internally.
2115  */
2116 const char *aul_get_app_specific_path(void);
2117
2118 /*
2119  * This API is only for Appfw internally.
2120  */
2121 int aul_get_app_shared_data_path_by_appid(const char *app_id, char **path);
2122
2123 /*
2124  * This API is only for Appfw internally.
2125  */
2126 int aul_get_app_shared_resource_path_by_appid(const char *app_id, char **path);
2127
2128 /*
2129  * This API is only for Appfw internally.
2130  */
2131 int aul_get_app_shared_trusted_path_by_appid(const char *app_id, char **path);
2132
2133 /*
2134  * This API is only for Appfw internally.
2135  */
2136 int aul_get_app_external_shared_data_path_by_appid(const char *app_id, char **path);
2137
2138 /*
2139  * This API is only for Appfw internally.
2140  */
2141 int aul_get_usr_app_shared_data_path_by_appid(const char *app_id, char **path, uid_t uid);
2142
2143 /*
2144  * This API is only for Appfw internally.
2145  */
2146 int aul_get_usr_app_shared_resource_path_by_appid(const char *app_id, char **path, uid_t uid);
2147
2148 /*
2149  * This API is only for Appfw internally.
2150  */
2151 int aul_get_usr_app_shared_trusted_path_by_appid(const char *app_id, char **path, uid_t uid);
2152
2153 /*
2154  * This API is only for Appfw internally.
2155  */
2156 int aul_get_usr_app_external_shared_data_path_by_appid(const char *app_id, char **path, uid_t uid);
2157
2158 /*
2159  * This type is only for Appfw internally.
2160  */
2161 typedef int (*subapp_fn)(void *data);
2162
2163 /*
2164  * This API is only for Appfw internally.
2165  */
2166 int aul_set_subapp(subapp_fn cb, void *data);
2167
2168 /*
2169  * This API is only for Appfw internally.
2170  */
2171 int aul_subapp_terminate_request_pid(int pid);
2172
2173 /*
2174  * This API is only for Appfw internally.
2175  */
2176 int aul_is_subapp(void);
2177
2178 /*
2179  * This API is only for Appfw internally.
2180  */
2181 int aul_kill_pid(int pid);
2182
2183 /*
2184  * This API is only for Appfw internally.
2185  */
2186 int aul_add_caller_cb(int pid,  void (*caller_cb) (int, void *), void *data);
2187
2188 /*
2189  * This API is only for Appfw internally.
2190  */
2191 int aul_remove_caller_cb(int pid, void *data);
2192
2193 /*
2194  * This API is only for Appfw internally.
2195  */
2196 int aul_invoke_caller_cb(void *data);
2197
2198 /*
2199  * This API is only for Appfw internally.
2200  */
2201 void aul_set_preinit_window(void *evas_object);
2202
2203 /*
2204  * This API is only for Appfw internally.
2205  */
2206 void* aul_get_preinit_window(const char *win_name);
2207
2208 /*
2209  * This API is only for Appfw internally.
2210  */
2211 void aul_set_preinit_background(void *evas_object);
2212
2213 /*
2214  * This API is only for Appfw internally.
2215  */
2216 void* aul_get_preinit_background(void);
2217
2218 /*
2219  * This API is only for Appfw internally.
2220  */
2221 void aul_set_preinit_conformant(void *evas_object);
2222
2223 /*
2224  * This API is only for Appfw internally.
2225  */
2226 void* aul_get_preinit_conformant(void);
2227
2228 /*
2229  * This API is only for Appfw internally.
2230  */
2231 void aul_set_preinit_appid(const char *appid);
2232
2233 /*
2234  * This API is only for Appfw internally.
2235  */
2236 void aul_set_preinit_pkgid(const char *pkgid);
2237
2238 /*
2239  * This API is only for Appfw internally.
2240  */
2241 void aul_set_preinit_root_path(const char *root_path);
2242
2243 /*
2244  * This API is only for Appfw internally.
2245  */
2246 const char *aul_get_preinit_root_path(void);
2247
2248 /*
2249  * This API is only for Appfw internally.
2250  */
2251 int aul_update_freezer_status(int pid, const char* type);
2252
2253 /*
2254  * This API is only for Appfw internally.
2255  */
2256 int aul_send_app_launch_request_signal(int pid, const char* appid, const char* pkgid, const char* type);
2257
2258 /*
2259  * This API is only for Appfw internally.
2260  */
2261 int aul_send_app_resume_request_signal(int pid, const char* appid, const char* pkgid, const char *type);
2262
2263 /*
2264  * This API is only for Appfw internally.
2265  */
2266 int aul_send_app_terminate_request_signal(int pid, const char* appid, const char* pkgid, const char *type);
2267
2268 /*
2269  * This API is only for Appfw internally.
2270  */
2271 int aul_send_app_status_change_signal(int pid, const char* appid, const char* pkgid, const char* status, const char *type);
2272
2273 /*
2274  * This API is only for Appfw internally.
2275  */
2276 int aul_send_app_terminated_signal(int pid);
2277
2278 /*
2279  * This API is only for Appfw internally.
2280  */
2281 int aul_send_app_group_signal(int owner_pid, int child_pid, const char *child_pkgid);
2282
2283 /*
2284  * This API is only for Appfw internally.
2285  */
2286 int aul_invoke_status_local_cb(int status);
2287
2288 /*
2289  * This type is only for Appfw internally.
2290  */
2291 typedef int (*data_control_provider_handler_fn) (bundle *b, int request_id, void *data);
2292
2293 /*
2294  * This API is only for Appfw internally.
2295  */
2296 int aul_set_data_control_provider_cb(data_control_provider_handler_fn handler);
2297
2298 /*
2299  * This API is only for Appfw internally.
2300  */
2301 int aul_unset_data_control_provider_cb(void);
2302
2303 /*
2304  * This API is only for Appfw internally.
2305  */
2306 int aul_pause_app(const char *appid);
2307
2308 /*
2309  * This API is only for Appfw internally.
2310  */
2311 int aul_pause_app_for_uid(const char *appid, uid_t uid);
2312
2313 /*
2314  * This API is only for Appfw internally.
2315  */
2316 int aul_pause_pid(int pid);
2317
2318 /*
2319  * This API is only for Appfw internally.
2320  */
2321 int aul_pause_pid_for_uid(int pid, uid_t uid);
2322
2323 /*
2324  * This API is only for Appfw internally.
2325  */
2326 int aul_reload_appinfo(void);
2327
2328 /*
2329  * This API is only for Appfw internally.
2330  */
2331 int aul_status_update(int status);
2332
2333 /*
2334  * This API is only for Appfw internally.
2335  */
2336 int aul_running_list_update(char *appid, char *app_path, char *pid);
2337
2338 /*
2339  * This API is only for Appfw internally.
2340  */
2341 int aul_app_group_get_window(int pid);
2342
2343 /*
2344  * This API is only for Appfw internally.
2345  */
2346 int aul_app_group_set_window(int wid);
2347
2348 /*
2349  * This API is only for Appfw internally.
2350  */
2351 void aul_app_group_get_leader_pids(int *cnt, int **pids);
2352
2353 /*
2354  * This API is only for Appfw internally.
2355  */
2356 void aul_app_group_get_group_pids(int leader_pid, int *cnt, int **pids);
2357
2358 /*
2359  * This API is only for Appfw internally.
2360  */
2361 int aul_app_group_get_leader_pid(int pid);
2362
2363 /*
2364  * This API is only for Appfw internally.
2365  */
2366 int aul_app_group_clear_top(void);
2367
2368 /*
2369  * This API is only for Appfw internally.
2370  */
2371 int aul_app_group_is_top(void);
2372
2373 /*
2374  * This API is only for Appfw internally.
2375  */
2376 int aul_app_group_get_fg_flag(int pid);
2377
2378 /*
2379  * This API is only for Appfw internally.
2380  */
2381 void aul_app_group_lower(int *exit);
2382
2383 /*
2384  * This API is only for Appfw internally.
2385  */
2386 void aul_app_group_get_idle_pids(int *cnt, int **pids);
2387
2388 /**
2389  * @par Description:
2390  *      This API puts some app below the caller app
2391  * @par Purpose:
2392  *      This API's purpose is to reorder window stack limitedly.
2393  *
2394  * @param[in]   below_appid     The appid to be reordered below the caller app
2395  * @return      0 success, negative value(<0) if fail
2396  *
2397  * @remark
2398  *      below_appid should be main app which have been launched before.
2399  *      This API is only available in User Session.
2400 */
2401 int aul_app_group_activate_below(const char *below_appid);
2402
2403 /**
2404  * @par Description:
2405  *      This API puts some app above the caller app
2406  * @par Purpose:
2407  *      This API's purpose is to reorder window stack limitedly.
2408  *
2409  * @param[in]   above_appid     The appid to be reordered above the caller app
2410  * @return      0 if success, negative value(<0) if fail
2411  *
2412  * @remark
2413  *      above_appid should be main app which have been launched before.
2414  *      This API is only available in User Session.
2415 */
2416 int aul_app_group_activate_above(const char *above_appid);
2417
2418 /*
2419  * This API is only for Appfw internally.
2420  */
2421 int aul_request_data_control_socket_pair(bundle *b, int *fd);
2422 /*
2423  * This API is only for Appfw internally.
2424  */
2425 int aul_request_message_port_socket_pair(int *fd);
2426 /*
2427  * This API is only for Appfw internally.
2428  */
2429 int aul_listen_booting_done_signal(int (*func) (int, void *), void *data);
2430
2431 /*
2432  * This API is only for Appfw internally.
2433  */
2434 int aul_listen_cooldown_signal(int (*func) (const char *, void *), void *data);
2435
2436 /**
2437  * @par Description:
2438  *      This API registers a callback function that will be called when the
2439  *      status of the application is changed.
2440  * @par Purpose:
2441  *      This API is for monitoring the status of all applications.
2442  *
2443  * @param[in]   func            callback function
2444  * @param[in]   data            user data
2445  * @return      0 if success, negative value if fail
2446  * @retval      AUL_R_OK        - success
2447  * @retval      AUL_R_ERROR     - general error
2448  *
2449  * @code
2450  * #include <aul.h>
2451  *
2452  * int app_status_handler(int pid, int status, void *data)
2453  * {
2454  *      const char *app_status;
2455  *
2456  *      switch (status) {
2457  *      case 0:
2458  *              app_status = "STATUS_LAUNCHING";
2459  *              break;
2460  *      case 3:
2461  *              app_status = "STATUS_VISIBLE";
2462  *              break;
2463  *      case 4:
2464  *              app_status = "STATUS_BACKGROUND";
2465  *              break;
2466  *      case 5:
2467  *              app_status = "STATUS_FOCUS";
2468  *              break;
2469  *      default:
2470  *              app_status = "STATUS_UNKNOWN";
2471  *      }
2472  *
2473  *      printf("pid: %d, status: %s", pid, status);
2474  *      return 0;
2475  * }
2476  *
2477  * int main(int argc, char **argv)
2478  * {
2479  *      int ret;
2480  *
2481  *      ret = aul_listen_app_status_signal(app_status_handler, NULL);
2482  *      if (ret != AUL_R_OK) {
2483  *              printf("Failed to add status handler");
2484  *              return -1;
2485  *      }
2486  *
2487  *      ...
2488  *
2489  *      return 0;
2490  * }
2491  * @endcode
2492  */
2493 int aul_listen_app_status_signal(int (*func)(int, int, void *), void *data);
2494
2495 /*
2496  * This API is only for Appfw internally.
2497  */
2498 int aul_check_tep_mount(const char *tep_path);
2499
2500 /*
2501  * This API is only for Appfw internally.
2502  */
2503 int aul_is_tep_mount_dbus_done(const char *tep_string);
2504
2505 /*
2506  * This API is only for Appfw internally.
2507  */
2508 int aul_forward_app(const char *appid, bundle *kb);
2509
2510 /**
2511  * @par Description:
2512  *      This API create custom launchpad-loader
2513  * @par Purpose:
2514  *      This API's purpose is to make a slot for custom loader.
2515  *      Once it is made, added loader will make a candidate process to use.
2516  *
2517  * @param[in]   loader_path     The file name of the custom loader binary including full path
2518  * @param[in]   extra           A bundle to be passed to the custom loader
2519  * @return      Loader ID if success, negative value(<0) if fail
2520  *
2521  * @remark
2522  *      This API is only for Appfw internally.
2523  *      This API is only available in User Session.
2524 */
2525 int aul_add_loader(const char *loader_path, bundle *extra);
2526
2527 /**
2528  * @par Description:
2529  *      This API create custom launchpad-loader
2530  * @par Purpose:
2531  *      This API's purpose is to make a slot for custom loader.
2532  *      Once it is made, added loader will make a candidate process to use.
2533  *
2534  * @param[in]   loader_path     The file name of the custom loader binary including full path
2535  * @param[in]   extra           A bundle to be passed to the custom loader
2536  * @param[in]   uid             User ID
2537  * @return      Loader ID if success, negative value(<0) if fail
2538  *
2539  * @remark
2540  *      This API is only for Appfw internally.
2541  *      This API is only available to System user.
2542 */
2543 int aul_add_loader_for_uid(const char *loader_path, bundle *extra, uid_t uid);
2544
2545
2546 /**
2547  * @par Description:
2548  *      This API destroy custom launchpad-loader
2549  * @par Purpose:
2550  *      This API's purpose is to remove a slot for custom loader.
2551  *      Once it is removed, the prepared process will be removed as well.
2552  *
2553  * @param[in]   loader_id       Loader ID
2554  * @return      0 if success, negative value(<0) if fail
2555  *
2556  * @remark
2557  *      This API is only for Appfw internally.
2558  *      This API is only available in User Session.
2559 */
2560 int aul_remove_loader(int loader_id);
2561
2562 /**
2563  * @par Description:
2564  *      This API destroy custom launchpad-loader
2565  * @par Purpose:
2566  *      This API's purpose is to remove a slot for custom loader.
2567  *      Once it is removed, the prepared process will be removed as well.
2568  *
2569  * @param[in]   loader_id       Loader ID
2570  * @param[in]   uid             User ID
2571  * @return      0 if success, negative value(<0) if fail
2572  *
2573  * @remark
2574  *      This API is only for Appfw internally.
2575  *      This API is only available to System user.
2576 */
2577 int aul_remove_loader_for_uid(int loader_id, uid_t uid);
2578
2579 /**
2580  * @par Description
2581  *      This API gets specified application process id.
2582  * @par Purpose:
2583  *      The purpose of this API is to get the pid of specified application.
2584  *
2585  * @param[in]   appid   application name
2586  * @return      callee's pid if success, negative value(<0) if fail
2587  *
2588  * @remark
2589  *      This API is only available in User Session.
2590  */
2591 int aul_app_get_pid(const char *appid);
2592
2593 /**
2594  * @par Description
2595  *      This API gets specified application process id.
2596  * @par Purpose:
2597  *      The purpose of this API is to get the pid of specified application.
2598  *
2599  * @param[in]   appid   application name
2600  * @param[in]   uid     User ID
2601  * @return      callee's pid if success, negative value(<0) if fail
2602  *
2603  * @remark
2604  *      This API is only available to System user.
2605  */
2606 int aul_app_get_pid_for_uid(const char *appid, uid_t uid);
2607
2608 /**
2609  * @par Description:
2610  * This function update rua stat.
2611  *
2612  * @param[in] b Bundle object contains caller and tag information.
2613  * @param[in] uid Target uid
2614  *
2615  * @return 0 if success, negative value(<0) if fail
2616  * @see None
2617  * @remarks This API is only for Appfw internally.
2618  *
2619  * @par Sample code:
2620  * @code
2621 #include <aul.h>
2622
2623 ...
2624 {
2625     int r;
2626     bundle *b = bundle_create();
2627     bundle_add_str(b, AUL_SVC_K_RUA_STAT_CALLER, caller);
2628     bundle_add_str(b, AUL_SVC_K_RUA_STAT_TAG, tag);
2629
2630     r = aul_update_rua_stat_for_uid(b);
2631 }
2632
2633  * @endcode
2634  **/
2635 int aul_update_rua_stat_for_uid(bundle *b, uid_t uid);
2636
2637 /**
2638  * @par Description:
2639  * This function add rua history.
2640  *
2641  * @param[in] b Bundle object Target Package name or app path.
2642  * @param[in] uid Target uid
2643  *
2644  * @return 0 if success, negative value(<0) if fail
2645  * @see None
2646  * @remarks This API is only for Appfw internally.
2647  *
2648  * @par Sample code:
2649  * @code
2650 #include <aul.h>
2651
2652 ...
2653 {
2654     int r;
2655     bundle *b = bundle_create();
2656     if (pkg_name)
2657         bundle_add_str(b, AUL_K_RUA_PKGNAME, pkg_name);
2658     else if (app_path)
2659         bundle_add_str(b, AUL_K_RUA_APPPATH, app_path);
2660
2661     r = aul_add_rua_history_for_uid(b);
2662 }
2663
2664  * @endcode
2665  **/
2666 int aul_add_rua_history_for_uid(bundle *b, uid_t uid);
2667
2668 /**
2669  * @par Description:
2670  * This function delete rua history.
2671  *
2672  * @param[in] b Bundle object Target Package name. If NULL or has no value, delete all rua history.
2673  * @param[in] uid Target uid
2674  *
2675  * @return 0 if success, negative value(<0) if fail
2676  * @see None
2677  * @remarks This API is only for Appfw internally.
2678  *
2679  * @par Sample code:
2680  * @code
2681 #include <aul.h>
2682
2683 ...
2684 {
2685     int r;
2686     bundle *b = NULL;
2687     if (pkg_name) {
2688         b = bundle_create();
2689         bundle_add_str(b, AUL_K_RUA_PKGNAME, pkg_name);
2690     }
2691     r = aul_delete_rua_history_for_uid(b, getuid());
2692 }
2693
2694  * @endcode
2695  **/
2696 int aul_delete_rua_history_for_uid(bundle *b, uid_t uid);
2697
2698
2699 /**
2700  * @par Description:
2701  * This function sets the default application(application id) associated with operatioin, uri and mime-type.
2702  *
2703  * @param[in] b Bundle object Target application id and operation, uri and mime-type.
2704  *
2705  * @return 0 if success, negative value(<0) if fail
2706  * @see None
2707  * @remarks This API is only for Appfw internally.
2708  *
2709  * @par Sample code:
2710  * @code
2711 #include <aul.h>
2712 #include <aul_svc.h>
2713
2714 ...
2715 {
2716     int r;
2717     bundle *b = bundle_create();
2718
2719     const char *appid = "org.tizen.test";
2720     const char *operation = "test_operation";
2721     const char *mime_type = "test_mime";
2722     const char *uri = "test_uri";
2723
2724     aul_svc_set_operation(b, operation);
2725     aul_svc_set_mime(b, mime_type);
2726     aul_svc_set_uri(b, uri);
2727
2728     aul_svc_set_appid(b, appid)
2729
2730     r = aul_set_default_app_by_operation(b);
2731 }
2732
2733  * @endcode
2734  **/
2735 int aul_set_default_app_by_operation(bundle *b);
2736
2737 /**
2738  * @par Description:
2739  * This API unset the default application(application id) associated with operation, uri and mime-type.
2740  *
2741  * @param[in] app_id    The ID of the application
2742  *
2743  * @return 0 if success, negative value(<0) if fail
2744  *
2745  * @pre None.
2746  * @post None.
2747  * @see None.
2748  * @remarks None.
2749  *
2750  * @par Sample code:
2751  * @code
2752 #include <aul.h>
2753
2754 ...
2755 {
2756     aul_unset_default_app_by_operation("org.tizen.test");
2757 }
2758  * @endcode
2759  *
2760  */
2761 int aul_unset_default_app_by_operation(const char *app_id);
2762
2763 /**
2764  * @par Description:
2765  *      Sends the launch request asynchronously.
2766  *
2767  * @param[in]   appid           The application ID
2768  * @param[in]   kb              The Bundle data
2769  * @return      a pid of the callee on success,
2770  *              otherwise a negative error value
2771  * @retval      AUL_R_OK        - Successful
2772  * @retval      AUL_R_EINVAL    - Invalid parameter
2773  * @retval      AUL_R_ECOM      - Internal AUL IPC error
2774  * @retval      AUL_R_ERROR     - General error
2775  *
2776  * @remark
2777  *      This API is only available in User Session.
2778  *      This API doesn't check whether the callee application is executed successfully.
2779  *      If the caller application is equal to the callee application, this API can return AUL_R_OK.
2780  */
2781 int aul_launch_app_async(const char *appid, bundle *kb);
2782
2783 /**
2784  * @par Description:
2785  *      Sends the launch request asynchronously.
2786  *
2787  * @param[in]   appid           The application ID
2788  * @param[in]   kb              The Bundle data
2789  * @param[in]   uid             User ID
2790  * @return      a pid of the callee on success,
2791  *              otherwise a negative error value
2792  * @retval      AUL_R_OK        - Successful
2793  * @retval      AUL_R_EINVAL    - Invalid parameter
2794  * @retval      AUL_R_ECOM      - Internal AUL IPC error
2795  * @retval      AUL_R_ERROR     - General error
2796  *
2797  * @remark
2798  *      This API is only available to System user.
2799  *      This API doesn't check whether the callee application is executed successfully.
2800  *      If the caller application is equal to the callee application, this API can return AUL_R_OK.
2801  */
2802 int aul_launch_app_async_for_uid(const char *appid, bundle *kb, uid_t uid);
2803
2804 /**
2805  * @par Description:
2806  * This API request launchpad to make candidate processes.
2807  *
2808  * @return 0 if success, negative value(<0) if fail
2809  *
2810  * @remark
2811  *      This API is only available in User Session.
2812  */
2813 int aul_prepare_candidate_process(void);
2814
2815 /*
2816  * This API is only for Appfw internally.
2817  */
2818 int aul_widget_instance_add(const char *widget_id, const char *instance_id);
2819
2820 /*
2821  * This API is only for Appfw internally.
2822  */
2823 int aul_widget_instance_del(const char *widget_id, const char *instance_id);
2824
2825 /*
2826  * This API is only for Appfw internally.
2827  */
2828 typedef void (*aul_widget_instance_foreach_cb)(const char *instance_id, void *data);
2829
2830 /*
2831  * This API is only for Appfw internally.
2832  */
2833 int aul_widget_instance_foreach(const char *widget_id, aul_widget_instance_foreach_cb cb, void *data);
2834
2835 /*
2836  * This API is only for Appfw internally.
2837  */
2838 int aul_widget_instance_update(const char *widget_id, const char *instance_id, bundle *b);
2839
2840 /*
2841  * This API is only for Appfw internally.
2842  */
2843 int aul_widget_instance_count(const char *widget_id);
2844
2845 /**
2846  * @par Description:
2847  *      This API gets the last caller process id of specified application process id.
2848  * @par Purpose:
2849  *      This API's purpose is to get the application's last caller process id.
2850  *
2851  * @param[in]   pid     pid of application
2852  * @return      caller pid if success, nagative value if fail
2853  *
2854  * @remark
2855  *      This API is only available in User Session.
2856  */
2857 int aul_app_get_last_caller_pid(int pid);
2858
2859 /**
2860  * @par Description:
2861  *      This API gets the last caller process id of specified application process id.
2862  * @par Purpose:
2863  *      This API's purpose is to get the last caller process id of the application.
2864  *
2865  * @param[in]   pid     pid of application
2866  * @param[in]   uid     User ID
2867  * @return      caller pid if success, nagative value if fail
2868  *
2869  * @remark
2870  *      This API is only available in System users.
2871  */
2872 int aul_app_get_last_caller_pid_for_uid(int pid, uid_t uid);
2873
2874 /**
2875  * @par Description:
2876  *      This API trigger to resume application asynchronously.
2877  *      If the application is running, this API send a resume event to the App.
2878  *      If the application is not running, this API return AUL_R_ERROR.
2879  *      Although the application is running, if the application cannot receive resume event,
2880  *      AUL try to raise the application's default windows.
2881  * @par Purpose:
2882  *      This API is for caller.
2883  *      This API's purpose is to send resume event.
2884  * @par Typical use case:
2885  *      In multiple application model, If you want to only resume specific application, Use this API
2886  *
2887  * @param[in]   pid     application's pid to be resumed
2888  * @return      0 if success, negative value(<0) if fail
2889  * @retval      AUL_R_OK        - success
2890  * @retval      AUL_R_EINVAL    - invaild pid
2891  * @retval      AUL_R_ECOM      - internal AUL IPC error
2892  * @retval      AUL_R_ERROR     - general error (include application is not running)
2893  * @warning     This API need to require root or inhouse permisssion \n
2894  *              If you have not the permission, this API return AUL_R_ERROR. \n
2895  * @remark
2896  *      This API is only available to User Session.
2897  */
2898 int aul_resume_pid_async(int pid);
2899
2900 /**
2901  * @par Description:
2902  *      This API trigger to resume application asynchronously.
2903  *      If the application is running, this API send a resume event to the App.
2904  *      If the application is not running, this API return AUL_R_ERROR.
2905  *      Although the application is running, if the application cannot receive resume event,
2906  *      AUL try to raise the application's default windows.
2907  * @par Purpose:
2908  *      This API is for caller.
2909  *      This API's purpose is to send resume event.
2910  * @par Typical use case:
2911  *      In multiple application model, If you want to only resume specific application, Use this API
2912  *
2913  * @param[in]   pid     application's pid to be resumed
2914  * @param[in]   uid     User ID
2915  * @return      0 if success, negative value(<0) if fail
2916  * @retval      AUL_R_OK        - success
2917  * @retval      AUL_R_EINVAL    - invaild pid
2918  * @retval      AUL_R_ECOM      - internal AUL IPC error
2919  * @retval      AUL_R_ERROR     - general error (include application is not running)
2920  * @warning     This API need to require root or inhouse permisssion \n
2921  *              If you have not the permission, this API return AUL_R_ERROR. \n
2922  * @remark
2923  *      This API is only available to System user.
2924  */
2925 int aul_resume_pid_async_for_uid(int pid, uid_t uid);
2926
2927 /**
2928  * @par Description:
2929  *      This API set the alias appid.
2930  *      The alias appid is only available for the aul_svc_set_appid() API.
2931  *      If the appid is not available, this API returns an error.
2932  *
2933  * @privlevel platform
2934  * @privilege %http://tizen.org/privilege/systemsettings.admin
2935  * @param[in]   alias_appid     an alias application ID
2936  * @param[in]   appid           an application ID
2937  * @return      0 if success, negative value(<0) if fail
2938  *
2939  * @remark
2940  *      This API is only available to User Session.
2941  */
2942 int aul_set_alias_appid(const char *alias_appid, const char *appid);
2943
2944 /**
2945  * @par Description:
2946  *      This API unset the alias appid.
2947  *
2948  * @privlevel platform
2949  * @privilege %http://tizen.org/privilege/systemsettings.admin
2950  * @param[in]   alias_appid     an alias application ID
2951  * @return      0 if success, negative value(<0) if fail
2952  *
2953  * @remark
2954  *      This API is only available to User Session.
2955  */
2956 int aul_unset_alias_appid(const char *alias_appid);
2957
2958 /**
2959  * @par Description:
2960  *      This API activates the alias information based on the given appid.
2961  *
2962  * @privlevel platform
2963  * @privilege %http://tizen.org/privilege/systemsettings.admin
2964  * @param[in]   appid   an application ID
2965  * @return      0 if success, negative value(<0) if fail
2966  *
2967  * @remark
2968  *      This API is only available to User Session.
2969  */
2970 int aul_enable_alias_info(const char *appid);
2971
2972 /**
2973  * @par Description:
2974  *      This API deactivates the alias information based on the given appid.
2975  *
2976  * @privlebel platform
2977  * @privilege %http://tizen.org/privilege/systemsettings.admin
2978  * @param[in]   appid   an application ID
2979  * @return      0 if success, negative value(<0) if fail
2980  *
2981  * @remark
2982  *      This API is only available to User Session.
2983  */
2984 int aul_disable_alias_info(const char *appid);
2985
2986 /**
2987  * This API is only for Appfw internally.
2988  */
2989 typedef int (*app_status_cb)(aul_app_info *info, int ctx_status, void *data);
2990
2991 /**
2992  * This API is only for Appfw internally.
2993  */
2994 typedef struct status_listen_s *status_listen_h;
2995
2996 /**
2997  * @par Description:
2998  *      Registers a callback function to be invoked when the application change status.
2999  *
3000  * @param[in]   appid           The application ID to get status
3001  * @param[in]   callback        The callback function to register
3002  * @param[in]   data            The user data to be passed to the callback function
3003  * @param[out]  handle          The status listen handle
3004  * @return      @c 0 on success,
3005  *              otherwise a negative error value
3006  */
3007 int aul_listen_app_status(const char *appid, app_status_cb callback,
3008                 void *data, status_listen_h *handle);
3009 int aul_listen_app_status_for_uid(const char *appid, app_status_cb callback,
3010                 void *data, status_listen_h *handle, uid_t uid);
3011
3012 /*
3013  * This API is only for Appfw internally.
3014  */
3015 int aul_widget_instance_get_content(const char *widget_id, const char *instance_id, char **content);
3016
3017 /**
3018  * @par Description:
3019  *      Gets running application instance info
3020  *      This API calls the iter_fn with the aul_app_info when running app instance info is found.
3021  *
3022  * @param[in]   iter_fn         iterative function
3023  * @param[in]   user_data       User data
3024  * @return      0 if success, negative value(<0) if fail
3025  * @retval      AUL_R_OK        Successful
3026  * @retval      AUL_R_ERROR     General error
3027  * @retval      AUL_R_EINVAL    Invalid parameter
3028  */
3029 int aul_app_get_running_app_instance_info(aul_app_info_iter_fn iter_fn,
3030                 void *user_data);
3031 int aul_app_get_running_app_instance_info_for_uid(aul_app_info_iter_fn iter_fn,
3032                 void *user_data, uid_t uid);
3033
3034 /*
3035  * This API is only for Appfw internally.
3036  */
3037 int aul_app_get_instance_id_bypid(int pid, char *instance_id, int len);
3038 int aul_app_get_instance_id_bypid_for_uid(int pid, char *instance_id,
3039                 int len, uid_t uid);
3040
3041 /*
3042  * This API is only for Appfw internally.
3043  */
3044 int aul_resume_app_by_instance_id(const char *appid, const char *instance_id);
3045 int aul_resume_app_by_instance_id_for_uid(const char *appid,
3046                 const char *instance_id, uid_t uid);
3047
3048 /**
3049  * This API is only for Appfw internally.
3050  */
3051 int aul_ignore_app_status(status_listen_h handle);
3052
3053 #ifdef __cplusplus
3054         }
3055 #endif
3056
3057