Ignore:
Timestamp:
2010-08-14T13:06:11Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
5848675
Parents:
d93c0eb9
Message:

Allow changing the display_name, now permanently!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/msn_util.c

    rd93c0eb9 r4452e69  
    6161{
    6262        struct msn_data *md = ic->proto_data;
    63         char buf[1024], *realname, groupid[8];
     63        char buf[1024], realname[strlen(realname_)*3+1], groupid[8];
    6464       
    6565        *groupid = '\0';
     
    9494                        if( l == NULL )
    9595                        {
    96                                 char *groupname = msn_http_encode( group );
     96                                char groupname[strlen(group)+1];
     97                                strcpy( groupname, group );
     98                                http_encode( groupname );
    9799                                g_snprintf( buf, sizeof( buf ), "ADG %d %s %d\r\n", ++md->trId, groupname, 0 );
    98                                 g_free( groupname );
    99100                                return msn_write( ic, buf, strlen( buf ) );
    100101                        }
     
    109110        }
    110111       
    111         realname = msn_http_encode( realname_ );
     112        strcpy( realname, realname_ );
     113        http_encode( realname );
    112114        g_snprintf( buf, sizeof( buf ), "ADD %d %s %s %s%s\r\n", ++md->trId, list, who, realname, groupid );
    113         g_free( realname );
    114115       
    115116        return msn_write( ic, buf, strlen( buf ) );
     
    380381}
    381382
    382 /* The difference between this function and the normal http_encode() function
    383    is that this one escapes every 7-bit ASCII character because this is said
    384    to avoid some lame server-side checks when setting a real-name. Also,
    385    non-ASCII characters are not escaped because MSN servers don't seem to
    386    appreciate that! */
    387 char *msn_http_encode( const char *input )
    388 {
    389         char *ret, *s;
    390         int i;
    391        
    392         ret = s = g_new0( char, strlen( input ) * 3 + 1 );
    393         for( i = 0; input[i]; i ++ )
    394                 if( input[i] & 128 )
    395                 {
    396                         *s = input[i];
    397                         s ++;
    398                 }
    399                 else
    400                 {
    401                         g_snprintf( s, 4, "%%%02X", input[i] );
    402                         s += 3;
    403                 }
    404        
    405         return ret;
    406 }
    407 
    408383void msn_msgq_purge( struct im_connection *ic, GSList **list )
    409384{
     
    444419                imcb_log( ic, "%s", ret->str );
    445420        g_string_free( ret, TRUE );
    446 }
    447 
    448 gboolean msn_set_display_name( struct im_connection *ic, const char *rawname )
    449 {
    450         char *fn = msn_http_encode( rawname );
    451         struct msn_data *md = ic->proto_data;
    452         char buf[1024];
    453        
    454         g_snprintf( buf, sizeof( buf ), "REA %d %s %s\r\n", ++md->trId, ic->acc->user, fn );
    455         g_free( fn );
    456        
    457         return msn_write( ic, buf, strlen( buf ) ) != 0;
    458421}
    459422
Note: See TracChangeset for help on using the changeset viewer.