aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheJackiMonster <thejackimonster@gmail.com>2022-02-18 21:05:21 +0100
committerTheJackiMonster <thejackimonster@gmail.com>2022-02-18 21:05:21 +0100
commit807dec8e802737fb46d015c48a7859a6ec504f74 (patch)
treebc4081d48854b23ff0f74565192b8fdd6bf6c03d
parentf57863e8ddbf60a034071101ba6af40eee5a4797 (diff)
downloadlibgnunetchat-807dec8e802737fb46d015c48a7859a6ec504f74.tar.gz
libgnunetchat-807dec8e802737fb46d015c48a7859a6ec504f74.zip
Handle deletions of accounts properly
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-rw-r--r--src/gnunet_chat_handle_intern.c43
1 files changed, 29 insertions, 14 deletions
diff --git a/src/gnunet_chat_handle_intern.c b/src/gnunet_chat_handle_intern.c
index 96a8d0f..d3f4694 100644
--- a/src/gnunet_chat_handle_intern.c
+++ b/src/gnunet_chat_handle_intern.c
@@ -206,7 +206,7 @@ on_handle_gnunet_identity(void *cls,
206{ 206{
207 struct GNUNET_CHAT_Handle* handle = cls; 207 struct GNUNET_CHAT_Handle* handle = cls;
208 208
209 if ((!name) || (!ego)) 209 if (!ego)
210 goto send_refresh; 210 goto send_refresh;
211 211
212 struct GNUNET_CHAT_InternalAccounts *accounts = handle->accounts_head; 212 struct GNUNET_CHAT_InternalAccounts *accounts = handle->accounts_head;
@@ -216,16 +216,29 @@ on_handle_gnunet_identity(void *cls,
216 if (!(accounts->account)) 216 if (!(accounts->account))
217 goto skip_account; 217 goto skip_account;
218 218
219 if ((accounts->account->name) && 219 if (ego != accounts->account->ego)
220 (0 == strcmp(accounts->account->name, name))) 220 goto check_matching_name;
221
222 if (name)
223 util_set_name_field(name, &(accounts->account->name));
224 else
221 { 225 {
222 accounts->account->ego = ego; 226 account_destroy(accounts->account);
223 goto send_refresh; 227
228 GNUNET_CONTAINER_DLL_remove(
229 handle->accounts_head,
230 handle->accounts_tail,
231 accounts
232 );
224 } 233 }
225 234
226 if (ego == accounts->account->ego) 235 goto send_refresh;
236
237check_matching_name:
238 if ((accounts->account->name) && (name) &&
239 (0 == strcmp(accounts->account->name, name)))
227 { 240 {
228 util_set_name_field(name, &(accounts->account->name)); 241 accounts->account->ego = ego;
229 goto send_refresh; 242 goto send_refresh;
230 } 243 }
231 244
@@ -379,14 +392,13 @@ on_handle_message_callback(void *cls)
379{ 392{
380 struct GNUNET_CHAT_Message *message = (struct GNUNET_CHAT_Message*) cls; 393 struct GNUNET_CHAT_Message *message = (struct GNUNET_CHAT_Message*) cls;
381 394
382 if ((!message) || (!(message->msg))) 395 GNUNET_assert((message) &&
383 return; 396 (message->msg) &&
397 (message->context) &&
398 (message->context->handle));
384 399
385 struct GNUNET_CHAT_Context *context = message->context; 400 struct GNUNET_CHAT_Context *context = message->context;
386 401
387 if (!context)
388 return;
389
390 switch (message->msg->header.kind) 402 switch (message->msg->header.kind)
391 { 403 {
392 case GNUNET_MESSENGER_KIND_DELETE: 404 case GNUNET_MESSENGER_KIND_DELETE:
@@ -405,7 +417,7 @@ on_handle_message_callback(void *cls)
405 417
406 struct GNUNET_CHAT_Handle *handle = context->handle; 418 struct GNUNET_CHAT_Handle *handle = context->handle;
407 419
408 if ((!handle) || (!(handle->msg_cb))) 420 if (!(handle->msg_cb))
409 return; 421 return;
410 422
411 handle->msg_cb(handle->msg_cls, context, message); 423 handle->msg_cb(handle->msg_cls, context, message);
@@ -535,7 +547,10 @@ on_handle_message (void *cls,
535 ); 547 );
536 548
537 task = GNUNET_SCHEDULER_add_delayed( 549 task = GNUNET_SCHEDULER_add_delayed(
538 delay, 550 GNUNET_TIME_absolute_get_difference(
551 GNUNET_TIME_absolute_get(),
552 GNUNET_TIME_absolute_add(timestamp, delay)
553 ),
539 on_handle_message_callback, 554 on_handle_message_callback,
540 message 555 message
541 ); 556 );