Move function definition to aul header
[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_res_control_allowed_resource_path(const char *res_type, char **path);
2008
2009 /*
2010  * This API is only for Appfw internally.
2011  */
2012 int aul_get_app_res_control_global_resource_path(const char *res_type, char **path);
2013
2014 /*
2015  * This API is only for Appfw internally.
2016  */
2017 int aul_get_app_shared_data_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_shared_resource_path_by_appid(const char *app_id, char **path);
2023
2024 /*
2025  * This API is only for Appfw internally.
2026  */
2027 int aul_get_app_shared_trusted_path_by_appid(const char *app_id, char **path);
2028
2029 /*
2030  * This API is only for Appfw internally.
2031  */
2032 int aul_get_app_external_shared_data_path_by_appid(const char *app_id, char **path);
2033
2034 /*
2035  * This API is only for Appfw internally.
2036  */
2037 int aul_get_usr_app_shared_data_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_shared_resource_path_by_appid(const char *app_id, char **path, uid_t uid);
2043
2044 /*
2045  * This API is only for Appfw internally.
2046  */
2047 int aul_get_usr_app_shared_trusted_path_by_appid(const char *app_id, char **path, uid_t uid);
2048
2049 /*
2050  * This API is only for Appfw internally.
2051  */
2052 int aul_get_usr_app_external_shared_data_path_by_appid(const char *app_id, char **path, uid_t uid);
2053
2054 /*
2055  * This type is only for Appfw internally.
2056  */
2057 typedef int (*subapp_fn)(void *data);
2058
2059 /*
2060  * This API is only for Appfw internally.
2061  */
2062 int aul_set_subapp(subapp_fn cb, void *data);
2063
2064 /*
2065  * This API is only for Appfw internally.
2066  */
2067 int aul_subapp_terminate_request_pid(int pid);
2068
2069 /*
2070  * This API is only for Appfw internally.
2071  */
2072 int aul_is_subapp(void);
2073
2074 /*
2075  * This API is only for Appfw internally.
2076  */
2077 int aul_kill_pid(int pid);
2078
2079 /*
2080  * This API is only for Appfw internally.
2081  */
2082 int aul_add_caller_cb(int pid,  void (*caller_cb) (int, void *), void *data);
2083
2084 /*
2085  * This API is only for Appfw internally.
2086  */
2087 int aul_remove_caller_cb(int pid, void *data);
2088
2089 /*
2090  * This API is only for Appfw internally.
2091  */
2092 int aul_invoke_caller_cb(void *data);
2093
2094 /*
2095  * This API is only for Appfw internally.
2096  */
2097 void aul_set_preinit_window(void *evas_object);
2098
2099 /*
2100  * This API is only for Appfw internally.
2101  */
2102 void* aul_get_preinit_window(const char *win_name);
2103
2104 /*
2105  * This API is only for Appfw internally.
2106  */
2107 void aul_set_preinit_background(void *evas_object);
2108
2109 /*
2110  * This API is only for Appfw internally.
2111  */
2112 void* aul_get_preinit_background(void);
2113
2114 /*
2115  * This API is only for Appfw internally.
2116  */
2117 void aul_set_preinit_conformant(void *evas_object);
2118
2119 /*
2120  * This API is only for Appfw internally.
2121  */
2122 void* aul_get_preinit_conformant(void);
2123
2124 /*
2125  * This API is only for Appfw internally.
2126  */
2127 void aul_set_preinit_appid(const char *appid);
2128
2129 /*
2130  * This API is only for Appfw internally.
2131  */
2132 void aul_set_preinit_pkgid(const char *pkgid);
2133
2134 /*
2135  * This API is only for Appfw internally.
2136  */
2137 void aul_set_preinit_root_path(const char *root_path);
2138
2139 /*
2140  * This API is only for Appfw internally.
2141  */
2142 const char *aul_get_preinit_root_path(void);
2143
2144 /*
2145  * This API is only for Appfw internally.
2146  */
2147 int aul_update_freezer_status(int pid, const char* type);
2148
2149 /*
2150  * This API is only for Appfw internally.
2151  */
2152 int aul_send_app_launch_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_resume_request_signal(int pid, const char* appid, const char* pkgid, const char *type);
2158
2159 /*
2160  * This API is only for Appfw internally.
2161  */
2162 int aul_send_app_terminate_request_signal(int pid, const char* appid, const char* pkgid, const char *type);
2163
2164 /*
2165  * This API is only for Appfw internally.
2166  */
2167 int aul_send_app_status_change_signal(int pid, const char* appid, const char* pkgid, const char* status, const char *type);
2168
2169 /*
2170  * This API is only for Appfw internally.
2171  */
2172 int aul_send_app_terminated_signal(int pid);
2173
2174 /*
2175  * This API is only for Appfw internally.
2176  */
2177 int aul_send_app_group_signal(int owner_pid, int child_pid, const char *child_pkgid);
2178
2179 /*
2180  * This API is only for Appfw internally.
2181  */
2182 int aul_invoke_status_local_cb(int status);
2183
2184 /*
2185  * This type is only for Appfw internally.
2186  */
2187 typedef int (*data_control_provider_handler_fn) (bundle *b, int request_id, void *data);
2188
2189 /*
2190  * This API is only for Appfw internally.
2191  */
2192 int aul_set_data_control_provider_cb(data_control_provider_handler_fn handler);
2193
2194 /*
2195  * This API is only for Appfw internally.
2196  */
2197 int aul_unset_data_control_provider_cb(void);
2198
2199 /*
2200  * This API is only for Appfw internally.
2201  */
2202 int aul_pause_app(const char *appid);
2203
2204 /*
2205  * This API is only for Appfw internally.
2206  */
2207 int aul_pause_app_for_uid(const char *appid, uid_t uid);
2208
2209 /*
2210  * This API is only for Appfw internally.
2211  */
2212 int aul_pause_pid(int pid);
2213
2214 /*
2215  * This API is only for Appfw internally.
2216  */
2217 int aul_pause_pid_for_uid(int pid, uid_t uid);
2218
2219 /*
2220  * This API is only for Appfw internally.
2221  */
2222 int aul_reload_appinfo(void);
2223
2224 /*
2225  * This API is only for Appfw internally.
2226  */
2227 int aul_status_update(int status);
2228
2229 /*
2230  * This API is only for Appfw internally.
2231  */
2232 int aul_app_group_get_window(int pid);
2233
2234 /*
2235  * This API is only for Appfw internally.
2236  */
2237 int aul_app_group_set_window(int wid);
2238
2239 /*
2240  * This API is only for Appfw internally.
2241  */
2242 void aul_app_group_get_leader_pids(int *cnt, int **pids);
2243
2244 /*
2245  * This API is only for Appfw internally.
2246  */
2247 void aul_app_group_get_group_pids(int leader_pid, int *cnt, int **pids);
2248
2249 /*
2250  * This API is only for Appfw internally.
2251  */
2252 int aul_app_group_get_leader_pid(int pid);
2253
2254 /*
2255  * This API is only for Appfw internally.
2256  */
2257 int aul_app_group_clear_top(void);
2258
2259 /*
2260  * This API is only for Appfw internally.
2261  */
2262 int aul_app_group_is_top(void);
2263
2264 /*
2265  * This API is only for Appfw internally.
2266  */
2267 int aul_app_group_get_fg_flag(int pid);
2268
2269 /*
2270  * This API is only for Appfw internally.
2271  */
2272 void aul_app_group_lower(int *exit);
2273
2274 /*
2275  * This API is only for Appfw internally.
2276  */
2277 void aul_app_group_get_idle_pids(int *cnt, int **pids);
2278
2279 /**
2280  * @par Description:
2281  *      This API puts some app below the caller app
2282  * @par Purpose:
2283  *      This API's purpose is to reorder window stack limitedly.
2284  *
2285  * @param[in]   below_appid     The appid to be reordered below the caller app
2286  * @return      0 success, negative value(<0) if fail
2287  *
2288  * @remark
2289  *      below_appid should be main app which have been launched before.
2290  *      This API is only available in User Session.
2291 */
2292 int aul_app_group_activate_below(const char *below_appid);
2293
2294 /**
2295  * @par Description:
2296  *      This API puts some app above the caller app
2297  * @par Purpose:
2298  *      This API's purpose is to reorder window stack limitedly.
2299  *
2300  * @param[in]   above_appid     The appid to be reordered above the caller app
2301  * @return      0 if success, negative value(<0) if fail
2302  *
2303  * @remark
2304  *      above_appid should be main app which have been launched before.
2305  *      This API is only available in User Session.
2306 */
2307 int aul_app_group_activate_above(const char *above_appid);
2308
2309 /*
2310  * This API is only for Appfw internally.
2311  */
2312 int aul_request_data_control_socket_pair(bundle *b, int *fd);
2313
2314 /*
2315  * This API is only for Appfw internally.
2316  */
2317 int aul_request_message_port_socket_pair(int *fd);
2318
2319 /**
2320  * @brief Called when the system booting is completed.
2321  * @param[in]   unused          The unused parameter
2322  * @param[in]   user_data       The use data passed from the registration function
2323  * @return      The return value is not used.
2324  *
2325  * @see aul_listen_booting_done_signal();
2326  */
2327 typedef int (*aul_booting_done_event_cb)(int unused, void *user_data);
2328
2329 /**
2330  * @brief Registers a callback function to be invoked when the system booting is completed.
2331  * @param[in]   callback        The callback function
2332  * @param[in]   user_data       The user data to be passed to the callback function
2333  * @return      @c 0 on success,
2334  *              otherwise a negative error value
2335  *
2336  * @see aul_booting_done_event_cb()a
2337  * @remarks This function is only available for App Framework internally.
2338  */
2339 int aul_listen_booting_done_signal(aul_booting_done_event_cb, void *user_data);
2340
2341 /**
2342  * @brief Called when the coodlown event occurs.
2343  * @param[in]   status          The cooldown status
2344  * @param[in]   user_data       The user data passed from the registration function
2345  * @return      The return value is not used.
2346  *
2347  * @see aul_listen_cooldown_signal()
2348  */
2349 typedef int (*aul_cooldown_event_cb)(const char *status, void *user_data);
2350
2351 /**
2352  * @brief Registers a callback function to be invoked when the cooldown event occurs.
2353  * @param[in]   callback        The callback function
2354  * @param[in]   user_data       The user data to be passed to the callback function
2355  * @return      @c 0 on success,
2356  *              otherwise a negative error value
2357  *
2358  * @see aul_coodlown_event_cb()
2359  *
2360  * @remarks This function is only available for App Framework internally.
2361  */
2362 int aul_listen_cooldown_signal(int (*func) (const char *, void *), void *data);
2363
2364 /**
2365  * @brief Called when the status of the app process is changed.
2366  * @details This function is called when the app process status is changed, after you register this callback using aul_listen_app_status_signal().
2367  * @param[in]   pid             The process ID
2368  * @param[in]   status          The status of the process
2369  * @param[in]   user_data       The user data passed from the registeration function
2370  *
2371  * @see @aul_listen_app_status_signal()
2372  * @see #aul_process_status_e
2373  */
2374 typedef int (*aul_app_status_changed_cb)(int pid, int status, void *user_data);
2375
2376 /**
2377  * @brief Registers a callback function to be invoked when the process status is changed.
2378  * @remarks If the callback function is nullptr, the registered event will be deregistered.
2379  * @param[in]   callback        The callback function
2380  * @param[in]   user_data       The user data to be passed to the callback function
2381  * @return      @c 0 on success,
2382  *              otherwise a negative error value
2383  * @retval      #AUL_R_OK       Successful
2384  * @retval      #AUL_R_ERROR    Internal I/O error
2385  *
2386  * @see @aul_app_status_changed_cb()
2387  * @see #aul_process_status_e
2388  *
2389  * @remarks This function is only available for App Framework internally.
2390  *
2391  * @code
2392  * #include <aul.h>
2393  *
2394  * static int app_status_changed_cb(int pid, int status, void *user_data)
2395  * {
2396  *     cosnt char *app_status;
2397  *
2398  *     switch (status) {
2399  *     case AUL_PROC_STATUS_LAUNCH:
2400  *         app_status = "LAUNCHING";
2401  *         break;
2402  *     case AUL_PROC_STATUS_FG:
2403  *         app_status = "VISIBLE";
2404  *         break;
2405  *     case AUL_PROC_STATUS_BG:
2406  *         app_status = "BACKGROUND";
2407  *         break;
2408  *     case AUL_PROC_STATUS_FOCUS:
2409  *         app_status = "FOCUS";
2410  *         break;
2411  *     case AUL_PROC_STATUS_HIDE:
2412  *         app_status = "HIDE";
2413  *         break;
2414  *     default:
2415  *         app_status = "UNKNOWN";
2416  *         break;
2417  *     }
2418  *
2419  *     dlog_print(DLOG_INFO, LOG_TAG, "pid: %d, status: %%s(%d)", pid, app_status, status);
2420  *     return 0;
2421  * }
2422  *
2423  * int listen_app_status_signal(void)
2424  * {
2425  *     int ret;
2426  *
2427  *     ret = aul_listen_app_status_signal(app_status_changed_cb, NULL);
2428  *     if (ret != AUL_R_OK) {
2429  *         dlog_print(DLOG_ERROR, LOG_TAG, "aul_listen_app_status_signal() is failed. error(%d)", ret);
2430  *         return -1;
2431  *     }
2432  *
2433  *     return 0;
2434  * }
2435  */
2436 int aul_listen_app_status_signal(aul_app_status_changed_cb callback, void *user_data);
2437
2438 /*
2439  * This API is only for Appfw internally.
2440  */
2441 int aul_check_tep_mount(const char *tep_path);
2442
2443 /*
2444  * This API is only for Appfw internally.
2445  */
2446 int aul_is_tep_mount_dbus_done(const char *tep_string);
2447
2448 /*
2449  * This API is only for Appfw internally.
2450  */
2451 int aul_forward_app(const char *appid, bundle *kb);
2452
2453 /**
2454  * @par Description:
2455  *      This API create custom launchpad-loader
2456  * @par Purpose:
2457  *      This API's purpose is to make a slot for custom loader.
2458  *      Once it is made, added loader will make a candidate process to use.
2459  *
2460  * @param[in]   loader_path     The file name of the custom loader binary including full path
2461  * @param[in]   extra           A bundle to be passed to the custom loader
2462  * @return      Loader ID if success, negative value(<0) if fail
2463  *
2464  * @remark
2465  *      This API is only for Appfw internally.
2466  *      This API is only available in User Session.
2467 */
2468 int aul_add_loader(const char *loader_path, bundle *extra);
2469
2470 /**
2471  * @par Description:
2472  *      This API create custom launchpad-loader
2473  * @par Purpose:
2474  *      This API's purpose is to make a slot for custom loader.
2475  *      Once it is made, added loader will make a candidate process to use.
2476  *
2477  * @param[in]   loader_path     The file name of the custom loader binary including full path
2478  * @param[in]   extra           A bundle to be passed to the custom loader
2479  * @param[in]   uid             User ID
2480  * @return      Loader ID if success, negative value(<0) if fail
2481  *
2482  * @remark
2483  *      This API is only for Appfw internally.
2484  *      This API is only available to System user.
2485 */
2486 int aul_add_loader_for_uid(const char *loader_path, bundle *extra, uid_t uid);
2487
2488
2489 /**
2490  * @par Description:
2491  *      This API destroy custom launchpad-loader
2492  * @par Purpose:
2493  *      This API's purpose is to remove a slot for custom loader.
2494  *      Once it is removed, the prepared process will be removed as well.
2495  *
2496  * @param[in]   loader_id       Loader ID
2497  * @return      0 if success, negative value(<0) if fail
2498  *
2499  * @remark
2500  *      This API is only for Appfw internally.
2501  *      This API is only available in User Session.
2502 */
2503 int aul_remove_loader(int loader_id);
2504
2505 /**
2506  * @par Description:
2507  *      This API destroy custom launchpad-loader
2508  * @par Purpose:
2509  *      This API's purpose is to remove a slot for custom loader.
2510  *      Once it is removed, the prepared process will be removed as well.
2511  *
2512  * @param[in]   loader_id       Loader ID
2513  * @param[in]   uid             User ID
2514  * @return      0 if success, negative value(<0) if fail
2515  *
2516  * @remark
2517  *      This API is only for Appfw internally.
2518  *      This API is only available to System user.
2519 */
2520 int aul_remove_loader_for_uid(int loader_id, uid_t uid);
2521
2522 /**
2523  * @par Description
2524  *      This API gets specified application process id.
2525  * @par Purpose:
2526  *      The purpose of this API is to get the pid of specified application.
2527  *
2528  * @param[in]   appid   application name
2529  * @return      callee's pid if success, negative value(<0) if fail
2530  *
2531  * @remark
2532  *      This API is only available in User Session.
2533  */
2534 int aul_app_get_pid(const char *appid);
2535
2536 /**
2537  * @par Description
2538  *      This API gets specified application process id.
2539  * @par Purpose:
2540  *      The purpose of this API is to get the pid of specified application.
2541  *
2542  * @param[in]   appid   application name
2543  * @param[in]   uid     User ID
2544  * @return      callee's pid if success, negative value(<0) if fail
2545  *
2546  * @remark
2547  *      This API is only available to System user.
2548  */
2549 int aul_app_get_pid_for_uid(const char *appid, uid_t uid);
2550
2551 /**
2552  * @par Description:
2553  * This function update rua stat.
2554  *
2555  * @param[in] b Bundle object contains caller and tag information.
2556  * @param[in] uid Target uid
2557  *
2558  * @return 0 if success, negative value(<0) if fail
2559  * @see None
2560  * @remarks This API is only for Appfw internally.
2561  *
2562  * @par Sample code:
2563  * @code
2564 #include <aul.h>
2565
2566 ...
2567 {
2568     int r;
2569     bundle *b = bundle_create();
2570     bundle_add_str(b, AUL_SVC_K_RUA_STAT_CALLER, caller);
2571     bundle_add_str(b, AUL_SVC_K_RUA_STAT_TAG, tag);
2572
2573     r = aul_update_rua_stat_for_uid(b);
2574 }
2575
2576  * @endcode
2577  **/
2578 int aul_update_rua_stat_for_uid(bundle *b, uid_t uid);
2579
2580 /**
2581  * @par Description:
2582  * This function add rua history.
2583  *
2584  * @param[in] b Bundle object Target Package name or app path.
2585  * @param[in] uid Target uid
2586  *
2587  * @return 0 if success, negative value(<0) if fail
2588  * @see None
2589  * @remarks This API is only for Appfw internally.
2590  *
2591  * @par Sample code:
2592  * @code
2593 #include <aul.h>
2594
2595 ...
2596 {
2597     int r;
2598     bundle *b = bundle_create();
2599     if (pkg_name)
2600         bundle_add_str(b, AUL_K_RUA_PKGNAME, pkg_name);
2601     else if (app_path)
2602         bundle_add_str(b, AUL_K_RUA_APPPATH, app_path);
2603
2604     r = aul_add_rua_history_for_uid(b);
2605 }
2606
2607  * @endcode
2608  **/
2609 int aul_add_rua_history_for_uid(bundle *b, uid_t uid);
2610
2611 /**
2612  * @par Description:
2613  * This function delete rua history.
2614  *
2615  * @param[in] b Bundle object Target Package name. If NULL or has no value, delete all rua history.
2616  * @param[in] uid Target uid
2617  *
2618  * @return 0 if success, negative value(<0) if fail
2619  * @see None
2620  * @remarks This API is only for Appfw internally.
2621  *
2622  * @par Sample code:
2623  * @code
2624 #include <aul.h>
2625
2626 ...
2627 {
2628     int r;
2629     bundle *b = NULL;
2630     if (pkg_name) {
2631         b = bundle_create();
2632         bundle_add_str(b, AUL_K_RUA_PKGNAME, pkg_name);
2633     }
2634     r = aul_delete_rua_history_for_uid(b, getuid());
2635 }
2636
2637  * @endcode
2638  **/
2639 int aul_delete_rua_history_for_uid(bundle *b, uid_t uid);
2640
2641
2642 /**
2643  * @par Description:
2644  * This function sets the default application(application id) associated with operatioin, uri and mime-type.
2645  *
2646  * @param[in] b Bundle object Target application id and operation, uri and mime-type.
2647  *
2648  * @return 0 if success, negative value(<0) if fail
2649  * @see None
2650  * @remarks This API is only for Appfw internally.
2651  *
2652  * @par Sample code:
2653  * @code
2654 #include <aul.h>
2655 #include <aul_svc.h>
2656
2657 ...
2658 {
2659     int r;
2660     bundle *b = bundle_create();
2661
2662     const char *appid = "org.tizen.test";
2663     const char *operation = "test_operation";
2664     const char *mime_type = "test_mime";
2665     const char *uri = "test_uri";
2666
2667     aul_svc_set_operation(b, operation);
2668     aul_svc_set_mime(b, mime_type);
2669     aul_svc_set_uri(b, uri);
2670
2671     aul_svc_set_appid(b, appid)
2672
2673     r = aul_set_default_app_by_operation(b);
2674 }
2675
2676  * @endcode
2677  **/
2678 int aul_set_default_app_by_operation(bundle *b);
2679
2680 /**
2681  * @par Description:
2682  * This API unset the default application(application id) associated with operation, uri and mime-type.
2683  *
2684  * @param[in] app_id    The ID of the application
2685  *
2686  * @return 0 if success, negative value(<0) if fail
2687  *
2688  * @pre None.
2689  * @post None.
2690  * @see None.
2691  * @remarks None.
2692  *
2693  * @par Sample code:
2694  * @code
2695 #include <aul.h>
2696
2697 ...
2698 {
2699     aul_unset_default_app_by_operation("org.tizen.test");
2700 }
2701  * @endcode
2702  *
2703  */
2704 int aul_unset_default_app_by_operation(const char *app_id);
2705
2706 /**
2707  * @par Description:
2708  *      Sends the launch request asynchronously.
2709  *
2710  * @param[in]   appid           The application ID
2711  * @param[in]   kb              The Bundle data
2712  * @return      a pid of the callee on success,
2713  *              otherwise a negative error value
2714  * @retval      AUL_R_OK        - Successful
2715  * @retval      AUL_R_EINVAL    - Invalid parameter
2716  * @retval      AUL_R_ECOM      - Internal AUL IPC error
2717  * @retval      AUL_R_ERROR     - General error
2718  *
2719  * @remark
2720  *      This API is only available in User Session.
2721  *      This API doesn't check whether the callee application is executed successfully.
2722  *      If the caller application is equal to the callee application, this API can return AUL_R_OK.
2723  */
2724 int aul_launch_app_async(const char *appid, bundle *kb);
2725
2726 /**
2727  * @par Description:
2728  *      Sends the launch request asynchronously.
2729  *
2730  * @param[in]   appid           The application ID
2731  * @param[in]   kb              The Bundle data
2732  * @param[in]   uid             User ID
2733  * @return      a pid of the callee on success,
2734  *              otherwise a negative error value
2735  * @retval      AUL_R_OK        - Successful
2736  * @retval      AUL_R_EINVAL    - Invalid parameter
2737  * @retval      AUL_R_ECOM      - Internal AUL IPC error
2738  * @retval      AUL_R_ERROR     - General error
2739  *
2740  * @remark
2741  *      This API is only available to System user.
2742  *      This API doesn't check whether the callee application is executed successfully.
2743  *      If the caller application is equal to the callee application, this API can return AUL_R_OK.
2744  */
2745 int aul_launch_app_async_for_uid(const char *appid, bundle *kb, uid_t uid);
2746
2747 /**
2748  * @par Description:
2749  * This API request launchpad to make candidate processes.
2750  *
2751  * @return 0 if success, negative value(<0) if fail
2752  *
2753  * @remark
2754  *      This API is only available in User Session.
2755  */
2756 int aul_prepare_candidate_process(void);
2757
2758 /*
2759  * This API is only for Appfw internally.
2760  */
2761 int aul_widget_instance_add(const char *widget_id, const char *instance_id);
2762
2763 /*
2764  * This API is only for Appfw internally.
2765  */
2766 int aul_widget_instance_del(const char *widget_id, const char *instance_id);
2767
2768 /*
2769  * This API is only for Appfw internally.
2770  */
2771 typedef void (*aul_widget_instance_foreach_cb)(const char *instance_id, void *data);
2772
2773 /*
2774  * This API is only for Appfw internally.
2775  */
2776 int aul_widget_instance_foreach(const char *widget_id, aul_widget_instance_foreach_cb cb, void *data);
2777
2778 /*
2779  * This API is only for Appfw internally.
2780  */
2781 int aul_widget_instance_update(const char *widget_id, const char *instance_id, bundle *b);
2782
2783 /*
2784  * This API is only for Appfw internally.
2785  */
2786 int aul_widget_instance_count(const char *widget_id);
2787
2788 /**
2789  * @par Description:
2790  *      This API gets the last caller process id of specified application process id.
2791  * @par Purpose:
2792  *      This API's purpose is to get the application's last caller process id.
2793  *
2794  * @param[in]   pid     pid of application
2795  * @return      caller pid if success, nagative value if fail
2796  *
2797  * @remark
2798  *      This API is only available in User Session.
2799  */
2800 int aul_app_get_last_caller_pid(int pid);
2801
2802 /**
2803  * @par Description:
2804  *      This API gets the last caller process id of specified application process id.
2805  * @par Purpose:
2806  *      This API's purpose is to get the last caller process id of the application.
2807  *
2808  * @param[in]   pid     pid of application
2809  * @param[in]   uid     User ID
2810  * @return      caller pid if success, nagative value if fail
2811  *
2812  * @remark
2813  *      This API is only available in System users.
2814  */
2815 int aul_app_get_last_caller_pid_for_uid(int pid, uid_t uid);
2816
2817 /**
2818  * @par Description:
2819  *      This API trigger to resume application asynchronously.
2820  *      If the application is running, this API send a resume event to the App.
2821  *      If the application is not running, this API return AUL_R_ERROR.
2822  *      Although the application is running, if the application cannot receive resume event,
2823  *      AUL try to raise the application's default windows.
2824  * @par Purpose:
2825  *      This API is for caller.
2826  *      This API's purpose is to send resume event.
2827  * @par Typical use case:
2828  *      In multiple application model, If you want to only resume specific application, Use this API
2829  *
2830  * @param[in]   pid     application's pid to be resumed
2831  * @return      0 if success, negative value(<0) if fail
2832  * @retval      AUL_R_OK        - success
2833  * @retval      AUL_R_EINVAL    - invaild pid
2834  * @retval      AUL_R_ECOM      - internal AUL IPC error
2835  * @retval      AUL_R_ERROR     - general error (include application is not running)
2836  * @warning     This API need to require root or inhouse permisssion \n
2837  *              If you have not the permission, this API return AUL_R_ERROR. \n
2838  * @remark
2839  *      This API is only available to User Session.
2840  */
2841 int aul_resume_pid_async(int pid);
2842
2843 /**
2844  * @par Description:
2845  *      This API trigger to resume application asynchronously.
2846  *      If the application is running, this API send a resume event to the App.
2847  *      If the application is not running, this API return AUL_R_ERROR.
2848  *      Although the application is running, if the application cannot receive resume event,
2849  *      AUL try to raise the application's default windows.
2850  * @par Purpose:
2851  *      This API is for caller.
2852  *      This API's purpose is to send resume event.
2853  * @par Typical use case:
2854  *      In multiple application model, If you want to only resume specific application, Use this API
2855  *
2856  * @param[in]   pid     application's pid to be resumed
2857  * @param[in]   uid     User ID
2858  * @return      0 if success, negative value(<0) if fail
2859  * @retval      AUL_R_OK        - success
2860  * @retval      AUL_R_EINVAL    - invaild pid
2861  * @retval      AUL_R_ECOM      - internal AUL IPC error
2862  * @retval      AUL_R_ERROR     - general error (include application is not running)
2863  * @warning     This API need to require root or inhouse permisssion \n
2864  *              If you have not the permission, this API return AUL_R_ERROR. \n
2865  * @remark
2866  *      This API is only available to System user.
2867  */
2868 int aul_resume_pid_async_for_uid(int pid, uid_t uid);
2869
2870 /**
2871  * @par Description:
2872  *      This API set the alias appid.
2873  *      The alias appid is only available for the aul_svc_set_appid() API.
2874  *      If the appid is not available, this API returns an error.
2875  *
2876  * @privlevel platform
2877  * @privilege %http://tizen.org/privilege/systemsettings.admin
2878  * @param[in]   alias_appid     an alias application ID
2879  * @param[in]   appid           an application ID
2880  * @return      0 if success, negative value(<0) if fail
2881  *
2882  * @remark
2883  *      This API is only available to User Session.
2884  */
2885 int aul_set_alias_appid(const char *alias_appid, const char *appid);
2886
2887 /**
2888  * @par Description:
2889  *      This API unset the alias appid.
2890  *
2891  * @privlevel platform
2892  * @privilege %http://tizen.org/privilege/systemsettings.admin
2893  * @param[in]   alias_appid     an alias application ID
2894  * @return      0 if success, negative value(<0) if fail
2895  *
2896  * @remark
2897  *      This API is only available to User Session.
2898  */
2899 int aul_unset_alias_appid(const char *alias_appid);
2900
2901 /**
2902  * @par Description:
2903  *      This API activates the alias information based on the given appid.
2904  *
2905  * @privlevel platform
2906  * @privilege %http://tizen.org/privilege/systemsettings.admin
2907  * @param[in]   appid   an application ID
2908  * @return      0 if success, negative value(<0) if fail
2909  *
2910  * @remark
2911  *      This API is only available to User Session.
2912  */
2913 int aul_enable_alias_info(const char *appid);
2914
2915 /**
2916  * @par Description:
2917  *      This API deactivates the alias information based on the given appid.
2918  *
2919  * @privlebel platform
2920  * @privilege %http://tizen.org/privilege/systemsettings.admin
2921  * @param[in]   appid   an application ID
2922  * @return      0 if success, negative value(<0) if fail
2923  *
2924  * @remark
2925  *      This API is only available to User Session.
2926  */
2927 int aul_disable_alias_info(const char *appid);
2928
2929 /**
2930  * This API is only for Appfw internally.
2931  */
2932 typedef int (*app_status_cb)(aul_app_info *info, int ctx_status, void *data);
2933
2934 /**
2935  * This API is only for Appfw internally.
2936  */
2937 typedef struct status_listen_s *status_listen_h;
2938
2939 /**
2940  * @par Description:
2941  *      Registers a callback function to be invoked when the application change status.
2942  *
2943  * @param[in]   appid           The application ID to get status
2944  * @param[in]   callback        The callback function to register
2945  * @param[in]   data            The user data to be passed to the callback function
2946  * @param[out]  handle          The status listen handle
2947  * @return      @c 0 on success,
2948  *              otherwise a negative error value
2949  */
2950 int aul_listen_app_status(const char *appid, app_status_cb callback,
2951                 void *data, status_listen_h *handle);
2952 int aul_listen_app_status_for_uid(const char *appid, app_status_cb callback,
2953                 void *data, status_listen_h *handle, uid_t uid);
2954
2955 /*
2956  * This API is only for Appfw internally.
2957  */
2958 int aul_widget_instance_get_content(const char *widget_id, const char *instance_id, char **content);
2959
2960 /**
2961  * @par Description:
2962  *      Gets running application instance info
2963  *      This API calls the iter_fn with the aul_app_info when running app instance info is found.
2964  *
2965  * @param[in]   iter_fn         iterative function
2966  * @param[in]   user_data       User data
2967  * @return      0 if success, negative value(<0) if fail
2968  * @retval      AUL_R_OK        Successful
2969  * @retval      AUL_R_ERROR     General error
2970  * @retval      AUL_R_EINVAL    Invalid parameter
2971  */
2972 int aul_app_get_running_app_instance_info(aul_app_info_iter_fn iter_fn,
2973                 void *user_data);
2974 int aul_app_get_running_app_instance_info_for_uid(aul_app_info_iter_fn iter_fn,
2975                 void *user_data, uid_t uid);
2976
2977 /*
2978  * This API is only for Appfw internally.
2979  */
2980 int aul_app_get_instance_id_bypid(int pid, char *instance_id, int len);
2981 int aul_app_get_instance_id_bypid_for_uid(int pid, char *instance_id,
2982                 int len, uid_t uid);
2983
2984 /*
2985  * This API is only for Appfw internally.
2986  */
2987 int aul_resume_app_by_instance_id(const char *appid, const char *instance_id);
2988 int aul_resume_app_by_instance_id_for_uid(const char *appid,
2989                 const char *instance_id, uid_t uid);
2990
2991 /**
2992  * This API is only for Appfw internally.
2993  */
2994 int aul_ignore_app_status(status_listen_h handle);
2995
2996 /**
2997  * This API is only for Appfw internally.
2998  */
2999 int aul_notify_exit(void);
3000 int aul_notify_start(void);
3001
3002 /**
3003  * This API is only for App Framework internally.
3004  */
3005 const char *aul_app_status_convert_to_string(int status);
3006
3007 /**
3008  * This API is only for App Framework internally.
3009  */
3010 int aul_terminate_instance_async(const char *instance_id, int pid);
3011 int aul_terminate_instance_async_for_uid(const char *instance_id, int pid,
3012                 uid_t uid);
3013
3014 /**
3015  * @brief Sends the terminate request.
3016  * @since_tizen 5.5
3017  * @privlevel platform
3018  * @privilege %http://tizen.org/privilege/appmanager.kill
3019  *
3020  * @param[in]   appid           The application ID
3021  * @param[in]   instance_id     The instance ID
3022  * @return      @c 0 on success,
3023  *              otherwise a negative error value
3024  *
3025  * @remarks This function is only for App Framework internally.
3026  */
3027 int aul_terminate_app_with_instance_id(const char *appid,
3028                 const char *instance_id);
3029
3030 /**
3031  * @brief Sends the terminate request.
3032  * @since_tizen 5.5
3033  * @privlevel platform
3034  * @privilege %http://tizen.org/privilege/appmanager.kill
3035  *
3036  * @param[in]   appid           The application ID
3037  * @param[in]   instance_id     The instance ID
3038  * @param[in]   uid             The user ID
3039  * @return      @c 0 on success,
3040  *              otherwise a negative error value
3041  *
3042  * @remarks This function is only for App Framework internally.
3043  */
3044 int aul_terminate_app_with_instance_id_for_uid(const char *appid,
3045                 const char *instance_id, uid_t uid);
3046
3047 /**
3048  * @brief Sends the terminate request.
3049  * @since_tizen 5.5
3050  * @privlevel platform
3051  * @privilege %http://tizen.org/privilege/appmanager.kill
3052  *
3053  * @param[in]   appid           The application ID
3054  * @return      @c 0 on success,
3055  *              otherwise a negative error value
3056  *
3057  * @remarks This function is only for App Framework internally.
3058  */
3059 int aul_terminate_app(const char *appid);
3060
3061 /**
3062  * @brief Sends the terminate request.
3063  * @since_tizen 5.5
3064  * @privlevel platform
3065  * @privilege %http://tizen.org/privilege/appmanager.kill
3066  *
3067  * @param[in]   appid           The application ID
3068  * @param[in]   uid             The user ID
3069  * @return      @c 0 on success,
3070  *              otherwise a negative error value
3071  *
3072  * @remarks This function is only for App Framework internally.
3073  */
3074 int aul_terminate_app_for_uid(const char *appid, uid_t uid);
3075
3076 /**
3077  * @brief Checks whether the application is running or not.
3078  * @since_tizen 5.5
3079  *
3080  * @param[in]   appid           The application ID
3081  * @param[in]   instance_id     The instance ID
3082  * @param[out]  running         @c true if the instance is running, \n
3083  *                              otherwise @c false if not running
3084  * @return      @c 0 on success,
3085  *              otherwise a negative error value
3086  *
3087  * @remarks This function is only for App Framework internally.
3088  */
3089 int aul_app_is_running_with_instance_id(const char *appid,
3090                 const char *instance_id, bool *running);
3091
3092 /**
3093  * @brief Sends a preparation request for an app-defined loader.
3094  * @since_tizen 5.5
3095  *
3096  * @param[in]   loader_name     The loader name
3097  * @return      @c the loader ID on success,
3098  *              otherwise a negative error value
3099  *
3100  * @remarks This function is only for App Framework internally.
3101  */
3102 int aul_prepare_app_defined_loader(const char *loader_name);
3103 int aul_prepare_app_defined_loader_for_uid(const char *loader_name, uid_t uid);
3104
3105 /**
3106  * @remarks This function is only for App Framework internally.
3107  */
3108 int aul_status_update_v2(int status);
3109
3110 /**
3111  * @remarks This function is only for App Framework internally.
3112  */
3113 int aul_get_default_app(bundle *b, char **appid);
3114
3115 /**
3116  * @remarks This function is only for App Framework internally.
3117  */
3118 int aul_set_auto_restart(bundle *b);
3119
3120 /**
3121  * @remarks This function is only for App Framework internally.
3122  */
3123 int aul_unset_auto_restart(void);
3124
3125 /**
3126  * @remarks This function is only for App Framework internally.
3127  */
3128 int aul_package_pre_event_send(uid_t uid, bundle *b);
3129
3130 /**
3131  * @remarks This function is only for App Framework internally.
3132  */
3133 int aul_launch_worker_init(void);
3134
3135 /**
3136  * @remarks This function is only for App Framework internally.
3137  */
3138 void aul_launch_worker_fini(void);
3139
3140 /**
3141  * @brief Called when the application ID is delivered.
3142  * @since_tizen 8.0
3143  * @param[in]   result          The result
3144  * @param[in]   pid             The process ID
3145  * @param[in]   appid           The application ID
3146  * @param[in]   user_data       The user data passed from the regitration function
3147  * @remarks This function is only for App Framework internally.
3148  * @see aul_app_get_appid_bypid_async()
3149  */
3150 typedef void (*aul_appid_cb)(int result, pid_t pid, const char *appid, void *user_data);
3151
3152 /**
3153  * @brief Gets the application ID from the process ID.
3154  * @since_tizen 8.0
3155  * @param[in]   pid             The process ID
3156  * @param[in]   callback        The callback function
3157  * @param[in]   user_data       The user data to be passed to the callaback function
3158  * @return      @c 0 on success,
3159  *              otherwise a negative error value
3160  * @retval      #AUL_R_OK       Successful
3161  * @retval      #AUL_R_EINVAL   Invalid parameter
3162  * @retval      #AUL_R_ENOMEM   Out of memory
3163  * @retval      #AUL_R_ERROR    Internal I/O error
3164  * @remarks This function is only for App Framework internally.
3165  * @see aul_appid_cb()
3166  */
3167 int aul_app_get_appid_bypid_async(pid_t pid, aul_appid_cb callback, void *user_data);
3168
3169 /**
3170  * @brief Called when the result is delivered.
3171  * @since_tizen 8.0
3172  * @param[in]   result          The result
3173  * @param[in]   user_data       The user data passed from the regitration function
3174  * @remarks This function is only for App Framework internally.
3175  */
3176 typedef void (*aul_result_cb)(int result, void *user_data);
3177
3178 /**
3179  * @brief Sends the termination request with the process ID.
3180  * @since_tizen 8.0
3181  * @privilege   %http://tizen.org/privilege/appmanager.kill
3182  * @privlevel   platform
3183  * @param[in]   pid             The process ID
3184  * @param[in]   callback        The callback function
3185  * @param[in]   user_data       The user data to be passed to the callback function
3186  * @return      @c 0 on success,
3187  *              otherwise a negative error value
3188  * @retval      #AUL_R_OK       Successful
3189  * @retval      #AUL_R_EINVAL   Invalid parameter
3190  * @retval      #AUL_R_ENOMEM   Out of memory
3191  * @retval      #AUL_R_ERROR    Internal I/O error
3192  * @remarks This function is only for App Framework internally.
3193  * @see aul_result_cb()
3194  */
3195 int aul_terminate_pid_async_v2(pid_t pid, aul_result_cb callback, void *user_data);
3196
3197 /**
3198  * @brief Sends the termination request.
3199  * @since_tizen 8.0
3200  * @privilege   %http://tizen.org/privilege/appmanager.kill
3201  * @privlevel   platform
3202  * @param[in]   appid           The application ID
3203  * @param[in]   callback        The callback function
3204  * @param[in]   user_data       The user data to be passed to the callback function
3205  * @return      @c 0 on success,
3206  *              otherwise a negative error value
3207  * @retval      #AUL_R_OK       Successful
3208  * @retval      #AUL_R_EINVAL   Invalid parameter
3209  * @retval      #AUL_R_ENOMEM   Out of memory
3210  * @retval      #AUL_R_ERROR    Internal I/O error
3211  * @remarks This function is only for App Framework internally.
3212  * @see aul_result_cb()
3213  */
3214 int aul_terminate_app_async(const char *appid, aul_result_cb callback, void *user_data);
3215
3216 /**
3217  * @brief Sends the request to kill the process ID.
3218  * @since_tizen 8.0
3219  * @privilege   %http://tizen.org/privilege/appmanager.kill
3220  * @privlevel   platform
3221  * @param[in]   pid             The process ID
3222  * @param[in]   callback        The callback function
3223  * @param[in]   user_data       The user data to be passed to the callback function
3224  * @return      @c 0 on success,
3225  *              otherwise a negative error value
3226  * @retval      #AUL_R_OK       Successful
3227  * @retval      #AUL_R_EINVAL   Invalid parameter
3228  * @retval      #AUL_R_ENOMEM   Out of memory
3229  * @retval      #AUL_R_ERROR    Internal I/O error
3230  * @remarks This function is only for App Framework internally.
3231  * @see aul_result_cb()
3232  */
3233 int aul_kill_pid_async(pid_t pid, aul_result_cb callback, void *user_data);
3234
3235 /**
3236  * @Brief Called when the reply is delivered from the callee application.
3237  * @since_tizen 8.0
3238  * @param[in]   b               The bundle object
3239  * @param[in]   is_cancel       If true, the request was cancelled
3240  * @param[in]   user_data       The user data passed from the registration function
3241  * @remarks This function is only for App Framework internally.
3242  * @see aul_send_launch_request_for_uid()
3243  */
3244 typedef void (*aul_reply_cb)(bundle *b, int is_cancel, void *user_data);
3245
3246 /**
3247  * @brief Sends the launch request asynchronously.
3248  * @since_tizen 8.0
3249  * @privilege %http://tizen.org/privilege/appmanager.launch
3250  * @privlevel public
3251  * @param[in]   appid           The application ID
3252  * @param[in]   b               The bundle object
3253  * @param[in]   uid             The target user ID
3254  * @param[in]   reply_cb        The reply callback function
3255  * @param[in]   result_cb       The result callback function
3256  * @param[in]   user_data       The user data to be passed to the callback function
3257  * @retrun      @c 0 on success,
3258  *              otherwise a negative error value
3259  * @retval      #AUL_R_OK       Successful
3260  * @retval      #AUL_R_EINVAL   Invalid parameter
3261  * @retval      #AUL_R_ENOMEM   Out of memory
3262  * @retval      #AUL_R_ERROR    Internal I/O error
3263  * @retval      #AUL_R_ECOMM    Communication error on send
3264  * @retval      #AUL_R_EILLACC  Permission denied
3265  * @remarks This function is only for App Framework internally.
3266  * @see aul_reply_cb()
3267  */
3268 int aul_send_launch_request_for_uid(const char *appid, bundle *b, uid_t uid,
3269                 aul_reply_cb reply_cb, aul_result_cb result_cb, void *user_data);
3270
3271 #ifdef __cplusplus
3272         }
3273 #endif