1 /* -*- Mode: C ; c-basic-offset: 4 -*- */
3 Copyright (C) 2007-2008 Nedko Arnaudov
4 Copyright (C) 2007-2008 Juuso Alasuutari
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #if defined(HAVE_CONFIG_H)
29 #include <dbus/dbus.h>
33 static char g_xml_data
[102400];
37 jack_controller_dbus_introspect(
38 struct jack_dbus_method_call
* call
)
40 jack_dbus_construct_method_return_single(
43 (message_arg_t
)(const char *)g_xml_data
);
46 JACK_DBUS_METHOD_ARGUMENTS_BEGIN(Introspect
)
47 JACK_DBUS_METHOD_ARGUMENT("xml_data", "s", true)
48 JACK_DBUS_METHOD_ARGUMENTS_END
50 JACK_DBUS_METHODS_BEGIN
51 JACK_DBUS_METHOD_DESCRIBE(Introspect
, jack_controller_dbus_introspect
)
54 JACK_DBUS_IFACE_BEGIN(g_jack_controller_iface_introspectable
, "org.freedesktop.DBus.Introspectable")
55 JACK_DBUS_IFACE_EXPOSE_METHODS
58 static char * g_buffer_ptr
;
62 write_line_format(const char * format
, ...)
67 g_buffer_ptr
+= vsprintf(g_buffer_ptr
, format
, ap
);
73 write_line(const char * line
)
75 write_line_format("%s\n", line
);
78 void jack_controller_introspect_init() __attribute__((constructor
));
81 jack_controller_introspect_init()
83 struct jack_dbus_interface_descriptor
** interface_ptr_ptr
;
84 const struct jack_dbus_interface_method_descriptor
* method_ptr
;
85 const struct jack_dbus_interface_method_argument_descriptor
* method_argument_ptr
;
86 const struct jack_dbus_interface_signal_descriptor
* signal_ptr
;
87 const struct jack_dbus_interface_signal_argument_descriptor
* signal_argument_ptr
;
89 g_buffer_ptr
= g_xml_data
;
91 write_line("<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"");
92 write_line("\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">");
94 write_line("<node name=\"" JACK_CONTROLLER_OBJECT_PATH
"\">");
96 interface_ptr_ptr
= g_jackcontroller_interfaces
;
98 while (*interface_ptr_ptr
!= NULL
)
100 write_line_format(" <interface name=\"%s\">\n", (*interface_ptr_ptr
)->name
);
102 if ((*interface_ptr_ptr
)->methods
!= NULL
)
104 method_ptr
= (*interface_ptr_ptr
)->methods
;
105 while (method_ptr
->name
!= NULL
)
107 write_line_format(" <method name=\"%s\">\n", method_ptr
->name
);
109 method_argument_ptr
= method_ptr
->arguments
;
111 while (method_argument_ptr
->name
!= NULL
)
114 " <arg name=\"%s\" type=\"%s\" direction=\"%s\" />\n",
115 method_argument_ptr
->name
,
116 method_argument_ptr
->type
,
117 method_argument_ptr
->direction_out
? "out" : "in");
118 method_argument_ptr
++;
121 write_line(" </method>");
126 if ((*interface_ptr_ptr
)->signals
!= NULL
)
128 signal_ptr
= (*interface_ptr_ptr
)->signals
;
129 while (signal_ptr
->name
!= NULL
)
131 write_line_format(" <signal name=\"%s\">\n", signal_ptr
->name
);
133 signal_argument_ptr
= signal_ptr
->arguments
;
135 while (signal_argument_ptr
->name
!= NULL
)
138 " <arg name=\"%s\" type=\"%s\" />\n",
139 signal_argument_ptr
->name
,
140 signal_argument_ptr
->type
);
141 signal_argument_ptr
++;
144 write_line(" </signal>");
149 write_line(" </interface>");
153 write_line("</node>");