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