diff --git a/.gitignore b/.gitignore
index 98d300c..5a05fcd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -256,3 +256,4 @@ ModelManifest.xml
/SiaDrive_Packager_Debug.iss
/include/siadrive_api/siacommon.h
/SiaDrive_Packager_Release.iss
+/3rd_party/Sia-v1.2.1-windows-amd64.zip
diff --git a/htdocs/favicon.ico b/htdocs/favicon.ico
new file mode 100644
index 0000000..96921a5
Binary files /dev/null and b/htdocs/favicon.ico differ
diff --git a/htdocs/index.html b/htdocs/index.html
index 151efc6..b325df7 100644
--- a/htdocs/index.html
+++ b/htdocs/index.html
@@ -1,6 +1,7 @@
SiaDrive
+
diff --git a/include/siadrive_api/siacommon.h.in b/include/siadrive_api/siacommon.h.in
index 6b1c5d9..7967c2c 100644
--- a/include/siadrive_api/siacommon.h.in
+++ b/include/siadrive_api/siacommon.h.in
@@ -112,6 +112,14 @@ get_access:\
type Get##name() const { return json_doc[#name].get();}\
set_access:\
type Set##name(const type& value) { json_doc[#name] = value; return value; }\
+protected:\
+ bool Check##name() { return json_doc.find(#name) != json_doc.end(); }
+
+#define JPropertyCb(type, name, get_access, set_access, json_doc, cb) \
+get_access:\
+ type Get##name() const { return json_doc[#name].get();}\
+set_access:\
+ type Set##name(const type& value) { json_doc[#name] = value; cb(value); return value; }\
protected:\
bool Check##name() { return json_doc.find(#name) != json_doc.end(); }
@@ -212,6 +220,8 @@ BOOL SIADRIVE_EXPORTABLE RecurDeleteFilesByExtentsion(const SString& folder, con
std::vector SIADRIVE_EXPORTABLE GetAvailableDrives();
std::int32_t SIADRIVE_EXPORTABLE GetRegistry(const SString& name, const std::int32_t& defaultValue);
+
+HRESULT SIADRIVE_EXPORTABLE CreateShortcut(const SString& execPath, const SString& description, const SString& shortcutPath, const bool& minimized);
#endif
bool SIADRIVE_EXPORTABLE ExecuteProcess(CSiaDriveConfig* siaDriveConfig, FilePath process, FilePath workingDir, const bool& waitForExit);
diff --git a/res/SiaDriveLogo.ico b/res/SiaDriveLogo.ico
new file mode 100644
index 0000000..220267c
Binary files /dev/null and b/res/SiaDriveLogo.ico differ
diff --git a/res/SiaDriveLogo.png b/res/SiaDriveLogo.png
new file mode 100644
index 0000000..8a5cd1b
Binary files /dev/null and b/res/SiaDriveLogo.png differ
diff --git a/res/SiaDriveLogo.xcf b/res/SiaDriveLogo.xcf
new file mode 100644
index 0000000..522928d
Binary files /dev/null and b/res/SiaDriveLogo.xcf differ
diff --git a/src/siadrive/main.cpp b/src/siadrive/main.cpp
index 2f39298..1bd31b1 100644
--- a/src/siadrive/main.cpp
+++ b/src/siadrive/main.cpp
@@ -22,7 +22,6 @@ int APIENTRY wWinMain(HINSTANCE hInstance,
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
- ::CoInitializeEx(nullptr, COINIT_MULTITHREADED);
std::shared_ptr siaDriveConfig(new CSiaDriveConfig);
const EventLevel eventLevel = EventLevelFromString(siaDriveConfig->GetEventLevel());
@@ -72,7 +71,5 @@ int APIENTRY wWinMain(HINSTANCE hInstance,
CefRunMessageLoop();
CefShutdown();
- ::CoUninitialize();
-
return 0;;
}
diff --git a/src/siadrive/siadriveapp.cpp b/src/siadrive/siadriveapp.cpp
index 2d370b4..a68dd24 100644
--- a/src/siadrive/siadriveapp.cpp
+++ b/src/siadrive/siadriveapp.cpp
@@ -383,7 +383,7 @@ void CSiaDriveApp::OnContextInitialized()
#endif
windowInfo.width = 800;
windowInfo.height = 675;
-
+
CefBrowserHost::CreateBrowser(windowInfo, handler, url.str(), browserSettings, nullptr);
}
}
diff --git a/src/siadrive/siadrivehandler.cpp b/src/siadrive/siadrivehandler.cpp
index e2e3db4..2dd5bad 100644
--- a/src/siadrive/siadrivehandler.cpp
+++ b/src/siadrive/siadrivehandler.cpp
@@ -5,11 +5,16 @@
#include
#include
#include
-
+#include
using namespace Sia;
+using namespace Sia::Api;
CSiaDriveHandler* g_instance = nullptr;
+#ifdef _WIN32
+static NOTIFYICONDATA g_notifyIcon = { 0 };
+#endif
+
CSiaDriveHandler::CSiaDriveHandler(const bool& useViews) :
_useViews(useViews),
_isClosing(false)
@@ -51,6 +56,29 @@ void CSiaDriveHandler::OnTitleChange(CefRefPtr browser, const CefStr
void CSiaDriveHandler::OnAfterCreated(CefRefPtr browser)
{
CEF_REQUIRE_UI_THREAD();
+#ifdef _WIN32
+ SString filePath(FilePath(".\\htdocs\\favicon.ico").MakeAbsolute());
+ HWND hwnd = browser->GetHost()->GetWindowHandle();
+ HINSTANCE hinstance = ::GetModuleHandle(nullptr);
+ HICON icon = static_cast(::LoadImage(hinstance, &filePath[0], IMAGE_ICON, 16, 16, LR_LOADFROMFILE | LR_SHARED));
+
+ ::SendMessage(hwnd, WM_SETICON, ICON_SMALL, reinterpret_cast(icon));
+ ::SendMessage(hwnd, WM_SETICON, ICON_BIG, reinterpret_cast(icon));
+ ::SendMessage(GetWindow(hwnd, GW_OWNER), WM_SETICON, ICON_SMALL, reinterpret_cast(icon));
+ ::SendMessage(GetWindow(hwnd, GW_OWNER), WM_SETICON, ICON_BIG, reinterpret_cast(icon));
+
+ g_notifyIcon.cbSize = sizeof(g_notifyIcon);
+ g_notifyIcon.hWnd = hwnd;
+ g_notifyIcon.hIcon = icon;
+ GUID g = { 0 };
+ ::CoCreateGuid(&g);
+ g_notifyIcon.guidItem = g;
+ g_notifyIcon.uVersion = NOTIFYICON_VERSION_4;
+ g_notifyIcon.uFlags = NIF_ICON | NIF_GUID;
+ ::Shell_NotifyIcon(NIM_ADD, &g_notifyIcon);
+#else
+ a
+#endif
_browserList.push_back(browser);
}
@@ -87,6 +115,7 @@ void CSiaDriveHandler::OnBeforeClose(CefRefPtr browser)
if (_browserList.empty())
{
CefQuitMessageLoop();
+ ::Shell_NotifyIcon(NIM_DELETE, &g_notifyIcon);
}
}
diff --git a/src/siadrive_api/siacommon.cpp b/src/siadrive_api/siacommon.cpp
index e9ef72c..cd4d675 100644
--- a/src/siadrive_api/siacommon.cpp
+++ b/src/siadrive_api/siacommon.cpp
@@ -234,7 +234,7 @@ bool ExecuteProcess(CSiaDriveConfig* siaDriveConfig, FilePath process, FilePath
return false;
}
-HRESULT CreateShortcut(const SString& execPath, const SString& description, const SString& shortcutPath)
+HRESULT CreateShortcut(const SString& execPath, const SString& description, const SString& shortcutPath, const bool& minimized)
{
IShellLink* shellLink(nullptr);
HRESULT hr = ::CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER, IID_IShellLink, reinterpret_cast(&shellLink));
@@ -243,6 +243,7 @@ HRESULT CreateShortcut(const SString& execPath, const SString& description, cons
shellLink->SetPath(&execPath[0]);
shellLink->SetWorkingDirectory(&FilePath(execPath).RemoveFileName()[0]);
shellLink->SetDescription(&description[0]);
+ shellLink->SetShowCmd(minimized ? SW_MINIMIZE : SW_SHOWDEFAULT);
IPersistFile* persistFile(nullptr);
hr = shellLink->QueryInterface(IID_IPersistFile, reinterpret_cast(&persistFile));
diff --git a/src/siadrive_api/siadriveconfig.cpp b/src/siadrive_api/siadriveconfig.cpp
index 7542d7e..d432706 100644
--- a/src/siadrive_api/siadriveconfig.cpp
+++ b/src/siadrive_api/siadriveconfig.cpp
@@ -23,8 +23,9 @@ CSiaDriveConfig::~CSiaDriveConfig()
void CSiaDriveConfig::OnAutoStartOnLogonChanged(const bool& value)
{
+#ifndef _DEBUG
#ifdef _WIN32
- PWSTR startupPath;
+ PWSTR startupPath = nullptr;
if (SUCCEEDED(::SHGetKnownFolderPath(FOLDERID_Startup, 0, nullptr, &startupPath)))
{
FilePath shortcutPath(startupPath, "SiaDrive.lnk");
@@ -37,7 +38,7 @@ void CSiaDriveConfig::OnAutoStartOnLogonChanged(const bool& value)
SString execPath;
execPath.Resize(MAX_PATH + 1);
GetModuleFileName(::GetModuleHandle(nullptr), &execPath[0], MAX_PATH);
- CreateShortcut(execPath, "SiaDrive", shortcutPath);
+ CreateShortcut(execPath, "SiaDrive", shortcutPath, true);
}
}
else if (exists)
@@ -49,6 +50,7 @@ void CSiaDriveConfig::OnAutoStartOnLogonChanged(const bool& value)
#else
a
#endif
+#endif
}
bool CSiaDriveConfig::LoadDefaults()
@@ -150,6 +152,10 @@ bool CSiaDriveConfig::LoadDefaults()
SetLaunchFileMgrOnMount(true);
changed = true;
}
+
+ // Do this to add/remove shortcut on start-up
+ OnAutoStartOnLogonChanged(GetAutoStartOnLogon());
+
return changed;
}