Changeset 9bf2481


Ignore:
Timestamp:
2010-04-09T23:16:38Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
bb839e8
Parents:
c4bc92a
Message:

First stab at MSN keepalives.

Only kicks in if the user goes offline during a conversation.

Location:
protocols/msn
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/msn.c

    rc4bc92a r9bf2481  
    4141
    4242        s = set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc );
     43       
     44        s = set_add( &acc->set, "switchboard_keepalives", "false", set_eval_bool, acc );
    4345}
    4446
  • protocols/msn/msn.h

    rc4bc92a r9bf2481  
    3131#define TYPING_NOTIFICATION_MESSAGE "\r\r\rBEWARE, ME R TYPINK MESSAGE!!!!\r\r\r"
    3232#define GROUPCHAT_SWITCHBOARD_MESSAGE "\r\r\rME WANT TALK TO MANY PEOPLE\r\r\r"
     33#define SB_KEEPALIVE_MESSAGE "\r\r\rDONT HANG UP ON ME!\r\r\r"
    3334
    3435#ifdef DEBUG_MSN
     
    5354                           "TypingUser: %s\r\n" \
    5455                           "\r\n\r\n"
     56
     57#define SB_KEEPALIVE_HEADERS "MIME-Version: 1.0\r\n" \
     58                             "Content-Type: text/x-ping\r\n" \
     59                             "\r\n\r\n"
    5560
    5661#define PROFILE_URL "http://members.msn.com/"
     
    8388        gint inp;
    8489        struct msn_handler_data *handler;
     90        gint keepalive;
    8591       
    8692        int trId;
     
    179185gboolean msn_sb_connected( gpointer data, gint source, b_input_condition cond );
    180186int msn_sb_write_msg( struct im_connection *ic, struct msn_message *m );
     187gboolean msn_sb_keepalive( gpointer data, gint source, b_input_condition cond );
    181188
    182189#endif //_MSN_H
  • protocols/msn/ns.c

    rc4bc92a r9bf2481  
    436436        else if( strcmp( cmd[0], "FLN" ) == 0 )
    437437        {
    438                 if( cmd[1] )
    439                         imcb_buddy_status( ic, cmd[1], 0, NULL, NULL );
     438                struct msn_switchboard *sb;
     439               
     440                if( cmd[1] == NULL )
     441                        return 1;
     442               
     443                imcb_buddy_status( ic, cmd[1], 0, NULL, NULL );
     444               
     445                if( ( sb = msn_sb_by_handle( ic, cmd[1] ) ) &&
     446                    set_getbool( &ic->acc->set, "switchboard_keepalives" ) &&
     447                    sb->keepalive == 0 )
     448                {
     449                        msn_sb_keepalive( sb, 0, 0 );
     450                        sb->keepalive = b_timeout_add( 20000, msn_sb_keepalive, sb );
     451                }
    440452        }
    441453        else if( strcmp( cmd[0], "NLN" ) == 0 )
    442454        {
    443455                const struct msn_away_state *st;
     456                struct msn_switchboard *sb;
    444457               
    445458                if( num_parts != 5 )
     
    463476                                   ( st != msn_away_state_list ? OPT_AWAY : 0 ),
    464477                                   st->name, NULL );
     478               
     479                if( ( sb = msn_sb_by_handle( ic, cmd[1] ) ) && sb->keepalive > 0 )
     480                {
     481                        b_event_remove( sb->keepalive );
     482                        sb->keepalive = 0;
     483                }
    465484        }
    466485        else if( strcmp( cmd[0], "RNG" ) == 0 )
  • protocols/msn/sb.c

    rc4bc92a r9bf2481  
    168168               
    169169                /* Build the message. Convert LF to CR-LF for normal messages. */
    170                 if( strcmp( text, TYPING_NOTIFICATION_MESSAGE ) != 0 )
    171                 {
    172                         buf = g_new0( char, sizeof( MSN_MESSAGE_HEADERS ) + strlen( text ) * 2 + 1 );
    173                         i = strlen( MSN_MESSAGE_HEADERS );
    174                        
    175                         strcpy( buf, MSN_MESSAGE_HEADERS );
    176                         for( j = 0; text[j]; j ++ )
    177                         {
    178                                 if( text[j] == '\n' )
    179                                         buf[i++] = '\r';
    180                                
    181                                 buf[i++] = text[j];
    182                         }
    183                 }
    184                 else
     170                if( strcmp( text, TYPING_NOTIFICATION_MESSAGE ) == 0 )
    185171                {
    186172                        i = strlen( MSN_TYPING_HEADERS ) + strlen( sb->ic->acc->user );
    187173                        buf = g_new0( char, i );
    188174                        i = g_snprintf( buf, i, MSN_TYPING_HEADERS, sb->ic->acc->user );
     175                }
     176                else if( strcmp( text, SB_KEEPALIVE_MESSAGE ) == 0 )
     177                {
     178                        buf = g_strdup( SB_KEEPALIVE_HEADERS );
     179                        i = strlen( buf );
     180                }
     181                else
     182                {
     183                        buf = g_new0( char, sizeof( MSN_MESSAGE_HEADERS ) + strlen( text ) * 2 + 1 );
     184                        i = strlen( MSN_MESSAGE_HEADERS );
     185                       
     186                        strcpy( buf, MSN_MESSAGE_HEADERS );
     187                        for( j = 0; text[j]; j ++ )
     188                        {
     189                                if( text[j] == '\n' )
     190                                        buf[i++] = '\r';
     191                               
     192                                buf[i++] = text[j];
     193                        }
    189194                }
    190195               
     
    764769        return( 1 );
    765770}
     771
     772gboolean msn_sb_keepalive( gpointer data, gint source, b_input_condition cond )
     773{
     774        struct msn_switchboard *sb = data;
     775        return sb->ready && msn_sb_sendmessage( sb, SB_KEEPALIVE_MESSAGE );
     776}
Note: See TracChangeset for help on using the changeset viewer.