# HG changeset patch
# User Evan Schoenberg <evan.s@dreskin.net>
# Date 1166776392 0
# Node ID 7a94d65a8f6a44947fbba239a134c5e9913db088
# Parent  2e3ffe29f9aee44c295c9011b56e7ba3e75b6459
[gaim-migrate @ 18046]
When there is no away message specified in the info block and the contact is no longer away, clear the cached away message if there is one.

Previously, when a contact did the following:
1. Away with Message 1
2. Available
3. Away with Message 2

the 3rd event would lead to setting away first with Message 1 (cached in the old user_info object) and then with Message 2 (using a newly created user_info object).

I also changed 2 "#if 0" directives which together controlled logging unknown TLVs into "#ifdef LOG_UNKNOWN_TLV" and added a commented-out #define at the top of the file.

committer: Tailor Script <tailor@pidgin.im>

diff -r 2e3ffe29f9ae -r 7a94d65a8f6a libgaim/protocols/oscar/family_locate.c
--- a/libgaim/protocols/oscar/family_locate.c	Fri Dec 22 08:29:28 2006 +0000
+++ b/libgaim/protocols/oscar/family_locate.c	Fri Dec 22 08:33:12 2006 +0000
@@ -31,6 +31,9 @@
 #include "win32dep.h"
 #endif
 
+/* Define to log unknown TLVs */
+/* #define LOG_UNKNOWN_TLV */
+
 /*
  * Capability blocks.
  *
@@ -301,6 +304,21 @@
 			cur->away = NULL;
 		cur->away_encoding = strdup(userinfo->away_encoding);
 		cur->away_len = userinfo->away_len;
+
+	} else if (!(userinfo->flags & AIM_FLAG_AWAY)) {
+		/*
+		 * We don't have an away message specified in this user_info block.
+		 * If the user is not away, clear any cached away message now.
+		 */
+		if (cur->away) {
+			free(cur->away);
+			cur->away = NULL;
+		}
+		if (cur->away_encoding) {
+			free(cur->away_encoding);
+			cur->away_encoding = NULL;
+		}
+		cur->away_len = 0;
 	}
 
 	/*
@@ -525,7 +543,7 @@
 	return 0;
 }
 
-#if 0
+#ifdef LOG_UNKNOWN_TLV
 static void
 dumptlv(OscarData *od, guint16 type, ByteStream *bs, guint8 len)
 {
@@ -851,7 +869,7 @@
 			 * recovery.
 			 *
 			 */
-#if 0
+#ifdef LOG_UNKNOWN_TLV
 			gaim_debug_misc("oscar", "userinfo: **warning: unexpected TLV:\n");
 			gaim_debug_misc("oscar", "userinfo:   sn    =%s\n", outinfo->sn);
 			dumptlv(od, type, bs, length);