aboutsummaryrefslogtreecommitdiff
path: root/src/lib/include/gnunet_dbus_lib_client.h
blob: 413a0c3814955affe8840a6ca5134e7ad7b0f860 (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
103
104
105
#ifndef GNUNET_DBUS_CLIENT_H
#define GNUNET_DBUS_CLIENT_H

#include <stdbool.h>

/**
 * Used by services to keep track of connected clients. Can associate an
 * arbitrary piece of data with each client.
 */
struct GNUNET_DBUS_Client;

/**
 * An iterable, double-linked-list of GNUNET_DBUS_Client
 */
struct GNUNET_DBUS_ClientIterator
{
  struct GNUNET_DBUS_ClientIterator *next;
  struct GNUNET_DBUS_ClientIterator *prev;

  struct GNUNET_DBUS_Client *client;
};

/**
 * Create a GNUNET_DBUS_Client with the given DBus unique name (eg. "1:23").
 */
struct GNUNET_DBUS_Client *
GNUNET_DBUS_client_create (
    const char *unique_name);

/**
 * Increase the reference count of this GNUNET_DBUS_Client by one.
 */
void
GNUNET_DBUS_client_ref (
    struct GNUNET_DBUS_Client *client);

/**
 * Decrease the reference count of this GNUNET_DBUS_Client by one. Will free
 * the GNUNET_DBUS_Client if the reference count reaches zero.
 */
void
GNUNET_DBUS_client_unref (
    struct GNUNET_DBUS_Client *client);

/*
 * Get the DBus unique name of this client (eg. "1:23").
 */
const char *
GNUNET_DBUS_client_get_unique_name (
    const struct GNUNET_DBUS_Client *client);

/**
 * Set the arbitrary piece of data associated with the client.
 */
void
GNUNET_DBUS_client_set_data (
    struct GNUNET_DBUS_Client *client,
    void *data);

/**
 * Get the arbitrary piece of data associated with the client.
 */
void *
GNUNET_DBUS_client_get_data (
    const struct GNUNET_DBUS_Client *client);
/**
 * Set whether this client prefers data to be pretty-encoded for transmission
 * over DBus. For example, the enum variant GNUNET_BLOCK_TYPE_DHT_HELLO will be
 * sent over-the-wire to this client as a DBus uint32 or as a the DBus string
 * "dht_hello" depending on this flag.
 */
void
GNUNET_DBUS_client_set_prefers_pretty_encodings (
    struct GNUNET_DBUS_Client *client,
    bool prefers_pretty_encodings);

/**
 * Get whether this client prefers data to be pretty-encoded for transmission
 * over DBus. For example, the enum variant GNUNET_BLOCK_TYPE_DHT_HELLO will be
 * sent over-the-wire to this client as a DBus uint32 or as a the DBus string
 * "dht_hello" depending on this flag.
 */
bool
GNUNET_DBUS_client_get_prefers_pretty_encodings (
    const struct GNUNET_DBUS_Client *client);

DBusMessage *
GNUNET_DBUS_client_create_method_call (
    struct GNUNET_DBUS_Client *client,
    const char *object_path,
    const char *interface,
    const char *method,
    bool pretty,
    void (*return_callback)(DBusMessage *message));

DBusMessage *
GNUNET_DBUS_client_create_unicast_signal (
    struct GNUNET_DBUS_Client *client,
    const char *object_path,
    const char *interface,
    const char *signal,
    bool pretty);

#endif