1
0

Continue renter configuration

This commit is contained in:
Scott E. Graves
2017-03-29 23:42:32 -05:00
parent 688c56ad5c
commit ed80d032f7
6 changed files with 81 additions and 38 deletions

View File

@@ -188,7 +188,19 @@ public:
_shutdownCallback();
return true;
}
else if (name == "setRenterSettings")
{
CefRefPtr<CefV8Value> vAllowance = arguments[0];
CefRefPtr<CefV8Value> cb = arguments[1];
SiaRenterAllowance allowance({
SiaCurrency(vAllowance->GetValue("Funds")->GetStringValue().ToWString()),
SString::ToUInt32(vAllowance->GetValue("Hosts")->GetStringValue().ToWString()),
SString::ToUInt32(vAllowance->GetValue("Period")->GetStringValue().ToWString()),
SString::ToUInt32(vAllowance->GetValue("RenewWindowInBlocks")->GetStringValue().ToWString())
});
auto ret = _siaApi.GetRenter()->SetAllowance(allowance);
}
// Function does not exist.
return false;
}
@@ -275,6 +287,12 @@ void CSiaDriveApp::OnContextCreated(
obj->SetValue("isOnline", CefV8Value::CreateBool(_siaApi->GetWallet()->GetConnected()), V8_PROPERTY_ATTRIBUTE_NONE);
obj->SetValue("clientVersion", CefV8Value::CreateString(SIDRIVE_VERSION_STRING), V8_PROPERTY_ATTRIBUTE_NONE);
obj->SetValue("allocatedRenterFunds", CefV8Value::CreateString(_siaApi->GetRenter()->GetFunds().ToString()), V8_PROPERTY_ATTRIBUTE_NONE);
CefRefPtr<CefV8Value> defaultFunds = CefV8Value::CreateObject(nullptr, nullptr);
defaultFunds->SetValue("Funds", CefV8Value::CreateString(SIA_DEFAULT_MINIMUM_FUNDS.ToString()), V8_PROPERTY_ATTRIBUTE_NONE);
defaultFunds->SetValue("Hosts", CefV8Value::CreateString(SString::FromUInt32(SIA_DEFAULT_HOST_COUNT).str()), V8_PROPERTY_ATTRIBUTE_NONE);
defaultFunds->SetValue("Period", CefV8Value::CreateString(SString::FromUInt32(SIA_DEFAULT_CONTRACT_LENGTH).str()), V8_PROPERTY_ATTRIBUTE_NONE);
defaultFunds->SetValue("RenewWindowInBlocks", CefV8Value::CreateString(SString::FromUInt32(SIA_DEFAULT_RENEW_WINDOW).str()), V8_PROPERTY_ATTRIBUTE_NONE);
obj->SetValue("defaultRenterSettings", defaultFunds, V8_PROPERTY_ATTRIBUTE_NONE);
global->SetValue("uiState", obj, V8_PROPERTY_ATTRIBUTE_NONE);
CefRefPtr<FunctionHandler> handler(new FunctionHandler(*_siaApi, _appStarted, _siaDriveConfig, _siaDrive, [this]() {this->ShutdownServices(); }, [this](CefRefPtr<CefV8Context> context) {this->SiaApiRefreshCallback(context, *_siaCurl, _siaDriveConfig.get()); }));
@@ -286,6 +304,7 @@ void CSiaDriveApp::OnContextCreated(
obj->SetValue("mountDrive", CefV8Value::CreateFunction("mountDrive", handler), V8_PROPERTY_ATTRIBUTE_NONE);
obj->SetValue("unmountDrive", CefV8Value::CreateFunction("unmountDrive", handler), V8_PROPERTY_ATTRIBUTE_NONE);
obj->SetValue("shutdown", CefV8Value::CreateFunction("shutdown", handler), V8_PROPERTY_ATTRIBUTE_NONE);
obj->SetValue("setRenterSettings", CefV8Value::CreateFunction("setRenterSettings", handler), 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)

View File

@@ -84,7 +84,7 @@ void CSiaApi::_CSiaRenter::Refresh(const CSiaCurl& siaCurl, CSiaDriveConfig* sia
{
_currentAllowance.Funds = SIA_DEFAULT_MINIMUM_FUNDS;
_currentAllowance.Hosts = SIA_DEFAULT_HOST_COUNT;
_currentAllowance.Period = SIA_BLOCKS_PER_MONTH * 3;
_currentAllowance.Period = SIA_DEFAULT_CONTRACT_LENGTH;
_currentAllowance.RenewWindowInBlocks = SIA_DEFAULT_RENEW_WINDOW;
}
if (ApiSuccess(RefreshFileTree()))

View File

@@ -484,15 +484,18 @@ private:
{
if ((wcscmp(fileName, L"\\") != 0) || (wcscmp(findData.cFileName, L".") != 0) && (wcscmp(findData.cFileName, L"..") != 0))
{
if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
if (!(SString(fileName).EndsWith(".siadrive") || SString(fileName).EndsWith(".siadrive.temp")))
{
dirs.insert({findData.cFileName, 0});
if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
dirs.insert({ findData.cFileName, 0 });
}
else
{
files.insert({ findData.cFileName, 1 });
}
fillFindData(&findData, dokanFileInfo);
}
else
{
files.insert({ findData.cFileName, 1 });
}
fillFindData(&findData, dokanFileInfo);
}
} while (::FindNextFile(findHandle, &findData) != 0);
::FindClose(findHandle);