1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
3 * LADI Session Handler (ladish)
5 * Copyright (C) 2008,2009,2011 Nedko Arnaudov <nedko@arnaudov.name>
6 * Copyright (C) 2008 Juuso Alasuutari <juuso.alasuutari@gmail.com>
8 **************************************************************************
9 * This file contains interface to D-Bus methods helpers
10 **************************************************************************
12 * Licensed under the Academic Free License version 2.1
14 * LADI Session Handler is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * LADI Session Handler is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
26 * or write to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
30 #ifndef __CDBUS_METHOD_H__
31 #define __CDBUS_METHOD_H__
33 struct cdbus_method_call
35 DBusConnection
* connection
;
36 const char * method_name
;
37 DBusMessage
* message
;
39 const struct cdbus_interface_descriptor
* iface
;
43 struct cdbus_method_arg_descriptor
47 const bool direction_in
; /* false == out, true == in */
50 typedef void (* cdbus_method_handler
)(struct cdbus_method_call
* call_ptr
);
52 struct cdbus_method_descriptor
55 const cdbus_method_handler handler
;
56 const struct cdbus_method_arg_descriptor
* args
;
59 void cdbus_error(struct cdbus_method_call
* call_ptr
, const char * err_name
, const char * format
, ...);
61 void cdbus_method_return_new_void(struct cdbus_method_call
* call_ptr
);
62 void cdbus_method_return_new_single(struct cdbus_method_call
* call_ptr
, int type
, const void * arg
);
63 void cdbus_method_return_new_valist(struct cdbus_method_call
* call_ptr
, int type
, ...);
64 bool cdbus_method_return_verify(DBusMessage
* msg
, const char ** str
);
65 void cdbus_method_return_send(struct cdbus_method_call
* call_ptr
);
66 void cdbus_method_default_handler(DBusPendingCall
* pending
, void * data
);
68 #define CDBUS_METHOD_ARGS_BEGIN(method_name, descr) \
69 static const struct cdbus_method_arg_descriptor method_name ## _args_dtor[] = \
72 #define CDBUS_METHOD_ARG_DESCRIBE_IN(arg_name, arg_type, descr) \
76 .direction_in = true \
79 #define CDBUS_METHOD_ARG_DESCRIBE_OUT(arg_name, arg_type, descr)\
83 .direction_in = false \
86 #define CDBUS_METHOD_ARGS_END \
92 #define CDBUS_METHODS_BEGIN \
93 static const struct cdbus_method_descriptor methods_dtor[] = \
96 #define CDBUS_METHOD_DESCRIBE(method_name, handler_name) \
98 .name = # method_name, \
99 .handler = handler_name, \
100 .args = method_name ## _args_dtor \
103 #define CDBUS_METHODS_END \
111 #endif /* __CDBUS_METHOD_H__ */