4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
28 #include <sys/types.h>
37 * This is new version of Application Utility Library
39 * Almost function's input param is application package name(APN).\n
40 * APN is application package name which is set by developer.\n
41 * In case of in-house application, prefix is org.tizen.\n
42 * It is different from debian package name.\n
44 * - Debian Package Name : Name which is managed by package manager
45 * - Application Package Name : Name which is used by AUL
46 * - Execution Path : real program executable path
51 * @ingroup APPLICATION_FRAMEWORK
52 * @defgroup aul Application Utility Library
59 * @brief Application Utility Library header
61 * Patched by Knhoon Baik <knhoon.baik@samsung.com>
62 * Patched by Youmin Ha <youmin.ha@samsung.com>
71 * @brief Return values in AUL.
73 typedef enum _aul_return_val {
74 AUL_R_ENOAPP = -11, /**< Failed to find app ID or pkg ID */
75 AUL_R_ENOLAUNCHPAD = -10, /**< no launchpad */
76 AUL_R_ETERMINATING = -9, /**< application terminating */
77 AUL_R_EILLACC = -8, /**< Illegal Access */
78 AUL_R_LOCAL = -7, /**< Launch by himself */
79 AUL_R_ETIMEOUT = -6, /**< Timeout */
80 AUL_R_ECANCELED = -5, /**< Operation canceled */
81 AUL_R_EINVAL = -4, /**< Invalid argument */
82 AUL_R_ECOMM = -3, /**< Comunication Error */
83 AUL_R_ENOINIT = -2, /**< AUL handler NOT initialized */
84 AUL_R_ERROR = -1, /**< General error */
85 AUL_R_OK = 0 /**< General success */
101 * @defgroup aul_launch Primitive APIs to launch/resume/terminate application
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)
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)
119 * @addtogroup aul_launch
123 typedef enum _aul_type{
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__"
144 /** AUL internal private key */
145 #define AUL_K_NO_CANCEL "__AUL_NO_CANCEL__"
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__"
152 /** AUL public key - added for multiuser mode */
153 #define AUL_K_CALLER_UID "__AUL_CALLER_UID__"
154 /** AUL public key - added for multiuser mode */
155 #define AUL_K_CALLEE_UID "__AUL_CALLEE_UID__"
157 /** AUL public key - To check caller's secuirty */
158 #define AUL_K_CALLER_APPID "__AUL_CALLER_APPID__"
159 /** AUL public key - To check caller's secuirty */
160 #define AUL_K_CALLEE_APPID "__AUL_CALLEE_APPID__"
162 /** AUL public key - To find argv0 */
163 #define AUL_K_ARGV0 "__AUL_ARGV0__"
164 /** AUL public key - To measure launching time */
165 #define AUL_K_STARTTIME "__AUL_STARTTIME__"
167 /** AUL public key - To support launching based on mime type */
168 #define AUL_K_MIME_TYPE "__AUL_MIME_TYPE__"
169 /** AUL public key - To support launching based on mime type */
170 #define AUL_K_UNALIASED_MIME_TYPE "__AUL_UNALIASED_MIME_TYPE__"
171 /** AUL public key - To support launching based on mime type */
172 #define AUL_K_MIME_CONTENT "__AUL_MIME_CONTENT__"
174 /** AUL public key - To support launching based on service */
175 #define AUL_K_SERVICE_NAME "__AUL_SERVICE_NAME__"
177 /** AUL public key - To force launch app selector instead of lauchingn default app */
178 #define AUL_K_FORCE_LAUNCH_APP_SELECTOR "__AUL_FORCE_LAUNCH_APP_SELECTOR__"
180 /** AUL public key - To support debug argument */
181 #define AUL_K_DEBUG "__AUL_DEBUG__"
183 /** AUL public key - To support SDK */
184 #define AUL_K_SDK "__AUL_SDK__"
186 /** AUL public key - To support Media key */
187 #define AUL_K_MULTI_KEY "__AUL_MULTI_KEY__"
188 /** AUL public key - To support Media key */
189 #define AUL_K_MULTI_KEY_EVENT "__AUL_MULTI_KEY_EVENT__"
191 /** AUL public bundle value */
192 #define AUL_K_PRIVACY_APPID "__AUL_PRIVACY_APPID__"
195 /** AUL public bundle value - To support Media key*/
196 #define AUL_V_KEY_PRESSED "__AUL_KEY_PRESSED__"
197 /** AUL public bundle value - To support Media key*/
198 #define AUL_V_KEY_RELEASED "__AUL_KEY_RELEASED__"
200 /** AUL internal private key */
201 #define AUL_K_EXEC "__AUL_EXEC__"
202 /** AUL internal private key */
203 #define AUL_K_MULTIPLE "__AUL_MULTIPLE__"
204 /** AUL internal private key */
205 #define AUL_K_PACKAGETYPE "__AUL_PACKAGETYPE__"
206 /** AUL internal private key */
207 #define AUL_K_HWACC "__AUL_HWACC__"
210 /** AUL internal private key */
211 #define AUL_K_APPID "__AUL_APPID__"
212 /** AUL internal private key */
213 #define AUL_K_PID "__AUL_PID__"
214 /** AUL internal private key - To support data control*/
215 #define AUL_K_DATA_CONTROL_TYPE "__AUL_DATA_CONTROL_TYPE__"
217 #define PRIVACY_POPUP "tizenprv00.privacy-popup"
221 * @brief This is callback function for aul_launch_init
222 * @param[in] type event's type received from system
223 * @param[in] b In case of RESET events, bundle which is received from peer
224 * @param[in] data user-supplied data
226 typedef int (*aul_handler_fn) (aul_type type, bundle * b, void *data);
230 * This API install your AUL handler and setup AUL internal connection.
232 * AUL receive START(RESET), RESUME, TERMINATE events from system.\n
233 * This API use to handle the events. \n
234 * @par Typical use case:
235 * In general, you need not use this API.
236 * If you use AppCore, you should NOT use this API.
237 * AppCore will set default aul_handler.
239 * @param[in] handler aul main callback handler function
240 * @param[in] data user-supplied data for start_handler
241 * @return 0 if success, negative value(<0) if fail\n
242 * @retval AUL_R_OK - success
243 * @retval AUL_R_ECANCELD - aul handler was installed already by others
244 * @retval AUL_R_ECOMM - error to create internal ipc
245 * @retval AUL_R_ERROR - error to attach glib main loop
247 * @warning If you use AppCore, you should NOT use this API.\n
248 * You need glib main loop.\n
250 * you must have aul handler to use this API.
251 * aul_luanch_init register aul handler.
258 * #include <bundle.h>
260 * static int aul_handler(aul_type type, bundle *kb,void *data)
265 * // process RESET event
268 * // process RESUME event
270 * case AUL_TERMINATE:
271 * // preocess TERMINATE event
277 * static GMainLoop *mainloop = NULL;
279 * int main(int argc, char **argv)
281 * aul_launch_init(aul_handler,NULL);
282 * aul_launch_argv_handler(argc, argv);
284 * mainloop = g_main_loop_new(NULL, FALSE);
285 * g_main_loop_run(mainloop);
292 int aul_launch_init(aul_handler_fn handler, void *data);
296 * This API create internal RESET events with given argc, argv \n
298 * This API's purpose is to generate reset event.
299 * If you want to generate local RESET events with argument vector format, use this API
300 * @par Typical use case:
301 * In general, you need not use this API.
302 * AppCore use this API to create internal reset event.
304 * @param[in] argc # of args
305 * @param[in] argv list of arg strings
306 * @return 0 if success, negative value(<0) if fail
307 * @retval AUL_R_OK - success
308 * @retval AUL_R_ENOINIT - aul handler was NOT yet installed
309 * @retval AUL_R_ECANCLED - error to create internal bundle with given argc,argv.
310 * @retval AUL_R_ERROR - general error
313 * you must have aul handler to use this API.
314 * aul_luanch_init register aul handler.
321 * #include <bundle.h>
323 * int send_local_reset_event()
327 * argv[0] = "local.app";
328 * argv[1] = "event_type";
329 * argv[2] = "my_reset";
331 * aul_launch_argv_handler(argc,argv);
336 * If you use AppCore, you NEED NOT use this API.
338 int aul_launch_argv_handler(int argc, char **argv);
342 * This API creates internal RESET events with given bundle \n
344 * This API's purpose is to generate reset event.
345 * If you want to generate local RESET events with argument vector format, first use
346 * bundle_import_from_argv to create a bundle from the argument vector and then use this API
347 * Eventually, this API will replace aul_launch_argv_handler().
348 * @par Typical use case:
349 * In general, you need not use this API.
350 * AppCore use this API to create internal reset event.
352 * @param[in] b bundle
353 * @return 0 if success, negative value(<0) if fail
354 * @retval AUL_R_OK - success
355 * @retval AUL_R_ENOINIT - aul handler was NOT yet installed
356 * @retval AUL_R_ERROR - general error
359 * you must have aul handler to use this API.
360 * aul_luanch_init register aul handler.
364 * aul_launch_init, bundle_import_from_argv
367 * #include <bundle.h>
369 * int send_local_reset_event()
374 * argv[0] = "local.app";
375 * argv[1] = "event_type";
376 * argv[2] = "my_reset";
379 * b = bundle_import_from_argv(argc,argv);
380 * aul_launch_local(b);
385 * If you use AppCore, you NEED NOT to use this API.
387 int aul_launch_local(bundle *b);
391 * This API launches application with the given bundle.
392 * If the application is not running or a multiple-instance one, this API launches with the given bundle.
393 * If the application is running, this API sends a RESET event to the App.
394 * While the application is running, if the application cannot receive the RESET event,
395 * this API returns a general error(AUL_R_ERROR).\n
397 * This API is for caller.
398 * This API's purpose is to launch/reset application with given bundle.
399 * @par Typical use case:
400 * If you know the target application's pkgname and bundle types,
401 * you can use this API to launch/reset the application.
403 * @param[in] pkgname package name to be run as callee
404 * @param[in] kb bundle to be passed to callee
405 * @return callee's pid if success, negative value(<0) if fail
406 * @retval AUL_R_OK - success
407 * @retval AUL_R_EINVAL - invaild package name
408 * @retval AUL_R_ECOM - internal AUL IPC error
409 * @retval AUL_R_ERROR - general error
419 * #include <bundle.h>
421 * int launch_inhouse_contact_app()
424 * b = bundle_create();
425 * bundle_add(b,"type","SIM");
426 * aul_launch_app("org.tizen.contact",b);
433 int aul_launch_app(const char *appid, bundle *kb);
437 * This API launches application, as menu screen launches the app.
438 * Thus, if the applocation is running, this API sends a RESUME event to the app.
439 * If the application is not running, this API launches the app.
440 * While the application is running, if the application cannot receive the RESUME event,
441 * AUL tries to raise the application's default window.
444 * This API is for caller.
445 * This API's purpose is to resume/launch application
446 * @par Typical use case:
447 * If you only want to show application with previous state or default state, Use this API.
449 * @param[in] pkgname package name to be resume as callee
450 * @return callee's pid if success, negative value(<0) if fail
451 * @retval AUL_R_OK - success
452 * @retval AUL_R_EINVAL - invaild package name
453 * @retval AUL_R_ECOM - internal AUL IPC error
454 * @retval AUL_R_ERROR - general error
461 * aul_launch_app, aul_app_is_running, aul_resume_pid
464 * #include <bundle.h>
466 * int open_inhouse_contact_app()
468 * if(aul_app_is_running("org.tizen.contact"))
469 * aul_open_app("org.tizen.contact");
474 * If you don't want to launch the app,
475 * you should check app's running state with aul_app_is_running.
476 * This API will launch the application if the application is not running.
478 int aul_open_app(const char *appid);
482 * This API trigger to resume application
483 * If the application is running, this API send a resume event to the App.
484 * If the application is not running, this API returns fail.
485 * Although the application is running, if the application cannot receive resume event,
486 * AUL try to raise the application's default windows.
488 * This API is for caller.
489 * This API's purpose is to send resume event.
490 * @par Typical use case:
491 * If you only want to show application with previous state or default state, Use this API.
493 * @param[in] pkgname package name to be resume as callee
494 * @return callee's pid if success, negative value(<0) if fail
495 * @retval AUL_R_OK - success
496 * @retval AUL_R_EINVAL - invaild package name
497 * @retval AUL_R_ECOM - internal AUL IPC error
498 * @retval AUL_R_ERROR - general error
505 * aul_launch_app, aul_app_is_running, aul_resume_pid
507 * This function will be deprecated. Use aul_open_add() instead.
510 * #include <bundle.h>
512 * int resume_inhouse_contact_app()
514 * if(aul_app_is_running("org.tizen.contact"))
515 * aul_resume_app("org.tizen.contact");
520 * If you don't want to launch the app,
521 * you should check app's running state with aul_app_is_running.
522 * This API will launch the application if the application is not running.
523 * If you want to only resume without launching in multiple instance application model,
524 * you should use aul_resume_pid.
526 int aul_resume_app(const char *appid);
530 * This API trigger to resume application
531 * If the application is running, this API send a resume event to the App.
532 * If the application is not running, this API return AUL_R_ERROR.
533 * Although the application is running, if the application cannot receive resume event,
534 * AUL try to raise the application's default windows.
536 * This API is for caller.
537 * This API's purpose is to send resume event.
538 * @par Typical use case:
539 * In multiple application model, If you want to only resume specific application, Use this API
541 * @param[in] pid application's pid to be resumed
542 * @return 0 if success, negative value(<0) if fail
543 * @retval AUL_R_OK - success
544 * @retval AUL_R_EINVAL - invaild pid
545 * @retval AUL_R_ECOM - internal AUL IPC error
546 * @retval AUL_R_ERROR - general error (include application is not running)
547 * @warning This API need to require root or inhouse permisssion \n
548 * If you have not the permission, this API return AUL_R_ERROR. \n
557 * #include <bundle.h>
559 * int iterfunc(const aul_app_info *info, void *data)
561 * if(strcmp(info->pkg_name,"org.tizen.contact")==0)
562 * aul_resume_pid(info->pid);
565 * int iterate_running_apps()
567 * return aul_app_get_running_app_info(iterfunc,NULL);
574 int aul_resume_pid(int pid);
578 * This API trigger to terminate application
580 * If the application is running, this API send a terminate event to the App. \n
581 * If the app cannot receive the event, AUL kill forcely the application.\n
583 * This API's purpose is to kill application
584 * @par Typical use case:
585 * In general, Application like Task Manager use this API.
587 * This API need to require root or inhouse permisssion. \n
589 * @param[in] pid application's pid to be terminated
590 * @return 0 if success, negative value(<0) if fail
591 * @retval AUL_R_OK - success
592 * @retval AUL_R_EINVAL - invaild pid
593 * @retval AUL_R_ECOM - internal AUL IPC error
594 * @retval AUL_R_ERROR - general error
595 * @warning This API need to require root or inhouse permisssion. \n
605 * #include <bundle.h>
607 * int iterfunc(const aul_app_info *info, void *data)
609 * if(strcmp(info->pkg_name,"org.tizen.contact")==0)
610 * aul_terminate_pid(info->pid);
613 * int iterate_running_apps()
615 * return aul_app_get_running_app_info(iterfunc,NULL);
620 * If you have not the permission, this API return AUL_R_ERROR. \n
622 int aul_terminate_pid(int pid);
627 * @defgroup aul_info Helper APIs to get running application information
630 * API to get running application information (state, executable path, ..)
631 * - get application package name from pid
632 * - get application running state
633 * - get application list of runnning applications
637 * @addtogroup aul_info
642 *@brief Running application's information structure retrieved by AUL
644 typedef struct _aul_app_info {
645 int pid; /**< app's pid if running*/
646 char* pkg_name; /**< application id */
647 char* app_path; /**< application excutable path */
652 * @brief iterator function running with aul_app_get_running_app_info
653 * @param[out] ainfo aul_app_info retreived by aul_app_get_running_app_info
654 * @param[out] data user-supplied data
656 typedef int (*aul_app_info_iter_fn)(const aul_app_info *ainfo, void *data);
660 * This API ask a application is running by application package name.
662 * To know whether some application is running or not, use this API
663 * @par Typical use case:
664 * For example, If you want to know browser application running,
665 * you can check it by using this API.
667 * @param[in] pkgname application package name
668 * @return true / false
669 * @retval 1 app_name is running now.
670 * @retval 0 app_name is NOT running now.
681 * int is_running_browser_app()
683 * return aul_app_is_running("org.tizen.browser");
691 int aul_app_is_running(const char *appid);
695 * This API use to get running application list.
696 * This API call iter_fn with each aul_app_info of running apps when running application is found.
698 * If you want to get running application list, use this API
699 * This API give you running applications which has SLP desktop file.
700 * @par Typical use case:
701 * In general, this API is used by task manager appllication. (running application list viewer)
703 * @param[in] iter_fn iterator function
704 * @param[in] data user-supplied data for iter_fn
705 * @return 0 if success, negative value(<0) if fail
706 * @retval AUL_R_OK - success
707 * @retval AUL_R_ERROR - internal error
718 * int iterfunc(const aul_app_info* info, void* data)
720 * printf("\t==========================\n");
721 * printf("\t pkg_name: %s\n", info->appid);
722 * printf("\t app_path: %s\n", info->app_path);
723 * printf("\t running pid: %d\n", info->pid);
724 * printf("\t==========================\n");
728 * int iterate_running_apps()
730 * return aul_app_get_running_app_info(iterfunc,NULL);
735 * This API should use if you want to know running application which has desktop files.
736 * If you want to get all process list, you must iterate process information by using proc filesystem
737 * Or, If you want to get all window list, you must iterate XWindows by using XWindow APIs
739 int aul_app_get_running_app_info(aul_app_info_iter_fn iter_fn, void *data);
743 * This API get application package name by pid
745 * If you want to get package name of running application, use this API
746 * @par Typical use case:
747 * In general, You can use this API when you want to know caller's information.
749 * @param[in] pid given pid
750 * @param[out] pkgname pkgname to be get
751 * @param[in] len length of pkgname
752 * @return 0 if success, negative value(<0) if fail
753 * @retval AUL_R_OK - success
754 * @retval AUL_R_ERROR - no such a package name
763 * #include <bundle.h>
765 * static int app_reset(bundle *b, void *data)
770 * pid = atoi(bundle_get_val(b,AUL_K_CALLER_PID));
771 * aul_app_get_pkgname_bypid(pid, appname, sizeof(appname));
778 int aul_app_get_pkgname_bypid(int pid, char *pkgname, int len);
782 * This API get application appid by pid
784 * If you want to get appid of running application, use this API
785 * @par Typical use case:
786 * In general, You can use this API when you want to know caller's information.
788 * @param[in] pid given pid
789 * @param[out] appid application id
790 * @param[in] len length of pkgname
791 * @return 0 if success, negative value(<0) if fail
792 * @retval AUL_R_OK - success
793 * @retval AUL_R_ERROR - no such a appid
802 * #include <bundle.h>
804 * static int app_reset(bundle *b, void *data)
809 * pid = atoi(bundle_get_val(b,AUL_K_CALLER_PID));
810 * aul_app_get_appid_bypid(pid, appid, sizeof(appid));
817 int aul_app_get_appid_bypid(int pid, char *appid, int len);
823 * @defgroup aul_mime High-level APIs to launch default application based on mime type
826 * AUL High-level APIs based on mime type
828 * These APIs provide two functionality\n
830 * -# To launch default application to open a file based on its MIME type \n
831 * For example, you can launch the default video player to open .mp4 files
832 * or launch the default browser to open HTML files \n
833 * -# To launch default application to process given content \n
834 * For example, you can launch the default e-mail application to process
835 * "nice@samsung.com" e-mail address.
839 * @addtogroup aul_mime
845 * This API launch application associated with given filename
847 * This API is for caller.
848 * This API launch application based on mime type.
849 * This API find mime_type associated with file name,
850 * and then find default app associated with found mime_type
851 * and then launch the app with filename argument.
852 * @par Typical use case:
853 * You can launch application to process given filename.
854 * That is, Even if you don't know the specific application's pkgname,
855 * you can launch the applicaiton processing given filename .
856 * For example, If you want to process image file, you can simply launch image viewer.
857 * At that time, you can use this APIs like aul_open_file("myimage.jpg");
859 * @param[in] filename filename
860 * @return callee's pid or 0 if success, negative value if fail\n
861 * (when no found default app, return 0)
862 * @retval AUL_R_OK - success
863 * @retval AUL_R_EINVAL - invalid argument(filename)
864 * @retval AUL_R_ECOM - internal AUL IPC error
865 * @retval AUL_R_ERROR - general error
876 * int view_image_file(char *filename)
878 * aul_open_file(filename);
886 int aul_open_file(const char* filename);
890 * This API launch application associated with given specific mimetype
892 * This API is for caller.
893 * This API launch application based on mime type like aul_open_file API.
894 * But, This API don't find mime_type associated with file name.
895 * This API use mimetype given by user. By using given mimetype, find default application.
896 * and then launch the app with filename argument.
897 * @par Typical use case:
898 * Some files cannot extract exact mimetype automatically.
899 * For example, To know mime type of files with DRM lock, first we should unlock DRM file.
900 * In this case, You can use this API.
901 * First, unlock DRM file, and extract mimetype from unlock file by using aul_get_mime_from_file,
902 * and then, use this API with DRM file and extracted mime type.
904 * @param[in] filename filename
905 * @param[in] mimetype specific mimetype
906 * @return callee's pid or 0 if success, negative value if fail\n
907 * (when no found default app, return 0)
908 * @retval AUL_R_OK - success
909 * @retval AUL_R_EINVAL - invalid argument(filename,mimetype)
910 * @retval AUL_R_ECOM - internal AUL IPC error
911 * @retval AUL_R_ERROR - general error
918 * aul_open_file, aul_get_mime_from_file
922 * int view_drm_image_file(char *drm_filename)
925 * // you must implement this function
926 * mimetype = get_mimetype_from_drmfile(drm_filename);
928 * aul_open_file_with_mimetype(drm_filename,mimetype);
935 int aul_open_file_with_mimetype(const char *filename, const char *mimetype);
939 * This API launch application associated with content like "http://www.samsung.com"
941 * This API is for caller.
942 * This API launch application based on mime type.
943 * This API find mime_type associated with content,
944 * and then find default app associated with found mime_type,
945 * and then launch the app with content argument.
946 * @par Typical use case:
947 * You can launch application to process given content.
948 * That is, Even if you don't know the specific application's pkgname,
949 * you can launch the applicaiton processing given content.
950 * For example, If you want to process URL "http://www.samsung.com",
951 * you can simply launch browser.
952 * At that time, you can use this APIs like aul_open_content("http://www.samsung.com");
954 * @param[in] content content
955 * @return callee's pid or 0 if success, negative value if fail\n
956 * (when no found default app, return 0)
957 * @retval AUL_R_OK - success
958 * @retval AUL_R_EINVAL - invalid argument(content)
959 * @retval AUL_R_ECOM - internal AUL IPC error
960 * @retval AUL_R_ERROR - general error or no found mimetype
971 * int view_url(char *url)
973 * aul_open_content(url);
981 int aul_open_content(const char* content);
985 * This API get the default application(appid) associated with MIME type
987 * This API use to get default application associteted with mimetype
988 * In general, Setting Application need this API.
989 * @par Typical use case:
990 * Setting Application show mapping of default application / mimetype
992 * @param[in] mimetype a mime type
993 * @param[out] defapp a application appid of the app
994 * @param[in] len length of defapp
995 * @return 0 if success, negative value if fail
996 * @retval AUL_R_OK - success
997 * @retval AUL_R_EINVAL - invalid argument(mimetype)
998 * @retval AUL_R_ERROR - general error or no found mimetype
1005 * aul_set_defapp_with_mime
1009 * void get_text_html_defapp()
1011 * char appname[255];
1012 * aul_get_defapp_from_mime("text/html",appname,sizeof(appname));
1020 int aul_get_defapp_from_mime(const char *mimetype, char *defapp, int len);
1024 * This API set the default application(appid) associated with MIME type
1026 * This API use to change default application associteted with mimetype
1027 * In general, Setting Application or Installer need this API.
1028 * @par Typical use case:
1029 * Default Application associated with mimetype can be changed by Setting Application or installer
1030 * So, application to process specific mimetype can be substituted.
1032 * @param[in] mimetype a mime type
1033 * @param[in] defapp a application appid of the app to be set
1034 * @return 0 if success, negative value if fail
1035 * @retval AUL_R_OK - success
1036 * @retval AUL_R_EINVAL - invalid argument(mimetype)
1037 * @retval AUL_R_ERROR - general error
1044 * aul_get_defapp_from_mime
1048 * void set_text_html_defapp()
1050 * aul_set_defapp_with_mime("text/html","org.tizen.browser");
1057 int aul_set_defapp_with_mime(const char *mimetype, const char *defapp);
1061 * This API get the mimetype associated with filename
1063 * This API use to get mimetype associteted with given filename
1064 * In general, This API use when you want to know only mimetype given filename.
1065 * @par Typical use case:
1066 * For example, In trasfering data through bluetooth,
1067 * additional information like mimetype should be added.
1068 * In such situation, You can get mimetype by using this API.
1070 * @param[in] filename file name
1071 * @param[out] mimetype a mime type
1072 * @param[in] len length of mimetype
1073 * @return 0 if success, negative value if fail
1074 * @retval AUL_R_OK - success
1075 * @retval AUL_R_EINVAL - invalid argument(filename)
1076 * @retval AUL_R_ERROR - general error
1087 * void get_mimetype()
1089 * char mimetype[255];
1090 * aul_get_mime_from_file("image.jpg",mimetype,sizeof(mimetype));
1097 int aul_get_mime_from_file(const char *filename, char *mimetype, int len);
1101 * This API get the mimetype associated with given content
1103 * This API use to get mimetype associteted with given content
1104 * In general, This API use when you want to know only mimetype given content
1105 * @par Typical use case:
1106 * For example, In trasfering data through bluetooth,
1107 * additional information like mimetype should be added.
1108 * In such situation, You can get mimetype by using this API.
1110 * @param[in] content content string like "011-0000-0000"
1111 * @param[out] mimetype a mime type
1112 * @param[in] len length of mimetype
1113 * @return 0 if success, negative value if fail
1114 * @retval AUL_R_OK - success
1115 * @retval AUL_R_EINVAL - invalid argument(content)
1116 * @retval AUL_R_ERROR - general error
1127 * void get_mimetype()
1129 * char mimetype[255];
1130 * aul_get_mime_from_content("http://www.samsung.com",mimetype,sizeof(mimetype));
1137 int aul_get_mime_from_content(const char *content, char *mimetype, int len);
1141 * This API get the icon's name associated with given mimetype
1143 * This API use to get icon's name associteted with given mimetype
1144 * @par Typical use case:
1145 * If you want to show mimetype's icon, use this API.
1147 * @param[in] mimetype a mime type
1148 * @param[out] iconname icon's name
1149 * @param[in] len length of iconname
1150 * @return 0 if success, negative value if fail
1151 * @retval AUL_R_OK - success
1152 * @retval AUL_R_EINVAL - invalid argument(content)
1153 * @retval AUL_R_ERROR - general error (no such mime type)
1164 * void get_mime_icon()
1167 * aul_get_mime_icon("text/html",icon,sizeof(icon));
1174 int aul_get_mime_icon(const char *mimetype, char *iconname, int len);
1178 * This API get the extensions associated with given mimetype
1180 * This API use to get extensions associteted with given mimetype
1181 * @par Typical use case:
1182 * In general, user is not familiar with mimetype(text/html),
1183 * user is familiar with extenstions(*.html, *.htm)
1184 * So, To show mimetype information to user, use this API
1186 * @param[in] mimetype a mime type
1187 * @param[out] extlist extentions (ex> mpeg,mpg,mpe)
1188 * @param[in] len length of extlist
1189 * @return 0 if success, negative value if fail
1190 * @retval AUL_R_OK - success
1191 * @retval AUL_R_EINVAL - invalid argument(mimetype)
1192 * @retval AUL_R_ERROR - general error (no mimetype or no extenstion)
1199 * aul_get_mime_description
1203 * void get_extension()
1205 * char extlist[255];
1206 * aul_get_mime_extension("text/html",extlist,sizeof(extlist));
1211 * Some mimetype don't have extension.
1212 * In that case, You can use aul_get_mime_description.
1215 int aul_get_mime_extension(const char *mimetype, char *extlist, int len);
1219 * This API get the description associated with given mimetype
1221 * This API use to get description associteted with given mimetype
1222 * @par Typical use case:
1223 * In general, user is not familiar with mimetype(text/html),
1224 * user is familiar with well-knowing information like extenstions(*.html, *.htm)
1225 * But, some mimetype don't have extenstion.
1226 * At that time,to show mimetype information to user, use this API
1228 * @param[in] mimetype a mime type
1229 * @param[out] desc description (ex> Call client)
1230 * @param[in] len length of desc
1231 * @return 0 if success, negative value if fail
1232 * @retval AUL_R_OK - success
1233 * @retval AUL_R_EINVAL - invalid argument(mimetype)
1234 * @retval AUL_R_ERROR - general error (no mimetype or no descrition)
1241 * aul_get_mime_extension
1245 * void get_information_from_mime()
1248 * if(aul_get_mime_extension("text/html",info,sizeof(info))<0){
1249 * aul_get_mime_description("text/html",info,sizeof(info));
1257 int aul_get_mime_description(const char *mimetype, char *desc, int len);
1259 /************************************************************************************************/
1260 /* Example of aul_open_content or aul_open_file */
1261 /* voice call , browser , docview , image viewer , audio player, video player */
1263 /* voice call - aul_open_content("callto://011-1111-1111"); */
1264 /* browser - aul_open_content("http://www.naver.com"); */
1265 /* - aul_open_file("/opt/share/index.html"); */
1266 /* docview - aul_open_file("/opt/share/word.pdf"); */
1267 /* image view - aul_open_file("/opt/share/image.jpg"); */
1268 /* audio play - aul_open_file("/opt/share/audio.mp3"); */
1269 /* video play - aul_open_file("/opt/share/video.mpg"); */
1270 /************************************************************************************************/
1275 * @defgroup aul_service High-level APIs to launch applications based on service.
1278 * AUL High-level APIs based on service
1280 * This is Request/Response mechanism based on AUL like DBUS service call with auto-activation.\n
1281 * We recommend this APIs for requesting application service like camera application service (take_picture)
1282 * But, You can use other mechanism like DBUS service or your own internal IPC
1285 * Launch application based on service \n
1286 * If application is not running, AUL requests to reset the event.\n
1287 * Application can wait result with callback function.
1290 * After callee performs the requested operation, callee sends the result back, if necessary.\n
1295 * @addtogroup aul_service
1300 * @brief aul_service_res_fn is service result function
1301 * @param[out] b result bundle
1302 * @param[out] data user-supplied data
1304 typedef void (*aul_service_res_fn)(bundle *b, int reserved, void *user_data);
1308 * This API launch application based on service.
1310 * This API is for caller.
1311 * This API launch application based on service name.
1312 * This API find default application associated with service name.
1313 * and then launch the application with given bundle.
1314 * @par Typical use case:
1315 * You can launch application provided the service if you know service name.
1316 * That is, even if you don't know the specific application's pkgname,
1317 * you can launch the applicaiton by requesting the service.
1318 * For example, If you want to take a picture in your app, you can simply launch camera application.
1319 * At that time, you can use this API like aul_open_service(TAKE_PICTURE_SVC,..);
1322 * @param[in] svcname service name to launch as callee
1323 * @param[in] b bundle to be passed to callee
1324 * @param[in] cbfunc result callback function
1325 * @param[in] data user-supplied data passed to callback function
1326 * @return callee's pid if success, negative value(<0) if fail
1327 * @retval AUL_R_OK - success
1328 * @retval AUL_R_EINVAL - invaild service name
1329 * @retval AUL_R_ENOINIT - you must initilize aul library with aul_launch_init
1330 * @retval AUL_R_ECOM - internal AUL IPC error
1331 * @retval AUL_R_ERROR - general error
1341 * #include <aul_service.h>
1342 * #include <bundle.h>
1344 * void res_func(bundle *b, int reserved, void *user_data)
1346 * // process result bundle
1349 * int create_camera_view()
1351 * aul_open_service(TAKE_PICTURE_SVC, NULL, res_func, NULL);
1356 * This API can wait result (asynchronous).
1357 * To see kinds of default service provided by platform, see "aul_service.h" header file
1360 int aul_open_service(const char *svcname, bundle *b, aul_service_res_fn cbfunc, void *data);
1364 * This API create service result bundle based on bundle received in reset event.
1366 * This API use to create result bundle to send it to caller.
1367 * @par Typical use case:
1368 * This API is for callee which provide application service.\n
1369 * To send result to caller, You must create result bundle. \n
1370 * Callee(application providing the service) can send result by using this API and aul_send_service_result.
1372 * @param[in] inb bundle received in reset event
1373 * @param[out] outb bundle to use for returning result
1374 * @return 0 if success, negative value(<0) if fail
1375 * @retval AUL_R_OK - success
1376 * @retval AUL_R_EINVAL - inb is not bundle created by aul_open_service
1377 * @retval AUL_R_ERROR - general error
1380 * To create result bundle, You need received original bundle.
1381 * The original bundle can get from app_reset handler.
1385 * aul_send_service_result
1388 * #include <bundle.h>
1390 * int app_reset(bundle *b, void *data)
1392 * ad->recved_bundle = bundle_dup(b);
1397 * bundle* res_bundle;
1398 * aul_create_result_bundle(ad->recved_bundle,&res_bundle);
1399 * bundle_add(res_bundle, "result", "1");
1400 * aul_send_service_result(res_bundle);
1407 int aul_create_result_bundle(bundle *inb, bundle **outb);
1411 * This API send service result to caller with bundle
1413 * This API is used to send result bundle to caller.
1414 * @par Typical use case:
1415 * This API is for callee which provide application service.\n
1416 * To send result to caller, You can use this API after creating result bundle. \n
1417 * Callee(application to provide service) can send result by using this API and aul_create_result_bundle.
1419 * @param[in] b Result data in bundle format
1420 * @return 0 if success, negative value(<0) if fail
1421 * @retval AUL_R_OK - success
1422 * @retval AUL_R_EINVAL - invalid result bundle
1423 * @retval AUL_R_ECOMM - internal AUL IPC error
1424 * @retval AUL_R_ERROR - general error
1427 * To send result bundle, You must create result bundle.
1428 * see aul_create_result_bundle
1432 * aul_create_result_bundle
1435 * #include <bundle.h>
1437 * int app_reset(bundle *b, void *data)
1439 * ad->recved_bundle = bundle_dup(b);
1444 * bundle* res_bundle;
1445 * aul_create_result_bundle(ad->recved_bundle,&res_bundle);
1446 * bundle_add(res_bundle, "result", "1");
1447 * aul_send_service_result(res_bundle);
1454 int aul_send_service_result(bundle *b);
1458 * This API set the default application(appid) associated with service name
1460 * This API use to change default application associteted with service name
1461 * In general, Setting Application needs this API.
1462 * @par Typical use case:
1463 * Default Application associated with service name can be changed by Setting Application
1464 * So, Inhouse service application can be substituted by 3rd party service application
1466 * @param[in] svcname service string like "create_contact"
1467 * @param[in] defapp default application like "com.samsung.contact"
1468 * @return 0 if success, negative value if fail
1469 * @retval AUL_R_OK - success
1470 * @retval AUL_R_EINVAL - invalid argument(content)
1471 * @retval AUL_R_ERROR - general error
1478 * aul_get_defapp_for_service
1481 * #include <aul_service.h>
1483 * void set_camera_service_defapp()
1485 * aul_set_defapp_for_service(TAKE_PICTURE_SVC,"com.samsung.camera");
1493 int aul_set_defapp_for_service(const char *svcname, const char *defapp);
1497 * This API get the application appid associated with given service name
1499 * This API use to get default application associteted with service name
1500 * In general, Setting Application need this API.
1501 * @par Typical use case:
1502 * Setting Application show mapping of default application/ service
1504 * @param[in] svcname service string like "create_contact"
1505 * @param[out] defapp default application
1506 * @param[in] len length of defapp
1507 * @return 0 if success, negative value if fail
1508 * @retval AUL_R_OK - success
1509 * @retval AUL_R_EINVAL - invalid argument(content)
1510 * @retval AUL_R_ERROR - general error
1517 * aul_set_defapp_for_service
1520 * #include <aul_service.h>
1522 * void get_camera_service_defapp()
1524 * char appname[255];
1525 * aul_get_defapp_for_service(TAKE_PICTURE_SVC,appname,sizeof(appname));
1533 int aul_get_defapp_for_service(const char *svcname, char *defapp, int len);
1537 * This API sets callback fuction that will be called when applications die.
1539 * This API's purpose is to listen the application dead event.
1540 * In general, task manager Application need this API.
1542 * @param[in] func callback function
1543 * @param[in] data user data
1544 * @return 0 if success, negative value if fail
1545 * @retval AUL_R_OK - success
1546 * @retval AUL_R_ERROR - general error
1553 * aul_listen_app_launch_signal
1557 * int app_dead_handler(int pid, void *data)
1559 * printf("===> %s : %d\n", __FUNCTION__, pid);
1563 * void dead_listen()
1565 * aul_listen_app_dead_signal(app_dead_handler, NULL);
1573 int aul_listen_app_dead_signal(int (*func) (int, void *), void *data);
1577 * This API sets callback fuction that will be called when applications are launched.
1579 * This API's purpose is to listen the application launching event.
1580 * In general, task manager Application need this API.
1582 * @param[in] func callback function
1583 * @param[in] data user data
1584 * @return 0 if success, negative value if fail
1585 * @retval AUL_R_OK - success
1586 * @retval AUL_R_ERROR - general error
1593 * aul_listen_app_dead_signal
1597 * int app_launch_handler(int pid, void *data)
1599 * printf("===> %s : %d\n", __FUNCTION__, pid);
1603 * void dead_listen()
1605 * aul_listen_app_launch_signal(app_launch_handler, NULL);
1613 int aul_listen_app_launch_signal(int (*func) (int, void *), void *data);
1616 const char *aul_get_app_external_root_path(void);
1617 const char *aul_get_app_root_path(void);
1618 const char *aul_get_app_data_path(void);
1619 const char *aul_get_app_cache_path(void);
1620 const char *aul_get_app_resource_path(void);
1621 const char *aul_get_app_shared_data_path(void);
1622 const char *aul_get_app_shared_resource_path(void);
1623 const char *aul_get_app_shared_trusted_path(void);
1624 const char *aul_get_app_external_data_path(void);
1625 const char *aul_get_app_external_cache_path(void);
1626 const char *aul_get_app_external_shared_data_path(void);
1627 const char *aul_get_app_specific_path(void);
1628 const char *aul_get_app_external_specific_path(void);
1629 int aul_get_app_shared_data_path_by_appid(const char *app_id, char **path);
1630 int aul_get_app_shared_resource_path_by_appid(const char *app_id, char **path);
1631 int aul_get_app_shared_trusted_path_by_appid(const char *app_id, char **path);
1632 int aul_get_app_external_shared_data_path_by_appid(const char *app_id, char **path);
1633 int aul_get_app_usr_shared_data_path_by_appid(const char *app_id, char **path, uid_t uid);
1634 int aul_get_app_usr_shared_resource_path_by_appid(const char *app_id, char **path, uid_t uid);
1635 int aul_get_app_usr_shared_trusted_path_by_appid(const char *app_id, char **path, uid_t uid);
1636 int aul_get_app_usr_external_shared_data_path_by_appid(const char *app_id, char **path, uid_t uid);
1639 typedef int (*subapp_fn)(void *data);
1641 int aul_set_subapp(subapp_fn cb, void *data);
1642 int aul_subapp_terminate_request_pid(int pid);
1643 int aul_is_subapp(void);
1645 typedef int (*data_control_provider_handler_fn) (bundle *b, int request_id, void *data);
1646 int aul_set_data_control_provider_cb(data_control_provider_handler_fn handler);
1647 int aul_unset_data_control_provider_cb(void);
1658 #endif /* __AUL_H__ */
1660 /* vi: set ts=8 sts=8 sw=8: */