diff src/protocols/msn/msg.c @ 5506:4f72b611f0ee

[gaim-migrate @ 5905] A few changes here. - Messages now have reference counting. - There's a message queue API in servconn. This was needed for times when we have a message but need further information from a command before processing it, like initial e-mail notifications. - As a result of the two above, we now have initial e-mail notifications again! committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Sun, 25 May 2003 09:04:32 +0000
parents bae3c48b9b4c
children b8abf266dd3b
line wrap: on
line diff
--- a/src/protocols/msn/msg.c	Sat May 24 19:15:58 2003 +0000
+++ b/src/protocols/msn/msg.c	Sun May 25 09:04:32 2003 +0000
@@ -63,6 +63,8 @@
 	msn_message_set_charset(msg, "UTF-8");
 	msn_message_set_flag(msg, 'N');
 
+	msn_message_ref(msg);
+
 	return msg;
 }
 
@@ -174,6 +176,12 @@
 {
 	g_return_if_fail(msg != NULL);
 
+	if (msg->ref_count > 0) {
+		msn_message_unref(msg);
+
+		return;
+	}
+
 	if (msg->sender != NULL)
 		msn_user_unref(msg->sender);
 
@@ -192,9 +200,39 @@
 	g_hash_table_destroy(msg->attr_table);
 	g_list_free(msg->attr_list);
 
+	gaim_debug(GAIM_DEBUG_INFO, "msn", "Destroying message\n");
 	g_free(msg);
 }
 
+MsnMessage *
+msn_message_ref(MsnMessage *msg)
+{
+	g_return_val_if_fail(msg != NULL, NULL);
+
+	msg->ref_count++;
+
+	return msg;
+}
+
+MsnMessage *
+msn_message_unref(MsnMessage *msg)
+{
+	g_return_val_if_fail(msg != NULL, NULL);
+
+	if (msg->ref_count <= 0)
+		return NULL;
+
+	msg->ref_count--;
+
+	if (msg->ref_count == 0) {
+		msn_message_destroy(msg);
+
+		return NULL;
+	}
+
+	return msg;
+}
+
 char *
 msn_message_build_string(const MsnMessage *msg)
 {