Changeset e67e513 for irc_send.c


Ignore:
Timestamp:
2011-10-03T14:56:58Z (13 years ago)
Author:
unknown <pesco@…>
Branches:
master
Children:
409c2de
Parents:
3231485
Message:

rename irc_usermsg to irc_rootmsg.
add new irc_usermsg, irc_usernotice.
deliver user-specific messages from libotr as notices to that user.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • irc_send.c

    r3231485 re67e513  
    110110}
    111111
    112 void irc_usermsg( irc_t *irc, char *format, ... )
    113 {
     112const char *irc_user_msgdest( irc_user_t *iu )
     113{
     114        irc_t *irc = iu->irc;
    114115        irc_channel_t *ic = NULL;
    115         irc_user_t *iu = irc->root;
    116         char text[2048];
    117         va_list params;
    118         char *dst;
    119        
    120         va_start( params, format );
    121         g_vsnprintf( text, sizeof( text ), format, params );
    122         va_end( params );
    123        
    124         /* Too similar to bee_irc_user_msg()... */
     116
    125117        if( iu->last_channel )
    126118        {
     
    128120                        ic = iu->last_channel;
    129121                else
    130                         ic = irc_channel_with_user( irc, irc->root );
     122                        ic = irc_channel_with_user( irc, iu );
    131123        }
    132124       
    133125        if( ic )
    134                 dst = ic->name;
     126                return ic->name;
    135127        else
    136                 dst = irc->user->nick;
    137        
    138         irc_send_msg( irc->root, "PRIVMSG", dst, text, NULL );
     128                return irc->user->nick;
     129}
     130
     131/* cmd = "PRIVMSG" or "NOTICE" */
     132static void irc_usermsg_( const char *cmd, irc_user_t *iu, const char *format, va_list params )
     133{
     134        char text[2048];
     135        const char *dst;
     136       
     137        g_vsnprintf( text, sizeof( text ), format, params );
     138       
     139        dst = irc_user_msgdest( iu );
     140        irc_send_msg( iu, cmd, dst, text, NULL );
     141}
     142
     143void irc_usermsg(irc_user_t *iu, char *format, ... )
     144{
     145        va_list params;
     146        va_start( params, format );
     147        irc_usermsg_( "PRIVMSG", iu, format, params );
     148        va_end( params );
     149}
     150
     151void irc_usernotice(irc_user_t *iu, char *format, ... )
     152{
     153        va_list params;
     154        va_start( params, format );
     155        irc_usermsg_( "NOTICE", iu, format, params );
     156        va_end( params );
     157}
     158
     159void irc_rootmsg( irc_t *irc, char *format, ... )
     160{
     161        va_list params;
     162        va_start( params, format );
     163        irc_usermsg_( "PRIVMSG", irc->root, format, params );
     164        va_end( params );
    139165}
    140166
Note: See TracChangeset for help on using the changeset viewer.