// SiaDriveDlg.h : header file // #pragma once #include #include "SiaDriveConfig.h" #include "ntray.h" using namespace Sia::Api; // CSiaDriveDlg dialog class CSiaDriveDlg : public CDHtmlDialog { // Construction public: CSiaDriveDlg(CWnd* pParent = NULL); // standard constructor // Dialog Data #ifdef AFX_DESIGN_TIME enum { IDD = IDD_SIADRIVE_DIALOG, IDH = IDR_HTML_SIADRIVE_DIALOG }; #endif protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support HRESULT OnButtonOK(IHTMLElement *pElement); HRESULT OnButtonCancel(IHTMLElement *pElement); HRESULT OnButtonCreateWallet(IHTMLElement* pElement); HRESULT OnButtonConfirmSeed(IHTMLElement* pElement); HRESULT OnButtonUnlockWallet(IHTMLElement* pElement); HRESULT OnButtonMount(IHTMLElement* pElement); HRESULT OnButtonRenterEdit(IHTMLElement* pElement); LRESULT OnTrayNotification(WPARAM wParam, LPARAM lParam); // Implementation protected: HICON m_hIcon; // Generated message map functions virtual void OnDocumentComplete(LPDISPATCH pDisp, LPCTSTR szUrl); virtual BOOL OnInitDialog(); afx_msg void OnPaint(); afx_msg HCURSOR OnQueryDragIcon(); afx_msg void OnSysCommand(UINT nID, LPARAM lParam); afx_msg void OnTimer(UINT_PTR nIDEvent); afx_msg void OnSize(UINT ntype, int cx, int cy); DECLARE_MESSAGE_MAP() DECLARE_DHTML_EVENT_MAP() virtual BOOL PreTranslateMessage(MSG* pMsg) override; private: void DisplayPopUp(const String& name); void DisplayCreateWallet(); void DisplayRenterTab(); void DisplaySeedCreated(const String& seed); bool UpdateSiaInfo(); void ReloadDisplay(); void DisplayUnlockWallet(); void ConfigureWallet(); void RemoveCreateWalletItems(); void RemoveDomNodeById(const String& id); void SetMainWindow(const String& name); void SetTabWindow(const String& name); bool UpdateUi(const bool& refresh = true); void SetChildWindow(const String& parentName, const String& name); HRESULT GetDomNodeAndElementById(const String& id, CComPtr& node, CComPtr& elem); HRESULT GetDomNodeById(const String& id, CComPtr& node); BOOL CallClientScript(LPCTSTR pStrFuncName, const json& json, CComVariant* pOutVarRes); BOOL CallClientScript(LPCTSTR pStrFuncName, const String& string, CComVariant* pOutVarRes); BOOL CallClientScript(LPCTSTR pStrFuncName, CComVariant* pOutVarRes); void SetBodyEnabled(const bool& enabled); void SetServerVersion(const String& version); void SetClientVersion(const String& version); void SetWalletConfirmedBalance(const String& balance); void SetWalletUnconfirmedBalance(const String& balance); void SetWalletTotalBalance(const String& balance); void SetWalletReceiveAddress(const String& address); String GetWalletUnlockPassword(); void SetWalletUnlockPassword(const String& address); void SetConsensusHeight(const std::uint64_t& height); void SetRenterAllocatedFunds(const SiaCurrency& currency); void SetRenterAvailableFunds(const SiaCurrency& currency); void SetRenterUsedFunds(const SiaCurrency& currency); void SetRenterHosts(const std::uint64_t& hosts); void SetRenterTotalUsed(const std::uint64_t& bytes); void SetRenterTotalAvailable(const double& gb); void SetRenterTotalRemain(const double& total); void SetRenterTotalUploadProgress(const std::uint32_t& progress); void QueueUiAction(std::function action); void ProcessUiActionQueue(); void ClearDisplay(); private: const DWORD _uiThreadId; CSiaDriveConfig _siaConfig; CTrayNotifyIcon _tray; std::unique_ptr _siaApi; CString _walletCreatedSeed; String _receiveAddress; std::mutex _uiActionQueueMutex; std::deque> _uiActionQueue; bool _connected = false; bool _seedCreation = false; static const UINT IDT_UPDATE = 1; static const UINT IDT_UI_ACTION_QUEUE = 2; static const std::uint8_t RENTER_TAB = 0; public: afx_msg void OnMnuItemToggle(); afx_msg void OnMnuItemExit(); };