aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2010-05-01 15:10:32 +0100
committerWilmer van der Gaast <wilmer@gaast.net>2010-05-01 15:10:32 +0100
commitf4b0911d037c02f8b9190518b5efda4368dcc25b (patch)
tree413f6b21f0913075ee105cf3fb10526b6e10847a /lib
parentc2ecadc08daa5163f4c90aef36de0e33d0d44f16 (diff)
Save the credentials again.
Diffstat (limited to 'lib')
-rw-r--r--lib/oauth.c27
-rw-r--r--lib/oauth.h4
2 files changed, 31 insertions, 0 deletions
diff --git a/lib/oauth.c b/lib/oauth.c
index 4c93cbf4..8012c37a 100644
--- a/lib/oauth.c
+++ b/lib/oauth.c
@@ -424,3 +424,30 @@ char *oauth_http_header( struct oauth_info *oi, const char *method, const char *
return ret ? g_string_free( ret, FALSE ) : NULL;
}
+
+char *oauth_to_string( struct oauth_info *oi )
+{
+ GSList *params = NULL;
+ char *ret;
+
+ oauth_params_add( &params, "oauth_token", oi->token );
+ oauth_params_add( &params, "oauth_token_secret", oi->token_secret );
+ ret = oauth_params_string( params );
+ oauth_params_free( &params );
+
+ return ret;
+}
+
+struct oauth_info *oauth_from_string( char *in, struct oauth_service *sp )
+{
+ struct oauth_info *oi = g_new0( struct oauth_info, 1 );
+ GSList *params = NULL;
+
+ oauth_params_parse( &params, in );
+ oi->token = g_strdup( oauth_params_get( &params, "oauth_token" ) );
+ oi->token_secret = g_strdup( oauth_params_get( &params, "oauth_token_secret" ) );
+ oauth_params_free( &params );
+ oi->sp = sp;
+
+ return oi;
+}
diff --git a/lib/oauth.h b/lib/oauth.h
index 849375be..6b51dc2c 100644
--- a/lib/oauth.h
+++ b/lib/oauth.h
@@ -84,3 +84,7 @@ char *oauth_http_header( struct oauth_info *oi, const char *method, const char *
/* Shouldn't normally be required unless the process is aborted by the user. */
void oauth_info_free( struct oauth_info *info );
+
+/* Convert to and back from strings, for easier saving. */
+char *oauth_to_string( struct oauth_info *oi );
+struct oauth_info *oauth_from_string( char *in, struct oauth_service *sp );