changeset 15308:745f090c1549

[gaim-migrate @ 18098] Patch 1609805 from Anders Kaseorg, who writes: This patch fixes two bugs when a user "enters" a Zephyr "chat room": - The IP address was displayed incorrectly. - The "entered the room" message was displayed after the message. Without patch: (11:20:42 PM) andersk test: First message. (11:20:42 PM) Anders Kaseorg [18.-13.2.92] entered the room. (11:20:47 PM) andersk test: Second message. With patch: (11:20:42 PM) Anders Kaseorg [18.243.2.92] entered the room. (11:20:42 PM) andersk test: First message. (11:20:47 PM) andersk test: Second message. committer: Tailor Script <tailor@pidgin.im>
author Evan Schoenberg <evan.s@dreskin.net>
date Wed, 10 Jan 2007 03:13:53 +0000
parents e9db26a103eb
children c2903a3768b5
files libgaim/protocols/zephyr/zephyr.c
diffstat 1 files changed, 5 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/libgaim/protocols/zephyr/zephyr.c	Tue Jan 09 21:16:58 2007 +0000
+++ b/libgaim/protocols/zephyr/zephyr.c	Wed Jan 10 03:13:53 2007 +0000
@@ -931,24 +931,19 @@
 				send_inst_utf8 = "malformed instance";
 			}
 
-			serv_got_chat_in(gc, zt2->id, send_inst_utf8, 0, buf3, time(NULL));
-			g_free(send_inst);
 			gconv1 = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT,
 														 zt2->name, gc->account);
 			gcc = gaim_conversation_get_chat_data(gconv1);
 
 			if (!gaim_conv_chat_find_user(gcc, sendertmp)) {
-				/* force interpretation in network byte order */
-				unsigned char *addrs = (unsigned char *)&(notice.z_sender_addr.s_addr);
-				gchar* ipaddr = g_strdup_printf("%hhd.%hhd.%hhd.%hhd", (unsigned char)addrs[0], 
-								(unsigned char)addrs[1], (unsigned char)addrs[2], 
-								(unsigned char) addrs[3]);
-					
+				gchar ipaddr[INET_ADDRSTRLEN];
+				inet_ntop(AF_INET, &notice.z_sender_addr.s_addr, ipaddr, sizeof(ipaddr));
+
 				gaim_conv_chat_add_user(gcc, sendertmp, ipaddr, GAIM_CBFLAGS_NONE, TRUE);
-				g_free(ipaddr); /* fix memory leak? */
-					
 			}
 			g_free(sendertmp);
+			serv_got_chat_in(gc, zt2->id, send_inst_utf8, 0, buf3, time(NULL));
+			g_free(send_inst);
 			g_free(send_inst_utf8);
 				
 			free_triple(zt1);