//---------------------------------------------------------------------------

#ifndef mainH
#define mainH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include "wclBluetooth.hpp"
#include <Forms.hpp>
#include "wclBluetoothErrors.hpp"
#include "wclPowerEvents.hpp"
#include <ComCtrls.hpp>
//---------------------------------------------------------------------------
class TfmMain : public TForm
{
__published:	// IDE-managed Components
        TLabel *laTimeout;
        TLabel *laPin;
        TListView *lvEvents;
        TButton *btClearEvents;
        TButton *btOpen;
        TButton *btClose;
        TListView *lvRadios;
        TButton *btRefreshRadio;
        TButton *btSetConnectable;
        TButton *btSetDiscoverable;
        TButton *btSetName;
        TEdit *edName;
        TButton *btEnumPaired;
        TListView *lvDevices;
        TButton *btRefreshDevice;
        TButton *btEnumServices;
        TListView *lvServices;
        TButton *btDiscover;
        TEdit *edTimeout;
        TButton *btTerminate;
        TButton *btUnpair;
        TButton *btPair;
        TEdit *edPin;
        TButton *btRSSI;
        TButton *btTurnOn;
        TButton *btTurnOff;
        TwclBluetoothManager *wclBluetoothManager;
        TButton *btCreateVCOM;
        TButton *btDestroyVCOM;
        TButton *btEnumVCOMs;
        TListView *lvVComs;
        TCheckBox *cbEnumPreinstalled;
        TButton *btInstallDevice;
        TButton *btUninstallDevice;
        TButton *btIsInRange;
        TLabel *laDiscoveringMode;
        TComboBox *cbDiscoveringMode;
        TLabel *laMitmProtection;
        TComboBox *cbMitmProtection;
        TLabel *laIoCap;
        TComboBox *cbIoCap;
        TLabel *laBleProtection;
        TComboBox *cbBleProtection;
        TLabel *laPairingMethod;
        TComboBox *cbPairingMethod;
        TButton *ntDisconnect;
        TButton *btEnumConnected;
        TButton *btEnumInstalledServices;
        TCheckBox *cbHandlePairing;
        TCheckBox *cbDontTurnOff;
        void __fastcall btClearEventsClick(TObject *Sender);
        void __fastcall FormDestroy(TObject *Sender);
        void __fastcall btRefreshRadioClick(TObject *Sender);
        void __fastcall btOpenClick(TObject *Sender);
        void __fastcall btCloseClick(TObject *Sender);
        void __fastcall btSetConnectableClick(TObject *Sender);
        void __fastcall btSetDiscoverableClick(TObject *Sender);
        void __fastcall btSetNameClick(TObject *Sender);
        void __fastcall btEnumPairedClick(TObject *Sender);
        void __fastcall btRefreshDeviceClick(TObject *Sender);
        void __fastcall btEnumServicesClick(TObject *Sender);
        void __fastcall btDiscoverClick(TObject *Sender);
        void __fastcall btTerminateClick(TObject *Sender);
        void __fastcall btUnpairClick(TObject *Sender);
        void __fastcall btPairClick(TObject *Sender);
        void __fastcall btRSSIClick(TObject *Sender);
        void __fastcall btTurnOnClick(TObject *Sender);
        void __fastcall btTurnOffClick(TObject *Sender);
        void __fastcall wclBluetoothManagerAfterOpen(TObject *Sender);
        void __fastcall wclBluetoothManagerBeforeClose(TObject *Sender);
        void __fastcall wclBluetoothManagerAuthenticationCompleted(
          TObject *Sender, const TwclBluetoothRadio *Radio,
          const __int64 Address, const int Error);
        void __fastcall wclBluetoothManagerDeviceFound(TObject *Sender,
          const TwclBluetoothRadio *Radio, const __int64 Address);
        void __fastcall wclBluetoothManagerDiscoveringCompleted(
          TObject *Sender, const TwclBluetoothRadio *Radio,
          const int Error);
        void __fastcall wclBluetoothManagerDiscoveringStarted(
          TObject *Sender, const TwclBluetoothRadio *Radio);
        void __fastcall wclBluetoothManagerNumericComparison(
          TObject *Sender, const TwclBluetoothRadio *Radio,
          const __int64 Address, const DWORD Number, bool& Confirm);
        void __fastcall wclBluetoothManagerPasskeyNotification(
          TObject *Sender, const TwclBluetoothRadio *Radio,
          const __int64 Address, const DWORD Passkey);
        void __fastcall wclBluetoothManagerPasskeyRequest(TObject *Sender,
          const TwclBluetoothRadio *Radio, const __int64 Address,
          DWORD& Passkey);
        void __fastcall wclBluetoothManagerPinRequest(TObject *Sender,
          const TwclBluetoothRadio *Radio, const __int64 Address,
          String& Pin);
        void __fastcall wclBluetoothManagerStatusChanged(TObject *Sender,
          const TwclBluetoothRadio *Radio);
        void __fastcall btEnumVCOMsClick(TObject *Sender);
        void __fastcall btCreateVCOMClick(TObject *Sender);
        void __fastcall btDestroyVCOMClick(TObject *Sender);
        void __fastcall btInstallDeviceClick(TObject *Sender);
        void __fastcall btUninstallDeviceClick(TObject *Sender);
        void __fastcall btIsInRangeClick(TObject *Sender);
        void __fastcall wclBluetoothManagerConfirm(TObject *Sender,
          const TwclBluetoothRadio *Radio, const __int64 Address,
          bool& Confirm);
        void __fastcall wclBluetoothManagerIoCapabilityRequest(
          TObject *Sender, const TwclBluetoothRadio *Radio,
          const __int64 Address, TwclBluetoothMitmProtection& Mitm,
          TwclBluetoothIoCapability& IoCapability, bool& OobPresent);
        void __fastcall wclBluetoothManagerOobDataRequest(TObject *Sender,
          const TwclBluetoothRadio *Radio, const __int64 Address,
          TwclBluetoothOobData &OobData);
        void __fastcall wclBluetoothManagerProtectionLevelRequest(
          TObject *Sender, const TwclBluetoothRadio *Radio,
          const __int64 Address,
          TwclBluetoothLeProtectionLevel& Protection);
        void __fastcall FormCreate(TObject *Sender);
        void __fastcall wclBluetoothManagerClosed(TObject *Sender);
        void __fastcall ntDisconnectClick(TObject *Sender);
        void __fastcall btEnumConnectedClick(TObject *Sender);
        void __fastcall btEnumInstalledServicesClick(TObject *Sender);
private:	// User declarations
        TwclPowerEventsMonitor* FPowerMonitor;

        void __fastcall TraceEvent(TwclBluetoothRadio* Radio, String Event,
          String Parameter, String Value);

        void __fastcall ShowError(int Error);

        void __fastcall RefreshRadio(TListItem* Item);
        void __fastcall AddDevice(TwclBluetoothRadio* Radio, __int64 Address);
        void __fastcall RefreshDevices();
        void __fastcall RefreshDevice(TListItem* Item);
        void __fastcall RefreshVComs();

        void __fastcall ClearRadios();
        void __fastcall ClearDevices();
        void __fastcall ClearServices();
        void __fastcall ClearComPorts();

        void __fastcall PowerStateChanged(TObject* Sender,
          const TwclPowerState State);

public:		// User declarations
        __fastcall TfmMain(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TfmMain *fmMain;
//---------------------------------------------------------------------------
#endif
