|
10 | 10 | #include <borealis/core/application.hpp>
|
11 | 11 | #include <borealis/core/thread.hpp>
|
12 | 12 | #include <borealis/views/dialog.hpp>
|
13 |
| -#include <borealis/platforms/desktop/steam_deck.hpp> |
14 |
| - |
15 | 13 | #include "utils/config_helper.hpp"
|
16 | 14 | #include "utils/dialog_helper.hpp"
|
17 | 15 | #include "api/bilibili/util/http.hpp"
|
18 | 16 | #include "fragment/latest_update.hpp"
|
| 17 | +#ifdef __SWITCH__ |
| 18 | +#include <switch.h> |
| 19 | +#elif defined(__APPLE__) |
| 20 | +#include <SystemConfiguration/SystemConfiguration.h> |
| 21 | +#elif defined(__linux__) |
| 22 | +#include <borealis/platforms/desktop/steam_deck.hpp> |
| 23 | +#endif |
19 | 24 |
|
20 | 25 | using namespace brls::literals;
|
21 | 26 |
|
@@ -69,6 +74,38 @@ std::string APPVersion::getPlatform() {
|
69 | 74 | #endif
|
70 | 75 | }
|
71 | 76 |
|
| 77 | +std::string APPVersion::getDeviceName() { |
| 78 | +#ifdef __SWITCH__ |
| 79 | + SetSysDeviceNickName nick; |
| 80 | + if (R_SUCCEEDED(setsysGetDeviceNickname(&nick))) { |
| 81 | + return nick.nickname; |
| 82 | + } |
| 83 | +#elif defined(_WIN32) |
| 84 | + DWORD nSize = 128; |
| 85 | + std::vector<WCHAR> buf(nSize); |
| 86 | + if (GetComputerNameW(buf.data(), &nSize)) { |
| 87 | + std::vector<char> name(nSize * 3); |
| 88 | + WideCharToMultiByte(CP_UTF8, 0, buf.data(), nSize, name.data(), name.size(), nullptr, nullptr); |
| 89 | + return name.data(); |
| 90 | + } |
| 91 | +#elif defined(__APPLE__) |
| 92 | + CFStringRef nameRef = SCDynamicStoreCopyComputerName(nullptr, nullptr); |
| 93 | + if (nameRef) { |
| 94 | + std::vector<char> name(CFStringGetLength(nameRef) * 3); |
| 95 | + CFStringGetCString(nameRef, name.data(), name.size(), kCFStringEncodingUTF8); |
| 96 | + CFRelease(nameRef); |
| 97 | + return name.data(); |
| 98 | + } |
| 99 | +#elif defined(__linux__) |
| 100 | + std::ifstream file("/etc/hostname"); |
| 101 | + if (file.is_open()) { |
| 102 | + return std::string(std::istreambuf_iterator<char>(file), |
| 103 | + std::istreambuf_iterator<char>()); |
| 104 | + } |
| 105 | +#endif |
| 106 | + return fmt::format("wiliwili - {}", getPlatform()); |
| 107 | +} |
| 108 | + |
72 | 109 | std::string APPVersion::getPackageName() { return std::string{STR(BUILD_PACKAGE_NAME)}; }
|
73 | 110 |
|
74 | 111 | bool APPVersion::needUpdate(std::string latestVersion) {
|
|
0 commit comments