use upoll for event loop
[src/app-framework-binder.git] / plugins / afm-main-plugin / 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 #pragma once
20
21 struct sbusmsg;
22 struct jbus;
23
24 extern struct jbus *create_jbus(struct sbus *sbus, const char *path);
25
26 extern void jbus_addref(struct jbus *jbus);
27 extern void jbus_unref(struct jbus *jbus);
28
29 /* verbs for the clients */
30 extern int jbus_call_ss(
31                 struct jbus *jbus,
32                 const char *method,
33                 const char *query,
34                 void (*onresp) (int, const char *, void *),
35                 void *data);
36
37 extern int jbus_call_js(
38                 struct jbus *jbus,
39                 const char *method,
40                 struct json_object *query,
41                 void (*onresp) (int, const char *, void *),
42                 void *data);
43
44 extern int jbus_call_sj(
45                 struct jbus *jbus,
46                 const char *method,
47                 const char *query,
48                 void (*onresp) (int, struct json_object *, void *),
49                 void *data);
50
51 extern int jbus_call_jj(
52                 struct jbus *jbus,
53                 const char *method,
54                 struct json_object *query,
55                 void (*onresp) (int, struct json_object *, void *),
56                 void *data);
57
58 extern char *jbus_call_ss_sync(
59                 struct jbus *jbus,
60                 const char *method,
61                 const char *query);
62
63 extern char *jbus_call_js_sync(
64                 struct jbus *jbus,
65                 const char *method,
66                 struct json_object *query);
67
68 extern struct json_object *jbus_call_sj_sync(
69                 struct jbus *jbus,
70                 const char *method,
71                 const char *query);
72
73 extern struct json_object *jbus_call_jj_sync(
74                 struct jbus *jbus,
75                 const char *method,
76                 struct json_object *query);
77
78 extern int jbus_on_signal_s(
79                 struct jbus *jbus,
80                 const char *name,
81                 void (*onsignal) (const char *, void *),
82                 void *data);
83
84 extern int jbus_on_signal_j(
85                 struct jbus *jbus,
86                 const char *name,
87                 void (*onsignal) (struct json_object *, void *),
88                 void *data);
89
90 /* verbs for servers */
91 extern int jbus_reply_s(
92                 struct sbusmsg *smsg,
93                 const char *reply);
94
95 extern int jbus_reply_j(
96                 struct sbusmsg *smsg,
97                 struct json_object *reply);
98
99 extern int jbus_reply_error_s(
100                 struct sbusmsg *smsg,
101                 const char *reply);
102
103 extern int jbus_reply_error_j(
104                 struct sbusmsg *smsg,
105                 struct json_object *reply);
106
107 extern int jbus_add_service_s(
108                 struct jbus *jbus,
109                 const char *method,
110                 void (*oncall) (struct sbusmsg *, const char *, void *),
111                 void *data);
112
113 extern int jbus_add_service_j(
114                 struct jbus *jbus,
115                 const char *method,
116                 void (*oncall) (struct sbusmsg *, struct json_object *, void *),
117                 void *data);
118
119 extern int jbus_start_serving(
120                 struct jbus *jbus);
121
122 extern int jbus_send_signal_s(
123                 struct jbus *jbus,
124                 const char *name,
125                 const char *content);
126
127 extern int jbus_send_signal_j(
128                 struct jbus *jbus,
129                 const char *name,
130                 struct json_object *content);
131