commit fbeb2aa851dee6cfb83cea0b044df609e029f46c
parent 0bd5ee192263caa91b13122a23e35f0f8a27d38e
Author: TheJackiMonster <thejackimonster@gmail.com>
Date: Thu, 16 Dec 2021 14:02:29 +0100
Fixed inconsistent user pointers of contacts and filtered contact lists to not include own accounts
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
Diffstat:
3 files changed, 9 insertions(+), 41 deletions(-)
diff --git a/src/event.c b/src/event.c
@@ -147,11 +147,13 @@ event_update_profile(MESSENGER_Application *app)
void
event_update_chats(MESSENGER_Application *app,
struct GNUNET_CHAT_Context *context,
- UNUSED const struct GNUNET_CHAT_Message *msg)
+ const struct GNUNET_CHAT_Message *msg)
{
if (GNUNET_CHAT_context_get_user_pointer(context))
return;
+ contact_create_info(GNUNET_CHAT_message_get_sender(msg));
+
_add_new_chat_entry(app, context);
}
diff --git a/src/ui/contacts.c b/src/ui/contacts.c
@@ -90,24 +90,15 @@ handle_dialog_destroy(UNUSED GtkWidget *window,
}
static int
-_iterate_clear_contacts(UNUSED void *cls,
- UNUSED struct GNUNET_CHAT_Handle *handle,
- struct GNUNET_CHAT_Contact *contact)
-{
- GNUNET_CHAT_contact_set_user_pointer(contact, NULL);
- return GNUNET_YES;
-}
-
-static int
_iterate_contacts(void *cls,
UNUSED struct GNUNET_CHAT_Handle *handle,
struct GNUNET_CHAT_Contact *contact)
{
- MESSENGER_Application *app = (MESSENGER_Application*) cls;
-
- if (GNUNET_CHAT_contact_get_user_pointer(contact))
+ if (GNUNET_YES == GNUNET_CHAT_contact_is_owned(contact))
return GNUNET_YES;
+ MESSENGER_Application *app = (MESSENGER_Application*) cls;
+
const char *title;
title = GNUNET_CHAT_contact_get_name(contact);
@@ -119,8 +110,6 @@ _iterate_contacts(void *cls,
entry->entry_box
);
- GNUNET_CHAT_contact_set_user_pointer(contact, entry);
-
if (title)
{
gtk_label_set_text(entry->title_label, title);
@@ -201,12 +190,6 @@ ui_contacts_dialog_init(MESSENGER_Application *app,
GNUNET_CHAT_iterate_contacts(
app->chat.messenger.handle,
- _iterate_clear_contacts,
- NULL
- );
-
- GNUNET_CHAT_iterate_contacts(
- app->chat.messenger.handle,
_iterate_contacts,
app
);
diff --git a/src/ui/new_group.c b/src/ui/new_group.c
@@ -149,24 +149,15 @@ handle_dialog_destroy(UNUSED GtkWidget *window,
}
static int
-_iterate_clear_contacts(UNUSED void *cls,
- UNUSED struct GNUNET_CHAT_Handle *handle,
- struct GNUNET_CHAT_Contact *contact)
-{
- GNUNET_CHAT_contact_set_user_pointer(contact, NULL);
- return GNUNET_YES;
-}
-
-static int
_iterate_contacts(void *cls,
UNUSED struct GNUNET_CHAT_Handle *handle,
struct GNUNET_CHAT_Contact *contact)
{
- MESSENGER_Application *app = (MESSENGER_Application*) cls;
-
- if (GNUNET_CHAT_contact_get_user_pointer(contact))
+ if (GNUNET_YES == GNUNET_CHAT_contact_is_owned(contact))
return GNUNET_YES;
+ MESSENGER_Application *app = (MESSENGER_Application*) cls;
+
const char *title;
title = GNUNET_CHAT_contact_get_name(contact);
@@ -178,8 +169,6 @@ _iterate_contacts(void *cls,
entry->entry_box
);
- GNUNET_CHAT_contact_set_user_pointer(contact, entry);
-
if (title)
{
gtk_label_set_text(entry->title_label, title);
@@ -324,12 +313,6 @@ ui_new_group_dialog_init(MESSENGER_Application *app,
GNUNET_CHAT_iterate_contacts(
app->chat.messenger.handle,
- _iterate_clear_contacts,
- NULL
- );
-
- GNUNET_CHAT_iterate_contacts(
- app->chat.messenger.handle,
_iterate_contacts,
app
);