#ifndef OverbyteIcsSslMailSnd1H
#define OverbyteIcsSslMailSnd1H

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

#include "OverbyteIcsWndControl.hpp"
#include "OverbyteIcsSmtpProt.hpp"
#include "OverbyteIcsSslHttpOAuth.hpp"
#include "OverbyteIcsCharsetComboBox.hpp"
#include "OverbyteIcsOAuthFormVclE.hpp"
#include "OverbyteIcsSslBase.hpp"
#include "OverbyteIcsTypes.hpp"

class TSslSmtpTestForm : public TForm
{
__published:
    TMemo *MsgMemo;
    TMemo *DisplayMemo;
    TPanel *ToolsPanel;
    TLabel *Label1;
    TLabel *Label2;
    TLabel *Label3;
    TLabel *Subject;
    TLabel *Label4;
    TLabel *Label5;
    TLabel *Label8;
    TLabel *Label9;
    TLabel *Label10;
    TLabel *Label11;
    TLabel *Label12;
    TLabel *Label13;
    TLabel *Label14;
    TLabel *Label15;
    TLabel *Label16;
    TLabel *Label17;
    TLabel *Label18;
    TLabel *Label19;
    TLabel *Label21;
    TLabel *DefEnc;
    TLabel *Label20;
    TLabel *Label22;
    TEdit *HostEdit;
    TEdit *FromEdit;
    TEdit *ToEdit;
    TEdit *SubjectEdit;
    TEdit *SignOnEdit;
    TEdit *PortEdit;
    TButton *ClearDisplayButton;
    TButton *ConnectButton;
    TButton *HeloButton;
    TButton *MailFromButton;
    TButton *RcptToButton;
    TButton *DataButton;
    TButton *AbortButton;
    TButton *QuitButton;
    TButton *MailButton;
    TButton *OpenButton;
    TEdit *UsernameEdit;
    TEdit *PasswordEdit;
    TComboBox *AuthComboBox;
    TButton *EhloButton;
    TButton *AuthButton;
    TEdit *CcEdit;
    TEdit *BccEdit;
    TButton *AllInOneButton;
    TComboBox *PriorityComboBox;
    TButton *TlsButton;
    TCheckBox *VerifyPeerCheckBox;
    TComboBox *SmtpSslModeCombobox;
    TEdit *KeyEdit;
    TEdit *CertEdit;
    TEdit *CaFileEdit;
    TEdit *CaPathEdit;
    TEdit *PassPhraseEdit;
    TIcsCharsetComboBox *IcsCharsetComboBox1;
    TCheckBox *ConvertToCharsetCheckBox;
    TCheckBox *Allow8BitCheckBox;
    TCheckBox *FoldHeadersCheckBox;
    TComboBox *DefEncodingComboBox;
    TCheckBox *WrapTextCheckBox;
    TEdit *WrapAtEdit;
    TCheckBox *UseMailMessageCheckBox;
    TCheckBox *OAuth2ExtBrow;
    TComboBox *OAuth2UserAuth;
    TPanel *AttachPanel;
    TLabel *Label6;
    TMemo *FileAttachMemo;
    TPanel *InfoPanel;
    TLabel *Label7;
    TSslSmtpCli *SslSmtpClient;
    TSslContext *SslContext1;
    TIcsRestEmail *IcsRestEmail1;
    TOAuthBrowser *OAuthBrowser1;
    void __fastcall FormCreate(TObject *Sender);
    void __fastcall ClearDisplayButtonClick(TObject *Sender);
    void __fastcall ConnectButtonClick(TObject *Sender);
    void __fastcall SslSmtpClientRequestDone(TObject *Sender, TSmtpRequest RqType, System::Word ErrorCode);
    void __fastcall HeloButtonClick(TObject *Sender);
    void __fastcall MailFromButtonClick(TObject *Sender);
    void __fastcall RcptToButtonClick(TObject *Sender);
    void __fastcall DataButtonClick(TObject *Sender);
    void __fastcall AbortButtonClick(TObject *Sender);
    void __fastcall QuitButtonClick(TObject *Sender);
    void __fastcall MailButtonClick(TObject *Sender);
    void __fastcall OpenButtonClick(TObject *Sender);
    void __fastcall FormShow(TObject *Sender);
    void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
    void __fastcall EhloButtonClick(TObject *Sender);
    void __fastcall AuthButtonClick(TObject *Sender);
    void __fastcall AllInOneButtonClick(TObject *Sender);
    void __fastcall SmtpClientDisplay(TObject *Sender, String Msg);
    void __fastcall SslSmtpClientGetData(TObject *Sender, int LineNum, void *MsgLine, int MaxLen, bool &More);
    void __fastcall SslSmtpClientHeaderLine(TObject *Sender, void *Msg, int Size);
    void __fastcall SslSmtpClientBeforeFileOpen(TObject *Sender, int Idx, String FileName, TSmtpBeforeOpenFileAction &Action);
    void __fastcall TlsButtonClick(TObject *Sender);
    void __fastcall IcsRestEmail1EmailNewToken(TObject *Sender);
    void __fastcall IcsRestEmail1EmailProg(TObject *Sender, TLogOption LogOption, const String Msg);
    void __fastcall SslSmtpClientGetNewToken(TObject *Sender);
    void __fastcall AuthComboBoxChange(TObject *Sender);
    void __fastcall IcsRestEmail1OAEmbed(TObject *Sender, const String URL, bool &Success);

private:
    String FIniFileName;
    bool FInitialized;
    bool FAllInOneFlag;
    int FEhloCount;
    void __fastcall Display(const String &Msg);
    void __fastcall ExceptionHandler(TObject *Sender, Exception *E);
    void __fastcall SetupOAuth2();
    void __fastcall ApplyMessageSettings();
    bool __fastcall ApplySslSettings();
    bool __fastcall IsOAuth2() const;

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

extern PACKAGE TSslSmtpTestForm *SslSmtpTestForm;

#endif
