]> diplodocus.org Git - nmh/commitdiff
Added support for mhbuild-disposition-<type>[/<subtype>] profile
authorDavid Levine <levinedl@acm.org>
Thu, 15 May 2014 15:28:03 +0000 (10:28 -0500)
committerDavid Levine <levinedl@acm.org>
Thu, 15 May 2014 15:28:03 +0000 (10:28 -0500)
entries when mhbuild expands Attach: headers.  Default to
'attachment', but override with 'inline' entries for text/calendar
and message/rfc822 in mhn.defaults.

etc/mhn.defaults.sh
man/mhbuild.man
man/send.man
uip/mhbuildsbr.c

index cff0e702d43cef63bb47535344f9a99be681a412..15be57d1e5c0bb7d87afbb2424c5336c0e67c365 100755 (executable)
@@ -124,6 +124,17 @@ elif [ -f "/dev/audio" ]; then
     fi
 fi
 
     fi
 fi
 
+####
+#### mhbuild-disposition-<type>[/<subtype>] entries are used by the
+#### WhatNow attach for deciding whether the Content-Disposition
+#### should be 'attachment' or 'inline'.  Only those values are
+#### supported.
+####
+cat <<EOF >> ${TMP}
+mhbuild-disposition-text/calendar: inline
+mhbuild-disposition-message/rfc822: inline
+EOF
+
 PGM="`$SEARCHPROG $SEARCHPATH mpeg_play`"
 if [ ! -z "$PGM" ]; then
        echo "mhshow-show-video/mpeg: %p$PGM %f" >> $TMP
 PGM="`$SEARCHPROG $SEARCHPATH mpeg_play`"
 if [ ! -z "$PGM" ]; then
        echo "mhshow-show-video/mpeg: %p$PGM %f" >> $TMP
index 4a0e87305422e9dda4cf70d24938cab48325c73b..dc47b63c5e9898bd1d884874614754668edefdae 100644 (file)
@@ -102,6 +102,23 @@ content specified by
 directives (see below).  See
 .IR send (1)
 for more details.
 directives (see below).  See
 .IR send (1)
 for more details.
+.PP
+By default, the Content-Disposition will be \*(lqattachment\*(rq.
+.B mhbuild
+looks for user profile and mhn.defaults entries of the form
+.PP
+.RS 5
+mhbuild-disposition-<type>/<subtype>
+.RE
+or
+.RS 5
+mhbuild-disposition-<type>
+.RE
+.PP
+to supply the disposition value.  The only supported values are
+.I attachment
+and
+.IR inline.
 .SS "Translating the Composition File"
 .B mhbuild
 is essentially a filter to aid in the composition of MIME
 .SS "Translating the Composition File"
 .B mhbuild
 is essentially a filter to aid in the composition of MIME
index 66b00553a4a7e9c0def8e875c42fd062fe2c93bb..c8346c345cf73ca9f91359cd8ec0de3b062d802c 100644 (file)
@@ -156,6 +156,10 @@ Content-Description: VERSION
 Content-Disposition: attachment; filename="VERSION"
 .fi
 .PP
 Content-Disposition: attachment; filename="VERSION"
 .fi
 .PP
+See
+.IR mhbuild (1)
+for explanation of how the Content-Disposition value is selected.
+.PP
 If
 .B \-push
 is specified,
 If
 .B \-push
 is specified,
@@ -466,6 +470,7 @@ for more information.
 .IR dist (1),
 .IR file (1),
 .IR forw (1),
 .IR dist (1),
 .IR file (1),
 .IR forw (1),
+.IR mhbuild (1),
 .IR mhparam (1),
 .IR repl (1),
 .IR whatnow (1),
 .IR mhparam (1),
 .IR repl (1),
 .IR whatnow (1),
index 3cdea761c3d6c3f1fe744f5bbdf822e25715c63b..3429c1efefd2759eebe2098815936e538dfa3d35 100644 (file)
@@ -1856,6 +1856,8 @@ setup_attach_content(CT ct, char *filename)
     char *type, *simplename = r1bindex(filename, '/');
     struct str2init *s2i;
     PM pm;
     char *type, *simplename = r1bindex(filename, '/');
     struct str2init *s2i;
     PM pm;
+    char buffer[BUFSIZ], *cp;
+    int no_subtype = 0;
 
     if (! (type = mime_type(filename))) {
        adios(NULL, "Unable to determine MIME type of \"%s\"", filename);
 
     if (! (type = mime_type(filename))) {
        adios(NULL, "Unable to determine MIME type of \"%s\"", filename);
@@ -1929,14 +1931,36 @@ setup_attach_content(CT ct, char *filename)
     ct->c_cefile.ce_file = getcpy(filename);
 
     /*
     ct->c_cefile.ce_file = getcpy(filename);
 
     /*
-     * If it's a text/calendar, we need to make sure it's an inline,
-     * otherwise it won't work with some calendar programs.  Otherwise
-     * assume attachment
+     * Look for mhbuild-disposition-<type>/<subtype> entry
+     * that specifies Content-Disposition type.  Only
+     * 'attachment' and 'inline' are allowed.  Default to
+     * 'attachment'.
      */
 
      */
 
-    if (strcasecmp(ct->c_ctinfo.ci_type, "text") == 0 &&
-       strcasecmp(ct->c_ctinfo.ci_subtype, "calendar") == 0) {
-       ct->c_dispo_type = getcpy("inline");
+    snprintf (buffer, sizeof(buffer), "%s-disposition-%s/%s",
+              invo_name, ct->c_ctinfo.ci_type, ct->c_ctinfo.ci_subtype);
+    cp = context_find (buffer);
+    if (cp == NULL || *cp == '\0') {
+        no_subtype = 1;
+        snprintf (buffer, sizeof(buffer), "%s-disposition-%s", invo_name,
+                  ct->c_ctinfo.ci_type);
+        cp = context_find (buffer);
+    }
+    if (cp != NULL && *cp != '\0') {
+        if (strcasecmp (cp, "attachment")  &&
+            strcasecmp (cp, "inline")) {
+            admonish (NULL, "configuration problem: %s-disposition-%s%s%s "
+                      "specifies '%s' but only 'attachment' and 'inline' are "
+                      "allowed", invo_name,
+                      ct->c_ctinfo.ci_type,
+                      no_subtype ? "" : "/",
+                      no_subtype ? "" : ct->c_ctinfo.ci_subtype,
+                      cp);
+        }
+    }
+
+    if (cp) {
+       ct->c_dispo_type = getcpy(cp);
     } else {
        ct->c_dispo_type = getcpy("attachment");
     }
     } else {
        ct->c_dispo_type = getcpy("attachment");
     }