⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 adfaxsrv.pas

📁 测试用例
💻 PAS
📖 第 1 页 / 共 5 页
字号:
    FFaxServerAcceptEvent: TFaxServerAcceptEvent;
    FFaxServerNameEvent: TFaxServerNameEvent;
    FFaxServerLogEvent: TFaxServerLogEvent;
    FSwitchingModes: Boolean;                                          
    FWaitForRing: Boolean;
  protected
    { property access methods }
    procedure SetComPort(const Value: TApdCustomComPort);
    procedure SetFaxLog(const Value: TApdFaxLog);
    procedure SetStatusDisplay(const Value: TApdAbstractFaxStatus);
    procedure SetAnswerOnRing(const Value: Word);
    procedure SetBlindDial(const Value: Boolean);
    procedure SetBufferMinimum(const Value: Word);
    procedure SetConstantStatus(const Value: Boolean);
    procedure SetCoverFile(const Value: TPassString);
    procedure SetDestinationDir(const Value: TPassString);
    procedure SetExitOnError(const Value: Boolean);
    procedure SetFaxClass(const Value: TFaxClass);
    procedure SetFaxFile(const Value: TPassString); override;
    procedure SetFaxFileExt(const Value: TPassString);
    procedure SetFaxNameMode(const Value: TFaxNameMode);
    procedure SetHeaderLine(const Value: TPassString);
    procedure SetHeaderRecipient(const Value: TPassString);
    procedure SetHeaderSender(const Value: TPassString);
    procedure SetHeaderTitle(const Value: TPassString);
    procedure SetInitBaud(const Value: Integer);
    procedure SetMaxSendCount(const Value: Word);
    procedure SetModemInit(const Value: TModemString);
    procedure SetNormalBaud(const Value: Integer);
    procedure SetPhoneNumber(const Value: TPassString);
    procedure SetSafeMode(const Value: Boolean);
    procedure SetSoftwareFlow(const Value: Boolean);
    procedure SetStationID(const Value: TStationID);
    procedure SetStatusInterval(const Value: Word);
    procedure SetToneDial(const Value: Boolean);
    procedure SetMonitoring(const Value: Boolean);
    procedure SetFaxPrinter(const Value: TApdCustomFaxPrinter);
    procedure SetPrintOnReceive(const Value: Boolean);
    procedure SetDesiredBPS(const Value: Word);
    procedure SetDesiredECM(const Value: Boolean);
    procedure SetDetectBusy(const Value: Boolean);
    procedure SetDelayBetweenSends(const Value: Word);
    procedure SetServerManager(const Value: TApdFaxServerManager);
    procedure SetSendQueryInterval(const Value: Integer);
    procedure SetFaxServerMode(const Value: TFaxServerMode);
    procedure SetDialAttempts(const Value: Word);
    procedure SetDialWait(const Value: Word);
    procedure SetDialPrefix(const Value: TModemString);
    procedure SetEnhFont(const Value: TFont);
    procedure SetEnhHeaderFont(const Value: TFont);
    procedure SetEnhTextEnabled(const Value: Boolean);
    procedure SetTapiDevice(const Value: TApdCustomTapiDevice);
    function GetPageLength: LongInt;
    function GetBytesTransferred: LongInt;
    function GetCurrentPage: Word;
    function GetDialAttempt: Word;
    function GetDialAttempts: Word;
    function GetElapsedTime: DWORD;                                      {!!.02}
    function GetFaxProgress: Word;
    function GetHangupCode: Word;
    function GetModemBPS: LongInt;
    function GetModemChip: string;
    function GetModemECM: Boolean;
    function GetModemModel: string;
    function GetModemRevision: string;
    function GetRemoteID: string;
    function GetSessionBPS: Word;
    function GetSessionECM: Boolean;
    function GetSessionResolution: Boolean;
    function GetSessionWidth: Boolean;
    function GetSupportedFaxClasses: TFaxClassSet;
    function GetTotalPages: Word;

    { internal event handlers }
    procedure FInternalFaxFinish(CP: TObject; ErrorCode: Integer);
    procedure FInternalFaxStatus(CP : TObject; First, Last : Boolean);
    procedure FInternalSendQueryTimer(Sender: TObject);
    procedure FInternalTapiPortOpenClose(Sender: TObject);
    procedure FInternalTapiFail(Sender : TObject);
    procedure FInternalPortToggle(CP: TObject; Opening : Boolean);
    procedure FInternalFaxAccept(CP : TObject; var Accept : Boolean);
    procedure FInternalFaxName(CP : TObject; var Name : TPassString);
    procedure FInternalFaxLog(CP : TObject; LogCode: TFaxLogCode);

    procedure Notification(AComponent: TComponent;
                           Operation: TOperation); override;
    { - ensures component properties are correctly assigned }
    procedure CheckPort;
  public
    { the file name of the APJ being sent }
    CurrentJobFileName: TPassString;
    { the index of the job in the APJ being sent }
    CurrentJobNumber: Integer;
    { the TFaxRecipientRec of the job being sent }
    CurrentRecipient: TFaxRecipientRec;
    { the TFaxHeaderRec of the APJ being sent }
    CurrentJobHeader: TFaxJobHeaderRec;

    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;

    function StartTransmitSingle: Boolean;
    { - checks the ApdFaxServerManager for ready jobs outside of the query interval }
    procedure ForceSendQuery;

    procedure CancelFax;                                               

    { properties }
    property ComPort: TApdCustomComPort
      read FComPort write SetComPort;
    property TapiDevice: TApdCustomTapiDevice
      read FTapiDevice write SetTapiDevice;
    property ServerManager: TApdFaxServerManager
      read FServerManager write SetServerManager;
    property StatusDisplay: TApdAbstractFaxStatus
      read FStatusDisplay write SetStatusDisplay;
    property FaxPrinter: TApdCustomFaxPrinter
      read FFaxPrinter write SetFaxPrinter;
    property FaxLog: TApdFaxLog
      read FFaxLog write SetFaxLog;
    property ExitOnError: Boolean
      read FExitOnError write SetExitOnError default adfDefExitOnError;
    property FaxClass: TFaxClass
      read FFaxClass write SetFaxClass default adfDefFaxClass;
    property FaxFile: TPassString
      read FFaxFile write SetFaxFile;
    property FaxFileExt: TPassString
      read FFaxFileExt write SetFaxFileExt;
    property InitBaud: Integer
      read FInitBaud write SetInitBaud default adfDefInitBaud;
    property ModemInit: TModemString
      read FModemInit write SetModemInit;
    property NormalBaud: Integer
      read FNormalBaud write SetNormalBaud default adfDefNormalBaud;
    property SoftwareFlow: Boolean
      read FSoftwareFlow write SetSoftwareFlow default adfDefSoftwareFlow;
    property StationID: TStationID
      read FStationID write SetStationID;
    property StatusInterval: Word
      read FStatusInterval write SetStatusInterval default adfDefFaxStatusInterval;
    property DesiredBPS: Word
      read FDesiredBPS write SetDesiredBPS default adfDefDesiredBPS;
    property DesiredECM: Boolean
      read FDesiredECM write SetDesiredECM default adfDefDesiredECM;

    property DelayBetweenSends: Word
      read FDelayBetweenSends write SetDelayBetweenSends default adfDefDelayBetweenSends;
    property SendQueryInterval: Integer
      read FSendQueryInterval write SetSendQueryInterval;

    { general read-only properties }
    property BytesTransferred: LongInt
      read GetBytesTransferred;
    property CurrentPage: Word
      read GetCurrentPage;
    property ElapsedTime : DWORD                                         {!!.02}
      read GetElapsedTime;                                               {!!.02}
    property FaxProgress: Word
      read GetFaxProgress;
    property HangupCode: Word
      read GetHangupCode;
    property ModemBPS: LongInt
      read GetModemBPS;
    property ModemChip: string
      read GetModemChip;
    property ModemECM: Boolean
      read GetModemECM;
    property ModemModel: string
      read GetModemModel;
    property ModemRevision: string
      read GetModemRevision;
    property PageLength: LongInt
      read GetPageLength;
    property RemoteID: string
      read GetRemoteID;
    property SessionBPS: Word
      read GetSessionBPS;
    property SessionECM: Boolean
      read GetSessionECM;
    property SessionResolution: Boolean
      read GetSessionResolution;                                       
    property SessionWidth: Boolean
      read GetSessionWidth;
    property SupportedFaxClasses: TFaxClassSet
      read GetSupportedFaxClasses;
    property TotalPages: Word
      read GetTotalPages;

    { send-specific properties }
    property BlindDial: Boolean
      read FBlindDial write SetBlindDial default adfDefBlindDial;
    property BufferMinimum: Word
      read FBufferMinimum write SetBufferMinimum default adfDefBufferMinimum;
    property CoverFile: TPassString
      read FCoverFile write SetCoverFile;
    property DetectBusy: Boolean
      read FDetectBusy write SetDetectBusy default adfDefDetectBusy;
    property DialAttempt : Word                                        
      read GetDialAttempt;                                             
    property DialAttempts : Word
      read GetDialAttempts write SetDialAttempts default adfDefDialAttempts; 
    property DialPrefix: TModemString
      read FDialPrefix write SetDialPrefix;
    property DialWait : Word
      read FDialWait write SetDialWait default adfDefDialWait;
    property DialRetryWait : Word                                      
      read FDialRetryWait write FDialRetryWait default adfDefDialRetryWait;  

    property HeaderLine: TPassString
      read FHeaderLine write SetHeaderLine;
    property HeaderRecipient: TPassString
      read FHeaderRecipient write SetHeaderRecipient;
    property HeaderSender: TPassString
      read FHeaderSender write SetHeaderSender;
    property HeaderTitle: TPassString
      read FHeaderTitle write SetHeaderTitle;

    property MaxSendCount: Word
      read FMaxSendCount write SetMaxSendCount default adfDefMaxSendCount;
    property PhoneNumber: TPassString
      read FPhoneNumber write SetPhoneNumber;
    property SafeMode: Boolean
      read FSafeMode write SetSafeMode default adfDefSafeMode;
    property ToneDial: Boolean
      read FToneDial write SetToneDial default adfDefToneDial;
    property EnhTextEnabled : Boolean
      read FEnhTextEnabled write SetEnhTextEnabled;
    property EnhHeaderFont : TFont
      read FEnhHeaderFont write SetEnhHeaderFont;
    property EnhFont : TFont
      read FEnhFont write SetEnhFont;

    { receive-specific properties }
    property AnswerOnRing: Word
      read FAnswerOnRing write SetAnswerOnRing default adfDefAnswerOnRing;
    property ConstantStatus: Boolean
      read FConstantStatus write SetConstantStatus default adfDefConstantStatus;
    property DestinationDir: TPassString
      read FDestinationDir write SetDestinationDir;
    property FaxNameMode: TFaxNameMode
      read FFaxNameMode write SetFaxNameMode default adfDefFaxNameMode;
    property PrintOnReceive: Boolean
      read FPrintOnReceive write SetPrintOnReceive;

    { controlling read-only properties }
    property Monitoring: Boolean
      read FMonitoring write SetMonitoring;
    property FaxInProgress: Boolean
      read FFaxInProgress write FFaxInProgress default False;
    property FaxServerMode: TFaxServerMode
      read FFaxServerMode write SetFaxServerMode;

    { events }
    property OnFaxServerStatus: TFaxServerStatusEvent
      read FFaxServerStatusEvent write FFaxServerStatusEvent;
    property OnFaxServerFatalError: TFaxServerFatalErrorEvent
      read FFaxServerFatalErrorEvent write FFaxServerFatalErrorEvent;
    property OnFaxServerFinish:  TFaxServerFinishEvent
      read FFaxServerFinishEvent write FFaxServerFinishEvent;
    property OnFaxServerPortOpenClose: TFaxServerPortOpenCloseEvent
      read FFaxServerPortOpenCloseEvent write FFaxServerPortOpenCloseEvent;
    property OnFaxServerAccept: TFaxServerAcceptEvent
      read FFaxServerAcceptEvent write FFaxServerAcceptEvent;
    property OnFaxServerName: TFaxServerNameEvent
      read FFaxServerNameEvent write FFaxServerNameEvent;
    property OnFaxServerLog: TFaxServerLogEvent
      read FFaxServerLogEvent write FFaxServerLogEvent;
  end;

  TApdFaxServer = class(TApdCustomFaxServer)
  published
    property ComPort;
    property TapiDevice;
    property ServerManager;
    property StatusDisplay;
    property FaxLog;
    property ExitOnError;
    property FaxClass;
    property InitBaud;
    property ModemInit;
    property NormalBaud;
    property SoftwareFlow;
    property StationID;
    property StatusInterval;
    property DelayBetweenSends;
    property SendQueryInterval;

    { general properties that apply to sending and receiving }
    property DesiredBPS;
    property DesiredECM;
    property FaxFileExt;

    { send-specific properties }
    property BlindDial;
    property BufferMinimum;
    property DetectBusy;
    property DialWait;
    property DialRetryWait;                                            
    property DialAttempts;
    property MaxSendCount;
    property SafeMode;
    property ToneDial;
    property DialPrefix;
    property EnhTextEnabled;
    property EnhFont;
    property EnhHeaderFont;

    { receive-specific properties }
    property AnswerOnRing;
    property ConstantStatus;
    property DestinationDir;
    property FaxNameMode;
    property PrintOnReceive;
    property FaxPrinter;

    { events }
    property OnFaxServerStatus;
    property OnFaxServerFatalError;
    property OnFaxServerFinish;
    property OnFaxServerPortOpenClose;
    property OnFaxServerAccept;
    property OnFaxServerName;
    property OnFaxServerLog;
  end;

