From: Aidan Van Dyk Date: Thu, 3 Mar 2005 19:25:36 +0000 (+0000) Subject: More faxq batch enhancments: Bug 625 X-Git-Tag: HYLAFAX-4_2_2BETA1~86 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=37bdc59e810a9eaab8a7cce082aefd4d6480be8e;p=thirdparty%2FHylaFAX.git More faxq batch enhancments: Bug 625 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. --- diff --git a/faxd/FaxRecv.c++ b/faxd/FaxRecv.c++ index b6aa852a..58fd3ab2 100644 --- a/faxd/FaxRecv.c++ +++ b/faxd/FaxRecv.c++ @@ -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); diff --git a/faxd/FaxSend.c++ b/faxd/FaxSend.c++ index d98c742b..278c9f97 100644 --- a/faxd/FaxSend.c++ +++ b/faxd/FaxSend.c++ @@ -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, diff --git a/faxd/FaxServer.h b/faxd/FaxServer.h index ce0a3ef3..3f3c8e1b 100644 --- a/faxd/FaxServer.h +++ b/faxd/FaxServer.h @@ -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; diff --git a/faxd/ModemServer.c++ b/faxd/ModemServer.c++ index 5f169f99..17fb10fd 100644 --- a/faxd/ModemServer.c++ +++ b/faxd/ModemServer.c++ @@ -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; - } - - } /* diff --git a/faxd/ModemServer.h b/faxd/ModemServer.h index 5b6fac41..3e78d2a3 100644 --- a/faxd/ModemServer.h +++ b/faxd/ModemServer.h @@ -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 diff --git a/faxd/ServerConfig.c++ b/faxd/ServerConfig.c++ index efc19aa6..4939679e 100644 --- a/faxd/ServerConfig.c++ +++ b/faxd/ServerConfig.c++ @@ -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)); diff --git a/faxd/ServerConfig.h b/faxd/ServerConfig.h index 1d92e643..a42869e3 100644 --- a/faxd/ServerConfig.h +++ b/faxd/ServerConfig.h @@ -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(); diff --git a/faxd/faxGettyApp.c++ b/faxd/faxGettyApp.c++ index ba210024..a3e27ca4 100644 --- a/faxd/faxGettyApp.c++ +++ b/faxd/faxGettyApp.c++ @@ -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); diff --git a/man/hylafax-config.4f b/man/hylafax-config.4f index 9feeed73..f8532c00 100644 --- a/man/hylafax-config.4f +++ b/man/hylafax-config.4f @@ -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).