aboutsummaryrefslogtreecommitdiff
path: root/src/gnunet_chat_message_intern.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gnunet_chat_message_intern.c')
-rw-r--r--src/gnunet_chat_message_intern.c135
1 files changed, 0 insertions, 135 deletions
diff --git a/src/gnunet_chat_message_intern.c b/src/gnunet_chat_message_intern.c
deleted file mode 100644
index 97f3c18..0000000
--- a/src/gnunet_chat_message_intern.c
+++ /dev/null
@@ -1,135 +0,0 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 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 gnunet_chat_message_intern.c
23 */
24
25#include <gnunet/gnunet_container_lib.h>
26
27#include "gnunet_chat_context.h"
28
29void
30link_message_parent (struct GNUNET_CHAT_Message *message)
31{
32 struct GNUNET_CHAT_Context *context = message->context;
33
34 struct GNUNET_CHAT_Message *prev = GNUNET_CONTAINER_multihashmap_get(
35 context->messages, &(message->msg->header.previous)
36 );
37
38 if (prev)
39 {
40 struct GNUNET_CHAT_MessageList *list = GNUNET_new(
41 struct GNUNET_CHAT_MessageList
42 );
43
44 list->message = message;
45
46 GNUNET_CONTAINER_DLL_insert(prev->head, prev->tail, list);
47 }
48
49 if (GNUNET_MESSENGER_KIND_MERGE != message->msg->header.kind)
50 return;
51
52 prev = GNUNET_CONTAINER_multihashmap_get(
53 context->messages, &(message->msg->body.merge.previous)
54 );
55
56 if (prev)
57 {
58 struct GNUNET_CHAT_MessageList *list = GNUNET_new(
59 struct GNUNET_CHAT_MessageList
60 );
61
62 list->message = message;
63
64 GNUNET_CONTAINER_DLL_insert(prev->head, prev->tail, list);
65 }
66}
67
68void
69unlink_message_parent (struct GNUNET_CHAT_Message *message)
70{
71 struct GNUNET_CHAT_Context *context = message->context;
72
73 struct GNUNET_CHAT_Message *prev = GNUNET_CONTAINER_multihashmap_get(
74 context->messages, &(message->msg->header.previous)
75 );
76
77 if (prev)
78 {
79 struct GNUNET_CHAT_MessageList *list = prev->head;
80
81 while (list)
82 {
83 if (list->message == message)
84 break;
85
86 list = list->next;
87 }
88
89 if (list)
90 {
91 GNUNET_CONTAINER_DLL_remove(prev->head, prev->tail, list);
92 GNUNET_free(list);
93 }
94 }
95
96 if (GNUNET_MESSENGER_KIND_MERGE != message->msg->header.kind)
97 return;
98
99 prev = GNUNET_CONTAINER_multihashmap_get(
100 context->messages, &(message->msg->body.merge.previous)
101 );
102
103 if (prev)
104 {
105 struct GNUNET_CHAT_MessageList *list = prev->head;
106
107 while (list)
108 {
109 if (list->message == message)
110 break;
111
112 list = list->next;
113 }
114
115 if (list)
116 {
117 GNUNET_CONTAINER_DLL_remove(prev->head, prev->tail, list);
118 GNUNET_free(list);
119 }
120 }
121}
122
123void
124clear_message_children (struct GNUNET_CHAT_Message *message)
125{
126 struct GNUNET_CHAT_MessageList *list = message->tail;
127
128 while (list)
129 {
130 GNUNET_CONTAINER_DLL_remove(message->head, message->tail, list);
131 GNUNET_free(list);
132
133 list = message->tail;
134 }
135}