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

📄 adprotcl.pas

📁 Async Professional 4.04
💻 PAS
📖 第 1 页 / 共 5 页
字号:

  procedure TApdCustomProtocol.SetComPort(const NewComPort : TApdCustomComPort);
    {-Set a new comport}
  begin
    if NewComPort <> FComPort then begin
      FComPort := NewComPort;
      if Assigned(FComPort) then
        apSetProtocolPort(PData, ComPort)
      else
        apSetProtocolPort(PData, nil);
    end;
  end;

  procedure TApdCustomProtocol.SetProtocolType(
                               const NewProtocol : TProtocolType);
    {-Set a new protocol type}
  var
    Status : Integer;
  begin
    if (NewProtocol <> FProtocolType) or
       (csLoading in ComponentState) then begin
      {Dispose of current protocol, if necessary}
      case FProtocolType of
        ptXmodem, ptXmodemCRC, ptXmodem1K, ptXmodem1KG :
          {nothing to do};
        ptYModem, ptYmodemG :
          ypDonePart(PData);
        ptZmodem :
          zpDonePart(PData);
        ptKermit :
          kpDonePart(PData);
        ptASCII :
          spDonePart(PData);
      end;

      {Init new protocol}
      Status := ecOk;
      Force := True;
      case NewProtocol of
        ptXmodem, ptXmodemCRC, ptXmodem1K, ptXmodem1KG :
          begin
            xpReinit(PData, NewProtocol <> ptXmodem,
                            NewProtocol = ptXmodem1K,
                            NewProtocol = ptXmodem1KG);
            SetXYmodemBlockWait(FXYmodemBlockWait);
          end;

        ptYmodem, ptYModemG :
          begin
            Status := ypReinit(PData,
                               True,
                               NewProtocol = ptYmodemG);
            if Status = ecOk then
              SetXYmodemBlockWait(FXYmodemBlockWait);
          end;

        ptZmodem :
          begin
            Status := zpReinit(PData);
            if Status = ecOk then begin
              SetZmodemOptionOverride(FZmodemOptionOverride);
              SetZmodemSkipNoFile(FZmodemSkipNoFile);
              SetZmodemFileOption(FZmodemFileOption);
              SetZmodemRecover(FZmodemRecover);
              SetZmodem8K(FZmodem8K);
              SetZmodemFinishRetry(FZmodemFinishRetry);
            end;
          end;

        ptKermit :
          begin
            Status := kpReinit(PData);
            if Status = ecOk then begin
              SetKermitMaxLen(FKermitMaxLen);
              SetKermitMaxWindows(FKermitMaxWindows);
              SetKermitSWCTurnDelay(FKermitSWCTurnDelay);
              SetKermitTimeoutSecs(FKermitTimeoutSecs);
              SetKermitPadCharacter(FKermitPadCharacter);
              SetKermitPadCount(FKermitPadCount);
              SetKermitTerminator(FKermitTerminator);
              SetKermitCtlPrefix(FKermitCtlPrefix);
              SetKermitHighbitPrefix(FKermitHighbitPrefix);
              SetKermitRepeatPrefix(FKermitRepeatPrefix);
            end;
          end;

        ptASCII :
          begin
            Status := spReinit(PData);
            if Status = ecOk then begin
              SetAsciiCharDelay(FAsciiCharDelay);
              SetAsciiLineDelay(FAsciiLineDelay);
              SetAsciiEOLChar(FAsciiEOLChar);
              SetAsciiCRTranslation(FAsciiCRTranslation);
              SetAsciiLFTranslation(FAsciiLFTranslation);
              SetAsciiEOFTimeout(FAsciiEOFTimeout);
            end;
          end;
     end;

     {Note new protocol type}
     if Status = ecOk then
        FProtocolType := NewProtocol
     else
       CheckException(Self, Status);
    end;
  end;

  function TApdCustomProtocol.GetDestinationDirectory : String;
    {-Return the destination directory}
  begin
    Result := StrPas(PData^.aDestDir);
  end;

  procedure TApdCustomProtocol.SetDestinationDirectory(const NewDir : String);
    {-Set a new destination directory}
  begin
    with PData^ do
      StrPCopy(aDestDir, NewDir);
  end;

  function TApdCustomProtocol.GetFileMask : TFileName;
    {-Return the current file mask}
  begin
    Result := StrPas(PData^.aSearchMask);
  end;

  procedure TApdCustomProtocol.SetFileMask(const NewFileMask : TFileName);
    {-Set a new file mask}
  var
    S : TFileName;
  begin
    with PData^ do
      {$IFDEF Win32}
      if Length(NewFileMask) > 255 then begin
        S := NewFileMask;
        SetLength(S, 255);
        StrPCopy(aSearchMask, S);
      end else
      {$ENDIF}
        StrPCopy(aSearchMask, NewFileMask);
  end;

  function TApdCustomProtocol.GetBatch : Boolean;
    {-Return True if the current protocol supports batch transfers}
  begin
    Result := PData^.aBatchProtocol;
  end;

  function TApdCustomProtocol.GetBlockCheckMethod : TBlockCheckMethod;
    {-Return the current block check method}
  begin
    Result := TBlockCheckMethod(PData^.aCheckType);
  end;

  function TApdCustomProtocol.GetProtocolStatus : Cardinal;
    {-Return the current protocol status}
  begin
    Result := PData^.aProtocolStatus;
  end;

  function TApdCustomProtocol.GetProtocolError : SmallInt;
    {-Return the current protocol error}
  begin
    Result := PData^.aProtocolError;
  end;

  function TApdCustomProtocol.GetFileLength : LongInt;
    {-Return the file length}
  begin
    Result := PData^.aSrcFileLen;
  end;

  function TApdCustomProtocol.GetFileDate : TDateTime;
    {-Return the file timestamp}
  begin
    Result := FileDateToDateTime(PData^.aSrcFileDate);
  end;

  function TApdCustomProtocol.GetInitialPosition : LongInt;
    {-Return the initial file position}
  begin
    Result := PData^.aInitFilePos;
  end;

  function TApdCustomProtocol.GetStatusInterval : Cardinal;
    {-Return the current status update interval, in ticks}
  begin
    Result := PData^.aStatusInterval;
  end;

  procedure TApdCustomProtocol.SetStatusInterval(const NewInterval : Cardinal);
    {-Set a new update status interval}
  begin
    with PData^ do
      if NewInterval <> aStatusInterval then
        aStatusInterval := NewInterval;
  end;

  procedure TApdCustomProtocol.SetStatusDisplay(
                               const NewDisplay : TApdAbstractStatus);
    {-Set a new status display}
  begin
    if NewDisplay <> FStatusDisplay then begin
      FStatusDisplay := NewDisplay;
      if Assigned(FStatusDisplay) then
        FStatusDisplay.FProtocol := Self;
    end;
  end;

  procedure TApdCustomProtocol.SetProtocolLog(const NewLog : TApdProtocolLog);
    {-Set a new protocol log}
  begin
    if NewLog <> FProtocolLog then begin
      FProtocolLog := NewLog;
      if Assigned(FProtocolLog) then
        FProtocolLog.FProtocol := Self;
    end;
  end;

  function TApdCustomProtocol.GetInProgress : Boolean;
    {-Return True if protocol is in progress}
  begin
    Result := PData^.aInProgress <> 0;
  end;

  function TApdCustomProtocol.GetBlockErrors : Cardinal;
    {-Return the number of block errors}
  begin
    Result := PData^.aBlockErrors;
  end;

  function TApdCustomProtocol.GetTotalErrors : Cardinal;
    {-Return the number of total errors}
  begin
    Result := PData^.aTotalErrors;
  end;

  function TApdCustomProtocol.GetBytesRemaining : LongInt;
    {-Return the number of bytes remaining to be transferred}
  begin
    Result := apGetBytesRemaining(PData);
  end;

  function TApdCustomProtocol.GetBytesTransferred : LongInt;
    {-Return the number of bytes transferred so far}
  begin
    Result := apGetBytesTransferred(PData);
  end;

  function TApdCustomProtocol.GetElapsedTicks : LongInt;
    {-Return the ticks elapsed for this transfer}
  begin
    Result := PData^.aElapsedTicks;
  end;

  function TApdCustomProtocol.GetFileName : String;
    {-Return the current file name}
  begin
    Result := StrPas(PData^.aPathname);
  end;

  procedure TApdCustomProtocol.SetFileName(const NewName : String);
    {-Set/change the incoming file name}
  var
    P : array[0..255] of Char;
    S : String;
  begin
    {Allow changes only when WorkFile is *not* open}
    case TFileRec(PData^.aWorkFile).Mode of
      fmInput, fmOutput, fmInOut : ;
      else begin
        {$IFDEF Win32}
        if Length(NewName) > 255 then begin
          S := NewName;
          SetLength(S, 255);
          StrPCopy(P, S);
        end else
        {$ENDIF}
          StrPCopy(P, NewName);
        apSetReceiveFileName(PData, P);
      end;
    end;
  end;

  function TApdCustomProtocol.GetXYmodemBlockWait : Cardinal;
    {-Return the X/Ymodem block wait value in ticks}
  begin
    case TProtocolType(PData^.aCurProtocol) of
      ptXmodem..ptYmodemG :
        begin
          FXYmodemBlockWait := PData^.xBlockWait;
          Result := FXYmodemBlockWait;
        end;
      else
        Result := FXYmodemBlockWait;
    end;
  end;

  procedure TApdCustomProtocol.SetXYmodemBlockWait(const NewWait : Cardinal);
    {-Set a new X/Ymodem block wait}
  begin
    if (NewWait <> FXYmodemBlockWait) or Force then begin
      FXYmodemBlockWait := NewWait;
      case TProtocolType(PData^.aCurProtocol) of
        ptXmodem..ptYmodemG :
          PData^.xBlockWait := NewWait;
      end;
    end;
  end;

  function TApdCustomProtocol.GetZmodemOptionOverride : Boolean;
    {-Return the zmodem override option}
  begin
    if PData^.aCurProtocol = Ord(ptZmodem) then
      FZmodemOptionOverride := PData^.ZFileMgmtOverride;
    Result := FZmodemOptionOverride;
  end;

  procedure TApdCustomProtocol.SetZmodemOptionOverride(
                               const NewOverride : Boolean);
    {-Enable/disable the zmodem option override option}
  begin
    if (NewOverride <> FZmodemOptionOverride) or Force then begin
      FZmodemOptionOverride := NewOverride;
      if PData^.aCurProtocol = Ord(ptZmodem) then
        PData^.ZFileMgmtOverride := NewOverride;
    end;
  end;

  function TApdCustomProtocol.GetZmodemSkipNoFile : Boolean;
    {-Return the zmodem skip no file option}
  begin
    if PData^.aCurProtocol = Ord(ptZmodem) then
      with PData^ do
        FZmodemSkipNoFile := (zFileMgmtOpts and FileSkipMask) <> 0;
    Result := FZmodemSkipNoFile;
  end;

  procedure TApdCustomProtocol.SetZmodemSkipNoFile(const NewSkip : Boolean);
    {-Enable/disable the skipnofile option}
  begin
    if (NewSkip <> FZmodemSkipNoFile) or Force then begin
      FZmodemSkipNoFile := NewSkip;
      if PData^.aCurProtocol = Ord(ptZmodem) then
        with PData^ do
          if NewSkip then
            zFileMgmtOpts := zFileMgmtOpts or FileSkipMask
          else
            zFileMgmtOpts := zFileMgmtOpts and not FileSkipMask;
    end;
  end;

  function TApdCustomProtocol.GetZmodemFileOption : TZmodemFileOptions;
    {-Return the zmodem file managment option}
  begin
    if PData^.aCurProtocol = Ord(ptZmodem) then
      FZmodemFileOption :=
        TZmodemFileOptions(PData^.zFileMgmtOpts and not FileSkipMask);
    Result := FZmodemFileOption;
  end;

  procedure TApdCustomProtocol.SetZmodemFileOption(
                               const NewOpt : TZmodemFileOptions);
    {-Set new file management options}
  var

⌨️ 快捷键说明

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