[4be8239] | 1 | /********************************************************************\ |
---|
| 2 | * BitlBee -- An IRC to other IM-networks gateway * |
---|
| 3 | * * |
---|
| 4 | * Copyright 2002-2010 Wilmer van der Gaast and others * |
---|
| 5 | \********************************************************************/ |
---|
| 6 | |
---|
| 7 | /* The IRC-based UI - Representing (virtual) channels. */ |
---|
| 8 | |
---|
| 9 | /* |
---|
| 10 | This program is free software; you can redistribute it and/or modify |
---|
| 11 | it under the terms of the GNU General Public License as published by |
---|
| 12 | the Free Software Foundation; either version 2 of the License, or |
---|
| 13 | (at your option) any later version. |
---|
| 14 | |
---|
| 15 | This program is distributed in the hope that it will be useful, |
---|
| 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 18 | GNU General Public License for more details. |
---|
| 19 | |
---|
| 20 | You should have received a copy of the GNU General Public License with |
---|
| 21 | the Debian GNU/Linux distribution in /usr/share/common-licenses/GPL; |
---|
| 22 | if not, write to the Free Software Foundation, Inc., 59 Temple Place, |
---|
| 23 | Suite 330, Boston, MA 02111-1307 USA |
---|
| 24 | */ |
---|
| 25 | |
---|
| 26 | #include "bitlbee.h" |
---|
| 27 | |
---|
[2b8473c] | 28 | static char *set_eval_channel_type( set_t *set, char *value ); |
---|
[e54112f] | 29 | static gint irc_channel_user_cmp( gconstpointer a_, gconstpointer b_ ); |
---|
[280c56a] | 30 | static const struct irc_channel_funcs control_channel_funcs; |
---|
[5a75d15] | 31 | |
---|
| 32 | extern const struct irc_channel_funcs irc_channel_im_chat_funcs; |
---|
[280c56a] | 33 | |
---|
[4be8239] | 34 | irc_channel_t *irc_channel_new( irc_t *irc, const char *name ) |
---|
| 35 | { |
---|
| 36 | irc_channel_t *ic; |
---|
| 37 | |
---|
[9438323] | 38 | if( !irc_channel_name_ok( name ) || irc_channel_by_name( irc, name ) ) |
---|
[4be8239] | 39 | return NULL; |
---|
| 40 | |
---|
| 41 | ic = g_new0( irc_channel_t, 1 ); |
---|
| 42 | ic->irc = irc; |
---|
| 43 | ic->name = g_strdup( name ); |
---|
| 44 | strcpy( ic->mode, CMODE ); |
---|
| 45 | |
---|
| 46 | irc_channel_add_user( ic, irc->root ); |
---|
| 47 | |
---|
[36562b0] | 48 | irc->channels = g_slist_append( irc->channels, ic ); |
---|
[4be8239] | 49 | |
---|
[2b8473c] | 50 | set_add( &ic->set, "type", "control", set_eval_channel_type, ic ); |
---|
| 51 | |
---|
[eb37735] | 52 | if( name[0] == '&' ) |
---|
[2b8473c] | 53 | set_setstr( &ic->set, "type", "control" ); |
---|
[eb37735] | 54 | else /* if( name[0] == '#' ) */ |
---|
[2b8473c] | 55 | set_setstr( &ic->set, "type", "chat" ); |
---|
[9ac3ed1] | 56 | |
---|
[4be8239] | 57 | return ic; |
---|
| 58 | } |
---|
| 59 | |
---|
[b9e020a] | 60 | irc_channel_t *irc_channel_by_name( irc_t *irc, const char *name ) |
---|
| 61 | { |
---|
| 62 | GSList *l; |
---|
| 63 | |
---|
| 64 | for( l = irc->channels; l; l = l->next ) |
---|
| 65 | { |
---|
| 66 | irc_channel_t *ic = l->data; |
---|
| 67 | |
---|
[36562b0] | 68 | if( g_strcasecmp( name, ic->name ) == 0 ) |
---|
[b9e020a] | 69 | return ic; |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | return NULL; |
---|
| 73 | } |
---|
| 74 | |
---|
[36562b0] | 75 | irc_channel_t *irc_channel_get( irc_t *irc, char *id ) |
---|
| 76 | { |
---|
| 77 | irc_channel_t *ic, *ret = NULL; |
---|
| 78 | GSList *l; |
---|
| 79 | int nr; |
---|
| 80 | |
---|
| 81 | if( sscanf( id, "%d", &nr ) == 1 && nr < 1000 ) |
---|
| 82 | { |
---|
| 83 | for( l = irc->channels; l; l = l->next ) |
---|
| 84 | { |
---|
| 85 | ic = l->data; |
---|
| 86 | if( ( nr-- ) == 0 ) |
---|
| 87 | return ic; |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | return NULL; |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | /* Exact match first: Partial match only sucks if there's a channel |
---|
| 94 | #aa and #aabb */ |
---|
| 95 | if( ( ret = irc_channel_by_name( irc, id ) ) ) |
---|
| 96 | return ret; |
---|
| 97 | |
---|
| 98 | for( l = irc->channels; l; l = l->next ) |
---|
| 99 | { |
---|
| 100 | ic = l->data; |
---|
| 101 | |
---|
| 102 | if( strstr( ic->name, id ) ) |
---|
| 103 | { |
---|
| 104 | /* Make sure it's a unique match. */ |
---|
| 105 | if( !ret ) |
---|
| 106 | ret = ic; |
---|
| 107 | else |
---|
| 108 | return NULL; |
---|
| 109 | } |
---|
| 110 | } |
---|
| 111 | |
---|
| 112 | return ret; |
---|
| 113 | } |
---|
| 114 | |
---|
[63a520b] | 115 | int irc_channel_free( irc_channel_t *ic ) |
---|
| 116 | { |
---|
| 117 | irc_t *irc = ic->irc; |
---|
| 118 | |
---|
| 119 | if( ic->flags & IRC_CHANNEL_JOINED ) |
---|
[18da20b] | 120 | irc_channel_del_user( ic, irc->user, FALSE, "Cleaning up channel" ); |
---|
[63a520b] | 121 | |
---|
[d7db346] | 122 | if( ic->f->_free ) |
---|
| 123 | ic->f->_free( ic ); |
---|
| 124 | |
---|
| 125 | while( ic->set ) |
---|
| 126 | set_del( &ic->set, ic->set->key ); |
---|
| 127 | |
---|
[63a520b] | 128 | irc->channels = g_slist_remove( irc->channels, ic ); |
---|
[e54112f] | 129 | while( ic->users ) |
---|
| 130 | { |
---|
| 131 | g_free( ic->users->data ); |
---|
| 132 | ic->users = g_slist_remove( ic->users, ic->users->data ); |
---|
| 133 | } |
---|
[63a520b] | 134 | |
---|
| 135 | g_free( ic->name ); |
---|
| 136 | g_free( ic->topic ); |
---|
[d7db346] | 137 | g_free( ic->topic_who ); |
---|
[63a520b] | 138 | g_free( ic ); |
---|
| 139 | |
---|
| 140 | return 1; |
---|
| 141 | } |
---|
| 142 | |
---|
[2b8473c] | 143 | static char *set_eval_channel_type( set_t *set, char *value ) |
---|
| 144 | { |
---|
| 145 | struct irc_channel *ic = set->data; |
---|
| 146 | const struct irc_channel_funcs *new; |
---|
| 147 | |
---|
| 148 | if( strcmp( value, "control" ) == 0 ) |
---|
| 149 | new = &control_channel_funcs; |
---|
| 150 | else if( strcmp( value, "chat" ) == 0 ) |
---|
[5a75d15] | 151 | new = &irc_channel_im_chat_funcs; |
---|
[2b8473c] | 152 | else |
---|
| 153 | return SET_INVALID; |
---|
| 154 | |
---|
| 155 | /* TODO: Return values. */ |
---|
| 156 | if( ic->f && ic->f->_free ) |
---|
| 157 | ic->f->_free( ic ); |
---|
| 158 | |
---|
| 159 | ic->f = new; |
---|
| 160 | |
---|
| 161 | if( ic->f && ic->f->_init ) |
---|
| 162 | ic->f->_init( ic ); |
---|
| 163 | |
---|
| 164 | return value; |
---|
| 165 | } |
---|
| 166 | |
---|
[4be8239] | 167 | int irc_channel_add_user( irc_channel_t *ic, irc_user_t *iu ) |
---|
| 168 | { |
---|
[e54112f] | 169 | irc_channel_user_t *icu; |
---|
| 170 | |
---|
[57c96f7] | 171 | if( irc_channel_has_user( ic, iu ) ) |
---|
[4be8239] | 172 | return 0; |
---|
| 173 | |
---|
[e54112f] | 174 | icu = g_new0( irc_channel_user_t, 1 ); |
---|
| 175 | icu->iu = iu; |
---|
| 176 | |
---|
| 177 | ic->users = g_slist_insert_sorted( ic->users, icu, irc_channel_user_cmp ); |
---|
[4be8239] | 178 | |
---|
[c5aefa4] | 179 | irc_channel_update_ops( ic, set_getstr( &ic->irc->b->set, "ops" ) ); |
---|
| 180 | |
---|
[4be8239] | 181 | if( iu == ic->irc->user || ic->flags & IRC_CHANNEL_JOINED ) |
---|
| 182 | { |
---|
| 183 | ic->flags |= IRC_CHANNEL_JOINED; |
---|
| 184 | irc_send_join( ic, iu ); |
---|
| 185 | } |
---|
| 186 | |
---|
| 187 | return 1; |
---|
| 188 | } |
---|
| 189 | |
---|
[18da20b] | 190 | int irc_channel_del_user( irc_channel_t *ic, irc_user_t *iu, gboolean silent, const char *msg ) |
---|
[4be8239] | 191 | { |
---|
[e54112f] | 192 | irc_channel_user_t *icu; |
---|
| 193 | |
---|
| 194 | if( !( icu = irc_channel_has_user( ic, iu ) ) ) |
---|
[4be8239] | 195 | return 0; |
---|
| 196 | |
---|
[e54112f] | 197 | ic->users = g_slist_remove( ic->users, icu ); |
---|
| 198 | g_free( icu ); |
---|
[4be8239] | 199 | |
---|
[18da20b] | 200 | if( ic->flags & IRC_CHANNEL_JOINED && !silent ) |
---|
| 201 | irc_send_part( ic, iu, msg ); |
---|
[4be8239] | 202 | |
---|
| 203 | if( iu == ic->irc->user ) |
---|
| 204 | ic->flags &= ~IRC_CHANNEL_JOINED; |
---|
| 205 | |
---|
| 206 | return 1; |
---|
| 207 | } |
---|
| 208 | |
---|
[e54112f] | 209 | irc_channel_user_t *irc_channel_has_user( irc_channel_t *ic, irc_user_t *iu ) |
---|
[0b5cc72] | 210 | { |
---|
[e54112f] | 211 | GSList *l; |
---|
| 212 | |
---|
| 213 | for( l = ic->users; l; l = l->next ) |
---|
| 214 | { |
---|
| 215 | irc_channel_user_t *icu = l->data; |
---|
| 216 | |
---|
| 217 | if( icu->iu == iu ) |
---|
| 218 | return icu; |
---|
| 219 | } |
---|
| 220 | |
---|
| 221 | return NULL; |
---|
[0b5cc72] | 222 | } |
---|
| 223 | |
---|
[83e92bf] | 224 | int irc_channel_set_topic( irc_channel_t *ic, const char *topic, const irc_user_t *iu ) |
---|
[4be8239] | 225 | { |
---|
| 226 | g_free( ic->topic ); |
---|
| 227 | ic->topic = g_strdup( topic ); |
---|
| 228 | |
---|
[83e92bf] | 229 | g_free( ic->topic_who ); |
---|
| 230 | if( iu ) |
---|
| 231 | ic->topic_who = g_strdup_printf( "%s!%s@%s", iu->nick, iu->user, iu->host ); |
---|
| 232 | else |
---|
| 233 | ic->topic_who = NULL; |
---|
| 234 | |
---|
| 235 | ic->topic_time = time( NULL ); |
---|
| 236 | |
---|
[4be8239] | 237 | if( ic->flags & IRC_CHANNEL_JOINED ) |
---|
[83e92bf] | 238 | irc_send_topic( ic, TRUE ); |
---|
[4be8239] | 239 | |
---|
| 240 | return 1; |
---|
| 241 | } |
---|
[b919363] | 242 | |
---|
[6a9d068] | 243 | void irc_channel_user_set_mode( irc_channel_t *ic, irc_user_t *iu, irc_channel_user_flags_t flags ) |
---|
| 244 | { |
---|
| 245 | irc_channel_user_t *icu = irc_channel_has_user( ic, iu ); |
---|
| 246 | |
---|
[c5aefa4] | 247 | if( !icu || icu->flags == flags ) |
---|
[6a9d068] | 248 | return; |
---|
| 249 | |
---|
| 250 | if( ic->flags & IRC_CHANNEL_JOINED ) |
---|
| 251 | irc_send_channel_user_mode_diff( ic, iu, icu->flags, flags ); |
---|
| 252 | |
---|
| 253 | icu->flags = flags; |
---|
| 254 | } |
---|
| 255 | |
---|
[9893da3] | 256 | void irc_channel_printf( irc_channel_t *ic, char *format, ... ) |
---|
| 257 | { |
---|
| 258 | va_list params; |
---|
| 259 | char *text; |
---|
| 260 | |
---|
| 261 | va_start( params, format ); |
---|
| 262 | text = g_strdup_vprintf( format, params ); |
---|
| 263 | va_end( params ); |
---|
| 264 | |
---|
| 265 | irc_send_msg( ic->irc->root, "PRIVMSG", ic->name, text, NULL ); |
---|
| 266 | g_free( text ); |
---|
| 267 | } |
---|
| 268 | |
---|
[b919363] | 269 | gboolean irc_channel_name_ok( const char *name ) |
---|
| 270 | { |
---|
[4c17d19] | 271 | char name_[strlen(name)+1]; |
---|
| 272 | |
---|
| 273 | /* Check if the first character is in CTYPES (#&) */ |
---|
| 274 | if( strchr( CTYPES, name[0] ) == NULL ) |
---|
| 275 | return FALSE; |
---|
| 276 | |
---|
| 277 | /* Check the rest of the name. Just checking name + 1 doesn't work |
---|
| 278 | since it will fail if the first character is a number, or if |
---|
| 279 | it's a one-char channel name - both of which are legal. */ |
---|
| 280 | name_[0] = '_'; |
---|
| 281 | strcpy( name_ + 1, name + 1 ); |
---|
| 282 | return nick_ok( name_ ); |
---|
[b919363] | 283 | } |
---|
[280c56a] | 284 | |
---|
[e54112f] | 285 | static gint irc_channel_user_cmp( gconstpointer a_, gconstpointer b_ ) |
---|
| 286 | { |
---|
| 287 | const irc_channel_user_t *a = a_, *b = b_; |
---|
| 288 | |
---|
| 289 | return irc_user_cmp( a->iu, b->iu ); |
---|
| 290 | } |
---|
| 291 | |
---|
[c5aefa4] | 292 | void irc_channel_update_ops( irc_channel_t *ic, char *value ) |
---|
| 293 | { |
---|
| 294 | irc_channel_user_set_mode( ic, ic->irc->root, |
---|
| 295 | ( strcmp( value, "both" ) == 0 || |
---|
| 296 | strcmp( value, "root" ) == 0 ) ? IRC_CHANNEL_USER_OP : 0 ); |
---|
| 297 | irc_channel_user_set_mode( ic, ic->irc->user, |
---|
| 298 | ( strcmp( value, "both" ) == 0 || |
---|
| 299 | strcmp( value, "user" ) == 0 ) ? IRC_CHANNEL_USER_OP : 0 ); |
---|
| 300 | } |
---|
| 301 | |
---|
| 302 | char *set_eval_irc_channel_ops( set_t *set, char *value ) |
---|
| 303 | { |
---|
| 304 | irc_t *irc = set->data; |
---|
| 305 | GSList *l; |
---|
| 306 | |
---|
| 307 | if( strcmp( value, "both" ) != 0 && strcmp( value, "none" ) != 0 && |
---|
| 308 | strcmp( value, "user" ) != 0 && strcmp( value, "root" ) != 0 ) |
---|
| 309 | return SET_INVALID; |
---|
| 310 | |
---|
| 311 | for( l = irc->channels; l; l = l->next ) |
---|
| 312 | irc_channel_update_ops( l->data, value ); |
---|
| 313 | |
---|
| 314 | return value; |
---|
| 315 | } |
---|
| 316 | |
---|
[280c56a] | 317 | /* Channel-type dependent functions, for control channels: */ |
---|
| 318 | static gboolean control_channel_privmsg( irc_channel_t *ic, const char *msg ) |
---|
| 319 | { |
---|
[bce78c8] | 320 | irc_t *irc = ic->irc; |
---|
| 321 | const char *s; |
---|
[fb117aee] | 322 | |
---|
[bce78c8] | 323 | /* Scan for non-whitespace chars followed by a colon: */ |
---|
[b0364dc] | 324 | for( s = msg; *s && !isspace( *s ) && *s != ':' && *s != ','; s ++ ) {} |
---|
[74f1cde] | 325 | |
---|
[b0364dc] | 326 | if( *s == ':' || *s == ',' ) |
---|
[bce78c8] | 327 | { |
---|
| 328 | char to[s-msg+1]; |
---|
| 329 | irc_user_t *iu; |
---|
| 330 | |
---|
[1a3ba05] | 331 | memset( to, 0, sizeof( to ) ); |
---|
[bce78c8] | 332 | strncpy( to, msg, s - msg ); |
---|
| 333 | while( *(++s) && isspace( *s ) ) {} |
---|
| 334 | |
---|
| 335 | iu = irc_user_by_name( irc, to ); |
---|
| 336 | if( iu && iu->f->privmsg ) |
---|
| 337 | { |
---|
| 338 | iu->flags &= ~IRC_USER_PRIVATE; |
---|
| 339 | iu->f->privmsg( iu, s ); |
---|
| 340 | } |
---|
[1a3ba05] | 341 | else |
---|
| 342 | { |
---|
[9893da3] | 343 | irc_channel_printf( ic, "User does not exist: %s", to ); |
---|
[1a3ba05] | 344 | } |
---|
[bce78c8] | 345 | } |
---|
| 346 | else |
---|
| 347 | { |
---|
| 348 | /* TODO: Maybe just use root->privmsg here now? */ |
---|
| 349 | char cmd[strlen(msg)+1]; |
---|
| 350 | |
---|
| 351 | g_free( ic->irc->last_root_cmd ); |
---|
| 352 | ic->irc->last_root_cmd = g_strdup( ic->name ); |
---|
| 353 | |
---|
| 354 | strcpy( cmd, msg ); |
---|
| 355 | root_command_string( ic->irc, cmd ); |
---|
| 356 | } |
---|
[280c56a] | 357 | |
---|
| 358 | return TRUE; |
---|
| 359 | } |
---|
| 360 | |
---|
[46d215d] | 361 | static gboolean control_channel_invite( irc_channel_t *ic, irc_user_t *iu ) |
---|
| 362 | { |
---|
| 363 | struct irc_control_channel *icc = ic->data; |
---|
| 364 | bee_user_t *bu = iu->bu; |
---|
| 365 | |
---|
| 366 | if( bu == NULL ) |
---|
| 367 | return FALSE; |
---|
| 368 | |
---|
| 369 | if( icc->type != IRC_CC_TYPE_GROUP ) |
---|
| 370 | { |
---|
| 371 | irc_send_num( ic->irc, 482, "%s :Invitations are only possible to fill_by=group channels", ic->name ); |
---|
| 372 | return FALSE; |
---|
| 373 | } |
---|
| 374 | |
---|
| 375 | bu->ic->acc->prpl->add_buddy( bu->ic, bu->handle, |
---|
| 376 | icc->group ? icc->group->name : NULL ); |
---|
| 377 | |
---|
| 378 | return TRUE; |
---|
| 379 | } |
---|
| 380 | |
---|
[2b8473c] | 381 | static char *set_eval_by_account( set_t *set, char *value ); |
---|
| 382 | static char *set_eval_fill_by( set_t *set, char *value ); |
---|
| 383 | static char *set_eval_by_group( set_t *set, char *value ); |
---|
| 384 | |
---|
[9ac3ed1] | 385 | static gboolean control_channel_init( irc_channel_t *ic ) |
---|
| 386 | { |
---|
| 387 | struct irc_control_channel *icc; |
---|
| 388 | |
---|
[2b8473c] | 389 | set_add( &ic->set, "account", NULL, set_eval_by_account, ic ); |
---|
| 390 | set_add( &ic->set, "fill_by", "all", set_eval_fill_by, ic ); |
---|
| 391 | set_add( &ic->set, "group", NULL, set_eval_by_group, ic ); |
---|
| 392 | |
---|
[9ac3ed1] | 393 | ic->data = icc = g_new0( struct irc_control_channel, 1 ); |
---|
| 394 | icc->type = IRC_CC_TYPE_DEFAULT; |
---|
| 395 | |
---|
[2b8473c] | 396 | if( bee_group_by_name( ic->irc->b, ic->name + 1, FALSE ) ) |
---|
| 397 | { |
---|
| 398 | set_setstr( &ic->set, "group", ic->name + 1 ); |
---|
| 399 | set_setstr( &ic->set, "fill_by", "group" ); |
---|
| 400 | } |
---|
| 401 | else if( set_setstr( &ic->set, "account", ic->name + 1 ) ) |
---|
| 402 | { |
---|
| 403 | set_setstr( &ic->set, "fill_by", "account" ); |
---|
| 404 | } |
---|
[cf1a979] | 405 | else |
---|
| 406 | { |
---|
| 407 | bee_irc_channel_update( ic->irc, ic, NULL ); |
---|
| 408 | } |
---|
[2b8473c] | 409 | |
---|
| 410 | return TRUE; |
---|
| 411 | } |
---|
| 412 | |
---|
| 413 | static char *set_eval_by_account( set_t *set, char *value ) |
---|
| 414 | { |
---|
| 415 | struct irc_channel *ic = set->data; |
---|
| 416 | struct irc_control_channel *icc = ic->data; |
---|
| 417 | account_t *acc; |
---|
| 418 | |
---|
| 419 | if( !( acc = account_get( ic->irc->b, value ) ) ) |
---|
| 420 | return SET_INVALID; |
---|
| 421 | |
---|
| 422 | icc->account = acc; |
---|
[cf1a979] | 423 | if( icc->type == IRC_CC_TYPE_ACCOUNT ) |
---|
| 424 | bee_irc_channel_update( ic->irc, ic, NULL ); |
---|
[2b8473c] | 425 | return g_strdup_printf( "%s(%s)", acc->prpl->name, acc->user ); |
---|
| 426 | } |
---|
| 427 | |
---|
| 428 | static char *set_eval_fill_by( set_t *set, char *value ) |
---|
| 429 | { |
---|
| 430 | struct irc_channel *ic = set->data; |
---|
| 431 | struct irc_control_channel *icc = ic->data; |
---|
| 432 | |
---|
| 433 | if( strcmp( value, "all" ) == 0 ) |
---|
| 434 | icc->type = IRC_CC_TYPE_DEFAULT; |
---|
| 435 | else if( strcmp( value, "rest" ) == 0 ) |
---|
| 436 | icc->type = IRC_CC_TYPE_REST; |
---|
| 437 | else if( strcmp( value, "group" ) == 0 ) |
---|
[13c1a9f] | 438 | icc->type = IRC_CC_TYPE_GROUP; |
---|
[2b8473c] | 439 | else if( strcmp( value, "account" ) == 0 ) |
---|
[a067771] | 440 | icc->type = IRC_CC_TYPE_ACCOUNT; |
---|
[2b8473c] | 441 | else |
---|
| 442 | return SET_INVALID; |
---|
| 443 | |
---|
[cf1a979] | 444 | bee_irc_channel_update( ic->irc, ic, NULL ); |
---|
[2b8473c] | 445 | return value; |
---|
| 446 | } |
---|
| 447 | |
---|
| 448 | static char *set_eval_by_group( set_t *set, char *value ) |
---|
| 449 | { |
---|
| 450 | struct irc_channel *ic = set->data; |
---|
| 451 | struct irc_control_channel *icc = ic->data; |
---|
[13c1a9f] | 452 | |
---|
[2b8473c] | 453 | icc->group = bee_group_by_name( ic->irc->b, value, TRUE ); |
---|
[cf1a979] | 454 | if( icc->type == IRC_CC_TYPE_GROUP ) |
---|
| 455 | bee_irc_channel_update( ic->irc, ic, NULL ); |
---|
[2b8473c] | 456 | return g_strdup( icc->group->name ); |
---|
| 457 | } |
---|
| 458 | |
---|
| 459 | static gboolean control_channel_free( irc_channel_t *ic ) |
---|
| 460 | { |
---|
| 461 | struct irc_control_channel *icc = ic->data; |
---|
| 462 | |
---|
| 463 | set_del( &ic->set, "account" ); |
---|
| 464 | set_del( &ic->set, "fill_by" ); |
---|
| 465 | set_del( &ic->set, "group" ); |
---|
| 466 | |
---|
| 467 | g_free( icc ); |
---|
| 468 | ic->data = NULL; |
---|
[13c1a9f] | 469 | |
---|
[9ac3ed1] | 470 | return TRUE; |
---|
| 471 | } |
---|
| 472 | |
---|
[280c56a] | 473 | static const struct irc_channel_funcs control_channel_funcs = { |
---|
| 474 | control_channel_privmsg, |
---|
[9ac3ed1] | 475 | NULL, |
---|
| 476 | NULL, |
---|
| 477 | NULL, |
---|
[46d215d] | 478 | control_channel_invite, |
---|
[9ac3ed1] | 479 | |
---|
| 480 | control_channel_init, |
---|
[2b8473c] | 481 | control_channel_free, |
---|
[280c56a] | 482 | }; |
---|