![]() |
Is it possible to configure hylafax to use spesific modem to send fax and base this on username of the sender?
For example I have 8 modems attached with muliport pci card and I want user X to send fax through fax#1 and user Y to send fax through fax#2 and etc..
I want to set this up using email interface of hylafax (faxmail).
.* owner=omer modem=ttyS0 .* owner=lee modem=ttyS1
By the way which MultiPort PCI card do you advice me to use with FreeBSD 6.0?
diff -Nru hylafax.orig/faxd/DestControl.c++ hylafax/faxd/DestControl.c++ --- hylafax.orig/faxd/DestControl.c++ 2006-01-11 10:24:48.552198392 -0800 +++ hylafax/faxd/DestControl.c++ 2006-01-11 16:47:34.415856432 -0800 @@ -44,8 +44,8 @@ const DestControlInfo DestControlInfo::defControlInfo; -DestControlInfo::DestControlInfo() : pattern("") { defined = 0; } -DestControlInfo::DestControlInfo(const char* re) : pattern(re) { defined = 0; } +DestControlInfo::DestControlInfo() : pattern("") { defined = 0; owner = ""; } +DestControlInfo::DestControlInfo(const char* re) : pattern(re) { defined = 0; owner = ""; } DestControlInfo::DestControlInfo(const DestControlInfo& other) : pattern(other.pattern) , rejectNotice(other.rejectNotice) @@ -53,6 +53,7 @@ , tod(other.tod) , args(other.args) { + owner = other.owner; defined = other.defined; maxConcurrentCalls = other.maxConcurrentCalls; maxSendPages = other.maxSendPages; @@ -75,6 +76,8 @@ rejectNotice = value; } else if (streq(tag, "modem")) { modem = value; + } else if (streq(tag, "owner")) { + owner = value; } else if (streq(tag, "maxconcurrentjobs")) { // backwards compatibility maxConcurrentCalls = getNumber(value); setDefined(DCI_MAXCONCURRENTCALLS); @@ -190,6 +193,7 @@ DestControl::DestControl() { lastModTime = 0; + user = ""; } DestControl::~DestControl() {} @@ -202,6 +206,12 @@ } } +void +DestControl::setUser(fxStr s) +{ + user = s; +} + const DestControlInfo& DestControl::operator[](const fxStr& canon) { @@ -213,6 +223,7 @@ } for (u_int i = 0, n = info.length(); i < n; i++) { DestControlInfo& dci = info[i]; + if (dci.owner != "" && !streq(dci.owner, user)) continue; // pattern is specific to another user if (dci.pattern.Find(canon)) return (dci); } diff -Nru hylafax.orig/faxd/DestControl.h hylafax/faxd/DestControl.h --- hylafax.orig/faxd/DestControl.h 2006-01-11 10:24:48.500206296 -0800 +++ hylafax/faxd/DestControl.h 2006-01-11 16:16:48.781435512 -0800 @@ -40,7 +40,7 @@ */ class DestControlInfo { private: - RE pattern; // destination pattern + RE pattern; // destination pattern u_long defined; // parameters that were defined u_int maxConcurrentCalls; // max number of parallel calls u_int maxSendPages; // max pages in a send job @@ -48,6 +48,7 @@ u_int maxTries; // max transmit attempts fxStr rejectNotice; // if set, reject w/ this notice fxStr modem; // if set, try with it + fxStr owner; // if set, rule only applies to owner TimeOfDay tod; // time of day restrictions int usexvres; // use extended resolution u_int vres; // use extended resolution @@ -87,6 +88,7 @@ class DestControl { private: fxStr filename; // database filename + fxStr user; // control username time_t lastModTime; // last modification timestamp u_int lineno; // line number while parsing DestControlInfoArray info; // control information @@ -101,6 +103,7 @@ virtual ~DestControl(); void setFilename(const char* filename); + void setUser(fxStr); const DestControlInfo& operator[](const fxStr&); }; diff -Nru hylafax.orig/faxd/faxQueueApp.c++ hylafax/faxd/faxQueueApp.c++ --- hylafax.orig/faxd/faxQueueApp.c++ 2006-01-11 10:24:48.499206448 -0800 +++ hylafax/faxd/faxQueueApp.c++ 2006-01-11 16:25:49.310262640 -0800 @@ -442,9 +442,13 @@ setDead(job); } } - if (processnext) processJob(*targetjob, targetjob->breq, destJobs[targetjob->dest], destCtrls[targetjob->dest]); - else if (startsendjob) sendJobStart(*targetjob->bfirst(), targetjob->bfirst()->breq, destCtrls[targetjob->dest]); - else { + if (processnext) { + destCtrls.setUser(targetjob->breq->owner); + processJob(*targetjob, targetjob->breq, destJobs[targetjob->dest], destCtrls[targetjob->dest]); + } else if (startsendjob) { + destCtrls.setUser(targetjob->bfirst()->breq->owner); + sendJobStart(*targetjob->bfirst(), targetjob->bfirst()->breq, destCtrls[targetjob->dest]); + } else { /* * This destination was marked as called, but all jobs to this * destination failed preparation, so we must undo the call marking. @@ -2193,17 +2197,19 @@ * ready for processing. */ Job* jb; - const DestControlInfo& dci = destCtrls[job.dest]; u_int n = 1; - while (isOKToCall(di, dci, n) && (jb = di.nextBlocked())) { - setReadyToRun(*jb); - if (!di.supportsBatching()) n++; + while (jb = di.nextBlocked()) { FaxRequest* req = readRequest(*jb); - if (req) { + if (!req) continue; + destCtrls.setUser(req->owner); + const DestControlInfo& dci = destCtrls[job.dest]; + if (isOKToCall(di, dci, n)) { + setReadyToRun(*jb); + if (!di.supportsBatching()) n++; req->notice = ""; updateRequest(*req, *jb); - delete req; } + delete req; } } @@ -2295,6 +2301,7 @@ /* * Do per-destination processing and checking. */ + destCtrls.setUser(req->owner); DestInfo& di = destJobs[job.dest]; const DestControlInfo& dci = destCtrls[job.dest]; /* diff -Nru hylafax.orig/man/destctrls.4f hylafax/man/destctrls.4f --- hylafax.orig/man/destctrls.4f 2006-01-11 10:24:48.480209336 -0800 +++ hylafax/man/destctrls.4f 2006-01-11 16:57:43.970190088 -0800 @@ -70,9 +70,10 @@ When a parameter value is needed .I faxq sequentially scans the file until it finds a record that matches -the canonical form of the destination phone number. -If the requested parameter is defined in this record, then the -value is returned, otherwise a default value is used from the +the canonical form of the destination phone number. If ``owner'' is +included in the entry, then the owner of the job-in-process must also +match. If a matching entry is found, then the +values given in the entry are used, otherwise values are used from the .I faxq configuration file. .PP @@ -81,8 +82,10 @@ .IR hylafax-config (${MANNUM4_5}) for a description of each parameter (except +.B Owner +and .B RejectNotice -which is described below). +which are described below). .sp .5 .nf .ta \w'MaxConcurrentCalls 'u +\w'integer 'u +\w'\fIunlimited\fP 'u @@ -92,6 +95,7 @@ MaxSendPages integer \s-1\fIunlimited\fP\s+1 max pages to permit in a send MaxTries integer \s-13\s+1 max attempts to transmit a job Modem string \s-1Any\s+1 ModemGroup to use for destination +Owner string \s-1\s+1 Restrict to jobs owned by this user RejectNotice string \- rejection notice for transmit job TimeOfDay string \s-1Any\s+1 default time-of-day restrictions VRes integer \- Vertical resolution @@ -120,6 +124,13 @@ is overridden by the inclusive set of modems found in both. .PP The +.B Owner +parameter constrains the usage of the entry to when the job +owner matches this user. Entries containing an +.B Owner +setting will be skipped when jobs from other users are processed. +.PP +The .B RejectNotice parameter controls whether or not to reject jobs to the destination. diff -Nru hylafax.orig/man/hylafax-config.4f hylafax/man/hylafax-config.4f --- hylafax.orig/man/hylafax-config.4f 2006-01-11 10:24:48.458212680 -0800 +++ hylafax/man/hylafax-config.4f 2006-01-11 16:49:55.663383544 -0800 @@ -661,7 +661,7 @@ .TP .B DestControls\(S1 An optional file containing rules for controlling -parameters on a per-destination basis; see +parameters on a per-destination and optionally also a per-job-owner basis; see .IR destctrls (${MANNUM4_5}) The following parameters may be controlled with this mechanism: .BR MaxConcurrentCalls ,