Make vCalendar plugin use the password store.
authorAndrej Kacian <ticho@claws-mail.org>
Wed, 30 Mar 2016 20:59:09 +0000 (22:59 +0200)
committerAndrej Kacian <ticho@claws-mail.org>
Wed, 30 Mar 2016 21:05:35 +0000 (23:05 +0200)
src/plugins/vcalendar/claws.def
src/plugins/vcalendar/plugin.c
src/plugins/vcalendar/plugin.def
src/plugins/vcalendar/vcal_folder.c
src/plugins/vcalendar/vcal_prefs.c
src/plugins/vcalendar/vcal_prefs.h
src/plugins/vcalendar/vcalendar.h

index 297aa5f54c60119dabebde7e0cd2f724fa206822..de9bbe51c18f1d5ce4c04fec89c9bbe9a74590e2 100644 (file)
@@ -109,8 +109,6 @@ mimeview_register_viewer_factory
 mimeview_unregister_viewer_factory
 move_file
 open_uri
 mimeview_unregister_viewer_factory
 move_file
 open_uri
-password_decrypt
-password_encrypt
 prefs_button_toggled
 prefs_common
 prefs_common_get_uri_cmd
 prefs_button_toggled
 prefs_common
 prefs_common_get_uri_cmd
index 945cab558590fc4cb3b199fb349cad0e7a54d0bf..575181d847f021faf375f0d078d31402a2dacefd 100644 (file)
@@ -99,11 +99,6 @@ const gchar *plugin_version(void)
        return VERSION;
 }
 
        return VERSION;
 }
 
