# HG changeset patch
# Node ID 5f6a7e634a7aa8bc8ade48220453d69c86e88392
# Parent  09fb857fb48c2b225e23245bd1b064827ae7787c
diff --git a/im.pidgin.Pidgin3.yml b/im.pidgin.Pidgin3.yml
--- a/im.pidgin.Pidgin3.yml
+++ b/im.pidgin.Pidgin3.yml
@@ -41,8 +41,8 @@
     sources:
       - type: archive
         archive-type: tar-xz
-        url: https://sourceforge.net/projects/pidgin/files/ibis/0.7.1/ibis-0.7.1.tar.xz/download
-        sha256: d6e50ca1df262c36ce299e0c948fcbcd4c2ce3eca02aff7a76a1cf3f64eddec6
+        url: https://sourceforge.net/projects/pidgin/files/ibis/0.8.0/ibis-0.8.0.tar.xz/download
+        sha256: a4cadcd1d2775536401ba410314953fc1dbbea16a62a0520b66acfe31986f309
   - name: xeme
     buildsystem: meson
     config-opts:
diff --git a/protocols/ircv3/meson.build b/protocols/ircv3/meson.build
--- a/protocols/ircv3/meson.build
+++ b/protocols/ircv3/meson.build
@@ -18,7 +18,7 @@
 	subdir_done()
 endif
 
-ibis_dep = dependency('ibis', version : '>= 0.7.1')
+ibis_dep = dependency('ibis', version : '>= 0.8.0')
 
 ircv3_filebase = f'purple-@purple_major_version@-ircv3'
 
diff --git a/protocols/ircv3/purpleircv3connection.c b/protocols/ircv3/purpleircv3connection.c
--- a/protocols/ircv3/purpleircv3connection.c
+++ b/protocols/ircv3/purpleircv3connection.c
@@ -248,6 +248,15 @@
 }
 
 static gboolean
