Ignore:
Timestamp:
2010-08-18T19:21:44Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
f2520b5
Parents:
e0e1546
Message:

Fetch the user's profile to see if there's a display name set there. If
there is, the one in the address book should be ignored. No support for
changing the profile yet though.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/soap.c

    re0e1546 r80175a1  
    209209       
    210210        *id -= '1';
    211         if( *id >= 0 && *id <= 2 )
     211        if( *id >= 0 && *id < sizeof( md->tokens ) / sizeof( md->tokens[0] ) )
    212212        {
    213213                g_free( md->tokens[(int)*id] );
     
    687687        struct msn_soap_req_data *soap_req = data;
    688688        struct im_connection *ic = soap_req->ic;
    689         struct msn_data *md = soap_req->ic->proto_data;
    690689        struct msn_group *group;
    691690       
     
    705704        if( type && g_strcasecmp( type, "me" ) == 0 )
    706705        {
    707 #if 0
    708                 g_free( md->myid );
    709                 md->myid = g_strdup( id );
    710 #endif         
    711706                set_t *set = set_find( &ic->acc->set, "display_name" );
    712707                g_free( set->value );
    713708                set->value = g_strdup( display_name );
     709               
     710                /* Try to fetch the profile; if the user has one, that's where
     711                   we can find the persistent display_name. */
     712                if( ( p = xt_find_node( node->children, "CID" ) ) && p->text )
     713                        msn_soap_profile_get( ic, p->text );
    714714               
    715715                return XT_HANDLED;
     
    882882                               msn_soap_ab_contact_del_free_data );
    883883}
     884
     885
     886
     887/* Storage stuff: Fetch profile. */
     888static int msn_soap_profile_get_build_request( struct msn_soap_req_data *soap_req )
     889{
     890        struct msn_data *md = soap_req->ic->proto_data;
     891       
     892        soap_req->url = g_strdup( SOAP_STORAGE_URL );
     893        soap_req->action = g_strdup( SOAP_PROFILE_GET_ACTION );
     894        soap_req->payload = g_markup_printf_escaped( SOAP_PROFILE_GET_PAYLOAD,
     895                md->tokens[3], (char*) soap_req->data );
     896       
     897        return 1;
     898}
     899
     900static xt_status msn_soap_profile_get_result( struct xt_node *node, gpointer data )
     901{
     902        struct msn_soap_req_data *soap_req = data;
     903        struct im_connection *ic = soap_req->ic;
     904        struct msn_data *md = soap_req->ic->proto_data;
     905        struct xt_node *dn;
     906       
     907        if( ( dn = xt_find_node( node->children, "DisplayName" ) ) && dn->text )
     908        {
     909                set_t *set = set_find( &ic->acc->set, "display_name" );
     910                g_free( set->value );
     911                set->value = g_strdup( dn->text );
     912               
     913                md->flags |= MSN_GOT_PROFILE_DN;
     914        }
     915       
     916        return XT_HANDLED;
     917}
     918
     919static const struct xt_handler_entry msn_soap_profile_get_parser[] = {
     920        { "ExpressionProfile", "GetProfileResult", msn_soap_profile_get_result },
     921        { NULL,               NULL,     NULL                        }
     922};
     923
     924static int msn_soap_profile_get_handle_response( struct msn_soap_req_data *soap_req )
     925{
     926        struct msn_data *md = soap_req->ic->proto_data;
     927       
     928        md->flags |= MSN_GOT_PROFILE;
     929        msn_ns_finish_login( soap_req->ic );
     930       
     931        return MSN_SOAP_OK;
     932}
     933
     934static int msn_soap_profile_get_free_data( struct msn_soap_req_data *soap_req )
     935{
     936        g_free( soap_req->data );
     937        return 0;
     938}
     939
     940int msn_soap_profile_get( struct im_connection *ic, const char *cid )
     941{
     942        return msn_soap_start( ic, g_strdup( cid ),
     943                               msn_soap_profile_get_build_request,
     944                               msn_soap_profile_get_parser,
     945                               msn_soap_profile_get_handle_response,
     946                               msn_soap_profile_get_free_data );
     947}
Note: See TracChangeset for help on using the changeset viewer.