changeset 18858:f773aa054dca

Clear bonjour buddy values before resetting them so that we notice value removals.
author Daniel Atallah <daniel.atallah@gmail.com>
date Thu, 09 Aug 2007 22:49:53 +0000
parents bc9b78ba996a
children c1546f6c0432
files libpurple/protocols/bonjour/buddy.c libpurple/protocols/bonjour/buddy.h libpurple/protocols/bonjour/mdns_avahi.c libpurple/protocols/bonjour/mdns_howl.c libpurple/protocols/bonjour/mdns_win32.c
diffstat 5 files changed, 30 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/bonjour/buddy.c	Thu Aug 09 22:37:06 2007 +0000
+++ b/libpurple/protocols/bonjour/buddy.c	Thu Aug 09 22:49:53 2007 +0000
@@ -42,6 +42,26 @@
 	return buddy;
 }
 
+#define _B_CLR(x) g_free(x); x = NULL;
+
+void clear_bonjour_buddy_values(BonjourBuddy *buddy) {
+
+	_B_CLR(buddy->first)
+	_B_CLR(buddy->email);
+	_B_CLR(buddy->ext);
+	_B_CLR(buddy->jid);
+	_B_CLR(buddy->last);
+	_B_CLR(buddy->msg);
+	_B_CLR(buddy->nick);
+	_B_CLR(buddy->node);
+	_B_CLR(buddy->phsh);
+	_B_CLR(buddy->status);
+	_B_CLR(buddy->vc);
+	_B_CLR(buddy->ver);
+	_B_CLR(buddy->AIM);
+
+}
+
 void
 set_bonjour_buddy_value(BonjourBuddy* buddy, const char *record_key, const char *value, uint32_t len){
 	gchar **fld = NULL;
--- a/libpurple/protocols/bonjour/buddy.h	Thu Aug 09 22:37:06 2007 +0000
+++ b/libpurple/protocols/bonjour/buddy.h	Thu Aug 09 22:49:53 2007 +0000
@@ -75,9 +75,15 @@
 BonjourBuddy *bonjour_buddy_new(const gchar *name, PurpleAccount *account);
 
 /**
+ * Clear any existing values from the buddy.
+ * This is called before updating so that we can notice removals
+ */
+void clear_bonjour_buddy_values(BonjourBuddy *buddy);
+
+/**
  * Sets a value in the BonjourBuddy struct, destroying the old value
  */
-void set_bonjour_buddy_value(BonjourBuddy* buddy, const char *record_key, const char *value, uint32_t len);
+void set_bonjour_buddy_value(BonjourBuddy *buddy, const char *record_key, const char *value, uint32_t len);
 
 /**
  * Check if all the compulsory buddy data is present.
--- a/libpurple/protocols/bonjour/mdns_avahi.c	Thu Aug 09 22:37:06 2007 +0000
+++ b/libpurple/protocols/bonjour/mdns_avahi.c	Thu Aug 09 22:49:53 2007 +0000
@@ -86,6 +86,7 @@
 			buddy->port_p2pj = port;
 
 			/* Obtain the parameters from the text_record */
+			clear_bonjour_buddy_values(buddy);
 			l = txt;
 			while (l != NULL) {
 				ret = avahi_string_list_get_pair(l, &key, &value, &size);
--- a/libpurple/protocols/bonjour/mdns_howl.c	Thu Aug 09 22:37:06 2007 +0000
+++ b/libpurple/protocols/bonjour/mdns_howl.c	Thu Aug 09 22:49:53 2007 +0000
@@ -85,6 +85,7 @@
 	/* Obtain the parameters from the text_record */
 	if ((text_record_len > 0) && (text_record) && (*text_record != '\0'))
 	{
+		clear_bonjour_buddy_values(buddy);
 		sw_text_record_iterator_init(&iterator, text_record, text_record_len);
 		while (sw_text_record_iterator_next(iterator, key, (sw_octet *)value, &value_length) == SW_OKAY)
 			set_bonjour_buddy_value(buddy, key, value, value_length);
--- a/libpurple/protocols/bonjour/mdns_win32.c	Thu Aug 09 22:37:06 2007 +0000
+++ b/libpurple/protocols/bonjour/mdns_win32.c	Thu Aug 09 22:49:53 2007 +0000
@@ -64,6 +64,7 @@
 	uint8_t txt_len;
 	int i;
 
+	clear_bonjour_buddy_values(buddy);
 	for (i = 0; buddy_TXT_records[i] != NULL; i++) {
 		txt_entry = TXTRecordGetValuePtr(record_len, record, buddy_TXT_records[i], &txt_len);
 		if (txt_entry != NULL)