1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
/*
* modem/request-private.h - Private ModemRequest
*
* Copyright (C) 2008 Nokia Corporation
* @author Pekka Pessi <first.surname@nokia.com>
*
* This work is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This work is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _MODEM_REQUEST_PRIVATE_H_
#define _MODEM_REQUEST_PRIVATE_H_
#include <modem/request.h>
#include <dbus/dbus-glib.h>
G_BEGIN_DECLS
typedef struct _ModemRequestPrivate ModemRequestPrivate;
typedef void ModemRequestCallNotify (DBusGProxy *, DBusGProxyCall *, gpointer);
ModemRequest *_modem_request_new (gpointer object,
DBusGProxy *proxy,
GCallback callback,
gpointer user_data);
void _modem_request_add_proxy_call (ModemRequest *request,
DBusGProxyCall *call);
void _modem_request_destroy_notify (gpointer _request);
/** Make a DBus method call with reply */
#define modem_request_begin(object, proxy, method, method_callback, \
callback, user, gtype, ...) \
({ ModemRequest *_temp = NULL; DBusGProxyCall *_pcall; \
_temp = _modem_request_new ((object), (proxy), (callback), (user)); \
_pcall = dbus_g_proxy_begin_call ((proxy), (method), \
(method_callback), _temp, _modem_request_destroy_notify, \
(gtype), ## __VA_ARGS__); \
_modem_request_add_proxy_call (_temp, _pcall); \
_temp; })
/** Make a DBus method call with reply and timeout */
#define modem_request_with_timeout(object, proxy, method, \
method_callback, callback, user_data, timeout, gtype, ...) \
({ ModemRequest *_temp = NULL; DBusGProxyCall *_pcall; \
_temp = _modem_request_new ((object), (proxy), \
(callback), (user_data)); \
_pcall = dbus_g_proxy_begin_call_with_timeout ((proxy), (method), \
(method_callback), _temp, _modem_request_destroy_notify, \
(timeout), (gtype), ## __VA_ARGS__); \
_modem_request_add_proxy_call (_temp, _pcall); \
_temp; })
/** Make a DBus-request.
*
* If @a callback is NULL, do not wait for reply.
*/
#define modem_request(object, proxy, method, method_callback, \
callback, user, gtype, ...) \
((callback) \
? modem_request_begin ((object), (proxy), (method), \
(method_callback), \
(callback), (user), (gtype), ## __VA_ARGS__) \
: (dbus_g_proxy_call_no_reply ((proxy), (method), \
(gtype), ## __VA_ARGS__), \
NULL))
#define modem_request_object(request) \
(g_ptr_array_index ((GPtrArray*)(request), 0))
#define modem_request_callback(request) \
(g_ptr_array_index ((GPtrArray*)(request), 1))
#define modem_request_user_data(request) \
(g_ptr_array_index ((GPtrArray*)(request), 2))
G_END_DECLS
#endif /* #ifndef _MODEM_REQUEST_PRIVATE_H_ */
|