#ifndef OverbyteIcsXferTst1H
#define OverbyteIcsXferTst1H

#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.StdCtrls.hpp>
#include <Vcl.Forms.hpp>
#include <Vcl.ComCtrls.hpp>
#include <Vcl.ExtCtrls.hpp>

#include "OverbyteIcsTypes.hpp"
#include "OverbyteIcsSslUtils.hpp"
#include "OverbyteIcsFileCopy.hpp"
#include "OverbyteIcsFtpMulti.hpp"
#include "OverbyteIcsHttpMulti.hpp"

#include <memory>

class TForm1 : public TForm
{
__published:
    TLabel *Label1;
    TLabel *LabelProgress;
    TLabel *LabelSslState;
    TLabel *Label26;
    TLabel *lbl1;
    TLabel *Label29;
    TMemo *LogText;
    TPageControl *PageControl1;
    TTabSheet *TabSheet1;
    TLabel *Label2;
    TLabel *Label3;
    TLabel *Label4;
    TLabel *Label19;
    TLabel *Label20;
    TLabel *Label27;
    TLabel *Label31;
    TButton *doCopyCheck;
    TButton *doCopyList;
    TEdit *CopySrcDir;
    TEdit *CopySrcFile;
    TButton *doCopyFiles;
    TEdit *CopyTarDir;
    TButton *doCopyAbort;
    TButton *doDeleteCheck;
    TButton *doDeleteFiles;
    TEdit *NetLogon;
    TEdit *NetPassword;
    TCheckBox *CopySubdirs;
    TCheckBox *CopyEmptyDirs;
    TCheckBox *CopyWow64Disable;
    TEdit *CopyIgnorePath;
    TComboBox *CopyFileRepl;
    TCheckBox *CopyZip;
    TCheckBox *CopyUnzip;
    TTabSheet *TabSheet2;
    TLabel *Label9;
    TLabel *Label10;
    TLabel *Label11;
    TLabel *Label21;
    TLabel *Label22;
    TLabel *Label23;
    TLabel *Label24;
    TLabel *Label25;
    TEdit *FtpUsername;
    TEdit *FtpPassword;
    TComboBox *FtpServerType;
    TComboBox *FtpHost;
    TCheckBox *FtpPassive;
    TEdit *FtpPort;
    TEdit *FtpPortSsl;
    TEdit *FtpKeepAlive;
    TCheckBox *FtpNoFeatCmd;
    TEdit *FtpBandWidth;
    TCheckBox *FtpNoZlib;
    TCheckBox *FtpNoTmpFile;
    TCheckBox *FtpNoUtf8;
    TCheckBox *ftpNoHost;
    TCheckBox *ftpIgnoreUtf8;
    TCheckBox *FtpNoMd5;
    TCheckBox *FtpNoCrc;
    TCheckBox *FtpFixPassiveLanIP;
    TTabSheet *TabSheet5;
    TLabel *Label8;
    TLabel *Label13;
    TLabel *Label12;
    TLabel *Label28;
    TLabel *Label30;
    TEdit *FtpPath;
    TEdit *FtpSrcFile;
    TEdit *FtpLocDir;
    TButton *doFtpDownCheck;
    TButton *doFtpDownFiles;
    TButton *doFtpAbort;
    TButton *doFtpUpCheck;
    TButton *doFtpUpFiles;
    TButton *doFtpList;
    TCheckBox *FtpSubdirs;
    TCheckBox *FtpDelDone;
    TCheckBox *FtpDelOldTar;
    TCheckBox *FtpCopyAllDir;
    TCheckBox *FtpEmptyDirs;
    TButton *doFtpUpThread;
    TButton *doFtpListThread;
    TButton *doFtpDownThread;
    TEdit *FtpIgnorePath;
    TComboBox *FtpMultiFileRepl;
    TCheckBox *FtpMultiUnzip;
    TCheckBox *FtpMultiZip;
    TTabSheet *TabSheet4;
    TLabel *Label15;
    TLabel *Label16;
    TLabel *Label17;
    TLabel *Label18;
    TLabel *Label32;
    TEdit *Ftp1Path;
    TEdit *Ftp1SrcName;
    TEdit *Ftp1LocDir;
    TButton *doFtpDown1;
    TButton *doFtpUp1;
    TEdit *Ftp1UpFile;
    TCheckBox *Ftp1DelDone;
    TButton *doFtpAbort1;
    TComboBox *Ftp1FileRepl;
    TCheckBox *Ftp1Zip;
    TCheckBox *Ftp1Unzip;
    TTabSheet *TabSheet3;
    TLabel *Label5;
    TLabel *Label6;
    TLabel *Label7;
    TLabel *Label14;
    TLabel *Label33;
    TLabel *Label34;
    TEdit *HttpTarDir;
    TButton *doHttpDownCheck;
    TButton *doHttpDownFiles;
    TButton *doHttpAbort;
    TComboBox *HttpSrcFile;
    TMemo *HttpSrcDir;
    TEdit *HttpBandWidth;
    TComboBox *HttpFileRepl;
    TCheckBox *HttpParsePage;
    TEdit *HttpParseLevels;
    TCheckBox *HttpUnzip;
    TTabSheet *TabSheet6;
    TLabel *Label35;
    TLabel *Label36;
    TRadioGroup *CleanupType;
    TGroupBox *BoxCleanupDays;
    TLabel *Label115;
    TEdit *CleanupDays;
    TGroupBox *BoxCleanupDates;
    TLabel *Label109;
    TLabel *Label114;
    TDateTimePicker *CleanupDateFrom;
    TDateTimePicker *CleanupDateTo;
    TEdit *CleanupFileMask;
    TCheckBox *CleanupSubDirs;
    TEdit *CleanupPath;
    TButton *doCleanupCheck;
    TButton *doCleanupStart;
    TTabSheet *TabSheet7;
    TLabel *Label37;
    TLabel *Label38;
    TLabel *Label39;
    TEdit *Copy1FileTar;
    TComboBox *Copy1Replc;
    TEdit *Copy1FileSrc;
    TButton *doCopyOneFile;
    TTabSheet *TabZipping;
    TLabel *LabelZipDir;
    TRadioGroup *ZippingExtFmt;
    TRadioGroup *UnzipZipPath;
    TCheckBox *UnzipDownDel;
    TRadioGroup *ZippingType;
    TEdit *UnzipDir;
    TTabSheet *TabSheet8;
    TLabel *Label40;
    TLabel *Label41;
    TComboBox *WebdavHost;
    TCheckBox *WebdavJsonPropFind;
    TGroupBox *GroupBox5;
    TLabel *Label53;
    TLabel *Label54;
    TLabel *Label55;
    TEdit *WebdavAuthBearer;
    TEdit *WebdavAuthPW;
    TEdit *WebdavAuthLogin;
    TRadioGroup *WebdavAuthType;
    TEdit *WebdavPort;
    TCheckBox *WebdavSafeopy;
    TCheckBox *WebdavCompress;
    TTabSheet *TabSheet9;
    TLabel *Label43;
    TLabel *Label44;
    TLabel *Label45;
    TLabel *Label46;
    TLabel *Label47;
    TButton *doWebdavMAbort;
    TButton *doWebdavMUp;
    TButton *doWebdavMCheckUp;
    TButton *doWebdavMDown;
    TButton *doWebdavMCheckDown;
    TButton *doWebdavMList;
    TEdit *WebdavMLocalDir;
    TComboBox *WebdavMFileRepl;
    TEdit *WebdavExclDirs;
    TEdit *WebdavSrcFileMask;
    TCheckBox *WebdavCopyEmptyDir;
    TCheckBox *WebdavDelAfterXfer;
    TCheckBox *WebdavDelTarFiles;
    TCheckBox *WebdavSubDirs;
    TCheckBox *WebdavCopyAllDir;
    TEdit *WebdavMRemPath;
    TTabSheet *TabSheet10;
    TLabel *Label48;
    TLabel *Label49;
    TLabel *Label50;
    TLabel *Label51;
    TLabel *Label52;
    TButton *doWebdavSAbort;
    TButton *doWebdavSUp;
    TButton *doWebdavSDown;
    TCheckBox *WebdavSDelAfter;
    TComboBox *WebdavSFileRepl;
    TEdit *WebdavSUpPath;
    TEdit *WebdavSDownDir;
    TEdit *WebdavSDownFile;
    TEdit *WebdavSRemPath;
    TTabSheet *TabSheet11;
    TGroupBox *BoxClientCert;
    TComboBox *WebdavCliCertLoc;
    TEdit *WebdavCliCertFile;
    TMemo *LogDelim;
    TCheckBox *ShowDiagsHigh;
    TButton *doExit;
    TCheckBox *ShowDiagsLow;
    TCheckBox *ShowDiagsSSL;
    TButton *doClear;
    TCheckBox *ShowXProgesss;
    TCheckBox *RevokeCheck;
    TRadioGroup *VerifyCertMode;
    TCheckBox *ReportChain;
    TComboBox *SslSecurity;
    TEdit *DirLogs;
    TRadioGroup *XferSockFamily;
    TCheckBox *NoSSL;
    TTimer *TimerUpdates;
    void __fastcall doCopyListClick(TObject *Sender);
    void __fastcall CopyFiles(TObject *Sender);
    void __fastcall doAbortClick(TObject *Sender);
    void __fastcall doExitClick(TObject *Sender);
    void __fastcall DeleteFiles(TObject *Sender);
    void __fastcall HttpDownload(TObject *Sender);
    void __fastcall FtpDownload(TObject *Sender);
    void __fastcall doFtpListClick(TObject *Sender);
    void __fastcall FtpUpload(TObject *Sender);
    void __fastcall doFtpDown1Click(TObject *Sender);
    void __fastcall doFtpUp1Click(TObject *Sender);
    void __fastcall FormCreate(TObject *Sender);
    void __fastcall FormDestroy(TObject *Sender);
    void __fastcall doClearClick(TObject *Sender);
    void __fastcall doFtpListThreadClick(TObject *Sender);
    void __fastcall doFtpDownThreadClick(TObject *Sender);
    void __fastcall doFtpUpThreadClick(TObject *Sender);
    void __fastcall TimerUpdatesTimer(TObject *Sender);
    void __fastcall doCleanupCheckClick(TObject *Sender);
    void __fastcall CleanupTypeClick(TObject *Sender);
    void __fastcall doCleanupStartClick(TObject *Sender);
    void __fastcall doCopyOneFileClick(TObject *Sender);
    void __fastcall doWebdavMListClick(TObject *Sender);
    void __fastcall doWebdavMDownFiles(TObject *Sender);
    void __fastcall doWebdavMUpClick(TObject *Sender);
    void __fastcall doWebdavSDownClick(TObject *Sender);
    void __fastcall doWebdavSUpClick(TObject *Sender);
    void __fastcall doWebdavSAbortClick(TObject *Sender);

private:
    String FIniFileName;
    String FBuffDiags;
    std::unique_ptr<TIcsBuffLogStream> FLogStream;
    bool FAbortFlag = false;
    bool FLogEstimate = false;
    int FCurThreads = 0;
    int FNextThread = 0;
    TDateTime FCleanLoDT;
    TDateTime FCleanHiDT;

