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