- Timestamp:
- 2010-03-26T12:14:37Z (15 years ago)
- Branches:
- master
- Children:
- ebaebfe
- Parents:
- ba7d16f
- Location:
- protocols
- Files:
-
- 1 edited
- 6 moved
Legend:
- Unmodified
- Added
- Removed
-
protocols/Makefile
rba7d16f r3ddb7477 10 10 11 11 # [SH] Program variables 12 objects = nogaim.o 12 #objects = account.o nogaim.o user.o 13 objects = bee.o 14 13 15 14 16 # [SH] The next two lines should contain the directory name (in $(subdirs)) -
protocols/account.c
rba7d16f r3ddb7477 336 336 int account_reconnect_delay( account_t *a ) 337 337 { 338 char *setting = set_getstr( &a->irc-> set, "auto_reconnect_delay" );338 char *setting = set_getstr( &a->irc->b->set, "auto_reconnect_delay" ); 339 339 struct account_reconnect_delay p; 340 340 -
protocols/user.c
rba7d16f r3ddb7477 37 37 if( user_find( irc, nick ) != NULL ) 38 38 return( NULL ); 39 40 if( ( u = irc->users ) )41 {42 while( u )43 {44 if( nick_cmp( nick, u->nick ) < 0 )45 break;46 47 lu = u;48 u = u->next;49 }50 51 u = g_new0( user_t, 1 );52 if( lu )53 {54 u->next = lu->next;55 lu->next = u;56 }57 else58 {59 u->next = irc->users;60 irc->users = u;61 }62 }63 else64 {65 irc->users = u = g_new0( user_t, 1 );66 }67 68 u->user = u->realname = u->host = u->nick = g_strdup( nick );69 u->is_private = set_getbool( &irc->set, "private" );70 71 key = g_strdup( nick );72 nick_lc( key );73 g_hash_table_insert( irc->userhash, key, u );74 39 75 40 return( u ); … … 113 78 g_free( u ); 114 79 115 if( !g_hash_table_lookup_extended( irc->userhash, key, &okey, &ovalue ) || ovalue != u )116 {117 g_free( key );118 return( 1 ); /* Although this is a severe error, the user is removed from the list... */119 }120 g_hash_table_remove( irc->userhash, key );121 g_free( key );122 g_free( okey );123 124 80 return( 1 ); 125 81 } … … 128 84 129 85 return( 0 ); 130 }131 132 user_t *user_find( irc_t *irc, char *nick )133 {134 char key[512] = "";135 136 strncpy( key, nick, sizeof( key ) - 1 );137 if( nick_lc( key ) )138 return( g_hash_table_lookup( irc->userhash, key ) );139 else140 return( NULL );141 86 } 142 87 … … 160 105 return NULL; 161 106 } 162 163 /* DO NOT PASS u->nick FOR oldnick !!! */164 void user_rename( irc_t *irc, char *oldnick, char *newnick )165 {166 user_t *u = user_find( irc, oldnick );167 gpointer okey, ovalue;168 char *key;169 170 if( !u ) return; /* Should've been checked by the caller... */171 172 g_free( u->nick );173 if( u->nick == u->user ) u->user = NULL;174 if( u->nick == u->host ) u->host = NULL;175 if( u->nick == u->realname ) u->realname = NULL;176 u->nick = g_strdup( newnick );177 if( !u->user ) u->user = u->nick;178 if( !u->host ) u->host = u->nick;179 if( !u->realname ) u->realname = u->nick;180 181 /* Remove the old reference to this user from the hash and create a182 new one with the new nick. This is indeed a bit messy. */183 key = g_strdup( oldnick );184 nick_lc( key );185 if( !g_hash_table_lookup_extended( irc->userhash, key, &okey, &ovalue ) || ovalue != u )186 {187 g_free( key );188 return; /* This really shouldn't happen! */189 }190 g_hash_table_remove( irc->userhash, key );191 g_free( key );192 g_free( okey );193 194 key = g_strdup( newnick );195 nick_lc( key );196 g_hash_table_insert( irc->userhash, key, u );197 198 /* Also, let's try to keep the linked list nicely sorted. Fear this199 code. If my teacher would see this, she would cry. ;-) */200 {201 user_t *u1, *lu1;202 203 /* Remove the user from the old position in the chain. */204 if( u == irc->users )205 {206 irc->users = u->next;207 }208 else209 {210 u1 = u;211 for( lu1 = irc->users; lu1->next != u1; lu1 = lu1->next );212 lu1->next = u1->next;213 }214 215 /* Search for the new position. */216 for( lu1 = NULL, u1 = irc->users; u1; u1 = u1->next )217 {218 if( nick_cmp( newnick, u1->nick ) < 0 )219 break;220 221 lu1 = u1;222 }223 224 /* Insert it at this new position. */225 u->next = u1;226 if( lu1 )227 lu1->next = u;228 else229 irc->users = u;230 }231 } -
protocols/user.h
rba7d16f r3ddb7477 23 23 Suite 330, Boston, MA 02111-1307 USA 24 24 */ 25 25 26 #ifndef __USER_H__ 26 27 #define __USER_H__ 27 28 28 typedefstruct __USER29 struct __USER 29 30 { 30 char *nick;31 char * user;32 char * host;33 char * realname;34 31 struct im_connection *ic; 32 char *handle; 33 char *fullname; 34 char *group; 35 35 36 char *away; 36 char *status_msg; /* Non-IRC extension, but nice on IM. */ 37 38 char is_private; 39 char online; 40 41 char *handle; 42 char *group; 43 struct im_connection *ic; 44 45 char *sendbuf; 46 time_t last_typing_notice; 47 int sendbuf_len; 48 guint sendbuf_timer; 49 int sendbuf_flags; 50 51 void (*send_handler) ( irc_t *irc, struct __USER *u, char *msg, int flags ); 52 53 struct __USER *next; 37 char *status_msg; 54 38 } user_t; 55 39 56 user_t *user_add( struct irc *irc, char *nick );57 int user_del( irc_t *irc, char *nick );58 G_MODULE_EXPORT user_t *user_find( irc_t *irc, char *nick );59 G_MODULE_EXPORT user_t *user_findhandle( struct im_connection *ic, const char *handle );60 void user_rename( irc_t *irc, char *oldnick, char *newnick );61 62 40 #endif /* __USER_H__ */
Note: See TracChangeset
for help on using the changeset viewer.