Ignore:
Timestamp:
2010-08-14T13:06:11Z (15 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.c

    rd93c0eb9 r4452e69  
    2525
    2626#include "nogaim.h"
     27#include "soap.h"
    2728#include "msn.h"
    2829
     
    3536static void msn_init( account_t *acc )
    3637{
    37         set_add( &acc->set, "display_name", NULL, set_eval_display_name, acc );
    38         set_add( &acc->set, "local_display_name", "false", set_eval_bool, acc );
     38        set_t *s;
     39       
     40        s = set_add( &acc->set, "display_name", NULL, set_eval_display_name, acc );
     41        s->flags |= ACC_SET_NOSAVE | ACC_SET_ONLINE_ONLY;
     42       
    3943        set_add( &acc->set, "mail_notifications", "false", set_eval_bool, acc );
    4044        set_add( &acc->set, "switchboard_keepalives", "false", set_eval_bool, acc );
     
    203207}
    204208
    205 static void msn_set_my_name( struct im_connection *ic, char *info )
    206 {
    207         msn_set_display_name( ic, info );
    208 }
    209 
    210209static void msn_get_info(struct im_connection *ic, char *who)
    211210{
     
    332331        account_t *acc = set->data;
    333332        struct im_connection *ic = acc->ic;
    334        
    335         /* Allow any name if we're offline. */
    336         if( ic == NULL )
    337                 return value;
     333        struct msn_data *md = ic->proto_data;
     334        char buf[512];
     335        char *fn;
    338336       
    339337        if( strlen( value ) > 129 )
     
    343341        }
    344342       
    345         /* Returning NULL would be better, because the server still has to
    346            confirm the name change. However, it looks a bit confusing to the
    347            user. */
    348         return msn_set_display_name( ic, value ) ? value : NULL;
     343        msn_soap_addressbook_set_display_name( ic, value );
     344
     345        fn = g_malloc( strlen( value ) * 3 + 1 );
     346        strcpy( fn, value );
     347        http_encode( fn );
     348        g_snprintf( buf, sizeof( buf ), "PRP %d MFN %s\r\n",
     349                    ++md->trId, fn );
     350        g_free( fn );
     351       
     352        /* Note: We don't actually know if the server accepted the new name,
     353           and won't give proper feedback yet if it doesn't. */
     354        return msn_write( ic, buf, strlen( buf ) ) ? value : NULL;
    349355}
    350356
     
    375381        ret->set_away = msn_set_away;
    376382        ret->get_info = msn_get_info;
    377         ret->set_my_name = msn_set_my_name;
    378383        ret->add_buddy = msn_add_buddy;
    379384        ret->remove_buddy = msn_remove_buddy;
Note: See TracChangeset for help on using the changeset viewer.