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] Faxes cut in half



Jamin W. Collins wrote:

I could help adding the patch to the Debian build if you would like.  If
someone can point me in the direction of the patch in question I'd be
happy to build of version of the Debian package that includes it.


I've attached the patch. It will apply to HylaFAX+ 5.0.1. It may take some massaging to apply it to anything else 4.3.0 and later. It won't apply to anything earlier than that.


Lee.
diff -Nru hylafax.orig/faxd/faxQueueApp.c++ hylafax/faxd/faxQueueApp.c++
--- hylafax.orig/faxd/faxQueueApp.c++	2006-11-24 14:29:01.000000000 -0800
+++ hylafax/faxd/faxQueueApp.c++	2006-12-01 14:05:54.240422000 -0800
@@ -680,6 +680,8 @@
      * o the remote side is known to be capable of it, and
      * o the user hasn't specified a desire to send 1D data.
      */
+    int jcdf = job.getJCI().getDesiredDF();
+    if (jcdf != -1) req.desireddf = jcdf;
     if (req.desireddf == DF_2DMMR && (req.desiredec != EC_DISABLE) && 
 	use2D && job.modem->supportsMMR() &&
 	 (! info.getCalledBefore() || info.getSupportsMMR()) )
diff -Nru hylafax.orig/faxd/faxSendApp.c++ hylafax/faxd/faxSendApp.c++
--- hylafax.orig/faxd/faxSendApp.c++	2006-11-24 14:29:01.000000000 -0800
+++ hylafax/faxd/faxSendApp.c++	2006-12-01 12:48:22.980520984 -0800
@@ -161,8 +161,11 @@
 			 * user-specification.
 			 */
 
-			if (desiredDF != (u_int) -1)
+			bool usedf = false;			// to limit RTFCC application
+			if (desiredDF != (u_int) -1) {
 			    req->desireddf = desiredDF;
+			    usedf = true;
+			}
 			if (desiredBR != (u_int) -1)
 			    req->desiredbr = desiredBR;
 			if (desiredEC != (u_int) -1)
@@ -175,7 +178,7 @@
 			if (useJobTSI && req->tsi != "")
 			    FaxServer::setLocalIdentifier(req->tsi);
 
-			FaxServer::sendFax(*req, info, ai, batched);
+			FaxServer::sendFax(*req, info, ai, batched, usedf);
 
 			batchcommid = req->commid;		// ... to all batched jobs
 
diff -Nru hylafax.orig/faxd/FaxSend.c++ hylafax/faxd/FaxSend.c++
--- hylafax.orig/faxd/FaxSend.c++	2006-11-24 14:29:01.000000000 -0800
+++ hylafax/faxd/FaxSend.c++	2006-12-01 13:48:53.157650176 -0800
@@ -43,8 +43,9 @@
  * FAX Server Transmission Protocol.
  */
 void
