Add new functions to handling running components
[platform/core/appfw/aul-1.git] / include / aul_svc.h
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #pragma once
18
19 #include <bundle.h>
20 #include <sys/types.h>
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25
26
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"
64
65
66
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"
89
90 /** AUL SVC internal private key */
91 #define AUL_SVC_K_URI_R_INFO        "__AUL_SVC_URI_R_INFO__"
92
93 #define AUL_SVC_K_SELECTOR_EXTRA_LIST   "http://tizen.org/appcontrol/data/selector_extra_list"
94
95 /** AUL SVC internal private key */
96 #define AUL_SVC_OPERATION_LAUNCH_WIDGET         "http://tizen.org/appcontrol/operation/launch_widget"
97
98 #ifdef _APPFW_FEATURE_MULTI_INSTANCE
99 #define AUL_SVC_K_MULTI_INSTANCE    "multi_instance"
100 #endif
101
102 #define APP_SELECTOR "org.tizen.app-selector"
103 #define SHARE_PANEL "org.tizen.share-panel"
104
105 /** Internal operation for launching application which is other zone */
106 #define AUL_SVC_OPERATION_JUMP  "http://tizen.org/appcontrol/operation/jump"
107 #define AUL_SVC_K_JUMP_ZONE_NAME    "__K_JUMP_DOMAIN_NAME__"
108 #define AUL_SVC_K_JUMP_ORIGIN_OPERATION "__K_JUMP_ORIGIN_OPERATION__"
109 #define AUL_SVC_K_FOCUS_ZONE "__K_FOCUS_ZONE__"
110 #define AUL_SVC_K_LAUNCH_RESULT_APP_STARTED "__K_LAUNCH_RESULT_APP_STARTED__"
111 #define AUL_SVC_K_CAN_BE_LEADER "__K_CAN_BE_LEADER__"
112 #define AUL_SVC_K_REROUTE "__K_REROUTE__"
113 #define AUL_SVC_K_SHIFT_WINDOW "__K_SHIFT_WINDOW"
114 #define AUL_SVC_K_RECYCLE "__K_RECYCLE"
115 #define AUL_SVC_K_RELOCATE_BELOW "__K_RELOCATE_BELOW"
116 #define AUL_SVC_K_BG_LAUNCH "__K_BG_LAUNCH"
117 #define AUL_SVC_K_SPLASH_SCREEN "__K_SPLASH_SCREEN"
118 #define AUL_SVC_K_ALIAS_INFO "__K_ALIAS_INFO"
119
120 #define PAD_LOADER_ID_DIRECT    1
121
122 /**
123  * @brief Return values in appsvc.
124  */
125 typedef enum _aul_svc_return_val {
126         AUL_SVC_RET_ECANCELED = -8,     /**< Operation is canceled */
127         AUL_SVC_RET_EREJECTED = -7,  /**< application launch rejected */
128         AUL_SVC_RET_ETERMINATING = -6,   /**< application terminating */
129         AUL_SVC_RET_EILLACC = -5,        /**< Illegal Access */
130         AUL_SVC_RET_ELAUNCH = -4,        /**< Failure on launching the app */
131         AUL_SVC_RET_ENOMATCH = -3,       /**< No matching result Error */
132         AUL_SVC_RET_EINVAL = -2,         /**< Invalid argument */
133         AUL_SVC_RET_ERROR = -1,          /**< General error */
134         AUL_SVC_RET_OK = 0           /**< General success */
135 } aul_svc_return_val;
136
137
138 /**
139  * @brief result values in appsvc.
140  */
141 typedef enum _aul_svc_result_val {
142         AUL_SVC_RES_CANCEL = -2,     /**< Cancel by system */
143         AUL_SVC_RES_NOT_OK = -1,     /**< Fail by user */
144         AUL_SVC_RES_OK = 0       /**< Success by user */
145 } aul_svc_result_val;
146
147
148 /**
149  * @brief aul_svc_res_fn is appsvc result function
150  * @param[out]  b           result bundle
151  * @param[out]  request_code    request code
152  * @param[out]  result          result value
153  * @param[out]  data        user-supplied data
154 */
155 typedef void (*aul_svc_res_fn)(bundle *b, int request_code, aul_svc_result_val result, void *data);
156
157 /**
158  * @brief Called when the result of the launch request is delivered.
159  *
160  * @param[in]   request_code    The request code
161  * @param[in]   result          The result, the process ID of the callee on success otherwise a negative error value
162  * @param[in]   user_data       The user data passed from the callback registration function
163  */
164 typedef void (*aul_svc_err_cb)(int request_code, int result, void *user_data);
165
166 /**
167  * @brief iterator function running with aul_svc_get_list
168  * @param[out]  appid       appid retreived by aul_svc_get_list
169  * @param[out]  data        user-supplied data
170 */
171 typedef int (*aul_svc_info_iter_fn)(const char *appid, void *data);
172
173 typedef int (*aul_svc_host_res_fn)(void *data);
174
175 /**
176  * @par Description:
177  * This function sets an operation to launch application based on appsvc.
178  *
179  * @param[in] b bundle object
180  * @param[in] operation operation
181  *
182  * @return 0 if success, negative value(<0) if fail
183  * @retval AUL_SVC_RET_OK - success
184  * @retval AUL_SVC_RET_ERROR - general error
185  * @retval AUL_SVC_RET_EINVAL - invalid argument(content)
186  *
187  * @pre None.
188  * @post None.
189  * @see None.
190  * @remarks An application must call this function before using aul_svc_run_service API.
191  *
192  * @par Sample code:
193  * @code
194 #include <aul_svc.h>
195
196 ...
197 {
198     bundle *b = NULL;
199
200     b = bundle_create();
201
202     aul_svc_set_operation(b, AUL_SVC_OPERATION_VIEW);
203 }
204  * @endcode
205  *
206  */
207 int aul_svc_set_operation(bundle *b, const char *operation);
208
209 /**
210  * @par Description:
211  * This function sets an uri to launch application based on appsvc.
212  *
213  * @param[in] b bundle object
214  * @param[in] uri uri
215  *
216  * @return 0 if success, negative value(<0) if fail
217  * @retval AUL_SVC_RET_OK - success
218  * @retval AUL_SVC_RET_ERROR - general error
219  * @retval AUL_SVC_RET_EINVAL - invalid argument(content)
220  *
221  * @pre None.
222  * @post None.
223  * @see None.
224  * @remarks None.
225  *
226  * @par Sample code:
227  * @code
228 #include <aul_svc.h>
229
230 ...
231 {
232     bundle *b = NULL;
233
234     b = bundle_create();
235
236     aul_svc_set_operation(b, AUL_SVC_OPERATION_VIEW);
237     aul_svc_set_uri(b,"http://www.samsung.com");
238 }
239  * @endcode
240  *
241  */
242 int aul_svc_set_uri(bundle *b, const char *uri);
243
244 /**
245  * @par Description:
246  * This function sets a mime-type to launch application based on appsvc.
247  *
248  * @param[in] b bundle object
249  * @param[in] mime mime-type
250  *
251  * @return 0 if success, negative value(<0) if fail
252  * @retval AUL_SVC_RET_OK - success
253  * @retval AUL_SVC_RET_ERROR - general error
254  * @retval AUL_SVC_RET_EINVAL - invalid argument(content)
255  *
256  * @pre None.
257  * @post None.
258  * @see None.
259  * @remarks None.
260  *
261  * @par Sample code:
262  * @code
263 #include <aul_svc.h>
264
265 ...
266 {
267     bundle *b = NULL;
268
269     b = bundle_create();
270
271     aul_svc_set_operation(b, AUL_SVC_OPERATION_PICK);
272     aul_svc_set_mime(b,"image/jpg");
273 }
274  * @endcode
275  *
276  */
277 int aul_svc_set_mime(bundle *b, const char *mime);
278
279 /**
280  * @par Description:
281  * This function sets an extra data to launch application based on appsvc.
282  *
283  * @param[in] b bundle object
284  * @param[in] key key of extra data
285  * @param[in] val data
286  *
287  * @return 0 if success, negative value(<0) if fail
288  *
289  * @pre None.
290  * @post None.
291  * @see None.
292  * @remarks None.
293  *
294  * @par Sample code:
295  * @code
296 #include <aul_svc.h>
297
298 ...
299 {
300     bundle *b = NULL;
301
302     b = bundle_create();
303
304     aul_svc_set_operation(b, AUL_SVC_OPERATION_SEND);
305     aul_svc_set_uri(b,"mailto:xxx1@xxx");
306     aul_svc_add_data(b,AUL_SVC_DATA_CC,"xxx2@xxx");
307 }
308  * @endcode
309  *
310  */
311 int aul_svc_add_data(bundle *b, const char *key, const char *val);
312
313 /**
314  * @par Description:
315  * This function sets an extra array data to launch application based on appsvc.
316  *
317  * @param[in] b bundle object
318  * @param[in] key key of extra data
319  * @param[in] val_array data
320  * @param[in] len Length of array
321  *
322  * @return 0 if success, negative value(<0) if fail
323  *
324  * @pre None.
325  * @post None.
326  * @see None.
327  * @remarks None.
328  *
329  * @par Sample code:
330  * @code
331 #include <aul_svc.h>
332
333 ...
334 {
335     bundle *b = NULL;
336     char *images[] = {"/opt/media/a.jpg", "/opt/media/b.jpg", "/opt/media/c.jpg"};
337
338     b = bundle_create();
339
340     aul_svc_add_data_array(b, AUL_SVC_DATA_SELECTED, images, 3);
341 }
342  * @endcode
343  *
344  */
345 int aul_svc_add_data_array(bundle *b, const char *key, const char **val_array, int len);
346
347
348 /**
349  * @par Description:
350  * This function sets a package name to launch application based on appsvc.
351  *
352  * @param[in] b bundle object
353  * @param[in] pkg_name package name for explict launch
354  *
355  * @return 0 if success, negative value(<0) if fail
356  * @retval AUL_SVC_RET_OK - success
357  * @retval AUL_SVC_RET_ERROR - general error
358  * @retval AUL_SVC_RET_EINVAL - invalid argument(content)
359  *
360  * @pre None.
361  * @post None.
362  * @see None.
363  * @remarks None.
364  *
365  * @par Sample code:
366  * @code
367 #include <aul_svc.h>
368
369 ...
370 {
371     bundle *b = NULL;
372
373     b = bundle_create();
374
375     aul_svc_set_operation(b, AUL_SVC_OPERATION_PICK);
376     aul_svc_set_mime(b,"image/jpg");
377     aul_svc_set_pkgname(b, "org.tizen.mygallery");
378 }
379  * @endcode
380  *
381  */
382 /* Deprecated API */
383 int aul_svc_set_pkgname(bundle *b, const char *pkg_name); // __attribute__((deprecated));
384
385
386 /**
387  * @par Description:
388  * This function sets a appid to launch application based on appsvc.
389  *
390  * @param[in] b bundle object
391  * @param[in] appid application id for explict launch
392  *
393  * @return 0 if success, negative value(<0) if fail
394  * @retval AUL_SVC_RET_OK - success
395  * @retval AUL_SVC_RET_ERROR - general error
396  * @retval AUL_SVC_RET_EINVAL - invalid argument(content)
397  *
398  * @pre None.
399  * @post None.
400  * @see None.
401  * @remarks None.
402  *
403  * @par Sample code:
404  * @code
405 #include <aul_svc.h>
406
407 ...
408 {
409     bundle *b = NULL;
410
411     b = bundle_create();
412
413     aul_svc_set_operation(b, AUL_SVC_OPERATION_PICK);
414     aul_svc_set_mime(b,"image/jpg");
415     aul_svc_set_appid(b, "org.tizen.mygallery");
416 }
417  * @endcode
418  *
419  */
420 int aul_svc_set_appid(bundle *b, const char *appid);
421
422
423 /**
424  * @par Description:
425  * This function sets a appid to launch application based on appsvc.
426  *
427  * @param[in] b bundle object
428  * @param[in] application category
429  *
430  * @return 0 if success, negative value(<0) if fail
431  * @retval AUL_SVC_RET_OK - success
432  * @retval AUL_SVC_RET_ERROR - general error
433  * @retval AUL_SVC_RET_EINVAL - invalid argument(content)
434  *
435  * @pre None.
436  * @post None.
437  * @see None.
438  * @remarks None.
439  *
440  * @par Sample code:
441  * @code
442 #include <aul_svc.h>
443
444 ...
445 {
446     bundle *b = NULL;
447
448     b = bundle_create();
449
450     aul_svc_set_operation(b, AUL_SVC_OPERATION_VIEW);
451     aul_svc_set_category(b, "http://tizen.org/category/app/browser");
452 }
453  * @endcode
454  *
455  */
456 int aul_svc_set_category(bundle *b, const char *category);
457
458 /**
459  * @par Description:
460  * This API launch application based on appsvc.
461  *
462  * @param[in] b bundle to be passed to callee
463  * @param[in] request_code request code
464  * @param[in] cbfunc result callback function
465  * @param[in] data user-supplied data passed to callback function
466  *
467  * @return callee's pid if success, negative value(<0) if fail
468  * @retval callee's pid - success
469  * @retval AUL_SVC_RET_ERROR - general error
470  * @retval AUL_SVC_RET_EINVAL - invalid argument(content)
471  * @retval AUL_SVC_RET_ENOMATCH - no matching result Error
472  * @retval AUL_SVC_RET_ELAUNCH - failure on launching the app
473  *
474  * @pre None.
475  * @post None.
476  * @see None.
477  * @remarks None.
478  *
479  * @par Sample code:
480  * @code
481 #include <aul_svc.h>
482
483 ...
484 {
485     bundle *b = NULL;
486     static int num = 0;
487
488     b = bundle_create();
489
490     aul_svc_set_operation(b, AUL_SVC_OPERATION_PICK);
491     aul_svc_set_mime(b,"image/jpg");
492
493     return aul_svc_run_service(b, 0, cb_func, (void*)NULL);
494 }
495  * @endcode
496  *
497  */
498 int aul_svc_run_service(bundle *b, int request_code, aul_svc_res_fn cbfunc, void *data);
499 int aul_svc_run_service_for_uid(bundle *b, int request_code,
500                 aul_svc_res_fn cbfunc, void *data, uid_t uid);
501
502 /**
503  * @par Description:
504  * This API use to get application list that is matched with given bundle.
505  *
506  * @param[in] b bundle to resolve application
507  * @param[in] iter_fn iterator function
508  * @param[in] data user-supplied data for iter_fn
509  *
510  * @return 0 if success, negative value(<0) if fail
511  * @retval AUL_SVC_RET_OK - success
512  * @retval AUL_SVC_RET_EINVAL - invalid argument(content)
513  * @retval AUL_SVC_RET_ENOMATCH - no matching result Error
514  *
515  * @pre None.
516  * @post None.
517  * @see None.
518  * @remarks None.
519  *
520  * @par Sample code:
521  * @code
522 #include <aul_svc.h>
523
524 static int iter_fn(const char* appid, void *data)
525 {
526     printf("\t==========================\n");
527     printf("\t appid: %s\n", appid);
528     printf("\t==========================\n");
529     return 0;
530 }
531
532 ...
533 {
534     bundle *b = NULL;
535     static int num = 0;
536
537     b = bundle_create();
538
539     aul_svc_set_operation(b, AUL_SVC_OPERATION_PICK);
540     aul_svc_set_mime(b,"image/jpg");
541
542     return aul_svc_get_list(b, iter_fn, (void*)NULL);
543 }
544  * @endcode
545  *
546  */
547 int aul_svc_get_list(bundle *b, aul_svc_info_iter_fn iter_fn, void *data);
548 int aul_svc_get_list_for_uid(bundle *b, aul_svc_info_iter_fn iter_fn,
549                 void *data, uid_t uid);
550
551 /**
552  * @par Description:
553  * This API use to get default applications
554  *
555  * @param[in] iter_fn iterator function
556  * @param[in] data user-supplied data for iter_fn
557  *
558  * @return 0 if success, negative value(<0) if fail
559  * @retval AUL_SVC_RET_OK - success
560  * @retval AUL_SVC_RET_EINVAL - invalid argument(content)
561  * @retval AUL_SVC_RET_ENOMATCH - no matching result Error
562  *
563  * @pre None.
564  * @post None.
565  * @see None.
566  * @remarks None.
567  *
568  * @par Sample code:
569  * @code
570 #include <aul_svc.h>
571
572 static int iter_fn(const char* appid, void *data)
573 {
574     printf("\t==========================\n");
575     printf("\t appid : %s\n", appid);
576     printf("\t==========================\n");
577     return 0;
578 }
579
580 ...
581 {
582     return aul_svc_get_all_defapps(iter_fn, (void*)NULL);
583 }
584  * @endcode
585  *
586  */
587 int aul_svc_get_all_defapps(aul_svc_info_iter_fn iter_fn, void *data);
588 int aul_svc_get_all_defapps_for_uid(aul_svc_info_iter_fn iter_fn,
589                 void *data, uid_t uid);
590
591 /**
592  * @par Description:
593  * This function gets a operation from bundle.
594  *
595  * @param[in] b bundle object
596  *
597  * @return Pointer for operation string if success, NULL if fail
598  *
599  * @pre None.
600  * @post None.
601  * @see None.
602  * @remarks None.
603  *
604  * @par Sample code:
605  * @code
606 #include <aul_svc.h>
607
608 ...
609 {
610     char *val;
611     val = aul_svc_get_operation(b);
612 }
613  * @endcode
614  *
615  */
616 const char *aul_svc_get_operation(bundle *b);
617
618 /**
619  * @par Description:
620  * This function gets a uri from bundle.
621  *
622  * @param[in] b bundle object
623  *
624  * @return Pointer for uri string if success, NULL if fail
625  *
626  * @pre None.
627  * @post None.
628  * @see None.
629  * @remarks None.
630  *
631  * @par Sample code:
632  * @code
633 #include <aul_svc.h>
634
635 ...
636 {
637     char *val;
638     val = aul_svc_get_uri(b);
639 }
640  * @endcode
641  *
642  */
643 const char *aul_svc_get_uri(bundle *b);
644
645 /**
646  * @par Description:
647  * This function gets a mime-type from bundle.
648  *
649  * @param[in] b bundle object
650  *
651  * @return Pointer for mime-type string if success, NULL if fail
652  *
653  * @pre None.
654  * @post None.
655  * @see None.
656  * @remarks None.
657  *
658  * @par Sample code:
659  * @code
660 #include <aul_svc.h>
661
662 ...
663 {
664     char *val;
665     val = aul_svc_get_mime(b);
666 }
667  * @endcode
668  *
669  */
670 const char *aul_svc_get_mime(bundle *b);
671
672 /**
673  * @par Description:
674  * This function gets a package name from bundle.
675  *
676  * @param[in] b bundle object
677  *
678  * @return Pointer for package name string if success, NULL if fail
679  *
680  * @pre None.
681  * @post None.
682  * @see None.
683  * @remarks None.
684  *
685  * @par Sample code:
686  * @code
687 #include <aul_svc.h>
688
689 ...
690 {
691     char *val;
692     val = aul_svc_get_pkgname(b);
693 }
694  * @endcode
695  *
696  */
697 /* Deprecated API */
698 const char *aul_svc_get_pkgname(bundle *b); // __attribute__((deprecated));
699
700 /**
701  * @par Description:
702  * This function gets a application id from bundle.
703  *
704  * @param[in] b bundle object
705  *
706  * @return Pointer for application id string if success, NULL if fail
707  *
708  * @pre None.
709  * @post None.
710  * @see None.
711  * @remarks None.
712  *
713  * @par Sample code:
714  * @code
715 #include <aul_svc.h>
716
717 ...
718 {
719     char *val;
720     val = aul_svc_get_appid(b);
721 }
722  * @endcode
723  *
724  */
725 const char *aul_svc_get_appid(bundle *b);
726
727 /**
728  * @par Description:
729  * This function gets a application category from bundle.
730  *
731  * @param[in] b bundle object
732  *
733  * @return Pointer for application category string if success, NULL if fail
734  *
735  * @pre None.
736  * @post None.
737  * @see None.
738  * @remarks None.
739  *
740  * @par Sample code:
741  * @code
742 #include <aul_svc.h>
743
744 ...
745 {
746     char *val;
747     val = aul_svc_get_category(b);
748 }
749  * @endcode
750  *
751  */
752 const char *aul_svc_get_category(bundle *b);
753
754 /**
755  * @par Description:
756  * This function gets value from key.
757  *
758  * @param[in] b bundle object
759  * @param[in] key key
760  *
761  * @return Pointer for value string if success, NULL if fail
762  *
763  * @pre None.
764  * @post None.
765  * @see None.
766  * @remarks None.
767  *
768  * @par Sample code:
769  * @code
770 #include <aul_svc.h>
771
772 ...
773 {
774     char *val;
775     val = aul_svc_get_data(b, AUL_SVC_DATA_CC);
776 }
777  * @endcode
778  *
779  */
780 const char *aul_svc_get_data(bundle *b, const char *key);
781
782 /**
783  * @par Description:
784  * This function gets value from key.
785  *
786  * @param[in] b bundle object
787  * @param[in] key key
788  * @param[out] len length of array
789  *
790  * @return Pointer for value string array if success, NULL if fail
791  *
792  * @pre None.
793  * @post None.
794  * @see None.
795  * @remarks None.
796  *
797  * @par Sample code:
798  * @code
799 #include <aul_svc.h>
800
801 ...
802 {
803         char **val_array;
804         int len;
805         char *val;
806
807         if(aul_svc_data_is_array(b, AUL_SVC_DATA_SELECTED))
808                 val_array = aul_svc_get_data_array(b, AUL_SVC_DATA_SELECTED, &len);
809         else
810                 val = aul_svc_get_data(b, AUL_SVC_DATA_SELECTED);
811 }
812  * @endcode
813  *
814  */
815 const char **aul_svc_get_data_array(bundle *b, const char *key, int *len);
816
817 /**
818  * @par Description:
819  * This API create appsvc result bundle based on bundle received in reset event.
820  *
821  * @param[in] inb bundle received in reset event
822  * @param[in] outb bundle to use for returning result
823  *
824  * @retval AUL_SVC_RET_OK - success
825  * @retval AUL_SVC_RET_ERROR - general error
826  * @retval AUL_SVC_RET_EINVAL - invalid argument(content)
827  *
828  * @pre None.
829  * @post None.
830  * @see aul_svc_send_result.
831  * @remarks None.
832  *
833  * @par Sample code:
834  * @code
835 #include <aul_svc.h>
836
837 ...
838 {
839     struct appdata *ad = data;
840     bundle* res_bundle;
841
842     aul_svc_create_result_bundle(ad->b,&res_bundle);
843     bundle_add(res_bundle, "result", "1");
844     aul_svc_send_result(res_bundle, 0);
845 }
846  * @endcode
847  *
848  */
849 int aul_svc_create_result_bundle(bundle *inb, bundle **outb);
850
851 /**
852  * @par Description:
853  * This API send appsvc result to caller with bundle.
854  *
855  * @param[in] b Result data in bundle format
856  * @param[in] result result value
857  *
858  * @retval AUL_SVC_RET_OK - success
859  * @retval AUL_SVC_RET_ERROR - general error
860  * @retval AUL_SVC_RET_EINVAL - invalid argument(content)
861  *
862  * @pre aul_svc_create_result_bundle.
863  * @post None.
864  * @see aul_svc_send_result.
865  * @remarks None.
866  *
867  * @par Sample code:
868  * @code
869 #include <aul_svc.h>
870
871 ...
872 {
873     struct appdata *ad = data;
874     bundle* res_bundle;
875
876     aul_svc_create_result_bundle(ad->b,&res_bundle);
877     bundle_add(res_bundle, "result", "1");
878     aul_svc_send_result(res_bundle, 0);
879 }
880  * @endcode
881  *
882  */
883 int aul_svc_send_result(bundle *b, aul_svc_result_val result);
884
885 /**
886  * @par Description:
887  * This API set the default application(package name) associated with op, uri and mime-type.
888  *
889  * @param[in] op        operation
890  * @param[in] mime_type mime-type
891  * @param[in] scheme    scheme of uri
892  * @param[in] defapp    default application
893  *
894  * @retval AUL_SVC_RET_OK - success
895  * @retval AUL_SVC_RET_ERROR - general error
896  * @retval AUL_SVC_RET_EINVAL - invalid argument(content)
897  *
898  * @pre None.
899  * @post None.
900  * @see None.
901  * @remarks None.
902  *
903  * @par Sample code:
904  * @code
905 #include <aul_svc.h>
906
907 ...
908 {
909     aul_svc_set_defapp(AUL_SVC_OPERATION_VIEW, NULL,"http", "org.tizen.mybrowser");
910 }
911  * @endcode
912  *
913  */
914 int aul_svc_set_defapp(const char *op, const char *mime_type, const char *uri,
915                                                 const char *defapp);
916 int aul_svc_set_defapp_for_uid(const char *op, const char *mime_type, const char *uri,
917                                                 const char *defapp, uid_t uid);
918
919 /**
920  * @par Description:
921  * This API unset the default application(package name) associated with op, uri and mime-type.
922  *
923  * @param[in] defapp    default application
924  *
925  * @retval AUL_SVC_RET_OK - success
926  * @retval AUL_SVC_RET_ERROR - general error
927  *
928  * @pre None.
929  * @post None.
930  * @see None.
931  * @remarks None.
932  *
933  * @par Sample code:
934  * @code
935 #include <aul_svc.h>
936
937 ...
938 {
939     aul_svc_unset_defapp("org.tizen.test");
940 }
941  * @endcode
942  *
943  */
944 int aul_svc_unset_defapp(const char *defapp);
945 int aul_svc_unset_defapp_for_uid(const char *defapp, uid_t uid);
946
947 /**
948  * @par Description:
949  * This API unset all of default applications associated with op, uri and mime-type.
950  *
951  *
952  * @retval AUL_SVC_RET_OK - success
953  * @retval AUL_SVC_RET_ERROR - general error
954  *
955  * @pre None.
956  * @post None.
957  * @see None.
958  * @remarks None.
959  *
960  * @par Sample code:
961  * @code
962 #include <aul_svc.h>
963
964 ...
965 {
966     aul_svc_unset_all_defapps();
967 }
968  * @endcode
969  *
970  */
971 int aul_svc_unset_all_defapps();
972 int aul_svc_unset_all_defapps_for_uid(uid_t uid);
973
974 /**
975  * @par Description:
976  *  This API ask a application is default application or not.
977  *
978  * @param[in]   appid   application appid
979  * @return  true / false
980  * @retval  1   app_name is default application in appsvc.
981  * @retval  0   app_name is NOT default application in appsvc.
982  *
983   * @pre None.
984   * @post None.
985   * @see None.
986   * @remarks None.
987   *
988   * @par Sample code:
989   * @code
990 #include <aul_svc.h>
991
992  ...
993
994  * int is_defapp_browser_app()
995  * {
996  *      return aul_svc_is_defapp("org.tizen.browser");
997  * }
998  *
999  * @endcode
1000  * @remark
1001  *  None
1002 *
1003 */
1004 int aul_svc_is_defapp(const char *appid);
1005 int aul_svc_is_defapp_for_uid(const char *pkg_name, uid_t uid);
1006
1007
1008 /**
1009  * @par Description:
1010  *  This API ask a extra data is array or not.
1011  *
1012  * @param[in] b bundle object
1013  * @param[in] key key of extra data
1014  * @return  true / false
1015  * @retval  1   a extra data is array.
1016  * @retval  0   a extra data is not array.
1017  *
1018   * @pre None.
1019   * @post None.
1020   * @see None.
1021   * @remarks None.
1022   *
1023   * @par Sample code:
1024   * @code
1025 #include <aul_svc.h>
1026
1027  ...
1028
1029  * int aul_svc_data_is_array(bundle *b, char *key)
1030  * {
1031  *      return aul_svc_data_is_array(b, key);
1032  * }
1033  *
1034  * @endcode
1035  * @remark
1036  *  None
1037 *
1038 */
1039 int aul_svc_data_is_array(bundle *b, const char *key);
1040
1041 int aul_svc_subapp_terminate_request_pid(int pid);
1042
1043 /**
1044  * @par Description:
1045  * This function sets an uri to launch application based on appsvc.
1046  *
1047  * @param[in] b bundle object
1048  * @param[in] char *mode
1049  *
1050  * @return 0 if success, negative value(<0) if fail
1051  * @retval AUL_SVC_RET_OK - success
1052  * @retval AUL_SVC_RET_ERROR - general error
1053  * @retval AUL_SVC_RET_EINVAL - invalid argument(content)
1054  *
1055  * @pre None.
1056  * @post None.
1057  * @see None.
1058  * @remarks None.
1059  *
1060  * @par Sample code:
1061  * @code
1062 #include <aul_svc.h>
1063
1064 ...
1065 {
1066     aul_svc_set_launch_mode(app_control->data, mode);
1067 }
1068  * @endcode
1069  *
1070  */
1071 int aul_svc_set_launch_mode(bundle *b, const char *mode);
1072
1073 /**
1074  * @par Description:
1075  * This function sets an uri to launch application based on appsvc.
1076  *
1077  * @param[in] b bundle object
1078  *
1079  * @return Pointer for launch mode string if success, NULL if fail
1080  *
1081  * @pre None.
1082  * @post None.
1083  * @see None.
1084  * @remarks None.
1085  *
1086  * @par Sample code:
1087  * @code
1088 #include <aul_svc.h>
1089
1090 ...
1091 {
1092     aul_svc_get_launch_mode(app_control->data);
1093 }
1094  * @endcode
1095  *
1096  */
1097 const char *aul_svc_get_launch_mode(bundle *b);
1098
1099 int aul_svc_allow_transient_app(bundle *b, int wid);
1100
1101 int aul_svc_request_transient_app(bundle *b, int callee_wid,
1102                 aul_svc_host_res_fn cbfunc, void *data);
1103
1104 int aul_svc_subscribe_launch_result(bundle *b, const char *event);
1105
1106 /**
1107  * @par Description:
1108  * This function sets loader ID into bundle.
1109  *
1110  * @param[in] b Bundle object
1111  * @param[in] loader_id Loader ID from aul_add_loader() or PAD_LOADER_ID_DIRECT to launch apps without loader
1112  *
1113  * @return 0 if success, negative value(<0) if fail
1114  * @see aul_add_loader, aul_remove_loader
1115  * @remarks This API is only for Appfw internally.
1116  */
1117 int aul_svc_set_loader_id(bundle *b, int loader_id);
1118
1119 /**
1120  * @par Description:
1121  * This function sets loader name into bundle. Launchpad will assign a static slot to launch an app.
1122  *
1123  * @param[in] b Bundle object
1124  * @param[in] loader_name Loader name to assign
1125  *
1126  * @return 0 if success, negative value(<0) if fail
1127  * @remarks This API is only for Appfw internally.
1128  */
1129 int aul_svc_set_loader_name(bundle *b, const char *loader_name);
1130
1131 /**
1132  * @par Description:
1133  * This API sets the background launch mode.
1134  * If the background launch mode is enabled, a window of the callee process doesn't appear on the screen.
1135  *
1136  * @param[in] b Bundle object
1137  * @param[in] enabled boolean (true / false)
1138  *
1139  * @return 0 if success, negative value(<0) if fail
1140  * @remarks This API is only for Appfw internally.
1141  */
1142 int aul_svc_set_background_launch(bundle *b, int enabled);
1143
1144 /**
1145  * @par Description:
1146  * This API set the alias appid.
1147  *
1148  * @param[in] alias_appid       an alias application ID
1149  * @param[in] appid             an application ID
1150  * @return 0 if success, negative value(<0) if fail
1151  */
1152 int aul_svc_set_alias_appid(const char *alias_appid, const char *appid);
1153 int aul_svc_set_alias_appid_for_uid(const char *alias_appid,
1154                 const char *appid, uid_t uid);
1155
1156 /**
1157  * @par Description:
1158  * This API unset the alias appid.
1159  *
1160  * @param[in] alias_appid an alias application ID
1161  *
1162  * @return 0 if success, negative value(<0) if fail
1163  */
1164 int aul_svc_unset_alias_appid(const char *alias_appid);
1165 int aul_svc_unset_alias_appid_for_uid(const char *alias_appid, uid_t uid);
1166
1167 /**
1168  * @par Description:
1169  * This API retrieves all alias information.
1170  *
1171  * @param[in]   callback        The callback function to be invoked
1172  * @param[in]   user_data       The user data to be passed to the callback function
1173  *
1174  * @return      0 if success, negative value(<0) if fail
1175  */
1176 int aul_svc_foreach_alias_info(void (*callback)(const char *alias_appid,
1177                         const char *appid, void *data), void *user_data);
1178 int aul_svc_foreach_alias_info_for_uid(void (*callback)(const char *alias_appid,
1179                         const char *appid, void *data),
1180                 uid_t uid, void *user_data);
1181
1182 /**
1183  * @par Description:
1184  * This API activates the alias information based on the given appid.
1185  *
1186  * @param[in]   appid   an application ID
1187  * @return      0 if success, negative value(<0) if fail
1188  */
1189 int aul_svc_enable_alias_info(const char *appid);
1190 int aul_svc_enable_alias_info_for_uid(const char *appid, uid_t uid);
1191
1192 /**
1193  * @par Description:
1194  * This API deactivates the alias information based on the given appid.
1195  *
1196  * @param[in]   appid   an application ID
1197  * @return      0 if success, negative value(<0) if fail
1198  */
1199 int aul_svc_disable_alias_info(const char *appid);
1200 int aul_svc_disable_alias_info_for_uid(const char *appid, uid_t uid);
1201
1202 /**
1203  * @par Description:
1204  * This API gets an application ID by an alias application ID.
1205  *
1206  * @param[in]   alias_appid   An alias application ID
1207  * @param[out]  appid         An application ID
1208  *
1209  * @return      0 if success, negative value(<0) if fail
1210  */
1211 int aul_svc_get_appid_by_alias_appid(const char *alias_appid, char **appid);
1212 int aul_svc_get_appid_by_alias_appid_for_uid(const char *alias_appid,
1213                 char **appid, uid_t uid);
1214
1215 /**
1216  * @par Description:
1217  * This API retrieves all alias information based on the given appid.
1218  *
1219  * @param[in]   callback        The callback function to be invoked
1220  * @param[in]   appid           An application ID
1221  * @param[in]   user_data       The user data to be passed to the callback function
1222  *
1223  * @return      0 if success, negative value(<0) if fail
1224  */
1225 int aul_svc_foreach_alias_info_by_appid(int (*callback)(
1226                         const char *alias_appid, const char *appid, void *data),
1227                 const char *appid, void *user_data);
1228 int aul_svc_foreach_alias_info_by_appid_for_uid(int (*callback)(
1229                         const char *alias_appid, const char *appid, void *data),
1230                 const char *appid, uid_t uid, void *user_data);
1231
1232 /**
1233  * @par Description:
1234  * This API retrieves all allowed information.
1235  *
1236  * @param[in]   callback        The callback function to be invoked
1237  * @param[in]   user_data       The user data to be passed to the callback function
1238  *
1239  * @return      0 if success, negative value(<0) if fail
1240  */
1241 int aul_svc_foreach_allowed_info(int (*callback)(const char *appid,
1242                         const char *allowed_appid, void *data),
1243                 void *user_data);
1244 int aul_svc_foreach_allowed_info_for_uid(int (*callback)(const char *appid,
1245                         const char *allowed_appid, void *data),
1246                 uid_t uid, void *user_data);
1247
1248 /**
1249  * @par Description:
1250  * This API retrieves all allowed information based on the given appid.
1251  *
1252  * @param[in]   callback        The callback function to be invoked
1253  * @param[in]   appid           An application ID
1254  * @param[in]   user_data       The user data to be passed to the callback function
1255  *
1256  * @return      0 if success, negative value(<0) if fail
1257  */
1258 int aul_svc_foreach_allowed_info_by_appid(int (*callback)(
1259                         const char *appid, const char *allowed_appid, void *data),
1260                 const char *appid, void *user_data);
1261 int aul_svc_foreach_allowed_info_by_appid_for_uid(int (*callback)(
1262                         const char *appid, const char *allowed_appid, void *data),
1263                 const char *appid, uid_t uid, void *user_data);
1264
1265 /**
1266  * @par Description:
1267  *      Gets the instance ID.
1268  *
1269  * @param[in]   b               Bundle object
1270  *
1271  * @return Pointer for application id string if success, NULL if fail
1272  */
1273 const char *aul_svc_get_instance_id(bundle *b);
1274
1275 /**
1276  * @par Description:
1277  *      Sets the instance ID.
1278  *
1279  * @param[in]  b                Bundle object
1280  * @param[in]  instance ID      Instance ID
1281  *
1282  * @return 0 if success, negative value(<0) if fail
1283  */
1284 int aul_svc_set_instance_id(bundle *b, const char *instance_id);
1285
1286 /**
1287  * @par Description:
1288  *      Sends the launch request asynchronous.
1289  *
1290  * @param[in]  b                Bundle object
1291  * @param[in]  request_code     Request Code
1292  * @param[in]  cbfunc           Callback function
1293  * @param[in]  data             User data
1294  *
1295  * @return     a pid of the callee on success,
1296  *             otherwise a negative error value
1297  */
1298 int aul_svc_run_service_async(bundle *b, int request_code,
1299                 aul_svc_res_fn cbfunc, void *data);
1300 int aul_svc_run_service_async_for_uid(bundle *b, int request_code,
1301                 aul_svc_res_fn cbfunc, void *data, uid_t uid);
1302
1303
1304 /**
1305  * @brief Sends the launch request asynchronous.
1306  *
1307  * @param[in]   b               The bundle object
1308  * @param[in]   request_code    The request code
1309  * @param[in]   cbfunc          The reply callback function
1310  * @param[in]   err_cb          The result callback function
1311  * @param[in]   user_data       The user data to be passed to the callback function
1312  *
1313  * @return      a pid of the callee on success,
1314  *              otherwise a negative error value
1315  */
1316 int aul_svc_send_launch_request(bundle *b, int request_code,
1317                 aul_svc_res_fn cbfunc, aul_svc_err_cb err_cb,
1318                 void *user_data);
1319
1320 /**
1321  * @brief Sends the launch request asynchronous.
1322  *
1323  * @param[in]   b               The bundle object
1324  * @param[in]   request_code    The request code
1325  * @param[in]   cbfunc          The reply callback function
1326  * @param[in]   err_cb          The result callback function
1327  * @param[in]   user_data       The user data to be passed to the callback function
1328  * @param[in]   uid             The user ID
1329  *
1330  * @return      a pid of the callee on success,
1331  *              otherwise a negative error value
1332  */
1333 int aul_svc_send_launch_request_for_uid(bundle *b, int request_code,
1334                 aul_svc_res_fn cbfunc, aul_svc_err_cb err_cb,
1335                 void *user_data, uid_t uid);
1336
1337 /**
1338  * @brief Sends the launch request synchronous.
1339  *
1340  * @param[in]   b               The bundle object
1341  * @param[in]   request_code    The request code
1342  * @param[out]  res_b           The bundle object
1343  * @param[out]  res             The result
1344  * @param[in]   uid             The user ID
1345  *
1346  * @return      a pid of the callee on success,
1347  *              otherwise a negative error value
1348  */
1349 int aul_svc_send_launch_request_sync_for_uid(bundle *b, int request_code,
1350                 bundle **res_b, aul_svc_result_val *res, uid_t uid);
1351
1352 /**
1353  * @brief Sets the ID of the caller instance.
1354  * @since_tizen 5.5
1355  *
1356  * @param[in]   b               The bundle object
1357  * @param[in]   instance_id     The ID of the caller instance
1358  *
1359  * @return      @c 0 on success,
1360  *              otherwise a negative error value
1361  */
1362 int aul_svc_set_caller_instance_id(bundle *b, const char *instance_id);
1363
1364 /**
1365  * @brief Sets the ID of the component.
1366  * @since_tizen 5.5
1367  *
1368  * @param[in]   b               The bundle object
1369  * @param[in]   comp_id         The ID of the component
1370  *
1371  * @return      @c 0 on success,
1372  *              otherwise a negative error value
1373  */
1374 int aul_svc_set_comp_id(bundle *b, const char *comp_id);
1375
1376 /**
1377  * @brief Gets the ID of the component.
1378  * @since_tizen 5.5
1379  *
1380  * @param[in]   b               The bundle object
1381  *
1382  * @return      @c a component ID on success,
1383  *              otherwise a nullptr
1384  */
1385 const char *aul_svc_get_comp_id(bundle *b);
1386
1387 #ifdef __cplusplus
1388 }
1389 #endif