Changeset f924563 for protocols/msn


Ignore:
Timestamp:
2010-05-03T00:52:08Z (15 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
1a3ba05
Parents:
6a9d068 (diff), 6824fb3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Mainline merge.

Location:
protocols/msn
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/msn.c

    r6a9d068 rf924563  
    3838        set_add( &acc->set, "local_display_name", "false", set_eval_bool, acc );
    3939        set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc );
     40        set_add( &acc->set, "switchboard_keepalives", "false", set_eval_bool, acc );
    4041}
    4142
  • protocols/msn/msn.h

    r6a9d068 rf924563  
    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/"
     
    8489        gint inp;
    8590        struct msn_handler_data *handler;
     91        gint keepalive;
    8692       
    8793        int trId;
     
    181187gboolean msn_sb_connected( gpointer data, gint source, b_input_condition cond );
    182188int msn_sb_write_msg( struct im_connection *ic, struct msn_message *m );
     189void msn_sb_start_keepalives( struct msn_switchboard *sb, gboolean initial );
     190void msn_sb_stop_keepalives( struct msn_switchboard *sb );
    183191
    184192/* invitation.c */
  • protocols/msn/ns.c

    r6a9d068 rf924563  
    422422        else if( strcmp( cmd[0], "FLN" ) == 0 )
    423423        {
    424                 if( cmd[1] )
    425                         imcb_buddy_status( ic, cmd[1], 0, NULL, NULL );
     424                if( cmd[1] == NULL )
     425                        return 1;
     426               
     427                imcb_buddy_status( ic, cmd[1], 0, NULL, NULL );
     428               
     429                msn_sb_start_keepalives( msn_sb_by_handle( ic, cmd[1] ), TRUE );
    426430        }
    427431        else if( strcmp( cmd[0], "NLN" ) == 0 )
     
    449453                                   ( st != msn_away_state_list ? OPT_AWAY : 0 ),
    450454                                   st->name, NULL );
     455               
     456                msn_sb_stop_keepalives( msn_sb_by_handle( ic, cmd[2] ) );
    451457        }
    452458        else if( strcmp( cmd[0], "RNG" ) == 0 )
  • protocols/msn/sb.c

    r6a9d068 rf924563  
    175175                        i = g_snprintf( buf, i, MSN_TYPING_HEADERS, sb->ic->acc->user );
    176176                }
     177                else if( strcmp( text, SB_KEEPALIVE_MESSAGE ) == 0 )
     178                {
     179                        buf = g_strdup( SB_KEEPALIVE_HEADERS );
     180                        i = strlen( buf );
     181                }
    177182                else if( strncmp( text, MSN_INVITE_HEADERS, sizeof( MSN_INVITE_HEADERS ) - 1 ) == 0 )
    178183                {
     
    256261       
    257262        msn_msgq_purge( ic, &sb->msgq );
     263        msn_sb_stop_keepalives( sb );
    258264       
    259265        if( sb->key ) g_free( sb->key );
     
    477483               
    478484                sb->ready = 1;
     485               
     486                msn_sb_start_keepalives( sb, FALSE );
    479487        }
    480488        else if( strcmp( cmd[0], "CAL" ) == 0 )
     
    526534                        }
    527535                       
     536                        msn_sb_start_keepalives( sb, FALSE );
     537                       
    528538                        return( st );
    529539                }
     
    587597                if( sb->who )
    588598                {
     599                        msn_sb_stop_keepalives( sb );
     600                       
    589601                        /* This is a single-person chat, and the other person is leaving. */
    590602                        g_free( sb->who );
     
    752764        return( 1 );
    753765}
     766
     767static gboolean msn_sb_keepalive( gpointer data, gint source, b_input_condition cond )
     768{
     769        struct msn_switchboard *sb = data;
     770        return sb->ready && msn_sb_sendmessage( sb, SB_KEEPALIVE_MESSAGE );
     771}
     772
     773void msn_sb_start_keepalives( struct msn_switchboard *sb, gboolean initial )
     774{
     775        bee_user_t *bu;
     776       
     777        if( sb && sb->who && sb->keepalive == 0 &&
     778            ( bu = bee_user_by_handle( sb->ic->bee, sb->ic, sb->who ) ) &&
     779            !( bu->flags & BEE_USER_ONLINE ) &&
     780            set_getbool( &sb->ic->acc->set, "switchboard_keepalives" ) )
     781        {
     782                if( initial )
     783                        msn_sb_keepalive( sb, 0, 0 );
     784               
     785                sb->keepalive = b_timeout_add( 20000, msn_sb_keepalive, sb );
     786        }
     787}
     788
     789void msn_sb_stop_keepalives( struct msn_switchboard *sb )
     790{
     791        if( sb && sb->keepalive > 0 )
     792        {
     793                b_event_remove( sb->keepalive );
     794                sb->keepalive = 0;
     795        }
     796}
Note: See TracChangeset for help on using the changeset viewer.