File: SendFaxClient.h

package info (click to toggle)
hylafax 1%3A4.2.1-5sarge3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 6,788 kB
  • ctags: 7,523
  • sloc: sh: 15,597; ansic: 13,040; makefile: 1,772; cpp: 864
file content (185 lines) | stat: -rw-r--r-- 7,122 bytes parent folder | download | duplicates (4)
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
/*	$Id: SendFaxClient.h,v 1.3 1999/06/17 11:05:39 robert Exp $ */
/*
 * Copyright (c) 1993-1996 Sam Leffler
 * Copyright (c) 1993-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.
 */

/*
                    SendFaxClient class
*/
#ifndef _SendFaxClient_
#define	_SendFaxClient_

#include "FaxClient.h"
#include "SendFaxJob.h"

class TypeRule;
class TypeRules;
class DialStringRules;
struct FileInfo;
class FileInfoArray;
struct PollRequest;
class PollRequestArray;

class SendFaxClient : public FaxClient {
public:
    // NB: the SF_ prefixes workaround a bug in the AIX xlC compiler
    struct SF_stringtag {
	const char*	 name;
	fxStr SendFaxClient::* p;
	const char*	 def;		// NULL is shorthand for ""
    };
private:
    SendFaxJobArray* jobs;		// job state information
    SendFaxJob	proto;			// prototypical job
    fxStr	typeRulesFile;		// filename for type deduction rules
    TypeRules*	typeRules;		// file type/conversion database
    fxStr	dialRulesFile;		// filename for dialstring rules
    DialStringRules* dialRules;		// dial string conversion database
    FileInfoArray* files;		// files to send (possibly converted)
    PollRequestArray* polls;		// polling requests
    bool	verbose;		// enable debugging information
    bool	setup;			// if true, then ready to send
    fxStr	tmpFile;		// stuff to cleanup on abort
    fxStr	from;			// command line from information
    fxStr	senderName;		// sender's full name
    fxStr	coverCmd;		// cover page program name
    u_int	totalPages;		// total pages in submitted documents
    fxStr	dateFormat;		// date format string for cover page

    static const SF_stringtag strings[];
protected:
    SendFaxClient();

    /*
     * Derived classes can override these methods to
     * provide more suitable feedback than the default
     * ``print to the terminal'' work done by FaxClient.
     */
    virtual void vprintError(const char* fmt, va_list ap);
    virtual void vprintWarning(const char* fmt, va_list ap);
    virtual void vtraceServer(const char* fmt, va_list ap);
    /*
     * Derived classes can override this method to capture
     * job identifiers returned by the server when a job is
     * submitted.  The default action is to print a message
     * to the terminal identifying the jobid and groupid of
     * newly submitted job.
     */
    virtual void notifyNewJob(const SendFaxJob& job);
    /*
     * Derived classes can override makeCoverPage to supply an
     * application-specific cover page generation scheme.
     */
    virtual bool makeCoverPage(const SendFaxJob&, fxStr& file, fxStr& emsg);
    /*
     * These methods are used to count/estimate the number
     * of pages in a document that is to be transmitted.
     * Counting pages in a TIFF document is easy and reliable
     * but doing it for a PostScript document is not; so that
     * method is marked virtual in case a derived class wants to
     * provide a better algorithm than the default one.
     */
    void countTIFFPages(const char* name);
    virtual void estimatePostScriptPages(const char* name);

    /*
     * Configuration file support; derived classes may override
     * these to implement application-specific config controls.
     */
    virtual void setupConfig();
    virtual void resetConfig();
    virtual bool setConfigItem(const char* tag, const char* value);

    /*
     * File typerule support.
     */
    const TypeRule* fileType(const char* filename, fxStr& emsg);
    bool prepareFile(FileInfo& info, fxStr& emsg);

    /*
     * Miscellaneous stuff used by setupSenderIdentity.
     */
    void setBlankMailboxes(const fxStr&);
    bool getNonBlankMailbox(fxStr&);
public:
    virtual ~SendFaxClient();

						// prepare jobs for submission
    virtual bool prepareForJobSubmissions(fxStr& emsg);
    void purgeFileConversions(void);		// purge any converted docs
    virtual bool submitJobs(fxStr& emsg);	// submit documents & jobs
    virtual bool sendDocuments(fxStr& emsg);	// send prepared documents

    /*
     * Job manipulation interfaces.
     */
    SendFaxJob& addJob(void);
    SendFaxJob* findJob(const fxStr& number, const fxStr& name);
    SendFaxJob* findJobByTag(const fxStr& tag);
    void removeJob(const SendFaxJob&);
    u_int getNumberOfJobs() const;

    SendFaxJob& getProtoJob();
    /*
     * Document transmit request interfaces.
     */
    u_int addFile(const fxStr& filename);
    u_int findFile(const fxStr& filename) const;
    void removeFile(u_int);
    u_int getNumberOfFiles() const;
    const fxStr& getFileDocument(u_int) const;
    /*
     * Polled retrieval request interfaces.
     */
    u_int addPollRequest();
    u_int addPollRequest(const fxStr& sep);
    u_int addPollRequest(const fxStr& sep, const fxStr& pwd);
    void removePollRequest(u_int);
    u_int getNumberOfPollRequests() const;
    void getPollRequest(u_int, fxStr& sep, fxStr& pwd);

    /*
     * Sender identity controls.  There are two separate
     * identities maintained, one for the actual user/account
     * that submits the jobs and another for person identified
     * as the sender on the outbound facsimile.  This distinction
     * is used by proxy services such as email to fax gateways
     * and for folks people that submit jobs for other people.
     */
						// identity associated with job
    bool setupSenderIdentity(const fxStr&, fxStr& emsg);
    const fxStr& getSenderName() const;
    void setFromIdentity(const char*);		// identity associated with fax
    const fxStr& getFromIdentity() const;

    bool getVerbose() const;			// trace operation
    void setVerbose(bool);
};

inline SendFaxJob& SendFaxClient::getProtoJob()	{ return proto; }
inline const fxStr& SendFaxClient::getFromIdentity() const { return from; }
inline const fxStr& SendFaxClient::getSenderName() const { return senderName;}
inline void SendFaxClient::setVerbose(bool b) { verbose = b; }
inline bool SendFaxClient::getVerbose() const { return verbose; }
#endif /* _SendFaxClient_ */