2007-07-26 [colin] 2.10.0cvs68
authorColin Leroy <colin@colino.net>
Thu, 26 Jul 2007 16:32:02 +0000 (16:32 +0000)
committerColin Leroy <colin@colino.net>
Thu, 26 Jul 2007 16:32:02 +0000 (16:32 +0000)
* src/ldapserver.c
Fix possible crash on cache invalidation
* src/compose.c
* src/procmime.c
* src/procmime.h
* src/quote_fmt_parse.y
Make replying to mails with big attachments
much faster. Fixes bug 1224, 'The process of
Replying to emails with large attachments
seems unreasonably long...'

ChangeLog
PATCHSETS
configure.ac
src/compose.c
src/ldapserver.c
src/procmime.c
src/procmime.h
src/quote_fmt_parse.y

index c526e1e3aab719b496565be7354d293fec16197f..3b8277e07fe07536267eae11d82b09beea57f314 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2007-07-26 [colin]     2.10.0cvs68
+
+       * src/ldapserver.c
+               Fix possible crash on cache invalidation
+       * src/compose.c
+       * src/procmime.c
+       * src/procmime.h
+       * src/quote_fmt_parse.y
+               Make replying to mails with big attachments
+               much faster. Fixes bug 1224, 'The process of 
+               Replying to emails with large attachments 
+               seems unreasonably long...'
+
 2007-07-26 [colin]     2.10.0cvs67
 
        * src/mimeview.c
index 4981a30c419ddd92642f59a9c71beba9bc397ca6..6c804e2db2e15e919a81b6192c5f4ce0c4d3cbff 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.654.2.2774 -r 1.654.2.2775 configure.ac;  ) > 2.10.0cvs65.patchset
 ( cvs diff -u -r 1.12.2.38 -r 1.12.2.39 src/gtk/prefswindow.c;  ) > 2.10.0cvs66.patchset
 ( cvs diff -u -r 1.83.2.113 -r 1.83.2.114 src/mimeview.c;  cvs diff -u -r 1.75.2.43 -r 1.75.2.44 src/matcher.c;  cvs diff -u -r 1.9.2.20 -r 1.9.2.21 src/common/ssl.c;  ) > 2.10.0cvs67.patchset
+( cvs diff -u -r 1.382.2.395 -r 1.382.2.396 src/compose.c;  cvs diff -u -r 1.4.2.10 -r 1.4.2.11 src/ldapserver.c;  cvs diff -u -r 1.49.2.93 -r 1.49.2.94 src/procmime.c;  cvs diff -u -r 1.17.2.18 -r 1.17.2.19 src/procmime.h;  cvs diff -u -r 1.22.2.34 -r 1.22.2.35 src/quote_fmt_parse.y;  ) > 2.10.0cvs68.patchset
index 1e42f32900882e52989b9f7bb5c0e6f75baf60a5..5ebfdc4e7712ae71d313fe07593615ce4b451885 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=10
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=67
+EXTRA_VERSION=68
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index e84cc11b97c3d8dd17f6b1ae616c12e29bb0db00..9bbddbe161ab579237d2fd2ebb30871cee45fd58 100644 (file)
 #include "combobox.h"
 #include "hooks.h"
 #include "privacy.h"
+#include "timing.h"
 
 enum
 {
@@ -1359,7 +1360,7 @@ static void compose_extract_original_charset(Compose *compose)
                info = compose->targetinfo;
        }
        if (info) {
-               MimeInfo *mimeinfo = procmime_scan_message(info);
+               MimeInfo *mimeinfo = procmime_scan_message_short(info);
                MimeInfo *partinfo = mimeinfo;
                while (partinfo && partinfo->type != MIMETYPE_TEXT)
                        partinfo = procmime_mimeinfo_next(partinfo);
@@ -1405,7 +1406,7 @@ static Compose *compose_generic_reply(MsgInfo *msginfo,
        gboolean quote = FALSE;
        const gchar *qmark = NULL;
        const gchar *body_fmt = NULL;
-
+       START_TIMING("");
        g_return_val_if_fail(msginfo != NULL, NULL);
        g_return_val_if_fail(msginfo->folder != NULL, NULL);
 
@@ -1482,7 +1483,8 @@ static Compose *compose_generic_reply(MsgInfo *msginfo,
                                          _("Message reply format error at line %d."));
                quote_fmt_reset_vartable();
        }
-       if (procmime_msginfo_is_encrypted(compose->replyinfo)) {
+
+       if (MSG_IS_ENCRYPTED(compose->replyinfo->flags)) {
                compose_force_encryption(compose, account, FALSE);
        }
 
@@ -1512,7 +1514,7 @@ static Compose *compose_generic_reply(MsgInfo *msginfo,
                compose_destroy(compose);
                return NULL;
        }
-
+       END_TIMING();
        return compose;
 }
 
@@ -1998,7 +2000,7 @@ Compose *compose_reedit(MsgInfo *msginfo, gboolean batch)
                                        G_CALLBACK(compose_changed_cb),
                                        compose);
        
