diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2006-07-03 23:22:45 +0200 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2006-07-03 23:22:45 +0200 |
commit | 5b52a4895e5a59ff6509f7771f4d8665737688c3 (patch) | |
tree | 32c13033b127804864507d8ff90c0c274f8b07e5 /user.c | |
parent | 911f2eb7060f6af6fe8e4e02144cfb7c4bb4cc8b (diff) |
Implemented per-account nick lists instead of per-protocol nick lists.
nick_t is dead, instead nicks are just saves in a per-account_t GLib
hash table. While doing this, the import_buddies command finally died
and text_save() disappeared, because the old file format can't handle
most of the new features in this branch anyway.
Still have to implement support for the new nick lists in text_load()!
Diffstat (limited to 'user.c')
-rw-r--r-- | user.c | 26 |
1 files changed, 16 insertions, 10 deletions
@@ -142,16 +142,22 @@ user_t *user_find( irc_t *irc, char *nick ) user_t *user_findhandle( struct gaim_connection *gc, char *handle ) { - user_t *u = gc->irc->users; - - while( u ) - { - if( u->gc == gc && u->handle && gc->acc->prpl->cmp_buddynames ( u->handle, handle ) == 0 ) - break; - u = u->next; - } - - return( u ); + user_t *u; + char *nick; + + /* First, let's try a hash lookup. If it works, it's probably faster. */ + if( ( nick = g_hash_table_lookup( gc->acc->nicks, handle ) ) && + ( u = user_find( gc->irc, nick ) ) && + ( gc->acc->prpl->handle_cmp( handle, u->handle ) == 0 ) ) + return u; + + /* However, it doesn't always work, so in that case we'll have to dig + through the whole userlist. :-( */ + for( u = gc->irc->users; u; u = u->next ) + if( u->gc == gc && u->handle && gc->acc->prpl->handle_cmp( u->handle, handle ) == 0 ) + return u; + + return NULL; } void user_rename( irc_t *irc, char *oldnick, char *newnick ) |