# HG changeset patch # User Tim Ringenbach # Date 1087196710 0 # Node ID adde46ad65e9d27179fbae68cda4f996448ab80b # Parent 2104c10396269b86a84f6bca5310087bcae9a5f1 [gaim-migrate @ 10084] This keeps track of IP addresses that other clients send us, and displays them in the Get Info dialog. Eventually we'll want to do other stuff with them, probably. committer: Tailor Script diff -r 2104c1039626 -r adde46ad65e9 src/protocols/yahoo/yahoo.c --- a/src/protocols/yahoo/yahoo.c Mon Jun 14 06:09:26 2004 +0000 +++ b/src/protocols/yahoo/yahoo.c Mon Jun 14 07:05:10 2004 +0000 @@ -1828,13 +1828,27 @@ } if (base64) { + guint32 ip; + char *tmp2; + YahooFriend *f; + gaim_base64_decode(base64, &decoded, &len); if (len) { char *tmp = gaim_str_binary_to_ascii(decoded, len); gaim_debug_info("yahoo", "Got P2P service packet (from server): who = %s, ip = %s\n", who, tmp); g_free(tmp); } + + tmp2 = g_strndup(decoded, len); /* so its \0 terminated...*/ + ip = strtol(tmp2, NULL, 10); + g_free(tmp2); g_free(decoded); + tmp2 = g_strdup_printf("%u.%u.%u.%u", ip & 0xff, (ip >> 8) & 0xff, (ip >> 16) & 0xff, + (ip >> 24) & 0xff); + f = yahoo_friend_find(gc, who); + if (f) + yahoo_friend_set_ip(f, tmp2); + g_free(tmp2); } } diff -r 2104c1039626 -r adde46ad65e9 src/protocols/yahoo/yahoo_friend.c --- a/src/protocols/yahoo/yahoo_friend.c Mon Jun 14 06:09:26 2004 +0000 +++ b/src/protocols/yahoo/yahoo_friend.c Mon Jun 14 07:05:10 2004 +0000 @@ -71,6 +71,18 @@ return f; } +void yahoo_friend_set_ip(YahooFriend *f, const char *ip) +{ + if (f->ip) + g_free(f->ip); + f->ip = g_strdup(ip); +} + +const char *yahoo_friend_get_ip(YahooFriend *f) +{ + return f->ip; +} + void yahoo_friend_free(gpointer p) { YahooFriend *f = p; diff -r 2104c1039626 -r adde46ad65e9 src/protocols/yahoo/yahoo_friend.h --- a/src/protocols/yahoo/yahoo_friend.h Mon Jun 14 06:09:26 2004 +0000 +++ b/src/protocols/yahoo/yahoo_friend.h Mon Jun 14 07:05:10 2004 +0000 @@ -45,6 +45,10 @@ YahooFriend *yahoo_friend_new(void); YahooFriend *yahoo_friend_find(GaimConnection *gc, const char *name); YahooFriend *yahoo_friend_find_or_new(GaimConnection *gc, const char *name); + +void yahoo_friend_set_ip(YahooFriend *f, const char *ip); +const char *yahoo_friend_get_ip(YahooFriend *f); + void yahoo_friend_free(gpointer p); #endif /* _YAHOO_FRIEND_H_ */ diff -r 2104c1039626 -r adde46ad65e9 src/protocols/yahoo/yahoo_profile.c --- a/src/protocols/yahoo/yahoo_profile.c Mon Jun 14 06:09:26 2004 +0000 +++ b/src/protocols/yahoo/yahoo_profile.c Mon Jun 14 07:05:10 2004 +0000 @@ -32,6 +32,7 @@ #endif #include "yahoo.h" +#include "yahoo_friend.h" typedef struct { GaimConnection *gc; @@ -634,6 +635,7 @@ static char *yahoo_tooltip_info_text(YahooGetInfoData *info_data) { GString *s = g_string_sized_new(80); /* wild guess */ GaimBuddy *b; + YahooFriend *f; g_string_printf(s, _("%s: %s
"), _("Yahoo! ID"), info_data->name); b = gaim_find_buddy(gaim_connection_get_account(info_data->gc), @@ -656,6 +658,12 @@ g_string_append_printf(s, "%s
", statustext); g_free(statustext); } + if ((f = yahoo_friend_find(info_data->gc, b->name))) { + const char *ip; + if ((ip = yahoo_friend_get_ip(f))) + g_string_append_printf(s, _("IP Address: %s
"), ip); + } + } return g_string_free(s, FALSE);