Changeset 27e2c66


Ignore:
Timestamp:
2010-05-08T00:25:15Z (9 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
b17ce85
Parents:
f1a0890
Message:

Support for receiving messages in chatrooms.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • irc_im.c

    rf1a0890 r27e2c66  
    245245}
    246246
    247 gboolean bee_irc_chat_log( bee_t *bee, struct groupchat *c, const char *format, ... )
    248 {
    249 }
    250 
    251 gboolean bee_irc_chat_msg( bee_t *bee, struct groupchat *c, const char *who, const char *msg, time_t sent_at )
    252 {
     247gboolean bee_irc_chat_log( bee_t *bee, struct groupchat *c, const char *text )
     248{
     249        irc_channel_t *ic = c->ui_data;
     250       
     251        irc_channel_printf( ic, "%s", text );
     252}
     253
     254gboolean bee_irc_chat_msg( bee_t *bee, struct groupchat *c, bee_user_t *bu, const char *msg, time_t sent_at )
     255{
     256        irc_t *irc = bee->ui_data;
     257        irc_user_t *iu = bu->ui_data;
     258        irc_channel_t *ic = c->ui_data;
     259        char *ts = NULL;
     260       
     261        if( sent_at > 0 && set_getbool( &bee->set, "display_timestamps" ) )
     262                ts = irc_format_timestamp( irc, sent_at );
     263       
     264        irc_send_msg( iu, "PRIVMSG", ic->name, msg, ts );
     265        g_free( ts );
     266       
     267        return TRUE;
    253268}
    254269
     
    301316        bee_irc_chat_new,
    302317        bee_irc_chat_free,
    303         NULL,
    304         NULL,
     318        bee_irc_chat_log,
     319        bee_irc_chat_msg,
    305320        bee_irc_chat_add_user,
    306321        NULL,
  • protocols/bee.h

    rf1a0890 r27e2c66  
    8181        gboolean (*chat_new)( bee_t *bee, struct groupchat *c );
    8282        gboolean (*chat_free)( bee_t *bee, struct groupchat *c );
    83         gboolean (*chat_log)( bee_t *bee, struct groupchat *c, const char *format, ... );
    84         gboolean (*chat_msg)( bee_t *bee, struct groupchat *c, const char *who, const char *msg, time_t sent_at );
     83        gboolean (*chat_log)( bee_t *bee, struct groupchat *c, const char *text );
     84        gboolean (*chat_msg)( bee_t *bee, struct groupchat *c, bee_user_t *bu, const char *msg, time_t sent_at );
    8585        gboolean (*chat_add_user)( bee_t *bee, struct groupchat *c, bee_user_t *bu );
    8686        gboolean (*chat_remove_user)( bee_t *bee, struct groupchat *c, bee_user_t *bu );
  • protocols/bee_chat.c

    rf1a0890 r27e2c66  
    105105void imcb_chat_msg( struct groupchat *c, const char *who, char *msg, uint32_t flags, time_t sent_at )
    106106{
    107 #if 0
    108         struct im_connection *ic = c->ic;
    109         char *wrapped;
    110         user_t *u;
     107        struct im_connection *ic = c->ic;
     108        bee_t *bee = ic->bee;
     109        bee_user_t *bu;
     110        char *s;
    111111       
    112112        /* Gaim sends own messages through this too. IRC doesn't want this, so kill them */
     
    114114                return;
    115115       
    116         u = user_findhandle( ic, who );
    117        
    118         if( ( g_strcasecmp( set_getstr( &ic->bee->set, "strip_html" ), "always" ) == 0 ) ||
    119             ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->bee->set, "strip_html" ) ) )
     116        bu = bee_user_by_handle( bee, ic, who );
     117       
     118        s = set_getstr( &ic->bee->set, "strip_html" );
     119        if( ( g_strcasecmp( s, "always" ) == 0 ) ||
     120            ( ( ic->flags & OPT_DOES_HTML ) && s ) )
    120121                strip_html( msg );
    121122       
    122         wrapped = word_wrap( msg, 425 );
    123         if( c && u )
    124         {
    125                 char *ts = NULL;
    126                 if( set_getbool( &ic->irc->set, "display_timestamps" ) )
    127                         ts = format_timestamp( ic->irc, sent_at );
    128                 irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, ts ? : "", wrapped );
    129                 g_free( ts );
    130         }
     123        if( bu && bee->ui->chat_msg )
     124                bee->ui->chat_msg( bee, c, bu, msg, sent_at );
    131125        else
    132         {
    133                 imcb_log( ic, "Message from/to conversation %s@%p (unknown conv/user): %s", who, c, wrapped );
    134         }
    135         g_free( wrapped );
    136 #endif
     126                imcb_chat_log( c, "Message from unknown participant %s: %s", who, msg );
    137127}
    138128
    139129void imcb_chat_log( struct groupchat *c, char *format, ... )
    140130{
    141 #if 0
    142         irc_t *irc = c->ic->irc;
     131        struct im_connection *ic = c->ic;
     132        bee_t *bee = ic->bee;
    143133        va_list params;
    144134        char *text;
    145         user_t *u;
     135       
     136        if( !bee->ui->chat_log )
     137                return;
    146138       
    147139        va_start( params, format );
     
    149141        va_end( params );
    150142       
    151         u = user_find( irc, irc->mynick );
    152        
    153         irc_privmsg( irc, u, "PRIVMSG", c->channel, "System message: ", text );
    154        
     143        bee->ui->chat_log( bee, c, text );
    155144        g_free( text );
    156 #endif
    157145}
    158146
Note: See TracChangeset for help on using the changeset viewer.