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