changeset 22815:f67edee0224e

When searching for a conversation, search only in the list of the specified type of conversation (i.e. IMs or Chats), when appropriate, instead of the list of all conversations.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sun, 04 May 2008 03:28:58 +0000
parents 2d10cd28aa57
children 04e0d8677b9a
files libpurple/conversation.c
diffstat 1 files changed, 16 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/conversation.c	Sun May 04 03:24:18 2008 +0000
+++ b/libpurple/conversation.c	Sun May 04 03:28:58 2008 +0000
@@ -813,14 +813,27 @@
 
 	g_return_val_if_fail(name != NULL, NULL);
 
+	switch (type) {
+		case PURPLE_CONV_TYPE_IM:
+			cnv = purple_get_ims();
+			break;
+		case PURPLE_CONV_TYPE_CHAT:
+			cnv = purple_get_chats();
+			break;
+		case PURPLE_CONV_TYPE_ANY:
+			cnv = purple_get_conversations();
+			break;
+		default:
+			g_return_val_if_reached(NULL);
+	}
+
 	name1 = g_strdup(purple_normalize(account, name));
 
-	for (cnv = purple_get_conversations(); cnv != NULL; cnv = cnv->next) {
+	for (; cnv != NULL; cnv = cnv->next) {
 		c = (PurpleConversation *)cnv->data;
 		name2 = purple_normalize(account, purple_conversation_get_name(c));
 
-		if (((type == PURPLE_CONV_TYPE_ANY) || (type == purple_conversation_get_type(c))) &&
-				(account == purple_conversation_get_account(c)) &&
+		if ((account == purple_conversation_get_account(c)) &&
 				!purple_utf8_strcasecmp(name1, name2)) {
 
 			break;