implement catdup4()
[ladish.git] / dbus / method.h
blob787937fdb16582ca936430873adced6dad030cde
1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
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 * 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 __LASH_DBUS_METHOD_H__
31 #define __LASH_DBUS_METHOD_H__
33 struct dbus_method_call
35 DBusConnection * connection;
36 const char * method_name;
37 DBusMessage * message;
38 DBusMessage * reply;
39 const struct dbus_interface_descriptor * iface;
40 void * iface_context;
43 struct dbus_method_arg_descriptor
45 const char * name;
46 const char * type;
47 const bool direction_in; /* false == out, true == in */
50 typedef void (* dbus_method_handler)(struct dbus_method_call * call_ptr);
52 struct dbus_method_descriptor
54 const char * name;
55 const dbus_method_handler handler;
56 const struct dbus_method_arg_descriptor * args;
59 void method_return_new_void(struct dbus_method_call * call_ptr);
60 void method_return_new_single(struct dbus_method_call * call_ptr, int type, const void * arg);
61 void method_return_new_valist(struct dbus_method_call * call_ptr, int type, ...);
62 bool method_return_verify(DBusMessage * msg, const char ** str);
63 void method_return_send(struct dbus_method_call * call_ptr);
64 void method_default_handler(DBusPendingCall * pending, void * data);
66 #define METHOD_ARGS_BEGIN(method_name, descr) \
67 static const struct dbus_method_arg_descriptor method_name ## _args_dtor[] = \
70 #define METHOD_ARG_DESCRIBE_IN(arg_name, arg_type, descr) \
71 { \
72 .name = arg_name, \
73 .type = arg_type, \
74 .direction_in = true \
77 #define METHOD_ARG_DESCRIBE_OUT(arg_name, arg_type, descr) \
78 { \
79 .name = arg_name, \
80 .type = arg_type, \
81 .direction_in = false \
84 #define METHOD_ARGS_END \
85 { \
86 .name = NULL, \
87 } \
90 #define METHODS_BEGIN \
91 static const struct dbus_method_descriptor methods_dtor[] = \
94 #define METHOD_DESCRIBE(method_name, handler_name) \
95 { \
96 .name = # method_name, \
97 .handler = handler_name, \
98 .args = method_name ## _args_dtor \
101 #define METHODS_END \
103 .name = NULL, \
104 .handler = NULL, \
105 .args = NULL \
109 #endif /* __LASH_DBUS_METHOD_H__ */