Changeset 839189b for protocols


Ignore:
Timestamp:
2010-05-02T21:06:25Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
3b878a1
Parents:
4273158
Message:

Applied show-offline patch from Florian E.J. Fruth, adapted for a few
changes that happened since 1.2.4.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/nogaim.c

    r4273158 r839189b  
    657657        u->away = u->status_msg = NULL;
    658658       
    659         if( ( flags & OPT_LOGGED_IN ) && !u->online )
    660         {
     659        if( set_getbool( &ic->irc->set, "show_offline" ) && !u->online )
     660        {
     661                /* always set users as online */
    661662                irc_spawn( ic->irc, u );
    662663                u->online = 1;
     664                if( !( flags & OPT_LOGGED_IN ) )
     665                {
     666                        /* set away message if user isn't really online */
     667                        u->away = g_strdup( "User is offline" );
     668                }
     669        }
     670        else if( ( flags & OPT_LOGGED_IN ) && !u->online )
     671        {
     672                irc_spawn( ic->irc, u );
     673                u->online = 1;
    663674        }
    664675        else if( !( flags & OPT_LOGGED_IN ) && u->online )
     
    666677                struct groupchat *c;
    667678               
    668                 irc_kill( ic->irc, u );
    669                 u->online = 0;
    670                
    671                 /* Remove him/her from the groupchats to prevent PART messages after he/she QUIT already */
    672                 for( c = ic->groupchats; c; c = c->next )
    673                         remove_chat_buddy_silent( c, handle );
    674         }
    675        
     679                if( set_getbool( &ic->irc->set, "show_offline" ) )
     680                {
     681                        /* keep offline users in channel and set away message to "offline" */
     682                        u->away = g_strdup( "User is offline" );
     683
     684                        /* Keep showing him/her in the control channel but not in groupchats. */
     685                        for( c = ic->groupchats; c; c = c->next )
     686                        {
     687                                if( remove_chat_buddy_silent( c, handle ) && c->joined )
     688                                        irc_part( c->ic->irc, u, c->channel );
     689                        }
     690                }
     691                else
     692                {
     693                        /* kill offline users */
     694                        irc_kill( ic->irc, u );
     695                        u->online = 0;
     696
     697                        /* Remove him/her from the groupchats to prevent PART messages after he/she QUIT already */
     698                        for( c = ic->groupchats; c; c = c->next )
     699                                remove_chat_buddy_silent( c, handle );
     700                }
     701        }
     702
    676703        if( flags & OPT_AWAY )
    677704        {
     
    698725        }
    699726       
    700         /* LISPy... */
    701         if( ( set_getbool( &ic->irc->set, "away_devoice" ) ) &&         /* Don't do a thing when user doesn't want it */
    702             ( u->online ) &&                                            /* Don't touch offline people */
    703             ( ( ( u->online != oo ) && !u->away ) ||                    /* Voice joining people */
    704               ( ( u->online == oo ) && ( oa == !u->away ) ) ) )         /* (De)voice people changing state */
     727        /* early if-clause for show_offline even if there is some redundant code here because this isn't LISP but C ;) */
     728        if( set_getbool( &ic->irc->set, "show_offline" ) && set_getbool( &ic->irc->set, "away_devoice" ) )
    705729        {
    706730                char *from;
     
    715739                                                            ic->irc->myhost );
    716740                }
    717                 irc_write( ic->irc, ":%s MODE %s %cv %s", from, ic->irc->channel,
    718                                                           u->away?'-':'+', u->nick );
    719                 g_free( from );
     741
     742                /* if we use show_offline, we op online users, voice away users, and devoice/deop offline users */
     743                if( flags & OPT_LOGGED_IN )
     744                {
     745                        /* user is "online" (either really online or away) */
     746                        irc_write( ic->irc, ":%s MODE %s %cv%co %s %s", from, ic->irc->channel,
     747                                                                  u->away?'+':'-', u->away?'-':'+', u->nick, u->nick );
     748                }
     749                else
     750                {
     751                        /* user is offline */
     752                        irc_write( ic->irc, ":%s MODE %s -vo %s %s", from, ic->irc->channel, u->nick, u->nick );
     753                }
     754        }
     755        else
     756        {
     757                /* LISPy... */
     758                if( ( set_getbool( &ic->irc->set, "away_devoice" ) ) &&         /* Don't do a thing when user doesn't want it */
     759                    ( u->online ) &&                                            /* Don't touch offline people */
     760                    ( ( ( u->online != oo ) && !u->away ) ||                    /* Voice joining people */
     761                      ( ( u->online == oo ) && ( oa == !u->away ) ) ) )         /* (De)voice people changing state */
     762                {
     763                        char *from;
     764
     765                        if( set_getbool( &ic->irc->set, "simulate_netsplit" ) )
     766                        {
     767                                from = g_strdup( ic->irc->myhost );
     768                        }
     769                        else
     770                        {
     771                                from = g_strdup_printf( "%s!%s@%s", ic->irc->mynick, ic->irc->mynick,
     772                                                                    ic->irc->myhost );
     773                        }
     774                        irc_write( ic->irc, ":%s MODE %s %cv %s", from, ic->irc->channel,
     775                                                                  u->away?'-':'+', u->nick );
     776                        g_free( from );
     777                }
    720778        }
    721779}
Note: See TracChangeset for help on using the changeset viewer.