"uucp",
"15", "16", "17"
};
+/*
+ * These are also used in util/notify.sh.in
+ */
const char* FaxRequest::notifyVals[4] = {
"none", // no_notice
"when done", // when_done
void writeQFile();
u_int findItem(FaxSendOp, u_int start = 0) const;
- bool isNotify(u_int what) const;
-
static bool isStrCmd(const char* cmd, u_int& ix);
static bool isShortCmd(const char* cmd, u_int& ix);
fxStr code; // code relating to notice
#endif
};
-inline bool FaxRequest::isNotify(u_int what) const
- { return (notify & (u_short) what) != 0; }
+
#endif /* _FaxRequest_ */
(const char*)strTime(req->tts - now), req->result.string());
setSleep(job, req->tts);
Trigger::post(Trigger::SEND_REQUEUE, job);
- if (req->isNotify(FaxRequest::when_requeued))
- notifySender(job, Job::requeued);
+ notifySender(job, Job::requeued);
} else {
traceQueue(job, "SEND INCOMPLETE: retry immediately; %s",
req->result.string());
req.result = r;
updateRequest(req, job);
traceQueue(job, "%s", r.string());
- if (req.isNotify(FaxRequest::when_requeued) && old_state != FaxRequest::state_blocked)
- notifySender(job, Job::blocked);
+ if (old_state != FaxRequest::state_blocked)
+ notifySender(job, Job::blocked);
Trigger::post(Trigger::JOB_BLOCKED, job);
}
traceQueue(job, "%s: requeue for %s",
r.string(), (const char*)strTime(delay));
setSleep(job, tts);
- if (req.isNotify(FaxRequest::when_requeued))
- notifySender(job, Job::requeued);
+ notifySender(job, Job::requeued);
Trigger::post(Trigger::JOB_DELAYED, job);
}
req.pri = job.pri; // just in case someone cares
req.tts = Sys::now(); // mark job termination time
req.writeQFile();
- if (force || req.isNotify(FaxRequest::notify_any))
- notifySender(job, why, duration);
+ notifySender(job, why, duration);
} else {
/*
* Move failed, probably because there's no
*/
jobError(job, "rename to %s failed: %s",
(const char*) dest, strerror(errno));
- if (force || req.isNotify(FaxRequest::notify_any)) {
- req.writeQFile();
- notifySender(job, why, duration);
- }
+ req.writeQFile();
+ notifySender(job, why, duration);
u_int n = req.items.length();
for (u_int i = 0; i < n; i++) {
const FaxItem& fitem = req.items[i];
SENDTO=$mailaddr
export COMMID SENDTO FROMADDR TOADDR DESTINATION WHY JTIME NEXT JOBINFO
+# This does the grunt work of building the notify email
+do_notify()
+{
+
+
+ if [ -f etc/templates/$TEMPLATE/hook.sh ]
+ then
+ # Any hooks that the templates need
+ . etc/templates/$TEMPLATE/hook.sh
+ fi
+
+
+ if [ -n "$RETURNFILETYPE" ]; then
+ for ft in $RETURNFILETYPE
+ do
+ ATTACH_ARGS="$ATTACH_ARGS "`BuildAttachArgs $ft`
+ done
+ fi
+
+ template="etc/templates/$TEMPLATE/notify-$WHY.txt"
+ if [ "$jobtype" != "facsimile" ] && [ -f etc/templates/$TEMPLATE/notify-$WHY-page.txt ]; then
+ template="etc/templates/$TEMPLATE/notify-$WHY-page.txt"
+ fi
+
+
+ eval CreateMailMessage "$template" $ATTACH_ARGS \
+ 2>$ERRORSTO | $SENDMAIL -f"$FROMADDR" -oi "$mailaddr"
+
+}
+
+
#
# Apply customizations. All customizable variables should
# be set to their non-customized defaults prior to this.
. etc/FaxNotify
fi
-if [ -f etc/templates/$TEMPLATE/hook.sh ]
-then
- # Any hooks that the templates need
- . etc/templates/$TEMPLATE/hook.sh
-fi
+case "$WHY:$notify" in
+ "requeued:when done+requeued") do_notify;; # Requeued
+ "requeued:when requeued") do_notify;; # Requeued
+ "requeued:when done") ;; # Do nothing;
+ "requeued:none") ;; # Do nothing;
+ "blocked:when done+requeued") do_notify;; # Requeued
+ "blocked:when requeued") do_notify;; # Requeued
+ "blocked:when done") ;; # Do nothing;
+ "blocked:none") ;; # Do nothing;
-if [ -n "$RETURNFILETYPE" ]; then
- for ft in $RETURNFILETYPE
- do
- ATTACH_ARGS="$ATTACH_ARGS "`BuildAttachArgs $ft`
- done
-fi
-
-template="etc/templates/$TEMPLATE/notify-$WHY.txt"
-if [ "$jobtype" != "facsimile" ] && [ -f etc/templates/$TEMPLATE/notify-$WHY-page.txt ]; then
- template="etc/templates/$TEMPLATE/notify-$WHY-page.txt"
-fi
+ "done:when done+requeued") do_notify;; # Done
+ "done:when requeued") ;; # Do nothing
+ "done:when done") do_notify;; # Done
+ "done:none") ;; # Do nothing
+ # Anything else is a "failure", which always runs notification
+ *) do_notify;;
+esac
-eval CreateMailMessage "$template" $ATTACH_ARGS \
- 2>$ERRORSTO | $SENDMAIL -f"$FROMADDR" -oi "$mailaddr"
CleanupPrivateTmp