Changeset efbc154


Ignore:
Timestamp:
2010-04-16T09:58:22Z (15 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
0f84234
Parents:
b6190ca (diff), bb839e8 (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:

Merge msn-keepalive, a nice hack (not yet documented) which sends keepalives
to switchboards with offline contacts. This is meant as a work-around for
the current lack of support for offline messaging.

Location:
protocols/msn
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/msn.c

    rb6190ca refbc154  
    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

    rb6190ca refbc154  
    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;
     
    180186gboolean msn_sb_connected( gpointer data, gint source, b_input_condition cond );
    181187int msn_sb_write_msg( struct im_connection *ic, struct msn_message *m );
     188void msn_sb_start_keepalives( struct msn_switchboard *sb, gboolean initial );
     189void msn_sb_stop_keepalives( struct msn_switchboard *sb );
    182190
    183191#endif //_MSN_H
  • protocols/msn/ns.c

    rb6190ca refbc154  
    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

    rb6190ca refbc154  
    168168               
    169169                /* Build the message. Convert LF to CR-LF for normal messages. */
    170                 if( strcmp( text, TYPING_NOTIFICATION_MESSAGE ) != 0 )
     170                if( strcmp( text, TYPING_NOTIFICATION_MESSAGE ) == 0 )
     171                {
     172                        i = strlen( MSN_TYPING_HEADERS ) + strlen( sb->ic->acc->user );
     173                        buf = g_new0( char, i );
     174                        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
    171182                {
    172183                        buf = g_new0( char, sizeof( MSN_MESSAGE_HEADERS ) + strlen( text ) * 2 + 1 );
     
    182193                        }
    183194                }
    184                 else
    185                 {
    186                         i = strlen( MSN_TYPING_HEADERS ) + strlen( sb->ic->acc->user );
    187                         buf = g_new0( char, i );
    188                         i = g_snprintf( buf, i, MSN_TYPING_HEADERS, sb->ic->acc->user );
    189                 }
    190195               
    191196                /* Build the final packet (MSG command + the message). */
     
    250255       
    251256        msn_msgq_purge( ic, &sb->msgq );
     257        msn_sb_stop_keepalives( sb );
    252258       
    253259        if( sb->key ) g_free( sb->key );
     
    471477               
    472478                sb->ready = 1;
     479               
     480                msn_sb_start_keepalives( sb, FALSE );
    473481        }
    474482        else if( strcmp( cmd[0], "CAL" ) == 0 )
     
    520528                        }
    521529                       
     530                        msn_sb_start_keepalives( sb, FALSE );
     531                       
    522532                        return( st );
    523533                }
     
    581591                if( sb->who )
    582592                {
     593                        msn_sb_stop_keepalives( sb );
     594                       
    583595                        /* This is a single-person chat, and the other person is leaving. */
    584596                        g_free( sb->who );
     
    764776        return( 1 );
    765777}
     778
     779static gboolean msn_sb_keepalive( gpointer data, gint source, b_input_condition cond )
     780{
     781        struct msn_switchboard *sb = data;
     782        return sb->ready && msn_sb_sendmessage( sb, SB_KEEPALIVE_MESSAGE );
     783}
     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.