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