- Timestamp:
- 2010-07-11T12:21:59Z (14 years ago)
- Branches:
- master
- Children:
- 2e0eaac
- Parents:
- 133cdff
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
nick.c
r133cdff rb1f818b 2 2 * BitlBee -- An IRC to other IM-networks gateway * 3 3 * * 4 * Copyright 2002-20 07Wilmer van der Gaast and others *4 * Copyright 2002-2010 Wilmer van der Gaast and others * 5 5 \********************************************************************/ 6 6 … … 42 42 } 43 43 44 void nick_set ( account_t *acc, const char *handle, const char *nick )44 void nick_set_raw( account_t *acc, const char *handle, const char *nick ) 45 45 { 46 46 char *store_handle, *store_nick = g_malloc( MAX_NICK_LENGTH + 1 ); 47 47 48 48 store_handle = clean_handle( handle ); 49 store_nick[MAX_NICK_LENGTH] = 0;49 store_nick[MAX_NICK_LENGTH] = '\0'; 50 50 strncpy( store_nick, nick, MAX_NICK_LENGTH ); 51 51 nick_strip( store_nick ); … … 54 54 } 55 55 56 char *nick_get( account_t *acc, const char *handle ) 56 void nick_set( bee_user_t *bu, const char *nick ) 57 { 58 nick_set_raw( bu->ic->acc, bu->handle, nick ); 59 } 60 61 char *nick_get( bee_user_t *bu ) 57 62 { 58 63 static char nick[MAX_NICK_LENGTH+1]; … … 61 66 memset( nick, 0, MAX_NICK_LENGTH + 1 ); 62 67 63 store_handle = clean_handle( handle );68 store_handle = clean_handle( bu->handle ); 64 69 /* Find out if we stored a nick for this person already. If not, try 65 70 to generate a sane nick automatically. */ 66 if( ( found_nick = g_hash_table_lookup( acc->nicks, store_handle ) ) )71 if( ( found_nick = g_hash_table_lookup( bu->ic->acc->nicks, store_handle ) ) ) 67 72 { 68 73 strncpy( nick, found_nick, MAX_NICK_LENGTH ); … … 72 77 char *s; 73 78 74 g_snprintf( nick, MAX_NICK_LENGTH, "%s", handle );79 g_snprintf( nick, MAX_NICK_LENGTH, "%s", bu->handle ); 75 80 if( ( s = strchr( nick, '@' ) ) ) 76 81 while( *s ) … … 78 83 79 84 nick_strip( nick ); 80 if( set_getbool( & acc->bee->set, "lcnicks" ) )85 if( set_getbool( &bu->bee->set, "lcnicks" ) ) 81 86 nick_lc( nick ); 82 87 } … … 85 90 /* Make sure the nick doesn't collide with an existing one by adding 86 91 underscores and that kind of stuff, if necessary. */ 87 nick_dedupe( acc, handle, nick );92 nick_dedupe( bu, nick ); 88 93 89 94 return nick; 90 95 } 91 96 92 void nick_dedupe( account_t *acc, const char *handle, char nick[MAX_NICK_LENGTH+1] ) 93 { 94 irc_t *irc = (irc_t*) acc->bee->ui_data; 97 char *nick_gen( bee_user_t *bu ) 98 { 99 return NULL; 100 } 101 102 void nick_dedupe( bee_user_t *bu, char nick[MAX_NICK_LENGTH+1] ) 103 { 104 irc_t *irc = (irc_t*) bu->bee->ui_data; 95 105 int inf_protection = 256; 96 106 … … 119 129 "Please send all the following lines in your report:" ); 120 130 121 irc_usermsg( irc, "Trying to get a sane nick for handle %s", handle );131 irc_usermsg( irc, "Trying to get a sane nick for handle %s", bu->handle ); 122 132 for( i = 0; i < MAX_NICK_LENGTH; i ++ ) 123 133 irc_usermsg( irc, "Char %d: %c/%d", i, nick[i], nick[i] ); … … 136 146 /* Just check if there is a nickname set for this buddy or if we'd have to 137 147 generate one. */ 138 int nick_saved( account_t *acc, const char *handle)148 int nick_saved( bee_user_t *bu ) 139 149 { 140 150 char *store_handle, *found; 141 151 142 store_handle = clean_handle( handle );143 found = g_hash_table_lookup( acc->nicks, store_handle );152 store_handle = clean_handle( bu->handle ); 153 found = g_hash_table_lookup( bu->ic->acc->nicks, store_handle ); 144 154 g_free( store_handle ); 145 155 … … 147 157 } 148 158 149 void nick_del( account_t *acc, const char *handle)150 { 151 g_hash_table_remove( acc->nicks,handle );159 void nick_del( bee_user_t *bu ) 160 { 161 g_hash_table_remove( bu->ic->acc->nicks, bu->handle ); 152 162 } 153 163
Note: See TracChangeset
for help on using the changeset viewer.