aboutsummaryrefslogtreecommitdiff
path: root/src/messenger/messenger_api_contact.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/messenger/messenger_api_contact.c')
-rw-r--r--src/messenger/messenger_api_contact.c110
1 files changed, 0 insertions, 110 deletions
diff --git a/src/messenger/messenger_api_contact.c b/src/messenger/messenger_api_contact.c
deleted file mode 100644
index cbca17640..000000000
--- a/src/messenger/messenger_api_contact.c
+++ /dev/null
@@ -1,110 +0,0 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2020--2021 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.c
23 * @brief messenger api: client implementation of GNUnet MESSENGER service
24 */
25
26#include "messenger_api_contact.h"
27
28struct GNUNET_MESSENGER_Contact*
29create_contact (const struct GNUNET_IDENTITY_PublicKey *key)
30{
31 GNUNET_assert(key);
32
33 struct GNUNET_MESSENGER_Contact *contact = GNUNET_new(struct GNUNET_MESSENGER_Contact);
34
35 contact->name = NULL;
36 contact->rc = 0;
37
38 GNUNET_memcpy(&(contact->public_key), key, sizeof(contact->public_key));
39
40 return contact;
41}
42
43void
44destroy_contact (struct GNUNET_MESSENGER_Contact *contact)
45{
46 GNUNET_assert(contact);
47
48 if (contact->name)
49 GNUNET_free(contact->name);
50
51 GNUNET_free(contact);
52}
53
54const char*
55get_contact_name (const struct GNUNET_MESSENGER_Contact *contact)
56{
57 GNUNET_assert(contact);
58
59 return contact->name;
60}
61
62void
63set_contact_name (struct GNUNET_MESSENGER_Contact *contact,
64 const char *name)
65{
66 GNUNET_assert(contact);
67
68 if (contact->name)
69 GNUNET_free(contact->name);
70
71 contact->name = name ? GNUNET_strdup(name) : NULL;
72}
73
74const struct GNUNET_IDENTITY_PublicKey*
75get_contact_key (const struct GNUNET_MESSENGER_Contact *contact)
76{
77 GNUNET_assert(contact);
78
79 return &(contact->public_key);
80}
81
82void
83increase_contact_rc (struct GNUNET_MESSENGER_Contact *contact)
84{
85 GNUNET_assert(contact);
86
87 contact->rc++;
88}
89
90int
91decrease_contact_rc (struct GNUNET_MESSENGER_Contact *contact)
92{
93 GNUNET_assert(contact);
94
95 if (contact->rc > 0)
96 contact->rc--;
97
98 return contact->rc ? GNUNET_NO : GNUNET_YES;
99}
100
101void
102get_context_from_member (const struct GNUNET_HashCode *key,
103 const struct GNUNET_ShortHashCode *id,
104 struct GNUNET_HashCode *context)
105{
106 GNUNET_assert((key) && (id) && (context));
107
108 GNUNET_CRYPTO_hash (id, sizeof(*id), context);
109 GNUNET_CRYPTO_hash_xor (key, context, context);
110}