Make GData plugin use the password store.
[claws.git] / src / plugins / gdata / gdata_plugin.c
index 5985f1d..99303a1 100644 (file)
@@ -37,6 +37,7 @@
 #include "main.h"
 #include "mainwindow.h"
 #include "addr_compl.h"
 #include "main.h"
 #include "mainwindow.h"
 #include "addr_compl.h"
+#include "passwordstore.h"
 
 #include "cm_gdata_contacts.h"
 #include "cm_gdata_prefs.h"
 
 #include "cm_gdata_contacts.h"
 #include "cm_gdata_prefs.h"
@@ -72,7 +73,7 @@ static void cm_gdata_save_config(void)
 
   if (prefs_write_param(cm_gdata_param, pfile->fp) < 0) {
     debug_print("failed!\n");
 
   if (prefs_write_param(cm_gdata_param, pfile->fp) < 0) {
     debug_print("failed!\n");
-    g_warning(_("\nGData Plugin: Failed to write plugin configuration to file\n"));
+    g_warning("GData Plugin: Failed to write plugin configuration to file");
     prefs_file_close_revert(pfile);
     return;
   }
     prefs_file_close_revert(pfile);
     return;
   }
@@ -97,7 +98,7 @@ gint plugin_init(gchar **error)
   gchar *rcpath;
 
   /* Version check */
   gchar *rcpath;
 
   /* Version check */
-  if(!check_plugin_version(MAKE_NUMERIC_VERSION(3,7,1,55),
+  if(!check_plugin_version(MAKE_NUMERIC_VERSION(3,13,2,39),
                           VERSION_NUMERIC, _("GData"), error))
     return -1;
 
                           VERSION_NUMERIC, _("GData"), error))
     return -1;
 
@@ -121,15 +122,22 @@ gint plugin_init(gchar **error)
   prefs_read_config(cm_gdata_param, "GDataPlugin", rcpath, NULL);
   g_free(rcpath);
 
   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();
 
   cm_gdata_prefs_init();
 
+  debug_print("GData plugin loaded\n");
+
   /* contacts cache */
   cm_gdata_load_contacts_cache_from_file();
   cm_gdata_update_contacts_update_timer();
   cm_gdata_update_contacts_cache();
 
   /* contacts cache */
   cm_gdata_load_contacts_cache_from_file();
   cm_gdata_update_contacts_update_timer();
   cm_gdata_update_contacts_cache();
 
-  debug_print("GData plugin loaded\n");
-
   return 0;
 }
 
   return 0;
 }