3ca12eba7530b2186aa8b52d84d989b23d39b6b9
[src/app-framework-binder.git] / include / afb / afb-daemon-itf-x1.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 #include <stdarg.h>
21
22 /* declaration of features of libsystemd */
23 struct sd_event;
24 struct sd_bus;
25 struct afb_stored_req;
26 struct afb_req_x1;
27 struct afb_event_x1;
28 struct afb_api_x3;
29
30 /**
31  * @deprecated use bindings version 3
32  *
33  * Definition of the facilities provided by the daemon.
34  */
35 struct afb_daemon_itf_x1
36 {
37         /** broadcasts evant 'name' with 'object' */
38         int (*event_broadcast)(struct afb_api_x3 *closure, const char *name, struct json_object *object);
39
40         /** gets the common systemd's event loop */
41         struct sd_event *(*get_event_loop)(struct afb_api_x3 *closure);
42
43         /** gets the common systemd's user d-bus */
44         struct sd_bus *(*get_user_bus)(struct afb_api_x3 *closure);
45
46         /** gets the common systemd's system d-bus */
47         struct sd_bus *(*get_system_bus)(struct afb_api_x3 *closure);
48
49         /** logging messages */
50         void (*vverbose_v1)(struct afb_api_x3*closure, int level, const char *file, int line, const char *fmt, va_list args);
51
52         /** creates an event of 'name' */
53         struct afb_event_x1 (*event_make)(struct afb_api_x3 *closure, const char *name);
54
55         /** get the file descriptor of the install directory */
56         int (*rootdir_get_fd)(struct afb_api_x3 *closure);
57
58         /** opens a file of the install directory */
59         int (*rootdir_open_locale)(struct afb_api_x3 *closure, const char *filename, int flags, const char *locale);
60
61         /** queue a job */
62         int (*queue_job)(struct afb_api_x3 *closure, void (*callback)(int signum, void *arg), void *argument, void *group, int timeout);
63
64         /** logging messages */
65         void (*vverbose_v2)(struct afb_api_x3*closure, int level, const char *file, int line, const char * func, const char *fmt, va_list args);
66
67         /** retrieve a stored request */
68         struct afb_req_x1 (*unstore_req)(struct afb_api_x3*closure, struct afb_stored_req *sreq);
69
70         /** require an api */
71         int (*require_api)(struct afb_api_x3*closure, const char *name, int initialized);
72
73         /** aliases an api */
74         int (*add_alias)(struct afb_api_x3*closure, const char *name, const char *as_name);
75
76         /** creates a new api */
77         struct afb_api_x3 *(*new_api)(struct afb_api_x3 *closure, const char *api, const char *info, int noconcurrency, int (*preinit)(void*, struct afb_api_x3 *), void *preinit_closure);
78 };
79
80 /**
81  * @deprecated use bindings version 3
82  *
83  * Structure for accessing daemon.
84  * See also: afb_daemon_get_event_sender, afb_daemon_get_event_loop, afb_daemon_get_user_bus, afb_daemon_get_system_bus
85  */
86 struct afb_daemon_x1
87 {
88         const struct afb_daemon_itf_x1 *itf;    /**< the interfacing functions */
89         struct afb_api_x3 *closure;             /**< the closure when calling these functions */
90 };
91