Fedora 30 packaging fix issu
[src/app-framework-binder.git] / src / afb-export.h
1 /*
2  * Copyright (C) 2016, 2017, 2018 "IoT.bzh"
3  * Author: José Bollo <jose.bollo@iot.bzh>
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *   http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 #pragma once
19
20 struct json_object;
21
22 struct afb_export;
23 struct afb_apiset;
24 struct afb_context;
25 struct afb_xreq;
26
27 struct afb_binding_v2;
28 struct afb_binding_data_v2;
29 struct afb_api_v3;
30 struct afb_api_x3;
31 struct afb_event_x2;
32
33 extern void afb_export_set_config(struct json_object *config);
34
35 extern struct afb_export *afb_export_create_none_for_path(
36                                 struct afb_apiset *declare_set,
37                                 struct afb_apiset *call_set,
38                                 const char *path,
39                                 int (*creator)(void*, struct afb_api_x3*),
40                                 void *closure);
41
42 extern struct afb_export *afb_export_create_v2(struct afb_apiset *declare_set,
43                                 struct afb_apiset *call_set,
44                                 const char *apiname,
45                                 const struct afb_binding_v2 *binding,
46                                 struct afb_binding_data_v2 *data,
47                                 int (*init)(),
48                                 void (*onevent)(const char*, struct json_object*),
49                                 const char* path);
50
51 extern struct afb_export *afb_export_create_v3(struct afb_apiset *declare_set,
52                                 struct afb_apiset *call_set,
53                                 const char *apiname,
54                                 struct afb_api_v3 *api,
55                                 struct afb_export* creator,
56                                 const char* path);
57
58 extern struct afb_export *afb_export_addref(struct afb_export *export);
59 extern void afb_export_unref(struct afb_export *export);
60
61 extern void afb_export_destroy(struct afb_export *export);
62
63 extern int afb_export_declare(struct afb_export *export, int noconcurrency);
64 extern void afb_export_undeclare(struct afb_export *export);
65
66 extern const char *afb_export_apiname(const struct afb_export *export);
67 extern int afb_export_add_alias(struct afb_export *export, const char *apiname, const char *aliasname);
68 extern int afb_export_rename(struct afb_export *export, const char *apiname);
69 extern void afb_export_update_hooks(struct afb_export *export);
70
71 extern int afb_export_unshare_session(struct afb_export *export);
72
73 extern int afb_export_preinit_x3(
74                                 struct afb_export *export,
75                                 int (*preinit)(void *,struct afb_api_x3*),
76                                 void *closure);
77
78 extern int afb_export_handle_events_v12(
79                                 struct afb_export *export,
80                                 void (*on_event)(const char *event, struct json_object *object));
81
82
83 extern int afb_export_handle_events_v3(
84                                 struct afb_export *export,
85                                 void (*on_event)(struct afb_api_x3 *api, const char *event, struct json_object *object));
86
87
88 extern int afb_export_handle_init_v3(
89                                 struct afb_export *export,
90                                 int (*oninit)(struct afb_api_x3 *api));
91
92 extern int afb_export_start(struct afb_export *export);
93
94 extern int afb_export_logmask_get(const struct afb_export *export);
95 extern void afb_export_logmask_set(struct afb_export *export, int mask);
96
97 extern void *afb_export_userdata_get(const struct afb_export *export);
98 extern void afb_export_userdata_set(struct afb_export *export, void *data);
99
100 extern int afb_export_event_handler_add(
101                         struct afb_export *export,
102                         const char *pattern,
103                         void (*callback)(void *, const char*, struct json_object*, struct afb_api_x3*),
104                         void *closure);
105
106 extern int afb_export_event_handler_del(
107                         struct afb_export *export,
108                         const char *pattern,
109                         void **closure);
110
111 extern int afb_export_subscribe(struct afb_export *export, struct afb_event_x2 *event);
112 extern int afb_export_unsubscribe(struct afb_export *export, struct afb_event_x2 *event);
113 extern void afb_export_process_xreq(struct afb_export *export, struct afb_xreq *xreq);
114 extern void afb_export_context_init(struct afb_export *export, struct afb_context *context);
115 extern struct afb_export *afb_export_from_api_x3(struct afb_api_x3 *api);
116 extern struct afb_api_x3 *afb_export_to_api_x3(struct afb_export *export);
117
118 #if defined(WITH_LEGACY_BINDING_V1)
119
120 struct afb_service_x1;
121 struct afb_binding_interface_v1;
122
123 extern struct afb_export *afb_export_create_v1(struct afb_apiset *declare_set,
124                                 struct afb_apiset *call_set,
125                                 const char *apiname,
126                                 int (*init)(struct afb_service_x1),
127                                 void (*onevent)(const char*, struct json_object*),
128                                 const char* path);
129
130 extern struct afb_binding_v1 *afb_export_register_v1(
131                                 struct afb_export *export,
132                                 struct afb_binding_v1 *(*regfun)(const struct afb_binding_interface_v1*));
133
134 #endif
135