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