c1ea1802896a4b99b05bfec133a4e8902fb4c915
[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 #ifndef __AUL_H__
21 #define __AUL_H__
22
23 #include <errno.h>
24 #include <bundle.h>
25 #include <sys/types.h>
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 /**
32  * @brief Return values in AUL.
33  */
34 typedef enum _aul_return_val {
35         AUL_R_EREJECTED = -14,          /**< App disable for mode */
36         AUL_R_ENOAPP = -13,             /**< Failed to find app ID or pkg ID */
37         AUL_R_EHIDDENFORGUEST = -11,    /**< App hidden for guest mode */
38         AUL_R_ENOLAUNCHPAD = -10,       /**< no launchpad */
39         AUL_R_ETERMINATING = -9,        /**< application terminating */
40         AUL_R_EILLACC = -8,             /**< Illegal Access */
41         AUL_R_LOCAL = -7,               /**< Launch by himself */
42         AUL_R_ETIMEOUT = -6,            /**< Timeout */
43         AUL_R_ECANCELED = -5,           /**< Operation canceled */
44         AUL_R_EINVAL = -4,              /**< Invalid argument */
45         AUL_R_ECOMM = -3,               /**< Comunication Error */
46         AUL_R_ENOINIT = -2,             /**< AUL handler NOT initialized */
47         AUL_R_ERROR = -1,               /**< General error */
48         AUL_R_OK = 0                    /**< General success */
49 }aul_return_val;
50
51 enum app_status {
52         STATUS_LAUNCHING,
53         STATUS_CREATED,
54         STATUS_FOCUS,
55         STATUS_VISIBLE,
56         STATUS_BG,
57         STATUS_DYING,
58         STATUS_HOME,
59         STATUS_NORESTART,
60         STATUS_SERVICE
61 };
62
63 typedef enum _aul_type{
64         AUL_START,
65         AUL_RESUME,
66         AUL_TERMINATE,
67         AUL_TERMINATE_BGAPP,
68         AUL_PAUSE,
69 }aul_type;
70
71 /** AUL public key - To check caller's secuirty */
72 #define AUL_K_CALLER_PID        "__AUL_CALLER_PID__"
73 /** AUL public key - To check callee's secuirty */
74 #define AUL_K_CALLEE_PID        "__AUL_CALLEE_PID__"
75 /** AUL public key - added for multiuser mode */
76 #define AUL_K_CALLER_UID        "__AUL_CALLER_UID__"
77 /** AUL public key - added for multiuser mode */
78 #define AUL_K_CALLEE_UID        "__AUL_CALLEE_UID__"
79 /** AUL public key - added for multiuser mode */
80 #define AUL_K_TARGET_UID        "__AUL_TARGET_UID__"
81 /** AUL public key - To check caller's secuirty */
82 #define AUL_K_CALLER_APPID      "__AUL_CALLER_APPID__"
83 /** AUL public key - To check caller's secuirty */
84 #define AUL_K_CALLEE_APPID      "__AUL_CALLEE_APPID__"
85 /** AUL public key - To find argv0 */
86 #define AUL_K_ARGV0             "__AUL_ARGV0__"
87 /** AUL public key - To measure launching time */
88 #define AUL_K_STARTTIME         "__AUL_STARTTIME__"
89 /** AUL public key - To support launching based on mime type */
90 #define AUL_K_MIME_TYPE         "__AUL_MIME_TYPE__"
91 /** AUL public key - To support launching based on mime type */
92 #define AUL_K_UNALIASED_MIME_TYPE               "__AUL_UNALIASED_MIME_TYPE__"
93 /** AUL public key - To support launching based on mime type */
94 #define AUL_K_MIME_CONTENT      "__AUL_MIME_CONTENT__"
95 /** AUL public key - To support launching based on service */
96 #define AUL_K_SERVICE_NAME              "__AUL_SERVICE_NAME__"
97 /** AUL public key - To force launch app selector instead of lauchingn default app */
98 #define AUL_K_FORCE_LAUNCH_APP_SELECTOR "__AUL_FORCE_LAUNCH_APP_SELECTOR__"
99 /** AUL public key - To support debug argument */
100 #define AUL_K_DEBUG     "__AUL_DEBUG__"
101 /** AUL public key - To support SDK */
102 #define AUL_K_SDK       "__AUL_SDK__"
103 /** AUL public key - To support Media key */
104 #define AUL_K_MULTI_KEY "__AUL_MULTI_KEY__"
105 /** AUL public key - To support Media key */
106 #define AUL_K_MULTI_KEY_EVENT   "__AUL_MULTI_KEY_EVENT__"
107 /** AUL public bundle value */
108 #define AUL_K_PRIVACY_APPID             "__AUL_PRIVACY_APPID__"
109 /** AUL public bundle value - To support Media key*/
110 #define AUL_V_KEY_PRESSED       "__AUL_KEY_PRESSED__"
111 /** AUL public bundle value - To support Media key*/
112 #define AUL_V_KEY_RELEASED      "__AUL_KEY_RELEASED__"
113 /** AUL public key - To support rua stat */
114 #define AUL_SVC_K_RUA_STAT_CALLER "__K_RUA_STAT_CALLER__"
115 #define AUL_SVC_K_RUA_STAT_TAG    "__K_RUA_STAT_TAG__"
116
117
118 /** AUL internal private key */
119 #define AUL_K_PKG_NAME          "__AUL_PKG_NAME__"
120 /** AUL internal private key */
121 #define AUL_K_WAIT_RESULT       "__AUL_WAIT_RESULT__"
122 /** AUL internal private key */
123 #define AUL_K_SEND_RESULT       "__AUL_SEND_RESULT__"
124 /** AUL internal private key */
125 #define AUL_K_TASK_MANAGE       "__AUL_TASK_MANAGE__"
126 /** AUL internal private key */
127 #define AUL_K_APP_TYPE          "__AUL_APP_TYPE__"
128 /** AUL internal private key - To check original caller's identity */
129 #define AUL_K_ORG_CALLER_PID    "__AUL_ORG_CALLER_PID__"
130 /** AUL internal private key - To check forwarded callee app's pid */
131 #define AUL_K_FWD_CALLEE_PID    "__AUL_FWD_CALLEE_PID__"
132 /** AUL internal private key */
133 #define AUL_K_NO_CANCEL        "__AUL_NO_CANCEL__"
134 /** AUL internal private key */
135 #define AUL_K_EXEC              "__AUL_EXEC__"
136 /** AUL internal private key */
137 #define AUL_K_MULTIPLE          "__AUL_MULTIPLE__"
138 /** AUL internal private key */
139 #define AUL_K_PACKAGETYPE       "__AUL_PACKAGETYPE__"
140 /** AUL internal private key */
141 #define AUL_K_HWACC             "__AUL_HWACC__"
142 /** AUL internal private key */
143 #define AUL_K_APPID             "__AUL_APPID__"
144 /** AUL internal private key */
145 #define AUL_K_PID               "__AUL_PID__"
146 /** AUL internal private key */
147 #define AUL_K_WID               "__AUL_WID__"
148 /** AUL internal private key */
149 #define AUL_K_LEADER_PID        "__AUL_LEADER_PID__"
150 /** AUL internal private key - To support data control */
151 #define AUL_K_DATA_CONTROL_TYPE   "__AUL_DATA_CONTROL_TYPE__"
152 /** AUL internal private key */
153 #define AUL_K_PKGID             "__AUL_PKGID_"
154 /** AUL internal private key */
155 #define AUL_K_INTERNAL_POOL "__AUL_INTERNAL_POOL__"
156 /** AUL internal private key */
157 #define AUL_TEP_PATH            "_AUL_TEP_PATH_"
158 /** AUL internal private key */
159 #define AUL_K_COMP_TYPE         "__AUL_COMP_TYPE__"
160 /** AUL internal private key */
161 #define AUL_K_LOADER_ID         "__AUL_LOADER_ID__"
162 /** AUL internal private key */
163 #define AUL_K_LOADER_PATH       "__AUL_LOADER_PATH__"
164
165 /**
166  * @brief       This is callback function for aul_launch_init
167  * @param[in]   type    event's type received from system
168  * @param[in]   b       In case of RESET events, bundle which is received from peer
169  * @param[in]   data    user-supplied data
170  */
171 typedef int (*aul_handler_fn) (aul_type type, bundle * b, void *data);
172
173 /**
174  * @par Description:
175  *      This API install your AUL handler and setup AUL internal connection.
176  * @par Purpose:
177  *      AUL receive START(RESET), RESUME, TERMINATE events from system.\n
178  *      This API use to handle the events. \n
179  * @par Typical use case:
180  *      In general, you need not use this API.
181  *      If you use AppCore, you should NOT use this API.
182  *      AppCore will set default aul_handler.
183  *
184  * @param[in]   handler         aul main callback handler function
185  * @param[in]   data            user-supplied data for start_handler
186  * @return      0 if success, negative value(<0) if fail\n
187  * @retval      AUL_R_OK        - success
188  * @retval      AUL_R_ECANCELD  - aul handler was installed already by others
189  * @retval      AUL_R_ECOMM     - error to create internal ipc
190  * @retval      AUL_R_ERROR     - error to attach glib main loop
191  *
192  * @warning     If you use AppCore, you should NOT use this API.\n
193  *              You need glib main loop.\n
194  * @pre
195  *      you must have aul handler to use this API.
196  *      aul_luanch_init register aul handler.
197  * @code
198  * #include <aul.h>
199  * #include <bundle.h>
200  *
201  * static int aul_handler(aul_type type, bundle *kb,void *data)
202  * {
203  *      switch(type)
204  *      {
205  *              case AUL_START:
206  *                      // process RESET event
207  *                      break;
208  *              case AUL_RESUME:
209  *                      // process RESUME event
210  *                      break;
211  *              case AUL_TERMINATE:
212  *                      // preocess TERMINATE event
213  *                      break;
214  *      }
215  *      return 0;
216  * }
217  *
218  * static GMainLoop *mainloop = NULL;
219  *
220  * int main(int argc, char **argv)
221  * {
222  *      aul_launch_init(aul_handler,NULL);
223  *      aul_launch_argv_handler(argc, argv);
224  *
225  *      mainloop = g_main_loop_new(NULL, FALSE);
226  *      g_main_loop_run(mainloop);
227  * }
228  *
229  * @endcode
230  * @remark
231  *      This API is only available in User Session.
232 */
233 int aul_launch_init(aul_handler_fn handler, void *data);
234
235 /**
236  * @par Description:
237  *      This API create internal RESET events with given argc, argv \n
238  * @par Purpose:
239  *      This API's purpose is to generate reset event.
240  *      If you want to generate local RESET events with argument vector format, use this API
241  * @par Typical use case:
242  *      In general, you need not use this API.
243  *      AppCore use this API to create internal reset event.
244  *
245  * @param[in]   argc    # of args
246  * @param[in]   argv    list of arg strings
247  * @return      0 if success, negative value(<0) if fail
248  * @retval      AUL_R_OK        - success
249  * @retval      AUL_R_ENOINIT   - aul handler was NOT yet installed
250  * @retval      AUL_R_ECANCLED  - error to create internal bundle with given argc,argv.
251  * @retval      AUL_R_ERROR     - general error
252  *
253  * @pre
254  *      you must have aul handler to use this API.
255  *      aul_luanch_init register aul handler.
256  * @see
257  *      aul_launch_init
258  * @code
259  * #include <aul.h>
260  * #include <bundle.h>
261  *
262  * int send_local_reset_event()
263  * {
264  *      int argc=3;
265  *      char* argv[4];
266  *      argv[0] = "local.app";
267  *      argv[1] = "event_type";
268  *      argv[2] = "my_reset";
269  *      argv[3] = NULL;
270  *      aul_launch_argv_handler(argc,argv);
271  * }
272  *
273  * @endcode
274  * @remark
275  *      If you use AppCore, you NEED NOT use this API.
276  *      This API is only available in User Session.
277 */
278 int aul_launch_argv_handler(int argc, char **argv);
279
280 /**
281  * @par Description:
282  *      This API creates internal RESET events with given bundle \n
283  * @par Purpose:
284  *  This API's purpose is to generate reset event.
285  *  If you want to generate local RESET events with argument vector format, first use
286  *  bundle_import_from_argv to create a bundle from the argument vector and then use this API
287  *  Eventually, this API will replace aul_launch_argv_handler().
288  * @par Typical use case:
289  *      In general, you need not use this API.
290  *      AppCore use this API to create internal reset event.
291  *
292  * @param[in]   b       bundle
293  * @return      0 if success, negative value(<0) if fail
294  * @retval      AUL_R_OK        - success
295  * @retval      AUL_R_ENOINIT   - aul handler was NOT yet installed
296  * @retval      AUL_R_ERROR     - general error
297  *
298  * @pre
299  *      you must have aul handler to use this API.
300  *      aul_luanch_init register aul handler.
301  * @post
302  *      None
303  * @see
304  *      aul_launch_init, bundle_import_from_argv
305  * @code
306  * #include <aul.h>
307  * #include <bundle.h>
308  *
309  * int send_local_reset_event()
310  * {
311  *  bundle* b;
312  *      int argc=3;
313  *      char* argv[4];
314  *      argv[0] = "local.app";
315  *      argv[1] = "event_type";
316  *      argv[2] = "my_reset";
317  *      argv[3] = NULL;
318  *
319  *      b = bundle_import_from_argv(argc,argv);
320  *      aul_launch_local(b);
321  * }
322  *
323  * @endcode
324  * @remark
325  *      If you use AppCore, you NEED NOT to use this API.
326  *      This API is only available in User Session.
327 */
328 int aul_launch_local(bundle *b);
329
330 /**
331  * @par Description:
332  *      This API launches application with the given bundle.
333  *  If the application is not running or a multiple-instance one, this API launches with the given bundle.
334  *      If the application is running, this API sends a RESET event to the App.
335  *      While the application is running, if the application cannot receive the RESET event,
336  *      this API returns a general error(AUL_R_ERROR).\n
337  * @par Purpose:
338  *      This API is for caller.
339  *      This API's purpose is to launch/reset application with given bundle.
340  * @par Typical use case:
341  *      If you know the target application's pkgname and bundle types,
342  *      you can use this API to launch/reset the application.
343  *
344  * @param[in]   pkgname         package name to be run as callee
345  * @param[in]   kb              bundle to be passed to callee
346  * @return      callee's pid if success, negative value(<0) if fail
347  * @retval      AUL_R_OK        - success
348  * @retval      AUL_R_EINVAL    - invaild package name
349  * @retval      AUL_R_ECOM      - internal AUL IPC error
350  * @retval      AUL_R_ERROR     - general error
351  *
352  * @see
353  *      aul_open_app
354  * @code
355  * #include <aul.h>
356  * #include <bundle.h>
357  *
358  * int launch_inhouse_contact_app()
359  * {
360  *      bundle *b;
361  *      b = bundle_create();
362  *      bundle_add(b,"type","SIM");
363  *      aul_launch_app("org.tizen.contact",b);
364  * }
365  *
366  * @endcode
367  * @remark
368  *      This API is only available in User Session.
369  */
370 int aul_launch_app(const char *appid, bundle *kb);
371
372 /**
373  * @par Description:
374  *      This API launches application with the given bundle.
375  *  If the application is not running or a multiple-instance one, this API launches with the given bundle.
376  *      If the application is running, this API sends a RESET event to the App.
377  *      While the application is running, if the application cannot receive the RESET event,
378  *      this API returns a general error(AUL_R_ERROR).\n
379  * @par Purpose:
380  *      This API is for caller.
381  *      This API's purpose is to launch/reset application with given bundle.
382  * @par Typical use case:
383  *      If you know the target application's pkgname and bundle types,
384  *      you can use this API to launch/reset the application.
385  *
386  * @param[in]   pkgname         package name to be run as callee
387  * @param[in]   kb              bundle to be passed to callee
388  * @param[in]   uid             User ID to launch
389  * @return      callee's pid if success, negative value(<0) if fail
390  * @retval      AUL_R_OK        - success
391  * @retval      AUL_R_EINVAL    - invaild package name
392  * @retval      AUL_R_ECOM      - internal AUL IPC error
393  * @retval      AUL_R_ERROR     - general error
394  *
395  * @see
396  *      aul_open_app
397  * @remark
398  *      This API is also available in System Session.
399  */
400 int aul_launch_app_for_uid(const char *appid, bundle *kb, uid_t uid);
401
402 /**
403  * @par Description:
404  *  This API launches application, as menu screen launches the app.
405  *  Thus, if the applocation is running, this API sends a RESUME event to the app.
406  *  If the application is not running, this API launches the app.
407  *  While the application is running, if the application cannot receive the RESUME event,
408  *  AUL tries to raise the application's default window.
409  *
410  * @par Purpose:
411  *      This API is for caller.
412  *      This API's purpose is to resume/launch application
413  * @par Typical use case:
414  *      If you only want to show application with previous state or default state, Use this API.
415  *
416  * @param[in]   pkgname         package name to be resume as callee
417  * @return      callee's pid if success, negative value(<0) if fail
418  * @retval      AUL_R_OK        - success
419  * @retval      AUL_R_EINVAL    - invaild package name
420  * @retval      AUL_R_ECOM      - internal AUL IPC error
421  * @retval      AUL_R_ERROR     - general error
422  *
423  * @see
424  *      aul_launch_app, aul_app_is_running, aul_resume_pid
425  * @code
426  * #include <aul.h>
427  * #include <bundle.h>
428  *
429  * int open_inhouse_contact_app()
430  * {
431  *      if(aul_app_is_running("org.tizen.contact"))
432  *              aul_open_app("org.tizen.contact");
433  * }
434  *
435  * @endcode
436  * @remark
437  *      If you don't want to launch the app,
438  *      you should check app's running state with aul_app_is_running.
439  *      This API will launch the application if the application is not running.
440  *      This API is only available in User Session.
441 */
442 int aul_open_app(const char *appid);
443
444 /**
445  * @par Description:
446  *      This API trigger to resume application
447  *      If the application is running, this API send a resume event to the App.
448  *      If the application is not running, this API returns fail.
449  *      Although the application is running, if the application cannot receive resume event,
450  *      AUL try to raise the application's default windows.
451  * @par Purpose:
452  *      This API is for caller.
453  *      This API's purpose is to send resume event.
454  * @par Typical use case:
455  *      If you only want to show application with previous state or default state, Use this API.
456  *
457  * @param[in]   pkgname         package name to be resume as callee
458  * @return      callee's pid if success, negative value(<0) if fail
459  * @retval      AUL_R_OK        - success
460  * @retval      AUL_R_EINVAL    - invaild package name
461  * @retval      AUL_R_ECOM      - internal AUL IPC error
462  * @retval      AUL_R_ERROR     - general error
463  *
464  * @see
465  *      aul_launch_app, aul_app_is_running, aul_resume_pid
466  * @deprecated
467  *  This function will be deprecated. Use aul_open_add() instead.
468  * @code
469  * #include <aul.h>
470  * #include <bundle.h>
471  *
472  * int resume_inhouse_contact_app()
473  * {
474  *      if(aul_app_is_running("org.tizen.contact"))
475  *              aul_resume_app("org.tizen.contact");
476  * }
477  *
478  * @endcode
479  * @remark
480  *      If you don't want to launch the app,
481  *      you should check app's running state with aul_app_is_running.
482  *      This API will launch the application if the application is not running.
483  *      If you want to only resume without launching in multiple instance application model,
484  *      you should use aul_resume_pid.
485  *      This API is only available in User Session.
486 */
487 int aul_resume_app(const char *appid);
488
489 /**
490  * @par Description:
491  *      This API trigger to resume application
492  *      If the application is running, this API send a resume event to the App.
493  *      If the application is not running, this API return AUL_R_ERROR.
494  *      Although the application is running, if the application cannot receive resume event,
495  *      AUL try to raise the application's default windows.
496  * @par Purpose:
497  *      This API is for caller.
498  *      This API's purpose is to send resume event.
499  * @par Typical use case:
500  *      In multiple application model, If you want to only resume specific application, Use this API
501  *
502  * @param[in]   pid     application's pid to be resumed
503  * @return      0 if success, negative value(<0) if fail
504  * @retval      AUL_R_OK        - success
505  * @retval      AUL_R_EINVAL    - invaild pid
506  * @retval      AUL_R_ECOM      - internal AUL IPC error
507  * @retval      AUL_R_ERROR     - general error (include application is not running)
508  * @warning     This API need to require root or inhouse permisssion \n
509  *              If you have not the permission, this API return AUL_R_ERROR. \n
510  * @see
511  *      aul_launch_app
512  * @code
513  * #include <aul.h>
514  * #include <bundle.h>
515  *
516  * int iterfunc(const aul_app_info *info, void *data)
517  * {
518  *      if(strcmp(info->pkg_name,"org.tizen.contact")==0)
519  *              aul_resume_pid(info->pid);
520  * }
521  *
522  * int iterate_running_apps()
523  * {
524  *      return aul_app_get_running_app_info(iterfunc,NULL);
525  * }
526  *
527  * @endcode
528  * @remark
529  *      This API is only available in User Session.
530 */
531 int aul_resume_pid(int pid);
532
533 /**
534  * @par Description:
535  *      This API trigger to terminate application
536  *
537  *      If the application is running, this API send a terminate event to the App. \n
538  *      If the app cannot receive the event, AUL kill forcely the application.\n
539  * @par Purpose:
540  *      This API's purpose is to kill application
541  * @par Typical use case:
542  *      In general, Application like Task Manager use this API.
543  *
544  *              This API need to require root or inhouse permisssion. \n
545  *
546  * @param[in]   pid     application's pid to be terminated
547  * @return      0 if success, negative value(<0) if fail
548  * @retval      AUL_R_OK        - success
549  * @retval      AUL_R_EINVAL    - invaild pid
550  * @retval      AUL_R_ECOM      - internal AUL IPC error
551  * @retval      AUL_R_ERROR     - general error
552  * @warning     This API need to require root or inhouse permisssion. \n
553  *
554  * @code
555  * #include <aul.h>
556  * #include <bundle.h>
557  *
558  * int iterfunc(const aul_app_info *info, void *data)
559  * {
560  *      if(strcmp(info->pkg_name,"org.tizen.contact")==0)
561  *              aul_terminate_pid(info->pid);
562  * }
563  *
564  * int iterate_running_apps()
565  * {
566  *      return aul_app_get_running_app_info(iterfunc,NULL);
567  * }
568  *
569  * @endcode
570  * @remark
571  *      If you have not the permission, this API return AUL_R_ERROR. \n
572  *      This API is only available in User Session.
573 */
574 int aul_terminate_pid(int pid);
575
576 /**
577  * @par Description:
578  *      This API trigger to terminate application asynchronously
579  *
580  *      If the application is running, this API send a terminate event to the App. \n
581  *      If the app cannot receive the event, AUL kill forcely the application.\n
582  * @par Purpose:
583  *      This API's purpose is to kill application
584  * @par Typical use case:
585  *      In general, Application like Task Manager use this API.
586  *
587  *              This API need to require root or inhouse permisssion. \n
588  *
589  * @param[in]   pid     application's pid to be terminated
590  * @return      0 if success, negative value(<0) if fail
591  * @retval      AUL_R_OK        - success
592  * @retval      AUL_R_EINVAL    - invaild pid
593  * @retval      AUL_R_ECOM      - internal AUL IPC error
594  * @retval      AUL_R_ERROR     - general error
595  * @warning     This API need to require root or inhouse permisssion. \n
596  * @remark
597  *      If you have not the permission, this API return AUL_R_ERROR. \n
598  *      This API is only available in User Session.
599 */
600 int aul_terminate_pid_async(int pid);
601
602 /**
603  *@brief Running application's information structure retrieved by AUL
604  */
605 typedef struct _aul_app_info {
606         int pid;                /**< app's pid if running*/
607         char* pkg_name;         /**< application id */
608         char* app_path;         /**< application excutable path */
609         char* appid;
610 } aul_app_info;
611
612 /**
613  * @brief iterator function running with aul_app_get_running_app_info
614  * @param[out]  ainfo   aul_app_info retreived by aul_app_get_running_app_info
615  * @param[out]  data    user-supplied data
616 */
617 typedef int (*aul_app_info_iter_fn)(const aul_app_info *ainfo, void *data);
618
619 /**
620  * @par Description:
621  *      This API ask a application is running by application package name.
622  * @par Purpose:
623  *      To know whether some application is running or not, use this API
624  * @par Typical use case:
625  *      For example, If you want to know browser application running,
626  *      you can check it by using this API.
627  *
628  * @param[in]   pkgname application package name
629  * @return      true / false
630  * @retval      1       app_name is running now.
631  * @retval      0       app_name is NOT running now.
632  *
633  * @code
634  * #include <aul.h>
635  *
636  * int is_running_browser_app()
637  * {
638  *      return aul_app_is_running("org.tizen.browser");
639  * }
640  *
641  * @endcode
642  * @remark
643  *      This API is only available in User Session.
644 *
645 */
646 int aul_app_is_running(const char *appid);
647
648 /**
649  * @par Description:
650  *      This API use to get running application list.
651  *      This API call iter_fn with each aul_app_info of running apps when running application is found.
652  * @par Purpose:
653  *      If you want to get running application list, use this API
654  *      This API give you running applications which has SLP desktop file.
655  * @par Typical use case:
656  *      In general, this API is used by task manager appllication. (running application list viewer)
657  *
658  * @param[in]   iter_fn         iterator function
659  * @param[in]   data            user-supplied data for iter_fn
660  * @return      0 if success, negative value(<0) if fail
661  * @retval      AUL_R_OK        - success
662  * @retval      AUL_R_ERROR     - internal error
663  *
664  * @code
665  * #include <aul.h>
666  *
667  * int iterfunc(const aul_app_info* info, void* data)
668  * {
669  *      printf("\t==========================\n");
670  *      printf("\t pkg_name: %s\n", info->appid);
671  *      printf("\t app_path: %s\n", info->app_path);
672  *      printf("\t running pid: %d\n", info->pid);
673  *      printf("\t==========================\n");
674  *      return 0;
675  * }
676  *
677  * int iterate_running_apps()
678  * {
679  *      return aul_app_get_running_app_info(iterfunc,NULL);
680  * }
681  *
682  * @endcode
683  * @remark
684  *      This API should use if you want to know running application which has desktop files.
685  *      If you want to get all process list, you must iterate process information by using proc filesystem
686  *      Or, If you want to get all window list, you must iterate XWindows by using XWindow APIs
687  *      This API is only available in User Session.
688  */
689 int aul_app_get_running_app_info(aul_app_info_iter_fn iter_fn, void *data);
690
691 /**
692  * @par Description:
693  *      This API get application package name by pid
694  * @par Purpose:
695  *      If you want to get package name of running application, use this API
696  * @par Typical use case:
697  *      In general, You can use this API when you want to know caller's information.
698  *
699  * @param[in]   pid             given pid
700  * @param[out]  pkgname         pkgname to be get
701  * @param[in]   len             length of pkgname
702  * @return      0 if success, negative value(<0) if fail
703  * @retval      AUL_R_OK        - success
704  * @retval      AUL_R_ERROR     - no such a package name
705  * @code
706  * #include <aul.h>
707  * #include <bundle.h>
708  *
709  * static int app_reset(bundle *b, void *data)
710  * {
711  *      int pid;
712  *      char appname[255];
713  *
714  *      pid = atoi(bundle_get_val(b,AUL_K_CALLER_PID));
715  *      aul_app_get_pkgname_bypid(pid, appname, sizeof(appname));
716  * }
717  *
718  * @endcode
719  * @remark
720  *      This API is only available in User Session.
721 */
722 int aul_app_get_pkgname_bypid(int pid, char *pkgname, int len);
723
724 /**
725  * @par Description:
726  *      This API get application pkgid by pid
727  * @par Purpose:
728  *      If you want to get pkgid of running application, use this API
729  * @par Typical use case:
730  *      In general, You can use this API when you want to know caller's information.
731  *
732  * @param[in]   pid             given pid
733  * @param[out]  pkgid           package id
734  * @param[in]   len             length of pkgid
735  * @return      0 if success, negative value(<0) if fail
736  * @retval      AUL_R_OK        - success
737  * @retval      AUL_R_ERROR     - no such a appid
738  *
739  * @code
740  * #include <aul.h>
741  * #include <bundle.h>
742  *
743  * static int app_reset(bundle *b, void *data)
744  * {
745  *      int pid;
746  *      char pkgid[255];
747  *
748  *      pid = atoi(bundle_get_val(b, AUL_K_CALLER_PID));
749  *      aul_app_get_pkgid_bypid(pid, pkgid, sizeof(pkgid));
750  * }
751  *
752  * @endcode
753  * @remark
754  *      This API is only available in User Session.
755 */
756 int aul_app_get_pkgid_bypid(int pid, char *pkgid, int len);
757
758 /**
759  * @par Description:
760  *      This API get application pkgid by pid
761  * @par Purpose:
762  *      If you want to get pkgid of running application, use this API
763  * @par Typical use case:
764  *      In general, You can use this API when you want to know caller's information.
765  *
766  * @param[in]   pid             given pid
767  * @param[out]  pkgid           package id
768  * @param[in]   len             length of pkgid
769  * @param[in]   uid             User ID
770  * @return      0 if success, negative value(<0) if fail
771  * @retval      AUL_R_OK        - success
772  * @retval      AUL_R_ERROR     - no such a appid
773  *
774  * @remark
775  *      This API is also available in System Session.
776 */
777 int aul_app_get_pkgid_bypid_for_uid(int pid, char *pkgid, int len, uid_t uid);
778
779 /**
780  * @par Description:
781  *      This API get application appid by pid
782  * @par Purpose:
783  *      If you want to get appid of running application, use this API
784  * @par Typical use case:
785  *      In general, You can use this API when you want to know caller's information.
786  *
787  * @param[in]   pid             given pid
788  * @param[out]  appid           application id
789  * @param[in]   len             length of pkgname
790  * @return      0 if success, negative value(<0) if fail
791  * @retval      AUL_R_OK        - success
792  * @retval      AUL_R_ERROR     - no such a appid
793  * @code
794  * #include <aul.h>
795  * #include <bundle.h>
796  *
797  * static int app_reset(bundle *b, void *data)
798  * {
799  *      int pid;
800  *      char appid[255];
801  *
802  *      pid = atoi(bundle_get_val(b,AUL_K_CALLER_PID));
803  *      aul_app_get_appid_bypid(pid, appid, sizeof(appid));
804  * }
805  *
806  * @endcode
807  * @remark
808  *      This API is only available in User Session.
809 */
810 int aul_app_get_appid_bypid(int pid, char *appid, int len);
811
812 /**
813  * @par Description:
814  *      This API get application appid by pid
815  * @par Purpose:
816  *      If you want to get appid of running application, use this API
817  * @par Typical use case:
818  *      In general, You can use this API when you want to know caller's information.
819  *
820  * @param[in]   pid             given pid
821  * @param[out]  appid           application id
822  * @param[in]   len             length of pkgname
823  * @param[in]   uid             User ID
824  * @return      0 if success, negative value(<0) if fail
825  * @retval      AUL_R_OK        - success
826  * @retval      AUL_R_ERROR     - no such a appid
827  * @remark
828  *      This API is also available in System Session.
829 */
830 int aul_app_get_appid_bypid_for_uid(int pid, char *appid, int len, uid_t uid);
831
832 /**
833  * @par Description:
834  *      This API launch application associated with given filename
835  * @par Purpose:
836  *      This API is for caller.
837  *      This API launch application based on mime type.
838  *      This API find mime_type associated with file name,
839  *      and then find default app associated with found mime_type
840  *      and then launch the app with filename argument.
841  * @par Typical use case:
842  *      You can launch application to process given filename.
843  *      That is, Even if you don't know the specific application's pkgname,
844  *      you can launch the applicaiton processing given filename .
845  *      For example, If you want to process image file, you can simply launch image viewer.
846  *      At that time, you can use this APIs like aul_open_file("myimage.jpg");
847  *
848  * @param[in]   filename        filename
849  * @return      callee's pid or 0 if success, negative value if fail\n
850  *              (when no found default app, return 0)
851  * @retval      AUL_R_OK        - success
852  * @retval      AUL_R_EINVAL    - invalid argument(filename)
853  * @retval      AUL_R_ECOM      - internal AUL IPC error
854  * @retval      AUL_R_ERROR     - general error
855  *
856  * @code
857  * #include <aul.h>
858  *
859  * int view_image_file(char *filename)
860  * {
861  *      aul_open_file(filename);
862  * }
863  *
864  * @endcode
865  * @remark
866  *      This API is only available in User Session.
867  *
868  */
869 int aul_open_file(const char* filename);
870
871 /**
872  * @par Description:
873  *      This API launch application associated with given specific mimetype
874  * @par Purpose:
875  *      This API is for caller.
876  *      This API launch application based on mime type like aul_open_file API.
877  *      But, This API don't find mime_type associated with file name.
878  *      This API use mimetype given by user. By using given mimetype, find default application.
879  *      and then launch the app with filename argument.
880  * @par Typical use case:
881  *      Some files cannot extract exact mimetype automatically.
882  *      For example, To know mime type of files with DRM lock, first we should unlock DRM file.
883  *      In this case, You can use this API.
884  *      First, unlock DRM file, and extract mimetype from unlock file by using aul_get_mime_from_file,
885  *      and then, use this API with DRM file and extracted mime type.
886  *
887  * @param[in]   filename        filename
888  * @param[in]   mimetype        specific mimetype
889  * @return      callee's pid or 0 if success, negative value if fail\n
890  *              (when no found default app, return 0)
891  * @retval      AUL_R_OK        - success
892  * @retval      AUL_R_EINVAL    - invalid argument(filename,mimetype)
893  * @retval      AUL_R_ECOM      - internal AUL IPC error
894  * @retval      AUL_R_ERROR     - general error
895  *
896  * @see
897  *      aul_open_file, aul_get_mime_from_file
898  * @code
899  * #include <aul.h>
900  *
901  * int view_drm_image_file(char *drm_filename)
902  * {
903  *      char* mimetype;
904  *      // you must implement this function
905  *      mimetype = get_mimetype_from_drmfile(drm_filename);
906  *
907  *      aul_open_file_with_mimetype(drm_filename,mimetype);
908  * }
909  *
910  * @endcode
911  * @remark
912  *      This API is only available in User Session.
913  */
914 int aul_open_file_with_mimetype(const char *filename, const char *mimetype);
915
916 /**
917  * @par Description:
918  *      This API launch application associated with content like "http://www.samsung.com"
919  * @par Purpose:
920  *      This API is for caller.
921  *      This API launch application based on mime type.
922  *      This API find mime_type associated with content,
923  *      and then find default app associated with found mime_type,
924  *      and then launch the app with content argument.
925  * @par Typical use case:
926  *      You can launch application to process given content.
927  *      That is, Even if you don't know the specific application's pkgname,
928  *      you can launch the applicaiton processing given content.
929  *      For example, If you want to process URL "http://www.samsung.com",
930  *      you can simply launch browser.
931  *      At that time, you can use this APIs like aul_open_content("http://www.samsung.com");
932  *
933  * @param[in]   content         content
934  * @return      callee's pid or 0 if success, negative value if fail\n
935  *              (when no found default app, return 0)
936  * @retval      AUL_R_OK        - success
937  * @retval      AUL_R_EINVAL    - invalid argument(content)
938  * @retval      AUL_R_ECOM      - internal AUL IPC error
939  * @retval      AUL_R_ERROR     - general error or no found mimetype
940  *
941  * @code
942  * #include <aul.h>
943  *
944  * int view_url(char *url)
945  * {
946  *      aul_open_content(url);
947  * }
948  *
949  * @endcode
950  * @remark
951  *      This API is only available in User Session.
952  *
953  */
954 int aul_open_content(const char* content);
955
956 /**
957  * @par Description:
958  *       This API get the default application(appid) associated with MIME type
959  * @par Purpose:
960  *      This API use to get default application associteted with mimetype
961  *      In general, Setting Application need this API.
962  * @par Typical use case:
963  *      Setting Application show mapping of default application / mimetype
964  *
965  * @param[in]   mimetype        a mime type
966  * @param[out]  defapp          a application appid of the app
967  * @param[in]   len             length of defapp
968  * @return      0 if success, negative value if fail
969  * @retval      AUL_R_OK        - success
970  * @retval      AUL_R_EINVAL    - invalid argument(mimetype)
971  * @retval      AUL_R_ERROR     - general error or no found mimetype
972  *
973  * @see
974  *      aul_set_defapp_with_mime
975  * @code
976  * #include <aul.h>
977  *
978  * void get_text_html_defapp()
979  * {
980  *      char appname[255];
981  *      aul_get_defapp_from_mime("text/html",appname,sizeof(appname));
982  * }
983  *
984  * @endcode
985  * @remark
986  *      This API is only available in User Session.
987  *
988  */
989 int aul_get_defapp_from_mime(const char *mimetype, char *defapp, int len);
990
991 /**
992  * @par Description:
993  *       This API set the default application(appid) associated with MIME type
994  * @par Purpose:
995  *      This API use to change default application associteted with mimetype
996  *      In general, Setting Application or Installer need this API.
997  * @par Typical use case:
998  *      Default Application associated with mimetype can be changed by Setting Application or installer
999  *      So, application to process specific mimetype can be substituted.
1000  *
1001  * @param[in]   mimetype        a mime type
1002  * @param[in]   defapp          a application appid of the app to be set
1003  * @return      0 if success, negative value if fail
1004  * @retval      AUL_R_OK        - success
1005  * @retval      AUL_R_EINVAL    - invalid argument(mimetype)
1006  * @retval      AUL_R_ERROR     - general error
1007  *
1008  * @see
1009  *      aul_get_defapp_from_mime
1010  * @code
1011  * #include <aul.h>
1012  *
1013  * void set_text_html_defapp()
1014  * {
1015  *      aul_set_defapp_with_mime("text/html","org.tizen.browser");
1016  * }
1017  *
1018  * @endcode
1019  * @remark
1020  *      This API is only available in User Session.
1021 */
1022 int aul_set_defapp_with_mime(const char *mimetype, const char *defapp);
1023
1024 /**
1025  * @par Description:
1026  *      This API get the mimetype associated with filename
1027  * @par Purpose:
1028  *      This API use to get mimetype associteted with given filename
1029  *      In general, This API use when you want to know only mimetype given filename.
1030  * @par Typical use case:
1031  *      For example, In trasfering data through bluetooth,
1032  *      additional information like mimetype should be added.
1033  *      In such situation, You can get mimetype by using this API.
1034  *
1035  * @param[in]   filename        file name
1036  * @param[out]  mimetype        a mime type
1037  * @param[in]   len             length of mimetype
1038  * @return      0 if success, negative value if fail
1039  * @retval      AUL_R_OK        - success
1040  * @retval      AUL_R_EINVAL    - invalid argument(filename)
1041  * @retval      AUL_R_ERROR     - general error
1042  *
1043  * @code
1044  * #include <aul.h>
1045  *
1046  * void get_mimetype()
1047  * {
1048  *      char mimetype[255];
1049  *      aul_get_mime_from_file("image.jpg",mimetype,sizeof(mimetype));
1050  * }
1051  *
1052  * @endcode
1053  * @remark
1054  *      This API is only available in User Session.
1055  */
1056 int aul_get_mime_from_file(const char *filename, char *mimetype, int len);
1057
1058 /**
1059  * @par Description:
1060  *      This API get the mimetype associated with given content
1061  * @par Purpose:
1062  *      This API use to get mimetype associteted with given content
1063  *      In general, This API use when you want to know only mimetype given content
1064  * @par Typical use case:
1065  *      For example, In trasfering data through bluetooth,
1066  *      additional information like mimetype should be added.
1067  *      In such situation, You can get mimetype by using this API.
1068  *
1069  * @param[in]   content         content string like "011-0000-0000"
1070  * @param[out]  mimetype        a mime type
1071  * @param[in]   len             length of mimetype
1072  * @return      0 if success, negative value if fail
1073  * @retval      AUL_R_OK        - success
1074  * @retval      AUL_R_EINVAL    - invalid argument(content)
1075  * @retval      AUL_R_ERROR     - general error
1076  *
1077  * @code
1078  * #include <aul.h>
1079  *
1080  * void get_mimetype()
1081  * {
1082  *      char mimetype[255];
1083  *      aul_get_mime_from_content("http://www.samsung.com",mimetype,sizeof(mimetype));
1084  * }
1085  *
1086  * @endcode
1087  * @remark
1088  *      This API is only available in User Session.
1089 */
1090 int aul_get_mime_from_content(const char *content, char *mimetype, int len);
1091
1092 /**
1093  * @par Description:
1094  *      This API get the icon's name associated with given mimetype
1095  * @par Purpose:
1096  *      This API use to get icon's name associteted with given mimetype
1097  * @par Typical use case:
1098  *      If you want to show mimetype's icon, use this API.
1099  *
1100  * @param[in]   mimetype        a mime type
1101  * @param[out]  iconname        icon's name
1102  * @param[in]   len             length of iconname
1103  * @return      0 if success, negative value if fail
1104  * @retval      AUL_R_OK        - success
1105  * @retval      AUL_R_EINVAL    - invalid argument(content)
1106  * @retval      AUL_R_ERROR     - general error (no such mime type)
1107  *
1108  * @code
1109  * #include <aul.h>
1110  *
1111  * void get_mime_icon()
1112  * {
1113  *      char icon[255];
1114  *      aul_get_mime_icon("text/html",icon,sizeof(icon));
1115  * }
1116  *
1117  * @endcode
1118  * @remark
1119  *      This API is only available in User Session.
1120  */
1121 int aul_get_mime_icon(const char *mimetype, char *iconname, int len);
1122
1123 /**
1124  * @par Description:
1125  *      This API get the extensions associated with given mimetype
1126  * @par Purpose:
1127  *      This API use to get extensions associteted with given mimetype
1128  * @par Typical use case:
1129  *      In general, user is not familiar with mimetype(text/html),
1130  *      user is familiar with extenstions(*.html, *.htm)
1131  *      So, To show mimetype information to user, use this API
1132  *
1133  * @param[in]   mimetype        a mime type
1134  * @param[out]  extlist         extentions (ex> mpeg,mpg,mpe)
1135  * @param[in]   len             length of extlist
1136  * @return      0 if success, negative value if fail
1137  * @retval      AUL_R_OK        - success
1138  * @retval      AUL_R_EINVAL    - invalid argument(mimetype)
1139  * @retval      AUL_R_ERROR     - general error (no mimetype or no extenstion)
1140  *
1141  * @see
1142  *      aul_get_mime_description
1143  * @code
1144  * #include <aul.h>
1145  *
1146  * void get_extension()
1147  * {
1148  *      char extlist[255];
1149  *      aul_get_mime_extension("text/html",extlist,sizeof(extlist));
1150  * }
1151  *
1152  * @endcode
1153  * @remark
1154  *      Some mimetype don't have extension.
1155  *      In that case, You can use aul_get_mime_description.
1156  *      This API is only available in User Session.
1157 */
1158 int aul_get_mime_extension(const char *mimetype, char *extlist, int len);
1159
1160 /**
1161  * @par Description:
1162  *      This API get the description associated with given mimetype
1163  * @par Purpose:
1164  *      This API use to get description associteted with given mimetype
1165  * @par Typical use case:
1166  *      In general, user is not familiar with mimetype(text/html),
1167  *      user is familiar with well-knowing information like extenstions(*.html, *.htm)
1168  *      But, some mimetype don't have extenstion.
1169  *      At that time,to show mimetype information to user, use this API
1170  *
1171  * @param[in]   mimetype        a mime type
1172  * @param[out]  desc            description (ex> Call client)
1173  * @param[in]   len             length of desc
1174  * @return      0 if success, negative value if fail
1175  * @retval      AUL_R_OK        - success
1176  * @retval      AUL_R_EINVAL    - invalid argument(mimetype)
1177  * @retval      AUL_R_ERROR     - general error (no mimetype or no descrition)
1178  *
1179  * @see
1180  *      aul_get_mime_extension
1181  * @code
1182  * #include <aul.h>
1183  *
1184  * void get_information_from_mime()
1185  * {
1186  *      char info[255];
1187  *      if(aul_get_mime_extension("text/html",info,sizeof(info))<0){
1188  *              aul_get_mime_description("text/html",info,sizeof(info));
1189  *      }
1190  * }
1191  *
1192  * @endcode
1193  * @remark
1194  *      This API is only available in User Session.
1195  */
1196 int aul_get_mime_description(const char *mimetype, char *desc, int len);
1197
1198 /**
1199  * @par Description:
1200  *      This API create service result bundle based on bundle received in reset event.
1201  * @par Purpose:
1202  *      This API use to create result bundle to send it to caller.
1203  * @par Typical use case:
1204  *      This API is for callee which provide application service.\n
1205  *      To send result to caller, You must create result bundle. \n
1206  *      Callee(application providing the service) can send result by using this API and aul_send_service_result.
1207  *
1208  * @param[in]   inb             bundle received in reset event
1209  * @param[out]  outb            bundle to use for returning result
1210  * @return      0 if success, negative value(<0) if fail
1211  * @retval      AUL_R_OK        - success
1212  * @retval      AUL_R_EINVAL    - inb is not bundle created by aul_open_service
1213  * @retval      AUL_R_ERROR     - general error
1214  *
1215  * @pre
1216  *      To create result bundle, You need received original bundle.
1217  *      The original bundle can get from app_reset handler.
1218  * @post
1219  *      None
1220  * @see
1221  *      aul_send_service_result
1222  * @code
1223  * #include <aul.h>
1224  * #include <bundle.h>
1225  *
1226  * int app_reset(bundle *b, void *data)
1227  * {
1228  *      ad->recved_bundle = bundle_dup(b);
1229  * }
1230  *
1231  * int click_ok()
1232  * {
1233  *      bundle* res_bundle;
1234  *      aul_create_result_bundle(ad->recved_bundle,&res_bundle);
1235  *      bundle_add(res_bundle, "result", "1");
1236  *      aul_send_service_result(res_bundle);
1237  * }
1238  * @endcode
1239  * @remark
1240  *      This API is only available in User Session.
1241  *
1242  */
1243 int aul_create_result_bundle(bundle *inb, bundle **outb);
1244
1245 /**
1246  * @par Description:
1247  *      This API send service result to caller with bundle
1248  * @par Purpose:
1249  *      This API is used to send result bundle to caller.
1250  * @par Typical use case:
1251  *      This API is for callee which provide application service.\n
1252  *      To send result to caller, You can use this API after creating result bundle. \n
1253  *      Callee(application to provide service) can send result by using this API and aul_create_result_bundle.
1254  *
1255  * @param[in]   b      Result data in bundle format
1256  * @return      0 if success, negative value(<0) if fail
1257  * @retval      AUL_R_OK        - success
1258  * @retval      AUL_R_EINVAL    - invalid result bundle
1259  * @retval      AUL_R_ECOMM     - internal AUL IPC error
1260  * @retval      AUL_R_ERROR     - general error
1261  *
1262  * @pre
1263  *      To send result bundle, You must create result bundle.
1264  *      see aul_create_result_bundle
1265  * @post
1266  *      None
1267  * @see
1268  *      aul_create_result_bundle
1269  * @code
1270  * #include <aul.h>
1271  * #include <bundle.h>
1272  *
1273  * int app_reset(bundle *b, void *data)
1274  * {
1275  *      ad->recved_bundle = bundle_dup(b);
1276  * }
1277  *
1278  * int click_ok()
1279  * {
1280  *      bundle* res_bundle;
1281  *      aul_create_result_bundle(ad->recved_bundle,&res_bundle);
1282  *      bundle_add(res_bundle, "result", "1");
1283  *      aul_send_service_result(res_bundle);
1284  * }
1285  * @endcode
1286  * @remark
1287  *      This API is only available in User Session.
1288  *
1289  */
1290 int aul_send_service_result(bundle *b);
1291
1292 /**
1293  * @par Description:
1294  *      This API sets callback fuction that will be called when applications die.
1295  * @par Purpose:
1296  *      This API's purpose is to listen the application dead event.
1297  *      In general, task manager Application need this API.
1298  *
1299  * @param[in]   func            callback function
1300  * @param[in]   data            user data
1301  * @return      0 if success, negative value if fail
1302  * @retval      AUL_R_OK        - success
1303  * @retval      AUL_R_ERROR     - general error
1304  *
1305  * @see
1306  *      aul_listen_app_launch_signal
1307  * @code
1308  * #include <aul.h>
1309  *
1310  * int app_dead_handler(int pid, void *data)
1311  * {
1312  *      printf("===> %s : %d\n", __FUNCTION__, pid);
1313  *      return 0;
1314  * }
1315  *
1316  * void dead_listen()
1317  * {
1318  *      aul_listen_app_dead_signal(app_dead_handler, NULL);
1319  * }
1320  *
1321  * @endcode
1322  * @remark
1323  *      This API is only available in User Session.
1324  *
1325  */
1326 int aul_listen_app_dead_signal(int (*func) (int, void *), void *data);
1327
1328 /**
1329  * @par Description:
1330  *      This API sets callback fuction that will be called when applications are launched.
1331  * @par Purpose:
1332  *      This API's purpose is to listen the application launching event.
1333  *      In general, task manager Application need this API.
1334  *
1335  * @param[in]   func            callback function
1336  * @param[in]   data            user data
1337  * @return      0 if success, negative value if fail
1338  * @retval      AUL_R_OK        - success
1339  * @retval      AUL_R_ERROR     - general error
1340  *
1341  * @see
1342  *      aul_listen_app_dead_signal
1343  * @code
1344  * #include <aul.h>
1345  *
1346  * int app_launch_handler(int pid, void *data)
1347  * {
1348  *      printf("===> %s : %d\n", __FUNCTION__, pid);
1349  *      return 0;
1350  * }
1351  *
1352  * void dead_listen()
1353  * {
1354  *      aul_listen_app_launch_signal(app_launch_handler, NULL);
1355  * }
1356  *
1357  * @endcode
1358  * @remark
1359  *      This API is only available in User Session.
1360  *
1361  */
1362 int aul_listen_app_launch_signal(int (*func) (int, void *), void *data);
1363
1364 /**
1365  * @par Description:
1366  *      This API gets status of specified application process id.
1367  * @par Purpose:
1368  *      This API's purpose is to get the application's status.
1369  *
1370  * @param[in]   pid     pid of application
1371  * @return      0 or greater if success, nagative value if fail
1372  * @retval      STATUS_LAUNCHING
1373  * @retval      STATUS_CREATED
1374  * @retval      STATUS_FOCUS
1375  * @retval      STATUS_VISIBLE
1376  * @retval      STATUS_BG
1377  * @retval      STATUS_DYING
1378  * @retval      STATUS_HOME
1379  * @retval      STATUS_NORESTART
1380  * @see
1381  *      aul_status_update
1382  * @code
1383  * #include <aul.h>
1384  *
1385  * int iterfunc(const aul_app_info *info, void *data)
1386  * {
1387  *      int status;
1388  *      status = aul_app_get_status_bypid(info->pid);
1389  *      if (status == STATUS_FOCUS) {
1390  *              printf("%s has focus", info->app_id);
1391  *              (int *)data = info->pid;
1392  *              return -1;
1393  *      }
1394  *      return 0;
1395  * }
1396  *
1397  * int find_focus_app_pid()
1398  * {
1399  *      int pid = 0;
1400  *      aul_app_get_running_app_info(iterfunc, &pid);
1401  *      return pid;
1402  * }
1403  * @endcode
1404  * @remark
1405  *      This API is only available in User Session.
1406  */
1407 int aul_app_get_status_bypid(int pid);
1408
1409 /**
1410  * @par Description
1411  *      This API sets callback function that on application status changed.
1412  * @par Purpose:
1413  *      This API's purpose is to listen the application's status changed within
1414  *      the caller process. In general, a library that required to release resource on
1415  *      application's status may use this API.
1416  *
1417  * @param[in]   func    callback function
1418  * @param[in]   data    user data
1419  * @return      0 if success, negative value if fail
1420  * @retval      AUL_R_OK        - success
1421  * @retval      AUL_R_ERROR     - general error
1422  * @see
1423  *      aul_remove_status_local_cb
1424  * @code
1425  * #include <aul.h>
1426  *
1427  * int status_changed(int status, void *data)
1428  * {
1429  *      if (status == STATUS_FOCUS)
1430  *              printf("%d has focus\n", getpid());
1431  *
1432  *      if (status == STATUS_VISIBLE)
1433  *              printf("%d resume\n", getpid());
1434  *
1435  *      if (status == STATUS_BG0
1436  *              printf("%d pause\n", getpid());
1437  * }
1438  *
1439  * void listen_app_status()
1440  * {
1441  *      aul_add_status_local_cb(status_changed, NULL);
1442  * }
1443  * @endcode
1444  * @remark
1445  *      This API is only available in User Session.
1446  *
1447  */
1448 int aul_add_status_local_cb(int (*func) (int, void *), void *data);
1449
1450 /**
1451  * @par Description
1452  *      This API unsets callback function that on application status changed.
1453  * @par Purpose:
1454  *      This API's purpose is to remove callback that added by
1455  *      aul_add_status_local_cb.
1456  *
1457  * @param[in]   func    callback function
1458  * @param[in]   data    user data
1459  * @return      0 if success, negative value if fail
1460  * @retval      AUL_R_OK        - success
1461  * @retval      AUL_R_ERROR     - general error
1462  *
1463  * @see
1464  *      aul_add_status_local_cb
1465  * @code
1466  * #include <aul.h>
1467  *
1468  * int status_changed(int status, void *data)
1469  * {
1470  *      if (status == STATUS_FOCUS)
1471  *              printf("%d has focus\n", getpid());
1472  *
1473  *      if (status == STATUS_VISIBLE)
1474  *              printf("%d resume\n", getpid());
1475  *
1476  *      if (status == STATUS_BG0
1477  *              printf("%d pause\n", getpid());
1478  * }
1479  *
1480  * void listen_app_status()
1481  * {
1482  *      aul_add_status_local_cb(status_changed, NULL);
1483  * }
1484  *
1485  * void ignore_app_status()
1486  * {
1487  *      aul_remove_status_local_cb(status_changed, NULL);
1488  * }
1489  *
1490  * @endcode
1491  * @remark
1492  *      This API is only available in User Session.
1493  *
1494  */
1495 int aul_remove_status_local_cb(int (*func) (int, void *), void *data);
1496
1497 /*
1498  * This API is only for Appfw internally.
1499  */
1500 int aul_terminate_bgapp_pid(int pid);
1501
1502 /*
1503  * This API is only for Appfw internally.
1504  */
1505 int aul_terminate_pid_without_restart(int pid);
1506
1507 /*
1508  * This API is only for Appfw internally.
1509  */
1510 const char *aul_get_app_external_root_path(void);
1511
1512 /*
1513  * This API is only for Appfw internally.
1514  */
1515 const char *aul_get_app_root_path(void);
1516
1517 /*
1518  * This API is only for Appfw internally.
1519  */
1520 const char *aul_get_app_data_path(void);
1521
1522 /*
1523  * This API is only for Appfw internally.
1524  */
1525 const char *aul_get_app_cache_path(void);
1526
1527 /*
1528  * This API is only for Appfw internally.
1529  */
1530 const char *aul_get_app_resource_path(void);
1531
1532 /*
1533  * This API is only for Appfw internally.
1534  */
1535 const char *aul_get_app_tep_resource_path(void);
1536
1537 /*
1538  * This API is only for Appfw internally.
1539  */
1540 const char *aul_get_app_shared_data_path(void);
1541
1542 /*
1543  * This API is only for Appfw internally.
1544  */
1545 const char *aul_get_app_shared_resource_path(void);
1546
1547 /*
1548  * This API is only for Appfw internally.
1549  */
1550 const char *aul_get_app_shared_trusted_path(void);
1551
1552 /*
1553  * This API is only for Appfw internally.
1554  */
1555 const char *aul_get_app_external_data_path(void);
1556
1557 /*
1558  * This API is only for Appfw internally.
1559  */
1560 const char *aul_get_app_external_cache_path(void);
1561
1562 /*
1563  * This API is only for Appfw internally.
1564  */
1565 const char *aul_get_app_external_shared_data_path(void);
1566
1567 /*
1568  * This API is only for Appfw internally.
1569  */
1570 const char *aul_get_app_specific_path(void);
1571
1572 /*
1573  * This API is only for Appfw internally.
1574  */
1575 const char *aul_get_app_external_specific_path(void);
1576
1577 /*
1578  * This API is only for Appfw internally.
1579  */
1580 int aul_get_app_shared_data_path_by_appid(const char *app_id, char **path);
1581
1582 /*
1583  * This API is only for Appfw internally.
1584  */
1585 int aul_get_app_shared_resource_path_by_appid(const char *app_id, char **path);
1586
1587 /*
1588  * This API is only for Appfw internally.
1589  */
1590 int aul_get_app_shared_trusted_path_by_appid(const char *app_id, char **path);
1591
1592 /*
1593  * This API is only for Appfw internally.
1594  */
1595 int aul_get_app_external_shared_data_path_by_appid(const char *app_id, char **path);
1596
1597 /*
1598  * This API is only for Appfw internally.
1599  */
1600 int aul_get_usr_app_shared_data_path_by_appid(const char *app_id, char **path, uid_t uid);
1601
1602 /*
1603  * This API is only for Appfw internally.
1604  */
1605 int aul_get_usr_app_shared_resource_path_by_appid(const char *app_id, char **path, uid_t uid);
1606
1607 /*
1608  * This API is only for Appfw internally.
1609  */
1610 int aul_get_usr_app_shared_trusted_path_by_appid(const char *app_id, char **path, uid_t uid);
1611
1612 /*
1613  * This API is only for Appfw internally.
1614  */
1615 int aul_get_usr_app_external_shared_data_path_by_appid(const char *app_id, char **path, uid_t uid);
1616
1617 /*
1618  * This type is only for Appfw internally.
1619  */
1620 typedef int (*subapp_fn)(void *data);
1621
1622 /*
1623  * This API is only for Appfw internally.
1624  */
1625 int aul_set_subapp(subapp_fn cb, void *data);
1626
1627 /*
1628  * This API is only for Appfw internally.
1629  */
1630 int aul_subapp_terminate_request_pid(int pid);
1631
1632 /*
1633  * This API is only for Appfw internally.
1634  */
1635 int aul_is_subapp(void);
1636
1637 /*
1638  * This API is only for Appfw internally.
1639  */
1640 int aul_kill_pid(int pid);
1641
1642 /*
1643  * This API is only for Appfw internally.
1644  */
1645 int aul_add_caller_cb(int pid,  void (*caller_cb) (int, void *), void *data);
1646
1647 /*
1648  * This API is only for Appfw internally.
1649  */
1650 int aul_remove_caller_cb(int pid);
1651
1652 /*
1653  * This API is only for Appfw internally.
1654  */
1655 int aul_invoke_caller_cb(int pid);
1656
1657 /*
1658  * This API is only for Appfw internally.
1659  */
1660 void aul_set_preinit_window(void *evas_object);
1661
1662 /*
1663  * This API is only for Appfw internally.
1664  */
1665 void* aul_get_preinit_window(const char *win_name);
1666
1667 /*
1668  * This API is only for Appfw internally.
1669  */
1670 void aul_set_preinit_background(void *evas_object);
1671
1672 /*
1673  * This API is only for Appfw internally.
1674  */
1675 void* aul_get_preinit_background(void);
1676
1677 /*
1678  * This API is only for Appfw internally.
1679  */
1680 void aul_set_preinit_conformant(void *evas_object);
1681
1682 /*
1683  * This API is only for Appfw internally.
1684  */
1685 void* aul_get_preinit_conformant(void);
1686
1687 /*
1688  * This API is only for Appfw internally.
1689  */
1690 void aul_set_preinit_appid(const char *appid);
1691
1692 /*
1693  * This API is only for Appfw internally.
1694  */
1695 void aul_set_preinit_pkgid(const char *pkgid);
1696
1697 /*
1698  * This API is only for Appfw internally.
1699  */
1700 int aul_update_freezer_status(int pid, const char* type);
1701
1702 /*
1703  * This API is only for Appfw internally.
1704  */
1705 int aul_send_app_launch_request_signal(int pid, const char* appid, const char* pkgid, const char* type);
1706
1707 /*
1708  * This API is only for Appfw internally.
1709  */
1710 int aul_send_app_resume_request_signal(int pid, const char* appid, const char* pkgid, const char *type);
1711
1712 /*
1713  * This API is only for Appfw internally.
1714  */
1715 int aul_send_app_terminate_request_signal(int pid, const char* appid, const char* pkgid, const char *type);
1716
1717 /*
1718  * This API is only for Appfw internally.
1719  */
1720 int aul_send_app_status_change_signal(int pid, const char* appid, const char* pkgid, const char* status, const char *type);
1721
1722 /*
1723  * This API is only for Appfw internally.
1724  */
1725 int aul_send_app_terminated_signal(int pid);
1726
1727 /*
1728  * This API is only for Appfw internally.
1729  */
1730 int aul_send_app_group_signal(int owner_pid, int child_pid, const char *child_pkgid);
1731
1732 /*
1733  * This API is only for Appfw internally.
1734  */
1735 int aul_invoke_status_local_cb(int status);
1736
1737 /*
1738  * This type is only for Appfw internally.
1739  */
1740 typedef int (*data_control_provider_handler_fn) (bundle *b, int request_id, void *data);
1741
1742 /*
1743  * This API is only for Appfw internally.
1744  */
1745 int aul_set_data_control_provider_cb(data_control_provider_handler_fn handler);
1746
1747 /*
1748  * This API is only for Appfw internally.
1749  */
1750 int aul_unset_data_control_provider_cb(void);
1751
1752 /*
1753  * This API is only for Appfw internally.
1754  */
1755 int aul_pause_app(const char *appid);
1756
1757 /*
1758  * This API is only for Appfw internally.
1759  */
1760 int aul_pause_pid(int pid);
1761
1762 /*
1763  * This API is only for Appfw internally.
1764  */
1765 int aul_reload_appinfo(void);
1766
1767 /*
1768  * This API is only for Appfw internally.
1769  */
1770 int aul_status_update(int status);
1771
1772 /*
1773  * This API is only for Appfw internally.
1774  */
1775 int aul_running_list_update(char *appid, char *app_path, char *pid);
1776
1777 /*
1778  * This API is only for Appfw internally.
1779  */
1780 void aul_app_group_add(int leader_pid, int pid, int wid);
1781
1782 /*
1783  * This API is only for Appfw internally.
1784  */
1785 void aul_app_group_remove(int pid);
1786
1787 /*
1788  * This API is only for Appfw internally.
1789  */
1790 void aul_app_group_attach_window(int parent_wid, int child_wid);
1791
1792 /*
1793  * This API is only for Appfw internally.
1794  */
1795 void aul_app_group_detach_window(int child_wid);
1796
1797 /*
1798  * This API is only for Appfw internally.
1799  */
1800 int aul_app_group_get_window(int pid);
1801
1802 /*
1803  * This API is only for Appfw internally.
1804  */
1805 int aul_app_group_get_window(int pid);
1806
1807 /*
1808  * This API is only for Appfw internally.
1809  */
1810 int aul_app_group_set_window(int wid);
1811
1812 /*
1813  * This API is only for Appfw internally.
1814  */
1815 void aul_app_group_get_leader_pids(int *cnt, int **pids);
1816
1817 /*
1818  * This API is only for Appfw internally.
1819  */
1820 void aul_app_group_get_group_pids(int leader_pid, int *cnt, int **pids);
1821
1822 /*
1823  * This API is only for Appfw internally.
1824  */
1825 int aul_app_group_get_leader_pid(int pid);
1826
1827 /*
1828  * This API is only for Appfw internally.
1829  */
1830 int aul_app_group_clear_top(void);
1831
1832 /*
1833  * This API is only for Appfw internally.
1834  */
1835 int aul_app_group_is_top(void);
1836
1837 /*
1838  * This API is only for Appfw internally.
1839  */
1840 int aul_app_group_get_fg_flag(int pid);
1841
1842 /*
1843  * This API is only for Appfw internally.
1844  */
1845 void aul_app_group_lower(int *exit);
1846
1847 /*
1848  * This API is only for Appfw internally.
1849  */
1850 void aul_app_group_get_idle_pids(int *cnt, int **pids);
1851
1852 /*
1853  * This API is only for Appfw internally.
1854  */
1855 int aul_request_data_control_socket_pair(bundle *b, int *fd);
1856
1857 /*
1858  * This API is only for Appfw internally.
1859  */
1860 int aul_listen_booting_done_signal(int (*func) (int, void *), void *data);
1861
1862 /*
1863  * This API is only for Appfw internally.
1864  */
1865 int aul_listen_cooldown_signal(int (*func) (const char *, void *), void *data);
1866
1867 /*
1868  * This API is only for Appfw internally.
1869  */
1870 int aul_listen_app_status_signal(int (*func) (int, int, void *), void *data);
1871
1872 /*
1873  * This API is only for Appfw internally.
1874  */
1875 int aul_check_tep_mount(const char *tep_path);
1876
1877 /*
1878  * This API is only for Appfw internally.
1879  */
1880 int aul_is_tep_mount_dbus_done(const char *tep_string);
1881
1882 /*
1883  * This API is only for Appfw internally.
1884  */
1885 int aul_forward_app(const char *appid, bundle *kb);
1886
1887 /**
1888  * @par Description:
1889  *      This API create custom launchpad-loader
1890  * @par Purpose:
1891  *      This API's purpose is to make a slot for custom loader.
1892  *      Once it is made, added loader will make a candidate process to use.
1893  *
1894  * @param[in]   loader_path     The file name of the custom loader binary including full path
1895  * @return      Loader ID if success, negative value(<0) if fail
1896  *
1897  * @remark
1898  *      This API is only for Appfw internally.
1899  *      This API is only available in User Session.
1900 */
1901 int aul_add_loader(const char *loader_path);
1902
1903 /**
1904  * @par Description:
1905  *      This API destroy custom launchpad-loader
1906  * @par Purpose:
1907  *      This API's purpose is to remove a slot for custom loader.
1908  *      Once it is removed, the prepared process will be removed as well.
1909  *
1910  * @param[in]   loader_id       Loader ID
1911  * @return      0 if success, negative value(<0) if fail
1912  *
1913  * @remark
1914  *      This API is only for Appfw internally.
1915  *      This API is only available in User Session.
1916 */
1917 int aul_remove_loader(int loader_id);
1918
1919 /**
1920  * @par Description
1921  *      This API gets specified application process id.
1922  * @par Purpose:
1923  *      The purpose of this API is to get the pid of specified application.
1924  *
1925  * @param[in]   appid   application name
1926  * @return      callee's pid if success, negative value(<0) if fail
1927  *
1928  * @remark
1929  *      This API is only available in User Session.
1930  */
1931 int aul_app_get_pid(const char *appid);
1932
1933 #ifdef __cplusplus
1934         }
1935 #endif
1936
1937 #endif          /* __AUL_H__ */
1938