Changeset 52a2521


Ignore:
Timestamp:
2010-06-30T23:46:55Z (9 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
3353b5e
Parents:
06f9548
Message:

When receiving a channel name hint, and a channel with that name already
exists, remove it if it's fully unused, instead of failing immediately.
(Fixes #639.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • irc_im.c

    r06f9548 r52a2521  
    421421       
    422422        /* Try to find a channel that expects to receive a groupchat.
    423            This flag is set by groupchat_stub_invite(). */
     423           This flag is set earlier in our current call trace. */
    424424        for( l = irc->channels; l; l = l->next )
    425425        {
     
    530530{
    531531        irc_t *irc = bee->ui_data;
    532         irc_channel_t *ic = c->ui_data;
     532        irc_channel_t *ic = c->ui_data, *oic;
    533533        char stripped[MAX_NICK_LENGTH+1], *full_name;
    534534       
     
    543543                nick_lc( stripped );
    544544       
     545        if( stripped[0] == '\0' )
     546                return FALSE;
     547       
    545548        full_name = g_strdup_printf( "#%s", stripped );
    546        
    547         if( stripped[0] && irc_channel_by_name( irc, full_name ) == NULL )
    548         {
    549                 g_free( ic->name );
    550                 ic->name = full_name;
    551         }
    552         else
    553         {
    554                 g_free( full_name );
    555         }
     549        if( ( oic = irc_channel_by_name( irc, full_name ) ) )
     550        {
     551                char *type, *chat_type;
     552               
     553                type = set_getstr( &oic->set, "type" );
     554                chat_type = set_getstr( &oic->set, "chat_type" );
     555               
     556                if( type && chat_type && oic->data == FALSE &&
     557                    strcmp( type, "chat" ) == 0 &&
     558                    strcmp( chat_type, "groupchat" ) == 0 )
     559                {
     560                        /* There's a channel with this name already, but it looks
     561                           like it's not in use yet. Most likely the IRC client
     562                           rejoined the channel after a reconnect. Remove it so
     563                           we can reuse its name. */
     564                        irc_channel_free( oic );
     565                }
     566                else
     567                {
     568                        g_free( full_name );
     569                        return FALSE;
     570                }
     571        }
     572       
     573        g_free( ic->name );
     574        ic->name = full_name;
    556575       
    557576        return TRUE;
Note: See TracChangeset for help on using the changeset viewer.