replace deprecated g_memmove with memmove
[claws.git] / src / plugins / pgpinline / pgpinline.c
index 4f8e789f23cd798871970ca21f1c47284f89b92d..c5a05fb99b6830b403b0c8de2f6dc0b62acacb45 100644 (file)
@@ -28,7 +28,7 @@
 #include <glib/gi18n.h>
 #include <errno.h>
 #include <gpgme.h>
-#include <claws_io.h>
+#include <file-utils.h>
 
 #include "utils.h"
 #include "privacy.h"
@@ -115,7 +115,7 @@ static gboolean pgpinline_is_signed(MimeInfo *mimeinfo)
                        return data->is_signed;
        }
        
-       textdata = get_part_as_string(mimeinfo);
+       textdata = procmime_get_part_as_string(mimeinfo, TRUE);
        if (!textdata)
                return FALSE;
        
@@ -164,7 +164,7 @@ static gint pgpinline_check_signature(MimeInfo *mimeinfo)
        cm_return_val_if_fail(mimeinfo->privacy != NULL, 0);
        data = (PrivacyDataPGP *) mimeinfo->privacy;
 
-       textdata = get_part_as_string(mimeinfo);
+       textdata = procmime_get_part_as_string(mimeinfo, TRUE);
 
        if (!textdata) {
                g_free(textdata);
@@ -265,7 +265,7 @@ static gboolean pgpinline_is_encrypted(MimeInfo *mimeinfo)
                mimeinfo->subtype = g_strdup("plain");
        }
 
-       textdata = get_part_as_string(mimeinfo);
+       textdata = procmime_get_part_as_string(mimeinfo, TRUE);
        if (!textdata)
                return FALSE;
 
@@ -317,7 +317,7 @@ static MimeInfo *pgpinline_decrypt(MimeInfo *mimeinfo)
                return NULL;
        }
 
