Changeset bb839e8 for protocols/msn/sb.c


Ignore:
Timestamp:
2010-04-10T01:05:39Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
efbc154
Parents:
9bf2481
Message:

Be more clever with keepalives; detect when a switchboard is opened with
someone who's offline already. Still a hack but it eases the pain a little
bit.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/sb.c

    r9bf2481 rbb839e8  
    255255       
    256256        msn_msgq_purge( ic, &sb->msgq );
     257        msn_sb_stop_keepalives( sb );
    257258       
    258259        if( sb->key ) g_free( sb->key );
     
    476477               
    477478                sb->ready = 1;
     479               
     480                msn_sb_start_keepalives( sb, FALSE );
    478481        }
    479482        else if( strcmp( cmd[0], "CAL" ) == 0 )
     
    525528                        }
    526529                       
     530                        msn_sb_start_keepalives( sb, FALSE );
     531                       
    527532                        return( st );
    528533                }
     
    586591                if( sb->who )
    587592                {
     593                        msn_sb_stop_keepalives( sb );
     594                       
    588595                        /* This is a single-person chat, and the other person is leaving. */
    589596                        g_free( sb->who );
     
    770777}
    771778
    772 gboolean msn_sb_keepalive( gpointer data, gint source, b_input_condition cond )
     779static gboolean msn_sb_keepalive( gpointer data, gint source, b_input_condition cond )
    773780{
    774781        struct msn_switchboard *sb = data;
    775782        return sb->ready && msn_sb_sendmessage( sb, SB_KEEPALIVE_MESSAGE );
    776783}
     784
     785void msn_sb_start_keepalives( struct msn_switchboard *sb, gboolean initial )
     786{
     787        struct buddy *b;
     788       
     789        if( sb && sb->who && sb->keepalive == 0 &&
     790            ( b = imcb_find_buddy( sb->ic, sb->who ) ) && !b->present &&
     791            set_getbool( &sb->ic->acc->set, "switchboard_keepalives" ) )
     792        {
     793                if( initial )
     794                        msn_sb_keepalive( sb, 0, 0 );
     795               
     796                sb->keepalive = b_timeout_add( 20000, msn_sb_keepalive, sb );
     797        }
     798}
     799
     800void msn_sb_stop_keepalives( struct msn_switchboard *sb )
     801{
     802        if( sb && sb->keepalive > 0 )
     803        {
     804                b_event_remove( sb->keepalive );
     805                sb->keepalive = 0;
     806        }
     807}
Note: See TracChangeset for help on using the changeset viewer.