libgnunetchat

library for GNUnet Messenger
Log | Files | Refs | README | LICENSE

commit 6e32f4c763daa53b8961abcbbc4f1d08f923f843
parent ae250a3b723b3fc56ee14be8f59019c49c66d35e
Author: Jacki <jacki@thejackimonster.de>
Date:   Mon, 26 Aug 2024 02:38:06 +0200

Fix ego comparison properly

Signed-off-by: Jacki <jacki@thejackimonster.de>

Diffstat:
Msrc/gnunet_chat_account.c | 10++++++++--
Msrc/gnunet_chat_account.h | 2++
Msrc/gnunet_chat_handle_intern.c | 7+++++--
3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/gnunet_chat_account.c b/src/gnunet_chat_account.c @@ -38,6 +38,8 @@ account_create (const char *name) struct GNUNET_CHAT_Account *account = GNUNET_new(struct GNUNET_CHAT_Account); account->ego = NULL; + account->created = GNUNET_NO; + account->directory = NULL; account->name = NULL; @@ -57,6 +59,7 @@ account_create_from_ego (struct GNUNET_IDENTITY_Ego *ego, struct GNUNET_CHAT_Account *account = account_create(name); account->ego = ego; + account->created = GNUNET_YES; return account; } @@ -109,16 +112,19 @@ account_update_ego (struct GNUNET_CHAT_Account *account, struct GNUNET_CHAT_Handle *handle, struct GNUNET_IDENTITY_Ego *ego) { - GNUNET_assert((account) && (handle) && (ego) && (account->ego != ego)); + GNUNET_assert((account) && (handle)); enum GNUNET_CHAT_MessageFlag flag; - if ((!(account->ego)) && (handle->current != account)) + if (GNUNET_NO == account->created) flag = GNUNET_CHAT_FLAG_CREATE_ACCOUNT; else flag = GNUNET_CHAT_FLAG_UPDATE_ACCOUNT; account->ego = ego; + if (!(account->ego)) + return; + if (handle->directory) account_update_directory(account, handle->directory); diff --git a/src/gnunet_chat_account.h b/src/gnunet_chat_account.h @@ -34,6 +34,8 @@ struct GNUNET_CHAT_Handle; struct GNUNET_CHAT_Account { struct GNUNET_IDENTITY_Ego *ego; + enum GNUNET_GenericReturnValue created; + char *directory; char *name; diff --git a/src/gnunet_chat_handle_intern.c b/src/gnunet_chat_handle_intern.c @@ -323,7 +323,8 @@ on_handle_gnunet_identity (void *cls, if (ego != accounts->account->ego) goto check_matching_name; - if (name) + if ((name) && ((!(accounts->account->name)) || + (0 != strcmp(accounts->account->name, name)))) { util_set_name_field(name, &(accounts->account->name)); @@ -336,7 +337,7 @@ on_handle_gnunet_identity (void *cls, GNUNET_YES ); } - else if (!(accounts->op)) + else if ((!name) && (!(accounts->op))) { if (handle->current == accounts->account) handle_disconnect(handle); @@ -344,6 +345,8 @@ on_handle_gnunet_identity (void *cls, account_destroy(accounts->account); internal_accounts_destroy(accounts); } + else if (!name) + account_update_ego(accounts->account, handle, NULL); goto send_refresh;