SpamReport: use new password API
authorColin Leroy <colin@colino.net>
Thu, 11 Feb 2016 10:33:19 +0000 (11:33 +0100)
committerColin Leroy <colin@colino.net>
Thu, 11 Feb 2016 10:33:19 +0000 (11:33 +0100)
src/plugins/spam_report/claws.def
src/plugins/spam_report/spam_report.c
src/plugins/spam_report/spam_report_prefs.c

index 15f8289b4adcb6e7ec788c8614c8054161e913e8..723dae8a2db008072bfb60ffae0f30d24fa46664 100644 (file)
@@ -33,6 +33,7 @@ matcherlist_free
 matcherlist_match
 matcherlist_new
 matcherprop_new
+password_decrypt
 pref_get_escaped_pref
 pref_get_unescaped_pref
 prefs_common
index a194138795bf7e45c590581d001b3ed18487b7aa..ce2fadc9674095ff5a98db0fa7329bbe833e4778 100644 (file)
@@ -32,6 +32,7 @@
 #include "common/claws.h"
 #include "common/version.h"
 #include "main.h"
+#include "password.h"
 #include "plugin.h"
 #include "prefs_common.h"
 #include "utils.h"
@@ -221,7 +222,12 @@ static void report_spam(gint id, ReportInterface *intf, MsgInfo *msginfo, gchar
        switch(intf->type) {
        case INTF_HTTP_AUTH:
                if (spamreport_prefs.user[id] && *(spamreport_prefs.user[id])) {
-                       auth = g_strdup_printf("%s:%s", spamreport_prefs.user[id], spamreport_prefs.pass[id]);
+                       gchar *pass = password_decrypt(spamreport_prefs.pass[id], NULL);
+                       auth = g_strdup_printf("%s:%s", spamreport_prefs.user[id], (pass != NULL ? pass : ""));
+                       if (pass != NULL) {
+                               memset(pass, 0, strlen(pass));
+                       }
+                       g_free(pass);
 
                        curl = curl_easy_init();
                        curl_easy_setopt(curl, CURLOPT_URL, intf->url);
index 772bd57769327881f724828ea73bf6cc5465d0e6..f2353e7a8cfbe88565011dad448861986a8d7d68 100644 (file)
@@ -30,6 +30,7 @@
 #include <gtk/gtk.h>
 
 #include "gtkutils.h"
+#include "password.h"
 #include "prefs.h"
 #include "prefs_gtk.h"
 #include "prefswindow.h"
@@ -114,6 +115,7 @@ static void create_spamreport_prefs_page(PrefsPage *page,
        gtk_widget_show(vbox);
        
        for (i = 0; i < INTF_LAST; i++) {
+               gchar *pass;
                prefs_page->frame[i] = gtk_frame_new(spam_interfaces[i].name);
                gtk_box_pack_start(GTK_BOX(vbox), prefs_page->frame[i], FALSE, FALSE, 6);
 
@@ -125,8 +127,13 @@ static void create_spamreport_prefs_page(PrefsPage *page,
 
                gtk_entry_set_text(GTK_ENTRY(prefs_page->user_entry[i]),
                        spamreport_prefs.user[i] ? spamreport_prefs.user[i]:"");
-               gtk_entry_set_text(GTK_ENTRY(prefs_page->pass_entry[i]),
-                       spamreport_prefs.pass[i] ? spamreport_prefs.pass[i]:"");
+
+               pass = password_decrypt(spamreport_prefs.pass[i], NULL);
+               gtk_entry_set_text(GTK_ENTRY(prefs_page->pass_entry[i]), pass ? pass:"");
+               if (pass != NULL) {
+                       memset(pass, 0, strlen(pass));
+               }
+               g_free(pass);
                gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prefs_page->enabled_chkbtn[i]),
                        spamreport_prefs.enabled[i]);