Fix more warnings
[lash.git] / dbus / method.h
blobf9e93a6296d6bc2881a36ad0514a295824f61d16
1 /*
2 * LASH
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__
25 #include <stdbool.h>
26 #include <dbus/dbus.h>
28 #include "dbus/types.h"
30 #define DIRECTION_OUT (0)
31 #define DIRECTION_IN (1)
33 struct _method_msg
35 const service_t *service;
36 DBusMessage *message;
37 void *context;
38 DBusFreeFunction context_free_func;
39 DBusPendingCallNotifyFunction return_handler;
42 struct _method_call
44 DBusConnection *connection;
45 const char *method_name;
46 DBusMessage *message;
47 DBusMessage *reply;
48 const interface_t *interface;
49 void *context;
52 struct _method_arg
54 const char *name;
55 const char *type;
56 const int direction; /* 0 == out, 1 == in */
59 struct _method
61 const char *name;
62 const method_handler_t handler;
63 const method_arg_t *args;
66 void
67 method_return_new_void(method_call_t *call);
69 void
70 method_return_new_single(method_call_t *call,
71 int type,
72 const void *arg);
74 void
75 method_return_new_valist(method_call_t *call,
76 int type,
77 ...);
79 bool
80 method_return_verify(DBusMessage *msg,
81 const char **str);
83 bool
84 method_iter_append_variant(DBusMessageIter *iter,
85 int type,
86 const void *arg);
88 bool
89 method_iter_append_dict_entry(DBusMessageIter *iter,
90 int type,
91 const char *key,
92 const void *value,
93 int length);
95 bool
96 method_send(method_msg_t *call,
97 bool will_block);
99 void
100 method_return_send(method_call_t *call);
102 void
103 method_default_handler(DBusPendingCall *pending,
104 void *data);
106 bool
107 method_call_init(method_msg_t *call,
108 service_t *service,
109 void *return_context,
110 DBusPendingCallNotifyFunction return_handler,
111 const char *destination,
112 const char *path,
113 const char *interface,
114 const char *method);
116 bool
117 method_call_new_void(service_t *service,
118 void *return_context,
119 DBusPendingCallNotifyFunction return_handler,
120 bool will_block,
121 const char *destination,
122 const char *path,
123 const char *interface,
124 const char *method);
126 bool
127 method_call_new_single(service_t *service,
128 void *return_context,
129 DBusPendingCallNotifyFunction return_handler,
130 bool will_block,
131 const char *destination,
132 const char *path,
133 const char *interface,
134 const char *method,
135 int type,
136 const void *arg);
138 bool
139 method_call_new_valist(service_t *service,
140 void *return_context,
141 DBusPendingCallNotifyFunction return_handler,
142 bool will_block,
143 const char *destination,
144 const char *path,
145 const char *interface,
146 const char *method,
147 int type,
148 ...);
150 bool
151 method_iter_get_args(DBusMessageIter *iter,
152 ...);
154 bool
155 method_iter_get_dict_entry(DBusMessageIter *iter,
156 const char **key_ptr,
157 void *value_ptr,
158 int *type_ptr,
159 int *size_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) \
167 .name = arg_name, \
168 .type = arg_type, \
169 .direction = arg_direction \
172 #define METHOD_ARGS_END \
174 .name = NULL, \
175 .type = NULL, \
176 .direction = 0 \
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 \
193 .name = NULL, \
194 .handler = NULL, \
195 .args = NULL \
199 #endif /* __LASH_DBUS_METHOD_H__ */