2 * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
27 /** AUL_SVC OPERATION TYPE*/
28 #define AUL_SVC_OPERATION_DEFAULT "http://tizen.org/appcontrol/operation/default"
29 /** AUL_SVC OPERATION TYPE*/
30 #define AUL_SVC_OPERATION_EDIT "http://tizen.org/appcontrol/operation/edit"
31 /** AUL_SVC OPERATION TYPE*/
32 #define AUL_SVC_OPERATION_VIEW "http://tizen.org/appcontrol/operation/view"
33 /** AUL_SVC OPERATION TYPE*/
34 #define AUL_SVC_OPERATION_PICK "http://tizen.org/appcontrol/operation/pick"
35 /** AUL_SVC OPERATION TYPE*/
36 #define AUL_SVC_OPERATION_CREATE_CONTENT "http://tizen.org/appcontrol/operation/create_content"
37 /** AUL_SVC OPERATION TYPE*/
38 #define AUL_SVC_OPERATION_CALL "http://tizen.org/appcontrol/operation/call"
39 /** AUL_SVC OPERATION TYPE*/
40 #define AUL_SVC_OPERATION_SEND "http://tizen.org/appcontrol/operation/send"
41 /** AUL_SVC OPERATION TYPE*/
42 #define AUL_SVC_OPERATION_SEND_TEXT "http://tizen.org/appcontrol/operation/send_text"
43 /** AUL_SVC OPERATION TYPE*/
44 #define AUL_SVC_OPERATION_DIAL "http://tizen.org/appcontrol/operation/dial"
45 /** AUL_SVC OPERATION TYPE*/
46 #define AUL_SVC_OPERATION_SEARCH "http://tizen.org/appcontrol/operation/search"
47 /** AUL_SVC OPERATION TYPE*/
48 #define AUL_SVC_OPERATION_DOWNLOAD "http://tizen.org/appcontrol/operation/download"
49 /** AUL_SVC OPERATION TYPE*/
50 #define AUL_SVC_OPERATION_SHARE "http://tizen.org/appcontrol/operation/share"
51 /** AUL_SVC OPERATION TYPE*/
52 #define AUL_SVC_OPERATION_MULTI_SHARE "http://tizen.org/appcontrol/operation/multi_share"
53 /** AUL_SVC OPERATION TYPE*/
54 #define AUL_SVC_OPERATION_SHARE_TEXT "http://tizen.org/appcontrol/operation/share_text"
55 /** AUL_SVC_OPERATION_TYPE*/
56 #define AUL_SVC_OPERATION_COMPOSE "http://tizen.org/appcontrol/operation/compose"
57 /** AUL_SVC OPERATION TYPE*/
58 #define AUL_SVC_OPERATION_LOCATION "http://tizen.org/appcontrol/operation/configure/location"
59 /** AUL_SVC OPERATION TYPE*/
60 #define AUL_SVC_OPERATION_FONT_TYPE "http://tizen.org/appcontrol/operation/configure/font/type"
61 /** AUL_SVC OPERATION TYPE*/
62 #define AUL_SVC_OPERATION_FONT_SIZE "http://tizen.org/appcontrol/operation/configure/font/size"
63 #define AUL_SVC_OPERATION_LAUNCH_ON_EVENT "http://tizen.org/appcontrol/operation/launch_on_event"
67 /** AUL_SVC DATA SUBJECT*/
68 #define AUL_SVC_DATA_SUBJECT "http://tizen.org/appcontrol/data/subject"
69 /** AUL_SVC DATA TYPE*/
70 #define AUL_SVC_DATA_TO "http://tizen.org/appcontrol/data/to"
71 /** AUL_SVC DATA TYPE*/
72 #define AUL_SVC_DATA_CC "http://tizen.org/appcontrol/data/cc"
73 /** AUL_SVC DATA TYPE*/
74 #define AUL_SVC_DATA_BCC "http://tizen.org/appcontrol/data/bcc"
75 /** AUL_SVC DATA TYPE*/
76 #define AUL_SVC_DATA_TEXT "http://tizen.org/appcontrol/data/text"
77 /** AUL_SVC DATA TYPE*/
78 #define AUL_SVC_DATA_TITLE "http://tizen.org/appcontrol/data/title"
79 /** AUL_SVC DATA TYPE*/
80 #define AUL_SVC_DATA_SELECTED "http://tizen.org/appcontrol/data/selected"
81 /** AUL_SVC DATA TYPE*/
82 #define AUL_SVC_DATA_KEYWORD "http://tizen.org/appcontrol/data/keyword"
83 /** AUL_SVC DATA TYPE*/
84 #define AUL_SVC_DATA_PATH "http://tizen.org/appcontrol/data/path"
85 /** AUL_SVC DATA TYPE*/
86 #define AUL_SVC_DATA_SELECTION_MODE "http://tizen.org/appcontrol/data/selection_mode"
87 /** AUL_SVC DATA TYPE*/
88 #define AUL_SVC_DATA_RETURN_RESULT "http://tizen.org/appcontrol/data/return_result"
91 /** AUL SVC internal private key */
92 #define AUL_SVC_K_URI_R_INFO "__AUL_SVC_URI_R_INFO__"
94 #define AUL_SVC_K_SELECTOR_EXTRA_LIST "http://tizen.org/appcontrol/data/selector_extra_list"
96 #ifdef _APPFW_FEATURE_MULTI_INSTANCE
97 #define AUL_SVC_K_MULTI_INSTANCE "multi_instance"
100 #define APP_SELECTOR "org.tizen.app-selector"
101 #define SHARE_PANEL "org.tizen.share-panel"
103 /** Internal operation for launching application which is other zone */
104 #define AUL_SVC_OPERATION_JUMP "http://tizen.org/appcontrol/operation/jump"
105 #define AUL_SVC_K_JUMP_ZONE_NAME "__K_JUMP_DOMAIN_NAME__"
106 #define AUL_SVC_K_JUMP_ORIGIN_OPERATION "__K_JUMP_ORIGIN_OPERATION__"
107 #define AUL_SVC_K_FOCUS_ZONE "__K_FOCUS_ZONE__"
108 #define AUL_SVC_K_LAUNCH_RESULT_APP_STARTED "__K_LAUNCH_RESULT_APP_STARTED__"
109 #define AUL_SVC_K_CAN_BE_LEADER "__K_CAN_BE_LEADER__"
110 #define AUL_SVC_K_REROUTE "__K_REROUTE__"
111 #define AUL_SVC_K_SHIFT_WINDOW "__K_SHIFT_WINDOW"
112 #define AUL_SVC_K_RECYCLE "__K_RECYCLE"
116 * @brief Return values in appsvc.
118 typedef enum _aul_svc_return_val {
119 AUL_SVC_RET_EREJECTED = -7, /**< application launch rejected */
120 AUL_SVC_RET_ETERMINATING = -6, /**< application terminating */
121 AUL_SVC_RET_EILLACC = -5, /**< Illegal Access */
122 AUL_SVC_RET_ELAUNCH = -4, /**< Failure on launching the app */
123 AUL_SVC_RET_ENOMATCH = -3, /**< No matching result Error */
124 AUL_SVC_RET_EINVAL = -2, /**< Invalid argument */
125 AUL_SVC_RET_ERROR = -1, /**< General error */
126 AUL_SVC_RET_OK = 0 /**< General success */
127 } aul_svc_return_val;
131 * @brief result values in appsvc.
133 typedef enum _aul_svc_result_val
135 AUL_SVC_RES_CANCEL = -2, /**< Cancel by system */
136 AUL_SVC_RES_NOT_OK = -1, /**< Fail by user */
137 AUL_SVC_RES_OK = 0 /**< Success by user */
138 } aul_svc_result_val;
142 * @brief aul_svc_res_fn is appsvc result function
143 * @param[out] b result bundle
144 * @param[out] request_code request code
145 * @param[out] result result value
146 * @param[out] data user-supplied data
148 typedef void (*aul_svc_res_fn)(bundle *b, int request_code, aul_svc_result_val result, void *data);
152 * @brief iterator function running with aul_svc_get_list
153 * @param[out] appid appid retreived by aul_svc_get_list
154 * @param[out] data user-supplied data
156 typedef int (*aul_svc_info_iter_fn)(const char *appid, void *data);
158 typedef int (*aul_svc_host_res_fn)(void *data);
162 * This function sets an operation to launch application based on appsvc.
164 * @param[in] b bundle object
165 * @param[in] operation operation
167 * @return 0 if success, negative value(<0) if fail
168 * @retval AUL_SVC_RET_OK - success
169 * @retval AUL_SVC_RET_ERROR - general error
170 * @retval AUL_SVC_RET_EINVAL - invalid argument(content)
175 * @remarks An application must call this function before using aul_svc_run_service API.
187 aul_svc_set_operation(b, AUL_SVC_OPERATION_VIEW);
192 int aul_svc_set_operation(bundle *b, const char *operation);
196 * This function sets an uri to launch application based on appsvc.
198 * @param[in] b bundle object
201 * @return 0 if success, negative value(<0) if fail
202 * @retval AUL_SVC_RET_OK - success
203 * @retval AUL_SVC_RET_ERROR - general error
204 * @retval AUL_SVC_RET_EINVAL - invalid argument(content)
221 aul_svc_set_operation(b, AUL_SVC_OPERATION_VIEW);
222 aul_svc_set_uri(b,"http://www.samsung.com");
227 int aul_svc_set_uri(bundle *b, const char *uri);
231 * This function sets a mime-type to launch application based on appsvc.
233 * @param[in] b bundle object
234 * @param[in] mime mime-type
236 * @return 0 if success, negative value(<0) if fail
237 * @retval AUL_SVC_RET_OK - success
238 * @retval AUL_SVC_RET_ERROR - general error
239 * @retval AUL_SVC_RET_EINVAL - invalid argument(content)
256 aul_svc_set_operation(b, AUL_SVC_OPERATION_PICK);
257 aul_svc_set_mime(b,"image/jpg");
262 int aul_svc_set_mime(bundle *b, const char *mime);
266 * This function sets an extra data to launch application based on appsvc.
268 * @param[in] b bundle object
269 * @param[in] key key of extra data
270 * @param[in] val data
272 * @return 0 if success, negative value(<0) if fail
289 aul_svc_set_operation(b, AUL_SVC_OPERATION_SEND);
290 aul_svc_set_uri(b,"mailto:xxx1@xxx");
291 aul_svc_add_data(b,AUL_SVC_DATA_CC,"xxx2@xxx");
296 int aul_svc_add_data(bundle *b, const char *key, const char *val);
300 * This function sets an extra array data to launch application based on appsvc.
302 * @param[in] b bundle object
303 * @param[in] key key of extra data
304 * @param[in] val_array data
305 * @param[in] len Length of array
307 * @return 0 if success, negative value(<0) if fail
321 char *images[] = {"/opt/media/a.jpg", "/opt/media/b.jpg", "/opt/media/c.jpg"};
325 aul_svc_add_data_array(b, AUL_SVC_DATA_SELECTED, images, 3);
330 int aul_svc_add_data_array(bundle *b, const char *key, const char **val_array, int len);
335 * This function sets a package name to launch application based on appsvc.
337 * @param[in] b bundle object
338 * @param[in] pkg_name package name for explict launch
340 * @return 0 if success, negative value(<0) if fail
341 * @retval AUL_SVC_RET_OK - success
342 * @retval AUL_SVC_RET_ERROR - general error
343 * @retval AUL_SVC_RET_EINVAL - invalid argument(content)
360 aul_svc_set_operation(b, AUL_SVC_OPERATION_PICK);
361 aul_svc_set_mime(b,"image/jpg");
362 aul_svc_set_pkgname(b, "org.tizen.mygallery");
368 int aul_svc_set_pkgname(bundle *b, const char *pkg_name); // __attribute__((deprecated));
373 * This function sets a appid to launch application based on appsvc.
375 * @param[in] b bundle object
376 * @param[in] appid application id for explict launch
378 * @return 0 if success, negative value(<0) if fail
379 * @retval AUL_SVC_RET_OK - success
380 * @retval AUL_SVC_RET_ERROR - general error
381 * @retval AUL_SVC_RET_EINVAL - invalid argument(content)
398 aul_svc_set_operation(b, AUL_SVC_OPERATION_PICK);
399 aul_svc_set_mime(b,"image/jpg");
400 aul_svc_set_appid(b, "org.tizen.mygallery");
405 int aul_svc_set_appid(bundle *b, const char *appid);
410 * This function sets a appid to launch application based on appsvc.
412 * @param[in] b bundle object
413 * @param[in] application category
415 * @return 0 if success, negative value(<0) if fail
416 * @retval AUL_SVC_RET_OK - success
417 * @retval AUL_SVC_RET_ERROR - general error
418 * @retval AUL_SVC_RET_EINVAL - invalid argument(content)
435 aul_svc_set_operation(b, AUL_SVC_OPERATION_VIEW);
436 aul_svc_set_category(b, "http://tizen.org/category/app/browser");
441 int aul_svc_set_category(bundle *b, const char *category);
445 * This API launch application based on appsvc.
447 * @param[in] b bundle to be passed to callee
448 * @param[in] request_code request code
449 * @param[in] cbfunc result callback function
450 * @param[in] data user-supplied data passed to callback function
452 * @return callee's pid if success, negative value(<0) if fail
453 * @retval callee's pid - success
454 * @retval AUL_SVC_RET_ERROR - general error
455 * @retval AUL_SVC_RET_EINVAL - invalid argument(content)
456 * @retval AUL_SVC_RET_ENOMATCH - no matching result Error
457 * @retval AUL_SVC_RET_ELAUNCH - failure on launching the app
475 aul_svc_set_operation(b, AUL_SVC_OPERATION_PICK);
476 aul_svc_set_mime(b,"image/jpg");
478 return aul_svc_run_service(b, 0, cb_func, (void*)NULL);
483 int aul_svc_run_service(bundle *b, int request_code, aul_svc_res_fn cbfunc, void *data);
487 * This API use to get application list that is matched with given bundle.
489 * @param[in] b bundle to resolve application
490 * @param[in] iter_fn iterator function
491 * @param[in] data user-supplied data for iter_fn
493 * @return 0 if success, negative value(<0) if fail
494 * @retval AUL_SVC_RET_OK - success
495 * @retval AUL_SVC_RET_EINVAL - invalid argument(content)
496 * @retval AUL_SVC_RET_ENOMATCH - no matching result Error
507 static int iter_fn(const char* appid, void *data)
509 printf("\t==========================\n");
510 printf("\t appid: %s\n", appid);
511 printf("\t==========================\n");
522 aul_svc_set_operation(b, AUL_SVC_OPERATION_PICK);
523 aul_svc_set_mime(b,"image/jpg");
525 return aul_svc_get_list(b, iter_fn, (void*)NULL);
530 int aul_svc_get_list(bundle *b, aul_svc_info_iter_fn iter_fn, void *data);
534 * This API use to get default applications
536 * @param[in] iter_fn iterator function
537 * @param[in] data user-supplied data for iter_fn
539 * @return 0 if success, negative value(<0) if fail
540 * @retval AUL_SVC_RET_OK - success
541 * @retval AUL_SVC_RET_EINVAL - invalid argument(content)
542 * @retval AUL_SVC_RET_ENOMATCH - no matching result Error
553 static int iter_fn(const char* appid, void *data)
555 printf("\t==========================\n");
556 printf("\t appid : %s\n", appid);
557 printf("\t==========================\n");
563 return aul_svc_get_all_defapps(iter_fn, (void*)NULL);
568 int aul_svc_get_all_defapps(aul_svc_info_iter_fn iter_fn, void *data);
572 * This function gets a operation from bundle.
574 * @param[in] b bundle object
576 * @return Pointer for operation string if success, NULL if fail
590 val = aul_svc_get_operation(b);
595 const char *aul_svc_get_operation(bundle *b);
599 * This function gets a uri from bundle.
601 * @param[in] b bundle object
603 * @return Pointer for uri string if success, NULL if fail
617 val = aul_svc_get_uri(b);
622 const char *aul_svc_get_uri(bundle *b);
626 * This function gets a mime-type from bundle.
628 * @param[in] b bundle object
630 * @return Pointer for mime-type string if success, NULL if fail
644 val = aul_svc_get_mime(b);
649 const char *aul_svc_get_mime(bundle *b);
653 * This function gets a package name from bundle.
655 * @param[in] b bundle object
657 * @return Pointer for package name string if success, NULL if fail
671 val = aul_svc_get_pkgname(b);
677 const char *aul_svc_get_pkgname(bundle *b); // __attribute__((deprecated));
681 * This function gets a application id from bundle.
683 * @param[in] b bundle object
685 * @return Pointer for application id string if success, NULL if fail
699 val = aul_svc_get_appid(b);
704 const char *aul_svc_get_appid(bundle *b);
708 * This function gets a application category from bundle.
710 * @param[in] b bundle object
712 * @return Pointer for application category string if success, NULL if fail
726 val = aul_svc_get_category(b);
731 const char *aul_svc_get_category(bundle *b);
735 * This function gets value from key.
737 * @param[in] b bundle object
740 * @return Pointer for value string if success, NULL if fail
754 val = aul_svc_get_data(b, AUL_SVC_DATA_CC);
759 const char *aul_svc_get_data(bundle *b, const char *key);
763 * This function gets value from key.
765 * @param[in] b bundle object
767 * @param[out] len length of array
769 * @return Pointer for value string array if success, NULL if fail
786 if(aul_svc_data_is_array(b, AUL_SVC_DATA_SELECTED))
787 val_array = aul_svc_get_data_array(b, AUL_SVC_DATA_SELECTED, &len);
789 val = aul_svc_get_data(b, AUL_SVC_DATA_SELECTED);
794 const char **aul_svc_get_data_array(bundle *b, const char *key, int *len);
798 * This API create appsvc result bundle based on bundle received in reset event.
800 * @param[in] inb bundle received in reset event
801 * @param[in] outb bundle to use for returning result
803 * @retval AUL_SVC_RET_OK - success
804 * @retval AUL_SVC_RET_ERROR - general error
805 * @retval AUL_SVC_RET_EINVAL - invalid argument(content)
809 * @see aul_svc_send_result.
818 struct appdata *ad = data;
821 aul_svc_create_result_bundle(ad->b,&res_bundle);
822 bundle_add(res_bundle, "result", "1");
823 aul_svc_send_result(res_bundle, 0);
828 int aul_svc_create_result_bundle(bundle *inb, bundle **outb);
832 * This API send appsvc result to caller with bundle.
834 * @param[in] b Result data in bundle format
835 * @param[in] result result value
837 * @retval AUL_SVC_RET_OK - success
838 * @retval AUL_SVC_RET_ERROR - general error
839 * @retval AUL_SVC_RET_EINVAL - invalid argument(content)
841 * @pre aul_svc_create_result_bundle.
843 * @see aul_svc_send_result.
852 struct appdata *ad = data;
855 aul_svc_create_result_bundle(ad->b,&res_bundle);
856 bundle_add(res_bundle, "result", "1");
857 aul_svc_send_result(res_bundle, 0);
862 int aul_svc_send_result(bundle *b, aul_svc_result_val result);
866 * This API set the default application(package name) associated with op, uri and mime-type.
868 * @param[in] op operation
869 * @param[in] mime_type mime-type
870 * @param[in] scheme scheme of uri
871 * @param[in] defapp default application
873 * @retval AUL_SVC_RET_OK - success
874 * @retval AUL_SVC_RET_ERROR - general error
875 * @retval AUL_SVC_RET_EINVAL - invalid argument(content)
888 aul_svc_set_defapp(AUL_SVC_OPERATION_VIEW, NULL,"http", "org.tizen.mybrowser");
893 int aul_svc_set_defapp(const char *op, const char *mime_type, const char *uri,
898 * This API unset the default application(package name) associated with op, uri and mime-type.
900 * @param[in] defapp default application
902 * @retval AUL_SVC_RET_OK - success
903 * @retval AUL_SVC_RET_ERROR - general error
916 aul_svc_unset_defapp("org.tizen.test");
921 int aul_svc_unset_defapp(const char *defapp);
925 * This API unset all of default applications associated with op, uri and mime-type.
928 * @retval AUL_SVC_RET_OK - success
929 * @retval AUL_SVC_RET_ERROR - general error
942 aul_svc_unset_all_defapps();
947 int aul_svc_unset_all_defapps();
951 * This API ask a application is default application or not.
953 * @param[in] appid application appid
954 * @return true / false
955 * @retval 1 app_name is default application in appsvc.
956 * @retval 0 app_name is NOT default application in appsvc.
969 * int is_defapp_browser_app()
971 * return aul_svc_is_defapp("org.tizen.browser");
979 int aul_svc_is_defapp(const char *appid);
984 * This API ask a extra data is array or not.
986 * @param[in] b bundle object
987 * @param[in] key key of extra data
988 * @return true / false
989 * @retval 1 a extra data is array.
990 * @retval 0 a extra data is not array.
1003 * int aul_svc_data_is_array(bundle *b, char *key)
1005 * return aul_svc_data_is_array(b, key);
1013 int aul_svc_data_is_array(bundle *b, const char *key);
1015 int aul_svc_subapp_terminate_request_pid(int pid);
1019 * This function sets an uri to launch application based on appsvc.
1021 * @param[in] b bundle object
1022 * @param[in] char *mode
1024 * @return 0 if success, negative value(<0) if fail
1025 * @retval AUL_SVC_RET_OK - success
1026 * @retval AUL_SVC_RET_ERROR - general error
1027 * @retval AUL_SVC_RET_EINVAL - invalid argument(content)
1036 #include <aul_svc.h>
1040 aul_svc_set_launch_mode(app_control->data, mode);
1045 int aul_svc_set_launch_mode(bundle *b, const char *mode);
1049 * This function sets an uri to launch application based on appsvc.
1051 * @param[in] b bundle object
1053 * @return Pointer for launch mode string if success, NULL if fail
1062 #include <aul_svc.h>
1066 aul_svc_get_launch_mode(app_control->data);
1071 const char *aul_svc_get_launch_mode(bundle *b);
1073 int aul_svc_allow_transient_app(bundle *b, int wid);
1075 int aul_svc_request_transient_app(bundle *b, int callee_wid,
1076 aul_svc_host_res_fn cbfunc, void *data);
1078 int aul_svc_subscribe_launch_result(bundle *b, const char *event);
1085 #endif /* __AUL_SVC_H__ */