Changeset 36533bf


Ignore:
Timestamp:
2011-12-19T12:54:49Z (12 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
4b53c65
Parents:
4be0e34
Message:

When updating the XMPP password field with OAuth data, try harder to preserve
existing data. (Like refresh tokens which we'll need again on next login.)

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lib/oauth.h

    r4be0e34 r36533bf  
    9696void oauth_params_free( GSList **params );
    9797char *oauth_params_string( GSList *params );
     98void oauth_params_set( GSList **params, const char *key, const char *value );
    9899const char *oauth_params_get( GSList **params, const char *key );
  • protocols/jabber/sasl.c

    r4be0e34 r36533bf  
    528528        struct im_connection *ic = data;
    529529        struct jabber_data *jd;
     530        GSList *auth = NULL;
    530531       
    531532        if( g_slist_find( jabber_connections, ic ) == NULL )
     
    540541                return;
    541542        }
    542         if( refresh_token != NULL )
    543         {
    544                 g_free( ic->acc->pass );
    545                 ic->acc->pass = g_strdup_printf( "refresh_token=%s", refresh_token );
    546         }
    547         /* Should do this, but only in the Facebook case where we get an access
    548            token that never expires. Shouldn't overwrite a refresh token with
    549            an access token.
    550         else
    551         {
    552                 g_free( ic->acc->pass );
    553                 ic->acc->pass = g_strdup_printf( "access_token=%s", access_token );
    554         } */
     543       
     544        oauth_params_parse( &auth, ic->acc->pass );
     545        if( refresh_token )
     546                oauth_params_set( &auth, "refresh_token", refresh_token );
     547        if( access_token )
     548                oauth_params_set( &auth, "access_token", access_token );
     549       
     550        g_free( ic->acc->pass );
     551        ic->acc->pass = oauth_params_string( auth );
     552        oauth_params_free( &auth );
    555553       
    556554        g_free( jd->oauth2_access_token );
Note: See TracChangeset for help on using the changeset viewer.