-       textdata = get_part_as_string(mimeinfo);
+       textdata = procmime_get_part_as_string(mimeinfo, TRUE);
        if (!textdata) {
                gpgme_release(ctx);
                privacy_set_error(_("Couldn't get text data."));
@@ -341,8 +341,8 @@ static MimeInfo *pgpinline_decrypt(MimeInfo *mimeinfo)
        fname = g_strdup_printf("%s%cplaintext.%08x",
                get_mime_tmp_dir(), G_DIR_SEPARATOR, ++id);
 
-       if ((dstfp = g_fopen(fname, "wb")) == NULL) {
-               FILE_OP_ERROR(fname, "fopen");
+       if ((dstfp = claws_fopen(fname, "wb")) == NULL) {
+               FILE_OP_ERROR(fname, "claws_fopen");
                privacy_set_error(_("Couldn't open decrypted file %s"), fname);
                g_free(fname);
                gpgme_data_release(plain);
@@ -367,24 +367,24 @@ static MimeInfo *pgpinline_decrypt(MimeInfo *mimeinfo)
        /* Store any part before encrypted text */
        pos = pgp_locate_armor_header(textdata, begin_indicator);
        if (pos != NULL && (pos - textdata) > 0) {
-           if (fwrite(textdata, 1, pos - textdata, dstfp) < pos - textdata) {
-               FILE_OP_ERROR(fname, "fwrite");
+           if (claws_fwrite(textdata, 1, pos - textdata, dstfp) < pos - textdata) {
+               FILE_OP_ERROR(fname, "claws_fwrite");
                privacy_set_error(_("Couldn't write to decrypted file %s"), fname);
                goto FILE_ERROR;
            }
        }
        
-       if (fwrite(_("\n--- Start of PGP/Inline encrypted data ---\n"), 1,
+       if (claws_fwrite(_("\n--- Start of PGP/Inline encrypted data ---\n"), 1,
                strlen(_("\n--- Start of PGP/Inline encrypted data ---\n")), 
                dstfp) < strlen(_("\n--- Start of PGP/Inline encrypted data ---\n"))) {
-               FILE_OP_ERROR(fname, "fwrite");
+               FILE_OP_ERROR(fname, "claws_fwrite");
                privacy_set_error(_("Couldn't write to decrypted file %s"), fname);
                goto FILE_ERROR;
        }
        chars = sgpgme_data_release_and_get_mem(plain, &len);
        if (len > 0) {
-               if (fwrite(chars, 1, len, dstfp) < len) {
-                       FILE_OP_ERROR(fname, "fwrite");
+               if (claws_fwrite(chars, 1, len, dstfp) < len) {
+                       FILE_OP_ERROR(fname, "claws_fwrite");
                        g_free(chars);
                        privacy_set_error(_("Couldn't write to decrypted file %s"), fname);
                        goto FILE_ERROR;
@@ -392,10 +392,10 @@ static MimeInfo *pgpinline_decrypt(MimeInfo *mimeinfo)
        }
        g_free(chars);
        /* Store any part after encrypted text */
-       if (fwrite(_("--- End of PGP/Inline encrypted data ---\n"), 1,
+       if (claws_fwrite(_("--- End of PGP/Inline encrypted data ---\n"), 1,
                strlen(_("--- End of PGP/Inline encrypted data ---\n")), 
                dstfp) < strlen(_("--- End of PGP/Inline encrypted data ---\n"))) {
-                       FILE_OP_ERROR(fname, "fwrite");
+                       FILE_OP_ERROR(fname, "claws_fwrite");
                        privacy_set_error(_("Couldn't write to decrypted file %s"), fname);
                        goto FILE_ERROR;
        }
@@ -403,16 +403,16 @@ static MimeInfo *pgpinline_decrypt(MimeInfo *mimeinfo)
            pos = pgp_locate_armor_header(pos, end_indicator);
            if (pos != NULL && *pos != '\0') {
                pos += strlen(end_indicator);
-               if (fwrite(pos, 1, strlen(pos), dstfp) < strlen(pos)) {
-                       FILE_OP_ERROR(fname, "fwrite");
+               if (claws_fwrite(pos, 1, strlen(pos), dstfp) < strlen(pos)) {
+                       FILE_OP_ERROR(fname, "claws_fwrite");
                        privacy_set_error(_("Couldn't write to decrypted file %s"), fname);
                        goto FILE_ERROR;
                }
            }
        }
 
-       if (safe_fclose(dstfp) == EOF) {
-               FILE_OP_ERROR(fname, "fclose");
+       if (claws_safe_fclose(dstfp) == EOF) {
+               FILE_OP_ERROR(fname, "claws_fclose");
                privacy_set_error(_("Couldn't close decrypted file %s"), fname);
                g_free(fname);
                gpgme_data_release(plain);
@@ -463,7 +463,7 @@ static MimeInfo *pgpinline_decrypt(MimeInfo *mimeinfo)
        return decinfo;
 
 FILE_ERROR:
-       fclose(dstfp);
+       claws_fclose(dstfp);
        g_free(fname);
        gpgme_data_release(plain);
        gpgme_release(ctx);
@@ -508,9 +508,9 @@ static gboolean pgpinline_sign(MimeInfo *mimeinfo, PrefsAccount *account, const
        rewind(fp);
 
        /* read temporary file into memory */
-       textstr = fp_read_noconv(fp);
+       textstr = file_read_stream_to_str_no_recode(fp);
        
-       fclose(fp);
+       claws_fclose(fp);
                
        gpgme_data_new_from_mem(&gpgtext, textstr, (size_t)strlen(textstr), 0);
        gpgme_data_new(&gpgsig);
@@ -586,7 +586,7 @@ static gboolean pgpinline_sign(MimeInfo *mimeinfo, PrefsAccount *account, const
        }
 
        tmp = g_malloc(len+1);
-       g_memmove(tmp, sigcontent, len+1);
+       memmove(tmp, sigcontent, len+1);
        tmp[len] = '\0';
        gpgme_data_release(gpgtext);
        g_free(textstr);
@@ -702,9 +702,9 @@ static gboolean pgpinline_encrypt(MimeInfo *mimeinfo, const gchar *encrypt_data)
        rewind(fp);
 
        /* read temporary file into memory */
-       textstr = fp_read_noconv(fp);
+       textstr = file_read_stream_to_str_no_recode(fp);
        
-       fclose(fp);
+       claws_fclose(fp);
 
        /* encrypt data */
        gpgme_data_new_from_mem(&gpgtext, textstr, (size_t)strlen(textstr), 0);
@@ -733,7 +733,7 @@ static gboolean pgpinline_encrypt(MimeInfo *mimeinfo, const gchar *encrypt_data)
        }
 
        tmp = g_malloc(len+1);
-       g_memmove(tmp, enccontent, len+1);
+       memmove(tmp, enccontent, len+1);
        tmp[len] = '\0';
        g_free(enccontent);