talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit c6bdd4be68b16e397b09d16078d06982585a01d1
parent 73e0a2e64074bab0b6abfde58fdf569b183dde5d
Author: Andrej Kacian <ticho@claws-mail.org>
Date:   Wed, 30 Mar 2016 22:59:09 +0200

Make vCalendar plugin use the password store.

Diffstat:
Msrc/plugins/vcalendar/claws.def | 2--
Msrc/plugins/vcalendar/plugin.c | 5-----
Msrc/plugins/vcalendar/plugin.def | 1-
Msrc/plugins/vcalendar/vcal_folder.c | 6+++---
Msrc/plugins/vcalendar/vcal_prefs.c | 48+++++++++++++++++++++++++-----------------------
Msrc/plugins/vcalendar/vcal_prefs.h | 1-
Msrc/plugins/vcalendar/vcalendar.h | 6++++++
7 files changed, 34 insertions(+), 35 deletions(-)

diff --git a/src/plugins/vcalendar/claws.def b/src/plugins/vcalendar/claws.def @@ -109,8 +109,6 @@ mimeview_register_viewer_factory mimeview_unregister_viewer_factory move_file open_uri -password_decrypt -password_encrypt prefs_button_toggled prefs_common prefs_common_get_uri_cmd diff --git a/src/plugins/vcalendar/plugin.c b/src/plugins/vcalendar/plugin.c @@ -99,11 +99,6 @@ const gchar *plugin_version(void) 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[] = diff --git a/src/plugins/vcalendar/plugin.def b/src/plugins/vcalendar/plugin.def @@ -7,5 +7,4 @@ EXPORTS plugin_type plugin_provides plugin_version - plugin_master_passphrase_change diff --git a/src/plugins/vcalendar/vcal_folder.c b/src/plugins/vcalendar/vcal_folder.c @@ -60,7 +60,7 @@ #include "mainwindow.h" #include "statusbar.h" #include "msgcache.h" -#include "password.h" +#include "passwordstore.h" #include "timing.h" #include "messageview.h" @@ -1178,8 +1178,8 @@ void vcal_folder_export(Folder *folder) 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, diff --git a/src/plugins/vcalendar/vcal_prefs.c b/src/plugins/vcalendar/vcal_prefs.c @@ -30,7 +30,7 @@ #include "defs.h" #include "mainwindow.h" -#include "password.h" +#include "passwordstore.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(""); - 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 : "")); @@ -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); - vcalprefs.export_pass = password_encrypt(pass, NULL); + vcal_passwd_set("export", 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); - vcalprefs.export_freebusy_pass = password_encrypt(pass, NULL); + + vcal_passwd_set("export_freebusy", 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(); + passwd_store_write_config(); 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; + gboolean passwords_migrated = FALSE; 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); + /* 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; diff --git a/src/plugins/vcalendar/vcal_prefs.h b/src/plugins/vcalendar/vcal_prefs.h @@ -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_master_passphrase_change(const gchar *oldp, const gchar *newp); #endif diff --git a/src/plugins/vcalendar/vcalendar.h b/src/plugins/vcalendar/vcalendar.h @@ -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); + +#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