1 /* -*- Mode: C ; c-basic-offset: 4 -*- */
3 Copyright (C) 2007,2008 Nedko Arnaudov
4 Copyright (C) 2007-2008 Juuso Alasuutari
5 Copyright (C) 2008 Marc-Olivier Barre
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #ifndef DBUS_H__3DB2458F_44B2_43EA_882A_9F888DF71A88__INCLUDED
23 #define DBUS_H__3DB2458F_44B2_43EA_882A_9F888DF71A88__INCLUDED
27 #define JACK_DBUS_DEBUG
29 //#define DISABLE_SIGNAL_MAGIC
31 #define DEFAULT_XDG_CONFIG "/.config"
32 #define DEFAULT_XDG_LOG "/.log"
33 #define JACKDBUS_DIR "/jack"
34 #define JACKDBUS_LOG "/jackdbus.log"
35 #define JACKDBUS_CONF "/conf.xml"
37 extern char *g_jackdbus_config_dir
;
38 extern size_t g_jackdbus_config_dir_len
; /* without terminating '\0' char */
39 extern int g_exit_command
;
42 jack_controller_settings_init();
45 jack_controller_settings_uninit();
47 #define JACK_DBUS_ERROR_UNKNOWN_METHOD "org.jackaudio.Error.UnknownMethod"
48 #define JACK_DBUS_ERROR_SERVER_NOT_RUNNING "org.jackaudio.Error.ServerNotRunning"
49 #define JACK_DBUS_ERROR_SERVER_RUNNING "org.jackaudio.Error.ServerRunning"
50 #define JACK_DBUS_ERROR_UNKNOWN_DRIVER "org.jackaudio.Error.UnknownDriver"
51 #define JACK_DBUS_ERROR_UNKNOWN_INTERNAL "org.jackaudio.Error.UnknownInternal"
52 #define JACK_DBUS_ERROR_UNKNOWN_PARAMETER "org.jackaudio.Error.UnknownParameter"
53 #define JACK_DBUS_ERROR_INVALID_ARGS "org.jackaudio.Error.InvalidArgs"
54 #define JACK_DBUS_ERROR_GENERIC "org.jackaudio.Error.Generic"
55 #define JACK_DBUS_ERROR_FATAL "org.jackaudio.Error.Fatal"
57 struct jack_dbus_method_call
60 DBusConnection
*connection
;
61 const char *method_name
;
66 struct jack_dbus_interface_method_argument_descriptor
70 bool direction_out
; /* true - out, false - in */
73 struct jack_dbus_interface_method_descriptor
76 const struct jack_dbus_interface_method_argument_descriptor
* arguments
;
77 void (* handler
)(struct jack_dbus_method_call
* call
);
80 struct jack_dbus_interface_signal_argument_descriptor
86 struct jack_dbus_interface_signal_descriptor
89 const struct jack_dbus_interface_signal_argument_descriptor
* arguments
;
92 struct jack_dbus_interface_descriptor
98 struct jack_dbus_method_call
* call
,
99 const struct jack_dbus_interface_method_descriptor
* methods
);
101 const struct jack_dbus_interface_method_descriptor
* methods
;
102 const struct jack_dbus_interface_signal_descriptor
* signals
;
105 struct jack_dbus_object_descriptor
107 struct jack_dbus_interface_descriptor
** interfaces
;
116 dbus_uint16_t uint16
;
118 dbus_uint32_t uint32
;
120 dbus_uint64_t uint64
;
125 #define JACK_DBUS_METHOD_ARGUMENTS_BEGIN(method_name) \
127 struct jack_dbus_interface_method_argument_descriptor method_name ## _arguments[] = \
130 #define JACK_DBUS_METHOD_ARGUMENTS_BEGIN_EX(method_name, descr) \
132 struct jack_dbus_interface_method_argument_descriptor method_name ## _arguments[] = \
135 #define JACK_DBUS_METHOD_ARGUMENT(argument_name, argument_type, argument_direction_out) \
137 .name = argument_name, \
138 .type = argument_type, \
139 .direction_out = argument_direction_out \
142 #define JACK_DBUS_METHOD_ARGUMENT_IN(argument_name, argument_type, descr) \
144 .name = argument_name, \
145 .type = argument_type, \
146 .direction_out = false \
149 #define JACK_DBUS_METHOD_ARGUMENT_OUT(argument_name, argument_type, descr) \
151 .name = argument_name, \
152 .type = argument_type, \
153 .direction_out = true \
156 #define JACK_DBUS_METHOD_ARGUMENT(argument_name, argument_type, argument_direction_out) \
158 .name = argument_name, \
159 .type = argument_type, \
160 .direction_out = argument_direction_out \
163 #define JACK_DBUS_METHOD_ARGUMENTS_END \
164 JACK_DBUS_METHOD_ARGUMENT(NULL, NULL, false) \
167 #define JACK_DBUS_METHODS_BEGIN \
169 struct jack_dbus_interface_method_descriptor methods_dtor[] = \
172 #define JACK_DBUS_METHOD_DESCRIBE(method_name, handler_name) \
174 .name = # method_name, \
175 .arguments = method_name ## _arguments, \
176 .handler = handler_name \
179 #define JACK_DBUS_METHODS_END \
187 #define JACK_DBUS_SIGNAL_ARGUMENTS_BEGIN(signal_name) \
189 struct jack_dbus_interface_signal_argument_descriptor signal_name ## _arguments[] = \
192 #define JACK_DBUS_SIGNAL_ARGUMENT(argument_name, argument_type) \
194 .name = argument_name, \
195 .type = argument_type \
198 #define JACK_DBUS_SIGNAL_ARGUMENTS_END \
199 JACK_DBUS_SIGNAL_ARGUMENT(NULL, NULL) \
202 #define JACK_DBUS_SIGNALS_BEGIN \
204 struct jack_dbus_interface_signal_descriptor signals_dtor[] = \
207 #define JACK_DBUS_SIGNAL_DESCRIBE(signal_name) \
209 .name = # signal_name, \
210 .arguments = signal_name ## _arguments \
213 #define JACK_DBUS_SIGNALS_END \
220 #define JACK_DBUS_IFACE_BEGIN(iface_var, iface_name) \
221 struct jack_dbus_interface_descriptor iface_var = \
223 .name = iface_name, \
224 .handler = jack_dbus_run_method,
226 #define JACK_DBUS_IFACE_HANDLER(handler_func) \
227 .handler = handler_func,
229 #define JACK_DBUS_IFACE_EXPOSE_METHODS \
230 .methods = methods_dtor,
232 #define JACK_DBUS_IFACE_EXPOSE_SIGNALS \
233 .signals = signals_dtor,
235 #define JACK_DBUS_IFACE_END \
239 jack_dbus_message_handler(
240 DBusConnection
*connection
,
241 DBusMessage
*message
,
245 jack_dbus_message_handler_unregister(
246 DBusConnection
*connection
,
250 jack_dbus_run_method(
251 struct jack_dbus_method_call
* call
,
252 const struct jack_dbus_interface_method_descriptor
* methods
);
256 void *dbus_call_context_ptr
,
257 const char *error_name
,
262 jack_dbus_only_error(
263 void *dbus_call_context_ptr
,
264 const char *error_name
,
269 jack_dbus_get_method_args(
270 struct jack_dbus_method_call
*call
,
275 jack_dbus_get_method_args_string_and_variant(
276 struct jack_dbus_method_call
*call
,
282 jack_dbus_get_method_args_two_strings_and_variant(
283 struct jack_dbus_method_call
*call
,
290 jack_dbus_message_append_variant(
291 DBusMessageIter
*iter
,
293 const char *signature
,
297 jack_dbus_construct_method_return_empty(
298 struct jack_dbus_method_call
* call
);
301 jack_dbus_construct_method_return_single(
302 struct jack_dbus_method_call
*call
,
307 jack_dbus_construct_method_return_array_of_strings(
308 struct jack_dbus_method_call
*call
,
309 unsigned int num_members
,
313 jack_dbus_send_signal(
314 const char *sender_object_path
,
316 const char *signal_name
,
320 #define JACK_CONTROLLER_OBJECT_PATH "/org/jackaudio/Controller"
322 extern struct jack_dbus_interface_descriptor
* g_jackcontroller_interfaces
[];
323 extern DBusConnection
* g_connection
;
325 #endif /* #ifndef DBUS_H__3DB2458F_44B2_43EA_882A_9F888DF71A88__INCLUDED */