diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2010-08-15 19:46:10 +0100 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2010-08-15 19:46:10 +0100 |
commit | e0e15468835d5ae5bce54a28bd7a5b7aea66a1e2 (patch) | |
tree | e0441f195514b8ad0318f577ea2c09de0b4469b3 | |
parent | 9b01339168bc79d08c4e371552cc44648bd8878d (diff) |
Making display name code a bit saner. Apparently PoS MSN is still suffering
from display_name amnesia a little bit though at least with Hotmail accounts.
-rw-r--r-- | protocols/msn/msn.c | 15 | ||||
-rw-r--r-- | protocols/msn/msn.h | 2 | ||||
-rw-r--r-- | protocols/msn/msn_util.c | 16 | ||||
-rw-r--r-- | protocols/msn/ns.c | 20 | ||||
-rw-r--r-- | protocols/msn/soap.c | 7 |
5 files changed, 30 insertions, 30 deletions
diff --git a/protocols/msn/msn.c b/protocols/msn/msn.c index 00c01dc3..873a51ad 100644 --- a/protocols/msn/msn.c +++ b/protocols/msn/msn.c @@ -336,9 +336,6 @@ static char *set_eval_display_name( set_t *set, char *value ) { account_t *acc = set->data; struct im_connection *ic = acc->ic; - struct msn_data *md = ic->proto_data; - char buf[512]; - char *fn; if( strlen( value ) > 129 ) { @@ -347,17 +344,7 @@ static char *set_eval_display_name( set_t *set, char *value ) } msn_soap_addressbook_set_display_name( ic, value ); - - fn = g_malloc( strlen( value ) * 3 + 1 ); - strcpy( fn, value ); - http_encode( fn ); - g_snprintf( buf, sizeof( buf ), "PRP %d MFN %s\r\n", - ++md->trId, fn ); - g_free( fn ); - - /* Note: We don't actually know if the server accepted the new name, - and won't give proper feedback yet if it doesn't. */ - return msn_write( ic, buf, strlen( buf ) ) ? value : NULL; + return msn_ns_set_display_name( ic, value ) ? value : NULL; } static void msn_buddy_data_add( bee_user_t *bu ) diff --git a/protocols/msn/msn.h b/protocols/msn/msn.h index ae4ea42b..3ea8c503 100644 --- a/protocols/msn/msn.h +++ b/protocols/msn/msn.h @@ -216,11 +216,11 @@ char *msn_findheader( char *text, char *header, int len ); char **msn_linesplit( char *line ); int msn_handler( struct msn_handler_data *h ); void msn_msgq_purge( struct im_connection *ic, GSList **list ); -gboolean msn_set_display_name( struct im_connection *ic, const char *rawname ); char *msn_p11_challenge( char *challenge ); gint msn_domaintree_cmp( gconstpointer a_, gconstpointer b_ ); struct msn_group *msn_group_by_name( struct im_connection *ic, const char *name ); struct msn_group *msn_group_by_id( struct im_connection *ic, const char *id ); +int msn_ns_set_display_name( struct im_connection *ic, const char *value ); /* tables.c */ const struct msn_away_state *msn_away_state_by_number( int number ); diff --git a/protocols/msn/msn_util.c b/protocols/msn/msn_util.c index cf8ab4db..78f81a41 100644 --- a/protocols/msn/msn_util.c +++ b/protocols/msn/msn_util.c @@ -597,3 +597,19 @@ struct msn_group *msn_group_by_id( struct im_connection *ic, const char *id ) return NULL; } + +int msn_ns_set_display_name( struct im_connection *ic, const char *value ) +{ + struct msn_data *md = ic->proto_data; + char fn[strlen(value)*3+1]; + char buf[512]; + + strcpy( fn, value ); + http_encode( fn ); + g_snprintf( buf, sizeof( buf ), "PRP %d MFN %s\r\n", + ++md->trId, fn ); + + /* Note: We don't actually know if the server accepted the new name, + and won't give proper feedback yet if it doesn't. */ + return msn_write( ic, buf, strlen( buf ) ); +} diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index 2449c8d5..c9b01ef2 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -258,6 +258,9 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) else if( strcmp( cmd[0], "BLP" ) == 0 ) { msn_ns_send_adl_start( ic ); + + if( md->adl_todo < 0 && !( ic->flags & OPT_LOGGED_IN ) ) + return msn_ns_set_display_name( ic, set_getstr( &ic->acc->set, "display_name" ) ); } else if( strcmp( cmd[0], "ADL" ) == 0 ) { @@ -267,21 +270,10 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) if( md->adl_todo < 0 && !( ic->flags & OPT_LOGGED_IN ) ) { - char buf[1024]; - char *fn_raw; - char *fn; - - if( ( fn_raw = set_getstr( &ic->acc->set, "display_name" ) ) == NULL ) - fn_raw = ic->acc->user; - fn = g_malloc( strlen( fn_raw ) * 3 + 1 ); - strcpy( fn, fn_raw ); - http_encode( fn ); - - g_snprintf( buf, sizeof( buf ), "PRP %d MFN %s\r\n", - ++md->trId, fn ); - g_free( fn ); + msn_ns_send_adl( ic ); - msn_write( ic, buf, strlen( buf ) ); + if( md->adl_todo < 0 && !( ic->flags & OPT_LOGGED_IN ) ) + return msn_ns_set_display_name( ic, set_getstr( &ic->acc->set, "display_name" ) ); } } else if( num_parts >= 3 ) diff --git a/protocols/msn/soap.c b/protocols/msn/soap.c index 91f93afd..b717343f 100644 --- a/protocols/msn/soap.c +++ b/protocols/msn/soap.c @@ -686,6 +686,7 @@ static xt_status msn_soap_addressbook_contact( struct xt_node *node, gpointer da *display_name = NULL, *group_id = NULL; struct msn_soap_req_data *soap_req = data; struct im_connection *ic = soap_req->ic; + struct msn_data *md = soap_req->ic->proto_data; struct msn_group *group; if( ( p = xt_find_path( node, "../contactId" ) ) ) @@ -703,6 +704,10 @@ static xt_status msn_soap_addressbook_contact( struct xt_node *node, gpointer da if( type && g_strcasecmp( type, "me" ) == 0 ) { +#if 0 + g_free( md->myid ); + md->myid = g_strdup( id ); +#endif set_t *set = set_find( &ic->acc->set, "display_name" ); g_free( set->value ); set->value = g_strdup( display_name ); @@ -765,7 +770,7 @@ static int msn_soap_ab_namechange_build_request( struct msn_soap_req_data *soap_ soap_req->url = g_strdup( SOAP_ADDRESSBOOK_URL ); soap_req->action = g_strdup( SOAP_AB_NAMECHANGE_ACTION ); soap_req->payload = msn_soap_abservice_build( SOAP_AB_NAMECHANGE_PAYLOAD, - "Initial", md->tokens[1], (char *) soap_req->data ); + "Timer", md->tokens[1], (char *) soap_req->data ); return 1; } |