diff options
Diffstat (limited to 'src/lib/include/gnunet_dbus_lib_method.h')
-rw-r--r-- | src/lib/include/gnunet_dbus_lib_method.h | 110 |
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 | */ | ||
10 | struct 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 | */ | ||
18 | struct 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 | */ | ||
33 | struct GNUNET_DBUS_Method * | ||
34 | GNUNET_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 | */ | ||
41 | void | ||
42 | GNUNET_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 | */ | ||
49 | void | ||
50 | GNUNET_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 | */ | ||
56 | void | ||
57 | GNUNET_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 | */ | ||
65 | void | ||
66 | GNUNET_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 | */ | ||
74 | const char * | ||
75 | GNUNET_DBUS_method_get_name ( | ||
76 | const struct GNUNET_DBUS_Method *method); | ||
77 | |||
78 | /** | ||
79 | * Iterate over the arguments of this GNUNET_DBUS_Method. | ||
80 | */ | ||
81 | const struct GNUNET_DBUS_ArgIterator * | ||
82 | GNUNET_DBUS_method_iterate_args ( | ||
83 | const struct GNUNET_DBUS_Method *method); | ||
84 | /* | ||
85 | * Iterate over the return arguments of this GNUNET_DBUS_Method. | ||
86 | */ | ||
87 | const struct GNUNET_DBUS_ArgIterator * | ||
88 | GNUNET_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 | */ | ||
94 | void | ||
95 | GNUNET_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 | */ | ||
104 | const struct GNUNET_DBUS_MethodIterator * | ||
105 | GNUNET_DBUS_method_find ( | ||
106 | const struct GNUNET_DBUS_MethodIterator *meth_it, | ||
107 | const char *name); | ||
108 | |||
109 | #endif | ||
110 | |||