~ubuntu-branches/debian/sid/claws-mail/sid

« back to all changes in this revision

Viewing changes to src/procmsg.c

  • Committer: Package Import Robot
  • Author(s): Ricardo Mones
  • Date: 2015-08-18 16:37:25 UTC
  • mfrom: (1.3.7)
  • Revision ID: package-import@ubuntu.com-20150818163725-1it32n9mzqkwy2ef
Tags: 3.12.0-1
* New upstream release:
- 'cannot reorganize mailboxes' (Closes: #777208)
- 'dropdown menu bar has disappeared…'(Closes: #778886)
- 'depends on plugins libraries'  (Closes: #779824)
- 'new upstream version (3.12.0)…' (Closes: #793665)
* 14CVE_2010_5109.patch, 15fix_crash_open_folder.patch,
  13desktop_file_categories.patch
- Remove patches applied upstream
* debian/control, debian/copyright, debian/claws-mail-managesieve*
- Add managesieve plugin (new in this release)
* debian/rules
- Set perl-plugin manpage release version automatically
* 12fix_manpage_header.patch
- Update patch to cope with upstream changes
* debian/control, debian/watch
- Update VCS-* and watch URLs (thanks Julian Wollrath)

Show diffs side-by-side

added added

removed removed

Lines of Context:
402
402
 
403
403
gchar *procmsg_get_message_file_path(MsgInfo *msginfo)
404
404
{
405
 
        gchar *file;
406
 
 
407
405
        cm_return_val_if_fail(msginfo != NULL, NULL);
408
406
 
409
 
        if (msginfo->plaintext_file)
410
 
                file = g_strdup(msginfo->plaintext_file);
411
 
        else {
412
 
                file = folder_item_fetch_msg(msginfo->folder, msginfo->msgnum);
413
 
        }
414
 
 
415
 
        return file;
 
407
        return folder_item_fetch_msg(msginfo->folder, msginfo->msgnum);
416
408
}
417
409
 
418
410
gchar *procmsg_get_message_file(MsgInfo *msginfo)
1136
1128
        return 0;
1137
1129
}
1138
1130
 
1139
 
static gint procmsg_save_to_outbox(FolderItem *outbox, const gchar *file,
 
1131
gint procmsg_save_to_outbox(FolderItem *outbox, const gchar *file,
1140
1132
                            gboolean is_queued)
1141
1133
{
1142
1134
        gint num;
1514
1506
static gint procmsg_send_message_queue_full(const gchar *file, gboolean keep_session, gchar **errstr,
1515
1507
                                            FolderItem *queue, gint msgnum, gboolean *queued_removed)
1516
1508
{
1517
 
        static HeaderEntry qentry[] = {{"S:",    NULL, FALSE},
 
1509
        static HeaderEntry qentry[] = {
 
1510
                                       {"S:",    NULL, FALSE}, /* 0 */
1518
1511
                                       {"SSV:",  NULL, FALSE},
1519
1512
                                       {"R:",    NULL, FALSE},
1520
1513
                                       {"NG:",   NULL, FALSE},
1521
1514
                                       {"MAID:", NULL, FALSE},
1522
 
                                       {"NAID:", NULL, FALSE},
 
1515
                                       {"NAID:", NULL, FALSE}, /* 5 */
1523
1516
                                       {"SCF:",  NULL, FALSE},
1524
1517
                                       {"RMID:", NULL, FALSE},
1525
1518
                                       {"FMID:", NULL, FALSE},
1526
1519
                                       {"X-Claws-Privacy-System:", NULL, FALSE},
1527
 
                                       {"X-Claws-Encrypt:", NULL, FALSE},
 
1520
                                       {"X-Claws-Encrypt:", NULL, FALSE}, /* 10 */
1528
1521
                                       {"X-Claws-Encrypt-Data:", NULL, FALSE},
1529
1522
                                       {"X-Claws-End-Special-Headers:", NULL, FALSE},
1530
1523
                                       {"X-Sylpheed-Privacy-System:", NULL, FALSE},
1531
1524
                                       {"X-Sylpheed-Encrypt:", NULL, FALSE},
1532
 
                                       {"X-Sylpheed-Encrypt-Data:", NULL, FALSE},
 
1525
                                       {"X-Sylpheed-Encrypt-Data:", NULL, FALSE}, /* 15 */
1533
1526
                                       {"X-Sylpheed-End-Special-Headers:", NULL, FALSE},
1534
1527
                                       {NULL,    NULL, FALSE}};
1535
1528
        FILE *fp;
1542
1535
        gchar *savecopyfolder = NULL;
1543
1536
        gchar *replymessageid = NULL;
1544
1537
        gchar *fwdmessageid = NULL;
1545
 
        gchar *privacy_system = NULL;
1546
 
        gboolean encrypt = FALSE;
1547
 
        gchar *encrypt_data = NULL;
1548
1538
        gchar buf[BUFFSIZE];
1549
1539
        gint hnum;
1550
1540
        PrefsAccount *mailac = NULL, *newsac = NULL;
1551
 
        gboolean save_clear_text = TRUE;
1552
 
        gchar *tmp_enc_file = NULL;
 
1541
        gboolean encrypt = FALSE;
 
1542
        FolderItem *outbox;
1553
1543
 
1554
1544
        cm_return_val_if_fail(file != NULL, -1);
1555
1545
 
1599
1589
                        if (fwdmessageid == NULL) 
1600
1590
                                fwdmessageid = g_strdup(p);
1601
1591
                        break;
1602
 
                case Q_PRIVACY_SYSTEM:
1603
 
                case Q_PRIVACY_SYSTEM_OLD:
1604
 
                        if (privacy_system == NULL) 
1605
 
                                privacy_system = g_strdup(p);
1606
 
                        break;
1607
1592
                case Q_ENCRYPT:
1608
1593
                case Q_ENCRYPT_OLD:
1609
1594
                        if (p[0] == '1') 
1610
1595
                                encrypt = TRUE;
1611
1596
                        break;
1612
 
                case Q_ENCRYPT_DATA:
1613
 
                case Q_ENCRYPT_DATA_OLD:
1614
 
                        if (encrypt_data == NULL) 
1615
 
                                encrypt_data = g_strdup(p);
1616
 
                        break;
1617
1597
                case Q_CLAWS_HDRS:
1618
1598
                case Q_CLAWS_HDRS_OLD:
1619
1599
                        /* end of special headers reached */
1631
1611
                return -1;
1632
1612
        }
1633
1613
 
1634
 
        if (encrypt) {
1635
 
                MimeInfo *mimeinfo;
1636
 
 
1637
 
                if (mailac && mailac->save_encrypted_as_clear_text 
1638
 
                &&  !mailac->encrypt_to_self)
1639
 
                        save_clear_text = TRUE;
1640
 
                else
1641
 
                        save_clear_text = FALSE;
1642
 
 
1643
 
                fclose(fp);
1644
 
                fp = NULL;
1645
 
 
1646
 
                mimeinfo = procmime_scan_queue_file(file);
1647
 
                if (!privacy_encrypt(privacy_system, mimeinfo, encrypt_data)
1648
 
                || (fp = my_tmpfile()) == NULL
1649
 
                ||  procmime_write_mimeinfo(mimeinfo, fp) < 0) {
1650
 
                        if (fp)
1651
 
                                fclose(fp);
1652
 
                        procmime_mimeinfo_free_all(mimeinfo);
1653
 
                        g_free(from);
1654
 
                        g_free(smtpserver);
1655
 
                        slist_free_strings_full(to_list);
1656
 
                        slist_free_strings_full(newsgroup_list);
1657
 
                        g_free(savecopyfolder);
1658
 
                        g_free(replymessageid);
1659
 
                        g_free(fwdmessageid);
1660
 
                        g_free(privacy_system);
1661
 
                        g_free(encrypt_data);
1662
 
                        if (errstr) {
1663
 
                                if (*errstr) g_free(*errstr);
1664
 
                                *errstr = g_strdup_printf(_("Couldn't encrypt the email: %s"),
1665
 
                                                privacy_get_error());
1666
 
                        }
1667
 
                        return -1;
1668
 
                }
1669
 
                
1670
 
                rewind(fp);
1671
 
                if (!save_clear_text) {
1672
 
                        gchar *content = NULL;
1673
 
                        FILE *tmpfp = get_tmpfile_in_dir(get_mime_tmp_dir(), &tmp_enc_file);
1674
 
                        if (tmpfp) {
1675
 
                                fclose(tmpfp);
1676
 
 
1677
 
                                content = file_read_stream_to_str(fp);
1678
 
                                rewind(fp);
1679
 
 
1680
 
                                str_write_to_file(content, tmp_enc_file);
1681
 
                                g_free(content);
1682
 
                        } else {
1683
 
                                g_warning("couldn't get tempfile\n");
1684
 
                        }
1685
 
                } 
1686
 
                
1687
 
                procmime_mimeinfo_free_all(mimeinfo);
1688
 
                
1689
 
                filepos = 0;
1690
 
        }
1691
 
 
1692
1614
        if (to_list) {
1693
1615
                debug_print("Sending message by mail\n");
1694
1616
                if (!from) {
1809
1731
 
1810
1732
        /* save message to outbox */
1811
1733
        if (mailval == 0 && newsval == 0 && savecopyfolder) {
1812
 
                FolderItem *outbox;
1813
 
 
1814
1734
                debug_print("saving sent message...\n");
1815
1735
 
1816
 
                outbox = folder_find_item_from_identifier(savecopyfolder);
1817
 
                if (!outbox)
1818
 
                        outbox = folder_get_default_outbox();
1819
 
                        
1820
 
                if (save_clear_text || tmp_enc_file == NULL) {
 
1736
                if (!encrypt || !mailac->save_encrypted_as_clear_text) {
 
1737
                        outbox = folder_find_item_from_identifier(savecopyfolder);
 
1738
                        if (!outbox)
 
1739
                                outbox = folder_get_default_outbox();
 
1740
 
 
1741
                        /* Mail was not saved to outbox before encrypting, save it now. */
1821
1742
                        gboolean saved = FALSE;
1822
1743
                        *queued_removed = FALSE;
1823
1744
                        if (queue && msgnum > 0) {
1833
1754
                                procmsg_msginfo_free(queued_mail);
1834
1755
                        }
1835
1756
                        if (!saved) {
1836
 
                                debug_print("resaving clear text queued mail to sent folder\n");
 
1757
                                debug_print("resaving queued mail to sent folder\n");
1837
1758
                                procmsg_save_to_outbox(outbox, file, TRUE);
1838
1759
                        }
1839
 
                } else {
1840
 
                        debug_print("saving encrpyted queued mail to sent folder\n");
1841
 
                        procmsg_save_to_outbox(outbox, tmp_enc_file, FALSE);
1842
1760
                }
1843
1761
        }
1844
1762
 
1845
 
        if (tmp_enc_file != NULL) {
1846
 
                claws_unlink(tmp_enc_file);
1847
 
                free(tmp_enc_file);
1848
 
                tmp_enc_file = NULL;
1849
 
        }
1850
 
 
1851
1763
        if (replymessageid != NULL || fwdmessageid != NULL) {
1852
1764
                gchar **tokens;
1853
1765
                FolderItem *item;
1901
1813
        g_free(savecopyfolder);
1902
1814
        g_free(replymessageid);
1903
1815
        g_free(fwdmessageid);
1904
 
        g_free(privacy_system);
1905
 
        g_free(encrypt_data);
1906
1816
 
1907
1817
        return (newsval != 0 ? newsval : mailval);
1908
1818
}