]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
Track skipped pages and cover pages
authorAidan Van Dyk <aidan@ifax.com>
Wed, 1 Oct 2008 20:06:51 +0000 (20:06 +0000)
committerAidan Van Dyk <aidan@ifax.com>
Wed, 1 Oct 2008 20:06:51 +0000 (20:06 +0000)
Setting TagLineCoverNumString implies that you *don't* want to include
the cover pages in the normal page numbering.  The tagline page numbers
will adjusted to not count the cover pages, and instead of using the
page number of the cover page, the set string will used instead.

22 files changed:
faxd/Class1.h
faxd/Class1Send.c++
faxd/Class2.h
faxd/Class20.c++
faxd/Class20.h
faxd/Class2Ersatz.c++
faxd/Class2Ersatz.h
faxd/Class2Send.c++
faxd/FaxModem.c++
faxd/FaxModem.h
faxd/FaxRequest.c++
faxd/FaxRequest.h
faxd/FaxSend.c++
faxd/FaxServer.h
faxd/ModemConfig.c++
faxd/ModemConfig.h
faxd/TagLine.c++
faxd/faxQueueApp.c++
faxd/faxSendApp.c++
faxd/faxSendApp.h
faxd/mkhash.c
man/hylafax-config.4f

index e10ba90428ee202b7e94c83dd93c73f7bf733d0d..4766d740808405f18a998d2cb08ef73e3aca66c3 100644 (file)
@@ -131,7 +131,7 @@ protected:
     bool       raiseToNextBR(Class2Params&);
     bool       sendTraining(Class2Params&, int, Status& eresult);
     bool       sendTCF(const Class2Params&, u_int ms);
-    bool       sendPage(TIFF* tif, Class2Params&, u_int, u_int, Status& eresult);
+    bool       sendPage(TIFF* tif, Class2Params&, u_int, u_int, Status& eresult, bool cover);
     bool       sendPageData(u_char* data, u_int cc, const u_char* bitrev, bool ecm, Status& eresult);
     bool       sendRTC(Class2Params params, u_int ppmcmd, uint32 rowsperstrip, Status& eresult);
     bool       sendPPM(u_int ppm, HDLCFrame& mcf, Status& eresult);
@@ -215,7 +215,7 @@ public:
     void       sendBegin();
     void       sendSetupPhaseB(const fxStr& pwd, const fxStr& sub);
     FaxSendStatus sendPhaseB(TIFF* tif, Class2Params&, FaxMachineInfo&,
-                   fxStr& pph, Status& eresult, u_int& batched);
+                   fxStr& pph, Status& eresult, u_int& batched, PageType pt);
     void       sendEnd();
     void       sendAbort();
 
index 3cedf1a779b18214391a5957cfa05ae30af7221f..0cd2beadea4515c6454a6f50b099792b3e75c6f7 100644 (file)
@@ -30,6 +30,7 @@
  * Send protocol.
  */
 #include "Sys.h"
+#include "SystemLog.h"
 #include "Class1.h"
 #include "ModemConfig.h"
 #include "HDLCFrame.h"
