[Commits] [SCM] claws branch, master, updated. 3.13.2-74-g1a9b1d8

ticho at claws-mail.org ticho at claws-mail.org
Sat Mar 19 18:10:47 CET 2016


The branch, master has been updated
       via  1a9b1d83726cd36c15325d5c5893617cc47b8675 (commit)
      from  e75a8701ffa80cfa446144e168f8c37986442aa7 (commit)

Summary of changes:
 src/plugins/gdata/cm_gdata_contacts.c |   17 +++++++++--------
 src/plugins/gdata/cm_gdata_prefs.c    |   13 -------------
 src/plugins/gdata/cm_gdata_prefs.h    |    3 ++-
 src/plugins/gdata/gdata_plugin.c      |   13 ++++++++-----
 4 files changed, 19 insertions(+), 27 deletions(-)


- Log -----------------------------------------------------------------
commit 1a9b1d83726cd36c15325d5c5893617cc47b8675
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Sat Mar 19 18:10:02 2016 +0100

    Make GData plugin use the password store.
    
    Untested, as I have no Google accounts to test with.

diff --git a/src/plugins/gdata/cm_gdata_contacts.c b/src/plugins/gdata/cm_gdata_contacts.c
index 0a062d2..86fc265 100644
--- a/src/plugins/gdata/cm_gdata_contacts.c
+++ b/src/plugins/gdata/cm_gdata_contacts.c
@@ -31,7 +31,7 @@
 
 #include "addr_compl.h"
 #include "main.h"
-#include "password.h"
+#include "passwordstore.h"
 #include "prefs_common.h"
 #include "mainwindow.h"
 #include "common/log.h"
@@ -522,6 +522,8 @@ static guchar* decode(const gchar *in)
 
 static void query()
 {
+	gchar *token;
+
   if(cm_gdata_contacts_query_running)
   {
     debug_print("GData plugin: Network query already in progress");
@@ -552,14 +554,12 @@ static void query()
   {
 #if GDATA_CHECK_VERSION(0,17,2)
     /* Try to restore from saved refresh token.*/
-    if(cm_gdata_config.oauth2_refresh_token)
+		if((token = passwd_store_get(PWS_PLUGIN,
+						"GData", GDATA_TOKEN_PWD_STRING)) != NULL)
     {
-      gchar *token = password_decrypt(cm_gdata_config.oauth2_refresh_token, NULL);
       log_message(LOG_PROTOCOL, _("GData plugin: Trying to refresh authorization\n"));
-      gdata_oauth2_authorizer_set_refresh_token(authorizer, (token != NULL ? token : ""));
-      if (token != NULL) {
-        memset(token, 0, strlen(token));
-      }
+      gdata_oauth2_authorizer_set_refresh_token(authorizer, token);
+      memset(token, 0, strlen(token));
       g_free(token);
       gdata_authorizer_refresh_authorization_async(GDATA_AUTHORIZER(authorizer), NULL, (GAsyncReadyCallback)cm_gdata_refresh_ready, NULL);
     }
@@ -638,7 +638,8 @@ void cm_gdata_contacts_done(void)
 #if GDATA_CHECK_VERSION(0,17,2)
     /* store refresh token */
     pass = gdata_oauth2_authorizer_dup_refresh_token(authorizer);
-    cm_gdata_config.oauth2_refresh_token = password_encrypt(pass, NULL);
+		passwd_store_set(PWS_PLUGIN, "GData", GDATA_TOKEN_PWD_STRING, pass,
+				FALSE);
     memset(pass, 0, strlen(pass));
     g_free(pass);
 #endif
diff --git a/src/plugins/gdata/cm_gdata_prefs.c b/src/plugins/gdata/cm_gdata_prefs.c
index 7ae6f55..83a23a6 100644
--- a/src/plugins/gdata/cm_gdata_prefs.c
+++ b/src/plugins/gdata/cm_gdata_prefs.c
@@ -152,16 +152,3 @@ void cm_gdata_prefs_done(void)
     prefs_gtk_unregister_page((PrefsPage*) &gdata_page);
   }
 }
-
-void cm_gdata_prefs_master_passphrase_change(const gchar *oldp, const gchar *newp) {
-	gchar *pass;
-	int i;
-
-	pass = password_decrypt(cm_gdata_config.oauth2_refresh_token, oldp);
-	if (pass != NULL) {
-		g_free(cm_gdata_config.oauth2_refresh_token);
-		cm_gdata_config.oauth2_refresh_token = password_encrypt(pass, newp);
-		memset(pass, 0, strlen(pass));
-	}
-	g_free(pass);
-}
diff --git a/src/plugins/gdata/cm_gdata_prefs.h b/src/plugins/gdata/cm_gdata_prefs.h
index 5e917bd..b99f77f 100644
--- a/src/plugins/gdata/cm_gdata_prefs.h
+++ b/src/plugins/gdata/cm_gdata_prefs.h
@@ -20,6 +20,8 @@
 
 #include "prefs_gtk.h"
 
+#define GDATA_TOKEN_PWD_STRING "oauth2_refresh_token"
+
 typedef struct {
   char *username;
   char *password;
@@ -33,6 +35,5 @@ extern PrefParam    cm_gdata_param[];
 
 void cm_gdata_prefs_init(void);
 void cm_gdata_prefs_done(void);
-void cm_gdata_prefs_master_passphrase_change(const gchar *oldp, const gchar *newp);
 
 #endif /* CM_GDATA_PREFS_H_ */
diff --git a/src/plugins/gdata/gdata_plugin.c b/src/plugins/gdata/gdata_plugin.c
index c001f99..99303a1 100644
--- a/src/plugins/gdata/gdata_plugin.c
+++ b/src/plugins/gdata/gdata_plugin.c
@@ -37,6 +37,7 @@
 #include "main.h"
 #include "mainwindow.h"
 #include "addr_compl.h"
+#include "passwordstore.h"
 
 #include "cm_gdata_contacts.h"
 #include "cm_gdata_prefs.h"
@@ -121,6 +122,13 @@ gint plugin_init(gchar **error)
   prefs_read_config(cm_gdata_param, "GDataPlugin", rcpath, NULL);
   g_free(rcpath);
 
+	/* If the refresh token is still stored in config, save it to
+	 * password store. */
+	if(cm_gdata_config.oauth2_refresh_token != NULL) {
+		passwd_store_set(PWS_PLUGIN, "GData", GDATA_TOKEN_PWD_STRING,
+				cm_gdata_config.oauth2_refresh_token, FALSE);
+	}
+
   cm_gdata_prefs_init();
 
   debug_print("GData plugin loaded\n");
@@ -181,11 +189,6 @@ const gchar *plugin_version(void)
   return VERSION;
 }
 
-void plugin_master_passphrase_change (const gchar *oldp, const gchar *newp)
-{
-	cm_gdata_prefs_master_passphrase_change(oldp, newp);
-}
-
 struct PluginFeature *plugin_provides(void)
 {
   static struct PluginFeature features[] =

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list