Skip to content

Commit

Permalink
core - ftp changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowMonster99 committed Jun 21, 2024
1 parent f16a5a6 commit ac65eba
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 21 deletions.
17 changes: 9 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ include_directories(
${CMAKE_SOURCE_DIR}/vendor/asio/asio/include
${CMAKE_SOURCE_DIR}/vendor/nlohmann/include
${CMAKE_SOURCE_DIR}/vendor/websocketpp
${CMAKE_SOURCE_DIR}/vendor/incbin
${CMAKE_SOURCE_DIR}/vendor/crow/include
)

add_compile_definitions(
Expand Down Expand Up @@ -108,6 +108,7 @@ set(SOURCE_FILES
"src/sys/settings.cc"
"src/api/executor.cc"
"src/deps/module.cc"
"src/crow/serv.cc"
)

if (MSVC)
Expand Down Expand Up @@ -147,14 +148,17 @@ if (WINDRES)
target_link_libraries(Millennium ${CMAKE_BINARY_DIR}/version.o)
endif()

target_link_libraries(Millennium
Boxer
cpr::cpr
unofficial::git2::git2
)

if(WIN32)
target_link_libraries(Millennium
Ws2_32.lib
wsock32
Iphlpapi
Boxer
cpr::cpr
unofficial::git2::git2
)
if (GITHUB_ACTION_BUILD)
target_link_libraries(Millennium
Expand All @@ -169,9 +173,6 @@ if(WIN32)
endif()
elseif(UNIX)
target_link_libraries(Millennium
Boxer
cpr::cpr
git2
Python3::Python
Python3::Python
)
endif()
1 change: 0 additions & 1 deletion CMakeUserPresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"VCPKG_TARGET_TRIPLET": "x86-mingw-static",
"CMAKE_CXX_STANDARD": "17",
"CMAKE_C_STANDARD": "23",
"CMAKE_CXX_COMPILER": "g++",
"CMAKE_CXX_FLAGS": "-static-libstdc++ -static-libgcc -static -lpthread"
}
},
Expand Down
10 changes: 3 additions & 7 deletions src/core/co_initialize/co_stub.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,14 @@ constexpr const char* bootstrapModule = R"(
function createWebSocket(url) {
return new Promise((resolve, reject) => {
let socket = new WebSocket(url);
socket.addEventListener('open', () => {
console.log('WebSocket connected');
resolve(socket);
});
socket.addEventListener('error', (error) => {
console.error('WebSocket error:', error);
reject(error);
});
socket.addEventListener('close', () => {
console.warn('WebSocket closed, attempting to reconnect...');
setTimeout(() => {
Expand All @@ -43,11 +40,10 @@ function waitForSocket(socket) {
});
}
const InjectLegacyReactGlobals = () =>
{
const InjectLegacyReactGlobals = () => {
let initReq;
let bufferWebpackCache = {};
window.webpackChunksteamui?.push([[Math.random()], {}, (r) => { initReq = r; }]);
for (let i of Object.keys(initReq.m)) {
Expand Down Expand Up @@ -75,7 +71,7 @@ function waitForSPReactDOM() {
return new Promise((resolve) => {
const interval = setInterval(() => {
if (window?.webpackChunksteamui?.length > 3) {
InjectLegacyReactGlobals()
InjectLegacyReactGlobals();
clearInterval(interval);
resolve();
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/py_controller/co_spawn.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct PythonThreadState {
PyThreadState* thread_state;
};

static const std::filesystem::path pythonModulesBaseDir = SystemIO::GetSteamPath() / ".millennium" / "@modules";
static const std::filesystem::path pythonModulesBaseDir = SystemIO::GetSteamPath() / "ext" / "data" / "cache";

static const std::string pythonPath = pythonModulesBaseDir.generic_string();
static const std::string pythonLibs = (pythonModulesBaseDir / "python311.zip").generic_string();
Expand Down
2 changes: 1 addition & 1 deletion src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Preload
const char* builtinsRepository = "https://github.com/SteamClientHomebrew/__builtins__.git";
const char* pythonModulesRepository = "https://github.com/SteamClientHomebrew/Packages.git";

std::filesystem::path builtinsModulesPath = SystemIO::GetSteamPath() / "steamui" / "plugins" / "__millennium__";
std::filesystem::path builtinsModulesPath = SystemIO::GetSteamPath() / "ext" / "data" / "assets";

public:

Expand Down
1 change: 1 addition & 0 deletions src/sys/locals.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class SettingsStore
private:
void LintPluginData(nlohmann::json json, std::string pluginName);
PluginTypeSchema GetPluginInternalData(nlohmann::json json, std::filesystem::directory_entry entry);
void InsertMillenniumModules(std::vector<SettingsStore::PluginTypeSchema>& plugins);
};

namespace SystemIO
Expand Down
2 changes: 1 addition & 1 deletion src/sys/log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ OutputLogger::OutputLogger()
}
#endif

const auto fileName = SystemIO::GetSteamPath() / ".millennium" / "debug.log";
const auto fileName = SystemIO::GetSteamPath() / "ext" / "data" / "logs" / "debug.log";

try
{
Expand Down
39 changes: 37 additions & 2 deletions src/sys/settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace FileSystem = std::filesystem;

void SettingsStore::SetSettings(std::string file_data)
{
const auto path = SystemIO::GetSteamPath() / ".millennium" / "settings.json";
const auto path = SystemIO::GetSteamPath() / "ext" / "data" / "settings.json";

if (!FileSystem::exists(path))
{
Expand All @@ -26,7 +26,7 @@ void SettingsStore::SetSettings(std::string file_data)

nlohmann::json SettingsStore::GetSettings()
{
const auto path = SystemIO::GetSteamPath() / ".millennium" / "settings.json";
const auto path = SystemIO::GetSteamPath() / "ext" / "data" / "settings.json";

if (!FileSystem::exists(path))
{
Expand Down Expand Up @@ -170,11 +170,41 @@ SettingsStore::PluginTypeSchema SettingsStore::GetPluginInternalData(nlohmann::j
return plugin;
}

void SettingsStore::InsertMillenniumModules(std::vector<SettingsStore::PluginTypeSchema>& plugins)
{
const std::filesystem::directory_entry entry(SystemIO::GetSteamPath() / "ext" / "data" / "assets");
const auto pluginConfiguration = entry.path() / SettingsStore::pluginConfigFile;

if (!FileSystem::exists(pluginConfiguration))
{
LOG_ERROR("No plugin configuration found in '{}'", entry.path().string());
return;
}

try
{
const auto pluginJson = SystemIO::ReadJsonSync(pluginConfiguration.string());
const auto pluginData = GetPluginInternalData(pluginJson, entry);

plugins.push_back(pluginData);
}
catch (SystemIO::FileException& exception)
{
LOG_ERROR("An error occurred reading plugin '{}', exception: {}", entry.path().string(), exception.what());
}
catch (std::exception& exception)
{
LOG_ERROR("An error occurred parsing plugin '{}', exception: {}", entry.path().string(), exception.what());
}
}

std::vector<SettingsStore::PluginTypeSchema> SettingsStore::ParseAllPlugins()
{
std::vector<SettingsStore::PluginTypeSchema> plugins;
const auto plugin_path = SystemIO::GetSteamPath() / "steamui" / "plugins";

this->InsertMillenniumModules(plugins);

try
{
for (const auto& entry : std::filesystem::directory_iterator(plugin_path))
Expand Down Expand Up @@ -213,5 +243,10 @@ std::vector<SettingsStore::PluginTypeSchema> SettingsStore::ParseAllPlugins()
LOG_ERROR("Fall back exception caught trying to parse plugins. {}", ex.what());
}

for (const auto& plugin : plugins)
{
Logger.Log("found plugin '{}'", plugin.pluginName);
}

return plugins;
}

0 comments on commit ac65eba

Please sign in to comment.