Mon, 14 Jun 2004 07:05:10 +0000
[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.
| 9278 | 1 | /* |
| 2 | * gaim | |
| 3 | * | |
| 4 | * Gaim is the legal property of its developers, whose names are too numerous | |
| 5 | * to list here. Please refer to the COPYRIGHT file distributed with this | |
| 6 | * source distribution. | |
| 7 | * | |
| 8 | * This program is free software; you can redistribute it and/or modify | |
| 9 | * it under the terms of the GNU General Public License as published by | |
| 10 | * the Free Software Foundation; either version 2 of the License, or | |
| 11 | * (at your option) any later version. | |
| 12 | * | |
| 13 | * This program is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | * GNU General Public License for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU General Public License | |
| 19 | * along with this program; if not, write to the Free Software | |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 21 | * | |
| 22 | */ | |
| 23 | ||
| 24 | #include "prpl.h" | |
| 9279 | 25 | #include "util.h" |
| 9278 | 26 | |
| 27 | #include "yahoo_friend.h" | |
| 28 | ||
| 29 | YahooFriend *yahoo_friend_new(void) | |
| 30 | { | |
| 31 | YahooFriend *ret; | |
| 32 | ||
| 33 | ret = g_new0(YahooFriend, 1); | |
| 34 | ret->status = YAHOO_STATUS_OFFLINE; | |
| 35 | ||
| 36 | return ret; | |
| 37 | } | |
| 38 | ||
| 9279 | 39 | YahooFriend *yahoo_friend_find(GaimConnection *gc, const char *name) |
| 40 | { | |
| 41 | struct yahoo_data *yd; | |
| 42 | const char *norm; | |
| 43 | ||
| 44 | g_return_val_if_fail(gc != NULL, NULL); | |
| 45 | g_return_val_if_fail(gc->proto_data != NULL, NULL); | |
| 46 | ||
| 47 | yd = gc->proto_data; | |
| 48 | norm = gaim_normalize(gaim_connection_get_account(gc), name); | |
| 49 | ||
| 50 | return g_hash_table_lookup(yd->friends, norm); | |
| 51 | } | |
| 52 | ||
| 53 | YahooFriend *yahoo_friend_find_or_new(GaimConnection *gc, const char *name) | |
| 54 | { | |
| 55 | YahooFriend *f; | |
| 56 | struct yahoo_data *yd; | |
| 57 | const char *norm; | |
| 58 | ||
| 59 | g_return_val_if_fail(gc != NULL, NULL); | |
| 60 | g_return_val_if_fail(gc->proto_data != NULL, NULL); | |
| 61 | ||
| 62 | yd = gc->proto_data; | |
| 63 | norm = gaim_normalize(gaim_connection_get_account(gc), name); | |
| 64 | ||
| 65 | f = g_hash_table_lookup(yd->friends, norm); | |
| 66 | if (!f) { | |
| 67 | f = yahoo_friend_new(); | |
| 68 | g_hash_table_insert(yd->friends, g_strdup(norm), f); | |
| 69 | } | |
| 70 | ||
| 71 | return f; | |
| 72 | } | |
| 73 | ||
| 9281 | 74 | void yahoo_friend_set_ip(YahooFriend *f, const char *ip) |
| 75 | { | |
| 76 | if (f->ip) | |
| 77 | g_free(f->ip); | |
| 78 | f->ip = g_strdup(ip); | |
| 79 | } | |
| 80 | ||
| 81 | const char *yahoo_friend_get_ip(YahooFriend *f) | |
| 82 | { | |
| 83 | return f->ip; | |
| 84 | } | |
| 85 | ||
| 9278 | 86 | void yahoo_friend_free(gpointer p) |
| 87 | { | |
| 88 | YahooFriend *f = p; | |
| 89 | if (f->msg) | |
| 90 | g_free(f->msg); | |
| 91 | if (f->game) | |
| 92 | g_free(f->game); | |
| 93 | g_free(f); | |
| 94 | } |