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