-void plugin_master_passphrase_change (const gchar *oldp, const gchar *newp)
-{
-       vcal_prefs_master_passphrase_change(oldp, newp);
-}
-
 struct PluginFeature *plugin_provides(void)
 {
        static struct PluginFeature features[] = 
 struct PluginFeature *plugin_provides(void)
 {
        static struct PluginFeature features[] = 
index f79dd579308b1e959d360e16765619ee42d3b6c6..8916a5d7c3b8ef989dcd1513fc5dd7405b7a57e1 100644 (file)
@@ -7,5 +7,4 @@ EXPORTS
         plugin_type
        plugin_provides
         plugin_version
         plugin_type
        plugin_provides
         plugin_version
-       plugin_master_passphrase_change
 
 
index 96630cda3c554249b8f729d5e5933607c35855db..b49595075a807c68ff9f11bc6006c7faf7b4ec77 100644 (file)
@@ -60,7 +60,7 @@
 #include "mainwindow.h"
 #include "statusbar.h"
 #include "msgcache.h"
 #include "mainwindow.h"
 #include "statusbar.h"
 #include "msgcache.h"
-#include "password.h"
+#include "passwordstore.h"
 #include "timing.h"
 #include "messageview.h"
 
 #include "timing.h"
 #include "messageview.h"
 
@@ -1178,8 +1178,8 @@ void vcal_folder_export(Folder *folder)
                return;
        vcal_folder_lock_count++;
        
                return;
        vcal_folder_lock_count++;
        
-       export_pass = password_decrypt(vcalprefs.export_pass, NULL);
-       export_freebusy_pass = password_decrypt(vcalprefs.export_freebusy_pass, NULL);
+       export_pass = vcal_passwd_get("export");
+       export_freebusy_pass = vcal_passwd_get("export_freebusy");
 
        if (vcal_meeting_export_calendar(vcalprefs.export_path, 
                        vcalprefs.export_user, 
 
        if (vcal_meeting_export_calendar(vcalprefs.export_path, 
                        vcalprefs.export_user, 
index baf40d4d22b35bcf9ff3a805a8d759237169a589..8686ba888b095d2c2fe583b0d97da77e5b69e0cf 100644 (file)
@@ -30,7 +30,7 @@
 #include "defs.h"
 
 #include "mainwindow.h"
 #include "defs.h"
 
 #include "mainwindow.h"
-#include "password.h"
+#include "passwordstore.h"
 #include "prefs.h"
 #include "prefs_gtk.h"
 #include "prefswindow.h"
 #include "prefs.h"
 #include "prefs_gtk.h"
 #include "prefswindow.h"
@@ -562,8 +562,8 @@ static void vcal_prefs_create_widget_func(PrefsPage * _page,
        if (!vcalprefs.export_freebusy_pass)
                vcalprefs.export_freebusy_pass = g_strdup("");
 
        if (!vcalprefs.export_freebusy_pass)
                vcalprefs.export_freebusy_pass = g_strdup("");
 
-       export_pass = password_decrypt(vcalprefs.export_pass, NULL);
-       export_freebusy_pass = password_decrypt(vcalprefs.export_freebusy_pass, NULL);
+       export_pass = vcal_passwd_get("export");
+       export_freebusy_pass = vcal_passwd_get("export_freebusy");
        
        gtk_entry_set_text(GTK_ENTRY(export_user_entry), vcalprefs.export_user);
        gtk_entry_set_text(GTK_ENTRY(export_pass_entry), (export_pass != NULL ? export_pass : ""));
        
        gtk_entry_set_text(GTK_ENTRY(export_user_entry), vcalprefs.export_user);
        gtk_entry_set_text(GTK_ENTRY(export_pass_entry), (export_pass != NULL ? export_pass : ""));
@@ -683,7 +683,7 @@ static void vcal_prefs_save_func(PrefsPage * _page)
        g_free(vcalprefs.export_pass);
        pass = gtk_editable_get_chars(GTK_EDITABLE(page->export_pass_entry), 0, -1);
        
        g_free(vcalprefs.export_pass);
        pass = gtk_editable_get_chars(GTK_EDITABLE(page->export_pass_entry), 0, -1);
        
-       vcalprefs.export_pass = password_encrypt(pass, NULL);
+       vcal_passwd_set("export", pass);
        memset(pass, 0, strlen(pass));
        g_free(pass);
        
        memset(pass, 0, strlen(pass));
        g_free(pass);
        
@@ -705,7 +705,8 @@ static void vcal_prefs_save_func(PrefsPage * _page)
            gtk_editable_get_chars(GTK_EDITABLE(page->export_freebusy_user_entry), 0, -1);
        g_free(vcalprefs.export_freebusy_pass);
        pass = gtk_editable_get_chars(GTK_EDITABLE(page->export_freebusy_pass_entry), 0, -1);
            gtk_editable_get_chars(GTK_EDITABLE(page->export_freebusy_user_entry), 0, -1);
        g_free(vcalprefs.export_freebusy_pass);
        pass = gtk_editable_get_chars(GTK_EDITABLE(page->export_freebusy_pass_entry), 0, -1);
-       vcalprefs.export_freebusy_pass = password_encrypt(pass, NULL);
+
+       vcal_passwd_set("export_freebusy", pass);
        memset(pass, 0, strlen(pass));
        g_free(pass);
 
        memset(pass, 0, strlen(pass));
        g_free(pass);
 
@@ -720,31 +721,15 @@ static void vcal_prefs_save_func(PrefsPage * _page)
                                         (page->ssl_verify_peer_checkbtn));
 
        vcal_prefs_save();
                                         (page->ssl_verify_peer_checkbtn));
 
        vcal_prefs_save();
+       passwd_store_write_config();
        vcal_folder_export(NULL);
 }
 
        vcal_folder_export(NULL);
 }
 
-void vcal_prefs_master_passphrase_change(const gchar *oldp, const gchar *newp) {
-       gchar *pass;
-       pass = password_decrypt(vcalprefs.export_pass, oldp);
-       if (pass != NULL) {
-               g_free(vcalprefs.export_pass);
-               vcalprefs.export_pass = password_encrypt(pass, newp);
-               memset(pass, 0, strlen(pass));
-       }
-       g_free(pass);
-       pass = password_decrypt(vcalprefs.export_freebusy_pass, oldp);
-       if (pass != NULL) {
-               g_free(vcalprefs.export_freebusy_pass);
-               vcalprefs.export_freebusy_pass = password_encrypt(pass, newp);
-               memset(pass, 0, strlen(pass));
-       }
-       g_free(pass);
-}
-
 void vcal_prefs_init(void)
 {
        static gchar *path[3];
        gchar *rcpath;
 void vcal_prefs_init(void)
 {
        static gchar *path[3];
        gchar *rcpath;
+       gboolean passwords_migrated = FALSE;
 
        path[0] = _("Plugins");
        path[1] = _("vCalendar");
 
        path[0] = _("Plugins");
        path[1] = _("vCalendar");
@@ -755,6 +740,23 @@ void vcal_prefs_init(void)
        prefs_read_config(param, PREFS_BLOCK_NAME, rcpath, NULL);
        g_free(rcpath);
 
        prefs_read_config(param, PREFS_BLOCK_NAME, rcpath, NULL);
        g_free(rcpath);
 
+       /* Move passwords that are still in main config to password store. */
+       if (vcalprefs.export_pass != NULL &&
+                       strlen(vcalprefs.export_pass) > 0) {
+               passwd_store_set(PWS_PLUGIN, "vCalendar", "export",
+                               vcalprefs.export_pass, TRUE);
+               passwords_migrated = TRUE;
+       }
+       if (vcalprefs.export_freebusy_pass != NULL &&
+                       strlen(vcalprefs.export_freebusy_pass) > 0) {
+               passwd_store_set(PWS_PLUGIN, "vCalendar", "export",
+                               vcalprefs.export_freebusy_pass, TRUE);
+               passwords_migrated = TRUE;
+       }
+
+       if (passwords_migrated)
+               passwd_store_write_config();
+
        vcal_prefs_page.page.path = path;
        vcal_prefs_page.page.create_widget = vcal_prefs_create_widget_func;
        vcal_prefs_page.page.destroy_widget = vcal_prefs_destroy_widget_func;
        vcal_prefs_page.page.path = path;
        vcal_prefs_page.page.create_widget = vcal_prefs_create_widget_func;
        vcal_prefs_page.page.destroy_widget = vcal_prefs_destroy_widget_func;
index 9e7d89ff52a3139745f51aa4c64d8a942f5b1a20..8a89f379554189c5c57ac8f511fcdeee134cca21 100644 (file)
@@ -51,6 +51,5 @@ extern VcalendarPrefs vcalprefs;
 void vcal_prefs_init   (void);
 void vcal_prefs_done   (void);
 void vcal_prefs_save   (void);
 void vcal_prefs_init   (void);
 void vcal_prefs_done   (void);
 void vcal_prefs_save   (void);
-void vcal_prefs_master_passphrase_change(const gchar *oldp, const gchar *newp);
 
 #endif
 
 #endif
index 92aa05b461e06e891c6e56d286a9266c81fc85d6..09d7cbd85c04b9f1b4f35efc6dc1420f53cc5bda 100644 (file)
@@ -34,4 +34,10 @@ void vcalviewer_display_event (VCalViewer *vcalviewer, VCalEvent *event);
 gchar *vcalviewer_get_uid_from_mimeinfo(MimeInfo *mimeinfo);
 void vcalviewer_reload(FolderItem *item);
 void vcalendar_cancel_meeting(FolderItem *item, const gchar *uid);
 gchar *vcalviewer_get_uid_from_mimeinfo(MimeInfo *mimeinfo);
 void vcalviewer_reload(FolderItem *item);
 void vcalendar_cancel_meeting(FolderItem *item, const gchar *uid);
+
+#define vcal_passwd_set(id, pwd) \
+       passwd_store_set(PWS_PLUGIN, "vCalendar", id, pwd, FALSE)
+#define vcal_passwd_get(id) \
+       passwd_store_get(PWS_PLUGIN, "vCalendar", id)
+
 #endif
 #endif