]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
More faxq batch enhancments: Bug 625
authorAidan Van Dyk <aidan@ifax.com>
Thu, 3 Mar 2005 19:25:36 +0000 (19:25 +0000)
committerAidan Van Dyk <aidan@ifax.com>
Thu, 3 Mar 2005 19:25:36 +0000 (19:25 +0000)
It add's a configuration options:

BatchLogs: boolean

It defaults to true.

If BatchLogs is set to true, then all the logs for a batch job are
contained in a single session logs.  If it is set to false, each
document has it's own session log, for both sending and receiving.

faxd/FaxRecv.c++
faxd/FaxSend.c++
faxd/FaxServer.h
faxd/ModemServer.c++
faxd/ModemServer.h
faxd/ServerConfig.c++
faxd/ServerConfig.h
faxd/faxGettyApp.c++
man/hylafax-config.4f

index b6aa852a02a4598035e0809234c0c39f2b136a60..58fd3ab25f21ff26e922a6524405ff351ff370fb 100644 (file)
@@ -170,6 +170,7 @@ FaxServer::recvDocuments(TIFF* tif, FaxRecvInfo& info, FaxRecvInfoArray& docs, f
     bool recvOK;
     u_int ppm = PPM_EOP;
     pageStart = Sys::now();
+    batchid = getCommID();
     for (;;) {
        bool okToRecv = true;
        fxStr reason;
@@ -240,6 +241,14 @@ FaxServer::recvDocuments(TIFF* tif, FaxRecvInfo& info, FaxRecvInfoArray& docs, f
        /*
         * Setup state for another file.
         */
+       if (! batchLogs)
+       {
+           traceServer("SESSION BATCH CONTINUING");
+           endSession();
+           beginSession(FAXNumber);
+           batchid.append(","|getCommID());
+           traceServer("SESSION BATCH %s", (const char*)batchid);
+       }
        tif = setupForRecv(info, docs, emsg);
        if (tif == NULL)
            return (false);
index d98c742b67bfbcd9d8d06ce4a551c1548e91adf2..278c9f97a1c3cf4905ed0a035395109295c239ab 100644 (file)
@@ -47,7 +47,19 @@ FaxServer::sendFax(FaxRequest& fax, FaxMachineInfo& clientInfo, FaxAcctInfo& ai,
 {
     u_int prevPages = fax.npages;
     if (!(batched & BATCH_FIRST) || lockModem()) {
-       beginSession(fax.number);
+        if (batched & BATCH_FIRST)
+       {
+           beginSession(fax.number);
+           batchid = getCommID();
+       } else
+       {
+           if (! batchLogs)
+           {
+               beginSession(fax.number);
+               batchid.append("," | getCommID());
+               traceServer("SESSION BATCH %s", (const char*) batchid);
+           }
+        }
        fax.commid = getCommID();               // set by beginSession
        traceServer("SEND FAX: JOB %s DEST %s COMMID %s DEVICE '%s'"
            , (const char*) fax.jobid
@@ -83,11 +95,12 @@ FaxServer::sendFax(FaxRequest& fax, FaxMachineInfo& clientInfo, FaxAcctInfo& ai,
            discardModem(true);
            changeState(MODEMWAIT, 5);
            unlockModem();
-       } else
+           endSession();
+       } else if(! batchLogs)
        {
-           traceServer("BATCH CONTINUING");
+           traceServer("SESSION BATCH CONTINUES");
+           endSession();
        }
-       endSession();
     } else {
        if (state != LOCKWAIT)
            sendFailed(fax, send_retry,
index ce0a3ef39112b25b9336cf7168167f8ad07c67be..3f3c8e1b4081ad65466d275385167053d745e0df 100644 (file)
@@ -58,6 +58,7 @@ private:
     time_t     fileStart;              // starting time for file transmit
     time_t     pageStart;              // starting time for page transmit
     u_int      npages;                 // # pages sent/received
+    fxStr      batchid;                // Batch ID, for session logs
 
     friend class FaxModem;
 
index 5f169f995d9c344b248c08cab5f37fa8fe5d9d61..17fb10fde5f3abce00c58ea42e6c7ce9b0749294 100644 (file)
@@ -663,17 +663,6 @@ ModemServer::beginSession(const fxStr& number)
        log =
            new FaxMachineLog(ftmp, canonicalizePhoneNumber(number), commid);
     }
-
-    if (batchid)
-    {
-       batchid.append("," | commid);
-       traceServer("CONTINUE BATCH %s", (const char*)batchid);
-    } else
-    {
-       batchid = commid;
-    }
-
-
 }
 
 /*
index 5b6fac41c5fadd4377f7433f700e28f5aeca6c50..3e78d2a3d2895597613ff10eef4ab0a68c890b1f 100644 (file)
@@ -66,7 +66,6 @@ private:
     bool       changePriority;         // change process priority by state
     bool       delayConfig;            // suppress effects while reading config
     fxStr      dialRulesFile;          // dial string rules filename
-    fxStr      batchid;                // communication ID from start of batch
     fxStr      commid;                 // communication ID
 // generic modem-related stuff
     int                modemFd;                // open modem file
index efc19aa67da0cc65ad52ec2661506c545399597e..4939679e05d39ac372a25f18615c00191982ee80 100644 (file)
@@ -77,6 +77,10 @@ ServerConfig::configTrace(const char* fmt, ...)
 
 #define        N(a)    (sizeof (a) / sizeof (a[0]))
 
+ServerConfig::S_booltag ServerConfig::bools[] = {
+{ "batchlogs",         &ServerConfig::batchLogs,       true },
+};
+
 ServerConfig::S_stringtag ServerConfig::strings[] = {
 { "logfacility",       &ServerConfig::logFacility,     LOG_FAX },
 { "faxnumber",         &ServerConfig::FAXNumber },
@@ -116,6 +120,8 @@ ServerConfig::setupConfig()
 {
     int i;
 
+    for (i = N(bools)-1; i >= 0; i--)
+       (*this).*bools[i].p = bools[i].def;
     for (i = N(strings)-1; i >= 0; i--)
        (*this).*strings[i].p = (strings[i].def ? strings[i].def : "");
     for (i = N(filemodes)-1; i >= 0; i--)
@@ -435,6 +441,8 @@ ServerConfig::setConfigItem(const char* tag, const char* value)
        }
     } else if (findTag(tag, (const tags*)filemodes, N(filemodes), ix))
        (*this).*filemodes[ix].p = strtol(value, 0, 8);
+    else if (findTag(tag, (const tags*)bools, N(bools), ix))
+       (*this).*bools[ix].p = getBoolean(value);
 
     else if (streq(tag, "speakervolume"))
        setModemSpeakerVolume(getVolume(value));
index 1d92e64300b9dce64e28fccc03f288319c36de21..a42869e33c4d7a009036311512bf6ffb18a6880b 100644 (file)
@@ -43,6 +43,11 @@ public:
        fxStr ServerConfig::* p;
        const char*      def;           // NULL is shorthand for ""
     };
+    struct S_booltag {
+       const char*      name;
+       bool ServerConfig::* p;
+       bool             def;           // NULL is shorthand for ""
+    };
     struct S_numbertag {
        const char*      name;
        u_int ServerConfig::*p;
@@ -73,6 +78,7 @@ private:
     fxBoolArray* acceptPWD;            // accept/reject matched PWD
     fxStr      logFacility;            // syslog facility to direct trace msgs
 
+    static S_booltag bools[];
     static S_stringtag strings[];
     static S_numbertag numbers[];
     static S_filemodetag filemodes[];
@@ -117,6 +123,7 @@ public:
     fxStr      localIdentifier;        // to use in place of FAXNumber
     fxStr      FAXNumber;              // phone number
     u_int      maxSetupAttempts;       // # times to try initializing modem
+    bool       batchLogs;              // Batch session logs togther or not
 
     virtual ~ServerConfig();
 
index ba2100242d9805b6f3b130a1f17f77b965431016..a3e27ca4a443faaae8d75bc84c6b87b420e2748c 100644 (file)
@@ -840,7 +840,7 @@ faxGettyApp::notifyRecvDone(FaxRecvInfo& ri)
     fxStr cmd(faxRcvdCmd
        | quote |             ri.qfile  | enquote
        | quote |   getModemDeviceID()  | enquote
-       | quote |           getCommID() | enquote
+       | quote |            ri.commid  | enquote
        | quote |            ri.reason  | enquote
        | callid_formatted);
     traceServer("RECV FAX: %s", (const char*) cmd);
index 9feeed733fc93bfc1b4674dfece4c4d70c1616fa..f8532c00950a1d5f33c46d698c0ad61f6d9d0185 100644 (file)
@@ -120,6 +120,7 @@ AdminGroup  string  \s-1faxadmin\s+1        System user group for administration (if PAM
 AnswerRotary   string  \s-1Any\s+1     alternatives for answering calls
 AnswerBias     integer \-      bias to apply to successful rotary answer 
 AreaCode\(S2   string  \-      local area code
+BatchLogs\(S1  boolean \s-1Yes\s+1     keep all session logs of a batch in a single log
 CallIDAnswerLength     integer \-      answer call when CallIDPattern received
 CallIDPattern  strint  \-      call identification pattern string
 CIDName        string  \-      equivalent to CallIDPattern (2)
@@ -496,6 +497,11 @@ to formulate canonical phone numbers for dialing (see
 .B DialStringRules
 below.)
 .TP
+.B BatchLogs\(S1
+When sending or recieving multiple documents (denoted by EOM), this
+value determines if the session logs span the entire batch or, if set
+to no, only contain a single document.
+.TP
 .B CallIDPattern
 A string that identifies the caller's identity in any call
 identification messages provided by the modem (such as Caller*ID or DNIS/DID).