#ifndef OverbyteIcsSnippets1H
#define OverbyteIcsSnippets1H

#include <System.Classes.hpp>
#include <Vcl.Controls.hpp>
#include <Vcl.StdCtrls.hpp>
#include <Vcl.Forms.hpp>
#include <Vcl.ExtCtrls.hpp>

#include "OverbyteIcsTypes.hpp"
#include "OverbyteIcsFileCopy.hpp"
#include "OverbyteIcsMailQueue.hpp"
#include "OverbyteIcsWebSocketCli.hpp"

#include <functional>

class TSnippets : public TForm
{
__published:
    TPanel *Panel1;
    TMemo *LogWin;
    TButton *doFtpDownOneFile;
    TButton *doFileCopyOneFile;
    TEdit *DirTemp;
    TLabel *Label1;
    TLabel *LabelProgress;
    TCheckBox *ShowDiags;
    TButton *doAbort;
    TButton *doClose;
    TLabel *Label2;
    TButton *doFtpDownMultiFiles;
    TButton *doFileCopyMultiFiles;
    TButton *doFtpUpOneFile;
    TButton *doFtpUpMultiFiles;
    TButton *doFtpViewDirs;
    TButton *doHttpSimpleUpload;
    TButton *doHttpDownList;
    TButton *doHttpDownLinked;
    TButton *doFileDirView;
    TButton *doHttpFormUpload;
    TButton *doHttpRestReq;
    TButton *doEmailMailQu;
    TButton *doSocketLocal;
    TButton *doClearLog;
    TCheckBox *FtpOnlyCheck;
    TButton *doSocketRemote;
    TButton *doWebSocket;
    TButton *doHttpRestDown;
    TButton *doHttpGetParams;
    TButton *doHttpPostParams;
    void __fastcall doFtpDownOneFileClick(TObject *Sender);
    void __fastcall doFileCopyOneFileClick(TObject *Sender);
    void __fastcall doAbortClick(TObject *Sender);
    void __fastcall doCloseClick(TObject *Sender);
    void __fastcall doFtpDownMultiFilesClick(TObject *Sender);
    void __fastcall doFileCopyMultiFilesClick(TObject *Sender);
    void __fastcall doFtpViewDirsClick(TObject *Sender);
    void __fastcall doFtpUpOneFileClick(TObject *Sender);
    void __fastcall doFtpUpMultiFilesClick(TObject *Sender);
    void __fastcall doFileDirViewClick(TObject *Sender);
    void __fastcall doHttpDownListClick(TObject *Sender);
    void __fastcall doHttpDownLinkedClick(TObject *Sender);
    void __fastcall doHttpRestReqClick(TObject *Sender);
    void __fastcall doHttpSimpleUploadClick(TObject *Sender);
    void __fastcall doHttpFormUploadClick(TObject *Sender);
    void __fastcall doEmailMailQuClick(TObject *Sender);
    void __fastcall doSocketLocalClick(TObject *Sender);
    void __fastcall doClearLogClick(TObject *Sender);
    void __fastcall doWebSocketClick(TObject *Sender);
    void __fastcall doSocketRemoteClick(TObject *Sender);
    void __fastcall doHttpRestDownClick(TObject *Sender);
    void __fastcall doHttpGetParamsClick(TObject *Sender);
    void __fastcall doHttpPostParamsClick(TObject *Sender);
    void __fastcall FormCreate(TObject *Sender);

private:
    bool FAbortFlag = false;

    void AddLogText(const String &Line);
    void WaitWhileRunning(int TimeoutMins, const std::function<void()> &OnIdle = nullptr);

    void __fastcall onXferEvent(TIcsCopyLogLevel LogLevel, String Info, bool &Cancel);
    void __fastcall onSslHttpRestProg(TObject *Sender, TLogOption LogOption, const String Msg);
    void __fastcall onSslWebSocketCliWSFrameRcvd(TSslWebSocketCli *Sender, const String APacket,
                                                 TWebSocketReceivedFrame *&AFrame);
    void __fastcall onSslWebSocketCliWSConnected(TObject *Sender);
    void __fastcall onSslWebSocketCliWSDisconnected(TObject *Sender);
    void __fastcall onCliLogRecvEvent(TObject *Sender, int Socnr, const String Line);
    void __fastcall onCliLogProgEvent(TObject *Sender, int Socnr, TLogOption LogOption, const String Msg);
    void __fastcall onSrvLogRecvEvent(TObject *Sender, int Socnr, const String Line);
    void __fastcall onSrvLogProgEvent(TObject *Sender, int Socnr, TLogOption LogOption, const String Msg);
    void __fastcall onIcsMailQueueLogEvent(TMailLogLevel LogLevel, const String Info);

public:
    __fastcall TSnippets(TComponent *Owner);
};

extern PACKAGE TSnippets *Snippets;

#endif
