Changeset aea8b68 for protocols/nogaim.c


Ignore:
Timestamp:
2010-05-06T00:28:56Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
f1a0890
Parents:
9438323
Message:

Starting to restore chatroom stuff. Only enough to create and be joined
into a room. More will follow soon.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/nogaim.c

    r9438323 raea8b68  
    536536        return bee_user_by_handle( ic->bee, ic, handle );
    537537}
    538 
    539 struct groupchat *imcb_chat_new( struct im_connection *ic, const char *handle )
    540 {
    541 #if 0
    542         struct groupchat *c;
    543        
    544         /* This one just creates the conversation structure, user won't see anything yet */
    545        
    546         if( ic->groupchats )
    547         {
    548                 for( c = ic->groupchats; c->next; c = c->next );
    549                 c = c->next = g_new0( struct groupchat, 1 );
    550         }
    551         else
    552                 ic->groupchats = c = g_new0( struct groupchat, 1 );
    553        
    554         c->ic = ic;
    555         c->title = g_strdup( handle );
    556         c->channel = g_strdup_printf( "&chat_%03d", ic->irc->c_id++ );
    557         c->topic = g_strdup_printf( "BitlBee groupchat: \"%s\". Please keep in mind that root-commands won't work here. Have fun!", c->title );
    558        
    559         if( set_getbool( &ic->bee->set, "debug" ) )
    560                 imcb_log( ic, "Creating new conversation: (id=%p,handle=%s)", c, handle );
    561        
    562         return c;
    563 #endif
    564         return NULL;
    565 }
    566 
    567 void imcb_chat_name_hint( struct groupchat *c, const char *name )
    568 {
    569 #if 0
    570         if( !c->joined )
    571         {
    572                 struct im_connection *ic = c->ic;
    573                 char stripped[MAX_NICK_LENGTH+1], *full_name;
    574                
    575                 strncpy( stripped, name, MAX_NICK_LENGTH );
    576                 stripped[MAX_NICK_LENGTH] = '\0';
    577                 nick_strip( stripped );
    578                 if( set_getbool( &ic->irc->set, "lcnicks" ) )
    579                         nick_lc( stripped );
    580                
    581                 full_name = g_strdup_printf( "&%s", stripped );
    582                
    583                 if( stripped[0] &&
    584                     nick_cmp( stripped, ic->irc->channel + 1 ) != 0 &&
    585                     irc_chat_by_channel( ic->irc, full_name ) == NULL )
    586                 {
    587                         g_free( c->channel );
    588                         c->channel = full_name;
    589                 }
    590                 else
    591                 {
    592                         g_free( full_name );
    593                 }
    594         }
    595 #endif
    596 }
    597 
    598 void imcb_chat_free( struct groupchat *c )
    599 {
    600 #if 0
    601         struct im_connection *ic = c->ic;
    602         struct groupchat *l;
    603         GList *ir;
    604        
    605         if( set_getbool( &ic->bee->set, "debug" ) )
    606                 imcb_log( ic, "You were removed from conversation %p", c );
    607        
    608         if( c )
    609         {
    610                 if( c->joined )
    611                 {
    612                         user_t *u, *r;
    613                        
    614                         r = user_find( ic->irc, ic->irc->mynick );
    615                         irc_privmsg( ic->irc, r, "PRIVMSG", c->channel, "", "Cleaning up channel, bye!" );
    616                        
    617                         u = user_find( ic->irc, ic->irc->nick );
    618                         irc_kick( ic->irc, u, c->channel, r );
    619                         /* irc_part( ic->irc, u, c->channel ); */
    620                 }
    621                
    622                 /* Find the previous chat in the linked list. */
    623                 for( l = ic->groupchats; l && l->next != c; l = l->next );
    624                
    625                 if( l )
    626                         l->next = c->next;
    627                 else
    628                         ic->groupchats = c->next;
    629                
    630                 for( ir = c->in_room; ir; ir = ir->next )
    631                         g_free( ir->data );
    632                 g_list_free( c->in_room );
    633                 g_free( c->channel );
    634                 g_free( c->title );
    635                 g_free( c->topic );
    636                 g_free( c );
    637         }
    638 #endif
    639 }
    640 
    641 void imcb_chat_msg( struct groupchat *c, const char *who, char *msg, uint32_t flags, time_t sent_at )
    642 {
    643 #if 0
    644         struct im_connection *ic = c->ic;
    645         char *wrapped;
    646         user_t *u;
    647        
    648         /* Gaim sends own messages through this too. IRC doesn't want this, so kill them */
    649         if( g_strcasecmp( who, ic->acc->user ) == 0 )
    650                 return;
    651        
    652         u = user_findhandle( ic, who );
    653        
    654         if( ( g_strcasecmp( set_getstr( &ic->bee->set, "strip_html" ), "always" ) == 0 ) ||
    655             ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->bee->set, "strip_html" ) ) )
    656                 strip_html( msg );
    657        
    658         wrapped = word_wrap( msg, 425 );
    659         if( c && u )
    660         {
    661                 char *ts = NULL;
    662                 if( set_getbool( &ic->irc->set, "display_timestamps" ) )
    663                         ts = format_timestamp( ic->irc, sent_at );
    664                 irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, ts ? : "", wrapped );
    665                 g_free( ts );
    666         }
    667         else
    668         {
    669                 imcb_log( ic, "Message from/to conversation %s@%p (unknown conv/user): %s", who, c, wrapped );
    670         }
    671         g_free( wrapped );
    672 #endif
    673 }
    674 
    675 void imcb_chat_log( struct groupchat *c, char *format, ... )
    676 {
    677 #if 0
    678         irc_t *irc = c->ic->irc;
    679         va_list params;
    680         char *text;
    681         user_t *u;
    682        
    683         va_start( params, format );
    684         text = g_strdup_vprintf( format, params );
    685         va_end( params );
    686        
    687         u = user_find( irc, irc->mynick );
    688        
    689         irc_privmsg( irc, u, "PRIVMSG", c->channel, "System message: ", text );
    690        
    691         g_free( text );
    692 #endif
    693 }
    694 
    695 void imcb_chat_topic( struct groupchat *c, char *who, char *topic, time_t set_at )
    696 {
    697 #if 0
    698         struct im_connection *ic = c->ic;
    699         user_t *u = NULL;
    700        
    701         if( who == NULL)
    702                 u = user_find( ic->irc, ic->irc->mynick );
    703         else if( g_strcasecmp( who, ic->acc->user ) == 0 )
    704                 u = user_find( ic->irc, ic->irc->nick );
    705         else
    706                 u = user_findhandle( ic, who );
    707        
    708         if( ( g_strcasecmp( set_getstr( &ic->bee->set, "strip_html" ), "always" ) == 0 ) ||
    709             ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->bee->set, "strip_html" ) ) )
    710                 strip_html( topic );
    711        
    712         g_free( c->topic );
    713         c->topic = g_strdup( topic );
    714        
    715         if( c->joined && u )
    716                 irc_write( ic->irc, ":%s!%s@%s TOPIC %s :%s", u->nick, u->user, u->host, c->channel, topic );
    717 #endif
    718 }
    719 
    720 void imcb_chat_add_buddy( struct groupchat *b, const char *handle )
    721 {
    722 #if 0
    723         user_t *u = user_findhandle( b->ic, handle );
    724         int me = 0;
    725        
    726         if( set_getbool( &b->ic->bee->set, "debug" ) )
    727                 imcb_log( b->ic, "User %s added to conversation %p", handle, b );
    728        
    729         /* It might be yourself! */
    730         if( b->ic->acc->prpl->handle_cmp( handle, b->ic->acc->user ) == 0 )
    731         {
    732                 u = user_find( b->ic->irc, b->ic->irc->nick );
    733                 if( !b->joined )
    734                         irc_join( b->ic->irc, u, b->channel );
    735                 b->joined = me = 1;
    736         }
    737        
    738         /* Most protocols allow people to join, even when they're not in
    739            your contact list. Try to handle that here */
    740         if( !u )
    741         {
    742                 imcb_add_buddy( b->ic, handle, NULL );
    743                 u = user_findhandle( b->ic, handle );
    744         }
    745        
    746         /* Add the handle to the room userlist, if it's not 'me' */
    747         if( !me )
    748         {
    749                 if( b->joined )
    750                         irc_join( b->ic->irc, u, b->channel );
    751                 b->in_room = g_list_append( b->in_room, g_strdup( handle ) );
    752         }
    753 #endif
    754 }
    755 
    756 /* This function is one BIG hack... :-( EREWRITE */
    757 void imcb_chat_remove_buddy( struct groupchat *b, const char *handle, const char *reason )
    758 {
    759 #if 0
    760         user_t *u;
    761         int me = 0;
    762        
    763         if( set_getbool( &b->ic->bee->set, "debug" ) )
    764                 imcb_log( b->ic, "User %s removed from conversation %p (%s)", handle, b, reason ? reason : "" );
    765        
    766         /* It might be yourself! */
    767         if( g_strcasecmp( handle, b->ic->acc->user ) == 0 )
    768         {
    769                 if( b->joined == 0 )
    770                         return;
    771                
    772                 u = user_find( b->ic->irc, b->ic->irc->nick );
    773                 b->joined = 0;
    774                 me = 1;
    775         }
    776         else
    777         {
    778                 u = user_findhandle( b->ic, handle );
    779         }
    780        
    781         if( me || ( remove_chat_buddy_silent( b, handle ) && b->joined && u ) )
    782                 irc_part( b->ic->irc, u, b->channel );
    783 #endif
    784 }
    785 
    786 #if 0
    787 static int remove_chat_buddy_silent( struct groupchat *b, const char *handle )
    788 {
    789         GList *i;
    790        
    791         /* Find the handle in the room userlist and shoot it */
    792         i = b->in_room;
    793         while( i )
    794         {
    795                 if( g_strcasecmp( handle, i->data ) == 0 )
    796                 {
    797                         g_free( i->data );
    798                         b->in_room = g_list_remove( b->in_room, i->data );
    799                         return( 1 );
    800                 }
    801                
    802                 i = i->next;
    803         }
    804        
    805         return 0;
    806 }
    807 #endif
    808538
    809539
Note: See TracChangeset for help on using the changeset viewer.