]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
[Bug 149] Changed - adds DestControls "Modem" option
authorDarren Nickerson <darren.nickerson@ifax.com>
Sun, 17 Jun 2001 17:57:55 +0000 (17:57 +0000)
committerDarren Nickerson <darren.nickerson@ifax.com>
Sun, 17 Jun 2001 17:57:55 +0000 (17:57 +0000)
Thanks Vyacheslav!!

faxd/DestControl.c++
faxd/DestControl.h
faxd/Modem.c++
faxd/Modem.h
faxd/faxQueueApp.c++
faxd/faxQueueApp.h
man/destctrls.4f

index 1ddc9eb9a2f193046ea5c06a65aaf41b94f7797a..a9020f0d03f1b4301b4f2f097554bd307004f2de 100644 (file)
@@ -47,6 +47,7 @@ DestControlInfo::DestControlInfo(const char* re) : pattern(re)        { defined = 0; }
 DestControlInfo::DestControlInfo(const DestControlInfo& other)
     : pattern(other.pattern)
     , rejectNotice(other.rejectNotice)
+    , modem(other.modem)
     , tod(other.tod)
     , args(other.args)
 {
@@ -68,6 +69,8 @@ DestControlInfo::parseEntry(const char* tag, const char* value)
 {
     if (streq(tag, "rejectnotice")) {
        rejectNotice = value;
+    } else if (streq(tag, "modem")) {
+       modem = value;
     } else if (streq(tag, "maxconcurrentjobs")) {
        maxConcurrentJobs = getNumber(value);
        setDefined(DCI_MAXCONCURRENTJOBS);
@@ -130,6 +133,12 @@ DestControlInfo::getRejectNotice() const
     return rejectNotice;
 }
 
+const fxStr&
+DestControlInfo::getModem() const
+{
+    return modem;
+}
+
 time_t
 DestControlInfo::nextTimeToSend(time_t t) const
 {
index 476283f6638542306c37289b79b0df38426d4e4b..8687cfe2971adc567d7d4b40be994cacdad116f6 100644 (file)
@@ -47,6 +47,7 @@ private:
     u_int      maxDials;               // max times to dial the phone
     u_int      maxTries;               // max transmit attempts
     fxStr      rejectNotice;           // if set, reject w/ this notice
+    fxStr      modem;                  // if set, try with it
     TimeOfDay  tod;                    // time of day restrictions
     fxStr      args;                   // arguments for subprocesses
 
@@ -68,6 +69,7 @@ public:
     u_int getMaxDials() const;
     u_int getMaxTries() const;
     const fxStr& getRejectNotice() const;
+    const fxStr& getModem() const;
     time_t nextTimeToSend(time_t) const;
     const fxStr& getArgs() const;
 };
index 36dd82fa3a8086e1412e87c523d45c33333244d0..795b6c7e3d524c92d10190dd00ad05026653287c 100644 (file)
@@ -136,39 +136,62 @@ Modem::isCapable(const Job& job) const
  * work associated with the specified job.
  */
 Modem*
-Modem::findModem(const Job& job)
+Modem::findModem(const Job& job, const DestControlInfo& dci)
 {
     RegEx* c = ModemGroup::find(job.device);
     if (c) {
+       const fxStr& mdci = dci.getModem();
+       RegEx* cdci = mdci != "" ? ModemGroup::find(mdci) : NULL;
+       int loops = 2;
+
        /*
-        * Job is assigned to a class of modems; search
-        * the set of modems in the class according to
-        * the order specified (if any order is specified).
+        * At first try to find modem strictly (suitable to job and destination rules)
+        * Then try to find modem not strictly (suitable to job rules only)
         */
-       for (ModemIter iter(list); iter.notDone(); iter++) {
-           Modem& modem = iter;
-           if (modem.getState() != Modem::READY)
-               continue;
-           if (c->Find(modem.devID) && modem.isCapable(job)) {
 
-               /*
-                * Move modem to the end of the priority group
-                */
+       for (int i = 0 ; i < loops ; i++) {
+           /*
+            * Job is assigned to a class of modems; search
+            * the set of modems in the class according to
+            * the order specified (if any order is specified).
+            */
+           for (ModemIter iter(list); iter.notDone(); iter++) {
+               Modem& modem = iter;
+               if (c->Find(modem.devID) && modem.isCapable(job)) {
+                   if (i == 0) {
+                       if (cdci) {                     // destination assigned to a class of modems
+                           if (!cdci->Find(modem.devID))
+                               continue;
+                       } else if (mdci != "") {        // destination assigned to an explicit modem
+                           if (mdci != modem.devID)
+                               continue;
+                       }
+                       loops = 1;                      // there is a strictly suitable modem
+                   }
+
+                   if (modem.getState() != Modem::READY) {
+                       continue;
+                   }
 
-               modem.remove();
+                   /*
+                    * Move modem to the end of the priority group
+                    */
 
-               if (!list.isEmpty()) {
-                   ModemIter iter(list);
+                   modem.remove();
 
-                   for ( ; iter.notDone(); iter++) {
-                       if (iter.modem().priority > modem.priority)
-                           break;
-                   }
-                   modem.insert(iter.modem());
-               } else
-                   modem.insert(list);
+                   if (!list.isEmpty()) {
+                       ModemIter iter(list);
+
+                       for ( ; iter.notDone(); iter++) {
+                           if (iter.modem().priority > modem.priority)
+                               break;
+                       }
+                       modem.insert(iter.modem());
+                   } else
+                       modem.insert(list);
 
-               return (&modem);
+                   return (&modem);
+               }
            }
        }
     } else {
index 7322234208723e95299eaa18768083360913588a..c70b269cc3251d27781ea6efe61052d000116a77 100644 (file)
@@ -107,7 +107,7 @@ public:
 
     static Modem& getModemByID(const fxStr& id);
     static Modem* modemExists(const fxStr& id);
-    static Modem* findModem(const Job& job);
+    static Modem* findModem(const Job& job, const DestControlInfo& dci);
 
     bool assign(Job&);         // assign modem
     void release();                    // release modem
index 3b3e27422cf14ed02a789815d54dc0f21a49007a..9c25f3188be1b2e0060709b3fdbb9ca8e1a4ec38 100644 (file)
@@ -2099,7 +2099,7 @@ faxQueueApp::runScheduler()
                job.remove();                   // remove from run queue
                delayJob(job, *req, "Delayed by time-of-day restrictions", tts);
                delete req;
-           } else if (assignModem(job)) {
+           } else if (assignModem(job, dci)) {
                job.remove();                   // remove from run queue
                /*
                 * We have a modem and have assigned it to the
@@ -2143,14 +2143,14 @@ faxQueueApp::runScheduler()
  * use from faxgetty processes.
  */
 bool
-faxQueueApp::assignModem(Job& job)
+faxQueueApp::assignModem(Job& job, const DestControlInfo& dci)
 {
     fxAssert(job.modem == NULL, "Assigning modem to job that already has one");
 
     bool retryModemLookup;
     do {
        retryModemLookup = false;
-       Modem* modem = Modem::findModem(job);
+       Modem* modem = Modem::findModem(job, dci);
        if (modem) {
            if (modem->assign(job)) {
                Trigger::post(Trigger::MODEM_ASSIGN, *modem);
index 72e30fa50f58fa219f297ba7a36cb34a4685e037..549d652d5d92f95d08bb167c0c4f53d70d5a543a 100644 (file)
@@ -154,7 +154,7 @@ private:
     fxStr      canonicalizePhoneNumber(const fxStr& ds);
 // modem support
     void       scanForModems();
-    bool       assignModem(Job& job);
+    bool       assignModem(Job& job, const DestControlInfo&);
     void       releaseModem(Job& job);
     void       notifyModemWedged(Modem&);
     void       pollForModemLock(Modem& modem);
index 310ac34a58053ea62224d44a2ef926b253da5d02..5f90b2d7a112de3c064d126f75e328de31c2ac46 100644 (file)
@@ -91,11 +91,33 @@ MaxConcurrentJobs   integer \s-11\s+1       max concurrent jobs to process for a destina
 MaxDials       integer \s-1\fIunlimited\fP\s+1 max phone calls to make to transmit a job
 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
 RejectNotice   string  \-      rejection notice for transmit job
 TimeOfDay      string  \s-1Any\s+1     default time-of-day restrictions
 .fi
 .PP
 The
+.B Modem
+parameter controls which
+.B ModemGroup
+is used in sending faxes to the destination.  If the user
+assigns a
+.B ModemGroup
+for a specific job where all modems are outside of this
+.B ModemGroup
+matching a destination, then the value of
+.B Modem
+is overridden by the user's assignment.  Likewise, if the user
+assigns a
+.B ModemGroup
+for a specific job where some, but not all, of the modems are
+included in this
+.B ModemGroup
+matching a destination, then the value of
+.B Modem
+is overridden by the inclusive set of modems found in both.
+.PP
+The
 .B RejectNotice
 parameter controls whether or not to reject
 jobs to the destination.