Auto-mount
This commit is contained in:
@@ -179,10 +179,11 @@
|
||||
<div class="hidden-element" id="sia_settings_window">
|
||||
<div class="box" id="sia_settings">
|
||||
<h1>General Settings</h1>
|
||||
<input type="checkbox" id="ID_Settings_LockWalletOnExit"> Lock wallet on exit<br><br>
|
||||
<input type="checkbox" id="ID_Settings_AutoMountOnUnlock"> Auto-mount last location<br><br>
|
||||
<input type="checkbox" id="ID_Settings_AutoStartOnLogon"> Auto-start on logon<br><br>
|
||||
<input type="checkbox" id="ID_Settings_LaunchFileMgrOnMount"> Launch file manager on mount<br><br>
|
||||
<input type="checkbox" id="ID_Settings_CloseToTray"> Close to system tray<br><br>
|
||||
<input type="checkbox" id="ID_Settings_LaunchFileMgrOnMount"> Launch file manager on mount<br><br>
|
||||
<input type="checkbox" id="ID_Settings_LockWalletOnExit"> Lock wallet on exit<br><br>
|
||||
<input type="checkbox" id="ID_Settings_StoreUnlockPassword"> Store unlock password<br><br>
|
||||
<input type="checkbox" id="ID_Settings_LaunchBundledSiad"> Use bundled siad<br><br>
|
||||
<h1>API Port</h1>
|
||||
|
@@ -345,7 +345,8 @@
|
||||
'RpcPort': getValue('ID_Settings_RpcPort'),
|
||||
'LaunchFileMgrOnMount': getChecked('ID_Settings_LaunchFileMgrOnMount'),
|
||||
'CloseToTray': getChecked('ID_Settings_CloseToTray'),
|
||||
'StoreUnlockPassword': getChecked('ID_Settings_StoreUnlockPassword')
|
||||
'StoreUnlockPassword': getChecked('ID_Settings_StoreUnlockPassword'),
|
||||
'AutoMountOnUnlock': getChecked('ID_Settings_AutoMountOnUnlock')
|
||||
}, (success, reason) => {
|
||||
if (success) {
|
||||
beginMainApplication();
|
||||
|
@@ -33,6 +33,8 @@ public:
|
||||
JProperty(bool, PromptOnClose, public, public, _configDocument)
|
||||
JProperty(bool, CloseToTray, public, public, _configDocument)
|
||||
JProperty(bool, StoreUnlockPassword, public, public, _configDocument)
|
||||
JProperty(bool, AutoMountOnUnlock, public, public, _configDocument)
|
||||
JProperty(std::string, LastMountLocation, public, public, _configDocument)
|
||||
|
||||
private:
|
||||
const bool _autoSave;
|
||||
|
@@ -65,7 +65,25 @@ private:
|
||||
{
|
||||
CefV8ValueList args;
|
||||
args.push_back(CefV8Value::CreateBool(ApiSuccess(error)));
|
||||
if (!args[0]->GetBoolValue())
|
||||
if (args[0]->GetBoolValue())
|
||||
{
|
||||
if (_siaDriveConfig->GetAutoMountOnUnlock())
|
||||
{
|
||||
const auto lastMountLocation = _siaDriveConfig->GetLastMountLocation();
|
||||
if (!lastMountLocation.empty())
|
||||
{
|
||||
// Change mount location
|
||||
// Disable mount location
|
||||
// Change mount button to 'Unmount'
|
||||
// Disable mount button
|
||||
std::thread([this, lastMountLocation, context, cb]()
|
||||
{
|
||||
_siaDrive->Mount(lastMountLocation[0], _siaDriveConfig->GetCacheFolder(), 0);
|
||||
}).detach();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
args.push_back(CefV8Value::CreateString("Failed to unlock wallet"));
|
||||
}
|
||||
@@ -246,6 +264,7 @@ public:
|
||||
_siaDriveConfig->SetRpcPort(SString::ToUInt32(settings->GetValue("RpcPort")->GetStringValue().ToWString()));
|
||||
_siaDriveConfig->SetCloseToTray(settings->GetValue("CloseToTray")->GetBoolValue());
|
||||
_siaDriveConfig->SetStoreUnlockPassword(settings->GetValue("StoreUnlockPassword")->GetBoolValue());
|
||||
_siaDriveConfig->SetAutoMountOnUnlock(settings->GetValue("AutoMountOnUnlock")->GetBoolValue());
|
||||
if (!_siaDriveConfig->GetStoreUnlockPassword())
|
||||
{
|
||||
SetRegistry("Unlock", "");
|
||||
@@ -481,7 +500,8 @@ void CSiaDriveApp::SiaApiRefreshCallback(CefRefPtr<CefV8Context> context, const
|
||||
{ "HostPort", _siaDriveConfig->GetHostPort() },
|
||||
{ "RpcPort", _siaDriveConfig->GetRpcPort() },
|
||||
{ "CloseToTray", _siaDriveConfig->GetCloseToTray() },
|
||||
{ "StoreUnlockPassword", _siaDriveConfig->GetStoreUnlockPassword() }
|
||||
{ "StoreUnlockPassword", _siaDriveConfig->GetStoreUnlockPassword() },
|
||||
{ "AutoMountOnUnlock", _siaDriveConfig->GetAutoMountOnUnlock() }
|
||||
};
|
||||
ExecuteSetter(context, uiActions, "setSiaSettings", CefV8Value::CreateString(settings.dump()));
|
||||
|
||||
@@ -589,7 +609,23 @@ void CSiaDriveApp::SiaApiRefreshCallback(CefRefPtr<CefV8Context> context, const
|
||||
if (isOnline)
|
||||
{
|
||||
auto uiActions = global->GetValue("uiUpdate");
|
||||
ExecuteSetter(context, uiActions, "setServerVersion", _siaApi->GetServerVersion());
|
||||
ExecuteSetter(context, uiActions, "setServerVersion", _siaApi->GetServerVersion());
|
||||
|
||||
if (_siaDriveConfig->GetAutoMountOnUnlock())
|
||||
{
|
||||
const auto lastMountLocation = _siaDriveConfig->GetLastMountLocation();
|
||||
if (!lastMountLocation.empty())
|
||||
{
|
||||
// Change mount location
|
||||
// Disable mount location
|
||||
// Change mount button to 'Unmount'
|
||||
// Disable mount button
|
||||
std::thread([this, lastMountLocation]()
|
||||
{
|
||||
_siaDrive->Mount(lastMountLocation[0], _siaDriveConfig->GetCacheFolder(), 0);
|
||||
}).detach();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isOnline && _siaDrive)
|
||||
|
@@ -190,6 +190,18 @@ bool CSiaDriveConfig::LoadDefaults()
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (!CheckAutoMountOnUnlock())
|
||||
{
|
||||
SetAutoMountOnUnlock(false);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (!CheckLastMountLocation())
|
||||
{
|
||||
SetLastMountLocation("");
|
||||
changed = true;
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
@@ -1937,6 +1937,7 @@ private:
|
||||
static NTSTATUS DOKAN_CALLBACK Sia_Mounted(PDOKAN_FILE_INFO dokanFileInfo)
|
||||
{
|
||||
CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DriveMounted(_mountPoint)));
|
||||
_siaDriveConfig->SetLastMountLocation(_mountPoint);
|
||||
if (_siaDriveConfig->GetLaunchFileMgrOnMount())
|
||||
{
|
||||
::ShellExecute(nullptr, L"open", &_mountPoint[0], nullptr, nullptr, SW_SHOWDEFAULT);
|
||||
@@ -2288,15 +2289,13 @@ private:
|
||||
|
||||
if (dokanFileInfo->DeleteOnClose)
|
||||
{
|
||||
// Should already be deleted by CloseHandle
|
||||
// if open with FILE_FLAG_DELETE_ON_CLOSE
|
||||
if (dokanFileInfo->IsDirectory)
|
||||
{
|
||||
while (!filePath.RemoveDirectory());
|
||||
filePath.RemoveDirectory();
|
||||
}
|
||||
else
|
||||
{
|
||||
while (!filePath.DeleteFile());
|
||||
filePath.DeleteFile();
|
||||
}
|
||||
|
||||
_siaApi->GetRenter()->RefreshFileTree();
|
||||
|
Reference in New Issue
Block a user