diff --git a/3rd_party/CEF/create.cmd b/3rd_party/CEF/create.cmd index 5c7a53f..b17351c 100644 --- a/3rd_party/CEF/create.cmd +++ b/3rd_party/CEF/create.cmd @@ -7,7 +7,7 @@ set PATH=%ROOT%depot_tools;%PATH% call create_common.cmd set CEF_USE_GN=1 -if ("%MODE%" EQ "Debug") ( +if ("%MODE%"=="Debug") ( set GN_DEFINES=is_win_fastlink=true fatal_linker_warnings=false ) else ( set GN_DEFINES=fatal_linker_warnings=false diff --git a/3rd_party/CEF/depot_tools b/3rd_party/CEF/depot_tools index c07db62..7a1f04d 160000 --- a/3rd_party/CEF/depot_tools +++ b/3rd_party/CEF/depot_tools @@ -1 +1 @@ -Subproject commit c07db621521d62557d089b3e94484c1831395487 +Subproject commit 7a1f04d377764d9039cde0c4aa4b55c42a411c23 diff --git a/htdocs/css/general.css b/htdocs/css/general.css index 76b7678..22d115c 100644 --- a/htdocs/css/general.css +++ b/htdocs/css/general.css @@ -195,7 +195,7 @@ select { outline: 1px; background: rgba(64, 142, 62, 0.04); color: var(--default-font-color); - padding: 5px 35px 5px 5px; + padding: 5px 15px; height: 33px; font-size: var(--default-font-size); -webkit-appearance: none; diff --git a/htdocs/js/index.js b/htdocs/js/index.js index 8160707..de8ff3b 100644 --- a/htdocs/js/index.js +++ b/htdocs/js/index.js @@ -86,7 +86,7 @@ const UiState = (()=> { function _clientVersion() { - return window.uiState.clientVersion; + return 'v' + window.uiState.clientVersion; } function _isOnline() { diff --git a/include/siadrive_api/filepath.h b/include/siadrive_api/filepath.h index f2d7df5..a1dd58b 100644 --- a/include/siadrive_api/filepath.h +++ b/include/siadrive_api/filepath.h @@ -21,7 +21,7 @@ public: static const SString DirSep; public: - static FilePath FinalizePath(const SString& path); + static SString FinalizePath(const SString& path); private: SString _path; diff --git a/include/siadrive_api/siacommon.h b/include/siadrive_api/siacommon.h index 67e069e..f2c5c41 100644 --- a/include/siadrive_api/siacommon.h +++ b/include/siadrive_api/siacommon.h @@ -2,6 +2,7 @@ #define _SIACOMMON_H #define SIDRIVE_VERSION_STRING "0.0.1" +#define COMPAT_SIAD_VERSION "1.1.2" #ifdef _WIN32 // Unicode for Win32 @@ -76,6 +77,7 @@ public: }; #define DEFAULT_CONFIG_FILE_PATH L"./config/siadriveconfig.json" +#define DEFAULT_RENTER_DB_FILE_PATH L"./config/renter_upload.db3" #define Property(type, name, get_access, set_access) \ private:\ diff --git a/include/siadrive_api/siadriveconfig.h b/include/siadrive_api/siadriveconfig.h index 78005ae..84d7c46 100644 --- a/include/siadrive_api/siadriveconfig.h +++ b/include/siadrive_api/siadriveconfig.h @@ -15,10 +15,11 @@ public: ~CSiaDriveConfig(); Property(SString, FilePath, public, private) - JProperty(std::uint8_t, UI_Main_TabIndex, public, private, _configDocument) JProperty(std::string, Renter_UploadDbFilePath, public, private, _configDocument) JProperty(std::string, TempFolder, public, private, _configDocument) JProperty(std::string, CacheFolder, public, public, _configDocument) + JProperty(std::uint16_t, HostPort, public, public, _configDocument) + JProperty(std::string, HostNameOrIp, public, public, _configDocument) private: json _configDocument; diff --git a/src/siadrive/siadriveapp.cpp b/src/siadrive/siadriveapp.cpp index bff8b30..5101c7a 100644 --- a/src/siadrive/siadriveapp.cpp +++ b/src/siadrive/siadriveapp.cpp @@ -8,8 +8,8 @@ #include #include #include "siadrivehandler.h" -/* -exotic stylishly alchemy deodorant rally younger ouch sensible rated boss nestle wipeout viking blip pairing rural dwarf rebel mumble shelter pager yodel object titans tidy virtual orders peculiar after +/* Work Laptop +vitals thirsty tattoo unjustly already lexicon ruthless rated skater voyage avoid jeers aunt tawny richly glass menu kidneys went wounded wounded trendy towel lipstick raking bacon dozen blip aggravate */ using namespace Sia; using namespace Sia::Api; @@ -29,9 +29,8 @@ private: bool& _appStarted; private: - void UnlockCallback(CefRefPtr context, CefRefPtr cb, const SString& password) const + void UnlockCallback(SiaApiError error, CefRefPtr context, CefRefPtr cb, const SString& password) const { - SiaApiError error = _siaApi.GetWallet()->Unlock(password); CefV8ValueList args; args.push_back(CefV8Value::CreateBool(ApiSuccess(error))); if (!args[0]->GetBoolValue()) @@ -72,8 +71,13 @@ public: retval = CefV8Value::CreateBool(true); SString password = arguments[0]->GetStringValue().ToWString(); CefRefPtr cb = arguments[1]; - - CefPostTask(TID_RENDERER, base::Bind(&FunctionHandler::UnlockCallback, this, context, cb, password)); + + // Don't hang UI while unlocking + std::thread([this, context, password, cb]() + { + CefPostTask(TID_RENDERER, base::Bind(&FunctionHandler::UnlockCallback, this, _siaApi.GetWallet()->Unlock(password), context, cb, password)); + }).detach(); + return true; } else if (name == "createWallet") @@ -147,9 +151,9 @@ CSiaDriveApp::CSiaDriveApp() { _siaDriveConfig.reset(new CSiaDriveConfig()); SiaHostConfig hostConfig; - hostConfig.HostName = "127.0.0.1"; - hostConfig.HostPort = 9980; - hostConfig.RequiredVersion = "1.1.2"; + hostConfig.HostName = _siaDriveConfig->GetHostNameOrIp(); + hostConfig.HostPort = _siaDriveConfig->GetHostPort(); + hostConfig.RequiredVersion = COMPAT_SIAD_VERSION; _siaCurl.reset(new CSiaCurl(hostConfig)); _siaApi.reset(new CSiaApi(hostConfig, _siaDriveConfig.get())); } diff --git a/src/siadrive_api/filepath.cpp b/src/siadrive_api/filepath.cpp index e9a56c0..9153d95 100644 --- a/src/siadrive_api/filepath.cpp +++ b/src/siadrive_api/filepath.cpp @@ -3,10 +3,15 @@ using namespace Sia::Api; -FilePath FilePath::FinalizePath(const SString& path) +SString FilePath::FinalizePath(const SString& path) { +#ifdef _WIN32 std::wregex r(L"/+"); - return FilePath(std::regex_replace(path.str(), r, L"/")); + return std::regex_replace(path.str(), r, L"\\"); +#else + std::wregex r(L"\\+"); + return std::regex_replace(path.str(), r, L"/"); +#endif } FilePath::FilePath() diff --git a/src/siadrive_api/siadriveconfig.cpp b/src/siadrive_api/siadriveconfig.cpp index 6c804c3..29ac7ba 100644 --- a/src/siadrive_api/siadriveconfig.cpp +++ b/src/siadrive_api/siadriveconfig.cpp @@ -1,5 +1,6 @@ #include #include +#include #ifdef _WIN32 #include #endif @@ -29,13 +30,13 @@ CSiaDriveConfig::~CSiaDriveConfig() void CSiaDriveConfig::LoadDefaults() { + SetRenter_UploadDbFilePath(static_cast(FilePath(DEFAULT_RENTER_DB_FILE_PATH))); #ifdef _WIN32 - SetUI_Main_TabIndex(0); - SetRenter_UploadDbFilePath("./config/renter_upload.db3"); SString tempFolder; tempFolder.Resize(MAX_PATH + 1); ::GetTempPath(MAX_PATH, &tempFolder[0]); + tempFolder = tempFolder.str().c_str(); SetTempFolder(tempFolder); PWSTR localAppData = nullptr; @@ -45,20 +46,26 @@ void CSiaDriveConfig::LoadDefaults() sdFolder.Resize(MAX_PATH + 1); ::PathCombine(&sdFolder[0], localAppData, L"SiaDrive"); ::CreateDirectory(sdFolder.str().c_str(), nullptr); - + sdFolder = sdFolder.str().c_str(); + SString cacheFolder; cacheFolder.Resize(MAX_PATH + 1); ::PathCombine(&cacheFolder[0], &sdFolder[0], L"Cache"); ::CreateDirectory(cacheFolder.str().c_str(), nullptr); + cacheFolder = cacheFolder.str().c_str(); + SetCacheFolder(cacheFolder); #else - + a #endif + SetHostNameOrIp("localhost"); + SetHostPort(9980); } void CSiaDriveConfig::Load( ) { - std::ifstream myfile(GetFilePath().str().c_str()); + FilePath filePath = GetFilePath(); + std::ifstream myfile(static_cast(filePath).str().c_str()); if (myfile.is_open()) { std::stringstream ss; @@ -76,16 +83,13 @@ void CSiaDriveConfig::Load( ) void CSiaDriveConfig::Save() const { -#ifdef _WIN32 - SString folder = GetFilePath(); - ::PathRemoveFileSpec(&folder[0]); + FilePath filePath = GetFilePath(); + FilePath folder = filePath; + folder.RemoveFileName(); - if (!::PathIsDirectory(folder.str().c_str())) + if (!folder.IsDirectory()) { - ::CreateDirectory(folder.str().c_str(), nullptr); + folder.CreateDirectory(); } -#else - -#endif - std::ofstream(SString::ToUtf8(GetFilePath()).c_str()) << std::setw(2) << _configDocument << std::endl; + std::ofstream(SString::ToUtf8(static_cast(filePath)).c_str()) << std::setw(2) << _configDocument << std::endl; } \ No newline at end of file