1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
|
/* -*- Mode: C ; c-basic-offset: 2 -*- */
/*
* ALSA SEQ < - > JACK MIDI bridge
*
* Copyright (c) 2007,2008,2009 Nedko Arnaudov <nedko@arnaudov.name>
* Copyright (C) 2007-2008 Juuso Alasuutari
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef DBUS_INTERNAL_H__9AE08E23_C592_46FB_84BD_E3D0E8721C07__INCLUDED
#define DBUS_INTERNAL_H__9AE08E23_C592_46FB_84BD_E3D0E8721C07__INCLUDED
#define A2J_DBUS_SERVICE_NAME "org.gna.home.a2jmidid"
#define A2J_DBUS_OBJECT_PATH "/"
struct a2j_dbus_method_call
{
void *context;
DBusConnection *connection;
const char *method_name;
DBusMessage *message;
DBusMessage *reply;
};
#define A2J_DBUS_DIRECTION_IN false
#define A2J_DBUS_DIRECTION_OUT true
struct a2j_dbus_interface_method_argument_descriptor
{
const char * name;
const char * type;
bool direction_out; /* A2J_DBUS_DIRECTION_XXX */
};
struct a2j_dbus_interface_method_descriptor
{
const char * name;
const struct a2j_dbus_interface_method_argument_descriptor * arguments;
void (* handler)(struct a2j_dbus_method_call * call);
};
struct a2j_dbus_interface_signal_argument_descriptor
{
const char * name;
const char * type;
};
struct a2j_dbus_interface_signal_descriptor
{
const char * name;
const struct a2j_dbus_interface_signal_argument_descriptor * arguments;
};
struct a2j_dbus_interface_descriptor
{
const char * name;
bool
(* handler)(
struct a2j_dbus_method_call * call,
const struct a2j_dbus_interface_method_descriptor * methods);
const struct a2j_dbus_interface_method_descriptor * methods;
const struct a2j_dbus_interface_signal_descriptor * signals;
};
struct a2j_dbus_object_descriptor
{
struct a2j_dbus_interface_descriptor ** interfaces;
void * context;
};
#define A2J_DBUS_METHOD_ARGUMENTS_BEGIN(method_name) \
static const \
struct a2j_dbus_interface_method_argument_descriptor method_name ## _arguments[] = \
{
#define A2J_DBUS_METHOD_ARGUMENT(argument_name, argument_type, argument_direction_out) \
{ \
.name = argument_name, \
.type = argument_type, \
.direction_out = argument_direction_out \
},
#define A2J_DBUS_METHOD_ARGUMENTS_END \
A2J_DBUS_METHOD_ARGUMENT(NULL, NULL, false) \
};
#define A2J_DBUS_METHODS_BEGIN \
static const \
struct a2j_dbus_interface_method_descriptor methods_dtor[] = \
{
#define A2J_DBUS_METHOD_DESCRIBE(method_name, handler_name) \
{ \
.name = # method_name, \
.arguments = method_name ## _arguments, \
.handler = handler_name \
},
#define A2J_DBUS_METHODS_END \
{ \
.name = NULL, \
.arguments = NULL, \
.handler = NULL \
} \
};
#define A2J_DBUS_SIGNAL_ARGUMENTS_BEGIN(signal_name) \
static const \
struct a2j_dbus_interface_signal_argument_descriptor signal_name ## _arguments[] = \
{
#define A2J_DBUS_SIGNAL_ARGUMENT(argument_name, argument_type) \
{ \
.name = argument_name, \
.type = argument_type \
},
#define A2J_DBUS_SIGNAL_ARGUMENTS_END \
A2J_DBUS_SIGNAL_ARGUMENT(NULL, NULL) \
};
#define A2J_DBUS_SIGNALS_BEGIN \
static const \
struct a2j_dbus_interface_signal_descriptor signals_dtor[] = \
{
#define A2J_DBUS_SIGNAL_DESCRIBE(signal_name) \
{ \
.name = # signal_name, \
.arguments = signal_name ## _arguments \
},
#define A2J_DBUS_SIGNALS_END \
{ \
.name = NULL, \
.arguments = NULL, \
} \
};
#define A2J_DBUS_IFACE_BEGIN(iface_var, iface_name) \
struct a2j_dbus_interface_descriptor iface_var = \
{ \
.name = iface_name, \
.handler = a2j_dbus_run_method,
#define A2J_DBUS_IFACE_HANDLER(handler_func) \
.handler = handler_func,
#define A2J_DBUS_IFACE_EXPOSE_METHODS \
.methods = methods_dtor,
#define A2J_DBUS_IFACE_EXPOSE_SIGNALS \
.signals = signals_dtor,
#define A2J_DBUS_IFACE_END \
};
#define A2J_DBUS_ERROR_GENERIC A2J_DBUS_SERVICE_NAME ".error.generic"
#define A2J_DBUS_ERROR_UNKNOWN_METHOD A2J_DBUS_SERVICE_NAME ".error.unknown_method"
#define A2J_DBUS_ERROR_INVALID_ARGS A2J_DBUS_SERVICE_NAME ".error.invalid_args"
#define A2J_DBUS_ERROR_UNKNOWN_PORT A2J_DBUS_SERVICE_NAME ".error.unknown_port"
#define A2J_DBUS_ERROR_BRIDGE_NOT_RUNNING A2J_DBUS_SERVICE_NAME ".error.bridge_not_running"
#define A2J_DBUS_ERROR_BRIDGE_RUNNING A2J_DBUS_SERVICE_NAME ".error.bridge_running"
void
a2j_dbus_error(
void *dbus_call_context_ptr,
const char *error_name,
const char *format,
...);
bool
a2j_dbus_run_method(
struct a2j_dbus_method_call * call,
const struct a2j_dbus_interface_method_descriptor * methods);
void
a2j_dbus_construct_method_return_single(
struct a2j_dbus_method_call * call_ptr,
int type,
void * arg_ptr);
void a2j_dbus_construct_method_return_void(struct a2j_dbus_method_call * call_ptr);
void
a2j_dbus_signal(
const char * path,
const char * interface,
const char * name,
int type,
...);
extern struct a2j_dbus_interface_descriptor * g_a2j_dbus_interfaces[];
extern struct a2j_dbus_interface_descriptor g_a2j_iface_introspectable;
#endif /* #ifndef DBUS_INTERNAL_H__9AE08E23_C592_46FB_84BD_E3D0E8721C07__INCLUDED */
|