4 * Copyright (C) 2008 Juuso Alasuutari <juuso.alasuutari@gmail.com>
5 * Copyright (C) 2008 Nedko Arnaudov
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, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 #ifndef __LASH_DBUS_METHOD_H__
23 #define __LASH_DBUS_METHOD_H__
26 #include <dbus/dbus.h>
28 #include "dbus/types.h"
30 #define DIRECTION_OUT (0)
31 #define DIRECTION_IN (1)
35 const service_t
*service
;
38 DBusFreeFunction context_free_func
;
39 DBusPendingCallNotifyFunction return_handler
;
44 DBusConnection
*connection
;
45 const char *method_name
;
48 const interface_t
*interface
;
56 const int direction
; /* 0 == out, 1 == in */
62 const method_handler_t handler
;
63 const method_arg_t
*args
;
67 method_return_new_void(method_call_t
*call
);
70 method_return_new_single(method_call_t
*call
,
75 method_return_new_valist(method_call_t
*call
,
80 method_return_verify(DBusMessage
*msg
,
84 method_iter_append_variant(DBusMessageIter
*iter
,
89 method_iter_append_dict_entry(DBusMessageIter
*iter
,
96 method_send(method_msg_t
*call
,
100 method_return_send(method_call_t
*call
);
103 method_default_handler(DBusPendingCall
*pending
,
107 method_call_init(method_msg_t
*call
,
109 void *return_context
,
110 DBusPendingCallNotifyFunction return_handler
,
111 const char *destination
,
113 const char *interface
,
117 method_call_new_void(service_t
*service
,
118 void *return_context
,
119 DBusPendingCallNotifyFunction return_handler
,
121 const char *destination
,
123 const char *interface
,
127 method_call_new_single(service_t
*service
,
128 void *return_context
,
129 DBusPendingCallNotifyFunction return_handler
,
131 const char *destination
,
133 const char *interface
,
139 method_call_new_valist(service_t
*service
,
140 void *return_context
,
141 DBusPendingCallNotifyFunction return_handler
,
143 const char *destination
,
145 const char *interface
,
151 method_iter_get_args(DBusMessageIter
*iter
,
155 method_iter_get_dict_entry(DBusMessageIter
*iter
,
156 const char **key_ptr
,
161 #define METHOD_ARGS_BEGIN(method_name) \
162 static const struct _method_arg method_name ## _args_dtor[] = \
165 #define METHOD_ARG_DESCRIBE(arg_name, arg_type, arg_direction) \
169 .direction = arg_direction \
172 #define METHOD_ARGS_END \
180 #define METHODS_BEGIN \
181 static const struct _method methods_dtor[] = \
184 #define METHOD_DESCRIBE(method_name, handler_name) \
186 .name = # method_name, \
187 .handler = handler_name, \
188 .args = method_name ## _args_dtor \
191 #define METHODS_END \
199 #endif /* __LASH_DBUS_METHOD_H__ */