Ignore:
Timestamp:
2006-12-05T20:40:17Z (17 years ago)
Author:
Jelmer Vernooij <jelmer@…>
Branches:
master
Children:
7740c4c
Parents:
f4aa393 (diff), 55078f5 (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] wilmer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/msn.c

    rf4aa393 rd8d63a2  
    2727#include "msn.h"
    2828
    29 static void msn_login( struct aim_user *acct )
    30 {
    31         struct gaim_connection *gc = new_gaim_conn( acct );
     29static char *msn_set_display_name( set_t *set, char *value );
     30
     31static void msn_acc_init( account_t *acc )
     32{
     33        set_t *s;
     34       
     35        s = set_add( &acc->set, "display_name", NULL, msn_set_display_name, acc );
     36        s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY;
     37}
     38
     39static void msn_login( account_t *acc )
     40{
     41        struct gaim_connection *gc = new_gaim_conn( acc );
    3242        struct msn_data *md = g_new0( struct msn_data, 1 );
    33        
    34         set_login_progress( gc, 1, "Connecting" );
    3543       
    3644        gc->proto_data = md;
    3745        md->fd = -1;
    3846       
    39         if( strchr( acct->username, '@' ) == NULL )
     47        if( strchr( acc->user, '@' ) == NULL )
    4048        {
    4149                hide_login_progress( gc, "Invalid account name" );
     
    4452        }
    4553       
     54        set_login_progress( gc, 1, "Connecting" );
     55       
    4656        md->fd = proxy_connect( "messenger.hotmail.com", 1863, msn_ns_connected, gc );
    4757        if( md->fd < 0 )
     
    4959                hide_login_progress( gc, "Could not connect to server" );
    5060                signoff( gc );
    51         }
    52         else
    53         {
    54                 md->gc = gc;
    55                 md->away_state = msn_away_state_list;
    56                
    57                 msn_connections = g_slist_append( msn_connections, gc );
    58         }
     61                return;
     62        }
     63       
     64        md->gc = gc;
     65        md->away_state = msn_away_state_list;
     66       
     67        msn_connections = g_slist_append( msn_connections, gc );
    5968}
    6069
     
    212221static void msn_set_info( struct gaim_connection *gc, char *info )
    213222{
    214         int i;
    215         char buf[1024], *fn, *s;
    216         struct msn_data *md = gc->proto_data;
    217        
    218         if( strlen( info ) > 129 )
    219         {
    220                 do_error_dialog( gc, "Maximum name length exceeded", "MSN" );
    221                 return;
    222         }
    223        
    224         /* Of course we could use http_encode() here, but when we encode
    225            every character, the server is less likely to complain about the
    226            chosen name. However, the MSN server doesn't seem to like escaped
    227            non-ASCII chars, so we keep those unescaped. */
    228         s = fn = g_new0( char, strlen( info ) * 3 + 1 );
    229         for( i = 0; info[i]; i ++ )
    230                 if( info[i] & 128 )
    231                 {
    232                         *s = info[i];
    233                         s ++;
    234                 }
    235                 else
    236                 {
    237                         g_snprintf( s, 4, "%%%02X", info[i] );
    238                         s += 3;
    239                 }
    240        
    241         g_snprintf( buf, sizeof( buf ), "REA %d %s %s\r\n", ++md->trId, gc->username, fn );
    242         msn_write( gc, buf, strlen( buf ) );
    243         g_free( fn );
     223        msn_set_display_name( set_find( &gc->acc->set, "display_name" ), info );
    244224}
    245225
     
    380360}
    381361
     362static char *msn_set_display_name( set_t *set, char *value )
     363{
     364        account_t *acc = set->data;
     365        struct gaim_connection *gc = acc->gc;
     366        struct msn_data *md;
     367        char buf[1024], *fn;
     368       
     369        /* Double-check. */
     370        if( gc == NULL )
     371                return NULL;
     372       
     373        md = gc->proto_data;
     374       
     375        if( strlen( value ) > 129 )
     376        {
     377                serv_got_crap( gc, "Maximum name length exceeded" );
     378                return NULL;
     379        }
     380       
     381        fn = msn_http_encode( value );
     382       
     383        g_snprintf( buf, sizeof( buf ), "REA %d %s %s\r\n", ++md->trId, gc->username, fn );
     384        msn_write( gc, buf, strlen( buf ) );
     385        g_free( fn );
     386       
     387        /* Returning NULL would be better, because the server still has to
     388           confirm the name change. However, it looks a bit confusing to the
     389           user. */
     390        return value;
     391}
     392
    382393void msn_init()
    383394{
    384395        struct prpl *ret = g_new0(struct prpl, 1);
     396       
    385397        ret->name = "msn";
    386398        ret->login = msn_login;
     399        ret->acc_init = msn_acc_init;
    387400        ret->close = msn_close;
    388401        ret->send_im = msn_send_im;
     
    404417        ret->rem_deny = msn_rem_deny;
    405418        ret->send_typing = msn_send_typing;
    406         ret->cmp_buddynames = g_strcasecmp;
     419        ret->handle_cmp = g_strcasecmp;
    407420
    408421        register_protocol(ret);
Note: See TracChangeset for help on using the changeset viewer.