implementation

{ TApdCustomFaxServer }

procedure TApdCustomFaxServer.CancelFax;                               
begin
  if FFaxServerMode = fsmSend then
    FSendFax.CancelFax
  else if FFaxServerMode = fsmReceive then
    FRecvFax.CancelFax;
end;

procedure TApdCustomFaxServer.CheckPort;
var
  ET : EventTimer;
begin
  if not Assigned(FComPort) then
    raise EPortNotAssigned.Create(ecPortNotAssigned, False);
  if FSendFax.ComPort = nil then
    FSendFax.ComPort := FComPort;
  if FRecvFax.Comport = nil then
    FRecvFax.ComPort := FComPort;

  if (FTapiDevice <> nil) and (FComPort.TapiMode in [tmOn, tmAuto]) then begin
    { open the device through TAPI if the device isn't already open }
    if not FComPort.Open then begin
      NewTimer(ET, 91);  { 5 seconds for TAPI to respond }            
      WaitingOnTapi := True;
      FTapiDevice.ConfigAndOpen;
      repeat
        DelayTicks(4, True);
      until (not WaitingOnTapi) or TimerExpired(ET);                   
      if TimerExpired(ET) then                                         
        FTapiDevice.CancelCall;                                        
      if not FComPort.Open then begin

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -