1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
3 * LADI Session Handler (ladish)
5 * Copyright (C) 2008, 2009 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 * LADI Session Handler is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * LADI Session Handler is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
24 * or write to the Free Software Foundation, Inc.,
25 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
28 #ifndef __LASH_DBUS_METHOD_H__
29 #define __LASH_DBUS_METHOD_H__
32 #include <dbus/dbus.h>
38 const service_t
*service
;
41 DBusFreeFunction context_free_func
;
42 DBusPendingCallNotifyFunction return_handler
;
47 DBusConnection
*connection
;
48 const char *method_name
;
51 const interface_t
*interface
;
59 const bool direction_in
; /* false == out, true == in */
65 const method_handler_t handler
;
66 const method_arg_t
*args
;
70 method_return_new_void(method_call_t
*call
);
73 method_return_new_single(method_call_t
*call
,
78 method_return_new_valist(method_call_t
*call
,
83 method_return_verify(DBusMessage
*msg
,
87 method_iter_append_variant(DBusMessageIter
*iter
,
92 method_iter_append_dict_entry(DBusMessageIter
*iter
,
99 method_send(method_msg_t
*call
,
103 method_return_send(method_call_t
*call
);
106 method_default_handler(DBusPendingCall
*pending
,
110 method_call_init(method_msg_t
*call
,
112 void *return_context
,
113 DBusPendingCallNotifyFunction return_handler
,
114 const char *destination
,
116 const char *interface
,
120 method_call_new_void(service_t
*service
,
121 void *return_context
,
122 DBusPendingCallNotifyFunction return_handler
,
124 const char *destination
,
126 const char *interface
,
130 method_call_new_single(service_t
*service
,
131 void *return_context
,
132 DBusPendingCallNotifyFunction return_handler
,
134 const char *destination
,
136 const char *interface
,
142 method_call_new_valist(service_t
*service
,
143 void *return_context
,
144 DBusPendingCallNotifyFunction return_handler
,
146 const char *destination
,
148 const char *interface
,
154 method_iter_get_args(DBusMessageIter
*iter
,
158 method_iter_get_dict_entry(DBusMessageIter
*iter
,
159 const char **key_ptr
,
164 #define METHOD_ARGS_BEGIN(method_name, descr) \
165 static const struct _method_arg method_name ## _args_dtor[] = \
168 #define METHOD_ARG_DESCRIBE_IN(arg_name, arg_type, descr) \
172 .direction_in = true \
175 #define METHOD_ARG_DESCRIBE_OUT(arg_name, arg_type, descr) \
179 .direction_in = false \
182 #define METHOD_ARGS_END \
188 #define METHODS_BEGIN \
189 static const struct _method methods_dtor[] = \
192 #define METHOD_DESCRIBE(method_name, handler_name) \
194 .name = # method_name, \
195 .handler = handler_name, \
196 .args = method_name ## _args_dtor \
199 #define METHODS_END \
207 #endif /* __LASH_DBUS_METHOD_H__ */