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.
30 * @brief This file contains APIs of the appsvc library
34 * @addtogroup APPLICATION_FRAMEWORK
37 * @defgroup appsvc Application Service
39 * @brief Application Service library
56 /** APP_SVC OPERATION TYPE*/
57 #define APPSVC_OPERATION_DEFAULT "http://tizen.org/appcontrol/operation/default"
58 /** APP_SVC OPERATION TYPE*/
59 #define APPSVC_OPERATION_EDIT "http://tizen.org/appcontrol/operation/edit"
60 /** APP_SVC OPERATION TYPE*/
61 #define APPSVC_OPERATION_VIEW "http://tizen.org/appcontrol/operation/view"
62 /** APP_SVC OPERATION TYPE*/
63 #define APPSVC_OPERATION_PICK "http://tizen.org/appcontrol/operation/pick"
64 /** APP_SVC OPERATION TYPE*/
65 #define APPSVC_OPERATION_CREATE_CONTENT "http://tizen.org/appcontrol/operation/create_content"
66 /** APP_SVC OPERATION TYPE*/
67 #define APPSVC_OPERATION_CALL "http://tizen.org/appcontrol/operation/call"
68 /** APP_SVC OPERATION TYPE*/
69 #define APPSVC_OPERATION_SEND "http://tizen.org/appcontrol/operation/send"
70 /** APP_SVC OPERATION TYPE*/
71 #define APPSVC_OPERATION_SEND_TEXT "http://tizen.org/appcontrol/operation/send_text"
72 /** APP_SVC OPERATION TYPE*/
73 #define APPSVC_OPERATION_DIAL "http://tizen.org/appcontrol/operation/dial"
74 /** APP_SVC OPERATION TYPE*/
75 #define APPSVC_OPERATION_SEARCH "http://tizen.org/appcontrol/operation/search"
76 /** APP_SVC OPERATION TYPE*/
77 #define APPSVC_OPERATION_DOWNLOAD "http://tizen.org/appcontrol/operation/download"
78 /** APP_SVC OPERATION TYPE*/
79 #define APPSVC_OPERATION_SHARE "http://tizen.org/appcontrol/operation/share"
80 /** APP_SVC OPERATION TYPE*/
81 #define APPSVC_OPERATION_MULTI_SHARE "http://tizen.org/appcontrol/operation/multi_share"
82 /** APP_SVC OPERATION TYPE*/
83 #define APPSVC_OPERATION_COMPOSE "http://tizen.org/appcontrol/opeation/compose"
84 /** APP_SVC OPERATION TYPE*/
85 #define APPSVC_OPERATION_LOCATION "http://tizen.org/appcontrol/operation/configure/location"
86 /** APP_SVC OPERATION TYPE*/
87 #define APPSVC_OPERATION_FONT_TYPE "http://tizen.org/appcontrol/operation/configure/font/type"
88 /** APP_SVC OPERATION TYPE*/
89 #define APPSVC_OPERATION_FONT_SIZE "http://tizen.org/appcontrol/operation/configure/font/size"
94 /** APP_SVC DATA SUBJECT*/
95 #define APPSVC_DATA_SUBJECT "http://tizen.org/appcontrol/data/subject"
96 /** APP_SVC DATA TYPE*/
97 #define APPSVC_DATA_TO "http://tizen.org/appcontrol/data/to"
98 /** APP_SVC DATA TYPE*/
99 #define APPSVC_DATA_CC "http://tizen.org/appcontrol/data/cc"
100 /** APP_SVC DATA TYPE*/
101 #define APPSVC_DATA_BCC "http://tizen.org/appcontrol/data/bcc"
102 /** APP_SVC DATA TYPE*/
103 #define APPSVC_DATA_TEXT "http://tizen.org/appcontrol/data/text"
104 /** APP_SVC DATA TYPE*/
105 #define APPSVC_DATA_TITLE "http://tizen.org/appcontrol/data/title"
106 /** APP_SVC DATA TYPE*/
107 #define APPSVC_DATA_SELECTED "http://tizen.org/appcontrol/data/selected"
108 /** APP_SVC DATA TYPE*/
109 #define APPSVC_DATA_KEYWORD "http://tizen.org/appcontrol/data/keyword"
110 /** APP_SVC DATA TYPE*/
111 #define APPSVC_DATA_PATH "http://tizen.org/appcontrol/data/path"
112 /** APP_SVC DATA TYPE*/
113 #define APPSVC_DATA_SELECTION_MODE "http://tizen.org/appcontrol/data/selection_mode"
114 /** APP_SVC DATA TYPE*/
115 #define APPSVC_DATA_RETURN_RESULT "http://tizen.org/appcontrol/data/return_result"
118 /** APP SVC internal private key */
119 #define APP_SVC_K_URI_R_INFO "__APP_SVC_URI_R_INFO__"
121 #define APP_SELECTOR "org.tizen.app-selector"
124 * @brief Return values in appsvc.
126 typedef enum _appsvc_return_val {
127 APPSVC_RET_EILLACC = -5, /**< Illegal Access */
128 APPSVC_RET_ELAUNCH = -4, /**< Failure on launching the app */
129 APPSVC_RET_ENOMATCH = -3, /**< No matching result Error */
130 APPSVC_RET_EINVAL = -2, /**< Invalid argument */
131 APPSVC_RET_ERROR = -1, /**< General error */
132 APPSVC_RET_OK = 0 /**< General success */
137 * @brief result values in appsvc.
139 typedef enum _appsvc_result_val {
140 APPSVC_RES_CANCEL = -2, /**< Cancel by system */
141 APPSVC_RES_NOT_OK = -1, /**< Fail by user */
142 APPSVC_RES_OK = 0 /**< Success by user */
147 * @brief appsvc_res_fn is appsvc result function
148 * @param[out] b result bundle
149 * @param[out] request_code request code
150 * @param[out] result result value
151 * @param[out] data user-supplied data
153 typedef void (*appsvc_res_fn)(bundle *b, int request_code, appsvc_result_val result, void *data);
157 * @brief iterator function running with appsvc_get_list
158 * @param[out] pkg_name package name retreived by appsvc_get_list
159 * @param[out] data user-supplied data
161 typedef int (*appsvc_info_iter_fn)(const char *appid, void *data);
163 typedef int (*appsvc_host_res_fn)(void *data);
167 * This function sets an operation to launch application based on appsvc.
169 * @param[in] b bundle object
170 * @param[in] operation operation
172 * @return 0 if success, negative value(<0) if fail
173 * @retval APPSVC_RET_OK - success
174 * @retval APPSVC_RET_ERROR - general error
175 * @retval APPSVC_RET_EINVAL - invalid argument(content)
180 * @remarks An application must call this function before using appsvc_run_service API.
192 appsvc_set_operation(b, APPSVC_OPERATION_VIEW);
197 int appsvc_set_operation(bundle *b, const char *operation);
201 * This function sets an uri to launch application based on appsvc.
203 * @param[in] b bundle object
206 * @return 0 if success, negative value(<0) if fail
207 * @retval APPSVC_RET_OK - success
208 * @retval APPSVC_RET_ERROR - general error
209 * @retval APPSVC_RET_EINVAL - invalid argument(content)
226 appsvc_set_operation(b, APPSVC_OPERATION_VIEW);
227 appsvc_set_uri(b,"http://www.samsung.com");
232 int appsvc_set_uri(bundle *b, const char *uri);
236 * This function sets a mime-type to launch application based on appsvc.
238 * @param[in] b bundle object
239 * @param[in] mime mime-type
241 * @return 0 if success, negative value(<0) if fail
242 * @retval APPSVC_RET_OK - success
243 * @retval APPSVC_RET_ERROR - general error
244 * @retval APPSVC_RET_EINVAL - invalid argument(content)
261 appsvc_set_operation(b, APPSVC_OPERATION_PICK);
262 appsvc_set_mime(b,"image/jpg");
267 int appsvc_set_mime(bundle *b, const char *mime);
271 * This function sets an extra data to launch application based on appsvc.
273 * @param[in] b bundle object
274 * @param[in] key key of extra data
275 * @param[in] val data
277 * @return 0 if success, negative value(<0) if fail
294 appsvc_set_operation(b, APPSVC_OPERATION_SEND);
295 appsvc_set_uri(b,"mailto:xxx1@xxx");
296 appsvc_add_data(b,APPSVC_DATA_CC,"xxx2@xxx");
301 int appsvc_add_data(bundle *b, const char *key, const char *val);
305 * This function sets an extra array data to launch application based on appsvc.
307 * @param[in] b bundle object
308 * @param[in] key key of extra data
309 * @param[in] val_array data
310 * @param[in] len Length of array
312 * @return 0 if success, negative value(<0) if fail
326 char *images[] = {"/opt/media/a.jpg", "/opt/media/b.jpg", "/opt/media/c.jpg"};
330 appsvc_add_data_array(b, APPSVC_DATA_SELECTED, images, 3);
335 int appsvc_add_data_array(bundle *b, const char *key, const char **val_array, int len);
340 * This function sets a package name to launch application based on appsvc.
342 * @param[in] b bundle object
343 * @param[in] pkg_name package name for explict launch
345 * @return 0 if success, negative value(<0) if fail
346 * @retval APPSVC_RET_OK - success
347 * @retval APPSVC_RET_ERROR - general error
348 * @retval APPSVC_RET_EINVAL - invalid argument(content)
365 appsvc_set_operation(b, APPSVC_OPERATION_PICK);
366 appsvc_set_mime(b,"image/jpg");
367 appsvc_set_pkgname(b, "org.tizen.mygallery");
373 int appsvc_set_pkgname(bundle *b, const char *pkg_name); // __attribute__((deprecated));
378 * This function sets a appid to launch application based on appsvc.
380 * @param[in] b bundle object
381 * @param[in] appid application id for explict launch
383 * @return 0 if success, negative value(<0) if fail
384 * @retval APPSVC_RET_OK - success
385 * @retval APPSVC_RET_ERROR - general error
386 * @retval APPSVC_RET_EINVAL - invalid argument(content)
403 appsvc_set_operation(b, APPSVC_OPERATION_PICK);
404 appsvc_set_mime(b,"image/jpg");
405 appsvc_set_appid(b, "org.tizen.mygallery");
410 int appsvc_set_appid(bundle *b, const char *appid);
415 * This function sets a appid to launch application based on appsvc.
417 * @param[in] b bundle object
418 * @param[in] application category
420 * @return 0 if success, negative value(<0) if fail
421 * @retval APPSVC_RET_OK - success
422 * @retval APPSVC_RET_ERROR - general error
423 * @retval APPSVC_RET_EINVAL - invalid argument(content)
440 appsvc_set_operation(b, APPSVC_OPERATION_VIEW);
441 appsvc_set_category(b, "http://tizen.org/category/app/browser");
446 int appsvc_set_category(bundle *b, const char *category);
450 * This API launch application based on appsvc.
452 * @param[in] b bundle to be passed to callee
453 * @param[in] request_code request code
454 * @param[in] cbfunc result callback function
455 * @param[in] data user-supplied data passed to callback function
457 * @return callee's pid if success, negative value(<0) if fail
458 * @retval callee's pid - success
459 * @retval APPSVC_RET_ERROR - general error
460 * @retval APPSVC_RET_EINVAL - invalid argument(content)
461 * @retval APPSVC_RET_ENOMATCH - no matching result Error
462 * @retval APPSVC_RET_ELAUNCH - failure on launching the app
480 appsvc_set_operation(b, APPSVC_OPERATION_PICK);
481 appsvc_set_mime(b,"image/jpg");
483 return appsvc_run_service(b, 0, cb_func, (void*)NULL);
488 int appsvc_run_service(bundle *b, int request_code, appsvc_res_fn cbfunc, void *data);
492 * This API use to get application list that is matched with given bundle.
494 * @param[in] b bundle to resolve application
495 * @param[in] iter_fn iterator function
496 * @param[in] data user-supplied data for iter_fn
498 * @return 0 if success, negative value(<0) if fail
499 * @retval APPSVC_RET_OK - success
500 * @retval APPSVC_RET_EINVAL - invalid argument(content)
501 * @retval APPSVC_RET_ENOMATCH - no matching result Error
512 static int iter_fn(const char* pkg_name, void *data)
514 printf("\t==========================\n");
515 printf("\t pkg_name: %s\n", pkg_name);
516 printf("\t==========================\n");
527 appsvc_set_operation(b, APPSVC_OPERATION_PICK);
528 appsvc_set_mime(b,"image/jpg");
530 return appsvc_get_list(b, iter_fn, (void*)NULL);
535 int appsvc_get_list(bundle *b, appsvc_info_iter_fn iter_fn, void *data);
539 * This function gets a operation from bundle.
541 * @param[in] b bundle object
543 * @return Pointer for operation string if success, NULL if fail
557 val = appsvc_get_operation(b);
562 const char *appsvc_get_operation(bundle *b);
566 * This function gets a uri from bundle.
568 * @param[in] b bundle object
570 * @return Pointer for uri string if success, NULL if fail
584 val = appsvc_get_uri(b);
589 const char *appsvc_get_uri(bundle *b);
593 * This function gets a mime-type from bundle.
595 * @param[in] b bundle object
597 * @return Pointer for mime-type string if success, NULL if fail
611 val = appsvc_get_mime(b);
616 const char *appsvc_get_mime(bundle *b);
620 * This function gets a package name from bundle.
622 * @param[in] b bundle object
624 * @return Pointer for package name string if success, NULL if fail
638 val = appsvc_get_pkgname(b);
644 const char *appsvc_get_pkgname(bundle *b); // __attribute__((deprecated));
648 * This function gets a application id from bundle.
650 * @param[in] b bundle object
652 * @return Pointer for application id string if success, NULL if fail
666 val = appsvc_get_appid(b);
671 const char *appsvc_get_appid(bundle *b);
675 * This function gets a application category from bundle.
677 * @param[in] b bundle object
679 * @return Pointer for application category string if success, NULL if fail
693 val = appsvc_get_category(b);
698 const char *appsvc_get_category(bundle *b);
702 * This function gets value from key.
704 * @param[in] b bundle object
707 * @return Pointer for value string if success, NULL if fail
721 val = appsvc_get_data(b, APPSVC_DATA_CC);
726 const char *appsvc_get_data(bundle *b, const char *key);
730 * This function gets value from key.
732 * @param[in] b bundle object
734 * @param[out] len length of array
736 * @return Pointer for value string array if success, NULL if fail
753 if(appsvc_data_is_array(b, APPSVC_DATA_SELECTED))
754 val_array = appsvc_get_data_array(b, APPSVC_DATA_SELECTED, &len);
756 val = appsvc_get_data(b, APPSVC_DATA_SELECTED);
761 const char **appsvc_get_data_array(bundle *b, const char *key, int *len);
765 * This API create appsvc result bundle based on bundle received in reset event.
767 * @param[in] inb bundle received in reset event
768 * @param[in] outb bundle to use for returning result
770 * @retval APPSVC_RET_OK - success
771 * @retval APPSVC_RET_ERROR - general error
772 * @retval APPSVC_RET_EINVAL - invalid argument(content)
776 * @see appsvc_send_result.
785 struct appdata *ad = data;
788 appsvc_create_result_bundle(ad->b,&res_bundle);
789 bundle_add(res_bundle, "result", "1");
790 appsvc_send_result(res_bundle, 0);
795 int appsvc_create_result_bundle(bundle *inb, bundle **outb);
799 * This API send appsvc result to caller with bundle.
801 * @param[in] b Result data in bundle format
802 * @param[in] result result value
804 * @retval APPSVC_RET_OK - success
805 * @retval APPSVC_RET_ERROR - general error
806 * @retval APPSVC_RET_EINVAL - invalid argument(content)
808 * @pre appsvc_create_result_bundle.
810 * @see appsvc_send_result.
819 struct appdata *ad = data;
822 appsvc_create_result_bundle(ad->b,&res_bundle);
823 bundle_add(res_bundle, "result", "1");
824 appsvc_send_result(res_bundle, 0);
829 int appsvc_send_result(bundle *b, appsvc_result_val result);
833 * This API set the default application(package name) associated with op, uri and mime-type.
835 * @param[in] op operation
836 * @param[in] mime_type mime-type
837 * @param[in] scheme scheme of uri
838 * @param[in] defapp default application
840 * @retval APPSVC_RET_OK - success
841 * @retval APPSVC_RET_ERROR - general error
842 * @retval APPSVC_RET_EINVAL - invalid argument(content)
855 appsvc_set_defapp(APPSVC_OPERATION_VIEW, NULL,"http", "org.tizen.mybrowser");
860 int appsvc_set_defapp(const char *op, const char *mime_type, const char *uri,
865 * This API unset the default application(package name) associated with op, uri and mime-type.
867 * @param[in] defapp default application
869 * @retval APPSVC_RET_OK - success
870 * @retval APPSVC_RET_ERROR - general error
883 appsvc_unset_defapp("org.tizen.test");
888 int appsvc_unset_defapp(const char *defapp);
892 * This API ask a application is default application or not.
894 * @param[in] pkg_name application package name
895 * @return true / false
896 * @retval 1 app_name is default application in appsvc.
897 * @retval 0 app_name is NOT default application in appsvc.
910 * int is_defapp_browser_app()
912 * return appsvc_is_defapp("org.tizen.browser");
920 int appsvc_is_defapp(const char *appid);
925 * This API ask a extra data is array or not.
927 * @param[in] b bundle object
928 * @param[in] key key of extra data
929 * @return true / false
930 * @retval 1 a extra data is array.
931 * @retval 0 a extra data is not array.
944 * int is_defapp_browser_app(bundle *b, char *key)
946 * return appsvc_data_is_array(b, key);
954 int appsvc_data_is_array(bundle *b, const char *key);
969 #endif /* __APP_SVC_H__ */
971 /* vi: set ts=8 sts=8 sw=8: */