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