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.
36 * This is new version of Application Utility Library
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
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
50 * @ingroup APPLICATION_FRAMEWORK
51 * @defgroup aul Application Utility Library
58 * @brief Application Utility Library header
60 * Patched by Knhoon Baik <knhoon.baik@samsung.com>
61 * Patched by Youmin Ha <youmin.ha@samsung.com>
70 * @brief Return values in AUL.
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 */
99 * @defgroup aul_launch Primitive APIs to launch/resume/terminate application
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)
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)
117 * @addtogroup aul_launch
121 typedef enum _aul_type{
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__"
142 /** AUL internal private key */
143 #define AUL_K_NO_CANCEL "__AUL_NO_CANCEL__"
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__"
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__"
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__"
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__"
167 /** AUL public key - To support launching based on service */
168 #define AUL_K_SERVICE_NAME "__AUL_SERVICE_NAME__"
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__"
173 /** AUL public key - To support SDK */
174 #define AUL_K_SDK "__AUL_SDK__"
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__"
181 /** AUL public bundle value */
182 #define AUL_K_PRIVACY_APPID "__AUL_PRIVACY_APPID__"
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__"
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__"
200 /** AUL internal private key */
201 #define AUL_K_APPID "__AUL_APPID__"
202 /** AUL internal private key */
203 #define AUL_K_PID "__AUL_PID__"
205 #define PRIVACY_POPUP "tizenprv00.privacy-popup"
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
215 typedef int (*aul_handler_fn) (aul_type type, bundle * b, void *data);
219 * This API install your AUL handler and setup AUL internal connection.
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.
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
236 * @warning If you use AppCore, you should NOT use this API.\n
237 * You need glib main loop or ecore main loop.\n
239 * you must have aul handler to use this API.
240 * aul_luanch_init register aul handler.
247 * #include <bundle.h>
249 * static int aul_handler(aul_type type, bundle *kb,void *data)
254 * // process RESET event
257 * // process RESUME event
259 * case AUL_TERMINATE:
260 * // preocess TERMINATE event
266 * int main(int argc, char **argv)
269 * aul_launch_init(aul_handler,NULL);
270 * aul_launch_argv_handler(argc, argv);
271 * ecore_main_loop_begin();
278 int aul_launch_init(aul_handler_fn handler, void *data);
282 * This API create internal RESET events with given argc, argv \n
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.
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
299 * you must have aul handler to use this API.
300 * aul_luanch_init register aul handler.
307 * #include <bundle.h>
309 * int send_local_reset_event()
313 * argv[0] = "local.app";
314 * argv[1] = "event_type";
315 * argv[2] = "my_reset";
317 * aul_launch_argv_handler(argc,argv);
322 * If you use AppCore, you NEED NOT use this API.
324 int aul_launch_argv_handler(int argc, char **argv);
328 * This API creates internal RESET events with given bundle \n
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.
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
345 * you must have aul handler to use this API.
346 * aul_luanch_init register aul handler.
350 * aul_launch_init, bundle_import_from_argv
353 * #include <bundle.h>
355 * int send_local_reset_event()
360 * argv[0] = "local.app";
361 * argv[1] = "event_type";
362 * argv[2] = "my_reset";
365 * b = bundle_import_from_argv(argc,argv);
366 * aul_launch_local(b);
371 * If you use AppCore, you NEED NOT to use this API.
373 int aul_launch_local(bundle *b);
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
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.
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
405 * #include <bundle.h>
407 * int launch_inhouse_contact_app()
410 * b = bundle_create();
411 * bundle_add(b,"type","SIM");
412 * aul_launch_app("org.tizen.contact",b);
419 int aul_launch_app(const char *appid, bundle *kb);
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.
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.
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
447 * aul_launch_app, aul_app_is_running, aul_resume_pid
450 * #include <bundle.h>
452 * int open_inhouse_contact_app()
454 * if(aul_app_is_running("org.tizen.contact"))
455 * aul_open_app("org.tizen.contact");
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.
464 int aul_open_app(const char *appid);
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.
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.
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
491 * aul_launch_app, aul_app_is_running, aul_resume_pid
493 * This function will be deprecated. Use aul_open_add() instead.
496 * #include <bundle.h>
498 * int resume_inhouse_contact_app()
500 * if(aul_app_is_running("org.tizen.contact"))
501 * aul_resume_app("org.tizen.contact");
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.
512 int aul_resume_app(const char *appid);
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.
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
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
543 * #include <bundle.h>
545 * int iterfunc(const aul_app_info *info, void *data)
547 * if(strcmp(info->pkg_name,"org.tizen.contact")==0)
548 * aul_resume_pid(info->pid);
551 * int iterate_running_apps()
553 * return aul_app_get_running_app_info(iterfunc,NULL);
560 int aul_resume_pid(int pid);
564 * This API trigger to terminate application
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
569 * This API's purpose is to kill application
570 * @par Typical use case:
571 * In general, Application like Task Manager use this API.
573 * This API need to require root or inhouse permisssion. \n
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
591 * #include <bundle.h>
593 * int iterfunc(const aul_app_info *info, void *data)
595 * if(strcmp(info->pkg_name,"org.tizen.contact")==0)
596 * aul_terminate_pid(info->pid);
599 * int iterate_running_apps()
601 * return aul_app_get_running_app_info(iterfunc,NULL);
606 * If you have not the permission, this API return AUL_R_ERROR. \n
608 int aul_terminate_pid(int pid);
613 * @defgroup aul_info Helper APIs to get running application information
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
623 * @addtogroup aul_info
628 *@brief Running application's information structure retrieved by AUL
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 */
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
642 typedef int (*aul_app_info_iter_fn)(const aul_app_info *ainfo, void *data);
646 * This API ask a application is running by application package name.
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.
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.
667 * int is_running_browser_app()
669 * return aul_app_is_running("org.tizen.browser");
677 int aul_app_is_running(const char *appid);
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.
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)
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
704 * int iterfunc(const aul_app_info* info, void* data)
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");
714 * int iterate_running_apps()
716 * return aul_app_get_running_app_info(iterfunc,NULL);
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
725 int aul_app_get_running_app_info(aul_app_info_iter_fn iter_fn, void *data);
729 * This API get application package name by pid
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.
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
749 * #include <bundle.h>
751 * static int app_reset(bundle *b, void *data)
756 * pid = atoi(bundle_get_val(b,AUL_K_CALLER_PID));
757 * aul_app_get_pkgname_bypid(pid, appname, sizeof(appname));
764 int aul_app_get_pkgname_bypid(int pid, char *pkgname, int len);
768 * This API get application appid by pid
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.
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
788 * #include <bundle.h>
790 * static int app_reset(bundle *b, void *data)
795 * pid = atoi(bundle_get_val(b,AUL_K_CALLER_PID));
796 * aul_app_get_appid_bypid(pid, appid, sizeof(appid));
803 int aul_app_get_appid_bypid(int pid, char *appid, int len);
809 * @defgroup aul_mime High-level APIs to launch default application based on mime type
812 * AUL High-level APIs based on mime type
814 * These APIs provide two functionality\n
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.
825 * @addtogroup aul_mime
831 * This API launch application associated with given filename
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");
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
862 * int view_image_file(char *filename)
864 * aul_open_file(filename);
872 int aul_open_file(const char* filename);
876 * This API launch application associated with given specific mimetype
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.
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
904 * aul_open_file, aul_get_mime_from_file
908 * int view_drm_image_file(char *drm_filename)
911 * // you must implement this function
912 * mimetype = get_mimetype_from_drmfile(drm_filename);
914 * aul_open_file_with_mimetype(drm_filename,mimetype);
921 int aul_open_file_with_mimetype(const char *filename, const char *mimetype);
925 * This API launch application associated with content like "http://www.samsung.com"
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");
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
957 * int view_url(char *url)
959 * aul_open_content(url);
967 int aul_open_content(const char* content);
971 * This API get the default application(appid) associated with MIME type
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
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
991 * aul_set_defapp_with_mime
995 * void get_text_html_defapp()
998 * aul_get_defapp_from_mime("text/html",appname,sizeof(appname));
1006 int aul_get_defapp_from_mime(const char *mimetype, char *defapp, int len);
1010 * This API set the default application(appid) associated with MIME type
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.
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
1030 * aul_get_defapp_from_mime
1034 * void set_text_html_defapp()
1036 * aul_set_defapp_with_mime("text/html","org.tizen.browser");
1043 int aul_set_defapp_with_mime(const char *mimetype, const char *defapp);
1047 * This API get the mimetype associated with filename
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.
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
1073 * void get_mimetype()
1075 * char mimetype[255];
1076 * aul_get_mime_from_file("image.jpg",mimetype,sizeof(mimetype));
1083 int aul_get_mime_from_file(const char *filename, char *mimetype, int len);
1087 * This API get the mimetype associated with given content
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.
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
1113 * void get_mimetype()
1115 * char mimetype[255];
1116 * aul_get_mime_from_content("http://www.samsung.com",mimetype,sizeof(mimetype));
1123 int aul_get_mime_from_content(const char *content, char *mimetype, int len);
1127 * This API get the icon's name associated with given mimetype
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.
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)
1150 * void get_mime_icon()
1153 * aul_get_mime_icon("text/html",icon,sizeof(icon));
1160 int aul_get_mime_icon(const char *mimetype, char *iconname, int len);
1164 * This API get the extensions associated with given mimetype
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
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)
1185 * aul_get_mime_description
1189 * void get_extension()
1191 * char extlist[255];
1192 * aul_get_mime_extension("text/html",extlist,sizeof(extlist));
1197 * Some mimetype don't have extension.
1198 * In that case, You can use aul_get_mime_description.
1201 int aul_get_mime_extension(const char *mimetype, char *extlist, int len);
1205 * This API get the description associated with given mimetype
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
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)
1227 * aul_get_mime_extension
1231 * void get_information_from_mime()
1234 * if(aul_get_mime_extension("text/html",info,sizeof(info))<0){
1235 * aul_get_mime_description("text/html",info,sizeof(info));
1243 int aul_get_mime_description(const char *mimetype, char *desc, int len);
1245 /************************************************************************************************/
1246 /* Example of aul_open_content or aul_open_file */
1247 /* voice call , browser , docview , image viewer , audio player, video player */
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 /************************************************************************************************/
1261 * @defgroup aul_service High-level APIs to launch applications based on service.
1264 * AUL High-level APIs based on service
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
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.
1276 * After callee performs the requested operation, callee sends the result back, if necessary.\n
1281 * @addtogroup aul_service
1286 * @brief aul_service_res_fn is service result function
1287 * @param[out] b result bundle
1288 * @param[out] data user-supplied data
1290 typedef void (*aul_service_res_fn)(bundle *b, int reserved, void *user_data);
1294 * This API launch application based on service.
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,..);
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
1327 * #include <aul_service.h>
1328 * #include <bundle.h>
1330 * void res_func(bundle *b, int reserved, void *user_data)
1332 * // process result bundle
1335 * int create_camera_view()
1337 * aul_open_service(TAKE_PICTURE_SVC, NULL, res_func, NULL);
1342 * This API can wait result (asynchronous).
1343 * To see kinds of default service provided by platform, see "aul_service.h" header file
1346 int aul_open_service(const char *svcname, bundle *b, aul_service_res_fn cbfunc, void *data);
1350 * This API create service result bundle based on bundle received in reset event.
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.
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
1366 * To create result bundle, You need received original bundle.
1367 * The original bundle can get from app_reset handler.
1371 * aul_send_service_result
1374 * #include <bundle.h>
1376 * int app_reset(bundle *b, void *data)
1378 * ad->recved_bundle = bundle_dup(b);
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);
1393 int aul_create_result_bundle(bundle *inb, bundle **outb);
1397 * This API send service result to caller with bundle
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.
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
1413 * To send result bundle, You must create result bundle.
1414 * see aul_create_result_bundle
1418 * aul_create_result_bundle
1421 * #include <bundle.h>
1423 * int app_reset(bundle *b, void *data)
1425 * ad->recved_bundle = bundle_dup(b);
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);
1440 int aul_send_service_result(bundle *b);
1444 * This API set the default application(appid) associated with service name
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
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
1464 * aul_get_defapp_for_service
1467 * #include <aul_service.h>
1469 * void set_camera_service_defapp()
1471 * aul_set_defapp_for_service(TAKE_PICTURE_SVC,"org.tizen.camera");
1479 int aul_set_defapp_for_service(const char *svcname, const char *defapp);
1483 * This API get the application appid associated with given service name
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
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
1503 * aul_set_defapp_for_service
1506 * #include <aul_service.h>
1508 * void get_camera_service_defapp()
1510 * char appname[255];
1511 * aul_get_defapp_for_service(TAKE_PICTURE_SVC,appname,sizeof(appname));
1519 int aul_get_defapp_for_service(const char *svcname, char *defapp, int len);
1523 * This API sets callback fuction that will be called when applications die.
1525 * This API's purpose is to listen the application dead event.
1526 * In general, task manager Application need this API.
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
1539 * aul_listen_app_launch_signal
1543 * int app_dead_handler(int pid, void *data)
1545 * printf("===> %s : %d\n", __FUNCTION__, pid);
1549 * void dead_listen()
1551 * aul_listen_app_dead_signal(app_dead_handler, NULL);
1559 int aul_listen_app_dead_signal(int (*func) (int, void *), void *data);
1563 * This API sets callback fuction that will be called when applications are launched.
1565 * This API's purpose is to listen the application launching event.
1566 * In general, task manager Application need this API.
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
1579 * aul_listen_app_dead_signal
1583 * int app_launch_handler(int pid, void *data)
1585 * printf("===> %s : %d\n", __FUNCTION__, pid);
1589 * void dead_listen()
1591 * aul_listen_app_launch_signal(app_launch_handler, NULL);
1599 int aul_listen_app_launch_signal(int (*func) (int, void *), void *data);
1610 #endif /* __AUL_H__ */
1612 /* vi: set ts=8 sts=8 sw=8: */