-FaxServer::sendFax(FaxRequest& fax, FaxMachineInfo& clientInfo, FaxAcctInfo& ai, u_int& batched)
+FaxServer::sendFax(FaxRequest& fax, FaxMachineInfo& clientInfo, FaxAcctInfo& ai, u_int& batched, bool usedf)
 {
+    useDF = usedf;
     u_int prevPages = fax.npages;
     if (!(batched & BATCH_FIRST) || lockModem()) {
         if (batched & BATCH_FIRST)
@@ -163,7 +164,7 @@
      */
     clientParams.decodePage(fax.pagehandling);
     /*
-     * So we want to restrict DF sellection to those masked in fax.desireddf
+     * So we want to restrict DF selection to those masked in fax.desireddf
      */
     clientParams.df = fxmin(modem->getBestDataFormat(), (u_int)fax.desireddf);
     clientParams.br = fxmin(modem->getBestSignallingRate(), (u_int) fax.desiredbr);
@@ -606,12 +607,21 @@
 	 * Ignore what faxq did and send with the "highest" (monochrome) 
 	 * compression that both the modem and the remote supports.
 	 */
-	params.df = 0;
-	u_int bits = clientCapabilities.df;
-	bits &= BIT(DF_JBIG+1)-1;		// cap at JBIG, only deal with monochrome
-	while (bits) {
-	    bits >>= 1;
-	    if (bits) params.df++;
+	if (useDF) {
+	    /*
+	     * The job has been restricted to a specific data format per
+	     * JobControls or something similar - that value is now 
+	     * found in clientParams.df.
+	     */
+	    params.df ==  fxmin(clientParams.df, params.df);
+	} else {
+	    params.df = 0;
+	    u_int bits = clientCapabilities.df;
+	    bits &= BIT(DF_JBIG+1)-1;		// cap at JBIG, only deal with monochrome
+	    while (bits) {			// puts params.df to the "best" support by the remote
+		bits >>= 1;
+		if (bits) params.df++;
+	    }
 	}
 	// Class 2 RTFCC doesn't support JBIG
 	if (params.df == DF_JBIG && (!modem->supportsJBIG() || (params.ec == EC_DISABLE) || class2RTFCC))
@@ -620,7 +630,7 @@
 	// it's likely that the remote was incorrect in telling us it does
 	if (params.df == DF_2DMRUNCOMP) params.df = DF_2DMR;
 	// don't let RTFCC cause problems with restricted modems...
-	if (params.df == DF_2DMMR && (!modem->supportsMMR() || (params.ec == EC_DISABLE)))
+	if (params.df == DF_2DMMR && (!modem->supportsMMR() || (params.ec == EC_DISABLE) || !(clientCapabilities.df & BIT(DF_2DMMR))))
 		params.df = DF_2DMR;
 	if (params.df == DF_2DMR && (!modem->supports2D() || !(clientCapabilities.df & BIT(DF_2DMR))))
 		params.df = DF_1DMH;
diff -Nru hylafax.orig/faxd/FaxServer.h hylafax/faxd/FaxServer.h
--- hylafax.orig/faxd/FaxServer.h	2006-11-24 14:29:01.000000000 -0800
+++ hylafax/faxd/FaxServer.h	2006-12-01 13:22:32.368966584 -0800
@@ -63,6 +63,8 @@
 
     friend class FaxModem;
 
+    bool	useDF;			// limits application of RTFCC
+
 // FAX transmission protocol support
     void	sendFax(FaxRequest& fax, FaxMachineInfo&, const fxStr& number, u_int&);
     bool	sendClientCapabilitiesOK(FaxRequest&, FaxMachineInfo&, fxStr&);
@@ -93,7 +95,7 @@
     void	readConfig(const fxStr& filename);
     void	setLocalIdentifier(const fxStr& lid);
 
-    void	sendFax(FaxRequest&, FaxMachineInfo&, FaxAcctInfo&, u_int&);
+    void	sendFax(FaxRequest&, FaxMachineInfo&, FaxAcctInfo&, u_int&, bool);
     bool	recvFax(const CallID& callid, fxStr& emsg);
 
     time_t	getFileTransferTime() const;
diff -Nru hylafax.orig/faxd/JobControl.c++ hylafax/faxd/JobControl.c++
--- hylafax.orig/faxd/JobControl.c++	2006-11-24 14:29:01.000000000 -0800
+++ hylafax/faxd/JobControl.c++	2006-12-01 14:57:39.613333560 -0800
@@ -39,6 +39,7 @@
 #define	DCI_USEXVRES		0x0020
 #define	DCI_VRES		0x0040
 #define	DCI_PRIORITY		0x0080
+#define	DCI_DESIREDDF		0x0100
 
 #define	isDefined(b)		(defined & b)
 #define	setDefined(b)		(defined |= b)
@@ -58,6 +59,7 @@
     usexvres = other.usexvres;
     vres = other.vres;
     priority = other.priority;
+    desireddf = other.desireddf;
 }
 
 JobControlInfo::JobControlInfo (const fxStr& buffer)
@@ -134,10 +136,14 @@
 	priority = getNumber(value);
 	setDefined(DCI_PRIORITY);
     } else {
+	if (streq(tag, "desireddf")) {		// need to pass desireddf to faxsend, also
+	    desireddf = getNumber(value);
+	    setDefined(DCI_DESIREDDF);
+	}
 	if( args != "" )
 	    args.append('\0');
 	args.append(fxStr::format("-c%c%s:\"%s\"",
-	    '\0', tag, value));
+	    '\0', tag, (const char*) value));
     }
     return true;
 }
@@ -225,3 +231,12 @@
     else
 	return -1;
 }
+
+int
+JobControlInfo::getDesiredDF() const
+{
+    if (isDefined(DCI_DESIREDDF))
+	return desireddf;
+    else
+	return -1;
+}
diff -Nru hylafax.orig/faxd/JobControl.h hylafax/faxd/JobControl.h
--- hylafax.orig/faxd/JobControl.h	2006-11-24 14:29:01.000000000 -0800
+++ hylafax/faxd/JobControl.h	2006-12-01 14:57:06.877310192 -0800
@@ -55,6 +55,7 @@
     u_int	vres;			// use extended resolution
     fxStr	args;			// arguments for subprocesses
     int		priority;		// override submission priority with this
+    int		desireddf;		// if set, desireddf value
 
     // default returned on no match
     static const JobControlInfo defControlInfo;
@@ -67,7 +68,6 @@
     ~JobControlInfo();
 
     int compare(const JobControlInfo*) const;
-    void parseEntry(const char* tag, const char* value, bool quoted);
 
     u_int getMaxConcurrentCalls() const;
     u_int getMaxSendPages() const;
@@ -79,6 +79,7 @@
     int getUseXVRes() const;
     u_int getVRes() const;
     int getPriority() const;
+    int getDesiredDF() const;
     const fxStr& getArgs() const;
 
     virtual bool setConfigItem(const char*, const char*);
diff -Nru hylafax.orig/man/jobcontrol.1m hylafax/man/jobcontrol.1m
--- hylafax.orig/man/jobcontrol.1m	2006-11-24 14:29:00.000000000 -0800
+++ hylafax/man/jobcontrol.1m	2006-12-01 17:01:59.981185256 -0800
@@ -175,6 +175,7 @@
 .ft C
     DesiredBR: 3
     DesiredEC: 0
+    DesiredDF: 1
 .ft P
 .fi
 .PP



Project hosted by iFAX Solutions