Initialize Tizen 2.3
[framework/appfw/aul-1.git] / include / aul.h
1 /*
2  *  aul
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22
23 #ifndef __AUL_H__
24 #define __AUL_H__
25
26 #include <errno.h>
27 #include <bundle.h>
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 /**
34  * @mainpage
35  *
36  * This is new version of Application Utility Library
37  *
38  * Almost function's input param is application package name(APN).\n
39  * APN is application package name which is set by developer.\n
40  * In case of in-house application, prefix is org.tizen.\n
41  * It is different from debian package name.\n
42  *
43  * - Debian Package Name : Name which is managed by package manager
44  * - Application Package Name : Name which is used by AUL
45  * - Execution Path : real program executable path
46  */
47
48 /**
49  * @open
50  * @ingroup APPLICATION_FRAMEWORK
51  * @defgroup aul  Application Utility Library
52  * @{
53  */
54
55
56 /**
57  * @file        aul.h
58  * @brief       Application Utility Library header
59  *
60  * Patched by    Knhoon Baik <knhoon.baik@samsung.com>
61  * Patched by    Youmin Ha   <youmin.ha@samsung.com>
62  */
63
64 /**
65  * @addtogroup aul
66  * @{
67  */
68
69 /**
70  * @brief Return values in AUL.
71  */
72 typedef enum _aul_return_val {
73         AUL_R_EHIDDENFORGUEST = -11,    /**< App hidden for guest mode */
74         AUL_R_ENOLAUNCHPAD = -10,       /**< no launchpad */
75         AUL_R_ETERMINATING = -9,        /**< application terminating */
76         AUL_R_EILLACC = -8,             /**< Illegal Access */
77         AUL_R_LOCAL = -7,               /**< Launch by himself */
78         AUL_R_ETIMEOUT = -6,            /**< Timeout */
79         AUL_R_ECANCELED = -5,           /**< Operation canceled */
80         AUL_R_EINVAL = -4,              /**< Invalid argument */
81         AUL_R_ECOMM = -3,               /**< Comunication Error */
82         AUL_R_ENOINIT = -2,             /**< AUL handler NOT initialized */
83         AUL_R_ERROR = -1,               /**< General error */
84         AUL_R_OK = 0                    /**< General success */
85 }aul_return_val;
86
87 enum app_status {
88         STATUS_LAUNCHING,
89         STATUS_CREATED,
90         STATUS_FOCUS,
91         STATUS_VISIBLE,
92         STATUS_BG,
93         STATUS_DYING,
94         STATUS_HOME,
95         STATUS_NORESTART
96 };
97
98 /** @} */
99
100 /**
101  * @defgroup aul_launch         Primitive APIs to launch/resume/terminate application
102  * @ingroup aul
103  * @brief
104  *      APIs to launch/resume/terminate application
105  *      - Launch application based on application package name
106  *      - Resume application based on application package name
107  *      - Resume application based on pid (required root or inhouse permisssion)
108  *      - Terminate application base on pid (required root or inhouse permission)
109  *
110  *      AUL internal information
111  *      - AUL grant pid, gid to launched application for security
112  *      - AUL send RESET/RESUME/TERM event for running application in case of single instance
113  *      - AUL set application enviroment based on desktop entry
114  *      - AUL support single instance / multi instance
115  *      - AUL support application data exchange format (bundle)
116  */
117
118 /**
119  * @addtogroup aul_launch
120  * @{
121  */
122
123 typedef enum _aul_type{
124         AUL_START,
125         AUL_RESUME,
126         AUL_TERMINATE
127 }aul_type;
128
129 /** AUL internal private key */
130 #define AUL_K_PKG_NAME          "__AUL_PKG_NAME__"
131 /** AUL internal private key */
132 #define AUL_K_WAIT_RESULT       "__AUL_WAIT_RESULT__"
133 /** AUL internal private key */
134 #define AUL_K_SEND_RESULT       "__AUL_SEND_RESULT__"
135 /** AUL internal private key */
136 #define AUL_K_TASK_MANAGE       "__AUL_TASK_MANAGE__"
137 /** AUL internal private key */
138 #define AUL_K_APP_TYPE          "__AUL_APP_TYPE__"
139 /** AUL internal private key - To check original caller's identity */
140 #define AUL_K_ORG_CALLER_PID    "__AUL_ORG_CALLER_PID__"
141 /** AUL internal private key - To check forwarded callee app's pid */
142 #define AUL_K_FWD_CALLEE_PID    "__AUL_FWD_CALLEE_PID__"
143
144 /** AUL internal private key */
145 #define AUL_K_NO_CANCEL        "__AUL_NO_CANCEL__"
146
147 /** AUL public key - To check caller's secuirty */
148 #define AUL_K_CALLER_PID        "__AUL_CALLER_PID__"
149 /** AUL public key - To check callee's secuirty */
150 #define AUL_K_CALLEE_PID        "__AUL_CALLEE_PID__"
151
152 /** AUL public key - To check caller's secuirty */
153 #define AUL_K_CALLER_APPID      "__AUL_CALLER_APPID__"
154 /** AUL public key - To check caller's secuirty */
155 #define AUL_K_CALLEE_APPID      "__AUL_CALLEE_APPID__"
156
157 /** AUL public key - To find argv0 */
158 #define AUL_K_ARGV0             "__AUL_ARGV0__"
159 /** AUL public key - To measure launching time */
160 #define AUL_K_STARTTIME         "__AUL_STARTTIME__"
161
162 /** AUL public key - To support launching based on mime type */
163 #define AUL_K_MIME_TYPE         "__AUL_MIME_TYPE__"
164 /** AUL public key - To support launching based on mime type */
165 #define AUL_K_UNALIASED_MIME_TYPE               "__AUL_UNALIASED_MIME_TYPE__"
166 /** AUL public key - To support launching based on mime type */
167 #define AUL_K_MIME_CONTENT      "__AUL_MIME_CONTENT__"
168
169 /** AUL public key - To support launching based on service */
170 #define AUL_K_SERVICE_NAME              "__AUL_SERVICE_NAME__"
171
172 /** AUL public key - To force launch app selector instead of lauchingn default app */
173 #define AUL_K_FORCE_LAUNCH_APP_SELECTOR "__AUL_FORCE_LAUNCH_APP_SELECTOR__"
174
175 /** AUL public key - To support SDK */
176 #define AUL_K_SDK       "__AUL_SDK__"
177
178 /** AUL public key - To support Media key */
179 #define AUL_K_MULTI_KEY "__AUL_MULTI_KEY__"
180 /** AUL public key - To support Media key */
181 #define AUL_K_MULTI_KEY_EVENT   "__AUL_MULTI_KEY_EVENT__"
182
183 /** AUL public bundle value */
184 #define AUL_K_PRIVACY_APPID             "__AUL_PRIVACY_APPID__"
185
186 /** AUL public bundle value - To support Media key*/
187 #define AUL_V_KEY_PRESSED       "__AUL_KEY_PRESSED__"
188 /** AUL public bundle value - To support Media key*/
189 #define AUL_V_KEY_RELEASED      "__AUL_KEY_RELEASED__"
190
191 /** AUL internal private key */
192 #define AUL_K_EXEC              "__AUL_EXEC__"
193 /** AUL internal private key */
194 #define AUL_K_MULTIPLE          "__AUL_MULTIPLE__"
195 /** AUL internal private key */
196 #define AUL_K_PACKAGETYPE       "__AUL_PACKAGETYPE__"
197 /** AUL internal private key */
198 #define AUL_K_HWACC             "__AUL_HWACC__"
199 /** AUL internal private key */
200 #define AUL_K_TASKMANAGE        "__AUL_TASKMANAGE__"
201
202
203 /** AUL internal private key */
204 #define AUL_K_APPID             "__AUL_APPID__"
205 /** AUL internal private key */
206 #define AUL_K_PID               "__AUL_PID__"
207
208 #define PRIVACY_POPUP "tizenprv00.privacy-popup"
209
210
211 /**
212  * @brief       This is callback function for aul_launch_init
213  * @param[in]   type    event's type received from system
214  * @param[in]   b       In case of RESET events, bundle which is received from peer
215  * @param[in]   data    user-supplied data
216  */
217 typedef int (*aul_handler_fn) (aul_type type, bundle * b, void *data);
218
219 /**
220  * @par Description:
221  *      This API install your AUL handler and setup AUL internal connection.
222  * @par Purpose:
223  *      AUL receive START(RESET), RESUME, TERMINATE events from system.\n
224  *      This API use to handle the events. \n
225  * @par Typical use case:
226  *      In general, you need not use this API.
227  *      If you use AppCore, you should NOT use this API.
228  *      AppCore will set default aul_handler.
229  *
230  * @param[in]   handler         aul main callback handler function
231  * @param[in]   data            user-supplied data for start_handler
232  * @return      0 if success, negative value(<0) if fail\n
233  * @retval      AUL_R_OK        - success
234  * @retval      AUL_R_ECANCELD  - aul handler was installed already by others
235  * @retval      AUL_R_ECOMM     - error to create internal ipc
236  * @retval      AUL_R_ERROR     - error to attach glib main loop or ecore main loop
237  *
238  * @warning     If you use AppCore, you should NOT use this API.\n
239  *              You need glib main loop or ecore main loop.\n
240  * @pre
241  *      you must have aul handler to use this API.
242  *      aul_luanch_init register aul handler.
243  * @post
244  *      None
245  * @see
246  *      None
247  * @code
248  * #include <aul.h>
249  * #include <bundle.h>
250  *
251  * static int aul_handler(aul_type type, bundle *kb,void *data)
252  * {
253  *      switch(type)
254  *      {
255  *              case AUL_START:
256  *                      // process RESET event
257  *                      break;
258  *              case AUL_RESUME:
259  *                      // process RESUME event
260  *                      break;
261  *              case AUL_TERMINATE:
262  *                      // preocess TERMINATE event
263  *                      break;
264  *      }
265  *      return 0;
266  * }
267  *
268  * int main(int argc, char **argv)
269  * {
270  *      ecore_init();
271  *      aul_launch_init(aul_handler,NULL);
272  *      aul_launch_argv_handler(argc, argv);
273  *      ecore_main_loop_begin();
274  * }
275  *
276  * @endcode
277  * @remark
278  *      None
279 */
280 int aul_launch_init(aul_handler_fn handler, void *data);
281
282 /**
283  * @par Description:
284  *      This API create internal RESET events with given argc, argv \n
285  * @par Purpose:
286  *      This API's purpose is to generate reset event.
287  *      If you want to generate local RESET events with argument vector format, use this API
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]   argc    # of args
293  * @param[in]   argv    list of arg strings
294  * @return      0 if success, negative value(<0) if fail
295  * @retval      AUL_R_OK        - success
296  * @retval      AUL_R_ENOINIT   - aul handler was NOT yet installed
297  * @retval      AUL_R_ECANCLED  - error to create internal bundle with given argc,argv.
298  * @retval      AUL_R_ERROR     - general error
299  *
300  * @pre
301  *      you must have aul handler to use this API.
302  *      aul_luanch_init register aul handler.
303  * @post
304  *      None
305  * @see
306  *      aul_launch_init
307  * @code
308  * #include <aul.h>
309  * #include <bundle.h>
310  *
311  * int send_local_reset_event()
312  * {
313  *      int argc=3;
314  *      char* argv[4];
315  *      argv[0] = "local.app";
316  *      argv[1] = "event_type";
317  *      argv[2] = "my_reset";
318  *      argv[3] = NULL;
319  *      aul_launch_argv_handler(argc,argv);
320  * }
321  *
322  * @endcode
323  * @remark
324  *      If you use AppCore, you NEED NOT use this API.
325 */
326 int aul_launch_argv_handler(int argc, char **argv);
327
328 /**
329  * @par Description:
330  *      This API create internal RESET events with given argc, argv \n
331  * @par Purpose:
332  *      This API's purpose is to generate reset event.
333  *      If you want to generate local RESET events with argument vector format, use this API
334  * @par Typical use case:
335  *      In general, you need not use this API.
336  *      AppCore use this API to create internal reset event.
337  *
338  * @param[in]   argc    # of args
339  * @param[in]   argv    list of arg strings
340  * @return      0 if success, negative value(<0) if fail
341  * @retval      AUL_R_OK        - success
342  * @retval      AUL_R_ENOINIT   - aul handler was NOT yet installed
343  * @retval      AUL_R_ECANCLED  - error to create internal bundle with given argc,argv.
344  * @retval      AUL_R_ERROR     - general error
345  *
346  * @pre
347  *      you must have aul handler to use this API.
348  *      aul_luanch_init register aul handler.
349  * @post
350  *      None
351  * @see
352  *      aul_launch_init
353  * @code
354  * #include <aul.h>
355  * #include <bundle.h>
356  *
357  * int send_local_reset_event()
358  * {
359  *      int argc=3;
360  *      char* argv[4];
361  *      argv[0] = "local.app";
362  *      argv[1] = "event_type";
363  *      argv[2] = "my_reset";
364  *      argv[3] = NULL;
365  *      aul_launch_argv_handler_for_efl(argc,argv);
366  * }
367  *
368  * @endcode
369  * @remark
370  *      If you use AppCore, you NEED NOT use this API.
371 */
372 int aul_launch_argv_handler_for_efl(int argc, char **argv);
373
374
375 /**
376  * @par Description:
377  *      This API creates internal RESET events with given bundle \n
378  * @par Purpose:
379  *  This API's purpose is to generate reset event.
380  *  If you want to generate local RESET events with argument vector format, first use
381  *  bundle_import_from_argv to create a bundle from the argument vector and then use this API
382  *  Eventually, this API will replace aul_launch_argv_handler().
383  * @par Typical use case:
384  *      In general, you need not use this API.
385  *      AppCore use this API to create internal reset event.
386  *
387  * @param[in]   b       bundle
388  * @return      0 if success, negative value(<0) if fail
389  * @retval      AUL_R_OK        - success
390  * @retval      AUL_R_ENOINIT   - aul handler was NOT yet installed
391  * @retval      AUL_R_ERROR     - general error
392  *
393  * @pre
394  *      you must have aul handler to use this API.
395  *      aul_luanch_init register aul handler.
396  * @post
397  *      None
398  * @see
399  *      aul_launch_init, bundle_import_from_argv
400  * @code
401  * #include <aul.h>
402  * #include <bundle.h>
403  *
404  * int send_local_reset_event()
405  * {
406  *  bundle* b;
407  *      int argc=3;
408  *      char* argv[4];
409  *      argv[0] = "local.app";
410  *      argv[1] = "event_type";
411  *      argv[2] = "my_reset";
412  *      argv[3] = NULL;
413  *
414  *      b = bundle_import_from_argv(argc,argv);
415  *      aul_launch_local(b);
416  * }
417  *
418  * @endcode
419  * @remark
420  *      If you use AppCore, you NEED NOT to use this API.
421 */
422 int aul_launch_local(bundle *b);
423
424 /**
425  * @par Description:
426  *      This API launches application with the given bundle.
427  *  If the application is not running or a multiple-instance one, this API launches with the given bundle.
428  *      If the application is running, this API sends a RESET event to the App.
429  *      While the application is running, if the application cannot receive the RESET event,
430  *      this API returns a general error(AUL_R_ERROR).\n
431  * @par Purpose:
432  *      This API is for caller.
433  *      This API's purpose is to launch/reset application with given bundle.
434  * @par Typical use case:
435  *      If you know the target application's pkgname and bundle types,
436  *      you can use this API to launch/reset the application.
437  *
438  * @param[in]   pkgname         package name to be run as callee
439  * @param[in]   kb              bundle to be passed to callee
440  * @return      callee's pid if success, negative value(<0) if fail
441  * @retval      AUL_R_OK        - success
442  * @retval      AUL_R_EINVAL    - invaild package name
443  * @retval      AUL_R_ECOM      - internal AUL IPC error
444  * @retval      AUL_R_ERROR     - general error
445  *
446  * @pre
447  *      None
448  * @post
449  *      None
450  * @see
451  *      aul_open_app
452  * @code
453  * #include <aul.h>
454  * #include <bundle.h>
455  *
456  * int launch_inhouse_contact_app()
457  * {
458  *      bundle *b;
459  *      b = bundle_create();
460  *      bundle_add(b,"type","SIM");
461  *      aul_launch_app("org.tizen.contact",b);
462  * }
463  *
464  * @endcode
465  * @remark
466  *      None
467  */
468 int aul_launch_app(const char *appid, bundle *kb);
469
470 /**
471  * @par Description:
472  *  This API launches application, as menu screen launches the app.
473  *  Thus, if the applocation is running, this API sends a RESUME event to the app.
474  *  If the application is not running, this API launches the app.
475  *  While the application is running, if the application cannot receive the RESUME event,
476  *  AUL tries to raise the application's default window.
477  *
478  * @par Purpose:
479  *      This API is for caller.
480  *      This API's purpose is to resume/launch application
481  * @par Typical use case:
482  *      If you only want to show application with previous state or default state, Use this API.
483  *
484  * @param[in]   pkgname         package name to be resume as callee
485  * @return      callee's pid if success, negative value(<0) if fail
486  * @retval      AUL_R_OK        - success
487  * @retval      AUL_R_EINVAL    - invaild package name
488  * @retval      AUL_R_ECOM      - internal AUL IPC error
489  * @retval      AUL_R_ERROR     - general error
490  *
491  * @pre
492  *      None
493  * @post
494  *      None
495  * @see
496  *      aul_launch_app, aul_app_is_running, aul_resume_pid
497  * @code
498  * #include <aul.h>
499  * #include <bundle.h>
500  *
501  * int open_inhouse_contact_app()
502  * {
503  *      if(aul_app_is_running("org.tizen.contact"))
504  *              aul_open_app("org.tizen.contact");
505  * }
506  *
507  * @endcode
508  * @remark
509  *      If you don't want to launch the app,
510  *      you should check app's running state with aul_app_is_running.
511  *      This API will launch the application if the application is not running.
512 */
513 int aul_open_app(const char *appid);
514
515 /**
516  * @par Description:
517  *      This API trigger to resume application
518  *      If the application is running, this API send a resume event to the App.
519  *      If the application is not running, this API returns fail.
520  *      Although the application is running, if the application cannot receive resume event,
521  *      AUL try to raise the application's default windows.
522  * @par Purpose:
523  *      This API is for caller.
524  *      This API's purpose is to send resume event.
525  * @par Typical use case:
526  *      If you only want to show application with previous state or default state, Use this API.
527  *
528  * @param[in]   pkgname         package name to be resume as callee
529  * @return      callee's pid if success, negative value(<0) if fail
530  * @retval      AUL_R_OK        - success
531  * @retval      AUL_R_EINVAL    - invaild package name
532  * @retval      AUL_R_ECOM      - internal AUL IPC error
533  * @retval      AUL_R_ERROR     - general error
534  *
535  * @pre
536  *      None
537  * @post
538  *      None
539  * @see
540  *      aul_launch_app, aul_app_is_running, aul_resume_pid
541  * @deprecated
542  *  This function will be deprecated. Use aul_open_add() instead.
543  * @code
544  * #include <aul.h>
545  * #include <bundle.h>
546  *
547  * int resume_inhouse_contact_app()
548  * {
549  *      if(aul_app_is_running("org.tizen.contact"))
550  *              aul_resume_app("org.tizen.contact");
551  * }
552  *
553  * @endcode
554  * @remark
555  *      If you don't want to launch the app,
556  *      you should check app's running state with aul_app_is_running.
557  *      This API will launch the application if the application is not running.
558  *      If you want to only resume without launching in multiple instance application model,
559  *      you should use aul_resume_pid.
560 */
561 int aul_resume_app(const char *appid);
562
563 /**
564  * @par Description:
565  *      This API trigger to resume application
566  *      If the application is running, this API send a resume event to the App.
567  *      If the application is not running, this API return AUL_R_ERROR.
568  *      Although the application is running, if the application cannot receive resume event,
569  *      AUL try to raise the application's default windows.
570  * @par Purpose:
571  *      This API is for caller.
572  *      This API's purpose is to send resume event.
573  * @par Typical use case:
574  *      In multiple application model, If you want to only resume specific application, Use this API
575  *
576  * @param[in]   pid     application's pid to be resumed
577  * @return      0 if success, negative value(<0) if fail
578  * @retval      AUL_R_OK        - success
579  * @retval      AUL_R_EINVAL    - invaild pid
580  * @retval      AUL_R_ECOM      - internal AUL IPC error
581  * @retval      AUL_R_ERROR     - general error (include application is not running)
582  * @warning     This API need to require root or inhouse permisssion \n
583  *              If you have not the permission, this API return AUL_R_ERROR. \n
584  * @pre
585  *      None
586  * @post
587  *      None
588  * @see
589  *      aul_launch_app
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_resume_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  *      None
608 */
609 int aul_resume_pid(int pid);
610
611 /**
612  * @par Description:
613  *      This API trigger to terminate application
614  *
615  *      If the application is running, this API send a terminate event to the App. \n
616  *      If the app cannot receive the event, AUL kill forcely the application.\n
617  * @par Purpose:
618  *      This API's purpose is to kill application
619  * @par Typical use case:
620  *      In general, Application like Task Manager use this API.
621  *
622  *              This API need to require root or inhouse permisssion. \n
623  *
624  * @param[in]   pid     application's pid to be terminated
625  * @return      0 if success, negative value(<0) if fail
626  * @retval      AUL_R_OK        - success
627  * @retval      AUL_R_EINVAL    - invaild pid
628  * @retval      AUL_R_ECOM      - internal AUL IPC error
629  * @retval      AUL_R_ERROR     - general error
630  * @warning     This API need to require root or inhouse permisssion. \n
631  *
632  * @pre
633  *      None
634  * @post
635  *      None
636  * @see
637  *      None
638  * @code
639  * #include <aul.h>
640  * #include <bundle.h>
641  *
642  * int iterfunc(const aul_app_info *info, void *data)
643  * {
644  *      if(strcmp(info->pkg_name,"org.tizen.contact")==0)
645  *              aul_terminate_pid(info->pid);
646  * }
647  *
648  * int iterate_running_apps()
649  * {
650  *      return aul_app_get_running_app_info(iterfunc,NULL);
651  * }
652  *
653  * @endcode
654  * @remark
655  *      If you have not the permission, this API return AUL_R_ERROR. \n
656 */
657 int aul_terminate_pid(int pid);
658
659 /** @} */
660
661 /**
662  * @defgroup aul_info           Helper APIs to get running application information
663  * @ingroup aul
664  * @brief
665  *      API to get running application information (state, executable path, ..)
666  *      - get application package name from pid
667  *      - get application running state
668  *      - get application list of runnning applications
669  */
670
671 /**
672  * @addtogroup aul_info
673  * @{
674  */
675
676 /**
677  *@brief Running application's information structure retrieved by AUL
678  */
679 typedef struct _aul_app_info {
680         int pid;                /**< app's pid if running*/
681         char* pkg_name;         /**< application id */
682         char* app_path;         /**< application excutable path */
683         char* appid;
684 } aul_app_info;
685
686 /**
687  * @brief iterator function running with aul_app_get_running_app_info
688  * @param[out]  ainfo   aul_app_info retreived by aul_app_get_running_app_info
689  * @param[out]  data    user-supplied data
690 */
691 typedef int (*aul_app_info_iter_fn)(const aul_app_info *ainfo, void *data);
692
693 /**
694  * @par Description:
695  *      This API ask a application is running by application package name.
696  * @par Purpose:
697  *      To know whether some application is running or not, use this API
698  * @par Typical use case:
699  *      For example, If you want to know browser application running,
700  *      you can check it by using this API.
701  *
702  * @param[in]   pkgname application package name
703  * @return      true / false
704  * @retval      1       app_name is running now.
705  * @retval      0       app_name is NOT running now.
706  *
707  * @pre
708  *      None
709  * @post
710  *      None
711  * @see
712  *      None
713  * @code
714  * #include <aul.h>
715  *
716  * int is_running_browser_app()
717  * {
718  *      return aul_app_is_running("org.tizen.browser");
719  * }
720  *
721  * @endcode
722  * @remark
723  *      None
724 *
725 */
726 int aul_app_is_running(const char *appid);
727
728 /**
729  * @par Description:
730  *      This API use to get running application list.
731  *      This API call iter_fn with each aul_app_info of running apps when running application is found.
732  * @par Purpose:
733  *      If you want to get running application list, use this API
734  *      This API give you running applications which has SLP desktop file.
735  * @par Typical use case:
736  *      In general, this API is used by task manager appllication. (running application list viewer)
737  *
738  * @param[in]   iter_fn         iterator function
739  * @param[in]   data            user-supplied data for iter_fn
740  * @return      0 if success, negative value(<0) if fail
741  * @retval      AUL_R_OK        - success
742  * @retval      AUL_R_ERROR     - internal error
743  *
744  * @pre
745  *      None
746  * @post
747  *      None
748  * @see
749  *      None
750  * @code
751  * #include <aul.h>
752  *
753  * int iterfunc(const aul_app_info* info, void* data)
754  * {
755  *      printf("\t==========================\n");
756  *      printf("\t pkg_name: %s\n", info->appid);
757  *      printf("\t app_path: %s\n", info->app_path);
758  *      printf("\t running pid: %d\n", info->pid);
759  *      printf("\t==========================\n");
760  *      return 0;
761  * }
762  *
763  * int iterate_running_apps()
764  * {
765  *      return aul_app_get_running_app_info(iterfunc,NULL);
766  * }
767  *
768  * @endcode
769  * @remark
770  *      This API should use if you want to know running application which has desktop files.
771  *      If you want to get all process list, you must iterate process information by using proc filesystem
772  *      Or, If you want to get all window list, you must iterate XWindows by using XWindow APIs
773  */
774 int aul_app_get_running_app_info(aul_app_info_iter_fn iter_fn, void *data);
775
776 /**
777  * @par Description:
778  *      This API get application package name by pid
779  * @par Purpose:
780  *      If you want to get package name of running application, use this API
781  * @par Typical use case:
782  *      In general, You can use this API when you want to know caller's information.
783  *
784  * @param[in]   pid             given pid
785  * @param[out]  pkgname         pkgname to be get
786  * @param[in]   len             length of pkgname
787  * @return      0 if success, negative value(<0) if fail
788  * @retval      AUL_R_OK        - success
789  * @retval      AUL_R_ERROR     - no such a package name
790  * @pre
791  *      None
792  * @post
793  *      None
794  * @see
795  *      None
796  * @code
797  * #include <aul.h>
798  * #include <bundle.h>
799  *
800  * static int app_reset(bundle *b, void *data)
801  * {
802  *      int pid;
803  *      char appname[255];
804  *
805  *      pid = atoi(bundle_get_val(b,AUL_K_CALLER_PID));
806  *      aul_app_get_pkgname_bypid(pid, appname, sizeof(appname));
807  * }
808  *
809  * @endcode
810  * @remark
811  *      None
812 */
813 int aul_app_get_pkgname_bypid(int pid, char *pkgname, int len);
814
815 /**
816  * @par Description:
817  *      This API get application appid by pid
818  * @par Purpose:
819  *      If you want to get appid of running application, use this API
820  * @par Typical use case:
821  *      In general, You can use this API when you want to know caller's information.
822  *
823  * @param[in]   pid             given pid
824  * @param[out]  appid           application id
825  * @param[in]   len             length of pkgname
826  * @return      0 if success, negative value(<0) if fail
827  * @retval      AUL_R_OK        - success
828  * @retval      AUL_R_ERROR     - no such a appid
829  * @pre
830  *      None
831  * @post
832  *      None
833  * @see
834  *      None
835  * @code
836  * #include <aul.h>
837  * #include <bundle.h>
838  *
839  * static int app_reset(bundle *b, void *data)
840  * {
841  *      int pid;
842  *      char appid[255];
843  *
844  *      pid = atoi(bundle_get_val(b,AUL_K_CALLER_PID));
845  *      aul_app_get_appid_bypid(pid, appid, sizeof(appid));
846  * }
847  *
848  * @endcode
849  * @remark
850  *      None
851 */
852 int aul_app_get_appid_bypid(int pid, char *appid, int len);
853
854
855 /** @} */
856
857 /**
858  * @defgroup aul_mime High-level APIs to launch default application based on mime type
859  * @ingroup aul
860  * @brief
861  *   AUL High-level APIs based on mime type
862  *
863  *   These APIs provide two functionality\n
864  *
865  *   -# To launch default application to open a file based on its MIME type \n
866  *   For example, you can launch the default video player to open .mp4 files
867  *   or launch the default browser to open HTML files \n
868  *   -# To launch default application to process given content \n
869  *   For example, you can launch the default e-mail application to process
870  *   "nice@samsung.com" e-mail address.
871  */
872
873 /**
874  * @addtogroup aul_mime
875  * @{
876  */
877
878 /**
879  * @par Description:
880  *      This API launch application associated with given filename
881  * @par Purpose:
882  *      This API is for caller.
883  *      This API launch application based on mime type.
884  *      This API find mime_type associated with file name,
885  *      and then find default app associated with found mime_type
886  *      and then launch the app with filename argument.
887  * @par Typical use case:
888  *      You can launch application to process given filename.
889  *      That is, Even if you don't know the specific application's pkgname,
890  *      you can launch the applicaiton processing given filename .
891  *      For example, If you want to process image file, you can simply launch image viewer.
892  *      At that time, you can use this APIs like aul_open_file("myimage.jpg");
893  *
894  * @param[in]   filename        filename
895  * @return      callee's pid or 0 if success, negative value if fail\n
896  *              (when no found default app, return 0)
897  * @retval      AUL_R_OK        - success
898  * @retval      AUL_R_EINVAL    - invalid argument(filename)
899  * @retval      AUL_R_ECOM      - internal AUL IPC error
900  * @retval      AUL_R_ERROR     - general error
901  *
902  * @pre
903  *      None
904  * @post
905  *      None
906  * @see
907  *      None
908  * @code
909  * #include <aul.h>
910  *
911  * int view_image_file(char *filename)
912  * {
913  *      aul_open_file(filename);
914  * }
915  *
916  * @endcode
917  * @remark
918  *      None
919  *
920  */
921 int aul_open_file(const char* filename);
922
923 /**
924  * @par Description:
925  *      This API launch application associated with given specific mimetype
926  * @par Purpose:
927  *      This API is for caller.
928  *      This API launch application based on mime type like aul_open_file API.
929  *      But, This API don't find mime_type associated with file name.
930  *      This API use mimetype given by user. By using given mimetype, find default application.
931  *      and then launch the app with filename argument.
932  * @par Typical use case:
933  *      Some files cannot extract exact mimetype automatically.
934  *      For example, To know mime type of files with DRM lock, first we should unlock DRM file.
935  *      In this case, You can use this API.
936  *      First, unlock DRM file, and extract mimetype from unlock file by using aul_get_mime_from_file,
937  *      and then, use this API with DRM file and extracted mime type.
938  *
939  * @param[in]   filename        filename
940  * @param[in]   mimetype        specific mimetype
941  * @return      callee's pid or 0 if success, negative value if fail\n
942  *              (when no found default app, return 0)
943  * @retval      AUL_R_OK        - success
944  * @retval      AUL_R_EINVAL    - invalid argument(filename,mimetype)
945  * @retval      AUL_R_ECOM      - internal AUL IPC error
946  * @retval      AUL_R_ERROR     - general error
947  *
948  * @pre
949  *      None
950  * @post
951  *      None
952  * @see
953  *      aul_open_file, aul_get_mime_from_file
954  * @code
955  * #include <aul.h>
956  *
957  * int view_drm_image_file(char *drm_filename)
958  * {
959  *      char* mimetype;
960  *      // you must implement this function
961  *      mimetype = get_mimetype_from_drmfile(drm_filename);
962  *
963  *      aul_open_file_with_mimetype(drm_filename,mimetype);
964  * }
965  *
966  * @endcode
967  * @remark
968  *      None
969  */
970 int aul_open_file_with_mimetype(const char *filename, const char *mimetype);
971
972 /**
973  * @par Description:
974  *      This API launch application associated with content like "http://www.samsung.com"
975  * @par Purpose:
976  *      This API is for caller.
977  *      This API launch application based on mime type.
978  *      This API find mime_type associated with content,
979  *      and then find default app associated with found mime_type,
980  *      and then launch the app with content argument.
981  * @par Typical use case:
982  *      You can launch application to process given content.
983  *      That is, Even if you don't know the specific application's pkgname,
984  *      you can launch the applicaiton processing given content.
985  *      For example, If you want to process URL "http://www.samsung.com",
986  *      you can simply launch browser.
987  *      At that time, you can use this APIs like aul_open_content("http://www.samsung.com");
988  *
989  * @param[in]   content         content
990  * @return      callee's pid or 0 if success, negative value if fail\n
991  *              (when no found default app, return 0)
992  * @retval      AUL_R_OK        - success
993  * @retval      AUL_R_EINVAL    - invalid argument(content)
994  * @retval      AUL_R_ECOM      - internal AUL IPC error
995  * @retval      AUL_R_ERROR     - general error or no found mimetype
996  *
997  * @pre
998  *      None
999  * @post
1000  *      None
1001  * @see
1002  *      None
1003  * @code
1004  * #include <aul.h>
1005  *
1006  * int view_url(char *url)
1007  * {
1008  *      aul_open_content(url);
1009  * }
1010  *
1011  * @endcode
1012  * @remark
1013  *      None
1014  *
1015  */
1016 int aul_open_content(const char* content);
1017
1018 /**
1019  * @par Description:
1020  *       This API get the default application(appid) associated with MIME type
1021  * @par Purpose:
1022  *      This API use to get default application associteted with mimetype
1023  *      In general, Setting Application need this API.
1024  * @par Typical use case:
1025  *      Setting Application show mapping of default application / mimetype
1026  *
1027  * @param[in]   mimetype        a mime type
1028  * @param[out]  defapp          a application appid of the app
1029  * @param[in]   len             length of defapp
1030  * @return      0 if success, negative value if fail
1031  * @retval      AUL_R_OK        - success
1032  * @retval      AUL_R_EINVAL    - invalid argument(mimetype)
1033  * @retval      AUL_R_ERROR     - general error or no found mimetype
1034  *
1035  * @pre
1036  *      None
1037  * @post
1038  *      None
1039  * @see
1040  *      aul_set_defapp_with_mime
1041  * @code
1042  * #include <aul.h>
1043  *
1044  * void get_text_html_defapp()
1045  * {
1046  *      char appname[255];
1047  *      aul_get_defapp_from_mime("text/html",appname,sizeof(appname));
1048  * }
1049  *
1050  * @endcode
1051  * @remark
1052  *      None
1053  *
1054  */
1055 int aul_get_defapp_from_mime(const char *mimetype, char *defapp, int len);
1056
1057 /**
1058  * @par Description:
1059  *       This API set the default application(appid) associated with MIME type
1060  * @par Purpose:
1061  *      This API use to change default application associteted with mimetype
1062  *      In general, Setting Application or Installer need this API.
1063  * @par Typical use case:
1064  *      Default Application associated with mimetype can be changed by Setting Application or installer
1065  *      So, application to process specific mimetype can be substituted.
1066  *
1067  * @param[in]   mimetype        a mime type
1068  * @param[in]   defapp          a application appid of the app to be set
1069  * @return      0 if success, negative value if fail
1070  * @retval      AUL_R_OK        - success
1071  * @retval      AUL_R_EINVAL    - invalid argument(mimetype)
1072  * @retval      AUL_R_ERROR     - general error
1073  *
1074  * @pre
1075  *      None
1076  * @post
1077  *      None
1078  * @see
1079  *      aul_get_defapp_from_mime
1080  * @code
1081  * #include <aul.h>
1082  *
1083  * void set_text_html_defapp()
1084  * {
1085  *      aul_set_defapp_with_mime("text/html","org.tizen.browser");
1086  * }
1087  *
1088  * @endcode
1089  * @remark
1090  *      None
1091 */
1092 int aul_set_defapp_with_mime(const char *mimetype, const char *defapp);
1093
1094 /**
1095  * @par Description:
1096  *      This API get the mimetype associated with filename
1097  * @par Purpose:
1098  *      This API use to get mimetype associteted with given filename
1099  *      In general, This API use when you want to know only mimetype given filename.
1100  * @par Typical use case:
1101  *      For example, In trasfering data through bluetooth,
1102  *      additional information like mimetype should be added.
1103  *      In such situation, You can get mimetype by using this API.
1104  *
1105  * @param[in]   filename        file name
1106  * @param[out]  mimetype        a mime type
1107  * @param[in]   len             length of mimetype
1108  * @return      0 if success, negative value if fail
1109  * @retval      AUL_R_OK        - success
1110  * @retval      AUL_R_EINVAL    - invalid argument(filename)
1111  * @retval      AUL_R_ERROR     - general error
1112  *
1113  * @pre
1114  *      None
1115  * @post
1116  *      None
1117  * @see
1118  *      None
1119  * @code
1120  * #include <aul.h>
1121  *
1122  * void get_mimetype()
1123  * {
1124  *      char mimetype[255];
1125  *      aul_get_mime_from_file("image.jpg",mimetype,sizeof(mimetype));
1126  * }
1127  *
1128  * @endcode
1129  * @remark
1130  *      None
1131  */
1132 int aul_get_mime_from_file(const char *filename, char *mimetype, int len);
1133
1134 /**
1135  * @par Description:
1136  *      This API get the mimetype associated with given content
1137  * @par Purpose:
1138  *      This API use to get mimetype associteted with given content
1139  *      In general, This API use when you want to know only mimetype given content
1140  * @par Typical use case:
1141  *      For example, In trasfering data through bluetooth,
1142  *      additional information like mimetype should be added.
1143  *      In such situation, You can get mimetype by using this API.
1144  *
1145  * @param[in]   content         content string like "011-0000-0000"
1146  * @param[out]  mimetype        a mime type
1147  * @param[in]   len             length of mimetype
1148  * @return      0 if success, negative value if fail
1149  * @retval      AUL_R_OK        - success
1150  * @retval      AUL_R_EINVAL    - invalid argument(content)
1151  * @retval      AUL_R_ERROR     - general error
1152  *
1153  * @pre
1154  *      None
1155  * @post
1156  *      None
1157  * @see
1158  *      None
1159  * @code
1160  * #include <aul.h>
1161  *
1162  * void get_mimetype()
1163  * {
1164  *      char mimetype[255];
1165  *      aul_get_mime_from_content("http://www.samsung.com",mimetype,sizeof(mimetype));
1166  * }
1167  *
1168  * @endcode
1169  * @remark
1170  *      None
1171 */
1172 int aul_get_mime_from_content(const char *content, char *mimetype, int len);
1173
1174 /**
1175  * @par Description:
1176  *      This API get the icon's name associated with given mimetype
1177  * @par Purpose:
1178  *      This API use to get icon's name associteted with given mimetype
1179  * @par Typical use case:
1180  *      If you want to show mimetype's icon, use this API.
1181  *
1182  * @param[in]   mimetype        a mime type
1183  * @param[out]  iconname        icon's name
1184  * @param[in]   len             length of iconname
1185  * @return      0 if success, negative value if fail
1186  * @retval      AUL_R_OK        - success
1187  * @retval      AUL_R_EINVAL    - invalid argument(content)
1188  * @retval      AUL_R_ERROR     - general error (no such mime type)
1189  *
1190  * @pre
1191  *      None
1192  * @post
1193  *      None
1194  * @see
1195  *      None
1196  * @code
1197  * #include <aul.h>
1198  *
1199  * void get_mime_icon()
1200  * {
1201  *      char icon[255];
1202  *      aul_get_mime_icon("text/html",icon,sizeof(icon));
1203  * }
1204  *
1205  * @endcode
1206  * @remark
1207  *      None
1208  */
1209 int aul_get_mime_icon(const char *mimetype, char *iconname, int len);
1210
1211 /**
1212  * @par Description:
1213  *      This API get the extensions associated with given mimetype
1214  * @par Purpose:
1215  *      This API use to get extensions associteted with given mimetype
1216  * @par Typical use case:
1217  *      In general, user is not familiar with mimetype(text/html),
1218  *      user is familiar with extenstions(*.html, *.htm)
1219  *      So, To show mimetype information to user, use this API
1220  *
1221  * @param[in]   mimetype        a mime type
1222  * @param[out]  extlist         extentions (ex> mpeg,mpg,mpe)
1223  * @param[in]   len             length of extlist
1224  * @return      0 if success, negative value if fail
1225  * @retval      AUL_R_OK        - success
1226  * @retval      AUL_R_EINVAL    - invalid argument(mimetype)
1227  * @retval      AUL_R_ERROR     - general error (no mimetype or no extenstion)
1228  *
1229  * @pre
1230  *      None
1231  * @post
1232  *      None
1233  * @see
1234  *      aul_get_mime_description
1235  * @code
1236  * #include <aul.h>
1237  *
1238  * void get_extension()
1239  * {
1240  *      char extlist[255];
1241  *      aul_get_mime_extension("text/html",extlist,sizeof(extlist));
1242  * }
1243  *
1244  * @endcode
1245  * @remark
1246  *      Some mimetype don't have extension.
1247  *      In that case, You can use aul_get_mime_description.
1248  *
1249 */
1250 int aul_get_mime_extension(const char *mimetype, char *extlist, int len);
1251
1252 /**
1253  * @par Description:
1254  *      This API get the description associated with given mimetype
1255  * @par Purpose:
1256  *      This API use to get description associteted with given mimetype
1257  * @par Typical use case:
1258  *      In general, user is not familiar with mimetype(text/html),
1259  *      user is familiar with well-knowing information like extenstions(*.html, *.htm)
1260  *      But, some mimetype don't have extenstion.
1261  *      At that time,to show mimetype information to user, use this API
1262  *
1263  * @param[in]   mimetype        a mime type
1264  * @param[out]  desc            description (ex> Call client)
1265  * @param[in]   len             length of desc
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 (no mimetype or no descrition)
1270  *
1271  * @pre
1272  *      None
1273  * @post
1274  *      None
1275  * @see
1276  *      aul_get_mime_extension
1277  * @code
1278  * #include <aul.h>
1279  *
1280  * void get_information_from_mime()
1281  * {
1282  *      char info[255];
1283  *      if(aul_get_mime_extension("text/html",info,sizeof(info))<0){
1284  *              aul_get_mime_description("text/html",info,sizeof(info));
1285  *      }
1286  * }
1287  *
1288  * @endcode
1289  * @remark
1290  *      None
1291  */
1292 int aul_get_mime_description(const char *mimetype, char *desc, int len);
1293
1294 /************************************************************************************************/
1295 /* Example of aul_open_content or aul_open_file                                                 */
1296 /* voice call , browser , docview , image viewer , audio player, video player                   */
1297 /*                                                                                              */
1298 /* voice call - aul_open_content("callto://011-1111-1111");                                     */
1299 /* browser -    aul_open_content("http://www.naver.com");                                       */
1300 /*         -    aul_open_file("/opt/share/index.html");                                         */
1301 /* docview -    aul_open_file("/opt/share/word.pdf");                                           */
1302 /* image view - aul_open_file("/opt/share/image.jpg");                                          */
1303 /* audio play - aul_open_file("/opt/share/audio.mp3");                                          */
1304 /* video play - aul_open_file("/opt/share/video.mpg");                                          */
1305 /************************************************************************************************/
1306
1307 /** @} */
1308
1309 /**
1310  * @defgroup aul_service High-level APIs to launch applications based on service.
1311  * @ingroup aul
1312  * @brief
1313  *      AUL High-level APIs based on service
1314  *
1315  *      This is Request/Response mechanism based on AUL like DBUS service call with auto-activation.\n
1316  *      We recommend this APIs for requesting application service like camera application service (take_picture)
1317  *      But, You can use other mechanism like DBUS service or your own internal IPC
1318  *
1319  *      - Caller\n
1320  *        Launch application based on service \n
1321  *        If application is not running, AUL requests to reset the event.\n
1322  *        Application can wait result with callback function.
1323  *
1324  *      - Callee\n
1325  *        After callee performs the requested operation, callee sends the result back, if necessary.\n
1326  *
1327  */
1328
1329 /**
1330  * @addtogroup aul_service
1331  * @{
1332  */
1333
1334 /**
1335  * @brief aul_service_res_fn is service result function
1336  * @param[out]  b       result bundle
1337  * @param[out]  data    user-supplied data
1338 */
1339 typedef void (*aul_service_res_fn)(bundle *b, int reserved, void *user_data);
1340
1341 /**
1342  * @par Description:
1343  *      This API launch application based on service.
1344  * @par Purpose:
1345  *      This API is for caller.
1346  *      This API launch application based on service name.
1347  *      This API find default application associated with service name.
1348  *      and then launch the application with given bundle.
1349  * @par Typical use case:
1350  *      You can launch application provided the service if you know service name.
1351  *      That is, even if you don't know the specific application's pkgname,
1352  *      you can launch the applicaiton by requesting the service.
1353  *      For example, If you want to take a picture in your app, you can simply launch camera application.
1354  *      At that time, you can use this API like aul_open_service(TAKE_PICTURE_SVC,..);
1355  *
1356  *
1357  * @param[in]   svcname         service name to launch as callee
1358  * @param[in]   b               bundle to be passed to callee
1359  * @param[in]   cbfunc          result callback function
1360  * @param[in]   data            user-supplied data passed to callback function
1361  * @return      callee's pid if success, negative value(<0) if fail
1362  * @retval      AUL_R_OK        - success
1363  * @retval      AUL_R_EINVAL    - invaild service name
1364  * @retval      AUL_R_ENOINIT   - you must initilize aul library with aul_launch_init
1365  * @retval      AUL_R_ECOM      - internal AUL IPC error
1366  * @retval      AUL_R_ERROR     - general error
1367  *
1368  * @pre
1369  *      None
1370  * @post
1371  *      None
1372  * @see
1373  *      None
1374  * @code
1375  * #include <aul.h>
1376  * #include <aul_service.h>
1377  * #include <bundle.h>
1378  *
1379  * void res_func(bundle *b, int reserved, void *user_data)
1380  * {
1381  *      // process result bundle
1382  * }
1383  *
1384  * int create_camera_view()
1385  * {
1386  *      aul_open_service(TAKE_PICTURE_SVC, NULL, res_func, NULL);
1387  * }
1388  *
1389  * @endcode
1390  * @remark
1391  *      This API can wait result (asynchronous).
1392  *      To see kinds of default service provided by platform, see "aul_service.h" header file
1393  *
1394  */
1395 int aul_open_service(const char *svcname, bundle *b, aul_service_res_fn cbfunc, void *data);
1396
1397 /**
1398  * @par Description:
1399  *      This API create service result bundle based on bundle received in reset event.
1400  * @par Purpose:
1401  *      This API use to create result bundle to send it to caller.
1402  * @par Typical use case:
1403  *      This API is for callee which provide application service.\n
1404  *      To send result to caller, You must create result bundle. \n
1405  *      Callee(application providing the service) can send result by using this API and aul_send_service_result.
1406  *
1407  * @param[in]   inb             bundle received in reset event
1408  * @param[out]  outb            bundle to use for returning result
1409  * @return      0 if success, negative value(<0) if fail
1410  * @retval      AUL_R_OK        - success
1411  * @retval      AUL_R_EINVAL    - inb is not bundle created by aul_open_service
1412  * @retval      AUL_R_ERROR     - general error
1413  *
1414  * @pre
1415  *      To create result bundle, You need received original bundle.
1416  *      The original bundle can get from app_reset handler.
1417  * @post
1418  *      None
1419  * @see
1420  *      aul_send_service_result
1421  * @code
1422  * #include <aul.h>
1423  * #include <bundle.h>
1424  *
1425  * int app_reset(bundle *b, void *data)
1426  * {
1427  *      ad->recved_bundle = bundle_dup(b);
1428  * }
1429  *
1430  * int click_ok()
1431  * {
1432  *      bundle* res_bundle;
1433  *      aul_create_result_bundle(ad->recved_bundle,&res_bundle);
1434  *      bundle_add(res_bundle, "result", "1");
1435  *      aul_send_service_result(res_bundle);
1436  * }
1437  * @endcode
1438  * @remark
1439  *      None
1440  *
1441  */
1442 int aul_create_result_bundle(bundle *inb, bundle **outb);
1443
1444 /**
1445  * @par Description:
1446  *      This API send service result to caller with bundle
1447  * @par Purpose:
1448  *      This API is used to send result bundle to caller.
1449  * @par Typical use case:
1450  *      This API is for callee which provide application service.\n
1451  *      To send result to caller, You can use this API after creating result bundle. \n
1452  *      Callee(application to provide service) can send result by using this API and aul_create_result_bundle.
1453  *
1454  * @param[in]   b      Result data in bundle format
1455  * @return      0 if success, negative value(<0) if fail
1456  * @retval      AUL_R_OK        - success
1457  * @retval      AUL_R_EINVAL    - invalid result bundle
1458  * @retval      AUL_R_ECOMM     - internal AUL IPC error
1459  * @retval      AUL_R_ERROR     - general error
1460  *
1461  * @pre
1462  *      To send result bundle, You must create result bundle.
1463  *      see aul_create_result_bundle
1464  * @post
1465  *      None
1466  * @see
1467  *      aul_create_result_bundle
1468  * @code
1469  * #include <aul.h>
1470  * #include <bundle.h>
1471  *
1472  * int app_reset(bundle *b, void *data)
1473  * {
1474  *      ad->recved_bundle = bundle_dup(b);
1475  * }
1476  *
1477  * int click_ok()
1478  * {
1479  *      bundle* res_bundle;
1480  *      aul_create_result_bundle(ad->recved_bundle,&res_bundle);
1481  *      bundle_add(res_bundle, "result", "1");
1482  *      aul_send_service_result(res_bundle);
1483  * }
1484  * @endcode
1485  * @remark
1486  *      None
1487  *
1488  */
1489 int aul_send_service_result(bundle *b);
1490
1491 /**
1492  * @par Description:
1493  *      This API set the default application(appid) associated with service name
1494  * @par Purpose:
1495  *      This API use to change default application associteted with service name
1496  *      In general, Setting Application needs this API.
1497  * @par Typical use case:
1498  *      Default Application associated with service name can be changed by Setting Application
1499  *      So, Inhouse service application can be substituted by 3rd party service application
1500  *
1501  * @param[in]   svcname         service string like "create_contact"
1502  * @param[in]   defapp          default application like "org.tizen.contact"
1503  * @return      0 if success, negative value if fail
1504  * @retval      AUL_R_OK        - success
1505  * @retval      AUL_R_EINVAL    - invalid argument(content)
1506  * @retval      AUL_R_ERROR     - general error
1507  *
1508  * @pre
1509  *      None
1510  * @post
1511  *      None
1512  * @see
1513  *      aul_get_defapp_for_service
1514  * @code
1515  * #include <aul.h>
1516  * #include <aul_service.h>
1517  *
1518  * void set_camera_service_defapp()
1519  * {
1520  *      aul_set_defapp_for_service(TAKE_PICTURE_SVC,"org.tizen.camera");
1521  * }
1522  *
1523  * @endcode
1524  * @remark
1525  *      None
1526  *
1527  */
1528 int aul_set_defapp_for_service(const char *svcname, const char *defapp);
1529
1530 /**
1531  * @par Description:
1532  *      This API get the application appid associated with given service name
1533  * @par Purpose:
1534  *      This API use to get default application associteted with service name
1535  *      In general, Setting Application need this API.
1536  * @par Typical use case:
1537  *      Setting Application show mapping of default application/ service
1538  *
1539  * @param[in]   svcname         service string like "create_contact"
1540  * @param[out]  defapp          default application
1541  * @param[in]   len             length of defapp
1542  * @return      0 if success, negative value if fail
1543  * @retval      AUL_R_OK        - success
1544  * @retval      AUL_R_EINVAL    - invalid argument(content)
1545  * @retval      AUL_R_ERROR     - general error
1546  *
1547  * @pre
1548  *      None
1549  * @post
1550  *      None
1551  * @see
1552  *      aul_set_defapp_for_service
1553  * @code
1554  * #include <aul.h>
1555  * #include <aul_service.h>
1556  *
1557  * void get_camera_service_defapp()
1558  * {
1559  *      char appname[255];
1560  *      aul_get_defapp_for_service(TAKE_PICTURE_SVC,appname,sizeof(appname));
1561  * }
1562  *
1563  * @endcode
1564  * @remark
1565  *      None
1566  *
1567  */
1568 int aul_get_defapp_for_service(const char *svcname, char *defapp, int len);
1569
1570 /**
1571  * @par Description:
1572  *      This API sets callback fuction that will be called when applications die.
1573  * @par Purpose:
1574  *      This API's purpose is to listen the application dead event.
1575  *      In general, task manager Application need this API.
1576  *
1577  * @param[in]   func            callback function
1578  * @param[in]   data            user data
1579  * @return      0 if success, negative value if fail
1580  * @retval      AUL_R_OK        - success
1581  * @retval      AUL_R_ERROR     - general error
1582  *
1583  * @pre
1584  *      None
1585  * @post
1586  *      None
1587  * @see
1588  *      aul_listen_app_launch_signal
1589  * @code
1590  * #include <aul.h>
1591  *
1592  * int app_dead_handler(int pid, void *data)
1593  * {
1594  *      printf("===> %s : %d\n", __FUNCTION__, pid);
1595  *      return 0;
1596  * }
1597  *
1598  * void dead_listen()
1599  * {
1600  *      aul_listen_app_dead_signal(app_dead_handler, NULL);
1601  * }
1602  *
1603  * @endcode
1604  * @remark
1605  *      None
1606  *
1607  */
1608 int aul_listen_app_dead_signal(int (*func) (int, void *), void *data);
1609
1610 /**
1611  * @par Description:
1612  *      This API sets callback fuction that will be called when applications are launched.
1613  * @par Purpose:
1614  *      This API's purpose is to listen the application launching event.
1615  *      In general, task manager Application need this API.
1616  *
1617  * @param[in]   func            callback function
1618  * @param[in]   data            user data
1619  * @return      0 if success, negative value if fail
1620  * @retval      AUL_R_OK        - success
1621  * @retval      AUL_R_ERROR     - general error
1622  *
1623  * @pre
1624  *      None
1625  * @post
1626  *      None
1627  * @see
1628  *      aul_listen_app_dead_signal
1629  * @code
1630  * #include <aul.h>
1631  *
1632  * int app_launch_handler(int pid, void *data)
1633  * {
1634  *      printf("===> %s : %d\n", __FUNCTION__, pid);
1635  *      return 0;
1636  * }
1637  *
1638  * void dead_listen()
1639  * {
1640  *      aul_listen_app_launch_signal(app_launch_handler, NULL);
1641  * }
1642  *
1643  * @endcode
1644  * @remark
1645  *      None
1646  *
1647  */
1648 int aul_listen_app_launch_signal(int (*func) (int, void *), void *data);
1649
1650
1651 typedef int (*subapp_fn)(void *data);
1652
1653 int aul_set_subapp(subapp_fn cb, void *data);
1654 int aul_subapp_terminate_request_pid(int pid);
1655 int aul_is_subapp(void);
1656 int aul_add_caller_cb(int pid,  void (*caller_cb) (int, void *), void *data);
1657 int aul_remove_caller_cb(int pid);
1658
1659 void aul_set_preinit_window(void *evas_object);
1660 void* aul_get_preinit_window(void);
1661
1662 void aul_set_preinit_appid(const char *appid);
1663
1664 int aul_launch_app_async(const char *appid, bundle *kb);
1665
1666 int aul_status_update(int status);
1667
1668
1669 /** @} */
1670
1671
1672
1673 #ifdef __cplusplus
1674         }
1675 #endif
1676
1677
1678 #endif          /* __AUL_H__ */
1679
1680 /* vi: set ts=8 sts=8 sw=8: */