aboutsummaryrefslogtreecommitdiff
path: root/src/lib/include/gnunet_dbus_lib_method.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/include/gnunet_dbus_lib_method.h')
-rw-r--r--src/lib/include/gnunet_dbus_lib_method.h110
1 files changed, 110 insertions, 0 deletions
diff --git a/src/lib/include/gnunet_dbus_lib_method.h b/src/lib/include/gnunet_dbus_lib_method.h
new file mode 100644
index 0000000..9b47fcf
--- /dev/null
+++ b/src/lib/include/gnunet_dbus_lib_method.h
@@ -0,0 +1,110 @@
1#ifndef GNUNET_DBUS_LIB_METHOD_H
2#define GNUNET_DBUS_LIB_METHOD_H
3
4#include <stdbool.h>
5
6/**
7 * Represents a DBus method. Consists of a linked-list of args and return args
8 * of type GNUNET_DBUS_Arg.
9 */
10struct GNUNET_DBUS_Method;
11
12#include "gnunet_dbus_lib_object.h"
13#include "gnunet_dbus_lib_method_context.h"
14
15/**
16 * An iterable, double-linked list of GNUNET_DBUS_Method.
17 */
18struct GNUNET_DBUS_MethodIterator
19{
20 /* linked list */
21 struct GNUNET_DBUS_MethodIterator *next;
22 struct GNUNET_DBUS_MethodIterator *prev;
23
24 struct GNUNET_DBUS_Method *method;
25};
26
27/**
28 * Create a new GNUNET_DBUS_Method with the given name. The underlying_method
29 * function will be called whenever this method is called via DBus. After
30 * creating a method you need to populate it the args and return args before
31 * binding it to an interface with GNUNET_DBUS_interface_add_method.
32 */
33struct GNUNET_DBUS_Method *
34GNUNET_DBUS_method_create (
35 const char *name,
36 void (*underlying_method)(struct GNUNET_DBUS_MethodContext *mc));
37
38/**
39 * Increase the reference count of this GNUNET_DBUS_Method by one.
40 */
41void
42GNUNET_DBUS_method_ref (
43 struct GNUNET_DBUS_Method *method);
44
45/**
46 * Decrease the reference count of this GNUNET_DBUS_Method by one. Will free
47 * the method if the reference count reaches zero.
48 */
49void
50GNUNET_DBUS_method_unref (
51 struct GNUNET_DBUS_Method *method);
52
53/**
54 * Add an argument with the given name and type signature to this method.
55 */
56void
57GNUNET_DBUS_method_add_arg (
58 struct GNUNET_DBUS_Method *method,
59 const char *name,
60 const char *signature);
61
62/**
63 * Add a return argument with the given name and type signature to this method.
64 */
65void
66GNUNET_DBUS_method_add_return_arg (
67 struct GNUNET_DBUS_Method *method,
68 const char *name,
69 const char *signature);
70
71/**
72 * Get the name of this method.
73 */
74const char *
75GNUNET_DBUS_method_get_name (
76 const struct GNUNET_DBUS_Method *method);
77
78/**
79 * Iterate over the arguments of this GNUNET_DBUS_Method.
80 */
81const struct GNUNET_DBUS_ArgIterator *
82GNUNET_DBUS_method_iterate_args (
83 const struct GNUNET_DBUS_Method *method);
84/*
85 * Iterate over the return arguments of this GNUNET_DBUS_Method.
86 */
87const struct GNUNET_DBUS_ArgIterator *
88GNUNET_DBUS_method_iterate_return_args (
89 const struct GNUNET_DBUS_Method *method);
90
91/**
92 * Call this method with the supplied GNUNET_DBUS_MethodContext.
93 */
94void
95GNUNET_DBUS_method_call (
96 struct GNUNET_DBUS_Method *method,
97 struct GNUNET_DBUS_MethodContext *mc);
98
99/**
100 * Find a GNUNET_DBUS_Method with the given name in the supplied iterator.
101 * Returns the position in the iterator of the method or NULL if it could not
102 * be found.
103 */
104const struct GNUNET_DBUS_MethodIterator *
105GNUNET_DBUS_method_find (
106 const struct GNUNET_DBUS_MethodIterator *meth_it,
107 const char *name);
108
109#endif
110