HylaFAX The world's most advanced open source fax server

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [hylafax-users] FaxMail + PDF Attachments + Email Header



Riccardo Magliocchetti wrote:
On Feb 6, 2008 9:04 PM, Lee Howard <faxguy@xxxxxxxxxxxxxxxx> wrote:
Riccardo Magliocchetti wrote:
This is very interesting. Does this mean that there will be a way to filter
the stuff that has not "content-disposition: attachment"?
Is this something that you want?

Sort of. These feature would let me remove the html body while keeping html attachments. Useful especially when the html body is empty.

Attached is a patch (which applies to HylaFAX+ 5.2.1 and will be in the 5.2.2 release) that causes faxmail to pass the MIME Content-Description, Content-ID, and Content-Disposition information along to the MIMEConverters as parameters prefixed with "description:", "id:", or "disposition:" respectively. This will allow you to employ that information with whatever intelligence you need to from within the MIMEConverters scripts to determine whether or not to do any conversion at all.


Thanks,

Lee.

diff -Nru hylafax.orig/faxmail/faxmail.c++ hylafax/faxmail/faxmail.c++
--- hylafax.orig/faxmail/faxmail.c++	2008-02-02 22:51:05.000000000 -0800
+++ hylafax/faxmail/faxmail.c++	2008-02-07 10:12:06.572701104 -0800
@@ -707,13 +707,31 @@
 bool
 faxMailApp::runConverter(const fxStr& app, const fxStr& tmp, MIMEState& mime)
 {
-    const char* av[3];
+    const char* av[6];
     av[0] = strrchr(app, '/');
     if (av[0] == NULL)
 	av[0] = app;
     // XXX should probably pass in MIME state like charset
-    av[1] = tmp;
-    av[2] = NULL;
+    u_int i = 1;
+    av[i++] = tmp;
+    fxStr label;
+    if (mime.getDescription() != "") {
+	label = "description:";
+	label.append(mime.getDescription());
+	av[i++] = (const char*) label;
+    }
+    if (mime.getContentID() != "") {
+	label = "id:";
+	label.append(mime.getContentID());
+	av[i++] = (const char*) label;
+    }
+    if (mime.getDisposition() != "") {
+	label = "disposition:";
+	label.append(mime.getDisposition());
+	av[i++] = (const char*) label;
+    }
+    av[i++] = NULL;
+
     pid_t pid = fork();
     switch (pid) {
     case -1:				// error
diff -Nru hylafax.orig/faxmail/MIMEState.c++ hylafax/faxmail/MIMEState.c++
--- hylafax.orig/faxmail/MIMEState.c++	2008-02-02 22:51:05.000000000 -0800
+++ hylafax/faxmail/MIMEState.c++	2008-02-07 09:43:05.726349976 -0800
@@ -159,6 +159,9 @@
     s = msg.findHeader("Content-ID");
     if (s)
 	cid = *s;
+    s = msg.findHeader("Content-Disposition");
+    if (s)
+	disp = *s;
     return (true);
 }
 
diff -Nru hylafax.orig/faxmail/MIMEState.h hylafax/faxmail/MIMEState.h
--- hylafax.orig/faxmail/MIMEState.h	2008-02-02 22:51:05.000000000 -0800
+++ hylafax/faxmail/MIMEState.h	2008-02-07 09:45:50.539294600 -0800
@@ -62,6 +62,7 @@
     fxStr	subtype;		// content subtype
     fxStr	desc;			// content description
     fxStr	cid;			// content ID
+    fxStr	disp;			// content disposition
     fxStr	boundary;		// multipart boundary marker
     u_int	blen;			// adjusted boundary length
     bool	lastPart;		// true if last multipart boundary seen
@@ -93,6 +94,7 @@
     bool isParent(const char* type, const char* subtype) const;
     const fxStr& getDescription(void) const;
     const fxStr& getContentID(void) const;
+    const fxStr& getDisposition(void) const;
 
     virtual void setEncoding(const char*);
     Encoding getEncoding(void) const;
@@ -118,4 +120,5 @@
 inline const fxStr& MIMEState::getSubType(void) const	{ return subtype; }
 inline const fxStr& MIMEState::getDescription(void) const { return desc; }
 inline const fxStr& MIMEState::getContentID(void) const	{ return cid; }
+inline const fxStr& MIMEState::getDisposition(void) const { return disp; }
 #endif /* _MIMEState_ */
diff -Nru hylafax.orig/man/faxmail.1 hylafax/man/faxmail.1
--- hylafax.orig/man/faxmail.1	2008-02-02 22:51:05.000000000 -0800
+++ hylafax/man/faxmail.1	2008-02-07 10:19:34.325632312 -0800
@@ -598,7 +598,10 @@
 body parts.
 The default pathname is ${LIBDATA}/faxmail.  \*(Fx comes with default converter
 scripts for TIFF and PDF, and they can be found in that path and used as a 
-reference for constructing other converters.
+reference for constructing other converters.  The script is passed the
+filename of the body part for conversion as the first parameters.  Subsequent
+parameters are the MIME Content-Description, Content-ID, and Content-Disposition
+information prefixed with ``description:'', ``id:'', and ``disposition:'' respectively.
 .TP 15
 .B Orientation
 Control whether pages are oriented horizontally (``landscape'')
diff -Nru hylafax.orig/man/hylafax-config.4f hylafax/man/hylafax-config.4f



Project hosted by iFAX Solutions