Changeset 7b71feb


Ignore:
Timestamp:
2010-05-13T23:34:38Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
4469e7e
Parents:
ad404ab
Message:

Just enough code to join named chatrooms again. This UI is *not* final, the "chat"
command will probably mostly stick around for bw compatibility. Still thinking
about how this should work eventually.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • irc.h

    rad404ab r7b71feb  
    193193        struct bee_group *group;
    194194        struct account *account;
     195};
     196
     197struct irc_groupchat_stub
     198{
     199        struct account *acc;
     200        char *room;
    195201};
    196202
  • irc_channel.c

    rad404ab r7b71feb  
    313313}
    314314
     315static gboolean groupchat_stub_join( irc_channel_t *ic )
     316{
     317        struct irc_groupchat_stub *igs = ic->data;
     318       
     319        if( igs && igs->acc->ic && igs->acc->prpl->chat_join )
     320        {
     321                ic->flags |= IRC_CHANNEL_CHAT_PICKME;
     322                igs->acc->prpl->chat_join( igs->acc->ic, igs->room, ic->irc->user->nick, NULL );
     323                ic->flags &= ~IRC_CHANNEL_CHAT_PICKME;
     324                return FALSE;
     325        }
     326        else
     327        {
     328                irc_send_num( ic->irc, 403, "%s :Can't join channel, account offline?", ic->name );
     329                return FALSE;
     330        }
     331}
     332
    315333static const struct irc_channel_funcs groupchat_stub_funcs = {
    316334        NULL,
    317         NULL,
     335        groupchat_stub_join,
    318336        NULL,
    319337        NULL,
  • irc_commands.c

    rad404ab r7b71feb  
    139139                return; /* Dude, you're already there...
    140140                           RFC doesn't have any reply for that though? */
     141       
     142        if( ic->f->join && !ic->f->join( ic ) )
     143                /* The story is: FALSE either means the handler showed an error
     144                   message, or is doing some work before the join should be
     145                   confirmed. (In the latter case, the caller should take care
     146                   of that confirmation.)
     147                   TRUE means all's good, let the user join the channel right away. */
     148                return;
    141149       
    142150        irc_channel_add_user( ic, irc->user );
  • root_commands.c

    rad404ab r7b71feb  
    940940}
    941941
    942 #if 0
    943 static set_t **cmd_chat_set_findhead( irc_t *irc, char *id )
    944 {
    945         struct chat *c;
    946        
    947         if( ( c = chat_get( irc, id ) ) )
    948                 return &c->set;
    949         else
    950                 return NULL;
    951 }
    952 
    953942static void cmd_chat( irc_t *irc, char **cmd )
    954943{
     
    959948        {
    960949                char *channel, *s;
     950                struct irc_channel *ic;
    961951               
    962952                MIN_ARGS( 3 );
    963953               
    964                 if( !( acc = account_get( irc, cmd[2] ) ) )
     954                if( !( acc = account_get( irc->b, cmd[2] ) ) )
    965955                {
    966956                        irc_usermsg( irc, "Invalid account" );
     
    981971                if( strchr( CTYPES, channel[0] ) == NULL )
    982972                {
    983                         s = g_strdup_printf( "%c%s", CTYPES[0], channel );
     973                        s = g_strdup_printf( "#%s", channel );
    984974                        g_free( channel );
    985975                        channel = s;
    986976                }
    987977               
    988                 if( ( c = chat_add( irc, acc, cmd[3], channel ) ) )
    989                         irc_usermsg( irc, "Chatroom added successfully." );
    990                 else
    991                         irc_usermsg( irc, "Could not add chatroom." );
    992                
    993                 g_free( channel );
    994         }
    995         else if( g_strcasecmp( cmd[1], "list" ) == 0 )
    996         {
    997                 int i = 0;
    998                
    999                 if( strchr( irc->umode, 'b' ) )
    1000                         irc_usermsg( irc, "Chatroom list:" );
    1001                
    1002                 for( c = irc->chatrooms; c; c = c->next )
    1003                 {
    1004                         irc_usermsg( irc, "%2d. %s(%s) %s, %s", i, c->acc->prpl->name,
    1005                                           c->acc->user, c->handle, c->channel );
     978                if( ( ic = irc_channel_new( irc, channel ) ) )
     979                {
     980                        struct irc_groupchat_stub *igs;
    1006981                       
    1007                         i ++;
    1008                 }
    1009                 irc_usermsg( irc, "End of chatroom list" );
    1010         }
    1011         else if( g_strcasecmp( cmd[1], "set" ) == 0 )
    1012         {
    1013                 MIN_ARGS( 2 );
    1014                
    1015                 cmd_set_real( irc, cmd + 1, cmd_chat_set_findhead, NULL );
    1016         }
    1017         else if( g_strcasecmp( cmd[1], "del" ) == 0 )
    1018         {
    1019                 MIN_ARGS( 2 );
    1020                
    1021                 if( ( c = chat_get( irc, cmd[2] ) ) )
    1022                 {
    1023                         chat_del( irc, c );
    1024                 }
    1025                 else
    1026                 {
    1027                         irc_usermsg( irc, "Could not remove chat." );
    1028                 }
    1029         }
     982                        ic->data = igs = g_new0( struct irc_groupchat_stub, 1 );
     983                        igs->acc = acc;
     984                        igs->room = g_strdup( cmd[3] );
     985                }
     986        }
     987        /*
    1030988        else if( g_strcasecmp( cmd[1], "with" ) == 0 )
    1031989        {
     
    10471005                }
    10481006        }
     1007        */
    10491008        else
    10501009        {
     
    10521011        }
    10531012}
    1054 #endif
    10551013
    10561014static void cmd_transfer( irc_t *irc, char **cmd )
     
    11371095        { "transfer",       0, cmd_transfer,       0 },
    11381096        { "yes",            0, cmd_yesno,          0 },
    1139 #if 0
    11401097        { "chat",           1, cmd_chat,           0 },
    1141 #endif
    11421098        { NULL }
    11431099};
Note: See TracChangeset for help on using the changeset viewer.