c9cb0035e3c07223fe8537d5c6c55e596ec19dcd
[AGL/documentation.git] / docs / 4_APIs_and_Services / 4.3_Application_Framework_Binder / 3_Binder_references / 6_Functions_of_class_afb_daemon.md
1 ---
2 edit_link: ''
3 title: Functions of class afb_daemon
4 origin_url: >-
5   https://git.automotivelinux.org/src/app-framework-binder/plain/docs/reference-v3/func-daemon.md?h=master
6 ---
7
8 <!-- WARNING: This file is generated by fetch_docs.js using /home/boron/Documents/AGL/docs-webtemplate/site/_data/tocs/apis_services/master/app-framework-binder-developer-guides-api-services-book.yml -->
9
10 Functions of class **afb_daemon**
11 ============================
12
13 All the functions of the class **afb_daemon** use the default api.
14 This are internally aliased to the corresponding function of class afb_api_t.
15
16 ```C
17 /**
18  * Retrieves the common systemd's event loop of AFB
19  */
20 struct sd_event *afb_daemon_get_event_loop();
21
22 /**
23  * Retrieves the common systemd's user/session d-bus of AFB
24  */
25 struct sd_bus *afb_daemon_get_user_bus();
26
27 /**
28  * Retrieves the common systemd's system d-bus of AFB
29  */
30 struct sd_bus *afb_daemon_get_system_bus();
31
32 /**
33  * Broadcasts widely the event of 'name' with the data 'object'.
34  * 'object' can be NULL.
35  *
36  * For convenience, the function calls 'json_object_put' for 'object'.
37  * Thus, in the case where 'object' should remain available after
38  * the function returns, the function 'json_object_get' shall be used.
39  *
40  * Calling this function is only forbidden during preinit.
41  *
42  * Returns the count of clients that received the event.
43  */
44 int afb_daemon_broadcast_event(
45                         const char *name,
46                         struct json_object *object);
47
48 /**
49  * Creates an event of 'name' and returns it.
50  *
51  * Calling this function is only forbidden during preinit.
52  *
53  * See afb_event_is_valid to check if there is an error.
54  */
55 afb_event_t afb_daemon_make_event(
56                         const char *name);
57
58 /**
59  * @deprecated use bindings version 3
60  *
61  * Send a message described by 'fmt' and following parameters
62  * to the journal for the verbosity 'level'.
63  *
64  * 'file', 'line' and 'func' are indicators of position of the code in source files
65  * (see macros __FILE__, __LINE__ and __func__).
66  *
67  * 'level' is defined by syslog standard:
68  *      EMERGENCY         0        System is unusable
69  *      ALERT             1        Action must be taken immediately
70  *      CRITICAL          2        Critical conditions
71  *      ERROR             3        Error conditions
72  *      WARNING           4        Warning conditions
73  *      NOTICE            5        Normal but significant condition
74  *      INFO              6        Informational
75  *      DEBUG             7        Debug-level messages
76  */
77 void afb_daemon_verbose(
78                         int level,
79                         const char *file,
80                         int line,
81                         const char * func,
82                         const char *fmt,
83                         ...);
84
85 /**
86  * @deprecated use bindings version 3
87  *
88  * Get the root directory file descriptor. This file descriptor can
89  * be used with functions 'openat', 'fstatat', ...
90  *
91  * Returns the file descriptor or -1 in case of error.
92  */
93 int afb_daemon_rootdir_get_fd();
94
95 /**
96  * Opens 'filename' within the root directory with 'flags' (see function openat)
97  * using the 'locale' definition (example: "jp,en-US") that can be NULL.
98  *
99  * Returns the file descriptor or -1 in case of error.
100  */
101 int afb_daemon_rootdir_open_locale(
102                         const char *filename,
103                         int flags,
104                         const char *locale);
105
106 /**
107  * Queue the job defined by 'callback' and 'argument' for being executed asynchronously
108  * in this thread (later) or in an other thread.
109  * If 'group' is not NUL, the jobs queued with a same value (as the pointer value 'group')
110  * are executed in sequence in the order of there submission.
111  * If 'timeout' is not 0, it represent the maximum execution time for the job in seconds.
112  * At first, the job is called with 0 as signum and the given argument.
113  * The job is executed with the monitoring of its time and some signals like SIGSEGV and
114  * SIGFPE. When a such signal is catched, the job is terminated and reexecuted but with
115  * signum being the signal number (SIGALRM when timeout expired).
116  *
117  * Returns 0 in case of success or -1 in case of error.
118  */
119 int afb_daemon_queue_job(
120                         void (*callback)(int signum, void *arg),
121                         void *argument,
122                         void *group,
123                         int timeout);
124
125 /**
126  * Tells that it requires the API of "name" to exist
127  * and if 'initialized' is not null to be initialized.
128  * Calling this function is only allowed within init.
129  *
130  * Returns 0 in case of success or -1 in case of error.
131  */
132 int afb_daemon_require_api(
133                         const char *name,
134                         int initialized);
135
136 /**
137  * Create an aliased name 'as_name' for the api 'name'.
138  * Calling this function is only allowed within preinit.
139  *
140  * Returns 0 in case of success or -1 in case of error.
141  */
142 int afb_daemon_add_alias(const char *name, const char *as_name);
143
144 /**
145  * Creates a new api of name 'api' with brief 'info'.
146  *
147  * Returns 0 in case of success or -1 in case of error.
148  */
149 int afb_daemon_new_api(
150                         const char *api,
151                         const char *info,
152                         int noconcurrency,
153                         int (*preinit)(void*, struct afb_api_x3 *),
154                         void *closure);
155 ```