+purple_ircv3_message_handler_ignore(G_GNUC_UNUSED IbisClient *client,
+                                    G_GNUC_UNUSED const char *command,
+                                    G_GNUC_UNUSED IbisMessage *message,
+                                    G_GNUC_UNUSED gpointer data)
+{
+	return TRUE;
+}
+
+static gboolean
 purple_ircv3_connection_saslsuccess(IbisClient *client,
                                     G_GNUC_UNUSED const char *command,
                                     G_GNUC_UNUSED IbisMessage *message,
@@ -466,6 +475,13 @@
 	g_signal_connect_object(client, "message::" IBIS_MSG_PART,
 	                        G_CALLBACK(purple_ircv3_message_handler_part),
 	                        connection, G_CONNECT_DEFAULT);
+	g_signal_connect_object(client, "message::" IBIS_RPL_NAMREPLY,
+	                        G_CALLBACK(purple_ircv3_message_handler_namreply),
+	                        connection, G_CONNECT_DEFAULT);
+	g_signal_connect_object(client, "message::" IBIS_RPL_ENDOFNAMES,
+	                        G_CALLBACK(purple_ircv3_message_handler_ignore),
+	                        connection, G_CONNECT_DEFAULT);
+
 
 	g_signal_connect_object(client, "message",
 	                        G_CALLBACK(purple_ircv3_connection_unknown_message_cb),
diff --git a/protocols/ircv3/purpleircv3messagehandlers.c b/protocols/ircv3/purpleircv3messagehandlers.c
--- a/protocols/ircv3/purpleircv3messagehandlers.c
+++ b/protocols/ircv3/purpleircv3messagehandlers.c
@@ -149,6 +149,88 @@
 }
 
 gboolean
+purple_ircv3_message_handler_namreply(IbisClient *client,
+                                      G_GNUC_UNUSED const char *command,
+                                      IbisMessage *message, gpointer data)
+{
+	PurpleIRCv3Connection *connection = data;
+	PurpleConversation *conversation = NULL;
+	GStrv params = NULL;
+	GStrv nicks = NULL;
+	const char *target = NULL;
+
+	params = ibis_message_get_params(message);
+	if(params == NULL) {
+		g_warning("namreply received with no parameters");
+
+		return FALSE;
+	}
+
+	if(g_strv_length(params) != 4) {
+		char *body = g_strjoinv(" ", params);
+		g_warning("unknown namreply format: '%s'", body);
+		g_free(body);
+
+		return FALSE;
+	}
+
+	/* params[0] holds nick of the user and params[1] holds the channel type
+	 * (public/private) but we don't care about either of these.
+	 */
+
+	target = params[2];
+	if(!ibis_client_is_channel(client, target)) {
+		g_warning("received namreply for '%s' which is not a channel.",
+		          target);
+
+		return FALSE;
+	}
+
+	conversation = purple_ircv3_connection_find_or_create_conversation(connection,
+	                                                                   target);
+
+	/* Split the last parameter on space to get a list of all the nicks. */
+	nicks = g_strsplit(params[3], " ", -1);
+	if(nicks != NULL) {
+		PurpleAccount *account = NULL;
+		PurpleConnection *purple_connection = NULL;
+		PurpleContactManager *manager = purple_contact_manager_get_default();
+		PurpleConversationMembers *members = NULL;
+
+		purple_connection = PURPLE_CONNECTION(connection);
+		account = purple_connection_get_account(purple_connection);
+
+		members = purple_conversation_get_members(conversation);
+
+		for(guint i = 0; i < g_strv_length(nicks); i++) {
+			PurpleContact *contact = NULL;
+			const char *nick = nicks[i];
+			char *stripped = NULL;
+
+			stripped = ibis_client_strip_source_prefix(client, nick);
+
+			contact = purple_contact_manager_find_with_id(manager, account,
+			                                              stripped);
+			if(!PURPLE_IS_CONTACT(contact)) {
+				contact = purple_contact_new(account, stripped);
+				purple_contact_info_set_username(PURPLE_CONTACT_INFO(contact),
+				                                 stripped);
+				purple_contact_manager_add(manager, contact);
+			}
+
+			purple_conversation_members_add_member(members,
+			                                       PURPLE_CONTACT_INFO(contact),
+			                                       FALSE, NULL);
+			g_free(stripped);
+		}
+	}
+
+	g_strfreev(nicks);
+
+	return TRUE;
+}
+
+gboolean
 purple_ircv3_message_handler_tagmsg(IbisClient *client,
                                     G_GNUC_UNUSED const char *command,
                                     IbisMessage *ibis_message, gpointer data)
diff --git a/protocols/ircv3/purpleircv3messagehandlers.h b/protocols/ircv3/purpleircv3messagehandlers.h
--- a/protocols/ircv3/purpleircv3messagehandlers.h
+++ b/protocols/ircv3/purpleircv3messagehandlers.h
@@ -40,6 +40,7 @@
 
 G_GNUC_INTERNAL gboolean purple_ircv3_message_handler_join(IbisClient *client, const char *command, IbisMessage *message, gpointer data);
 G_GNUC_INTERNAL gboolean purple_ircv3_message_handler_part(IbisClient *client, const char *command, IbisMessage *message, gpointer data);
+G_GNUC_INTERNAL gboolean purple_ircv3_message_handler_namreply(IbisClient *client, const char *command, IbisMessage *message, gpointer data);
 G_GNUC_INTERNAL gboolean purple_ircv3_message_handler_tagmsg(IbisClient *client, const char *command, IbisMessage *ibis_message, gpointer data);
 G_GNUC_INTERNAL gboolean purple_ircv3_message_handler_privmsg(IbisClient *client, const char *command, IbisMessage *message, gpointer data);
 G_GNUC_INTERNAL gboolean purple_ircv3_message_handler_topic(IbisClient *client, const char *command, IbisMessage *message, gpointer data);
diff --git a/subprojects/ibis.wrap b/subprojects/ibis.wrap
--- a/subprojects/ibis.wrap
+++ b/subprojects/ibis.wrap
@@ -1,4 +1,4 @@
 [wrap-hg]
 directory = ibis
 url = https://keep.imfreedom.org/ibis/ibis
-revision = v0.7.1
+revision = v0.8.0