-       if (procmime_msginfo_is_encrypted(msginfo)) {
+       if (MSG_IS_ENCRYPTED(msginfo->flags)) {
                fp = procmime_get_first_encrypted_text_content(msginfo);
                if (fp) {
                        compose_force_encryption(compose, account, TRUE);
@@ -8419,6 +8421,10 @@ gboolean compose_draft (gpointer data, guint action)
        }
 
        newmsginfo = folder_item_get_msginfo(draft, msgnum);
+       if (!newmsginfo && compose->msgid) {
+               newmsginfo = folder_item_get_msginfo_by_msgid(draft, compose->msgid);
+               msgnum = newmsginfo->msgnum;
+       }
        if (newmsginfo) {
                procmsg_msginfo_unset_flags(newmsginfo, ~0, ~0);
                if (target_locked)
@@ -9806,9 +9812,8 @@ static void compose_reply_from_messageview_real(MessageView *msgview, GSList *ms
                                                orig_msginfo, mimeinfo);
                        if (tmp_msginfo != NULL) {
                                new_msglist = g_slist_append(NULL, tmp_msginfo);
-                               if (procmime_msginfo_is_encrypted(orig_msginfo)) {
-                                       originally_enc = TRUE;
-                               }
+
+                               originally_enc = MSG_IS_ENCRYPTED(orig_msginfo->flags);
                                tmp_msginfo->folder = orig_msginfo->folder;
                                tmp_msginfo->msgnum = orig_msginfo->msgnum; 
                                if (orig_msginfo->tags)
index b4f4e4256826ff71e4bc9f883e1d14d64c16e708..8a59212e45c496ee479926f1cee3f5651b2ab56f 100644 (file)
@@ -703,6 +703,8 @@ gint ldapsvr_read_data( LdapServer *server )
        //printf( "...addrbook_read_data :%s:\n", addrcache_get_name( server->addressCache ) );
        
        addrcache_clear(server->addressCache);
+       ldapsvr_free_all_query( server );
+       server->listQuery = NULL;
        server->addressCache->modified = FALSE;
        server->addressCache->accessFlag = FALSE;
        server->addressCache->dataRead = TRUE;
index 8e1b15a85f96c1130523b0ec1f7043135ce1105d..c8ac29cbfe61014e769b13638866849a55ab4c8f 100644 (file)
 #include "prefs_common.h"
 #include "prefs_gtk.h"
 #include "alertpanel.h"
+#include "timing.h"
 
 static GHashTable *procmime_get_mime_type_table        (void);
+static MimeInfo *procmime_scan_file_short(const gchar *filename);
+static MimeInfo *procmime_scan_queue_file_short(const gchar *filename);
+static MimeInfo *procmime_scan_queue_file_full(const gchar *filename, gboolean short_scan);
 
 MimeInfo *procmime_mimeinfo_new(void)
 {
@@ -186,7 +190,7 @@ MimeInfo *procmime_scan_message(MsgInfo *msginfo)
 {
        gchar *filename;
        MimeInfo *mimeinfo;
-
+       START_TIMING("");
        filename = procmsg_get_message_file_path(msginfo);
        if (!filename || !is_file_exist(filename)) {
                g_free(filename);
@@ -200,6 +204,28 @@ MimeInfo *procmime_scan_message(MsgInfo *msginfo)
                mimeinfo = procmime_scan_queue_file(filename);
        g_free(filename);
 
+       END_TIMING();
+       return mimeinfo;
+}
+
+MimeInfo *procmime_scan_message_short(MsgInfo *msginfo)
+{
+       gchar *filename;
+       MimeInfo *mimeinfo;
+
+       filename = procmsg_get_message_file_path(msginfo);
+       if (!filename || !is_file_exist(filename)) {
+               g_free(filename);
+               return NULL;
+       }
+
+       if (!folder_has_parent_of_type(msginfo->folder, F_QUEUE) &&
+           !folder_has_parent_of_type(msginfo->folder, F_DRAFT))
+               mimeinfo = procmime_scan_file_short(filename);
+       else
+               mimeinfo = procmime_scan_queue_file_short(filename);
+       g_free(filename);
+
        return mimeinfo;
 }
 
@@ -812,18 +838,21 @@ FILE *procmime_get_text_content(MimeInfo *mimeinfo)
        return outfp;
 }
 
+static void output_mime_structure(MimeInfo *mimeinfo, int indent);
 /* search the first text part of (multipart) MIME message,
    decode, convert it and output to outfp. */
 FILE *procmime_get_first_text_content(MsgInfo *msginfo)
 {
        FILE *outfp = NULL;
        MimeInfo *mimeinfo, *partinfo;
-
+       START_TIMING("");
        g_return_val_if_fail(msginfo != NULL, NULL);
 
-       mimeinfo = procmime_scan_message(msginfo);
+       mimeinfo = procmime_scan_message_short(msginfo);
        if (!mimeinfo) return NULL;
 
+output_mime_structure(mimeinfo, 0);
+
        partinfo = mimeinfo;
        while (partinfo && partinfo->type != MIMETYPE_TEXT) {
                partinfo = procmime_mimeinfo_next(partinfo);
@@ -832,7 +861,7 @@ FILE *procmime_get_first_text_content(MsgInfo *msginfo)
                outfp = procmime_get_text_content(partinfo);
 
        procmime_mimeinfo_free_all(mimeinfo);
-
+       END_TIMING();
        return outfp;
 }
 
@@ -1348,9 +1377,10 @@ static int procmime_parse_mimepart(MimeInfo *parent,
                             gchar *content_location,
                             const gchar *filename,
                             guint offset,
-                            guint length);
+                            guint length,
+                            gboolean short_scan);
 
-static void procmime_parse_message_rfc822(MimeInfo *mimeinfo)
+static void procmime_parse_message_rfc822(MimeInfo *mimeinfo, gboolean short_scan)
 {
        HeaderEntry hentry[] = {{"Content-Type:",  NULL, TRUE},
                                {"Content-Transfer-Encoding:",
@@ -1411,7 +1441,7 @@ static void procmime_parse_message_rfc822(MimeInfo *mimeinfo)
                                hentry[2].body, hentry[3].body,
                                hentry[4].body, hentry[5].body,
                                mimeinfo->data.filename, content_start,
-                               len);
+                               len, short_scan);
        
        for (i = 0; i < (sizeof hentry / sizeof hentry[0]); i++) {
                g_free(hentry[i].body);
@@ -1419,7 +1449,7 @@ static void procmime_parse_message_rfc822(MimeInfo *mimeinfo)
        }
 }
 
-static void procmime_parse_multipart(MimeInfo *mimeinfo)
+static void procmime_parse_multipart(MimeInfo *mimeinfo, gboolean short_scan)
 {
        HeaderEntry hentry[] = {{"Content-Type:",  NULL, TRUE},
                                {"Content-Transfer-Encoding:",
@@ -1439,6 +1469,7 @@ static void procmime_parse_multipart(MimeInfo *mimeinfo)
        gchar buf[BUFFSIZE];
        FILE *fp;
        int result = 0;
+       gboolean done = FALSE;
 
        boundary = g_hash_table_lookup(mimeinfo->typeparameters, "boundary");
        if (!boundary)
@@ -1467,7 +1498,11 @@ static void procmime_parse_multipart(MimeInfo *mimeinfo)
                                                        hentry[2].body, hentry[3].body, 
                                                        hentry[4].body, hentry[5].body,
                                                        mimeinfo->data.filename, lastoffset,
-                                                       len);
+                                                       len, short_scan);
+                               if (result == 1 && short_scan) {
+                                       done = TRUE;
+                                       break;
+                               }
                        }
                        
                        if (buf[2 + boundary_len]     == '-' &&
@@ -1760,10 +1795,11 @@ static int procmime_parse_mimepart(MimeInfo *parent,
                             gchar *content_location,
                             const gchar *filename,
                             guint offset,
-                            guint length)
+                            guint length,
+                            gboolean short_scan)
 {
        MimeInfo *mimeinfo;
-
+       int result = 0;
        /* Create MimeInfo */
        mimeinfo = procmime_mimeinfo_new();
        mimeinfo->content = MIMECONTENT_FILE;
@@ -1824,21 +1860,27 @@ static int procmime_parse_mimepart(MimeInfo *parent,
 
        /* Call parser for mime type */
        switch (mimeinfo->type) {
+               case MIMETYPE_TEXT:
+                       if (g_ascii_strcasecmp(mimeinfo->subtype, "plain") == 0 && short_scan) {
+                               return 1;
+                       }
+                       break;
+
                case MIMETYPE_MESSAGE:
                        if (g_ascii_strcasecmp(mimeinfo->subtype, "rfc822") == 0) {
-                               procmime_parse_message_rfc822(mimeinfo);
+                               procmime_parse_message_rfc822(mimeinfo, short_scan);
                        }
                        break;
                        
                case MIMETYPE_MULTIPART:
-                       procmime_parse_multipart(mimeinfo);
+                       procmime_parse_multipart(mimeinfo, short_scan);
                        break;
                        
                default:
                        break;
        }
 
-       return 0;
+       return result;
 }
 
 static gchar *typenames[] = {
@@ -1870,7 +1912,7 @@ static void output_mime_structure(MimeInfo *mimeinfo, int indent)
        g_node_traverse(mimeinfo->node, G_PRE_ORDER, G_TRAVERSE_ALL, -1, output_func, NULL);
 }
 
-static MimeInfo *procmime_scan_file_with_offset(const gchar *filename, int offset)
+static MimeInfo *procmime_scan_file_with_offset(const gchar *filename, int offset, gboolean short_scan)
 {
        MimeInfo *mimeinfo;
        struct stat buf;
@@ -1886,25 +1928,35 @@ static MimeInfo *procmime_scan_file_with_offset(const gchar *filename, int offse
        mimeinfo->offset = offset;
        mimeinfo->length = buf.st_size - offset;
 
-       procmime_parse_message_rfc822(mimeinfo);
+       procmime_parse_message_rfc822(mimeinfo, short_scan);
        if (debug_get_mode())
                output_mime_structure(mimeinfo, 0);
 
        return mimeinfo;
 }
 
-MimeInfo *procmime_scan_file(const gchar *filename)
+static MimeInfo *procmime_scan_file_full(const gchar *filename, gboolean short_scan)
 {
        MimeInfo *mimeinfo;
 
        g_return_val_if_fail(filename != NULL, NULL);
 
-       mimeinfo = procmime_scan_file_with_offset(filename, 0);
+       mimeinfo = procmime_scan_file_with_offset(filename, 0, short_scan);
 
        return mimeinfo;
 }
 
-MimeInfo *procmime_scan_queue_file(const gchar *filename)
+MimeInfo *procmime_scan_file(const gchar *filename)
+{
+       return procmime_scan_file_full(filename, FALSE);
+}
+
+static MimeInfo *procmime_scan_file_short(const gchar *filename)
+{
+       return procmime_scan_file_full(filename, TRUE);
+}
+
+static MimeInfo *procmime_scan_queue_file_full(const gchar *filename, gboolean short_scan)
 {
        FILE *fp;
        MimeInfo *mimeinfo;
@@ -1938,11 +1990,21 @@ MimeInfo *procmime_scan_queue_file(const gchar *filename)
        offset = ftell(fp);
        fclose(fp);
 
-       mimeinfo = procmime_scan_file_with_offset(filename, offset);
+       mimeinfo = procmime_scan_file_with_offset(filename, offset, short_scan);
 
        return mimeinfo;
 }
 
+MimeInfo *procmime_scan_queue_file(const gchar *filename)
+{
+       return procmime_scan_queue_file_full(filename, FALSE);
+}
+
+static MimeInfo *procmime_scan_queue_file_short(const gchar *filename)
+{
+       return procmime_scan_queue_file_full(filename, TRUE);
+}
+
 typedef enum {
     ENC_AS_TOKEN,
     ENC_AS_QUOTED_STRING,
index 67750871a758b539ffbed95ac6e2815e8345cad0..ccf92609584f98bdf7ceed15e619db018119cc54 100644 (file)
@@ -165,6 +165,7 @@ MimeInfo *procmime_mimeinfo_parent  (MimeInfo       *mimeinfo);
 MimeInfo *procmime_mimeinfo_next       (MimeInfo       *mimeinfo);
 
 MimeInfo *procmime_scan_message                (MsgInfo        *msginfo);
+MimeInfo *procmime_scan_message_short  (MsgInfo        *msginfo);
 void procmime_scan_multipart_message   (MimeInfo       *mimeinfo,
                                         FILE           *fp);
 const gchar *procmime_mimeinfo_get_parameter
index 6f0f89be5118a72a87432350435b39abb104715c..35afce7b4f004c015a13fe764d590bfa0cbca743 100644 (file)
@@ -426,7 +426,7 @@ static void quote_fmt_show_msg(MsgInfo *msginfo, const gchar *body,
        if (body)
                fp = str_open_as_stream(body);
        else {
-               if (procmime_msginfo_is_encrypted(msginfo))
+               if (MSG_IS_ENCRYPTED(msginfo->flags))
                        fp = procmime_get_first_encrypted_text_content(msginfo);
                else
                        fp = procmime_get_first_text_content(msginfo);