📄 awabsfax.pas
字号:
(***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is TurboPower Async Professional
*
* The Initial Developer of the Original Code is
* TurboPower Software
*
* Portions created by the Initial Developer are Copyright (C) 1991-2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* ***** END LICENSE BLOCK ***** *)
{*********************************************************}
{* AWABSFAX.PAS 4.06 *}
{*********************************************************}
{* Abstract fax *}
{*********************************************************}
{Global defines potentially affecting this unit}
{$I AWDEFINE.INC}
{Options required for this unit}
{$A+,V-,I-,B-,F+,X+,Q-,N+}
unit AwAbsFax;
{-Abstract data and routines for Class I/II fax}
interface
uses
WinTypes,
WinProcs,
Messages,
SysUtils,
{----------APW}
AdExcept,
OoMisc,
AwUser;
type
{Fax notification function}
TFaxFunc = procedure(
Msg, wParam : Cardinal;
lParam : LongInt);
{Abstract fax data}
PFaxData = ^TFaxData;
TFaxData = record
aStatusTrigger : Integer; {Status timer trigger handle}
aTimeoutTrigger : Integer; {Timeout timer trigger handle}
aOutBuffFreeTrigger : Integer; {Outbuffree status trigger handle}
aOutBuffUsedTrigger : Integer; {Outbuffused status trigger handle}
{aNoCarrierTrigger : Integer;} {No carrier status trigger handle}{!!.02}
aStatusInterval : Integer; {Ticks between status updates}
aHWindow : HWnd; {Window associated with fax}
aPort : TApdBaseDispatcher; {Com port object to use}
aCurFaxFunc : TFaxFunc; {Routine to process fax send/receives}
aSending : Boolean; {True if sending faxes}
aSendingCover : Boolean; {True if sending cover page}
aInProgress : Boolean; {True during fax sessions}
aMaxConnect : Cardinal; {max number of connect attempts}
aConnectCnt : Cardinal; {count of connect attempts}
aRetryCnt : Cardinal; {Number of class 1 frame attempts}
aRetryWait : Cardinal; {ticks to wait between connect attempts}
afFlags : Cardinal; {fax send/receive options}
aSaveStatus : Cardinal; {Temp var and save between states}
aFaxProgress : Cardinal; {For storing progress codes}
aFaxListCount : Cardinal; {Number of fax entries}
aFaxError : Integer; {Fax error code}
aCurrPage : Integer; {counter for pages}
aPageCount : Integer; {total pages in document}
aCoverCount : Integer; {Number of cover pages, 0 or 1}
aDataCount : LongInt; {count of received "real" data bytes}
aPageSize : LongInt; {size of page file in bytes}
aFaxListHead : PFaxEntry; {Head of fax entry list}
aFaxListTail : PFaxEntry; {Tail of fax entry list}
aFaxListNode : PFaxEntry; {Current node of fax entry list}
aClassInUse : ClassType; {class of device in use}
aStationID : Str20; {Station ID (usually phone #)}
aRemoteID : Str20; {StationID of remote}
aStNumber : TChar20Array;{Station ID, usually phone number}
aDestDir : ShortString; {destination directory}
aFaxFileExt : ShortString; {fax file extension}
aFaxFileName : ShortString; {current document being processed}
aCoverFile : ShortString; {cover page file if any}
aPhoneNum : String[40]; {phone number to dial}
aStatusTimer : EventTimer; {Timer for status updates}
aTitle : ShortString; {Sender title}
aRecipient : ShortString; {Recipient's name}
aSender : ShortString; {Sender's name}
aSaveMode : Byte; {Save FileMode}
aSendManual : Boolean; {Save FaxMode}
aConcatFax : Boolean; {Fax is concatenated}
HaveTriggerHandler : Boolean;
aUsingTapi : Boolean; {True if we're integrated with TAPI}{!!.04}
end;
TFaxRec = record
aPData : PFaxData; {Pointer to fax data}
end;
PFaxRec = ^TFaxRec;
{Prepare procedure}
TFaxPrepProc = function(P : PFaxRec) : Integer;
{Various hook types}
FaxStatusProc = procedure (FP : PFaxRec;
Starting, Ending : Boolean);
NextFaxFunc = function(FP : PFaxRec;
var Number : ShortString;
var FName : ShortString;
var Cover : ShortString) : Boolean;
FaxLogProc = procedure(FP : PFaxRec; Log : TFaxLogCode); {!!.04}
FaxNameFunc = function (FP : PFaxRec) : ShortString;
AcceptFaxFunc = function(FP : PFaxRec;
RemoteName : Str20) : Boolean;
{FaxData init/destroy routines}
function afInitFaxData(var PData : PFaxData; ID : Str20;
ComPort : TApdBaseDispatcher; Window : TApdHwnd) : Integer;
function afDoneFaxData(var PData : PFaxData) : Integer;
{Option management}
procedure afOptionsOn(FP : PFaxRec; OptionFlags : Word);
{-Activate multiple options}
procedure afOptionsOff(FP : PFaxRec; OptionFlags : Word);
{-Deactivate multiple options}
function afOptionsAreOn(FP : PFaxRec; OptionFlags : Word) : Boolean;
{-Return True if all specified options are on}
{User control}
procedure afSetTitle(FP : PFaxRec; NewTitle : ShortString);
{-Set title of sender (used in header line)}
procedure afSetRecipientName(FP : PFaxRec; NewName : ShortString);
{-Set name of recipient}
procedure afSetSenderName(FP : PFaxRec; NewName : ShortString);
{-Set name of sender}
procedure afSetDestinationDir(FP : PFaxRec; Dest : ShortString);
{-Set a destination directory for received files}
procedure afSetStationID(FP : PFaxRec; NewID : Str20);
{-Assign our station ID}
procedure afSetConnectAttempts(FP : PFaxRec; Attempts : Word;
DelayTicks : Word);
{-Set number of connect attempts per fax, 0 = infinite}
procedure afSetNextFax(FP : PFaxRec;
Number : ShortString;
FName : ShortString;
Cover : ShortString);
{-Set the next fax to transmit}
procedure afSetComHandle(FP : PFaxRec; NewHandle : TApdBaseDispatcher);
{-Set a new comhandle to use}
procedure afSetWindow(FP : PFaxRec; NewWindow : TApdHwnd);
{-Set a new window handle to use}
procedure afSetFaxName(FP : PFaxRec; FaxName : ShortString);
{-Set the name of the incoming fax}
{Fax entry list stuff}
function afAddFaxEntry(FP : PFaxRec;
const Number : ShortString;
const FName : ShortString;
const Cover : ShortString) : Integer;
{-Add another number to the built-in list}
procedure afClearFaxEntries(FP : PFaxRec);
{-Remove all fax entries from builtin list}
{Status info}
function afGetFaxName(FP : PFaxRec) : ShortString;
{-Return name of current fax and size if known}
function afGetFaxProgress(FP : PFaxRec) : Word;
{-Return fax progress code}
procedure afReportError(FP : PFaxRec; ErrorCode : Integer);
{-Report the error}
procedure afSignalFinish(FP : PFaxRec);
{-Send finish message to parent window}
procedure afStartFax(FP : PFaxRec; StartProc : TFaxPrepProc; FaxFunc : TFaxFunc);
{-Start the fax session}
procedure afStopFax(FP : PFaxRec);
{-Stop the fax session}
function afStatusMsg(P : PChar; Status : Word) : PChar;
{-Return an appropriate error message from the stringtable}
{Private functions}
function afConvertHeaderString(FP : PFaxRec; S : ShortString) : ShortString;
{-Compress a fax header string, converting tags to appropriate values}
{Hooks, private}
procedure afFaxStatus(FP : PFaxRec; Starting, Ending : Boolean);
function afNextFax(FP : PFaxRec) : Boolean;
procedure afLogFax(FP : PFaxRec; Log : TFaxLogCode); {!!.04}
procedure afFaxName(FP : PFaxRec);
function afAcceptFax(FP : PFaxRec; RemoteName : Str20) : Boolean;
{Builtin functions}
function afNextFaxList(FP : PFaxRec;
var Number : ShortString;
var FName : ShortString;
var Cover : ShortString) : Boolean;
{-Returns next fax name/number in builtin list}
function afFaxNameMD(FP : PFaxRec) : ShortString;
{-Returns name for incoming fax}
function afFaxNameCount(FP : PFaxRec) : ShortString;
{-Returns name for incoming fax}
{Private data types}
type
{End-of-page status}
ReceivePageStatus = (
rpsBadPage,
rpsMoreSame,
rpsNewPage,
rpsNewDocument,
rpsEndOfDocument);
{Send machine states}
SendStates = (
tfNone,
{Setup, both classes}
tfGetEntry,
tfInit,
{Phase A, Class 1}
tf1Init1,
{Phase A, Class 2}
tf2Init1,
tf2Init1A,
tf2Init1B,
tf2Init2,
tf2Init3,
{Phase A, both classes}
tfDial,
tfRetryWait,
{Phase B, Class 1}
tf1Connect,
tf1SendTSI,
tf1TSIResponse,
tf1DCSResponse,
tf1TrainStart,
tf1TrainFinish,
tf1WaitCFR,
tf1WaitPageConnect,
{Phase B, Class 2}
tf2Connect,
tf2GetParams,
{Phase C, both classes}
tfWaitXon,
tfWaitFreeHeader,
tfSendPageHeader,
tfOpenCover,
tfSendCover,
tfPrepPage,
tfSendPage,
tfDrainPage,
{Phase D states for Class 1}
tf1PageEnd,
tf1PrepareEOP,
tf1SendEOP,
tf1WaitMPS,
tf1WaitEOP,
tf1WaitMCF,
tf1SendDCN,
tf1Hangup,
tf1WaitHangup,
{Phase D, Class 2}
tf2SendEOP,
tf2WaitFPTS,
tf2WaitFET,
tf2WaitPageOK,
tf2SendNewParams,
tf2NextPage,
tf20CheckPage,
{Phase E, both classes}
tfClose,
tfCompleteOK,
tfAbort,
tfDone);
{Receive machine states}
ReceiveStates = (
rfNone,
{Setup, both classes}
rfInit,
{Setup, class 1}
rf1Init1,
{Setup, class 2}
rf2Init1,
rf2Init1A,
rf2Init1B,
rf2Init2,
rf2Init3,
{Phase A, both classes}
rfWaiting,
rfAnswer,
{Phase B, class 1}
rf1SendCSI,
rf1SendDIS,
rf1CollectFrames,
rf1CollectRetry1,
rf1CollectRetry2,
rf1StartTrain,
rf1CollectTrain,
rf1Timeout,
rf1Retrain,
rf1FinishTrain,
rf1SendCFR,
rf1WaitPageConnect,
{Phase B, class 2}
rf2ValidConnect,
rf2GetSenderID,
rf2GetConnect,
{Phase C}
rfStartPage,
rfGetPageData,
{Phase D, class 1}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -