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