aboutsummaryrefslogtreecommitdiff
path: root/src/service/messenger/messenger_api_contact.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/service/messenger/messenger_api_contact.h')
-rw-r--r--src/service/messenger/messenger_api_contact.h126
1 files changed, 126 insertions, 0 deletions
diff --git a/src/service/messenger/messenger_api_contact.h b/src/service/messenger/messenger_api_contact.h
new file mode 100644
index 000000000..d3bb38e96
--- /dev/null
+++ b/src/service/messenger/messenger_api_contact.h
@@ -0,0 +1,126 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2020--2024 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20/**
21 * @author Tobias Frisch
22 * @file src/messenger/messenger_api_contact.h
23 * @brief messenger api: client implementation of GNUnet MESSENGER service
24 */
25
26#ifndef GNUNET_MESSENGER_API_CONTACT_H
27#define GNUNET_MESSENGER_API_CONTACT_H
28
29#include "gnunet_util_lib.h"
30
31struct GNUNET_MESSENGER_Contact
32{
33 char *name;
34 size_t rc;
35 size_t id;
36
37 struct GNUNET_CRYPTO_PublicKey public_key;
38};
39
40/**
41 * Creates and allocates a new contact with a given public <i>key</i>.
42 *
43 * @param[in] key Public key
44 * @param[in] unique_id Locally unique identifier
45 * @return New contact
46 */
47struct GNUNET_MESSENGER_Contact*
48create_contact (const struct GNUNET_CRYPTO_PublicKey *key,
49 size_t unique_id);
50
51/**
52 * Destroys a contact and frees its memory fully.
53 *
54 * @param[in,out] contact Contact
55 */
56void
57destroy_contact (struct GNUNET_MESSENGER_Contact *contact);
58
59/**
60 * Returns the current name of a given <i>contact</i> or NULL if no valid name was assigned yet.
61 *
62 * @param[in] contact Contact
63 * @return Name of the contact or NULL
64 */
65const char*
66get_contact_name (const struct GNUNET_MESSENGER_Contact *contact);
67
68/**
69 * Changes the current name of a given <i>contact</i> by copying it from the parameter <i>name</i>.
70 *
71 * @param[in,out] contact Contact
72 * @param[in] name Name
73 */
74void
75set_contact_name (struct GNUNET_MESSENGER_Contact *contact,
76 const char *name);
77
78/**
79 * Returns the public key of a given <i>contact</i>.
80 *
81 * @param[in] contact Contact
82 * @return Public key of the contact
83 */
84const struct GNUNET_CRYPTO_PublicKey*
85get_contact_key (const struct GNUNET_MESSENGER_Contact *contact);
86
87/**
88 * Increases the reference counter of a given <i>contact</i> which is zero as default.
89 *
90 * @param[in,out] contact Contact
91 */
92void
93increase_contact_rc (struct GNUNET_MESSENGER_Contact *contact);
94
95/**
96 * Decreases the reference counter if possible (can not underflow!) of a given <i>contact</i>
97 * and returns #GNUNET_YES if the counter is equal to zero, otherwise #GNUNET_NO.
98 *
99 * @param[in,out] contact Contact
100 * @return #GNUNET_YES or #GNUNET_NO depending on the reference counter
101 */
102enum GNUNET_GenericReturnValue
103decrease_contact_rc (struct GNUNET_MESSENGER_Contact *contact);
104
105/**
106 * Returns the locally unique identifier of a given <i>contact</i>.
107 *
108 * @param[in] contact contact Contact
109 * @return Locally unique identifier of contact
110 */
111size_t
112get_contact_id (const struct GNUNET_MESSENGER_Contact *contact);
113
114/**
115 * Calculates the context <i>hash</i> of a member in a room and returns it.
116 *
117 * @param[in] key Key of room
118 * @param[in] id Member id
119 * @param[out] context Member context
120 */
121void
122get_context_from_member (const struct GNUNET_HashCode *key,
123 const struct GNUNET_ShortHashCode *id,
124 struct GNUNET_HashCode *context);
125
126#endif //GNUNET_MESSENGER_API_CONTACT_H