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