973c158c82f3eb024bbb31648adb15d0a4f77a73
[src/app-framework-main.git] / src / utils-jbus.h
1 /*
2  Copyright 2015 IoT.bzh
3
4  author: José Bollo <jose.bollo@iot.bzh>
5
6  Licensed under the Apache License, Version 2.0 (the "License");
7  you may not use this file except in compliance with the License.
8  You may obtain a copy of the License at
9
10      http://www.apache.org/licenses/LICENSE-2.0
11
12  Unless required by applicable law or agreed to in writing, software
13  distributed under the License is distributed on an "AS IS" BASIS,
14  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  See the License for the specific language governing permissions and
16  limitations under the License.
17 */
18
19
20 struct jreq;
21 struct jbus;
22
23 extern struct jbus *create_jbus(const char *path, int session);
24 extern struct jbus *create_jbus_session(const char *path);
25 extern struct jbus *create_jbus_system(const char *path);
26
27 extern void jbus_addref(struct jbus *jbus);
28 extern void jbus_unref(struct jbus *jbus);
29
30 struct pollfd;
31 extern int jbus_fill_pollfds(struct jbus **jbuses, int njbuses, struct pollfd *fds);
32 extern int jbus_dispatch_pollfds(struct jbus **jbuses, int njbuses, struct pollfd *fds, int maxcount);
33 extern int jbus_read_write_dispatch_multiple(struct jbus **jbuses, int njbuses, int toms, int maxcount);
34 extern int jbus_dispatch_multiple(struct jbus **jbuses, int njbuses, int maxcount);
35
36 extern int jbus_read_write_dispatch(struct jbus *jbus, int toms);
37
38 /* verbs for the clients */
39 extern int jbus_call_ss(struct jbus *jbus, const char *method, const char *query, void (*onresp)(int, const char *, void *), void *data);
40 extern int jbus_call_js(struct jbus *jbus, const char *method, struct json_object *query, void (*onresp)(int, const char *, void *), void *data);
41 extern int jbus_call_sj(struct jbus *jbus, const char *method, const char *query, void (*onresp)(int, struct json_object *, void *), void *data);
42 extern int jbus_call_jj(struct jbus *jbus, const char *method, struct json_object *query, void (*onresp)(int, struct json_object *, void *), void *data);
43
44 extern char *jbus_call_ss_sync(struct jbus *jbus, const char *method, const char *query);
45 extern char *jbus_call_js_sync(struct jbus *jbus, const char *method, struct json_object *query);
46 extern struct json_object *jbus_call_sj_sync(struct jbus *jbus, const char *method, const char *query);
47 extern struct json_object *jbus_call_jj_sync(struct jbus *jbus, const char *method, struct json_object *query);
48
49 extern int jbus_on_signal_s(struct jbus *jbus, const char *name, void (*onsignal)(const char *));
50 extern int jbus_on_signal_j(struct jbus *jbus, const char *name, void (*onsignal)(struct json_object *));
51
52 /* verbs for servers */
53 extern int jbus_reply_s(struct jreq *jreq, const char *reply);
54 extern int jbus_reply_j(struct jreq *jreq, struct json_object *reply);
55 extern int jbus_reply_error_s(struct jreq *jreq, const char *reply);
56 extern int jbus_reply_error_j(struct jreq *jreq, struct json_object *reply);
57
58 extern int jbus_add_service_s(struct jbus *jbus, const char *method, void (*oncall)(struct jreq *, const char *));
59 extern int jbus_add_service_j(struct jbus *jbus, const char *method, void (*oncall)(struct jreq *, struct json_object *));
60 extern int jbus_start_serving(struct jbus *jbus);
61 extern int jbus_send_signal_s(struct jbus *jbus, const char *name, const char *content);
62 extern int jbus_send_signal_j(struct jbus *jbus, const char *name, struct json_object *content);
63
64