649 lines
15 KiB
C++
649 lines
15 KiB
C++
|
|
// SiaDriveDlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "SiaDriveApp.h"
|
|
#include "SiaDriveDlg.h"
|
|
#include "afxdialogex.h"
|
|
#include <stdbool.h>
|
|
#include <bitset>
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#endif
|
|
|
|
/*
|
|
* Home Test
|
|
wept saxophone dialect depth update jaunt loincloth asleep lush gnome laptop upper olive itches essential neither feel fewest siblings brunt tasked upwards coal niece faked dating hedgehog magically abort
|
|
|
|
* Work Test
|
|
names amaze when afraid inmate hull hexagon etched niece rudely tudor unopened acidic swagger emit shrugged noises tycoon leech tubes shrugged bulb inexact plywood tuesday rims cease excess aces
|
|
|
|
* Work Test2
|
|
ornament alkaline gasp pepper upkeep ablaze number sizes toyed sawmill looking bygones dwarf nerves session cake jerseys niche arrow howls omission verification identity waffle pockets giving hiding river acoustic
|
|
*/
|
|
|
|
static std::set<std::string> GetAvailableDrives()
|
|
{
|
|
static const std::vector<char> alpha = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };
|
|
std::bitset<26> drives(~GetLogicalDrives() & 0xFFFFFFFF);
|
|
|
|
std::set<std::string> avail;
|
|
for (size_t i = 0; i < alpha.size(); i++)
|
|
{
|
|
if (drives[i])
|
|
{
|
|
avail.insert(std::string(1, alpha[i]));
|
|
}
|
|
}
|
|
|
|
return std::move(avail);
|
|
}
|
|
|
|
// CAboutDlg dialog used for App About
|
|
|
|
class CAboutDlg : public CDialogEx
|
|
{
|
|
public:
|
|
CAboutDlg();
|
|
|
|
// Dialog Data
|
|
#ifdef AFX_DESIGN_TIME
|
|
enum { IDD = IDD_ABOUTBOX };
|
|
#endif
|
|
|
|
protected:
|
|
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
|
|
|
// Implementation
|
|
protected:
|
|
DECLARE_MESSAGE_MAP()
|
|
};
|
|
|
|
CAboutDlg::CAboutDlg() : CDialogEx(IDD_ABOUTBOX)
|
|
{
|
|
}
|
|
|
|
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialogEx::DoDataExchange(pDX);
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx)
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
// CSiaDriveDlg dialog
|
|
|
|
BEGIN_DHTML_EVENT_MAP(CSiaDriveDlg)
|
|
DHTML_EVENT_ONCLICK(_T("ButtonOK"), OnButtonOK)
|
|
DHTML_EVENT_ONCLICK(_T("ButtonCancel"), OnButtonCancel)
|
|
DHTML_EVENT_ONCLICK(_T("CreateWalletButton"), OnButtonCreateWallet)
|
|
DHTML_EVENT_ONCLICK(_T("ConfirmSeedButton"), OnButtonConfirmSeed)
|
|
DHTML_EVENT_ONCLICK(_T("UnlockWalletButton"), OnButtonUnlockWallet)
|
|
DHTML_EVENT_ONCLICK(_T("MountButton"), OnButtonMount)
|
|
END_DHTML_EVENT_MAP()
|
|
|
|
|
|
CSiaDriveDlg::CSiaDriveDlg(CWnd* pParent /*=NULL*/)
|
|
: CDHtmlDialog(IDD_SIADRIVE_DIALOG, IDR_HTML_SIADRIVE_DIALOG, pParent),
|
|
_siaApi({L"localhost", 9980, L"1.1.0"})
|
|
{
|
|
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
|
|
}
|
|
|
|
void CSiaDriveDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDHtmlDialog::DoDataExchange(pDX);
|
|
DDX_DHtml_ElementInnerText(pDX, _T("WalletCreatedSeed"), _walletCreatedSeed);
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CSiaDriveDlg, CDHtmlDialog)
|
|
ON_WM_SYSCOMMAND()
|
|
ON_WM_TIMER()
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
// CSiaDriveDlg message handlers
|
|
|
|
BOOL CSiaDriveDlg::OnInitDialog()
|
|
{
|
|
CDHtmlDialog::OnInitDialog();
|
|
|
|
// Add "About..." menu item to system menu.
|
|
|
|
// IDM_ABOUTBOX must be in the system command range.
|
|
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
|
|
ASSERT(IDM_ABOUTBOX < 0xF000);
|
|
|
|
CMenu* pSysMenu = GetSystemMenu(FALSE);
|
|
if (pSysMenu != NULL)
|
|
{
|
|
BOOL bNameValid;
|
|
CString strAboutMenu;
|
|
bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
|
|
ASSERT(bNameValid);
|
|
if (!strAboutMenu.IsEmpty())
|
|
{
|
|
pSysMenu->AppendMenu(MF_SEPARATOR);
|
|
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
|
|
}
|
|
}
|
|
|
|
// Set the icon for this dialog. The framework does this automatically
|
|
// when the application's main window is not a dialog
|
|
SetIcon(m_hIcon, TRUE); // Set big icon
|
|
SetIcon(m_hIcon, FALSE); // Set small icon
|
|
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
}
|
|
|
|
void CSiaDriveDlg::OnSysCommand(UINT nID, LPARAM lParam)
|
|
{
|
|
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
|
|
{
|
|
CAboutDlg dlgAbout;
|
|
dlgAbout.DoModal();
|
|
}
|
|
else
|
|
{
|
|
CDHtmlDialog::OnSysCommand(nID, lParam);
|
|
}
|
|
}
|
|
|
|
// If you add a minimize button to your dialog, you will need the code below
|
|
// to draw the icon. For MFC applications using the document/view model,
|
|
// this is automatically done for you by the framework.
|
|
|
|
void CSiaDriveDlg::OnPaint()
|
|
{
|
|
if (IsIconic())
|
|
{
|
|
CPaintDC dc(this); // device context for painting
|
|
|
|
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
|
|
|
|
// Center icon in client rectangle
|
|
int cxIcon = GetSystemMetrics(SM_CXICON);
|
|
int cyIcon = GetSystemMetrics(SM_CYICON);
|
|
CRect rect;
|
|
GetClientRect(&rect);
|
|
int x = (rect.Width() - cxIcon + 1) / 2;
|
|
int y = (rect.Height() - cyIcon + 1) / 2;
|
|
|
|
// Draw the icon
|
|
dc.DrawIcon(x, y, m_hIcon);
|
|
}
|
|
else
|
|
{
|
|
CDHtmlDialog::OnPaint();
|
|
}
|
|
}
|
|
|
|
BOOL CSiaDriveDlg::CallClientScript(LPCTSTR pStrFuncName, const String& data, CComVariant* pOutVarRes)
|
|
{
|
|
BOOL bRes = FALSE;
|
|
CComVariant vaResult;
|
|
CComPtr<IHTMLDocument2> pIDoc2;
|
|
if (SUCCEEDED(this->GetDHtmlDocument(&pIDoc2))) //Uses CDHtmlDialog as 'this'
|
|
{
|
|
//Getting IDispatch for Java Script objects
|
|
CComPtr<IDispatch> spScript;
|
|
if (SUCCEEDED(pIDoc2->get_Script(&spScript)))
|
|
{
|
|
//Find dispid for given function in the object
|
|
CComBSTR bstrMember(pStrFuncName);
|
|
DISPID dispid = NULL;
|
|
if (SUCCEEDED(spScript->GetIDsOfNames(IID_NULL, &bstrMember, 1, LOCALE_USER_DEFAULT, &dispid)))
|
|
{
|
|
VARIANT v[1];
|
|
v[0] = CComVariant(data.c_str());
|
|
|
|
//Putting parameters
|
|
DISPPARAMS dispparams;
|
|
memset(&dispparams, 0, sizeof dispparams);
|
|
dispparams.cArgs = 1;
|
|
dispparams.rgvarg = v;
|
|
dispparams.cNamedArgs = 0;
|
|
|
|
EXCEPINFO excepInfo;
|
|
memset(&excepInfo, 0, sizeof excepInfo);
|
|
UINT nArgErr = (UINT)-1; // initialize to invalid arg
|
|
|
|
//Call JavaScript function
|
|
if (SUCCEEDED(spScript->Invoke(dispid, IID_NULL, 0, DISPATCH_METHOD, &dispparams, &vaResult, &excepInfo, &nArgErr)))
|
|
{
|
|
//Done!
|
|
bRes = TRUE;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (pOutVarRes)
|
|
*pOutVarRes = vaResult;
|
|
|
|
return bRes;
|
|
}
|
|
|
|
BOOL CSiaDriveDlg::CallClientScript(LPCTSTR pStrFuncName, const json& json, CComVariant* pOutVarRes)
|
|
{
|
|
String data = CA2W(json.dump().c_str());
|
|
return CallClientScript(pStrFuncName, data, pOutVarRes);
|
|
}
|
|
|
|
BOOL CSiaDriveDlg::CallClientScript(LPCTSTR pStrFuncName, CComVariant* pOutVarRes)
|
|
{
|
|
|
|
BOOL bRes = FALSE;
|
|
CComVariant vaResult;
|
|
CComPtr<IHTMLDocument2> pIDoc2;
|
|
if (SUCCEEDED(this->GetDHtmlDocument(&pIDoc2))) //Uses CDHtmlDialog as 'this'
|
|
{
|
|
//Getting IDispatch for Java Script objects
|
|
CComPtr<IDispatch> spScript;
|
|
if (SUCCEEDED(pIDoc2->get_Script(&spScript)))
|
|
{
|
|
//Find dispid for given function in the object
|
|
CComBSTR bstrMember(pStrFuncName);
|
|
DISPID dispid = NULL;
|
|
if (SUCCEEDED(spScript->GetIDsOfNames(IID_NULL, &bstrMember, 1, LOCALE_USER_DEFAULT, &dispid)))
|
|
{
|
|
EXCEPINFO excepInfo;
|
|
memset(&excepInfo, 0, sizeof excepInfo);
|
|
DISPPARAMS dispparams;
|
|
memset(&dispparams, 0, sizeof dispparams);
|
|
dispparams.cArgs = 0;
|
|
dispparams.cNamedArgs = 0;
|
|
|
|
UINT nArgErr = static_cast<UINT>(-1); // initialize to invalid arg
|
|
//Call JavaScript function
|
|
if (SUCCEEDED(spScript->Invoke(dispid, IID_NULL, 0, DISPATCH_METHOD, &dispparams, &vaResult, &excepInfo, &nArgErr)))
|
|
{
|
|
//Done!
|
|
bRes = TRUE;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (pOutVarRes)
|
|
*pOutVarRes = vaResult;
|
|
|
|
return bRes;
|
|
}
|
|
|
|
// The system calls this function to obtain the cursor to display while the user drags
|
|
// the minimized window.
|
|
HCURSOR CSiaDriveDlg::OnQueryDragIcon()
|
|
{
|
|
return static_cast<HCURSOR>(m_hIcon);
|
|
}
|
|
|
|
HRESULT CSiaDriveDlg::OnButtonOK(IHTMLElement* /*pElement*/)
|
|
{
|
|
OnOK();
|
|
return S_OK;
|
|
}
|
|
|
|
HRESULT CSiaDriveDlg::OnButtonCancel(IHTMLElement* /*pElement*/)
|
|
{
|
|
OnCancel();
|
|
return S_OK;
|
|
}
|
|
|
|
HRESULT CSiaDriveDlg::OnButtonConfirmSeed(IHTMLElement* /*pElement*/)
|
|
{
|
|
_seedCreation = false;
|
|
_walletCreatedSeed = L"";
|
|
UpdateData(FALSE);
|
|
this->Navigate(this->m_strCurrentUrl);
|
|
|
|
return S_OK;
|
|
}
|
|
|
|
HRESULT CSiaDriveDlg::OnButtonUnlockWallet(IHTMLElement* /*pElement*/)
|
|
{
|
|
if (API_SUCCESS(SiaApiError, _siaApi.GetWallet()->Unlock(GetWalletUnlockPassword())))
|
|
{
|
|
SetWalletUnlockPassword(L"");
|
|
this->Navigate(this->m_strCurrentUrl);
|
|
}
|
|
else
|
|
{
|
|
SetWalletUnlockPassword(L"");
|
|
AfxMessageBox(L"Invalid password entered");
|
|
SetFocusToElement(L"ID_WalletUnlockPwd");
|
|
}
|
|
|
|
return S_OK;
|
|
}
|
|
|
|
HRESULT CSiaDriveDlg::OnButtonMount(IHTMLElement* /*pElement*/)
|
|
{
|
|
return S_OK;
|
|
}
|
|
|
|
bool IsRefreshKeyMessage(const MSG *message)
|
|
{
|
|
return message
|
|
&& ((message->message == WM_KEYDOWN) || (message->message == WM_KEYUP))
|
|
&& (message->wParam == VK_F5);
|
|
}
|
|
|
|
BOOL CSiaDriveDlg::PreTranslateMessage(MSG* pMsg)
|
|
{
|
|
//TODO: Implement copy/paste context menu
|
|
if (IsRefreshKeyMessage(pMsg) || (pMsg->message == WM_RBUTTONDOWN) || (pMsg->message == WM_RBUTTONDBLCLK))
|
|
{
|
|
return TRUE;
|
|
}
|
|
|
|
return CDHtmlDialog::PreTranslateMessage(pMsg);
|
|
}
|
|
|
|
void CSiaDriveDlg::SetClientVersion(const String& version)
|
|
{
|
|
CallClientScript(L"setClientVersion", version, nullptr);
|
|
}
|
|
|
|
void CSiaDriveDlg::SetServerVersion(const String& version)
|
|
{
|
|
CallClientScript(L"setServerVersion", version, nullptr);
|
|
}
|
|
|
|
void CSiaDriveDlg::SetWalletConfirmedBalance(const String& balance)
|
|
{
|
|
CallClientScript(L"setWalletConfirmedBalance", balance, nullptr);
|
|
}
|
|
|
|
void CSiaDriveDlg::SetWalletUnconfirmedBalance(const String& balance)
|
|
{
|
|
CallClientScript(L"setWalletUnconfirmedBalance", balance, nullptr);
|
|
}
|
|
|
|
void CSiaDriveDlg::SetWalletTotalBalance(const String& balance)
|
|
{
|
|
CallClientScript(L"setWalletTotalBalance", balance, nullptr);
|
|
}
|
|
|
|
void CSiaDriveDlg::SetWalletReceiveAddress(const String& address)
|
|
{
|
|
CallClientScript(L"setWalletReceiveAddress", address, nullptr);
|
|
}
|
|
|
|
String CSiaDriveDlg::GetWalletReceiveAddress()
|
|
{
|
|
CComVariant result;
|
|
CallClientScript(L"getWalletReceiveAddress", &result);
|
|
|
|
return result.bstrVal ? result.bstrVal : L"";
|
|
}
|
|
|
|
void CSiaDriveDlg::SetWalletUnlockPassword(const String& password)
|
|
{
|
|
CallClientScript(L"setWalletUnlockPassword", password, nullptr);
|
|
}
|
|
|
|
String CSiaDriveDlg::GetWalletUnlockPassword()
|
|
{
|
|
CComVariant result;
|
|
CallClientScript(L"getWalletUnlockPassword", &result);
|
|
|
|
return result.bstrVal ? result.bstrVal : L"";
|
|
}
|
|
|
|
void CSiaDriveDlg::OnDocumentComplete(LPDISPATCH, LPCTSTR)
|
|
{
|
|
KillTimer(IDT_UPDATE);
|
|
|
|
SetServerVersion(L"x.x.x.");
|
|
SetClientVersion(L"1.0.0");
|
|
SetWalletConfirmedBalance(L"");
|
|
SetWalletUnconfirmedBalance(L"");
|
|
SetWalletTotalBalance(L"");
|
|
SetWalletReceiveAddress(L"");
|
|
|
|
SetTimer(IDT_UPDATE, 2000, nullptr);
|
|
|
|
if ((_connected = UpdateUi(false)))
|
|
{
|
|
ConfigureWallet();
|
|
}
|
|
}
|
|
|
|
void CSiaDriveDlg::OnTimer(UINT_PTR nIDEvent)
|
|
{
|
|
switch (nIDEvent)
|
|
{
|
|
case IDT_UPDATE:
|
|
{
|
|
UpdateUi();
|
|
}
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
bool CSiaDriveDlg::UpdateSiaInfo()
|
|
{
|
|
const String serverVersion = _siaApi.GetServerVersion();
|
|
if (serverVersion.length())
|
|
{
|
|
if (_siaApi.GetWallet()->Refresh())
|
|
{
|
|
SiaCurrency confirmed;
|
|
if (API_SUCCESS(SiaApiError, _siaApi.GetWallet()->GetConfirmedBalance(confirmed)))
|
|
{
|
|
SiaCurrency unconfirmed;
|
|
if (API_SUCCESS(SiaApiError, _siaApi.GetWallet()->GetUnonfirmedBalance(unconfirmed)))
|
|
{
|
|
SiaCurrency total = confirmed + unconfirmed;
|
|
|
|
SetServerVersion(serverVersion);
|
|
SetWalletConfirmedBalance(SiaCurrencyToString(confirmed));
|
|
SetWalletUnconfirmedBalance(SiaCurrencyToString(unconfirmed));
|
|
SetWalletTotalBalance(SiaCurrencyToString(total));
|
|
|
|
if (GetWalletReceiveAddress().empty())
|
|
{
|
|
String address;
|
|
_siaApi.GetWallet()->GetAddress(address);
|
|
SetWalletReceiveAddress(address);
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
SetServerVersion(L"x.x.x");
|
|
SetWalletConfirmedBalance(L"");
|
|
SetWalletUnconfirmedBalance(L"");
|
|
SetWalletTotalBalance(L"");
|
|
SetWalletReceiveAddress(L"");
|
|
|
|
return false;
|
|
}
|
|
|
|
bool CSiaDriveDlg::UpdateUi(const bool& refresh)
|
|
{
|
|
bool ret = UpdateSiaInfo();
|
|
if (ret)
|
|
{
|
|
if (!_connected && !_seedCreation)
|
|
{
|
|
KillTimer(IDT_UPDATE);
|
|
this->Navigate(this->m_strCurrentUrl);
|
|
}
|
|
}
|
|
else if (refresh && !_seedCreation)
|
|
{
|
|
_connected = false;
|
|
KillTimer(IDT_UPDATE);
|
|
this->Navigate(this->m_strCurrentUrl);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
HRESULT CSiaDriveDlg::GetDomNodeById(const String& id, CComPtr<IHTMLDOMNode>& node)
|
|
{
|
|
CComPtr<IHTMLElement> elem;
|
|
return GetDomNodeAndElementById(id, node, elem);
|
|
}
|
|
|
|
HRESULT CSiaDriveDlg::GetDomNodeAndElementById(const String& id, CComPtr<IHTMLDOMNode>& node, CComPtr<IHTMLElement>& elem)
|
|
{
|
|
HRESULT hr;
|
|
if (SUCCEEDED((hr = GetElement(id.c_str(), &elem))))
|
|
{
|
|
hr = elem->QueryInterface(IID_IHTMLDOMNode, reinterpret_cast<void**>(&node));
|
|
}
|
|
|
|
return hr;
|
|
}
|
|
|
|
void CSiaDriveDlg::RemoveDomNodeById(const String& id)
|
|
{
|
|
CComPtr<IHTMLDOMNode> element;
|
|
if (SUCCEEDED(GetDomNodeById(id.c_str(), element)))
|
|
{
|
|
CComPtr<IHTMLDOMNode> parent;
|
|
if (SUCCEEDED(element->get_parentNode(&parent)))
|
|
{
|
|
CComPtr<IHTMLDOMNode> removed;
|
|
parent->removeChild(element, &removed);
|
|
}
|
|
}
|
|
}
|
|
|
|
void CSiaDriveDlg::RemoveCreateWalletItems()
|
|
{
|
|
RemoveDomNodeById(L"create_wallet");
|
|
RemoveDomNodeById(L"disp_wallet_seed");
|
|
}
|
|
|
|
void CSiaDriveDlg::DisplayCreateWallet()
|
|
{
|
|
SetMainWindow(L"create_wallet");
|
|
}
|
|
|
|
void CSiaDriveDlg::ConfigureWallet()
|
|
{
|
|
if (_siaApi.GetWallet()->GetCreated())
|
|
{
|
|
RemoveCreateWalletItems();
|
|
if (_siaApi.GetWallet()->GetLocked())
|
|
{
|
|
DisplayUnlockWallet();
|
|
}
|
|
else
|
|
{
|
|
CallClientScript(L"setAvailableDrives", json(GetAvailableDrives()), nullptr);
|
|
SetMainWindow(L"tab_view");
|
|
|
|
switch (_siaConfig.GetUI_Main_TabIndex())
|
|
{
|
|
case WALLET_TAB:
|
|
{
|
|
//DisplayWalletTab();
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
DisplayCreateWallet();
|
|
}
|
|
}
|
|
|
|
void CSiaDriveDlg::DisplaySeedCreated(const String& seed)
|
|
{
|
|
SetMainWindow(L"disp_wallet_seed");
|
|
_walletCreatedSeed = seed.c_str();
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
void CSiaDriveDlg::DisplayUnlockWallet()
|
|
{
|
|
KillTimer(IDT_UPDATE);
|
|
SetMainWindow(L"unlock_wallet");
|
|
SetFocusToElement(L"ID_WalletUnlockPwd");
|
|
}
|
|
|
|
void CSiaDriveDlg::SetMainWindow(const String& name)
|
|
{
|
|
CComPtr<IHTMLDOMNode> mainNode;
|
|
if (SUCCEEDED(GetDomNodeById(L"main_window", mainNode)))
|
|
{
|
|
CComPtr<IHTMLDOMNode> child;
|
|
if (SUCCEEDED(mainNode->get_firstChild(&child)))
|
|
{
|
|
CComPtr<IHTMLDOMNode> removed;
|
|
if (SUCCEEDED(mainNode->removeChild(child, &removed)))
|
|
{
|
|
CComPtr<IHTMLDOMNode> body;
|
|
if (SUCCEEDED(GetDomNodeById(L"CSiaDriveDlg", body)))
|
|
{
|
|
CComPtr<IHTMLElement> element;
|
|
if (SUCCEEDED(removed->QueryInterface(IID_IHTMLElement, reinterpret_cast<void**>(&element))))
|
|
{
|
|
CComPtr<IHTMLStyle> style;
|
|
if (SUCCEEDED(element->get_style(&style)))
|
|
{
|
|
style->put_display(L"none");
|
|
}
|
|
|
|
CComPtr<IHTMLDOMNode> added;
|
|
body->appendChild(removed, &added);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
CComPtr<IHTMLDOMNode> divNode;
|
|
CComPtr<IHTMLElement> divElement;
|
|
if (SUCCEEDED(GetDomNodeAndElementById(name, divNode, divElement)))
|
|
{
|
|
CComPtr<IHTMLDOMNode> parent;
|
|
if (SUCCEEDED(divNode->get_parentNode(&parent)))
|
|
{
|
|
CComPtr<IHTMLDOMNode> removedNode;
|
|
if (SUCCEEDED(parent->removeChild(divNode, &removedNode)))
|
|
{
|
|
CComPtr<IHTMLDOMNode> appendedNode;
|
|
if (SUCCEEDED(mainNode->appendChild(removedNode, &appendedNode)))
|
|
{
|
|
CComPtr<IHTMLStyle> style;
|
|
if (SUCCEEDED(divElement->get_style(&style)))
|
|
{
|
|
style->put_display(L"block");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
HRESULT CSiaDriveDlg::OnButtonCreateWallet(IHTMLElement* pElement)
|
|
{
|
|
if (!_seedCreation)
|
|
{
|
|
_seedCreation = true;
|
|
KillTimer(IDT_UPDATE);
|
|
|
|
String seed;
|
|
if (API_SUCCESS(SiaApiError, _siaApi.GetWallet()->Create(SiaSeedLanguage::English, seed)))
|
|
{
|
|
DisplaySeedCreated(seed);
|
|
}
|
|
}
|
|
|
|
return S_OK;
|
|
} |