aboutsummaryrefslogtreecommitdiff
path: root/src/lib/include/gnunet_dbus_lib_signal.h
blob: af314fe1b108b134a6896919c21e11ac31215c3c (plain) (blame)
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
95
96
97
98
99
100
101
102
#ifndef GNUNET_DBUS_LIB_SIGNAL_H
#define GNUNET_DBUS_LIB_SIGNAL_H

/**
 * Defines a DBus signal that may be sent from an interface.
 */
struct GNUNET_DBUS_Signal;

#include "gnunet_dbus_lib_object_path.h"
#include "gnunet_dbus_lib_interface.h"

/**
 * An iterable, double-linked-list of GNUNET_DBUS_Signal.
 */
struct GNUNET_DBUS_SignalIterator
{
  /* linked list */
  struct GNUNET_DBUS_SignalIterator *next;
  struct GNUNET_DBUS_SignalIterator *prev;

  struct GNUNET_DBUS_Signal *signal;
};

/**
 * Create a signal with the given name. The signal should be populated with
 * argument definitions then bound to an interface with
 * GNUNET_DBUS_interface_add_signal.
 */
struct GNUNET_DBUS_Signal *
GNUNET_DBUS_signal_create (
  const char *name);

/**
 * Increase the reference count of this GNUNET_DBUS_Signal by one.
 */
void
GNUNET_DBUS_signal_ref (
    struct GNUNET_DBUS_Signal *signal);

/**
 * Decrease the reference count of this GNUNET_DBUS_Signal by one. Will free
 * the GNUNET_DBUS_Signal if the reference count reaches zero.
 */
void
GNUNET_DBUS_signal_unref (
    struct GNUNET_DBUS_Signal *signal);

/**
 * Adds an argument definition to this GNUNET_DBUS_Signal given both it's name
 * and it's DBus type signature.
 */
void
GNUNET_DBUS_signal_add_arg (
    struct GNUNET_DBUS_Signal *signal,
    const char *name,
    const char *signature);

/**
 * Get the name of this GNUNET_DBUS_Signal.
 */
const char *
GNUNET_DBUS_signal_get_name (
    const struct GNUNET_DBUS_Signal *signal);

/**
 * Iterate over the arguments of this GNUNET_DBUS_Signal.
 */
const struct GNUNET_DBUS_ArgIterator *
GNUNET_DBUS_signal_iterate_args (
    const struct GNUNET_DBUS_Signal *signal);

/**
 * Instantiate the signal so that it can be sent to all interested peers on the
 * bus. The returned DBusMessage must be populated with the signal's arguments
 * and can then be sent to send the signal. The signal will originate from the
 * supplied object path and interface. pretty sets whether data pushed to the
 * returned DBusMessage will be prety-encoded.
 */
DBusMessage *
GNUNET_DBUS_signal_spawn (
    const struct GNUNET_DBUS_Signal *signal,
    const struct GNUNET_DBUS_ObjectPath *path,
    const struct GNUNET_DBUS_Interface *interface,
    bool pretty);

/**
 * Instantiate the signal so that it can be sent to a single client. The
 * returned DBusMessage must be populated with the signal's arguments and can
 * then be sent to send the signal. The signal will originate from the supplied
 * object path and interface. pretty sets whether data pushed to the returned
 * DBusMessage will be prety-encoded.
 */
DBusMessage *
GNUNET_DBUS_signal_spawn_unicast (
    const struct GNUNET_DBUS_Signal *signal,
    const struct GNUNET_DBUS_ObjectPath *path,
    const struct GNUNET_DBUS_Interface *interface,
    const struct GNUNET_DBUS_Client *client,
    bool pretty);

#endif