    void AddLogText(String S);
    void AddLogDelim(const String &S);
    void OpenLogFile();
    void GetSettings();
    void PutSettings();
    void InitSSL();
    void AddHostToList(TComboBox *Hosts);
    bool SetFTPGen(TIcsFtpMulti *Ftp);
    TIcsFtpMultiThread *SetFTPThreadGen();
    void DiscardThread(TIcsFtpMultiThread *Thread, bool Free);
    void __fastcall FormCloseQuery(TObject *Sender, bool &CanClose);
    bool SetWebDAVGen(TIcsWebDAV *WebDAV);
    void SetFtpButtons(bool Value);
    void SetWebDAVButtons(bool Value);
    bool ValidCleanupMask(const String &Mask);
    bool SetCleanupDates();
    void doCleanup(bool CheckFiles);
    void __fastcall onCopyEvent(TIcsCopyLogLevel LogLevel, String Info, bool &Cancel);
    void __fastcall onProgressEvent(TObject *Sender, const TIcsCopyProgress &CopyProgress, bool &Cancel);
    void __fastcall onThreadEvent(TIcsCopyLogLevel LogLevel, const String Id, const String Info, bool &Cancel);
    void __fastcall OnThreadTerminate(TObject *Sender);
    void __fastcall WebDAVRestProg(TObject *Sender, TLogOption LogOption, const String Msg);

public:
    __fastcall TForm1(TComponent *Owner);
};

extern PACKAGE TForm1 *Form1;

#endif
