changeset 19705:7ea794e7cec3

Keep the message history in PurpleConversation.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Mon, 10 Sep 2007 17:08:36 +0000
parents 892a99da5c5f
children 6d04b27c7f53
files libpurple/conversation.c libpurple/conversation.h
diffstat 2 files changed, 6 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/conversation.c	Mon Sep 10 14:47:42 2007 +0000
+++ b/libpurple/conversation.c	Mon Sep 10 17:08:36 2007 +0000
@@ -39,7 +39,6 @@
 static GList *ims = NULL;
 static GList *chats = NULL;
 static PurpleConversationUiOps *default_ops = NULL;
-static GHashTable *histories = NULL;
 
 void
 purple_conversations_set_ui_ops(PurpleConversationUiOps *ops)
@@ -209,7 +208,6 @@
 add_message_to_history(PurpleConversation *conv, const char *who, const char *message,
 		PurpleMessageFlags flags, time_t when)
 {
-	GList *list;
 	PurpleConvMessage *msg;
 
 	if (flags & PURPLE_MESSAGE_SEND) {
@@ -228,9 +226,7 @@
 	msg->what = g_strdup(message);
 	msg->when = when;
 
-	list = g_hash_table_lookup(histories, conv);
-	list = g_list_prepend(list, msg);
-	g_hash_table_insert(histories, conv, list);
+	conv->message_history = g_list_prepend(conv->message_history, msg);
 }
 
 static void
@@ -2068,14 +2064,14 @@
 
 void purple_conversation_clear_message_history(PurpleConversation *conv)
 {
-	GList *list = g_hash_table_lookup(histories, conv);
+	GList *list = conv->message_history;
 	message_history_free(list);
-	g_hash_table_remove(histories, conv);
+	conv->message_history = NULL;
 }
 
 GList *purple_conversation_get_message_history(PurpleConversation *conv)
 {
-	return g_hash_table_lookup(histories, conv);
+	return conv->message_history;
 }
 
 const char *purple_conversation_message_get_sender(PurpleConvMessage *msg)
@@ -2382,9 +2378,6 @@
 			     purple_value_new(PURPLE_TYPE_SUBTYPE,
 					    PURPLE_SUBTYPE_CONVERSATION),
 			     purple_value_new(PURPLE_TYPE_BOXED, "GList **"));
-
-	/* Initialize the history */
-	histories = g_hash_table_new(g_direct_hash, g_direct_equal);
 }
 
 void
@@ -2393,6 +2386,5 @@
 	while (conversations)
 		purple_conversation_destroy((PurpleConversation*)conversations->data);
 	purple_signals_unregister_by_instance(purple_conversations_get_handle());
-	g_hash_table_destroy(histories);
-	histories = NULL;
 }
+
--- a/libpurple/conversation.h	Mon Sep 10 14:47:42 2007 +0000
+++ b/libpurple/conversation.h	Mon Sep 10 17:08:36 2007 +0000
@@ -327,7 +327,7 @@
 	GHashTable *data;                        /**< Plugin-specific data.   */
 
 	PurpleConnectionFlags features; /**< The supported features */
-
+	GList *message_history;         /**< Message history, as a GList of PurpleConvMessage's */
 };
 
 #ifdef __cplusplus