vCalendar: Use new password API
authorColin Leroy <colin@colino.net>
Thu, 11 Feb 2016 10:21:52 +0000 (11:21 +0100)
committerColin Leroy <colin@colino.net>
Thu, 11 Feb 2016 10:21:52 +0000 (11:21 +0100)
src/plugins/vcalendar/claws.def
src/plugins/vcalendar/vcal_folder.c
src/plugins/vcalendar/vcal_meeting_gtk.c
src/plugins/vcalendar/vcal_prefs.c

index de9bbe5..1d38f53 100644 (file)
@@ -109,6 +109,7 @@ mimeview_register_viewer_factory
 mimeview_unregister_viewer_factory
 move_file
 open_uri
+password_decrypt
 prefs_button_toggled
 prefs_common
 prefs_common_get_uri_cmd
index c52a399..96630cd 100644 (file)
@@ -60,6 +60,7 @@
 #include "mainwindow.h"
 #include "statusbar.h"
 #include "msgcache.h"
+#include "password.h"
 #include "timing.h"
 #include "messageview.h"
 
@@ -1170,13 +1171,19 @@ void vcal_folder_export(Folder *folder)
 {      
        FolderItem *item = folder?folder->inbox:NULL;
        gboolean need_scan = folder?vcal_scan_required(folder, item):TRUE;
+       gchar *export_pass = NULL;
+       gchar *export_freebusy_pass = NULL;
 
        if (vcal_folder_lock_count) /* blocked */
                return;
        vcal_folder_lock_count++;
+       
+       export_pass = password_decrypt(vcalprefs.export_pass, NULL);
+       export_freebusy_pass = password_decrypt(vcalprefs.export_freebusy_pass, NULL);
+
        if (vcal_meeting_export_calendar(vcalprefs.export_path, 
                        vcalprefs.export_user, 
-                       vcalprefs.export_pass,
+                       export_pass,
                        TRUE)) {
                debug_print("exporting calendar\n");
                if (vcalprefs.export_enable &&
@@ -1185,9 +1192,13 @@ void vcal_folder_export(Folder *folder)
                        execute_command_line(
                                vcalprefs.export_command, TRUE);
        }
+       if (export_pass != NULL) {
+               memset(export_pass, 0, strlen(export_pass));
+       }
+       g_free(export_pass);
        if (vcal_meeting_export_freebusy(vcalprefs.export_freebusy_path,
                        vcalprefs.export_freebusy_user,
-                       vcalprefs.export_freebusy_pass)) {
+                       export_freebusy_pass)) {
                debug_print("exporting freebusy\n");
                if (vcalprefs.export_freebusy_enable &&
                    vcalprefs.export_freebusy_command &&
@@ -1195,6 +1206,10 @@ void vcal_folder_export(Folder *folder)
                        execute_command_line(
                                vcalprefs.export_freebusy_command, TRUE);
        }
+       if (export_freebusy_pass != NULL) {
+               memset(export_freebusy_pass, 0, strlen(export_freebusy_pass));
+       }
+       g_free(export_freebusy_pass);
        vcal_folder_lock_count--;
        if (!need_scan && folder) {
                vcal_set_mtime(folder, folder->inbox);
index 2b99c08..0c7a36c 100644 (file)
@@ -2127,7 +2127,7 @@ putfile:
                        file = tmp;
                }
                if (fp) {
-                       res = vcal_curl_put(file, fp, filesize, user, pass);
+                       res = vcal_curl_put(file, fp, filesize, user, (pass != NULL ? pass : ""));
                        fclose(fp);
                }
                g_free(file);
@@ -2275,7 +2275,7 @@ gboolean vcal_meeting_export_freebusy(const gchar *path, const gchar *user,
                        file = tmp;
                }
                if (fp) {
-                       res = vcal_curl_put(file, fp, filesize, user, pass);
+                       res = vcal_curl_put(file, fp, filesize, user, (pass != NULL ? pass : ""));
                        fclose(fp);
                }
                g_free(file);
index 4d42040..06c6fd4 100644 (file)
@@ -30,6 +30,7 @@
 #include "defs.h"
 
 #include "mainwindow.h"
+#include "password.h"
 #include "prefs.h"
 #include "prefs_gtk.h"
 #include "prefswindow.h"
@@ -268,6 +269,8 @@ static void vcal_prefs_create_widget_func(PrefsPage * _page,
 
        GtkWidget *frame_ssl_options;
        GtkWidget *ssl_verify_peer_checkbtn;
+       gchar *export_pass = NULL;
+       gchar *export_freebusy_pass = NULL;
 
        vbox1 = gtk_vbox_new (FALSE, VSPACING);
        gtk_widget_show (vbox1);
@@ -559,10 +562,23 @@ 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);
+       
        gtk_entry_set_text(GTK_ENTRY(export_user_entry), vcalprefs.export_user);
-       gtk_entry_set_text(GTK_ENTRY(export_pass_entry), vcalprefs.export_pass);
+       gtk_entry_set_text(GTK_ENTRY(export_pass_entry), (export_pass != NULL ? export_pass : ""));
        gtk_entry_set_text(GTK_ENTRY(export_freebusy_user_entry), vcalprefs.export_freebusy_user);
-       gtk_entry_set_text(GTK_ENTRY(export_freebusy_pass_entry), vcalprefs.export_freebusy_pass);
+       gtk_entry_set_text(GTK_ENTRY(export_freebusy_pass_entry), (export_freebusy_pass != NULL ? export_freebusy_pass : ""));
+
+       if (export_pass != NULL) {
+               memset(export_pass, 0, strlen(export_pass));
+       }
+       g_free(export_pass);
+
+       if (export_freebusy_pass != NULL) {
+               memset(export_freebusy_pass, 0, strlen(export_freebusy_pass));
+       }
+       g_free(export_freebusy_pass);
 
        g_signal_connect(G_OBJECT(export_enable_checkbtn),
                         "toggled", G_CALLBACK(path_changed), page);