@@ -273,7 +274,7 @@ Class1Modem::decodePPM(const fxStr& pph, u_int& ppm, Status& eresult)
  */
 FaxSendStatus
 Class1Modem::sendPhaseB(TIFF* tif, Class2Params& next, FaxMachineInfo& info,
-    fxStr& pph, Status& eresult, u_int& batched)
+    fxStr& pph, Status& eresult, u_int& batched, PageType pt)
 {
     int ntrys = 0;                     // # retraining/command repeats
     bool morePages = true;             // more pages still to send
@@ -362,7 +363,7 @@ Class1Modem::sendPhaseB(TIFF* tif, Class2Params& next, FaxMachineInfo& info,
            /*
             * Transmit the facsimile message/Phase C.
             */
-           if (!sendPage(tif, params, decodePageChop(pph, params), cmd, eresult)) {
+           if (!sendPage(tif, params, decodePageChop(pph, params), cmd, eresult, pt == PAGE_COVER)) {
                if (hadV34Trouble) {
                    protoTrace("The destination appears to have trouble with V.34-Fax.");
                    return (send_v34fail);
@@ -404,7 +405,8 @@ Class1Modem::sendPhaseB(TIFF* tif, Class2Params& next, FaxMachineInfo& info,
                protoTrace("Skipping page %d", FaxModem::getPageNumberOfCall());
                signalRcvd = FCF_MCF;
        }
-
+logDebug(" * * * PAGE SENT: %s", pt == PAGE_NORMAL ? "PAGE_NORMAL" :
+                                       (pt == PAGE_COVER ? "PAGE_COVER" : "PAGE_SKIP"));
        int ncrp = 0;
        u_int ppr;
        do {
@@ -431,9 +433,8 @@ Class1Modem::sendPhaseB(TIFF* tif, Class2Params& next, FaxMachineInfo& info,
                /* fall thru... */
            case FCF_MCF:               // ack confirmation
            case FCF_PIP:               // ack, w/ operator intervention
-               countPage(cmd == PPH_SKIP);     // bump page count
-               if (cmd != PPH_SKIP || conf.countSkippedPages)
-                   notifyPageSent(tif);        // update server
+               countPage(cmd == PPH_SKIP ? PAGE_SKIP : pt);// bump page count
+               notifyPageSent(tif, cmd == PPH_SKIP ? PAGE_SKIP : pt);          // update server
                if (pph[2] == 'Z')
                    pph.remove(0,2+5+1);// discard page-chop+handling info
                else
@@ -479,8 +480,8 @@ Class1Modem::sendPhaseB(TIFF* tif, Class2Params& next, FaxMachineInfo& info,
                        // ignore error and try to send next page
                        // after retraining
                    params.br = (u_int) -1;     // force retraining above
-                   countPage();                // bump page count
-                   notifyPageSent(tif);        // update server
+                   countPage(pt);              // bump page count
+                   notifyPageSent(tif, pt);    // update server
                    if (pph[2] == 'Z')
                        pph.remove(0,2+5+1);// discard page-chop+handling info
                    else
@@ -1710,7 +1711,7 @@ EOLcode(u_long& w)
  * Send a page of data.
  */
 bool
-Class1Modem::sendPage(TIFF* tif, Class2Params& params, u_int pageChop, u_int ppmcmd, Status& eresult)
+Class1Modem::sendPage(TIFF* tif, Class2Params& params, u_int pageChop, u_int ppmcmd, Status& eresult, bool cover)
 {
     if (params.ec == EC_DISABLE) {     // ECM does it later
        /*
@@ -1801,7 +1802,7 @@ Class1Modem::sendPage(TIFF* tif, Class2Params& params, u_int pageChop, u_int ppm
        u_char* dp;
        if (doTagLine) {
            u_long totbytes = totdata;
-           dp = imageTagLine(data+ts, fillorder, params, totbytes);
+           dp = imageTagLine(data+ts, fillorder, params, totbytes, cover);
            // Because the whole image is processed with MMR, 
            // totdata is then determined during encoding.
            totdata = (params.df == DF_2DMMR) ? totbytes : totdata+ts - (dp-data);
index b338a77d1f8ac6e8ece08da5bc648d3016edac0e..871eb5441da6f1a3ebd703130fefbdc31ab9aa9d 100644 (file)
@@ -84,9 +84,9 @@ protected:
 // transmission support
     bool       dataTransfer();
     bool       sendRTC(Class2Params params);
-    bool       sendPageData(TIFF* tif, u_int pageChop);
+    bool       sendPageData(TIFF* tif, u_int pageChop, bool cover);
 
-    virtual bool sendPage(TIFF* tif, u_int pageChop) = 0;
+    virtual bool sendPage(TIFF* tif, u_int pageChop, bool cover) = 0;
     virtual bool pageDone(u_int ppm, u_int& ppr) = 0;
 // reception support
     const AnswerMsg* findAnswer(const char*);
@@ -144,7 +144,7 @@ public:
     CallStatus dialResponse(Status& eresult);
     FaxSendStatus getPrologue(Class2Params&, bool&, Status& eresult, u_int&);
     FaxSendStatus sendPhaseB(TIFF* tif, Class2Params&, FaxMachineInfo&,
-                   fxStr& pph, Status& eresult, u_int& batched);
+                   fxStr& pph, Status& eresult, u_int& batched, PageType pt);
     void       sendAbort();
 
 // receive support
index 9c08b3c3f1bfbff9a59a4bc85af09ba9dd795bee..339f2b38ce6b0822bdd3c714438a76c2dbb19e7c 100644 (file)
@@ -124,7 +124,7 @@ Class20Modem::abortDataTransfer()
  * Send a page of data using the ``stream interface''.
  */
 bool
-Class20Modem::sendPage(TIFF* tif, u_int pageChop)
+Class20Modem::sendPage(TIFF* tif, u_int pageChop, bool cover)
 {
     /*
      * Support MT5634ZBA-V92 real-time fax compression conversion:
@@ -162,7 +162,7 @@ Class20Modem::sendPage(TIFF* tif, u_int pageChop)
     protoTrace("SEND begin page");
     if (flowControl == FLOW_XONXOFF)
        setXONXOFF(FLOW_XONXOFF, FLOW_NONE, ACT_FLUSH);
-    bool rc = sendPageData(tif, pageChop);
+    bool rc = sendPageData(tif, pageChop, cover);
     if (!rc)
        abortDataTransfer();
     else if( conf.class2SendRTC )
index 2f5cc305c4dca747a7d658b167a801998b8bec15..84d6935099f8d6def75e1ef70875216d30d0f702 100644 (file)
@@ -33,7 +33,7 @@
 class Class20Modem : public Class2Modem {
 protected:
 // transmission support
-    bool       sendPage(TIFF* tif, u_int pageChop);
+    bool       sendPage(TIFF* tif, u_int pageChop, bool cover);
     bool       pageDone(u_int ppm, u_int& ppr);
 
     void       abortDataTransfer();
index 7f1affdad5c334f43a226db698510d913edcf7c9..292366a09ff7473e0e8cb823a7068bcb9b193e30 100644 (file)
@@ -205,12 +205,12 @@ Class2ErsatzModem::sendEOT()
  * Send a page of data using the ``stream interface''.
  */
 bool
-Class2ErsatzModem::sendPage(TIFF* tif, u_int pageChop)
+Class2ErsatzModem::sendPage(TIFF* tif, u_int pageChop, bool cover)
 {
     protoTrace("SEND begin page");
     if (flowControl == FLOW_XONXOFF)
        setXONXOFF(FLOW_XONXOFF, FLOW_NONE, ACT_FLUSH);
-    bool rc = sendPageData(tif, pageChop);
+    bool rc = sendPageData(tif, pageChop, cover);
     if (rc && conf.class2SendRTC)
        rc = sendRTC(params);
     if (rc)
index e0854920112bc423cdacb03e82751ce1c568b461..af67126c32dfbde6aad212da4fbf4ff945b0bb90 100644 (file)
@@ -33,7 +33,7 @@
 class Class2ErsatzModem : public Class2Modem {
 protected:
 // transmission support
-    bool       sendPage(TIFF* tif, u_int pageChop);
+    bool       sendPage(TIFF* tif, u_int pageChop, bool coverpage);
     bool       pageDone(u_int ppm, u_int& ppr);
 
     bool       sendEOT();
index 39f2557304067526a0167512d3219f70b0afca8f..13809fa7ee22be9608603c10b13942e378a01c5f 100644 (file)
@@ -243,7 +243,7 @@ pageInfoChanged(const Class2Params& a, const Class2Params& b)
  */
 FaxSendStatus
 Class2Modem::sendPhaseB(TIFF* tif, Class2Params& next, FaxMachineInfo& info,
-    fxStr& pph, Status& eresult, u_int& batched)
+    fxStr& pph, Status& eresult, u_int& batched, PageType pt)
 {
     int ntrys = 0;                     // # retraining/command repeats
     u_int ppm, previousppm = 0;
@@ -281,7 +281,7 @@ Class2Modem::sendPhaseB(TIFF* tif, Class2Params& next, FaxMachineInfo& info,
            goto failed;
        if (ppm == PPH_SKIP)
            protoTrace("Skiping page %d", FaxModem::getPageNumberOfCall());
-       if (ppm == PPH_SKIP || (dataTransfer() && sendPage(tif, decodePageChop(pph, params)))) {
+       if (ppm == PPH_SKIP || (dataTransfer() && sendPage(tif, decodePageChop(pph, params), pt == PAGE_COVER))) {
            /*
             * Page transferred, process post page response from
             * remote station (XXX need to deal with PRI requests).).
@@ -313,9 +313,8 @@ Class2Modem::sendPhaseB(TIFF* tif, Class2Params& next, FaxMachineInfo& info,
                case PPR_PIP:           // page good, interrupt requested
                case PPR_RTP:           // page good, retrain requested
                 ignore:
-                   countPage(ppm == PPH_SKIP); // bump page count
-                   if (ppm != PPH_SKIP || conf.countSkippedPages)
-                       notifyPageSent(tif);// update server
+                   countPage(ppm == PPH_SKIP ? PAGE_SKIP : pt);        // bump page count
+                   notifyPageSent(tif, ppm == PPH_SKIP ? PAGE_SKIP : pt);// update server
                    if (pph[2] == 'Z')
                        pph.remove(0,2+5+1);    // discard page-chop+handling
                    else
@@ -433,7 +432,7 @@ failed:
  * is comprised of multiple strips.
  */
 bool
-Class2Modem::sendPageData(TIFF* tif, u_int pageChop)
+Class2Modem::sendPageData(TIFF* tif, u_int pageChop, bool cover)
 {
     bool rc = true;
 
@@ -501,7 +500,7 @@ Class2Modem::sendPageData(TIFF* tif, u_int pageChop)
        u_char* dp;
        if (doTagLine) {
            u_long totbytes = totdata;
-           dp = imageTagLine(data+ts, fillorder, params, totbytes);
+           dp = imageTagLine(data+ts, fillorder, params, totbytes, cover);
            totdata = (params.df == DF_2DMMR) ? totbytes : totdata+ts - (dp-data);
        } else
            dp = data;
index 380178a45c615e495ea68b7fde69ced0ab8ac4f5..5313edeb5e28a312bf25074ad805d4ae531ffc4d 100644 (file)
@@ -32,6 +32,7 @@
 #include "FaxFont.h"
 #include "t.30.h"
 #include "Sys.h"
+#include "SystemLog.h"
 
 FaxModem::FaxModem(FaxServer& s, const ModemConfig& c)
     : ClassModem(s,c)
@@ -69,6 +70,11 @@ FaxModem::sendSetup(FaxRequest& req, const Class2Params&, Status&)
     minsp = fxmax((u_int) req.minbr, fxmax((u_int) conf.minSpeed, modemParams.getMinSpeed()));
     pageNumber = 1;
     pageNumberOfJob = req.npages + 1;
+    pageNumberCovered = pageNumberSkipped = 0;
+    if (conf.tagLineCoverNumString.length() )
+           pageNumberOfJob -= req.ncover;
+    if (! conf.countSkippedPages)
+           pageNumberOfJob -= req.nskip;
     if (conf.useJobTagLine && req.desiredtl != 0)
        setupTagLine(req, req.tagline);
     else
@@ -748,16 +754,17 @@ FaxModem::recvResetPage(TIFF* tif)
 }
 
 void
-FaxModem::countPage(bool skipped)
+FaxModem::countPage(PageType pt)
 {
-    if (! skipped || conf.countSkippedPages)
-    {
-       pageNumber++;
-       pageNumberOfJob++;
-       pageNumberOfCall++;
-    }
+logDebug("FaxModem::countPage(%s)", pt == PAGE_NORMAL ? "PAGE_NORMAL" :
+                               (pt == PAGE_COVER ? "PAGE_COVER" : "PAGE_SKIP") );
+    pageNumber++;
+    pageNumberOfJob++;
+    pageNumberOfCall++;
 
-    if (skipped)
+    if (pt == PAGE_COVER)
+        pageNumberCovered++;
+    if (pt == PAGE_SKIP)
        pageNumberSkipped++;
 }
 
@@ -768,10 +775,10 @@ FaxModem::getPageNumberOfCall()
 }
 
 void
-FaxModem::notifyPageSent(TIFF* tif)
+FaxModem::notifyPageSent(TIFF* tif, PageType pt)
 {
     if (curreq)
-       server.notifyPageSent(*curreq, TIFFFileName(tif));
+       server.notifyPageSent(*curreq, TIFFFileName(tif), pt);
 }
 
 #include "MemoryDecoder.h"
index 50dfc8a2600392f64b9add81f67604a10491d47e..1b7ccd011598097356160694dd8612ad53c308e8 100644 (file)
@@ -46,6 +46,7 @@ class FaxServer;
 typedef unsigned int RTNHandling;       // RTN signal handling method 
 typedef unsigned int BadPageHandling;  // bad page (received) handling method 
 typedef unsigned int JBIGSupport;      // JBIG support available
+typedef unsigned int PageType;
 
 /*
  * This is an abstract class that defines the interface to
@@ -64,6 +65,7 @@ private:
     u_int      pageNumberOfJob;// current transmit page number of Job
     u_int      pageNumberOfCall;// current transmit page number of call
     u_int      pageNumberSkipped;// current skipped page count
+    u_int      pageNumberCovered;// current cover page count
     FaxFont*   tagLineFont;    // font for imaging tag line
     u_int      tagLineSlop;    // extra space reserved for tag line re-encoding
     fxStr      tagLine;        // tag line formatted with transmit time
@@ -120,7 +122,7 @@ protected:
     FaxModem(FaxServer&, const ModemConfig&);
 
 // miscellaneous
-    void       countPage(bool skipped = false);
+    void       countPage(PageType);
     int                getPageNumberOfCall();
     void       recvTrace(const char* fmt, ...);
     void       copyQualityTrace(const char* fmt, ...);
@@ -147,7 +149,7 @@ protected:
     void       recvResetPage(TIFF* tif);
     u_int      decodePageChop(const fxStr& pph, const Class2Params&);
     bool       decodePPM(const fxStr& pph, u_int& ppm, Status& eresult);
-    void       notifyPageSent(TIFF*);
+    void       notifyPageSent(TIFF*, PageType pt);
 // phase c data receive & copy quality checking
     bool       recvPageDLEData(TIFF* tif, bool checkQuality,
                    const Class2Params& params, Status& eresult);
@@ -167,7 +169,7 @@ protected:
 // tag line support
     bool       setupTagLineSlop(const Class2Params&);
     u_int      getTagLineSlop() const;
-    u_char*    imageTagLine(u_char* buf, u_int fillorder, const Class2Params&, u_long& totdata);
+    u_char*    imageTagLine(u_char* buf, u_int fillorder, const Class2Params&, u_long& totdata, PageType p);
 /*
  * Correct if neccessary Phase C (T.4/T.6) data (remove extra RTC/EOFB etc.)
  */
@@ -196,6 +198,12 @@ public:
        JBIG_SEND = 2,              // send-only JBIG support
        JBIG_FULL = 3               // full JBIG support
     };
+    enum {
+       PAGE_NORMAL     = 0,
+       PAGE_COVER      = 1,
+       PAGE_SKIP       = 2
+    };
+
 
     virtual ~FaxModem();
 
@@ -258,7 +266,7 @@ public:
        bool& hasDoc, Status& eresult, u_int& batched) = 0;
     virtual void sendSetupPhaseB(const fxStr& pwd, const fxStr& sub);
     virtual FaxSendStatus sendPhaseB(TIFF*, Class2Params&, FaxMachineInfo&,
-       fxStr& pph, Status& eresult, u_int& batched) = 0;
+       fxStr& pph, Status& eresult, u_int& batched, PageType = PAGE_NORMAL) = 0;
     virtual void sendEnd();
     virtual void sendAbort() = 0;
     // query interfaces for optional state
index 79a51148cbfecae44b587ff6ea5fc3da7c07d759..a1b905f9ff9e613bb3fab0bdae83448800bc696a 100644 (file)
@@ -58,7 +58,7 @@ FaxRequest::reset(void)
     pri = (u_short) -1;
     usrpri = FAX_DEFPRIORITY;
     pagewidth = pagelength = resolution = 0;
-    npages = totpages = skippages = coverpages = 0;
+    npages = totpages = nskip = skippages = ncover = coverpages= 0;
     ntries = ndials = 0;
     minbr = BR_2400;
     desiredbr = BR_33600;
@@ -126,7 +126,9 @@ FaxRequest::shortval FaxRequest::shortvals[] = {
     { "state",         &FaxRequest::state },
     { "npages",                &FaxRequest::npages },
     { "totpages",      &FaxRequest::totpages },
+    { "nskip",         &FaxRequest::nskip },
     { "skippages",     &FaxRequest::skippages },
+    { "ncover",                &FaxRequest::ncover },
     { "coverpages",    &FaxRequest::coverpages },
     { "ntries",                &FaxRequest::ntries },
     { "ndials",                &FaxRequest::ndials },
@@ -322,6 +324,7 @@ FaxRequest::readQFile(bool& rejectJob)
        case H_PAGELENGTH:      pagelength = atoi(tag); break;
        case H_PRIORITY:        usrpri = atoi(tag); break;
        case H_SCHEDPRI:        pri = atoi(tag); break;
+       case H_NSKIP:           nskip = atoi(tag); break;
        case H_SKIPPAGES:       skippages = atoi(tag); break;
        case H_DESIREDBR:       desiredbr = atoi(tag); break;
        case H_DESIREDST:       desiredst = tag[0] - '0'; break;
@@ -342,6 +345,7 @@ FaxRequest::readQFile(bool& rejectJob)
        case H_DONEOP:          doneop = tag; break;
        case H_RETURNED:        status = (FaxSendStatus) atoi(tag); break;
        case H_MINBR:           minbr = atoi(tag); break;
+       case H_NCOVER:          ncover = atoi(tag); break;
        case H_COVERPAGES:      coverpages = atoi(tag); break;
 
        case H_STATUS:
index 46ebc147f3b54447e3870e541c3fa7f1edb96e99..752e2a320915a1f255b62dadca5b96b62607c71c 100644 (file)
@@ -113,8 +113,10 @@ public:
     FaxSendStatus status;      // request status indicator
     u_short    totpages;       // total cummulative pages in documents
     u_short    skippages;      // skipped pages in documents
-    u_short    npages;         // total pages sent/received
     u_short    coverpages;     // number of cover pages 1st
+    u_short    npages;         // total pages sent/received
+    u_short    nskip;          // total pages skipped so far
+    u_short    ncover;         // cover pages sent so far
     u_short    ntries;         // # tries to send current page
     u_short    ndials;         // # consecutive failed tries to call dest
     u_short    totdials;       // total # calls to dest
index cc4614faeeb4695128a98c8f70fc9639cb997020..aca6259f401f55215777bf3fdbb1b874ebb71caa 100644 (file)
@@ -445,6 +445,7 @@ FaxServer::sendFaxPhaseB(FaxRequest& fax, FaxItem& freq, FaxMachineInfo& clientI
 {
     TIFF* tif = TIFFOpen(freq.item, "r");
     if (tif && (freq.dirnum == 0 || TIFFSetDirectory(tif, freq.dirnum))) {
+       bool coverpage = freq.item.find(0, "/cover") < freq.item.length();
        if (dosetup) {
            // set up DCS according to file characteristics
            fax.status = sendSetupParams(tif, clientParams, clientInfo, fax.result);
@@ -460,7 +461,7 @@ FaxServer::sendFaxPhaseB(FaxRequest& fax, FaxItem& freq, FaxMachineInfo& clientI
             */
            u_int prevPages = fax.npages;
            fax.status = modem->sendPhaseB(tif, clientParams, clientInfo,
-               fax.pagehandling, fax.result, batched);
+               fax.pagehandling, fax.result, batched, coverpage ? FaxModem::PAGE_COVER : FaxModem::PAGE_NORMAL);
            if (fax.status == send_v17fail && fax.result.value() == 0) {
                // non-fatal V.17 incompatibility
                clientInfo.setHasV17Trouble(true);
@@ -884,10 +885,16 @@ FaxServer::sendSetupParams(TIFF* tif, Class2Params& params, const FaxMachineInfo
  */
 
 void
-FaxServer::notifyPageSent(FaxRequest& req, const char*)
+FaxServer::notifyPageSent(FaxRequest& req, const char*, PageType pt)
 {
     time_t now = Sys::now();
     req.npages++;                      // count transmitted page
+    switch (pt) {
+       case FaxModem::PAGE_SKIP:
+           req.nskip++; break;
+       case FaxModem::PAGE_COVER:
+           req.ncover++; break;
+    }
     req.writeQFile();                  // update q file for clients
     u_short tpages = req.totpages;
     if (! modem->isCountingSkippedPages() )
index 191499ac5b58c0b55db07aeffcbb2dc3d77a2787..d7d064002abcea4014daa768e94c8eb8ca8f7068 100644 (file)
@@ -106,7 +106,7 @@ protected:
 // notification interfaces overridden in derived class
     virtual void notifyCallPlaced(const FaxRequest&);
     virtual void notifyConnected(const FaxRequest&);
-    virtual void notifyPageSent(FaxRequest&, const char*);
+    virtual void notifyPageSent(FaxRequest&, const char*, PageType pt);
     virtual void notifyDocumentSent(FaxRequest&, u_int index);
     virtual void notifyPollRecvd(FaxRequest&, FaxRecvInfo&);
     virtual void notifyPollDone(FaxRequest&, u_int index);
index fd639bc03c4e8241acdda36041451cb5435f8bd5..73702d9ad132c74995c62150d9e8199d4842111e 100644 (file)
@@ -160,6 +160,7 @@ static struct {
     const char*                 def;           // NULL is shorthand for ""
 } strcmds[] = {
 { "modemtype",                 &ModemConfig::type,             "unknown" },
+{ "taglinecovernumstring",     &ModemConfig::tagLineCoverNumString },
 { "taglinefont",               &ModemConfig::tagLineFontFile },
 { "taglineformat",             &ModemConfig::tagLineFmt,
   "From %%n|%c|Page %%p of %%t" },
index 95a085a9084f860a8bb968f00d1d70caf63ebcda..7a22aa8ca83c466335619f2fdf278599cf76ea21 100644 (file)
@@ -239,6 +239,7 @@ public:
     bool       waitForConnect;         // modem sends multiple answer responses
     fxStr      tagLineFmt;             // format string for tag lines
     fxStr      tagLineFontFile;        // font file for imaging tag lines
+    fxStr      tagLineCoverNumString;  // format string for tagline cover page numbers
     u_int      recvDataFormat;         // received facsimile data format
     bool       useJobTagLine;          // Use Job tagline or use conf taglineformat
     bool       raiseATCmd;             // whether or not to raise-case the AT commands
index 891edb76aab095c530dfce98a890c4531ccd458e..199237d8728631affbf18217daf9c9dd2c09d02f 100644 (file)
@@ -38,6 +38,7 @@ insert(fxStr& tag, u_int l, const fxStr& s)
     tag.insert(s, l);
 }
 
+extern void logDebug(const char* fmt, ...);
 /*
  * Read in the PCF font to use for imaging the tag line and
  * preformat as much of the tag line as possible.
@@ -56,9 +57,20 @@ FaxModem::setupTagLine(const FaxRequest& req, const fxStr& tagLineFmt)
     strftime(line, sizeof (line)-1, tagLineFmt, tm);
     tagLine = line;
     u_int l = 0;
+
     int tpages = req.totpages;
-    if (! conf.countSkippedPages)
+    int npages = req.npages;
+    if (! conf.countSkippedPages) {
        tpages -= req.skippages;
+       npages -= req.nskip;
+    }
+
+    if (conf.tagLineCoverNumString.length())
+    {
+       tpages -= req.coverpages;
+       npages -= req.ncover;
+    }
+
     while (l < tagLine.length()) {
        l = tagLine.next(l, '%');
        if (l >= tagLine.length()-1)
@@ -85,7 +97,7 @@ FaxModem::setupTagLine(const FaxRequest& req, const fxStr& tagLineFmt)
        case 's': insert(tagLine, l, req.sender); break;
        case 'S': insert(tagLine, l, req.regarding); break;
        case 't': insert(tagLine, l,
-                       fxStr((int)(tpages-req.npages), "%u")); break;
+                       fxStr((int)(tpages-npages), "%u")); break;
        case 'T': insert(tagLine, l,
                        fxStr((int)(tpages), "%u")); break;
        case 'v': insert(tagLine, l, req.voice); break;
@@ -143,12 +155,37 @@ FaxModem::setupTagLineSlop(const Class2Params& params)
  * setup the current page number.
  */
 u_char*
-FaxModem::imageTagLine(u_char* buf, u_int fillorder, const Class2Params& params, u_long& totdata)
+FaxModem::imageTagLine(u_char* buf, u_int fillorder, const Class2Params& params, u_long& totdata, PageType pt)
 {
     u_int l;
+    u_int pn = pageNumber;
+    u_int pnj = pageNumberOfJob;
+
+    if (! conf.countSkippedPages) {
+       pn -= pageNumberSkipped;
+       pnj -= pageNumberSkipped;
+    }
     /*
      * Fill in any per-page variables used in the tag line.
+     * If the TagLineCoverNumString is set, then coverpages
+     * are not counted, and that is used instead of pages numbers on
+     * the cover pages themselves.
      */
+    fxStr pns, pnjs;
+    if (pt == PAGE_COVER && conf.tagLineCoverNumString.length()) {
+       // Actually on the cover page, with it CoverNumString set
+       pns = conf.tagLineCoverNumString;
+       pnjs = conf.tagLineCoverNumString;
+    } else if (conf.tagLineCoverNumString.length() ) {
+       // regular page, with it CoverNumString set, adjust page numbers
+       pns = fxStr::format("%d", pn-pageNumberCovered);
+       pnjs = fxStr::format("%d", pnj-pageNumberCovered);
+    } else {
+       // CoverNumString not set, just do it
+       pns = fxStr::format("%d", pnj);
+       pnjs = fxStr::format("%d", pnj);
+    }
+
     fxStr tag = tagLine;
     l = 0;
     while (l < tag.length()) {
@@ -156,9 +193,9 @@ FaxModem::imageTagLine(u_char* buf, u_int fillorder, const Class2Params& params,
        if (l >= tag.length()-1)
            break;
        if (tag[l+1] == 'p')
-           insert(tag, l, fxStr((int) pageNumber, "%d"));
+           insert(tag, l, pns);
        if (tag[l+1] == 'P')
-           insert(tag, l, fxStr((int) pageNumberOfJob, "%d"));
+           insert(tag, l, pnjs);
        else
            l += 2;
     }
index d0306eb13b1a2c338049b7941ea47e523ea0ca65..766a3009791fad94d07d01c86141023b3ec3790c 100644 (file)
@@ -829,7 +829,8 @@ faxQueueApp::preparePageHandling(Job& job, FaxRequest& req,
     Class2Params next;                 // parameters for ``next'' page
     TIFF* tif = NULL;                  // current open TIFF image
     req.totpages = req.npages;         // count pages previously transmitted
-    req.skippages = 0;
+    req.skippages = req.nskip;
+    req.coverpages = req.ncover;
     bool firstpage = true;
     bool skiplast = false;
     bool coverdoc = false;
@@ -861,6 +862,8 @@ faxQueueApp::preparePageHandling(Job& job, FaxRequest& req,
            }
            const FaxItem& fitem = req.items[i];
 
+           logDebug("req.items[%d].item = \"%s\" (%s)", i,
+                   (const char*)fitem.item, (const char*)req.cover);
            if (fitem.item.find(0, "/cover") < fitem.item.length())
                coverdoc = true;
            else
index 524c0a72e1e22a54b3c76b44c89345bde7dbc9ac..9211e8fc358e464c1ed66888edeb0032496ad0bf 100644 (file)
@@ -299,13 +299,13 @@ faxSendApp::notifyConnected(const FaxRequest& req)
 }
 
 void
-faxSendApp::notifyPageSent(FaxRequest& req, const char* filename)
+faxSendApp::notifyPageSent(FaxRequest& req, const char* filename, bool skipped)
 {
     FaxSendInfo si(filename, req.commid, req.npages+1,
        getPageTransferTime(), getClientParams());
     sendJobStatus(req.jobid, "d%s", (const char*) si.encode());
 
-    FaxServer::notifyPageSent(req, filename);
+    FaxServer::notifyPageSent(req, filename, skipped);
 }
 
 /*
index 7939aa3dd266deaabc9876eea8918984c6303274..90c7ded46f966a2584c9594f1b80d42ac094601f 100644 (file)
@@ -80,7 +80,7 @@ private:
     void       notifyModemWedged();
     void       notifyCallPlaced(const FaxRequest&);
     void       notifyConnected(const FaxRequest&);
-    void       notifyPageSent(FaxRequest& req, const char* filename);
+    void       notifyPageSent(FaxRequest& req, const char* filename, bool skipped);
     void       notifyDocumentSent(FaxRequest&, u_int fileIndex);
     void       notifyPollRecvd(FaxRequest&, FaxRecvInfo&);
     void       notifyPollDone(FaxRequest&, u_int pollIndex);
index 98c9a51f87275214e9eeac47a6ce6bb5d44b7a68..e7313f3d875ccb1dfdaf423052da6e4e4a5c7512 100644 (file)
@@ -102,10 +102,13 @@ main()
     hash("subaddr");
     hash("passwd");
     hash("state");
+    hash("ncover");
     hash("coverpages");
     hash("npages");
     hash("totpages");
+    hash("nskip");
     hash("skippages");
+    hash("coverpages");
     hash("ntries");
     hash("ndials");
     hash("totdials");
index 9069b6df2ccf4e298e1fe5707873e4d32daa46a2..11f7be6216bb56940913021a3a76986728587a18 100644 (file)
@@ -215,6 +215,7 @@ SendUUCPCmd\(S1     string  \s-1bin/uucpsend\s+1    \s-1UUCP\s+1 transmit command script
 ServerTracing\(S2      integer \s-11\s+1       non-session server tracing
 SessionTracing\(S2     integer \s-11\s+1       send and receive session tracing
 SpeakerVolume  string  \s-1Quiet\s+1   volume level for modem speaker
+TagLineCoverNumString  string  \-      String substition when not counting cover pages
 TagLineFont    string  \-      tag line font filename
 TagLineFormat  string  \s-1\fIsee below\fP\s+1 tag line format string
 TIFF2FaxCmd\(S1        string  \s-1bin/tiff2fax\s+1    \s-1TIFF\s+1 converter command script
@@ -1604,6 +1605,13 @@ Also beware that some modems support fewer volume settings;
 see
 .BR ModemSetVolumeCmd .
 .TP
+.B TagLineCoverNumString
+
+Setting TagLineCoverNumString instructs faxsend to not include the cover pages
+in the normal page numbering mechanism.  The page numbers used in the tagline
+generation will adjusted to not count the cover pages, and the TagLineCoverNumString value
+wil be used instead of a page number on the tagline of the cover page.
+.TP
 .B TagLineFont
 The filename of the font to use in imaging 
 .I "tag lines"