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