Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[r2332]: trunk / util / SendFaxJob.c++ Maximize Restore History

Download this file

SendFaxJob.c++    658 lines (629 with data), 20.7 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
/* $Id: SendFaxJob.c++ 1119 2012-08-28 14:30:25Z faxguy $ */
/*
* Copyright (c) 1990-1996 Sam Leffler
* Copyright (c) 1991-1996 Silicon Graphics, Inc.
* HylaFAX is a trademark of Silicon Graphics
*
* Permission to use, copy, modify, distribute, and sell this software and
* its documentation for any purpose is hereby granted without fee, provided
* that (i) the above copyright notices and this permission notice appear in
* all copies of the software and related documentation, and (ii) the names of
* Sam Leffler and Silicon Graphics may not be used in any advertising or
* publicity relating to the software without the specific, prior written
* permission of Sam Leffler and Silicon Graphics.
*
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
*
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*/
#include "config.h"
#include "Sys.h"
#include <ctype.h>
#include <string.h>
#include <errno.h>
#if CONFIG_INETTRANSPORT
extern "C" {
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h> // XXX
}
#endif
#include "SendFaxClient.h"
#include "PageSize.h"
#include "FaxConfig.h"
SendFaxJob::SendFaxJob()
{
}
SendFaxJob::SendFaxJob(const SendFaxJob& other)
: jobtag(other.jobtag)
, mailbox(other.mailbox)
, number(other.number)
, subaddr(other.subaddr)
, passwd(other.passwd)
, external(other.external)
, coverFile(other.coverFile)
, coverTemplate(other.coverTemplate)
, name(other.name)
, voicenumber(other.voicenumber)
, location(other.location)
, company(other.company)
, comments(other.comments)
, regarding(other.regarding)
, fromlocation(other.fromlocation)
, fromfax(other.fromfax)
, fromvoice(other.fromvoice)
, fromcompany(other.fromcompany)
, killTime(other.killTime)
, sendTime(other.sendTime)
, tagline(other.tagline)
, pageSize(other.pageSize)
, timeZone(other.timeZone)
{
notify = other.notify;
autoCover = other.autoCover;
coverIsTemp = other.coverIsTemp;
sendTagLine = other.sendTagLine;
useXVRes = other.useXVRes;
useColor = other.useColor;
retryTime = other.retryTime;
hres = other.hres;
vres = other.vres;
pageWidth = other.pageWidth;
pageLength = other.pageLength;
maxRetries = other.maxRetries;
maxDials = other.maxDials;
priority = other.priority;
minsp = other.minsp;
desiredbr = other.desiredbr;
desiredst = other.desiredst;
desiredec = other.desiredec;
desireddf = other.desireddf;
pagechop = other.pagechop;
chopthreshold = other.chopthreshold;
skippages = other.skippages;
skippedpages = other.skippedpages;
nocountcover = other.nocountcover;
probeonly = other.probeonly;
serverdocover = other.serverdocover;
ignoremodembusy = other.ignoremodembusy;
}
SendFaxJob::~SendFaxJob()
{
if (coverFile != "" && coverIsTemp)
Sys::unlink(coverFile);
}
/*
* Configuration file support.
*/
#define N(a) (sizeof (a) / sizeof (a[0]))
SendFaxJob::SFJ_stringtag SendFaxJob::strings[] = {
{ "tagline", &SendFaxJob::tagline, NULL },
{ "tsi", &SendFaxJob::tsi, NULL },
{ "sendtime", &SendFaxJob::sendTime, NULL },
{ "killtime", &SendFaxJob::killTime, FAX_TIMEOUT },
{ "pagesize", &SendFaxJob::pageSize, "default" },
{ "jobtag", &SendFaxJob::jobtag, NULL },
{ "subaddress", &SendFaxJob::subaddr, NULL },
{ "password", &SendFaxJob::passwd, NULL },
{ "cover-template", &SendFaxJob::coverTemplate, NULL },
{ "cover-comments", &SendFaxJob::comments, NULL },
{ "cover-regarding", &SendFaxJob::regarding, NULL },
{ "cover-company", &SendFaxJob::company, NULL },
{ "cover-location", &SendFaxJob::location, NULL },
{ "cover-voice", &SendFaxJob::voicenumber, NULL },
{ "cover-from-location", &SendFaxJob::fromlocation, NULL },
{ "cover-from-fax", &SendFaxJob::fromfax, NULL },
{ "cover-from-voice", &SendFaxJob::fromvoice, NULL },
{ "cover-from-company", &SendFaxJob::fromcompany, NULL },
};
SendFaxJob::SFJ_numbertag SendFaxJob::numbers[] = {
{ "maxtries", &SendFaxJob::maxRetries, FAX_RETRIES },
{ "maxdials", &SendFaxJob::maxDials, FAX_REDIALS },
{ "skippages", &SendFaxJob::skippages, 0 },
{ "skippedpages", &SendFaxJob::skippedpages, 0 },
{ "nocountcover", &SendFaxJob::nocountcover, 0 },
{ "probeonly", &SendFaxJob::probeonly, 0 },
};
SendFaxJob::SFJ_floattag SendFaxJob::floats[] = {
{ "hres", &SendFaxJob::hres, 204. },
{ "vres", &SendFaxJob::vres, FAX_DEFVRES },
{ "pagewidth", &SendFaxJob::pageWidth, 0. },
{ "pagelength", &SendFaxJob::pageLength, 0. },
{ "chopthreshold", &SendFaxJob::chopthreshold, 3.0 },
};
void
SendFaxJob::setupConfig()
{
int i;
for (i = N(strings)-1; i >= 0; i--)
(*this).*strings[i].p = (strings[i].def ? strings[i].def : "");
for (i = N(numbers)-1; i >= 0; i--)
(*this).*numbers[i].p = numbers[i].def;
for (i = N(floats)-1; i >= 0; i--)
(*this).*floats[i].p = floats[i].def;
autoCover = true;
sendTagLine = false; // default is to use server config
useXVRes = false; // default is to use normal or fine
useColor = false; // default is to only send monochrome
serverdocover = false; // default to do it client-side
ignoremodembusy = false; // default to acknowledge busy status
notify = FAX_DEFNOTIFY; // default notification
mailbox = "";
timeZone = "";
priority = FAX_DEFPRIORITY; // default transmit priority
minsp = (u_int) -1;
desiredbr = (u_int) -1;
desiredst = (u_int) -1;
desiredec = (u_int) -1;
desireddf = (u_int) -1;
retryTime = (u_int) -1;
pagechop = chop_default;
}
bool
SendFaxJob::setConfigItem(const char* tag, const char* value)
{
u_int ix;
if (FaxConfig::findTag(tag, (const FaxConfig::tags*) strings, N(strings), ix)) {
(*this).*strings[ix].p = value;
switch (ix) {
case 0: sendTagLine = true; break;
}
} else if (FaxConfig::findTag(tag, (const FaxConfig::tags*) numbers, N(numbers), ix)) {
(*this).*numbers[ix].p = atoi(value);
} else if (FaxConfig::findTag(tag, (const FaxConfig::tags*) floats, N(floats), ix)) {
(*this).*floats[ix].p = atof(value);
} else if (streq(tag, "autocoverpage"))
setAutoCoverPage(FaxConfig::getBoolean(value));
else if (streq(tag, "notify") || streq(tag, "notification"))
setNotification(value);
else if (streq(tag, "mailaddr"))
setMailbox(value);
else if (streq(tag, "priority"))
setPriority(value);
else if (streq(tag, "minspeed"))
setMinSpeed(value);
else if (streq(tag, "desiredspeed"))
setDesiredSpeed(value);
else if (streq(tag, "desiredmst"))
setDesiredMST(value);
else if (streq(tag, "desiredec"))
setDesiredEC(value);
else if (streq(tag, "usexvres"))
setUseXVRes(FaxConfig::getBoolean(value));
else if (streq(tag, "usecolor"))
setUseColor(FaxConfig::getBoolean(value));
else if (streq(tag, "serverdocover"))
setServerDoCover(FaxConfig::getBoolean(value));
else if (streq(tag, "ignoremodembusy"))
setIgnoreModemBusy(FaxConfig::getBoolean(value));
else if (streq(tag, "desireddf"))
setDesiredDF(value);
else if (streq(tag, "retrytime"))
setRetryTime(value);
else if (streq(tag, "pagechop"))
setChopHandling(value);
else
return (false);
return (true);
}
#undef N
#define valeq(a,b) (strcasecmp(a,b)==0)
#define valneq(a,b,n) (strncasecmp(a,b,n)==0)
void SendFaxJob::setDoneOp(const char* v) { doneop = v; }
bool
SendFaxJob::setNotification(const char* v0)
{
const char* v = v0;
if (valneq(v, "when", 4)) {
for (v += 4; isspace(*v); v++)
;
}
if (valeq(v, "done"))
notify = when_done;
else if (valneq(v, "req", 3))
notify = when_requeued;
else if (valeq(v, "none") || valeq(v, "off"))
notify = no_notice;
else if (valeq(v, "default"))
notify = FAX_DEFNOTIFY;
else
return (false);
return (true);
}
void SendFaxJob::setNotification(FaxNotify n) { notify = n; }
/*
* Create the mail address for a local user.
*/
void
SendFaxJob::setMailbox(const char* user)
{
fxStr acct(user);
if (acct != "" && acct.next(0, "@!") == acct.length()) {
static fxStr domainName;
if (domainName == "") {
char hostname[64];
(void) gethostname(hostname, sizeof (hostname));
#if CONFIG_INETTRANSPORT
struct hostent* hp = gethostbyname(hostname);
domainName = (hp ? hp->h_name : hostname);
#else
domainName = hostname;
#endif
}
mailbox = acct | "@" | domainName;
} else
mailbox = acct;
// strip leading & trailing white space
mailbox.remove(0, mailbox.skip(0, " \t"));
mailbox.resize(mailbox.skipR(mailbox.length(), " \t"));
}
void SendFaxJob::setJobTag(const char* s) { jobtag = s; }
void
SendFaxJob::setRetryTime(const char* v)
{
char* cp;
u_int t = (u_int) strtoul(v, &cp, 10);
if (cp) {
while (isspace(*cp))
;
if (strncasecmp(cp, "min", 3) == 0)
t *= 60;
else if (strncasecmp(cp, "hour", 4) == 0)
t *= 60*60;
else if (strncasecmp(cp, "day", 3) == 0)
t *= 24*60*60;
}
retryTime = t;
}
void SendFaxJob::setRetryTime(u_int v) { retryTime = v; }
void SendFaxJob::setKillTime(const char* s) { killTime = s; }
void SendFaxJob::setSendTime(const char* s) { sendTime = s; }
void SendFaxJob::setMaxRetries(u_int n) { maxRetries = n; }
void SendFaxJob::setMaxDials(u_int n) { maxDials = n; }
void
SendFaxJob::setPriority(const char* pri)
{
if (valeq(pri, "default") || valeq(pri, "normal"))
priority = FAX_DEFPRIORITY;
else if (valeq(pri, "bulk") || valeq(pri, "junk"))
priority = FAX_DEFPRIORITY + 4*16;
else if (valeq(pri, "low"))
priority = FAX_DEFPRIORITY + 4*16-1;
else if (valeq(pri, "high"))
priority = FAX_DEFPRIORITY - 4*16;
else
priority = atoi(pri);
}
void SendFaxJob::setPriority(int p) { priority = p; }
void SendFaxJob::setTSI(const char* s) { tsi = s; }
void SendFaxJob::setFaxNumber(const char* s) { faxnumber = s; }
void SendFaxJob::setFaxName(const char* s) { faxname = s; }
void SendFaxJob::setTimeZone(const char* s) { timeZone = s; }
void SendFaxJob::setDialString(const char* s) { number = s; }
void SendFaxJob::setSubAddress(const char* s) { subaddr = s; }
void SendFaxJob::setPassword(const char* s) { passwd = s; }
void SendFaxJob::setExternalNumber(const char* s) { external = s; }
void SendFaxJob::setAutoCoverPage(bool b) { autoCover = b; }
void
SendFaxJob::setCoverPageFile(const char* s, bool removeOnExit)
{
if (coverFile != "" && removeOnExit)
Sys::unlink(coverFile);
coverFile = s;
coverIsTemp = removeOnExit;
}
void SendFaxJob::setCoverTemplate(const char* s) { coverTemplate = s; }
void SendFaxJob::setCoverName(const char* s) { name = s; }
void SendFaxJob::setCoverLocation(const char* s) { location = s; }
void SendFaxJob::setCoverCompany(const char* s) { company = s; }
void SendFaxJob::setCoverComments(const char* s) { comments = s; }
void SendFaxJob::setCoverRegarding(const char* s) { regarding = s; }
void SendFaxJob::setCoverVoiceNumber(const char* s) { voicenumber = s; }
void SendFaxJob::setCoverFromLocation(const char* s) { fromlocation = s; }
void SendFaxJob::setCoverFromFax(const char* s) { fromfax = s; }
void SendFaxJob::setCoverFromVoice(const char* s) { fromvoice = s; }
void SendFaxJob::setCoverFromCompany(const char* s) { fromcompany = s; }
bool
SendFaxJob::setPageSize(const char* name)
{
PageSizeInfo* info = PageSizeInfo::getPageSizeByName(name);
if (info) {
pageWidth = info->width();
pageLength = info->height();
pageSize = name;
delete info;
return (true);
} else
return (false);
}
void SendFaxJob::setVResolution(float r) { vres = r; }
void SendFaxJob::setHResolution(float r) { hres = r; }
int
SendFaxJob::getSpeed(const char* value) const
{
switch (atoi(value)) {
case 2400: return (0);
case 4800: return (1);
case 7200: return (2);
case 9600: return (3);
case 12000: return (4);
case 14400: return (5);
case 16800: return (6);
case 19200: return (7);
case 21600: return (8);
case 24000: return (9);
case 26400: return (10);
case 28800: return (11);
case 31200: return (12);
case 33600: return (13);
}
return (-1);
}
void SendFaxJob::setMinSpeed(int v) { minsp = v; }
void SendFaxJob::setMinSpeed(const char* v) { minsp = getSpeed(v); }
void SendFaxJob::setDesiredSpeed(int v) { desiredbr = v; }
void SendFaxJob::setDesiredSpeed(const char* v) { desiredbr = getSpeed(v); }
void
SendFaxJob::setDesiredMST(const char* v)
{
if (valeq(v, "0ms"))
desiredst = 0;
else if (valeq(v, "5ms"))
desiredst = 1;
else if (valeq(v, "10ms2"))
desiredst = 2;
else if (valeq(v, "10ms"))
desiredst = 3;
else if (valeq(v, "20ms2"))
desiredst = 4;
else if (valeq(v, "20ms"))
desiredst = 5;
else if (valeq(v, "40ms2"))
desiredst = 6;
else if (valeq(v, "40ms"))
desiredst = 7;
else
desiredst = atoi(v);
}
void SendFaxJob::setDesiredMST(int v) { desiredst = v; }
void
SendFaxJob::setDesiredEC(const char* e)
{
desiredec = atoi(e);
}
void SendFaxJob::setDesiredEC(int e) { desiredec = e; }
void SendFaxJob::setUseXVRes(bool b) { useXVRes = b; }
void SendFaxJob::setUseColor(bool b) { useColor = b; }
void SendFaxJob::setServerDoCover(bool b) { serverdocover = b; }
void SendFaxJob::setIgnoreModemBusy(bool b) { ignoremodembusy = b; }
void
SendFaxJob::setDesiredDF(const char* v)
{
if (strcasecmp(v, "1d") == 0 || strcasecmp(v, "1dmh") == 0 || strcasecmp(v, "1dmr") == 0)
desireddf = 0;
else if (strcasecmp(v, "2d") == 0 || strcasecmp(v, "2dmr") == 0)
desireddf = 1;
else if (strcasecmp(v, "2dmruncomp") == 0)
desireddf = 1; // NB: force 2D w/o uncompressed
else if (strcasecmp(v, "2dmmr") == 0)
desireddf = 3;
else if (strcasecmp(v, "jbig") == 0)
desireddf = 4;
else if (strcasecmp(v, "jpeg-grey") == 0)
desireddf = 5;
else if (strcasecmp(v, "jpeg-color") == 0)
desireddf = 5;
else
desireddf = atoi(v);
}
void SendFaxJob::setDesiredDF(int df) { desireddf = df; }
void
SendFaxJob::setTagLineFormat(const char* v)
{
tagline = v;
sendTagLine = true;
}
void
SendFaxJob::setChopHandling(const char* v)
{
if (strcasecmp(v, "none") == 0)
pagechop = chop_none;
else if (strcasecmp(v, "all") == 0)
pagechop = chop_all;
else if (strcasecmp(v, "last") == 0)
pagechop = chop_last;
else
pagechop = atoi(v);
}
void SendFaxJob::setChopHandling(u_int v) { pagechop = v; }
void SendFaxJob::setChopThreshold(float v) { chopthreshold = v; }
void SendFaxJob::setSkipPages(u_int v) { skippages = v; }
void SendFaxJob::setSkippedPages(u_int v) { skippedpages = v; }
void SendFaxJob::setNoCountCover(u_int v) { nocountcover = v; }
void SendFaxJob::setProbeOnly(u_int v) { probeonly = v; }
extern int
parseAtSyntax(const char* s, const struct tm& ref, struct tm& at0, fxStr& emsg);
#define CHECK(x) { if (!(x)) goto failure; }
#define CHECKCMD(x) CHECK(client.command(x) == COMPLETE)
#define CHECKPARM(a,b) CHECK(client.jobParm(a,b))
#define IFPARM(a,b,v) { if ((b) != (v)) CHECKPARM(a,b) }
bool
SendFaxJob::initJobs(SendFaxClient& client, fxStr& emsg)
{
if (!client.setCurrentJob("DEFAULT")) { // inherit from default
emsg = client.getLastResponse();
return (false);
}
return (true);
}
bool
SendFaxJob::createJob(SendFaxClient& client, fxStr& emsg)
{
if (!client.newJob(jobid, groupid, emsg)) // create new job on server
return (false);
time_t now = Sys::now();
fxStr tod = "";
u_int delim = 0;
CHECKPARM("FROMUSER", client.getSenderName())
delim = sendTime.next(0, '@');
if (delim < sendTime.length()) {
tod = sendTime.tail(sendTime.length() - delim - 1);
sendTime = sendTime.head(delim);
}
struct tm tts;
if (sendTime != "") {
if (!parseAtSyntax(sendTime, *localtime(&now), tts, emsg)) {
emsg.insert(sendTime | ": ");
return (false);
}
now = mktime(&tts);
// NB: must send time relative to GMT
CHECK(client.jobSendTime(*gmtime(&now)))
} else
tts = *localtime(&now);
if (killTime != "") {
struct tm when;
if (!parseAtSyntax(killTime, tts, when, emsg)) {
emsg.insert(killTime | ": ");
return (false);
}
CHECK(client.jobLastTime(mktime(&when) - now))
}
if (retryTime != (u_int) -1)
CHECK(client.jobRetryTime(retryTime))
IFPARM("MODEM", client.getModem(), ""); // XXX should be per-job state
IFPARM("MAXDIALS", maxDials, (u_int) -1)
IFPARM("MAXTRIES", maxRetries, (u_int) -1)
IFPARM("TIMEOFDAY", tod, "")
IFPARM("TIMEZONE", timeZone, "")
CHECKPARM("SCHEDPRI", priority)
/*
* If the dialstring is different from the
* displayable number then pass both.
*/
IFPARM("TSI", tsi, "")
IFPARM("FAXNUMBER", faxnumber, "")
IFPARM("FAXNAME", faxname, "")
IFPARM("EXTERNAL", external, number)
CHECKPARM("DIALSTRING", number)
IFPARM("SUBADDR", subaddr, "")
IFPARM("PASSWD", passwd, "")
CHECKPARM("NOTIFYADDR", mailbox)
IFPARM("TOUSER", name, "")
IFPARM("TOCOMPANY", company, "")
IFPARM("TOLOCATION", location, "")
IFPARM("TOVOICE", voicenumber, "")
IFPARM("FROMCOMPANY", fromcompany, "")
IFPARM("FROMLOCATION", fromlocation, "")
IFPARM("FROMVOICE", fromvoice, "")
IFPARM("REGARDING", regarding, "")
IFPARM("JOBINFO", jobtag, "")
CHECKPARM("VRES", (u_int) vres)
CHECKPARM("PAGEWIDTH", (u_int) pageWidth)
CHECKPARM("PAGELENGTH", (u_int) pageLength)
IFPARM("MINBR", minsp, (u_int) -1)
IFPARM("BEGBR", desiredbr, (u_int) -1)
IFPARM("BEGST", desiredst, (u_int) -1)
if (desiredec != (u_int) -1) {
CHECKPARM("USEECM", (bool) (desiredec != 0 ? true : false))
if (desiredec) {
CHECKPARM("ECMTYPE",
desiredec == 1 ? "64bit" :
desiredec == 2 ? "256bit" :
desiredec == 3 ? "halfduplex" :
desiredec == 4 ? "fullduplex" :
"256bit");
}
}
if (desireddf != (u_int) -1) {
CHECKPARM("DATAFORMAT",
desireddf == 0 ? "g31d" :
desireddf == 1 ? "g32d" :
desireddf == 2 ? "g32dunc" :
desireddf == 3 ? "g4" :
desireddf == 4 ? "jbig" :
desireddf == 5 ? "jpeg-grey" :
desireddf == 6 ? "jpeg-color" :
"g31d")
}
if (sendTagLine) {
CHECKPARM("USETAGLINE", true)
CHECKPARM("TAGLINE", tagline)
}
if (useXVRes) {
CHECKPARM("USEXVRES", true)
}
if (useColor) {
CHECKPARM("USECOLOR", true)
}
if (serverdocover) {
CHECKPARM("SERVERDOCOVER", true)
}
if (ignoremodembusy) {
CHECKPARM("IGNOREMODEMBUSY", true)
}
if (doneop == "archive") {
CHECKPARM("DONEOP", "archive")
}
CHECKPARM("NOTIFY",
notify == when_done ? "done" :
notify == when_requeued ? "done+requeue" :
"none")
CHECKPARM("PAGECHOP",
pagechop == chop_default? "default" :
pagechop == chop_none ? "none" :
pagechop == chop_all ? "all" :
"last")
IFPARM("CHOPTHRESHOLD", chopthreshold, -1)
IFPARM("SKIPPAGES", skippages, 0)
IFPARM("SKIPPEDPAGES", skippedpages, 0)
IFPARM("NOCOUNTCOVER", nocountcover, 0)
IFPARM("PROBEONLY", probeonly, 0)
if (coverFile != "") {
int fd = Sys::open(coverFile, O_RDONLY);
if (fd < 0) {
emsg = fxStr::format("%s: Can not open: %s",
(const char*) coverFile, strerror(errno));
return (false); // XXX
}
fxStr coverDoc;
bool fileSent =
client.setFormat(FaxClient::FORM_PS)
&& client.setType(FaxClient::TYPE_I) // XXX??? TYPE_A
&& client.sendZData(fd, &FaxClient::storeTemp, coverDoc, emsg);
Sys::close(fd);
if (!fileSent) {
if (emsg == "")
emsg = "Document transfer failed: " | client.getLastResponse();
return (false);
}
CHECK(client.jobCover(coverDoc))
}
/*
* Append documents and polling requests.
*/
u_int i, n;
for (i = 0, n = client.getNumberOfFiles(); i < n; i++)
CHECK(client.jobDocument(client.getFileDocument(i)))
for (i = 0, n = client.getNumberOfPollRequests(); i < n; i++) {
fxStr sep, pwd;
client.getPollRequest(i, sep, pwd);
CHECK(client.jobPollRequest(sep, pwd))
}
return (true);
failure:
emsg = client.getLastResponse();
return (false);
}
#undef CHECKPARM
#undef IFPARM
#undef CHECKCMD
#undef CHECK
fxIMPLEMENT_ObjArray(SendFaxJobArray, SendFaxJob)