Mo stuff
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -253,3 +253,4 @@ ModelManifest.xml
|
|||||||
3rd_party/CEF/depot_tools
|
3rd_party/CEF/depot_tools
|
||||||
3rd_party/CEF/depot_tools
|
3rd_party/CEF/depot_tools
|
||||||
/3rd_party/CEF/depot_tools.zip
|
/3rd_party/CEF/depot_tools.zip
|
||||||
|
/dist
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
set ROOT=%~dp0%
|
set ROOT=%~dp0%
|
||||||
pushd "%ROOT%"
|
pushd "%ROOT%"
|
||||||
|
|
||||||
call 3rd_party\CEF\create.cmd Debug
|
REM call 3rd_party\CEF\create.cmd Debug
|
||||||
|
|
||||||
mkdir build
|
mkdir build
|
||||||
mkdir build\debug
|
mkdir build\debug
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
set ROOT=%~dp0%
|
set ROOT=%~dp0%
|
||||||
pushd "%ROOT%"
|
pushd "%ROOT%"
|
||||||
|
|
||||||
call 3rd_party\CEF\create.cmd Release
|
REM call 3rd_party\CEF\create.cmd Release
|
||||||
|
|
||||||
mkdir build
|
mkdir build
|
||||||
mkdir build\release
|
mkdir build\release
|
||||||
|
@@ -5,6 +5,17 @@
|
|||||||
document.getElementById(id).innerText = balance;
|
document.getElementById(id).innerText = balance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setSelect(id, itemList) {
|
||||||
|
const select = document.getElementById(id);
|
||||||
|
select.innerHTML = "";
|
||||||
|
|
||||||
|
for (const item of itemList) {
|
||||||
|
const opt = document.createElement('option');
|
||||||
|
opt.innerText = item;
|
||||||
|
select.appendChild(opt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const _renter = (()=> {
|
const _renter = (()=> {
|
||||||
return {
|
return {
|
||||||
setAllocatedFunds: (currency)=> {
|
setAllocatedFunds: (currency)=> {
|
||||||
@@ -65,6 +76,9 @@
|
|||||||
},
|
},
|
||||||
setServerVersion: (version) => {
|
setServerVersion: (version) => {
|
||||||
setInnerText('ID_ServerVersion', version);
|
setInnerText('ID_ServerVersion', version);
|
||||||
|
},
|
||||||
|
setAvailableDriveLetters: (drives)=> {
|
||||||
|
setSelect('ID_MountDrives', drives);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
@@ -48,6 +48,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
static void ExecuteSetter(CefRefPtr<CefV8Context> context, CefRefPtr<CefV8Value> obj, const SString& method, const SString& value);
|
static void ExecuteSetter(CefRefPtr<CefV8Context> context, CefRefPtr<CefV8Value> obj, const SString& method, const SString& value);
|
||||||
|
static void ExecuteSetter(CefRefPtr<CefV8Context> context, CefRefPtr<CefV8Value> obj, const SString& method, CefRefPtr<CefV8Value> value);
|
||||||
void SiaApiRefreshCallback(CefRefPtr<CefV8Context> context, const Api::CSiaCurl& siaCurl, Api::CSiaDriveConfig* siaDriveConfig);
|
void SiaApiRefreshCallback(CefRefPtr<CefV8Context> context, const Api::CSiaCurl& siaCurl, Api::CSiaDriveConfig* siaDriveConfig);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -183,6 +183,10 @@ SString SIADRIVE_EXPORTABLE GenerateSha256(const SString& str);
|
|||||||
|
|
||||||
BOOL SIADRIVE_EXPORTABLE RecurDeleteFilesByExtentsion(const SString& folder, const SString& extensionWithDot);
|
BOOL SIADRIVE_EXPORTABLE RecurDeleteFilesByExtentsion(const SString& folder, const SString& extensionWithDot);
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
std::vector<SString> SIADRIVE_EXPORTABLE GetAvailableDrives();
|
||||||
|
#endif
|
||||||
|
|
||||||
#define RetryableAction(exec, count, delayMs) RetryAction([&]()->BOOL{return exec;}, count, delayMs)
|
#define RetryableAction(exec, count, delayMs) RetryAction([&]()->BOOL{return exec;}, count, delayMs)
|
||||||
#define DEFAULT_RETRY_COUNT 10
|
#define DEFAULT_RETRY_COUNT 10
|
||||||
#define DEFAULT_RETRY_DELAY_MS 1000
|
#define DEFAULT_RETRY_DELAY_MS 1000
|
||||||
|
@@ -162,6 +162,14 @@ void CSiaDriveApp::ExecuteSetter(CefRefPtr<CefV8Context> context, CefRefPtr<CefV
|
|||||||
setConfirmed->ExecuteFunctionWithContext(context, nullptr, args);
|
setConfirmed->ExecuteFunctionWithContext(context, nullptr, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSiaDriveApp::ExecuteSetter(CefRefPtr<CefV8Context> context, CefRefPtr<CefV8Value> obj, const SString& method, CefRefPtr<CefV8Value> value)
|
||||||
|
{
|
||||||
|
CefRefPtr<CefV8Value> setConfirmed = obj->GetValue(method.str());
|
||||||
|
CefV8ValueList args;
|
||||||
|
args.push_back(value);
|
||||||
|
setConfirmed->ExecuteFunctionWithContext(context, nullptr, args);
|
||||||
|
}
|
||||||
|
|
||||||
void CSiaDriveApp::OnContextCreated(
|
void CSiaDriveApp::OnContextCreated(
|
||||||
CefRefPtr<CefBrowser> browser,
|
CefRefPtr<CefBrowser> browser,
|
||||||
CefRefPtr<CefFrame> frame,
|
CefRefPtr<CefFrame> frame,
|
||||||
@@ -184,7 +192,7 @@ void CSiaDriveApp::OnContextCreated(
|
|||||||
obj->SetValue("startApp", CefV8Value::CreateFunction("startApp", handler), V8_PROPERTY_ATTRIBUTE_NONE);
|
obj->SetValue("startApp", CefV8Value::CreateFunction("startApp", handler), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
obj->SetValue("stopApp", CefV8Value::CreateFunction("stopApp", handler), V8_PROPERTY_ATTRIBUTE_NONE);
|
obj->SetValue("stopApp", CefV8Value::CreateFunction("stopApp", handler), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
global->SetValue("appActions", obj, V8_PROPERTY_ATTRIBUTE_NONE);
|
global->SetValue("appActions", obj, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||||
|
|
||||||
_refreshThread.reset(new CAutoThread(*_siaCurl, _siaDriveConfig.get(), [this, context](const CSiaCurl& siaCurl, CSiaDriveConfig* siaDriveConfig)
|
_refreshThread.reset(new CAutoThread(*_siaCurl, _siaDriveConfig.get(), [this, context](const CSiaCurl& siaCurl, CSiaDriveConfig* siaDriveConfig)
|
||||||
{
|
{
|
||||||
this->SiaApiRefreshCallback(context, siaCurl, siaDriveConfig);
|
this->SiaApiRefreshCallback(context, siaCurl, siaDriveConfig);
|
||||||
@@ -287,16 +295,6 @@ void CSiaDriveApp::SiaApiRefreshCallback(CefRefPtr<CefV8Context> context, const
|
|||||||
ExecuteSetter(context, walletActions, "setReceiveAddress", _walletReceiveAddress);
|
ExecuteSetter(context, walletActions, "setReceiveAddress", _walletReceiveAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display renter data
|
|
||||||
/*
|
|
||||||
|
|
||||||
SiaCurrency t = _siaApi->GetRenter()->GetTotalUsedBytes() ? _siaApi->GetRenter()->GetTotalUsedBytes() / (1024.0 * 1024.0 * 1024.0) : 0.0;
|
|
||||||
auto a = (t / (allocatedFunds - unspentFunds)) * allocatedFunds;
|
|
||||||
SetRenterTotalUsed(_siaApi->GetRenter()->GetTotalUsedBytes());
|
|
||||||
SetRenterTotalAvailable(a.ToDouble());
|
|
||||||
SetRenterTotalRemain((a-t).ToDouble());
|
|
||||||
SetRenterTotalUploadProgress(_siaApi->GetRenter()->GetTotalUploadProgress());
|
|
||||||
*/
|
|
||||||
// Funding
|
// Funding
|
||||||
SiaCurrency allocatedFunds = _siaApi->GetRenter()->GetFunds();
|
SiaCurrency allocatedFunds = _siaApi->GetRenter()->GetFunds();
|
||||||
SiaCurrency unspentFunds = _siaApi->GetRenter()->GetUnspent();
|
SiaCurrency unspentFunds = _siaApi->GetRenter()->GetUnspent();
|
||||||
@@ -313,8 +311,21 @@ void CSiaDriveApp::SiaApiRefreshCallback(CefRefPtr<CefV8Context> context, const
|
|||||||
ExecuteSetter(context, renterActions, "setAvailableSpace", SiaCurrencyToGB(totalRemainGb));
|
ExecuteSetter(context, renterActions, "setAvailableSpace", SiaCurrencyToGB(totalRemainGb));
|
||||||
ExecuteSetter(context, renterActions, "setUsedSpace", SiaCurrencyToGB(totalUsedGb));
|
ExecuteSetter(context, renterActions, "setUsedSpace", SiaCurrencyToGB(totalUsedGb));
|
||||||
|
|
||||||
// Progress
|
// Upload Progress
|
||||||
|
/*
|
||||||
|
SetRenterTotalUploadProgress(_siaApi->GetRenter()->GetTotalUploadProgress());
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Mount
|
||||||
|
auto uiUpdate = global->GetValue("uiUpdate");
|
||||||
|
auto drives = GetAvailableDrives();
|
||||||
|
auto driveList = CefV8Value::CreateArray(drives.size());
|
||||||
|
for (size_t i = 0; i < drives.size(); i++)
|
||||||
|
{
|
||||||
|
driveList->SetValue(i, CefV8Value::CreateString(drives[i].str()));
|
||||||
|
}
|
||||||
|
ExecuteSetter(context, uiUpdate, "setAvailableDriveLetters", driveList);
|
||||||
|
|
||||||
// Display block height
|
// Display block height
|
||||||
ExecuteSetter(context, uiActions, "setBlockHeight", SString::FromUInt64(_siaApi->GetConsensus()->GetHeight()));
|
ExecuteSetter(context, uiActions, "setBlockHeight", SString::FromUInt64(_siaApi->GetConsensus()->GetHeight()));
|
||||||
}
|
}
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
#include <ttmath/ttmath.h>
|
#include <ttmath/ttmath.h>
|
||||||
#include <SQLiteCpp/Exception.h>
|
#include <SQLiteCpp/Exception.h>
|
||||||
#include <sqlite3.h>
|
#include <sqlite3.h>
|
||||||
|
#include <bitset>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <Wincrypt.h>
|
#include <Wincrypt.h>
|
||||||
@@ -66,7 +67,7 @@ SString GenerateSha256(const SString& str)
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
#else
|
#else
|
||||||
|
a
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,7 +114,7 @@ BOOL RecurDeleteFilesByExtentsion(const SString& folder, const SString& extensio
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
#else
|
#else
|
||||||
|
a
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,7 +129,7 @@ BOOL RetryDeleteFileIfExists(const SString& filePath)
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
#else
|
#else
|
||||||
|
a
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,8 +144,27 @@ BOOL RetryAction(std::function<BOOL()> func, std::uint16_t retryCount, const DWO
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
#else
|
#else
|
||||||
|
a
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
std::vector<SString> 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::vector<SString> avail;
|
||||||
|
for (size_t i = 0; i < alpha.size(); i++)
|
||||||
|
{
|
||||||
|
if (drives[i] && (alpha[i] != 'A') && (alpha[i] != 'B'))
|
||||||
|
{
|
||||||
|
avail.push_back(alpha[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::move(avail);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
NS_END(2)
|
NS_END(2)
|
Reference in New Issue
Block a user