* src/summaryview.c
authorLuke Plant <L.Plant.98@cantab.net>
Sat, 8 Nov 2003 18:48:22 +0000 (18:48 +0000)
committerLuke Plant <L.Plant.98@cantab.net>
Sat, 8 Nov 2003 18:48:22 +0000 (18:48 +0000)
fix some typos

* src/compose.c
        rewrote compose_attach_parts(), fixing various bugs mainly
to do with re-editing.

* src/mimeview.c
        "save all" now only saves attachments with names/filenames

ChangeLog.claws
configure.ac
src/compose.c
src/mimeview.c
src/summaryview.c

index 32fc177..88efab4 100644 (file)
@@ -1,3 +1,14 @@
+2003-11-08 [luke]      0.9.6claws69
+       * src/summaryview.c
+                fix some typos
+
+        * src/compose.c
+                rewrite compose_attach_parts(), fixing various bugs mainly
+               to do with re-editing.
+
+        * src/mimeview.c
+                "save all" now only saves attachments with names/filenames
+
 2003-11-04 [match]     0.9.6claws68
        * src/ldapctrl.[ch]
                fix broken LDAP support.
index 7773d89..9d1553e 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=6
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=68
+EXTRA_VERSION=69
 if test $EXTRA_VERSION -eq 0; then
     VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}claws
 else
index 3755a63..4cd00fc 100644 (file)
@@ -2168,72 +2168,122 @@ static void compose_attach_append(Compose *compose, const gchar *file,
        gtk_clist_set_row_data(GTK_CLIST(compose->attach_clist), row, ainfo);
 }
 
