645f1031ea66a9ce968f5f93a6059542798f8f89
[AGL/documentation.git] / docs / 4_APIs_and_Services / 4.3_Application_Framework_Binder / 3_Binder_references / 7_Functions_of_class afb_service.md
1 ---
2 edit_link: ''
3 title: Functions of class afb_service
4 origin_url: >-
5   https://git.automotivelinux.org/src/app-framework-binder/plain/docs/reference-v3/func-service.md?h=master
6 ---
7
8 <!-- WARNING: This file is generated by fetch_docs.js using /home/boron/Documents/AGL/docs-webtemplate/site/_data/tocs/apis_services/master/app-framework-binder-developer-guides-api-services-book.yml -->
9
10 Functions of class **afb_service**
11 ==============================
12
13 All the functions of the class **afb_service** use the default api.
14
15 All these function are deprecated, try to use functions of class **afb_api** instead.
16
17 ## afb_service_call
18
19 ```C
20 /**
21  * @deprecated try to use @ref afb_api_call instead
22  *
23  * Calls the 'verb' of the 'api' with the arguments 'args' and 'verb' in the name of the binding.
24  * The result of the call is delivered to the 'callback' function with the 'callback_closure'.
25  *
26  * For convenience, the function calls 'json_object_put' for 'args'.
27  * Thus, in the case where 'args' should remain available after
28  * the function returns, the function 'json_object_get' shall be used.
29  *
30  * The 'callback' receives 5 arguments:
31  *  1. 'closure' the user defined closure pointer 'closure',
32  *  2. 'object'  a JSON object returned (can be NULL)
33  *  3. 'error'   a string not NULL in case of error but NULL on success
34  *  4. 'info'    a string handling some info (can be NULL)
35  *  5. 'api'     the api
36  *
37  * @param api      The api name of the method to call
38  * @param verb     The verb name of the method to call
39  * @param args     The arguments to pass to the method
40  * @param callback The to call on completion
41  * @param closure  The closure to pass to the callback
42  *
43  *
44  * @see afb_req_subcall
45  * @see afb_req_subcall_sync
46  * @see afb_api_call_sync
47  */
48 void afb_service_call(
49                         const char *api,
50                         const char *verb,
51                         struct json_object *args,
52                         void (*callback)(
53                                         void *closure,
54                                         struct json_object *object,
55                                         const char *error,
56                                         const char * info,
57                                         afb_api_t api),
58                         void *closure);
59 ```
60
61 ## afb_service_call_sync
62
63 ```C
64 /**
65  * @deprecated try to use @ref afb_api_call_sync instead
66  *
67  * Calls the 'verb' of the 'api' with the arguments 'args' and 'verb' in the name of the binding.
68  * 'result' will receive the response.
69  *
70  * For convenience, the function calls 'json_object_put' for 'args'.
71  * Thus, in the case where 'args' should remain available after
72  * the function returns, the function 'json_object_get' shall be used.
73  *
74  * @param api      The api name of the method to call
75  * @param verb     The verb name of the method to call
76  * @param args     The arguments to pass to the method
77  * @param object   Where to store the returned object - should call json_object_put on it - can be NULL
78  * @param error    Where to store the copied returned error - should call free on it - can be NULL
79  * @param info     Where to store the copied returned info - should call free on it - can be NULL
80  *
81  * @returns 0 in case of success or a negative value in case of error.
82  *
83  * @see afb_req_subcall
84  * @see afb_req_subcall_sync
85  * @see afb_api_call
86  */
87 int afb_service_call_sync(
88                         const char *api,
89                         const char *verb,
90                         struct json_object *args,
91                         struct json_object **object,
92                         char **error,
93                         char **info);
94 ```
95
96 ## afb_service_call_legacy
97
98 ```C
99 /**
100  * @deprecated try to use @ref afb_api_call instead
101  *
102  * Calls the 'verb' of the 'api' with the arguments 'args' and 'verb'
103  * in the name of the binding.
104  * The result of the call is delivered to the 'callback' function with
105  * the 'callback_closure'.
106  *
107  * For convenience, the function calls 'json_object_put' for 'args'.
108  * Thus, in the case where 'args' should remain available after
109  * the function returns, the function 'json_object_get' shall be used.
110  *
111  * The 'callback' receives 3 arguments:
112  *  1. 'closure' the user defined closure pointer 'closure',
113  *  2. 'status' a status being 0 on success or negative when an error occurred,
114  *  2. 'result' the resulting data as a JSON object.
115  *
116  * @param api      The api name of the method to call
117  * @param verb     The verb name of the method to call
118  * @param args     The arguments to pass to the method
119  * @param callback The to call on completion
120  * @param closure  The closure to pass to the callback
121  *
122  * @see also 'afb_api_call'
123  * @see also 'afb_api_call_sync'
124  * @see also 'afb_api_call_sync_legacy'
125  * @see also 'afb_req_subcall'
126  * @see also 'afb_req_subcall_sync'
127  */
128 void afb_service_call_legacy(
129                         const char *api,
130                         const char *verb,
131                         struct json_object *args,
132                         void (*callback)(
133                                         void *closure,
134                                         int status,
135                                         struct json_object *result,
136                                         afb_api_t api),
137                         void *closure);
138 ```
139
140 ## afb_service_call_sync_legacy
141
142 ```C
143 /**
144  * @deprecated try to use @ref afb_api_call_sync instead
145  *
146  * Calls the 'verb' of the 'api' with the arguments 'args' and 'verb' in the
147  * name of the binding. 'result' will receive the response.
148  *
149  * For convenience, the function calls 'json_object_put' for 'args'.
150  * Thus, in the case where 'args' should remain available after
151  * the function returns, the function 'json_object_get' shall be used.
152  *
153  * @param api      The api name of the method to call
154  * @param verb     The verb name of the method to call
155  * @param args     The arguments to pass to the method
156  * @param result   Where to store the result - should call json_object_put on it -
157  *
158  * @returns 0 in case of success or a negative value in case of error.
159  *
160  * @see also 'afb_api_call'
161  * @see also 'afb_api_call_sync'
162  * @see also 'afb_api_call_legacy'
163  * @see also 'afb_req_subcall'
164  * @see also 'afb_req_subcall_sync'
165  */
166 int afb_service_call_sync_legacy(
167                         const char *api,
168                         const char *verb,
169                         struct json_object *args,
170                         struct json_object **result);
171 ```