Changeset e54112f
- Timestamp:
- 2010-05-02T23:44:33Z (15 years ago)
- Branches:
- master
- Children:
- 6a9d068
- Parents:
- bce78c8
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
irc.h
rbce78c8 re54112f 153 153 }; 154 154 155 typedef enum 156 { 157 IRC_CHANNEL_USER_OP = 1, 158 IRC_CHANNEL_USER_HALFOP = 2, 159 IRC_CHANNEL_USER_VOICE = 4, 160 } irc_channel_user_flags_t; 161 162 typedef struct irc_channel_user 163 { 164 irc_user_t *iu; 165 int flags; 166 } irc_channel_user_t; 167 155 168 extern const struct bee_ui_funcs irc_ui_funcs; 156 169 … … 181 194 int irc_channel_add_user( irc_channel_t *ic, irc_user_t *iu ); 182 195 int irc_channel_del_user( irc_channel_t *ic, irc_user_t *iu ); 183 gbooleanirc_channel_has_user( irc_channel_t *ic, irc_user_t *iu );196 irc_channel_user_t *irc_channel_has_user( irc_channel_t *ic, irc_user_t *iu ); 184 197 int irc_channel_set_topic( irc_channel_t *ic, const char *topic, const irc_user_t *who ); 185 198 gboolean irc_channel_name_ok( const char *name ); -
irc_channel.c
rbce78c8 re54112f 26 26 #include "bitlbee.h" 27 27 28 static gint irc_channel_user_cmp( gconstpointer a_, gconstpointer b_ ); 28 29 static const struct irc_channel_funcs control_channel_funcs; 29 30 … … 71 72 72 73 irc->channels = g_slist_remove( irc->channels, ic ); 73 g_slist_free( ic->users ); 74 while( ic->users ) 75 { 76 g_free( ic->users->data ); 77 ic->users = g_slist_remove( ic->users, ic->users->data ); 78 } 74 79 75 80 g_free( ic->name ); … … 82 87 int irc_channel_add_user( irc_channel_t *ic, irc_user_t *iu ) 83 88 { 89 irc_channel_user_t *icu; 90 84 91 if( irc_channel_has_user( ic, iu ) ) 85 92 return 0; 86 93 87 ic->users = g_slist_insert_sorted( ic->users, iu, irc_user_cmp ); 94 icu = g_new0( irc_channel_user_t, 1 ); 95 icu->iu = iu; 96 97 ic->users = g_slist_insert_sorted( ic->users, icu, irc_channel_user_cmp ); 88 98 89 99 if( iu == ic->irc->user || ic->flags & IRC_CHANNEL_JOINED ) … … 98 108 int irc_channel_del_user( irc_channel_t *ic, irc_user_t *iu ) 99 109 { 100 if( !irc_channel_has_user( ic, iu ) ) 110 irc_channel_user_t *icu; 111 112 if( !( icu = irc_channel_has_user( ic, iu ) ) ) 101 113 return 0; 102 114 103 ic->users = g_slist_remove( ic->users, iu ); 115 ic->users = g_slist_remove( ic->users, icu ); 116 g_free( icu ); 104 117 105 118 if( ic->flags & IRC_CHANNEL_JOINED ) … … 112 125 } 113 126 114 /* Currently a fairly stupid one-liner but I fear it's going to get worse. :-) */ 115 gboolean irc_channel_has_user( irc_channel_t *ic, irc_user_t *iu ) 116 { 117 return g_slist_find( ic->users, iu ) != NULL; 127 irc_channel_user_t *irc_channel_has_user( irc_channel_t *ic, irc_user_t *iu ) 128 { 129 GSList *l; 130 131 for( l = ic->users; l; l = l->next ) 132 { 133 irc_channel_user_t *icu = l->data; 134 135 if( icu->iu == iu ) 136 return icu; 137 } 138 139 return NULL; 118 140 } 119 141 … … 140 162 { 141 163 return strchr( CTYPES, name[0] ) != NULL && nick_ok( name + 1 ); 164 } 165 166 static gint irc_channel_user_cmp( gconstpointer a_, gconstpointer b_ ) 167 { 168 const irc_channel_user_t *a = a_, *b = b_; 169 170 return irc_user_cmp( a->iu, b->iu ); 142 171 } 143 172 -
irc_send.c
rbce78c8 re54112f 163 163 for( l = ic->users; l; l = l->next ) 164 164 { 165 irc_user_t *iu = l->data; 165 irc_channel_user_t *icu = l->data; 166 irc_user_t *iu = icu->iu; 166 167 167 168 if( strlen( namelist ) + strlen( iu->nick ) > sizeof( namelist ) - 4 ) … … 243 244 void irc_send_who( irc_t *irc, GSList *l, const char *channel ) 244 245 { 246 gboolean is_channel = strcmp( channel, "**" ) != 0; 247 245 248 while( l ) 246 249 { 247 250 irc_user_t *iu = l->data; 251 if( is_channel ) 252 iu = ((irc_channel_user_t*)iu)->iu; 248 253 /* TODO(wilmer): Restore away/channel information here */ 249 254 irc_send_num( irc, 352, "%s %s %s %s %s %c :0 %s",
Note: See TracChangeset
for help on using the changeset viewer.