diff --git a/SiaDrive/SiaDrive.htm b/SiaDrive/SiaDrive.htm index 7045e33..2674904 100644 --- a/SiaDrive/SiaDrive.htm +++ b/SiaDrive/SiaDrive.htm @@ -1,7 +1,8 @@ + - +

Sia Information

@@ -36,7 +37,7 @@ -
+
diff --git a/SiaDrive/SiaDriveDlg.cpp b/SiaDrive/SiaDriveDlg.cpp index e29582b..f74b772 100644 --- a/SiaDrive/SiaDriveDlg.cpp +++ b/SiaDrive/SiaDriveDlg.cpp @@ -7,6 +7,7 @@ #include "SiaDriveDlg.h" #include "afxdialogex.h" #include +#include #ifdef _DEBUG #define new DEBUG_NEW @@ -18,8 +19,28 @@ wept saxophone dialect depth update jaunt loincloth asleep lush gnome laptop upp * 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 GetAvailableDrives() +{ + static const std::vector 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 drives(~GetLogicalDrives()); + + std::set 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 @@ -96,7 +117,7 @@ END_MESSAGE_MAP() BOOL CSiaDriveDlg::OnInitDialog() { CDHtmlDialog::OnInitDialog(); - + // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range. @@ -167,7 +188,7 @@ void CSiaDriveDlg::OnPaint() } } -BOOL CSiaDriveDlg::CallClientScript(LPCTSTR pStrFuncName, CStringArray* pArrFuncArgs, CComVariant* pOutVarRes) +BOOL CSiaDriveDlg::CallClientScript(LPCTSTR pStrFuncName, const json& json, CComVariant* pOutVarRes) { BOOL bRes = FALSE; CComVariant vaResult; @@ -183,24 +204,14 @@ BOOL CSiaDriveDlg::CallClientScript(LPCTSTR pStrFuncName, CStringArray* pArrFunc DISPID dispid = NULL; if (SUCCEEDED(spScript->GetIDsOfNames(IID_NULL, &bstrMember, 1, LOCALE_USER_DEFAULT, &dispid))) { - COleSafeArray ar; - ar.CreateOneDim(VT_VARIANT, pArrFuncArgs->GetSize()); - for (long i = 0; i < pArrFuncArgs->GetSize(); i++) - { - CComVariant v(pArrFuncArgs->GetAt(i)); - ar.PutElement(&i, &v); - } - - long l = 0; - COleSafeArray sa; - sa.CreateOneDim(VT_VARIANT, 1); - sa.PutElement(&l, ar); + VARIANT v[1]; + v[0] = CComVariant(CA2W(json.dump().c_str())); //Putting parameters DISPPARAMS dispparams; memset(&dispparams, 0, sizeof dispparams); dispparams.cArgs = 1; - dispparams.rgvarg = sa; + dispparams.rgvarg = v; dispparams.cNamedArgs = 0; EXCEPINFO excepInfo; @@ -275,11 +286,6 @@ HRESULT CSiaDriveDlg::OnButtonUnlockWallet(IHTMLElement* /*pElement*/) HRESULT CSiaDriveDlg::OnButtonMount(IHTMLElement* /*pElement*/) { - CStringArray driveList; - driveList.Add(L"S"); - driveList.Add(L"T"); - CallClientScript(L"setAvailableDrives", &driveList, nullptr); - return S_OK; } @@ -451,6 +457,7 @@ void CSiaDriveDlg::ConfigureWallet() } else { + CallClientScript(L"setAvailableDrives", json(GetAvailableDrives()), nullptr); SetMainWindow(L"tab_view"); switch (_siaConfig.GetUI_Main_TabIndex()) diff --git a/SiaDrive/SiaDriveDlg.h b/SiaDrive/SiaDriveDlg.h index 6f5cce3..9d5cb67 100644 --- a/SiaDrive/SiaDriveDlg.h +++ b/SiaDrive/SiaDriveDlg.h @@ -57,7 +57,7 @@ private: bool UpdateUi(const bool& refresh = true); HRESULT GetDomNodeAndElementById(const String& id, CComPtr& node, CComPtr& elem); HRESULT GetDomNodeById(const String& id, CComPtr& node); - BOOL CallClientScript(LPCTSTR pStrFuncName, CStringArray* pArrFuncArgs, CComVariant* pOutVarRes); + BOOL CallClientScript(LPCTSTR pStrFuncName, const json& json, CComVariant* pOutVarRes); private: CSiaDriveConfig _siaConfig; diff --git a/SiaDrive/res/code.js b/SiaDrive/res/code.js index d212550..d93783e 100644 --- a/SiaDrive/res/code.js +++ b/SiaDrive/res/code.js @@ -1,7 +1,8 @@ function setAvailableDrives(driveList) { - alert(driveList[0]); + driveList = JSON.parse(driveList); + var sel = document.getElementById("MountDrives"); sel.innerHTML = "";