1
0

UI stuffs

This commit is contained in:
Scott E. Graves
2017-03-22 10:59:07 -05:00
parent a6c6de75c3
commit 9efbae3fb9
10 changed files with 47 additions and 31 deletions

View File

@@ -7,7 +7,7 @@ set PATH=%ROOT%depot_tools;%PATH%
call create_common.cmd call create_common.cmd
set CEF_USE_GN=1 set CEF_USE_GN=1
if ("%MODE%" EQ "Debug") ( if ("%MODE%"=="Debug") (
set GN_DEFINES=is_win_fastlink=true fatal_linker_warnings=false set GN_DEFINES=is_win_fastlink=true fatal_linker_warnings=false
) else ( ) else (
set GN_DEFINES=fatal_linker_warnings=false set GN_DEFINES=fatal_linker_warnings=false

Submodule 3rd_party/CEF/depot_tools updated: c07db62152...7a1f04d377

View File

@@ -195,7 +195,7 @@ select {
outline: 1px; outline: 1px;
background: rgba(64, 142, 62, 0.04); background: rgba(64, 142, 62, 0.04);
color: var(--default-font-color); color: var(--default-font-color);
padding: 5px 35px 5px 5px; padding: 5px 15px;
height: 33px; height: 33px;
font-size: var(--default-font-size); font-size: var(--default-font-size);
-webkit-appearance: none; -webkit-appearance: none;

View File

@@ -86,7 +86,7 @@
const UiState = (()=> { const UiState = (()=> {
function _clientVersion() { function _clientVersion() {
return window.uiState.clientVersion; return 'v' + window.uiState.clientVersion;
} }
function _isOnline() { function _isOnline() {

View File

@@ -21,7 +21,7 @@ public:
static const SString DirSep; static const SString DirSep;
public: public:
static FilePath FinalizePath(const SString& path); static SString FinalizePath(const SString& path);
private: private:
SString _path; SString _path;

View File

@@ -2,6 +2,7 @@
#define _SIACOMMON_H #define _SIACOMMON_H
#define SIDRIVE_VERSION_STRING "0.0.1" #define SIDRIVE_VERSION_STRING "0.0.1"
#define COMPAT_SIAD_VERSION "1.1.2"
#ifdef _WIN32 #ifdef _WIN32
// Unicode for Win32 // Unicode for Win32
@@ -76,6 +77,7 @@ public:
}; };
#define DEFAULT_CONFIG_FILE_PATH L"./config/siadriveconfig.json" #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) \ #define Property(type, name, get_access, set_access) \
private:\ private:\

View File

@@ -15,10 +15,11 @@ public:
~CSiaDriveConfig(); ~CSiaDriveConfig();
Property(SString, FilePath, public, private) 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, Renter_UploadDbFilePath, public, private, _configDocument)
JProperty(std::string, TempFolder, public, private, _configDocument) JProperty(std::string, TempFolder, public, private, _configDocument)
JProperty(std::string, CacheFolder, public, public, _configDocument) JProperty(std::string, CacheFolder, public, public, _configDocument)
JProperty(std::uint16_t, HostPort, public, public, _configDocument)
JProperty(std::string, HostNameOrIp, public, public, _configDocument)
private: private:
json _configDocument; json _configDocument;

View File

@@ -8,8 +8,8 @@
#include <siacurl.h> #include <siacurl.h>
#include <siadriveconfig.h> #include <siadriveconfig.h>
#include "siadrivehandler.h" #include "siadrivehandler.h"
/* /* Work Laptop
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 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;
using namespace Sia::Api; using namespace Sia::Api;
@@ -29,9 +29,8 @@ private:
bool& _appStarted; bool& _appStarted;
private: private:
void UnlockCallback(CefRefPtr<CefV8Context> context, CefRefPtr<CefV8Value> cb, const SString& password) const void UnlockCallback(SiaApiError error, CefRefPtr<CefV8Context> context, CefRefPtr<CefV8Value> cb, const SString& password) const
{ {
SiaApiError error = _siaApi.GetWallet()->Unlock(password);
CefV8ValueList args; CefV8ValueList args;
args.push_back(CefV8Value::CreateBool(ApiSuccess(error))); args.push_back(CefV8Value::CreateBool(ApiSuccess(error)));
if (!args[0]->GetBoolValue()) if (!args[0]->GetBoolValue())
@@ -73,7 +72,12 @@ public:
SString password = arguments[0]->GetStringValue().ToWString(); SString password = arguments[0]->GetStringValue().ToWString();
CefRefPtr<CefV8Value> cb = arguments[1]; CefRefPtr<CefV8Value> 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; return true;
} }
else if (name == "createWallet") else if (name == "createWallet")
@@ -147,9 +151,9 @@ CSiaDriveApp::CSiaDriveApp()
{ {
_siaDriveConfig.reset(new CSiaDriveConfig()); _siaDriveConfig.reset(new CSiaDriveConfig());
SiaHostConfig hostConfig; SiaHostConfig hostConfig;
hostConfig.HostName = "127.0.0.1"; hostConfig.HostName = _siaDriveConfig->GetHostNameOrIp();
hostConfig.HostPort = 9980; hostConfig.HostPort = _siaDriveConfig->GetHostPort();
hostConfig.RequiredVersion = "1.1.2"; hostConfig.RequiredVersion = COMPAT_SIAD_VERSION;
_siaCurl.reset(new CSiaCurl(hostConfig)); _siaCurl.reset(new CSiaCurl(hostConfig));
_siaApi.reset(new CSiaApi(hostConfig, _siaDriveConfig.get())); _siaApi.reset(new CSiaApi(hostConfig, _siaDriveConfig.get()));
} }

View File

@@ -3,10 +3,15 @@
using namespace Sia::Api; using namespace Sia::Api;
FilePath FilePath::FinalizePath(const SString& path) SString FilePath::FinalizePath(const SString& path)
{ {
#ifdef _WIN32
std::wregex r(L"/+"); 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() FilePath::FilePath()

View File

@@ -1,5 +1,6 @@
#include <siadriveconfig.h> #include <siadriveconfig.h>
#include <fstream> #include <fstream>
#include <filepath.h>
#ifdef _WIN32 #ifdef _WIN32
#include <Shlobj.h> #include <Shlobj.h>
#endif #endif
@@ -29,13 +30,13 @@ CSiaDriveConfig::~CSiaDriveConfig()
void CSiaDriveConfig::LoadDefaults() void CSiaDriveConfig::LoadDefaults()
{ {
SetRenter_UploadDbFilePath(static_cast<SString>(FilePath(DEFAULT_RENTER_DB_FILE_PATH)));
#ifdef _WIN32 #ifdef _WIN32
SetUI_Main_TabIndex(0);
SetRenter_UploadDbFilePath("./config/renter_upload.db3");
SString tempFolder; SString tempFolder;
tempFolder.Resize(MAX_PATH + 1); tempFolder.Resize(MAX_PATH + 1);
::GetTempPath(MAX_PATH, &tempFolder[0]); ::GetTempPath(MAX_PATH, &tempFolder[0]);
tempFolder = tempFolder.str().c_str();
SetTempFolder(tempFolder); SetTempFolder(tempFolder);
PWSTR localAppData = nullptr; PWSTR localAppData = nullptr;
@@ -45,20 +46,26 @@ void CSiaDriveConfig::LoadDefaults()
sdFolder.Resize(MAX_PATH + 1); sdFolder.Resize(MAX_PATH + 1);
::PathCombine(&sdFolder[0], localAppData, L"SiaDrive"); ::PathCombine(&sdFolder[0], localAppData, L"SiaDrive");
::CreateDirectory(sdFolder.str().c_str(), nullptr); ::CreateDirectory(sdFolder.str().c_str(), nullptr);
sdFolder = sdFolder.str().c_str();
SString cacheFolder; SString cacheFolder;
cacheFolder.Resize(MAX_PATH + 1); cacheFolder.Resize(MAX_PATH + 1);
::PathCombine(&cacheFolder[0], &sdFolder[0], L"Cache"); ::PathCombine(&cacheFolder[0], &sdFolder[0], L"Cache");
::CreateDirectory(cacheFolder.str().c_str(), nullptr); ::CreateDirectory(cacheFolder.str().c_str(), nullptr);
cacheFolder = cacheFolder.str().c_str();
SetCacheFolder(cacheFolder); SetCacheFolder(cacheFolder);
#else #else
a
#endif #endif
SetHostNameOrIp("localhost");
SetHostPort(9980);
} }
void CSiaDriveConfig::Load( ) void CSiaDriveConfig::Load( )
{ {
std::ifstream myfile(GetFilePath().str().c_str()); FilePath filePath = GetFilePath();
std::ifstream myfile(static_cast<SString>(filePath).str().c_str());
if (myfile.is_open()) if (myfile.is_open())
{ {
std::stringstream ss; std::stringstream ss;
@@ -76,16 +83,13 @@ void CSiaDriveConfig::Load( )
void CSiaDriveConfig::Save() const void CSiaDriveConfig::Save() const
{ {
#ifdef _WIN32 FilePath filePath = GetFilePath();
SString folder = GetFilePath(); FilePath folder = filePath;
::PathRemoveFileSpec(&folder[0]); folder.RemoveFileName();
if (!::PathIsDirectory(folder.str().c_str())) if (!folder.IsDirectory())
{ {
::CreateDirectory(folder.str().c_str(), nullptr); folder.CreateDirectory();
} }
#else std::ofstream(SString::ToUtf8(static_cast<SString>(filePath)).c_str()) << std::setw(2) << _configDocument << std::endl;
#endif
std::ofstream(SString::ToUtf8(GetFilePath()).c_str()) << std::setw(2) << _configDocument << std::endl;
} }