aboutsummaryrefslogtreecommitdiff
path: root/src/lib/include/gnunet_dbus_lib_method_context.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/include/gnunet_dbus_lib_method_context.h')
-rw-r--r--src/lib/include/gnunet_dbus_lib_method_context.h115
1 files changed, 115 insertions, 0 deletions
diff --git a/src/lib/include/gnunet_dbus_lib_method_context.h b/src/lib/include/gnunet_dbus_lib_method_context.h
new file mode 100644
index 0000000..27b5789
--- /dev/null
+++ b/src/lib/include/gnunet_dbus_lib_method_context.h
@@ -0,0 +1,115 @@
1#ifndef GNUNET_DBUS_LIB_METHOD_CONTEXT_H
2#define GNUNET_DBUS_LIB_METHOD_CONTEXT_H
3
4#include <stdbool.h>
5
6#include <dbus/dbus.h>
7
8/**
9 * An object of this type is passed to every function bound to a
10 * GNUNET_DBUS_Method when it is called via DBus.
11 */
12struct GNUNET_DBUS_MethodContext
13{
14 /**
15 * The client calling this method.
16 */
17 struct GNUNET_DBUS_Client *client;
18
19 /**
20 * The service that this method was called on. This is necessary as the
21 * process might be running several DBus services all advertising the same
22 * method.
23 */
24 struct GNUNET_DBUS_Service *service;
25
26 /**
27 * The object that this method was called on.
28 */
29 struct GNUNET_DBUS_Object *object;
30
31 /**
32 * The interface that this method was called on.
33 */
34 struct GNUNET_DBUS_Interface *interface;
35
36 /**
37 * The method that was called. Necessary because multiple DBus methods may be
38 * bound to a single internal function.
39 */
40 struct GNUNET_DBUS_Method *method;
41
42 /**
43 * The method-call message sent by the client.
44 */
45 DBusMessage *message;
46
47 /**
48 * Whether the client expects a reply to this message. If the user of this
49 * API tries to send a reply to the client via this
50 * GNUNET_DBUS_MethodContext, the reply will not be sent if this flag is
51 * unset.
52 */
53 bool expects_reply;
54
55 /**
56 * Whether we have already replied to this DBus method-call message.
57 */
58 bool replied;
59
60 /**
61 * The reference count of the GNUNET_DBUS_MethodContext.
62 */
63 unsigned ref_count;
64};
65
66/**
67 * Create a GNUNET_DBUS_MethodContext from the supplied DBus method-call
68 * message. The message must have been sent by the given client to the given
69 * service+object+interface+method. This will increase the reference count of
70 * the DBusMessage but not the other supplied objects.
71 */
72struct GNUNET_DBUS_MethodContext *
73GNUNET_DBUS_method_context_create (
74 struct GNUNET_DBUS_Client *client,
75 struct GNUNET_DBUS_Service *service,
76 struct GNUNET_DBUS_Object *object,
77 struct GNUNET_DBUS_Interface *interface,
78 struct GNUNET_DBUS_Method *method,
79 DBusMessage *message);
80
81/**
82 * Increase the reference count of this GNUNET_DBUS_MethodContext by one.
83 */
84void
85GNUNET_DBUS_method_context_ref (
86 struct GNUNET_DBUS_MethodContext *mc);
87
88/**
89 * Decrease the reference count of this GNUNET_DBUS_MethodContext by one. Will
90 * free the method context if the reference count reaches zero.
91 */
92void
93GNUNET_DBUS_method_context_unref (
94 struct GNUNET_DBUS_MethodContext *mc);
95
96/**
97 * Send a DBusMessage in reply to the method call associated with this method
98 * context. The DBusMessage should have been created using
99 * GNUNET_DBUS_method_context_create_reply.
100 */
101void
102GNUNET_DBUS_method_context_send_reply (
103 struct GNUNET_DBUS_MethodContext *mc,
104 DBusMessage *reply);
105
106/**
107 * Create a DBusMessage in reply to this method call. After populating the
108 * message with data, send it using GNUNET_DBUS_method_context_send_reply.
109 */
110DBusMessage *
111GNUNET_DBUS_method_context_create_reply (
112 struct GNUNET_DBUS_MethodContext *mc);
113
114#endif
115