diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-26 22:26:48 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-26 22:27:09 +0100 |
| commit | eba8b7ddd0a455d9e49f32dcae712c5612c0093c (patch) | |
| tree | 749a3d34546d055507a920bce4ab10e8a9945719 /Public | |
| parent | dd192787a70a973f2474720aea49af3f6ddabb7a (diff) | |
Kernel: Major repository refactor.
Rework the repo into Private and Public modules.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Public')
| -rw-r--r-- | Public/.gitkeep | 0 | ||||
| -rw-r--r-- | Public/SDK/.gitkeep | 0 | ||||
| -rw-r--r-- | Public/Servers/CommSrv/.gitkeep | 0 | ||||
| -rw-r--r-- | Public/Servers/CommSrv/CommSrv.hxx | 12 | ||||
| -rw-r--r-- | Public/Servers/SeekerSrv/Seeker.hxx | 171 | ||||
| -rw-r--r-- | Public/Servers/SeekerSrv/SeekerAbout.cxx | 16 | ||||
| -rw-r--r-- | Public/Servers/SeekerSrv/SeekerAssert.cxx | 20 | ||||
| -rw-r--r-- | Public/Servers/SeekerSrv/SeekerDriver.cxx | 27 | ||||
| -rw-r--r-- | Public/Servers/SeekerSrv/SeekerFileWnd.cxx | 54 | ||||
| -rw-r--r-- | Public/Servers/SeekerSrv/SeekerSubsystemStart.cxx | 30 | ||||
| -rw-r--r-- | Public/Tools/.gitkeep | 0 |
11 files changed, 330 insertions, 0 deletions
diff --git a/Public/.gitkeep b/Public/.gitkeep new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/Public/.gitkeep diff --git a/Public/SDK/.gitkeep b/Public/SDK/.gitkeep new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/Public/SDK/.gitkeep diff --git a/Public/Servers/CommSrv/.gitkeep b/Public/Servers/CommSrv/.gitkeep new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/Public/Servers/CommSrv/.gitkeep diff --git a/Public/Servers/CommSrv/CommSrv.hxx b/Public/Servers/CommSrv/CommSrv.hxx new file mode 100644 index 00000000..b965fe8b --- /dev/null +++ b/Public/Servers/CommSrv/CommSrv.hxx @@ -0,0 +1,12 @@ +/* +* ======================================================== +* +* hCore +* Copyright 2024 Mahrouss Logic, all rights reserved. +* +* ======================================================== +*/ + +#pragma once + +#include <NewKit/Defines.hpp>
\ No newline at end of file diff --git a/Public/Servers/SeekerSrv/Seeker.hxx b/Public/Servers/SeekerSrv/Seeker.hxx new file mode 100644 index 00000000..1a3518b6 --- /dev/null +++ b/Public/Servers/SeekerSrv/Seeker.hxx @@ -0,0 +1,171 @@ +/* + * ======================================================== + * + * hCore + * Copyright 2024 Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#ifndef __SEEKER__ +#define __SEEKER__ + +#include <CompilerKit/Compiler.hpp> + +/* @brief SeekerSrv SDK. */ +/* SeekerSrv helps with GUI developement. */ + +enum +{ + kRegularFile, + kDirectory, + kJunctionFile, + kNetworkFile, + kNetworkDirectory, + kNetworkJunction, + kDrive, + kDevice, +}; + +enum +{ + kHardDrv = 110, + kOpticalDrv = 111, + kUsbDrv = 112, +}; + +enum +{ + kLangUs = 113, + kLangUk = 114, + kLangFr = 115, + kLangNl = 116, +}; + +#define kResourceExt ".rsc" +#define kExecutableExt ".exe" +#define kLibExt ".lib" +#define kShLibExt ".lib" + +typedef void Void; +typedef void* VoidPtr; + +typedef wchar_t WideChar; +typedef wchar_t* WideCString; + +typedef __SIZE_TYPE__ SizeT; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +struct SeekerProtocol; + +// @brief Opens a SeekerSrv window. +extern "C" VoidPtr SeekerOpenExplorer(const WideCString startCategory); + +// @brief Closes a SeekerSrv window. +extern "C" Void SeekerCloseExplorer(VoidPtr handle); + +// @brief Make SeekerSrv connect to endpoint. +extern "C" Void SeekerExplorerConnectToNetwork(VoidPtr handle, + const WideCString endpoint, + struct SeekerProtocol* proto); + +extern "C" Void SeekerExplorerChangeTo(VoidPtr handle, + const WideCString nodeName); + +// @brief Search for elements inside directory/drive +// returns a class list as voidstar. +extern "C" VoidPtr SeekerSearch(VoidPtr handle, + const WideCString where, + const WideCString forWhat); + +#define kProtocolStrLen 8 + +// @brief SeekerSrv Location Protocol. +// @brief takes a handler class to handle server response. +struct SeekerProtocol +{ + WideChar fProtocol[kProtocolStrLen]; // ftp, sftp, http + VoidPtr fProtocolHandlerClass; + SizeT fProtocolHandlerClassSize; +}; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +typedef void(*WndProcType)(int msg, VoidPtr lparam, VoidPtr wparam); + +extern "C" bool WindowClassCreate(const WideCString name, VoidPtr windowStruct, SizeT windowStructSz); +extern "C" VoidPtr WindowCreate(const WideCString name, const WideCString wndClass, VoidPtr parent); +extern "C" Void WindowFieldSet(const VoidPtr win, const WideCString key, const WideCString value); +extern "C" Void WindowFree(VoidPtr win); +extern "C" Void WindowProcSet(VoidPtr win, void(*winproc)(int msg, VoidPtr lparam, VoidPtr wparam)); +extern "C" Void WindowFreeClass(VoidPtr classPtr); + +// passing nullptr will give a console to the desktop. +extern "C" Void OpenConsole(VoidPtr handle); +extern "C" Void CloseConsole(VoidPtr handle); + +// Runtime functions +extern "C" void RtInitTerm(void); +extern "C" bool RtIsValidHeapPtr(VoidPtr heap); +extern "C" Void RtDialogAssert(const bool expr, const wchar_t* file, const wchar_t* expression); +extern "C" Void RtShellOpen(const WideCString path, int argc, const WideCString* argv); + +#define __WideExpr(x) L##x +#define RtWideString(x) __WideExpr(x) + +#define RtAssert(expr) RtDialogAssert(expr, RtWideString(__FILE__), RtWideString(#expr)) + +typedef VoidPtr HandlePtr; +typedef HandlePtr IdPtr; + +///////////////////////////////////////////////////// + +HandlePtr SeekerAboutDlg(Void); + +#define FINDER_YES L"Yes" +#define FINDER_NO L"No" + +#define kAssertInterrupt "sc $1" + +extern "C" Void QuickDrawRect(float x, float y, + float r, float g, float b, + float w, float h, float strike, + float radius); + +extern "C" Void QuickDrawPattern(float x, float y, + float* pattern, size_t sz, + float w, float h, float strike, + float radius); + +// @brief a C++ class. +typedef VoidPtr SeekerClassPtr; + +typedef struct +{ + float x, y; + float w, h; +} TAreaType; + +///////////////////////////////////////////////////// + +namespace Seeker +{ + class TControl + { + public: + explicit TControl() = default; + virtual ~TControl() = default; + + HCORE_COPY_DEFAULT(TControl); + + public: + virtual void Draw() noexcept = 0; + + public: + TAreaType fVisibleArea; + TAreaType fFullArea; + + }; +} +#endif /* ifndef __SEEKER__ */
\ No newline at end of file diff --git a/Public/Servers/SeekerSrv/SeekerAbout.cxx b/Public/Servers/SeekerSrv/SeekerAbout.cxx new file mode 100644 index 00000000..1b976aac --- /dev/null +++ b/Public/Servers/SeekerSrv/SeekerAbout.cxx @@ -0,0 +1,16 @@ +/* + * ======================================================== + * + * hCore + * Copyright 2024 Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#include <SeekerSrv/Seeker.hxx> + +HandlePtr SeekerAboutDlg(Void) +{ + HandlePtr windowHandle = WindowCreate(L"hCore", L"OSAboutDialog", nullptr); + return windowHandle; +}
\ No newline at end of file diff --git a/Public/Servers/SeekerSrv/SeekerAssert.cxx b/Public/Servers/SeekerSrv/SeekerAssert.cxx new file mode 100644 index 00000000..53fe232b --- /dev/null +++ b/Public/Servers/SeekerSrv/SeekerAssert.cxx @@ -0,0 +1,20 @@ +/* + * ======================================================== + * + * hCore + * Copyright 2024 Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#include <SeekerSrv/Seeker.hxx> + +extern "C" Void RtDialogAssert(const bool expr, const wchar_t* file, const wchar_t* expression) +{ + auto handle = WindowCreate(L"Assertion failed!", L"OSWndAssert", nullptr); + + WindowFieldSet(handle, L"Title", L"Assertion failed!"); + WindowFieldSet(handle, L"ButtonClicked_OK", L"Abort"); + + asm (kAssertInterrupt); +}
\ No newline at end of file diff --git a/Public/Servers/SeekerSrv/SeekerDriver.cxx b/Public/Servers/SeekerSrv/SeekerDriver.cxx new file mode 100644 index 00000000..8dc6f891 --- /dev/null +++ b/Public/Servers/SeekerSrv/SeekerDriver.cxx @@ -0,0 +1,27 @@ +/* + * ======================================================== + * + * hCore + * Copyright 2024 Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#include <SeekerSrv/Seeker.hxx> + +extern "C" Void DrawDesktopService(Void); +extern "C" Void DrawWindowService(Void); +extern "C" Void DrawMenuService(Void); +extern "C" Void DrawDialogService(Void); + +extern "C" Void PumpMessageService(Void); + +// @brief each app must call this for their region, otherwise it'll show a black rectangle. +extern "C" Void SeekerMessageLoop(Void) +{ + DrawDesktopService(); + DrawMenuService(); + DrawWindowService(); + DrawDialogService(); + PumpMessageService(); +} diff --git a/Public/Servers/SeekerSrv/SeekerFileWnd.cxx b/Public/Servers/SeekerSrv/SeekerFileWnd.cxx new file mode 100644 index 00000000..7407992c --- /dev/null +++ b/Public/Servers/SeekerSrv/SeekerFileWnd.cxx @@ -0,0 +1,54 @@ +/* + * ======================================================== + * + * hCore + * Copyright 2024 Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#include <SeekerSrv/Seeker.hxx> + +// Source code of the SeekerSrv Window. + +// @brief Opens a SeekerSrv window. +extern "C" VoidPtr SeekerOpenExplorer(const WideCString startCategory) +{ + auto win = WindowCreate(L"SeekerSrv", L"OSSeekerWnd", nullptr); + + if (win) + { + WindowFieldSet(win, L"Category", startCategory); + WindowFieldSet(win, L"CanClose", FINDER_NO); + WindowFieldSet(win, L"ClosePolicy", L"Restart"); + + return win; + } + + RtAssert(win != nullptr); + + return nullptr; +} + +// @brief Closes a SeekerSrv window. +extern "C" Void SeekerCloseExplorer(VoidPtr handle) +{ + if (RtIsValidHeapPtr(handle)) + { + WindowFree(handle); + } +} + +extern "C" Void SeekerExplorerConnectToNetwork(VoidPtr handle, + const WideCString endpoint, + struct SeekerProtocol* proto) +{ + if (handle) + { + WindowFieldSet(handle, L"NetworkProtocolEndpoint", endpoint); + WindowFieldSet(handle, L"NetworkProtocolClass", (wchar_t*)proto->fProtocolHandlerClass); + WindowFieldSet(handle, L"NetworkProtocolClassSize", (wchar_t*)proto->fProtocolHandlerClassSize); + + WindowFieldSet(handle, L"NetworkProtocolFire", FINDER_YES); + } +}
\ No newline at end of file diff --git a/Public/Servers/SeekerSrv/SeekerSubsystemStart.cxx b/Public/Servers/SeekerSrv/SeekerSubsystemStart.cxx new file mode 100644 index 00000000..e730aa31 --- /dev/null +++ b/Public/Servers/SeekerSrv/SeekerSubsystemStart.cxx @@ -0,0 +1,30 @@ +/* + * ======================================================== + * + * hCore + * Copyright 2024 Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#include <SeekerSrv/Seeker.hxx> + +extern "C" Void __InitCxxGlobals(Void); +extern "C" Void __InitCommonCtrls(Void); +extern "C" Void __InitSeekerCtrls(Void); +extern "C" char** __InitArgs(int* argc); + +extern "C++" Void __InvokeMain(int argc, char** argv); + +/* @brief As requested by PEF. */ +extern "C" Void __start(Void) +{ + __InitCxxGlobals(); + __InitSeekerCtrls(); + __InitCommonCtrls(); + + int argc = 0; + auto argv = __InitArgs(&argc); + + __InvokeMain(argc, argv); +}
\ No newline at end of file diff --git a/Public/Tools/.gitkeep b/Public/Tools/.gitkeep new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/Public/Tools/.gitkeep |