-#define IS_FIRST_PART_TEXT(info) \
-       ((info->type == MIMETYPE_TEXT) || \
-        (info->type == MIMETYPE_MULTIPART && info->subtype && \
-         !strcasecmp(info->subtype, "alternative") && \
-         (info->node->children && \
-          (((MimeInfo *) info->node->children->data)->type == MIMETYPE_TEXT))))
+#ifdef USE_GPGME
+static void compose_use_signing(Compose *compose, gboolean use_signing)
+{
+       GtkItemFactory *ifactory;
+       GtkWidget *menuitem = NULL;
+
+       compose->use_signing = use_signing;
+       ifactory = gtk_item_factory_from_widget(compose->menubar);
+       menuitem = gtk_item_factory_get_item
+               (ifactory, "/Message/Sign");
+       gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), 
+                                      use_signing);
+       compose_update_gnupg_mode_menu_item(compose);
+}
+#endif /* USE_GPGME */
+
+#define NEXT_PART_NOT_CHILD(info)  \
+{  \
+       node = info->node;  \
+       while (node->children)  \
+               node = g_node_last_child(node);  \
+       info = procmime_mimeinfo_next((MimeInfo *)node->data);  \
+}
 
 static void compose_attach_parts(Compose *compose, MsgInfo *msginfo)
 {
        MimeInfo *mimeinfo;
        MimeInfo *child;
-       gchar *infile;
+       MimeInfo *firsttext = NULL;
+       MimeInfo *encrypted = NULL;
+       GNode    *node;
        gchar *outfile;
        const gchar *partname = NULL;
 
        mimeinfo = procmime_scan_message(msginfo);
        if (!mimeinfo) return;
 
-       /* skip first text (presumably message body) */
-       child = (MimeInfo *) mimeinfo->node->children->data;
-       if (!child || IS_FIRST_PART_TEXT(mimeinfo)) {
+       if (mimeinfo->node->children == NULL) {
                procmime_mimeinfo_free_all(mimeinfo);
                return;
        }
 
-       if (IS_FIRST_PART_TEXT(child))
-               child = (MimeInfo *) child->node->next;
-
-       infile = procmsg_get_message_file_path(msginfo);
-
+       /* find first content part */
+       child = (MimeInfo *) mimeinfo->node->children->data;
+       while (child && child->node->children && (child->type == MIMETYPE_MULTIPART))
+               child = (MimeInfo *)child->node->children->data;
+
+       if (child->type == MIMETYPE_TEXT) {
+               firsttext = child;
+               debug_print("First text part found\n");
+       } else if (compose->mode == COMPOSE_REEDIT &&
+                child->type == MIMETYPE_APPLICATION &&
+                !strcasecmp(child->subtype, "pgp-encrypted")) {
+               AlertValue val;
+               val = alertpanel(_("Encrypted message"),
+                                _("Cannot re-edit an encrypted message. \n"
+                                  "Discard encrypted part?"),
+                                _("Yes"), _("No"), NULL);
+               if (val == G_ALERTDEFAULT) 
+                       encrypted = (MimeInfo *)child->node->parent->data;
+       }
+     
+       child = (MimeInfo *) mimeinfo->node->children->data;
        while (child != NULL) {
-               if (child->node->children || child->type == MIMETYPE_MULTIPART) {
+               if (child == encrypted) {
+                       /* skip this part of tree */
+                       NEXT_PART_NOT_CHILD(child);
+                       continue;
+               }
+
+               if (child->type == MIMETYPE_MULTIPART) {
+                       /* get the actual content */
+                       child = procmime_mimeinfo_next(child);
+                       continue;
+               }
+                   
+               if (child == firsttext) {
                        child = procmime_mimeinfo_next(child);
                        continue;
                }
-               if (child->node->parent && child->node->parent->parent
-               && (((MimeInfo *) child->node->parent->parent->data)->type == MIMETYPE_MULTIPART)
-               && !strcasecmp(((MimeInfo *) child->node->parent->parent->data)->subtype, "signed")
-               && child->type == MIMETYPE_TEXT) {
-                       /* this is the main text part of a signed message */
+
+               if ((compose->mode == COMPOSE_REEDIT || 
+                    compose->mode == COMPOSE_FORWARD_INLINE ||
+                    compose->mode == COMPOSE_FORWARD )  &&
+                   (child->type == MIMETYPE_APPLICATION) && 
+                   !strcmp(child->subtype, "pgp-signature")) {
+#ifdef USE_GPGME
+                       if (compose->mode == COMPOSE_REEDIT) {
+                               compose->gnupg_mode  = GNUPG_MODE_DETACH;
+                               compose_use_signing(compose, TRUE);
+                       }
+#endif
                        child = procmime_mimeinfo_next(child);
                        continue;
                }
                outfile = procmime_get_tmp_file_name(child);
                if (procmime_get_part(outfile, child) < 0)
                        g_warning("Can't get the part of multipart message.");
-               else if (compose->mode != COMPOSE_REEDIT || 
-                   !((child->type == MIMETYPE_APPLICATION) && !strcmp(child->subtype, "pgp-signature"))) {
+               else {
                        gchar *content_type;
 
                        content_type = g_strdup_printf("%s/%s", procmime_get_type_str(child->type), child->subtype);
                        partname = procmime_mimeinfo_get_parameter(child, "name");
-                       
+                       if (partname == NULL)
+                               partname = "";
                        compose_attach_append(compose, outfile, 
                                              partname, content_type);
                        g_free(content_type);
                }
-
-               child = child->node->next != NULL ? (MimeInfo *) child->node->next->data : NULL;
+               g_free(outfile);
+               NEXT_PART_NOT_CHILD(child);
        }
-
-       g_free(infile);
        procmime_mimeinfo_free_all(mimeinfo);
 }
 
-#undef IS_FIRST_PART_TEXT
+#undef NEXT_PART_NOT_CHILD
 
 #define GET_CHAR(pos, buf, len)                                                     \
 {                                                                           \
index 31c7a2a..68b206b 100644 (file)
@@ -941,7 +941,9 @@ static void mimeview_save_all(MimeView *mimeview)
        /* for each attachment, extract it in the selected dir. */
        while (attachment != NULL) {
                if (attachment->type != MIMETYPE_MESSAGE &&
-                   attachment->type != MIMETYPE_MULTIPART) {
+                   attachment->type != MIMETYPE_MULTIPART &&
+                   (procmime_mimeinfo_get_parameter(attachment, "name") ||
+                    procmime_mimeinfo_get_parameter(attachment, "filename"))) {
                        static guint subst_cnt = 1;
                        gchar *attachdir;
                        gchar *attachname = g_strdup(get_part_name(attachment));
index 2cd0aff..dea04f9 100644 (file)
@@ -477,8 +477,8 @@ static const gchar *const col_label[N_SUMMARY_COLS] = {
  */
 static gchar *search_descr_strings[] = {
        "a",     N_("all messages"),
-       "ag #",  N_("messages whose age is greather than #"),
-       "al #",  N_("messages whose age is greather than #"),
+       "ag #",  N_("messages whose age is greater than #"),
+       "al #",  N_("messages whose age is less than #"),
        "b S",   N_("messages which contain S in the message body"),
        "B S",   N_("messages which contain S in the whole message"),
        "c S",   N_("messages carbon-copied to S"),