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