Changeset 83e92bf


Ignore:
Timestamp:
2010-03-27T12:30:00Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
9b69eb7
Parents:
b95932e
Message:

Topic handling changes.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • irc.c

    rb95932e r83e92bf  
    620620                       
    621621                        ic = irc_channel_new( irc, ROOT_CHAN );
    622                         irc_channel_set_topic( ic, CONTROL_TOPIC );
     622                        irc_channel_set_topic( ic, CONTROL_TOPIC, irc->root );
    623623                        irc_channel_add_user( ic, irc->user );
    624624                       
  • irc.h

    rb95932e r83e92bf  
    118118        char *name;
    119119        char *topic;
     120        char *topic_who;
     121        time_t topic_time;
    120122        char mode[8];
    121123        GSList *users;
     
    145147irc_channel_t *irc_channel_new( irc_t *irc, const char *name );
    146148irc_channel_t *irc_channel_by_name( irc_t *irc, const char *name );
     149int irc_channel_free( irc_channel_t *ic );
    147150int irc_channel_add_user( irc_channel_t *ic, irc_user_t *iu );
    148151int irc_channel_del_user( irc_channel_t *ic, irc_user_t *iu );
    149 int irc_channel_set_topic( irc_channel_t *ic, const char *topic );
     152int irc_channel_set_topic( irc_channel_t *ic, const char *topic, const irc_user_t *who );
    150153
    151154/* irc_commands.c */
     
    160163void irc_send_part( irc_channel_t *ic, irc_user_t *iu, const char *reason );
    161164void irc_send_names( irc_channel_t *ic );
    162 void irc_send_topic( irc_channel_t *ic );
     165void irc_send_topic( irc_channel_t *ic, gboolean topic_change );
    163166void irc_send_whois( irc_user_t *iu );
    164167
  • irc_channel.c

    rb95932e r83e92bf  
    109109}
    110110
    111 int irc_channel_set_topic( irc_channel_t *ic, const char *topic )
     111int irc_channel_set_topic( irc_channel_t *ic, const char *topic, const irc_user_t *iu )
    112112{
    113113        g_free( ic->topic );
    114114        ic->topic = g_strdup( topic );
    115115       
     116        g_free( ic->topic_who );
     117        if( iu )
     118                ic->topic_who = g_strdup_printf( "%s!%s@%s", iu->nick, iu->user, iu->host );
     119        else
     120                ic->topic_who = NULL;
     121       
     122        ic->topic_time = time( NULL );
     123       
    116124        if( ic->flags & IRC_CHANNEL_JOINED )
    117                 irc_send_topic( ic );
     125                irc_send_topic( ic, TRUE );
    118126       
    119127        return 1;
  • irc_send.c

    rb95932e r83e92bf  
    135135                irc_write( irc, ":%s MODE %s +%s", irc->root->host, ic->name, ic->mode );
    136136                irc_send_names( ic );
    137                 irc_send_topic( ic );
     137                irc_send_topic( ic, FALSE );
    138138        }
    139139}
     
    182182}
    183183
    184 void irc_send_topic( irc_channel_t *ic )
    185 {
    186         if( ic->topic )
     184void irc_send_topic( irc_channel_t *ic, gboolean topic_change )
     185{
     186        if( topic_change && ic->topic_who )
     187        {
     188                irc_write( ic->irc, ":%s TOPIC %s :%s", ic->topic_who,
     189                           ic->name, ic->topic && *ic->topic ? ic->topic : "" );
     190        }
     191        else if( ic->topic )
     192        {
    187193                irc_send_num( ic->irc, 332, "%s :%s", ic->name, ic->topic );
     194                if( ic->topic_who )
     195                        irc_send_num( ic->irc, 333, "%s %s %d",
     196                                      ic->name, ic->topic_who, (int) ic->topic_time );
     197        }
    188198        else
    189199                irc_send_num( ic->irc, 331, "%s :No topic for this channel", ic->name );
Note: See TracChangeset for help on using the changeset viewer.