Fix some memory leaks
[claws.git] / src / compose.c
index 2acc299ab6a55787dda57823e0ed118221820940..495d89ad7eeb36b17d9e8c2b5478152e025cf44c 100644 (file)
@@ -84,6 +84,7 @@
 #include "customheader.h"
 #include "prefs_common.h"
 #include "prefs_account.h"
+#include "prefs_actions.h"
 #include "account.h"
 #include "filesel.h"
 #include "procheader.h"
 #include "template.h"
 #include "undo.h"
 #include "foldersel.h"
-#include "prefs_actions.h"
 
 #if USE_GPGME
 #  include "rfc2015.h"
@@ -650,12 +650,12 @@ static GtkItemFactoryEntry compose_entries[] =
        {N_("/_Message/_Encrypt"),      NULL, compose_toggle_encrypt_cb, 0, "<ToggleItem>"},
 #endif /* USE_GPGME */
        {N_("/_Message/---"),           NULL,           NULL,   0, "<Separator>"},
-       {N_("/_Message/Priority"),      NULL,           NULL,   0, "<Branch>"},
-       {N_("/_Message/Priority/Highest"), NULL, compose_set_priority_cb, PRIORITY_HIGHEST, "<RadioItem>"},
-       {N_("/_Message/Priority/High"),    NULL, compose_set_priority_cb, PRIORITY_HIGH, "/Message/Priority/Highest"},
-       {N_("/_Message/Priority/Normal"),  NULL, compose_set_priority_cb, PRIORITY_NORMAL, "/Message/Priority/Highest"},
-       {N_("/_Message/Priority/Low"),     NULL, compose_set_priority_cb, PRIORITY_LOW, "/Message/Priority/Highest"},
-       {N_("/_Message/Priority/Lowest"),  NULL, compose_set_priority_cb, PRIORITY_LOWEST, "/Message/Priority/Highest"},
+       {N_("/_Message/_Priority"),     NULL,           NULL,   0, "<Branch>"},
+       {N_("/_Message/Priority/_Highest"), NULL, compose_set_priority_cb, PRIORITY_HIGHEST, "<RadioItem>"},
+       {N_("/_Message/Priority/Hi_gh"),    NULL, compose_set_priority_cb, PRIORITY_HIGH, "/Message/Priority/Highest"},
+       {N_("/_Message/Priority/_Normal"),  NULL, compose_set_priority_cb, PRIORITY_NORMAL, "/Message/Priority/Highest"},
+       {N_("/_Message/Priority/Lo_w"),    NULL, compose_set_priority_cb, PRIORITY_LOW, "/Message/Priority/Highest"},
+       {N_("/_Message/Priority/_Lowest"),  NULL, compose_set_priority_cb, PRIORITY_LOWEST, "/Message/Priority/Highest"},
        {N_("/_Message/---"),           NULL,           NULL,   0, "<Separator>"},
        {N_("/_Message/_Request Return Receipt"),       NULL, compose_toggle_return_receipt_cb, 0, "<ToggleItem>"},
        {N_("/_Tools"),                 NULL, NULL, 0, "<Branch>"},
@@ -923,14 +923,8 @@ static void compose_generic_reply(MsgInfo *msginfo, gboolean quote,
        } else
                reply_account = account;
 
-       MSG_UNSET_PERM_FLAGS(msginfo->flags, MSG_FORWARDED);
-       MSG_SET_PERM_FLAGS(msginfo->flags, MSG_REPLIED);
-       if (MSG_IS_IMAP(msginfo->flags))
-               imap_msg_set_perm_flags(msginfo, MSG_REPLIED);
-       CHANGE_FLAGS(msginfo);
-
        compose = compose_create(account, COMPOSE_REPLY);
-       compose->replyinfo = procmsg_msginfo_copy(msginfo);
+       compose->replyinfo = procmsg_msginfo_new_ref(msginfo);
 
 #if 0 /* NEW COMPOSE GUI */
        if (followup_and_reply_to) {
@@ -2652,7 +2646,7 @@ gboolean compose_check_for_valid_recipient(Compose *compose) {
        for(list = compose->header_list; list; list = list->next) {
                gchar *header;
                gchar *entry;
-               header = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(((ComposeHeaderEntry *)list->data)->combo)->entry));
+               header = gtk_editable_get_chars(GTK_EDITABLE(GTK_COMBO(((ComposeHeaderEntry *)list->data)->combo)->entry), 0, -1);
                entry = gtk_editable_get_chars(GTK_EDITABLE(((ComposeHeaderEntry *)list->data)->entry), 0, -1);
                g_strstrip(entry);
                if(entry[0] != '\0') {
@@ -2669,6 +2663,7 @@ gboolean compose_check_for_valid_recipient(Compose *compose) {
                                }
                        }
                }
+               g_free(header);
                g_free(entry);
        }
        return recipient_found;
@@ -3178,7 +3173,7 @@ static gint compose_write_to_file(Compose *compose, const gchar *file,
 
                for (i = 0; i < len; i += B64_LINE_SIZE) {
                        l = MIN(B64_LINE_SIZE, len - i);
-                       to64frombits(outbuf, buf + i, l);
+                       base64_encode(outbuf, buf + i, l);
                        fputs(outbuf, fp);
                        fputc('\n', fp);
                }
@@ -3432,11 +3427,19 @@ static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item,
        }
        /* Save copy folder */
        if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(compose->savemsg_checkbtn))) {
-               gchar *str;
+               gchar *savefolderid;
+               
+               savefolderid = gtk_editable_get_chars(GTK_EDITABLE(compose->savemsg_entry), 0, -1);
+               fprintf(fp, "SCF:%s\n", savefolderid);
+               g_free(savefolderid);
+       }
+       /* Message-ID of message replying to */
+       if((compose->replyinfo != NULL) && (compose->replyinfo->msgid != NULL)) {
+               gchar *folderid;
                
-               str = gtk_editable_get_chars(GTK_EDITABLE(compose->savemsg_entry), 0, -1);
-               fprintf(fp, "SCF:%s\n", str);
-               g_free(str);
+               folderid = folder_item_get_identifier(compose->replyinfo->folder);
+               fprintf(fp, "RMID:%s\x7f%d\x7f%s\n", folderid, compose->replyinfo->msgnum, compose->replyinfo->msgid);
+               g_free(folderid);
        }
        fprintf(fp, "\n");
 
@@ -3553,12 +3556,12 @@ static void compose_write_attach(Compose *compose, FILE *fp)
                        while ((len = fread(inbuf, sizeof(gchar),
                                            B64_LINE_SIZE, attach_fp))
                               == B64_LINE_SIZE) {
-                               to64frombits(outbuf, inbuf, B64_LINE_SIZE);
+                               base64_encode(outbuf, inbuf, B64_LINE_SIZE);
                                fputs(outbuf, fp);
                                fputc('\n', fp);
                        }
                        if (len > 0 && feof(attach_fp)) {
-                               to64frombits(outbuf, inbuf, len);
+                               base64_encode(outbuf, inbuf, len);
                                fputs(outbuf, fp);
                                fputc('\n', fp);
                        }
@@ -4661,7 +4664,7 @@ static Compose *compose_create(PrefsAccount *account, ComposeMode mode)
                        GtkWidget *menuitem;
 
                        if (!gtkpspell_set_sug_mode(gtkpspell, prefs_common.pspell_sugmode)) {
-                               debug_print(_("Pspell: could not set suggestion mode %s"),
+                               debug_print(_("Pspell: could not set suggestion mode %s\n"),
                                    gtkpspellcheckers->error_message);
                                gtkpspell_checkers_reset_error();
                        }