diff --git a/CMakeLists.txt b/CMakeLists.txt index 7aeb54c..ba1833e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,7 +33,17 @@ if(NOT DEFINED DW_BUILD_NUMBER) endif() message(STATUS "Build number: ${DW_BUILD_NUMBER}") -add_executable(discord_webview src/main.cpp src/UpdateCheck.cpp ${DW_HOST}) +add_executable(discord_webview + src/Application.cpp + src/DiscordWindow.cpp + src/ProgressWindow.cpp + src/SettingsWindow.cpp + src/Sha256.cpp + src/UpdateCheck.cpp + src/main.cpp + src/PagePermissions.cpp + ${DW_HOST} +) target_link_libraries(discord_webview PRIVATE webview_window) target_compile_definitions(discord_webview PRIVATE DW_BUILD_NUMBER=${DW_BUILD_NUMBER}) @@ -46,3 +56,14 @@ if(WIN32) # The program carries WebView2Loader.dll, which the library writes beside the executable at start: the release is the executable alone. webview_window_embed_loader(discord_webview) endif() + +# The unit tests of the logic the program keeps apart from the windows. Off by default: configure with -DDW_BUILD_TESTS=ON, then run +# ctest in the build folder. +option(DW_BUILD_TESTS "Build the unit tests" OFF) +if(DW_BUILD_TESTS) + enable_testing() + add_executable(permission_policy_test tests/PagePermissions_test.cpp src/PagePermissions.cpp) + target_include_directories(permission_policy_test PRIVATE src) + target_link_libraries(permission_policy_test PRIVATE webview_window) + add_test(NAME permission_policy COMMAND permission_policy_test) +endif() diff --git a/README.md b/README.md index 369375c..e42dc81 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,6 @@ CI (`.github/workflows/build.yml`) runs `build.sh all` on every push to `main` a - The window is undecorated (WebViewWindow always creates frameless windows on Linux). The page draws its own title bar: move the window with its bar, and close it with its close button or Alt+F4. - Links to other sites open in the default browser. Links to discord.com load in the window. -- Voice and video calls, notifications, tray icon and the Discord desktop-only features are not available. WebKitGTK's WebRTC - support is limited. +- Voice and video calls don't work yet. Discord's desktop voice engine isn't available here, and the page gets the microphone, + camera and notifications only as a browser would. `docs/MISSING_FEATURES.md` lists what the desktop app has and this one lacks. - Closing the window quits the program. diff --git a/assets/discord.png b/assets/discord.png new file mode 100644 index 0000000..69e33c3 Binary files /dev/null and b/assets/discord.png differ diff --git a/docs/MISSING_FEATURES.md b/docs/MISSING_FEATURES.md new file mode 100644 index 0000000..907c0a2 --- /dev/null +++ b/docs/MISSING_FEATURES.md @@ -0,0 +1,99 @@ +# Desktop features the Discord app has that DiscordWebView lacks + +The Discord desktop app is an Electron shell around the same web client this program loads. The shell gives the web client a +bridge, `window.DiscordNative`, which the page uses for audio, video, screen sharing, notifications, badges, file dialogs and +more. This program loads `https://discord.com/app` into a WebView and does not provide that bridge, so the web client runs +as it would in a plain browser. + +The inventory below comes from the desktop build 1.0.161 (Linux, Flatpak): `resources/app.asar` and +`modules/discord_desktop_core/core.asar`, in particular `mainScreenPreload.js`, where `DiscordNative` is defined. Module names +are the keys of that object. The main-process side of the channels (`bundle.js`) was not read. + +## Status key + +- **Missing**: not started. +- **Partial**: some of the behaviour is in place. The entry says what. +- **Done**: implemented and covered by a test. The test is named in the entry. + +## Audio and video + +| Feature | Discord bridge | Status | +| --- | --- | --- | +| Voice and video engine | `nativeModules.requireModule('discord_voice')` (`discord_voice.node`, a Node addon) | Missing. Needs a Node-addon host, so it can't be dropped in. | +| Noise suppression | `nativeModules` → `discord_krisp` | Missing (depends on the voice engine). | +| Microphone and camera permission | WebView permission requests | Done: allowed for discord.com (`PagePermissions`). Not yet checked with a live call. | +| Screen share sources | `desktopCapture.getDesktopCaptureSources`, `window.getMediaSourceId` | Missing. | +| Keep the display awake during calls | `powerSaveBlocker.blockDisplaySleep` / `unblockDisplaySleep` | Missing. | +| Network time for voice | `ntpClock` | Missing. | + +## Permissions + +| Feature | Discord bridge | Status | +| --- | --- | --- | +| Microphone, camera and notifications allowed for discord.com | (WebView) | Done: `src/PagePermissions.cpp`, `tests/PagePermissions_test.cpp` (unit), and `WebViewWindow/tests/linux_permission_test.sh` (Linux, live). | +| Other permission kinds | (WebView) | Left to the platform default. | + +## Notifications and badges + +| Feature | Discord bridge | Status | +| --- | --- | --- | +| Desktop notifications | `ipc`: `NOTIFICATION_SHOW`, `NOTIFICATION_CLOSE`, `NOTIFICATIONS_*` | Partial: the page's Notification API is allowed for discord.com, so `Notification.permission` is `granted`. Nothing from the `ipc` channels is used, so the notifications are the WebView's own. | +| Unread badge on the taskbar or dock | `ipc`: `APP_SET_BADGE_COUNT`, `APP_DOCK_SET_BADGE`, `APP_DOCK_BOUNCE` | Missing. | +| Tray icon state (unread, mute) | `ipc`: `SYSTEM_TRAY_SET_STATES`, `SYSTEM_TRAY_SET_ICON`, `SYSTEM_TRAY_SET_STRINGS` | Missing. The tray icon exists, but Discord doesn't update it. | +| Taskbar progress and flash | `window.setProgressBar`, `window.flashFrame` | Missing. | +| Windows taskbar thumbnail buttons | `thumbar.setThumbarButtons` | Missing (Windows only). | + +## Window control + +| Feature | Discord bridge | Status | +| --- | --- | --- | +| Always on top | `window.setAlwaysOnTop`, `isAlwaysOnTop` | Missing. | +| Background throttling and frame rate | `window.setBackgroundThrottling`, `setFrameRate` | Missing. | +| Minimum size | `window.setMinimumSize` | Missing. | +| Zoom | `window.setZoomFactor` | Missing. | +| Picture-in-picture window | `window.openDocumentPip` | Missing. | +| Content protection (hide from screen capture) | `window.setContentProtection` | Missing. | + +## Files, clipboard and downloads + +| Feature | Discord bridge | Status | +| --- | --- | --- | +| Downloads saved to disk | (WebView download events) | Missing. Downloads aren't handled at all. | +| Open and save dialogs | `fileManager.showOpenDialog`, `saveWithDialog`, `showItemInFolder` | Missing. | +| Native clipboard (images, files, cut) | `clipboard.copyImage`, `copyFile`, `cut`, `paste`, `read` | Missing. The web clipboard API is untested. | + +## Settings, storage and system + +| Feature | Discord bridge | Status | +| --- | --- | --- | +| Persistent settings | `settings.get`, `set` | Missing. The page keeps its own state in the WebView's storage. | +| Encrypted storage for tokens | `safeStorage.encryptString`, `decryptString` | Missing. | +| Launch at login, start minimised, minimise to tray | `app`: `TOGGLE_OPEN_ON_STARTUP`, `TOGGLE_START_MINIMIZED`, `TOGGLE_MINIMIZE_TO_TRAY` | Missing. A tray menu entry exists, but the page's toggles don't reach it. | +| Relaunch | `app.relaunch` | Missing. | +| Power events (suspend, resume, lock) and idle time | `powerMonitor` | Missing. | +| Spell check | `spellCheck` | Missing. | +| Hardware acceleration switch | `gpuSettings` | Missing. | +| Display count | `hardware.getDisplayCount` | Missing. | +| Feature negotiation | `features.supports`, `declareSupported` | Missing. The web client asks which desktop features exist. | +| Crash reporting | `crashReporter`, `processUtils.setCrashInformation` | Missing. | +| Image conversion (HEIC, JXR) | `sysimg` | Missing. | +| Accessibility state | `accessibility.getEnabled` | Missing. | +| Game integrations | `riotGames`, `cs2Gsi`, `dotaGsi` | Missing. Out of scope for this program. | + +## Verification + +- `WebViewWindow/tests/linux_permission_test.sh`: a local page asks for the microphone and notifications. Without a host answer + the microphone is refused and notifications are at the default. With `--allow-permissions` both are granted. Passes on Linux. +- `WebViewWindow/tests/linux_example_test.sh`: the existing window checks still pass after the change. +- `tests/PagePermissions_test.cpp` (`cmake -DDW_BUILD_TESTS=ON`, then `ctest`): which addresses count as Discord's. Passes. +- Not checked: the Windows build of the permission hook (it compiles with MinGW, but hasn't run), a live Discord login, and any + voice or video call. + +## Plan + +1. Permissions for microphone, camera and notifications, by a hook in WebViewWindow (done; the hook is only in the local checkout so far). +2. Downloads and the save dialog (`fileManager`). +3. Settings and `safeStorage` through the host. +4. Badges and tray state from the page, through a bridge the page can call. +5. Voice and video. Needs a decision: the engine is a Node addon, so this either waits for a different approach or stays + out of scope. diff --git a/src/AppIcon.h b/src/AppIcon.h new file mode 100644 index 0000000..8708fc5 --- /dev/null +++ b/src/AppIcon.h @@ -0,0 +1,600 @@ +// The application icon, embedded so the program needs no file beside it. Generated from assets/discord.png, the 256-pixel size of +// Discord's own favicon. Regenerate it with the same bytes if the icon changes. +#pragma once + +#include + +inline constexpr unsigned char kAppIconBytes[] = { + 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x06, 0x00, 0x00, 0x00, 0x5c, 0x72, 0xa8, + 0x66, 0x00, 0x00, 0x24, 0x9e, 0x49, 0x44, 0x41, 0x54, 0x78, 0x9c, 0xed, 0xdd, 0x7f, 0x74, 0x54, + 0xf5, 0x9d, 0x37, 0xf0, 0xf7, 0xe7, 0xce, 0x4c, 0x12, 0x42, 0xc8, 0x24, 0x12, 0x34, 0x45, 0x28, + 0x31, 0x45, 0x02, 0x88, 0x92, 0x22, 0x6c, 0x90, 0x46, 0xf0, 0x47, 0x4e, 0x0b, 0xb5, 0xd5, 0xf8, + 0x03, 0x18, 0x5a, 0xd7, 0x87, 0xca, 0xc4, 0xd2, 0xae, 0x8f, 0xc7, 0xe7, 0xa9, 0xed, 0xc1, 0xdd, + 0xb6, 0x4b, 0x5d, 0xdd, 0xf5, 0xd8, 0xda, 0x76, 0xfb, 0x74, 0x7d, 0x28, 0x89, 0x2e, 0x8f, 0x47, + 0xeb, 0x04, 0xa8, 0x52, 0x6a, 0x57, 0xf4, 0xd0, 0x2a, 0x9e, 0x94, 0x1f, 0xc2, 0x22, 0x54, 0x14, + 0x50, 0x9a, 0x4d, 0x16, 0xb4, 0xa9, 0x40, 0x27, 0x13, 0x20, 0x99, 0x64, 0xe6, 0xde, 0xcf, 0xf3, + 0xc7, 0x24, 0xf2, 0x2b, 0x3f, 0xe6, 0xc7, 0xfd, 0x7d, 0x3f, 0xaf, 0x73, 0x3c, 0x02, 0x99, 0xb9, + 0xf7, 0x73, 0x73, 0xef, 0xf7, 0x73, 0x3f, 0xdf, 0xef, 0xbd, 0xf7, 0x7b, 0x09, 0xc2, 0xd1, 0xee, + 0xfc, 0x7a, 0xb4, 0x24, 0xa0, 0x2a, 0x15, 0xac, 0x60, 0x02, 0x31, 0x26, 0x80, 0xa9, 0x8c, 0x89, + 0xcb, 0x89, 0x51, 0x06, 0xa0, 0x04, 0x84, 0x12, 0x06, 0x15, 0x12, 0x50, 0x04, 0x70, 0x09, 0x00, + 0x80, 0xa9, 0x08, 0x84, 0xc0, 0xc5, 0x4b, 0xe3, 0x28, 0x03, 0x49, 0x02, 0x9d, 0x06, 0x10, 0x07, + 0xb8, 0x0b, 0x8c, 0x4e, 0x06, 0x4e, 0x80, 0xd0, 0x49, 0x4c, 0x1d, 0x4c, 0xdc, 0x01, 0xa0, 0x83, + 0x18, 0xc7, 0x34, 0x45, 0x3b, 0xb6, 0x7e, 0x6d, 0xe9, 0x09, 0x13, 0x37, 0x57, 0xe8, 0x8c, 0xac, + 0x0e, 0x40, 0x8c, 0x2c, 0xb4, 0x32, 0x5a, 0x80, 0xa4, 0x32, 0x95, 0x09, 0x33, 0x88, 0x31, 0x15, + 0xc0, 0x0c, 0x26, 0x54, 0x10, 0xa3, 0x12, 0x44, 0x63, 0x2c, 0x0d, 0x8e, 0x39, 0xca, 0x84, 0xff, + 0x26, 0xc6, 0x11, 0x26, 0xb4, 0x01, 0x38, 0x00, 0x8d, 0x0f, 0x68, 0x0a, 0x1f, 0xda, 0xd0, 0x58, + 0x7a, 0xda, 0xd2, 0xd8, 0xc4, 0x88, 0x24, 0x01, 0xd8, 0xcc, 0xe2, 0x86, 0x68, 0x91, 0x8f, 0x7c, + 0x73, 0x99, 0x79, 0x36, 0x01, 0xd5, 0x0c, 0xcc, 0x22, 0xa6, 0x8a, 0xc1, 0xcf, 0xd8, 0x36, 0xc6, + 0x48, 0x30, 0xf1, 0xfb, 0xc4, 0x38, 0xc4, 0x84, 0x9d, 0x04, 0xda, 0xa3, 0x42, 0xdd, 0x23, 0x49, + 0xc1, 0x5e, 0x24, 0x01, 0x58, 0x6c, 0x71, 0x43, 0xb4, 0x5c, 0x81, 0x72, 0x03, 0x80, 0x5a, 0x00, + 0x37, 0x10, 0xd3, 0x14, 0xc7, 0x35, 0xf6, 0x74, 0x31, 0x12, 0x00, 0xbf, 0xc7, 0x84, 0x16, 0x00, + 0x2d, 0x1a, 0xb4, 0x37, 0x36, 0x34, 0x96, 0x76, 0x58, 0x1d, 0x96, 0x97, 0x49, 0x02, 0x30, 0xd9, + 0xe2, 0x86, 0x68, 0x91, 0x0f, 0xbe, 0x1b, 0xc0, 0x5c, 0xc7, 0x84, 0x85, 0x04, 0xaa, 0xb2, 0x3a, + 0x26, 0x2b, 0x31, 0xf8, 0x30, 0x31, 0xb6, 0x80, 0x68, 0xab, 0x0a, 0xf5, 0x0d, 0xa9, 0x10, 0xcc, + 0x25, 0x09, 0xc0, 0x04, 0x4b, 0xc2, 0xd1, 0x09, 0x0a, 0x94, 0xbb, 0x18, 0xa8, 0x23, 0xc2, 0x4d, + 0x00, 0x8d, 0xb2, 0x3a, 0x26, 0x9b, 0xea, 0x01, 0xf3, 0x9b, 0x00, 0x6d, 0x82, 0x82, 0x2d, 0x91, + 0xb5, 0xc5, 0x6d, 0x56, 0x07, 0xe4, 0x76, 0x92, 0x00, 0x0c, 0x12, 0xba, 0xaf, 0xab, 0x82, 0x99, + 0xef, 0x22, 0xd0, 0x12, 0x00, 0x73, 0xac, 0x8e, 0xc7, 0xa1, 0x76, 0x00, 0xbc, 0x19, 0x44, 0x11, + 0x49, 0x06, 0xc6, 0x90, 0x04, 0xa0, 0xa3, 0x50, 0x38, 0x5a, 0x02, 0x52, 0xee, 0x06, 0xe8, 0x1e, + 0x48, 0xa3, 0xd7, 0xdb, 0x0e, 0x06, 0xff, 0x92, 0x35, 0x2d, 0xb2, 0xfe, 0x69, 0xb9, 0xf4, 0xa8, + 0x17, 0x49, 0x00, 0x39, 0xaa, 0x7f, 0x30, 0xea, 0x2f, 0x38, 0xe3, 0x5b, 0x08, 0x70, 0x18, 0x4c, + 0x5f, 0x74, 0xed, 0x00, 0x9e, 0x7d, 0xf4, 0x00, 0xfc, 0x1a, 0x40, 0x6b, 0xe2, 0xa3, 0xd5, 0xad, + 0x9b, 0x7e, 0x5a, 0x9a, 0xb4, 0x3a, 0x20, 0x27, 0x93, 0x04, 0x90, 0xa5, 0x25, 0xf7, 0xc5, 0x26, + 0x28, 0x1a, 0xc2, 0x00, 0x96, 0x83, 0x68, 0x92, 0xd5, 0xf1, 0x78, 0x12, 0xe3, 0x28, 0x88, 0x9f, + 0x22, 0xf2, 0xad, 0x7b, 0x61, 0x6d, 0x91, 0x5c, 0x4d, 0xc8, 0x82, 0x24, 0x80, 0x0c, 0x85, 0x1a, + 0x62, 0xb5, 0x0c, 0x5a, 0x49, 0x8c, 0x25, 0x72, 0xb6, 0xb7, 0x8d, 0x1e, 0x80, 0x5f, 0x63, 0xe0, + 0xd1, 0xe6, 0xc6, 0xe0, 0x1e, 0xab, 0x83, 0x71, 0x12, 0x49, 0x00, 0x69, 0xe8, 0x2f, 0xf3, 0xeb, + 0xc1, 0x7c, 0x3f, 0x88, 0x16, 0x58, 0x1d, 0x8f, 0x18, 0xd6, 0x0e, 0x00, 0x4f, 0x44, 0x1a, 0x8b, + 0x37, 0x59, 0x1d, 0x88, 0x13, 0x48, 0x02, 0x18, 0x46, 0x7f, 0xc3, 0xbf, 0x1b, 0x8c, 0xbf, 0x07, + 0xe1, 0x4a, 0xab, 0xe3, 0x11, 0x19, 0x79, 0x1b, 0xc0, 0xcf, 0xe0, 0x53, 0x23, 0x91, 0x35, 0xa5, + 0x71, 0xab, 0x83, 0xb1, 0x2b, 0x49, 0x00, 0x83, 0x90, 0x86, 0xef, 0x2a, 0x07, 0x01, 0x3c, 0x21, + 0x89, 0x60, 0x70, 0x92, 0x00, 0xce, 0x21, 0x0d, 0xdf, 0xd5, 0x0e, 0x02, 0x78, 0x24, 0xd2, 0x58, + 0x1c, 0xb1, 0x3a, 0x10, 0x3b, 0x91, 0x04, 0xd0, 0x6f, 0x69, 0xb8, 0xab, 0x8e, 0x80, 0x9f, 0x82, + 0x70, 0x95, 0xd5, 0xb1, 0x08, 0x43, 0xbd, 0x8d, 0x54, 0x22, 0xd8, 0x64, 0x75, 0x20, 0x76, 0xe0, + 0xf9, 0x04, 0xb0, 0xe4, 0xeb, 0xb1, 0xa9, 0x8a, 0x8a, 0x35, 0x32, 0xb8, 0xe7, 0x35, 0xfc, 0x2a, + 0x80, 0x55, 0x91, 0xc6, 0xe0, 0x3e, 0xab, 0x23, 0xb1, 0x92, 0x67, 0x13, 0x40, 0xea, 0xae, 0x3d, + 0xdf, 0xe3, 0x60, 0xdc, 0x2b, 0x97, 0xf3, 0x3c, 0xab, 0x07, 0xc0, 0xb3, 0x44, 0xca, 0x6a, 0xaf, + 0xde, 0x47, 0xe0, 0xc9, 0x04, 0x10, 0x0a, 0x77, 0x85, 0x41, 0x78, 0x02, 0x40, 0xa9, 0xd5, 0xb1, + 0x08, 0x5b, 0xf8, 0x33, 0x52, 0xdd, 0x82, 0x35, 0x56, 0x07, 0x62, 0x36, 0x4f, 0x25, 0x80, 0xfe, + 0x72, 0x7f, 0x1d, 0x88, 0x6a, 0xac, 0x8e, 0x45, 0xd8, 0x0f, 0x83, 0xff, 0x40, 0xc0, 0xfd, 0x5e, + 0xea, 0x16, 0x78, 0x22, 0x01, 0x84, 0x56, 0x46, 0x0b, 0x58, 0xf5, 0x7d, 0x97, 0x18, 0xdf, 0x91, + 0x72, 0x5f, 0x8c, 0xa0, 0x07, 0xa9, 0xcb, 0x86, 0x8f, 0x7b, 0xe1, 0xb2, 0xa1, 0xeb, 0x13, 0x40, + 0xa8, 0x21, 0x36, 0x17, 0x4c, 0xcf, 0x80, 0x30, 0xcd, 0xea, 0x58, 0x84, 0xa3, 0xbc, 0x0d, 0xf0, + 0xbd, 0x6e, 0xaf, 0x06, 0x5c, 0x9b, 0x00, 0xea, 0x1f, 0x8c, 0xfa, 0x0b, 0x4e, 0xfb, 0x56, 0x03, + 0x72, 0xd6, 0x17, 0x59, 0x73, 0x7d, 0x35, 0xe0, 0xca, 0x04, 0xb0, 0xf4, 0xbe, 0xae, 0xc9, 0xa4, + 0xf1, 0x73, 0xd2, 0xd7, 0x17, 0xba, 0x60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 0x60, 0xe6, + 0xfd, 0xa4, 0x28, 0xf5, 0x4e, 0xbb, 0x54, 0xe8, 0xa8, 0x04, 0xb0, 0xb4, 0x21, 0x36, 0x1b, 0xa0, + 0x17, 0x09, 0x98, 0x68, 0x75, 0x2c, 0x42, 0x0c, 0xe2, 0xa8, 0x06, 0xbe, 0x75, 0xbd, 0x83, 0xee, + 0x1e, 0x74, 0xcc, 0x20, 0x60, 0xa8, 0x21, 0xb6, 0x10, 0xa0, 0xdf, 0x4b, 0xe3, 0x17, 0x36, 0x36, + 0x51, 0x01, 0x6d, 0x4f, 0x1d, 0xab, 0xce, 0xe0, 0x88, 0x04, 0x10, 0x0a, 0xc7, 0x42, 0xfd, 0x67, + 0xfe, 0x31, 0x56, 0xc7, 0x22, 0xc4, 0x08, 0x46, 0x01, 0xf4, 0xe2, 0x92, 0x86, 0xd8, 0x5d, 0x56, + 0x07, 0x92, 0x0e, 0xdb, 0x27, 0x80, 0x50, 0x43, 0xd7, 0x43, 0x20, 0x7a, 0x01, 0x80, 0xbc, 0x50, + 0x53, 0x38, 0xc5, 0x28, 0x05, 0xb4, 0x61, 0x69, 0x43, 0xec, 0x21, 0xab, 0x03, 0x19, 0x89, 0xad, + 0x13, 0x40, 0x28, 0xdc, 0xb5, 0x1a, 0xc0, 0x0f, 0x2d, 0x0e, 0x43, 0x88, 0xac, 0x10, 0xe8, 0x87, + 0xa1, 0x86, 0xae, 0xd5, 0x56, 0xc7, 0x31, 0x1c, 0xdb, 0x26, 0x80, 0x50, 0xb8, 0x6b, 0x35, 0x08, + 0xff, 0x68, 0x75, 0x1c, 0x42, 0xe4, 0xe8, 0x1f, 0xed, 0x9c, 0x04, 0x6c, 0x99, 0x00, 0xa4, 0xf1, + 0x0b, 0x97, 0xb1, 0x6d, 0x12, 0xb0, 0x5d, 0x02, 0x90, 0xc6, 0x2f, 0x5c, 0xca, 0x96, 0x49, 0xc0, + 0x56, 0x09, 0x40, 0x1a, 0xbf, 0x70, 0x39, 0xdb, 0x25, 0x01, 0xdb, 0xdc, 0x08, 0x14, 0x6a, 0xe8, + 0x7a, 0x08, 0x32, 0xe0, 0x27, 0x3c, 0x80, 0xc1, 0xdf, 0x6e, 0x6e, 0x0c, 0xfe, 0xc8, 0xea, 0x38, + 0x00, 0x9b, 0x24, 0x80, 0x65, 0xe1, 0xd8, 0x5d, 0x4c, 0xb4, 0xc1, 0xea, 0x38, 0x84, 0x30, 0x8b, + 0xc6, 0xbc, 0x6c, 0x7d, 0x53, 0xd0, 0xf2, 0xd7, 0x94, 0x59, 0x9e, 0x00, 0xfa, 0xef, 0xf0, 0x7b, + 0x11, 0x72, 0x9d, 0x5f, 0x78, 0x4b, 0x0f, 0xc0, 0x77, 0x44, 0x1a, 0x83, 0x5b, 0xac, 0x0c, 0xc2, + 0xd2, 0x04, 0x10, 0x6a, 0x88, 0x55, 0x03, 0xb4, 0x1d, 0xd2, 0xf8, 0x85, 0x07, 0x31, 0xf8, 0x14, + 0x18, 0x37, 0x35, 0x37, 0x05, 0xf7, 0x58, 0x15, 0x83, 0x65, 0x09, 0x20, 0x14, 0x3e, 0x55, 0xc1, + 0xc4, 0x6f, 0xca, 0xbd, 0xfd, 0xc2, 0xe3, 0x8e, 0x82, 0x68, 0xbe, 0x55, 0x4f, 0x11, 0x5a, 0x92, + 0x00, 0x42, 0x2b, 0xa3, 0x05, 0x48, 0xfa, 0xde, 0x92, 0x47, 0x7a, 0x85, 0x00, 0x18, 0x78, 0x47, + 0x83, 0x3a, 0x6f, 0x43, 0x63, 0xe9, 0x69, 0xb3, 0xd7, 0x6d, 0xcd, 0x65, 0x40, 0x55, 0xd9, 0x24, + 0x8d, 0x5f, 0x88, 0x14, 0x02, 0xae, 0x56, 0xa0, 0x44, 0xea, 0x97, 0x47, 0xfd, 0x66, 0xaf, 0xdb, + 0xf4, 0x04, 0xb0, 0xb4, 0xa1, 0xeb, 0x51, 0x80, 0xbe, 0x60, 0xf6, 0x7a, 0x85, 0xb0, 0x33, 0x02, + 0xdd, 0x92, 0x1f, 0x50, 0x56, 0x9b, 0xbf, 0x5e, 0x13, 0xa5, 0x26, 0x51, 0xa4, 0x97, 0xcc, 0x5c, + 0xa7, 0x10, 0x4e, 0xc2, 0xe0, 0xc5, 0xcd, 0x8d, 0xc1, 0x8d, 0x66, 0xad, 0xcf, 0xb4, 0x04, 0xb0, + 0xf4, 0xbe, 0xae, 0xc9, 0xc4, 0xf8, 0x23, 0x64, 0xc4, 0x5f, 0x88, 0x21, 0x31, 0xf8, 0x14, 0x01, + 0x7f, 0x13, 0x69, 0x0c, 0x1e, 0x32, 0x63, 0x7d, 0xa6, 0x74, 0x01, 0x42, 0x2b, 0xa3, 0x05, 0xa4, + 0x61, 0x33, 0xa4, 0xf1, 0x0b, 0x31, 0x2c, 0x02, 0x8d, 0x61, 0x60, 0xd3, 0xe2, 0x86, 0x68, 0x91, + 0x19, 0xeb, 0x33, 0x25, 0x01, 0xb0, 0xaa, 0x34, 0xc9, 0xbc, 0xfd, 0x42, 0xa4, 0x87, 0x40, 0x55, + 0x0a, 0x2b, 0x6b, 0xcc, 0x58, 0x97, 0xe1, 0x09, 0x60, 0x59, 0xb8, 0x6b, 0xb9, 0xbc, 0xae, 0x4b, + 0x88, 0xcc, 0x10, 0xd1, 0x57, 0xcd, 0x78, 0x17, 0xa1, 0xa1, 0x63, 0x00, 0xa1, 0xf0, 0xa9, 0x0a, + 0x10, 0xbf, 0x07, 0x29, 0xfd, 0x85, 0xc8, 0x18, 0x83, 0x4f, 0x29, 0x44, 0xb3, 0x8c, 0x7c, 0x05, + 0x99, 0x61, 0x15, 0x40, 0x68, 0x65, 0xb4, 0x00, 0xd0, 0x22, 0x90, 0xc6, 0x2f, 0x44, 0x56, 0x08, + 0x34, 0x86, 0x35, 0x7e, 0xce, 0xc8, 0xfb, 0x03, 0x8c, 0xeb, 0x02, 0x24, 0x95, 0x55, 0xf2, 0x8a, + 0x6e, 0x21, 0x72, 0x44, 0x54, 0x93, 0x1f, 0x50, 0x0c, 0x7b, 0xf5, 0x98, 0x21, 0x5d, 0x80, 0x50, + 0xb8, 0xb3, 0x1a, 0xa4, 0xc8, 0x43, 0x3e, 0x42, 0xe8, 0x80, 0x81, 0x04, 0x81, 0xe7, 0x47, 0x1a, + 0x83, 0x3b, 0xf5, 0x5e, 0xb6, 0xee, 0x09, 0x20, 0xb4, 0x32, 0x5a, 0x00, 0xd5, 0xb7, 0x13, 0xc0, + 0x4c, 0xbd, 0x97, 0x2d, 0x84, 0x57, 0x31, 0xf8, 0x30, 0xf9, 0xb4, 0x6a, 0xbd, 0xdf, 0x3f, 0xa8, + 0x7f, 0x17, 0x20, 0xa9, 0xac, 0x82, 0x34, 0x7e, 0x21, 0x74, 0x45, 0xa0, 0x2a, 0x4e, 0xea, 0xdf, + 0x15, 0xd0, 0xb5, 0x02, 0x90, 0xd2, 0x5f, 0x08, 0xe3, 0xf4, 0x77, 0x05, 0xae, 0xd1, 0xf3, 0x2e, + 0x41, 0x7d, 0x2b, 0x00, 0xa2, 0x9f, 0x43, 0x1a, 0xbf, 0x10, 0x86, 0x20, 0x20, 0x00, 0xc6, 0x3a, + 0x3d, 0x97, 0xa9, 0x5b, 0x02, 0x08, 0x85, 0xbb, 0x56, 0x02, 0xf4, 0x39, 0xbd, 0x96, 0x27, 0x84, + 0x18, 0x04, 0x51, 0xcd, 0xd2, 0x86, 0x58, 0x58, 0xb7, 0xc5, 0xe9, 0xb1, 0x90, 0x50, 0x43, 0x57, + 0x39, 0x98, 0xf7, 0x81, 0xe8, 0x32, 0x3d, 0x96, 0x27, 0x84, 0x18, 0x56, 0x14, 0xac, 0x56, 0x46, + 0x9a, 0x4a, 0x3b, 0x73, 0x5d, 0x90, 0x3e, 0x15, 0x00, 0x63, 0xb5, 0x34, 0x7e, 0x21, 0x4c, 0x53, + 0x0a, 0x52, 0x1e, 0xd7, 0x63, 0x41, 0x39, 0x57, 0x00, 0x32, 0xf0, 0x27, 0x84, 0xf9, 0xf4, 0x1a, + 0x10, 0xcc,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0x40, 0xbc, + 0xd8, 0x4a, 0x00, 0x69, 0x25, 0x80, 0xb4, 0x2a, 0x80, 0x50, 0x43, 0x57, 0x39, 0x80, 0x56, 0xc8, + 0x43, 0x3f, 0x00, 0x80, 0xcb, 0xc6, 0x29, 0xb8, 0x75, 0x61, 0x00, 0x35, 0xd7, 0x06, 0x30, 0xba, + 0xd0, 0xd4, 0x17, 0x2c, 0x7f, 0x62, 0xdb, 0xf6, 0x04, 0xce, 0x74, 0x33, 0xc6, 0x97, 0x2b, 0x18, + 0x5b, 0x4a, 0x18, 0x37, 0x56, 0x41, 0x41, 0x81, 0x39, 0xb1, 0x9c, 0xe9, 0x66, 0x74, 0xc6, 0x18, + 0x7f, 0x39, 0xae, 0xe1, 0xf8, 0x49, 0x0d, 0x85, 0xa3, 0x08, 0xd7, 0xcf, 0x35, 0x3e, 0x01, 0x0c, + 0x26, 0x1e, 0x67, 0xfc, 0xbe, 0x25, 0x81, 0x37, 0xb7, 0x27, 0xa4, 0x2a, 0xe8, 0xc7, 0x40, 0x02, + 0xa0, 0xca, 0xe6, 0xc6, 0x31, 0xc7, 0x46, 0xfa, 0x6c, 0x9a, 0x15, 0x00, 0x2f, 0x07, 0xc8, 0xf3, + 0x8d, 0xff, 0x9a, 0xab, 0x7c, 0xb8, 0x6d, 0x61, 0x1e, 0xa6, 0x57, 0x19, 0xf6, 0x9e, 0x86, 0xb4, + 0x2d, 0x98, 0x67, 0x4d, 0x83, 0x03, 0x52, 0x83, 0x91, 0xa3, 0x0b, 0x09, 0x97, 0x7f, 0xca, 0x94, + 0x57, 0x4b, 0x0e, 0xab, 0xa0, 0x80, 0x3e, 0x19, 0x2f, 0xd8, 0x77, 0x20, 0x89, 0xdf, 0xbd, 0x99, + 0xc0, 0x9e, 0x7d, 0x19, 0xdf, 0x10, 0xe7, 0x2a, 0xa9, 0x27, 0x05, 0xb5, 0x30, 0xd2, 0x78, 0x56, + 0x67, 0xc4, 0x53, 0x46, 0xfd, 0xf2, 0xa8,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, + 0x97, 0xb3, 0xbf, 0x48, 0x19, 0x5d, 0x48, 0xb8, 0xb1, 0xd6, 0x3b, 0xcf, 0x08, 0x30, 0x50, 0x3d, + 0xf0, 0xe7, 0x73, 0x2a, 0x00, 0x4c, 0xb5, 0x24, 0x1a, 0x0b, 0x2c, 0xba, 0xd9, 0x3b, 0x3b, 0x5b, + 0xa4, 0xa7, 0x6e, 0x41, 0xc0, 0x33, 0x4f, 0x0a, 0x12, 0x61, 0xd6, 0xc0, 0x9f, 0x15, 0x20, 0x35, + 0x00, 0x48, 0x44, 0x53, 0xac, 0x0b, 0xc9, 0x3c, 0xb3, 0x75, 0x78, 0x4d, 0xb7, 0x70, 0x9f, 0xf2, + 0x4b, 0x15, 0xcc, 0xbc, 0xca, 0x1b, 0xf3, 0x05, 0x30, 0xa8, 0x22, 0xb4, 0x32, 0x5a, 0x00, 0xf4, + 0x27, 0x00, 0x45, 0x53, 0xa6, 0xc2, 0x23, 0x03, 0x80, 0x37, 0xcf, 0xf7, 0xc4, 0x66, 0x8a, 0x2c, + 0x7c, 0xe1, 0x46, 0x6f, 0x54, 0x86, 0x04, 0x04, 0x58, 0x55, 0xa6, 0x02, 0x03, 0x5d, 0x00, 0xa2, + 0x19, 0x96, 0x46, 0x64, 0x92, 0xb2, 0xb1, 0x84, 0xea, 0x19, 0x72, 0xe9, 0x4f, 0x0c, 0x6e, 0xc6, + 0x34, 0x1f, 0xca, 0xc6, 0x7a, 0x63, 0x6c, 0x88, 0x80, 0x19, 0xc0, 0x27, 0x09, 0x80, 0x3d, 0x91, + 0x00, 0xea, 0xe6, 0x7b, 0x23, 0xc3, 0x8b, 0xec, 0xf8, 0x7c, 0x84, 0x05, 0xd7, 0x79, 0xa3, 0x42, + 0x1c, 0x18, 0xf3, 0x53, 0x00, 0x80, 0x18, 0x15, 0x96, 0x46, 0x63, 0x92, 0xda, 0xb9, 0x72, 0xf6, + 0x17, 0xc3, 0x5b, 0x30, 0xcf, 0x33, 0x83, 0x81, 0x67, 0x2b, 0x00, 0x06, 0x26, 0x5b, 0x1b, 0x8b, + 0xf1, 0xae, 0xb9, 0xca, 0x87, 0xb1, 0xa5, 0xde, 0xd8, 0xb3, 0x22, 0x7b, 0xe3, 0xca, 0x14, 0xcc, + 0x98, 0xe6, 0x89, 0xc1, 0xc0, 0x0a, 0x60, 0xa0, 0x02, 0x00, 0x7d, 0xda, 0xd2, 0x50, 0x4c, 0x30, + 0x6f, 0x8e, 0x37, 0x4a, 0x3b, 0x91, 0x3b, 0x6f, 0x1c, 0x2b, 0x54, 0x09, 0x00, 0xca, 0x92, 0x15, + 0xd1, 0x32, 0x10, 0x4a, 0xad, 0x0e, 0xc7, 0x48, 0x01, 0x3f, 0x50, 0x73, 0xad, 0x94, 0xff, 0x22, + 0x3d, 0xb3, 0xab, 0xfd, 0xae, 0x7f, 0x9d, 0x18, 0x01, 0x63, 0xee, 0x5c, 0x11, 0x2d, 0x51, 0x08, + 0xca, 0xa0, 0xf3, 0x85, 0xbb, 0xc9, 0xec, 0x6a, 0xbf, 0xdc, 0xf9, 0x27, 0xd2, 0x36, 0xba, 0x90, + 0x30, 0xd3, 0x03, 0x57, 0x8b, 0xfc, 0x8a, 0x52, 0xa1, 0x80, 0xe0, 0xfa, 0x04, 0x70, 0xdd, 0xdf, + 0xb8, 0x7f, 0x67, 0x0a, 0x7d, 0x79, 0x64, 0x9e, 0x88, 0x09, 0x0a, 0x40, 0xe5, 0x23, 0x7f, 0xce, + 0xb9, 0x02, 0x7e, 0xe0, 0xea, 0x69, 0x9e, 0xd8, 0x99, 0x42, 0x47, 0x33, 0xaf, 0xf2, 0x42, 0x37, + 0x80, 0x26, 0x28, 0x44, 0x70, 0x75, 0x02, 0x98, 0x31, 0xcd, 0x27, 0xe5, 0xbf, 0xc8, 0xd8, 0xe8, + 0x42, 0x72, 0xfd, 0xd5, 0x00, 0x06, 0xca, 0x14, 0x06, 0xbb, 0x3a, 0x01, 0xd4, 0x5c, 0xeb, 0x85, + 0x11, 0x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7, 0xa9, 0x09, 0x00, 0x00, 0x7a, 0x93, 0xda, + 0x6a, 0x06, 0xff, 0xd6, 0xec, 0xf5, 0x0a, 0x61, 0x6f, 0xfc, 0x6a, 0x73, 0x63, 0xf0, 0xbb, 0x66, + 0xaf, 0xd5, 0xf4, 0x04, 0xb0, 0x69, 0x5d, 0x69, 0xd2, 0x07, 0x2d, 0x24, 0x33, 0x0a, 0x0b, 0xd1, + 0x8f, 0x79, 0x3f, 0x7c, 0x5a, 0xbd, 0x15, 0xab, 0x36, 0x6d, 0x10, 0xf0, 0x42, 0xa1, 0x70, 0xac, + 0x82, 0x81, 0x16, 0x22, 0xba, 0xdc, 0xaa, 0x18, 0x84, 0xb0, 0x1a, 0x83, 0x3f, 0x24, 0x42, 0xad, + 0xd1, 0xd7, 0xfb, 0x87, 0x62, 0x7a, 0x05, 0x30, 0x20, 0xd2, 0x14, 0x6c, 0x03, 0x50, 0xcf, 0xe0, + 0x53, 0x56, 0xc5, 0x20, 0x84, 0xb5, 0xb8, 0x87, 0x80, 0x2f, 0x59, 0xd5, 0xf8, 0x01, 0x0b, 0x13, + 0x00, 0x00, 0x34, 0x37, 0x05, 0xf7, 0x10, 0x78, 0x49, 0xff, 0xd3, 0x4e, 0x42, 0x78, 0x08, 0xf7, + 0x00, 0x7c, 0x87, 0x51, 0x0f, 0xf9, 0xa4, 0xcb, 0xd2, 0x04, 0x00, 0x00, 0x91, 0xc6, 0x92, 0x2d, + 0x60, 0xb9, 0x3c, 0x28, 0xbc, 0x85, 0x98, 0xef, 0x89, 0x34, 0x96, 0x6c, 0xb1, 0x3a, 0x0e, 0xcb, + 0x13, 0x00, 0x00, 0x44, 0x9a, 0x82, 0x11, 0x66, 0xed, 0xdb, 0x56, 0xc7, 0x21, 0x84, 0x19, 0x98, + 0xf9, 0xdb, 0x2f, 0x34, 0x95, 0x6c, 0xb4, 0x3a, 0x0e, 0xc0, 0x26, 0x09, 0x00, 0x00, 0x9a, 0x9b, + 0x4a, 0x7e, 0x04, 0xe6, 0x1f, 0x58, 0x1d, 0x87, 0x10, 0xc6, 0xe2, 0x1f, 0x34, 0x37, 0x05, 0x7f, + 0x64, 0x75, 0x14, 0x03, 0x6c, 0x93, 0x00, 0x00, 0x20, 0xd2, 0x14, 0x5c, 0x2d, 0x49, 0x40, 0xb8, + 0x17, 0xff, 0x20, 0xd2, 0x18, 0x5c, 0x6d, 0x75, 0x14, 0xe7, 0xb2, 0x55, 0x02, 0x00, 0x24, 0x09, + 0x08, 0xb7, 0xb2, 0x5f, 0xe3, 0x07, 0x6c, 0x98, 0x00, 0x00, 0x49, 0x02, 0xc2, 0x6d, 0xec, 0xd9, + 0xf8, 0x01, 0x9b, 0x26, 0x00, 0x40, 0x92, 0x80, 0x70, 0x0b, 0xfb, 0x36, 0x7e, 0xc0, 0xc2, 0x3b, + 0x01, 0xd3, 0xb5, 0x34, 0xdc, 0xf9, 0x10, 0x91, 0xf2, 0x43, 0xab, 0xe3, 0x10, 0x22, 0x53, 0xcc, + 0xfc, 0x6d, 0x3b, 0x0d, 0xf8, 0x0d, 0xc6, 0xf6, 0x09, 0x00, 0x00, 0x96, 0x35, 0xc4, 0xee, 0x62, + 0xe0, 0x59, 0x80, 0x46, 0x59, 0x1d, 0x8b, 0x10, 0x23, 0xe3, 0x1e, 0x30, 0xdf, 0x1b, 0x69, 0x2a, + 0x89, 0x58, 0x1d, 0xc9, 0x48, 0x1c, 0x91, 0x00, 0x00, 0x20, 0xd4, 0xd0, 0xb9, 0x10, 0xa0, 0x17, + 0x25, 0x09, 0x08, 0x3b, 0x63, 0xf0, 0x29, 0x02, 0x2f, 0xb1, 0xc3, 0x4d, 0x3e, 0xe9, 0x70, 0x4c, + 0x02, 0x00, 0x80, 0x50, 0x43, 0xac, 0x9a, 0x19, 0x2f, 0xcb, 0x03, 0x44, 0xc2, 0x8e, 0x18, 0xfc, + 0x21, 0x18, 0xf5, 0xcd, 0x4d, 0xc1, 0x3d, 0x56, 0xc7, 0x92, 0x2e, 0x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94, 0x74, 0x09, 0x84, 0x9e, 0xfa, 0x4b, 0xfe, 0x07, 0x22, 0x4d, 0x25, 0xeb, 0xac, 0x8e, + 0x45, 0x4f, 0xae, 0x4b, 0x00, 0x40, 0x6a, 0xc2, 0x51, 0x00, 0x11, 0x10, 0xd5, 0x58, 0x1d, 0x8b, + 0x70, 0x01, 0xe6, 0x5d, 0x4c, 0xb8, 0xdb, 0xcc, 0x17, 0x76, 0x98, 0xc5, 0x15, 0x5d, 0x80, 0x0b, + 0xf5, 0x5f, 0x2a, 0xbc, 0x21, 0xf5, 0x30, 0x91, 0xcc, 0x37, 0x28, 0xb2, 0xc4, 0x9c, 0x00, 0xf3, + 0x0f, 0xe2, 0x45, 0x5a, 0xad, 0x1b, 0x1b, 0x3f, 0xe0, 0xd2, 0x0a, 0xe0, 0x5c, 0xa1, 0x70, 0x67, + 0x35, 0x88, 0xd6, 0x01, 0x34, 0xd3, 0xea, 0x58, 0x84, 0x83, 0xa4, 0x5e, 0x66, 0xbb, 0x3c, 0xd2, + 0x14, 0xdc, 0x69, 0x75, 0x28, 0x46, 0x72, 0x65, 0x05, 0x70, 0xae, 0x48, 0x53, 0xc9, 0x3e, 0xf8, + 0xb4, 0xb9, 0x52, 0x0d, 0x88, 0xb4, 0x30, 0x27, 0x98, 0xf9, 0x31, 0xf8, 0xb5, 0x6a, 0xb7, 0x37, + 0x7e, 0xc0, 0x03, 0x15, 0xc0, 0xb9, 0x42, 0xe1, 0xce, 0x6a, 0x26, 0xfa, 0x39, 0x81, 0x3e, 0x67, + 0x75, 0x2c, 0xc2, 0x86, 0x98, 0x77, 0x69, 0x0a, 0x2f, 0x77, 0xcb, 0x08, 0x7f, 0x3a, 0x3c, 0x95, + 0x00, 0x06, 0x84, 0xc2, 0xb1, 0x95, 0x00, 0x56, 0x83, 0xe8, 0x32, 0xab, 0x63, 0x11, 0x36, 0xc0, + 0x88, 0x02, 0xda, 0x77, 0x22, 0x4d, 0x25, 0x4d, 0x56, 0x87, 0x62, 0x36, 0x4f, 0x26, 0x00, 0x00, + 0x08, 0x35, 0x44, 0xcb, 0xc1, 0xca, 0x6a, 0x10, 0xee, 0x91, 0x4b, 0x86, 0x1e, 0xc5, 0x9c, 0x00, + 0xf0, 0x0c, 0xa0, 0xad, 0x8a, 0x34, 0x95, 0x76, 0x5a, 0x1d, 0x8e, 0x15, 0x3c, 0x9b, 0x00, 0x06, + 0x84, 0xc2, 0x9d, 0xd5, 0x00, 0x3d, 0x0e, 0xa2, 0x2f, 0x58, 0x1d, 0x8b, 0x30, 0x11, 0xf3, 0x36, + 0x4d, 0xe1, 0x95, 0x5e, 0x2a, 0xf7, 0x07, 0xe3, 0xf9, 0x04, 0x30, 0xa0, 0xff, 0x99, 0x82, 0xd5, + 0x72, 0xb5, 0xc0, 0xe5, 0x98, 0xdf, 0x61, 0xf0, 0xff, 0x6e, 0x6e, 0x2a, 0xd9, 0x6a, 0x75, 0x28, + 0x76, 0x20, 0x09, 0xe0, 0x02, 0xa1, 0x86, 0xce, 0x10, 0x98, 0x56, 0xcb, 0x73, 0x05, 0x2e, 0xc3, + 0xfc, 0x27, 0x80, 0x1f, 0x8d, 0x17, 0xf1, 0x73, 0x4e, 0x7d, 0x72, 0xcf, 0x08, 0x92, 0x00, 0x06, + 0x11, 0x5a, 0x19, 0x2d, 0x40, 0x92, 0x42, 0x00, 0xad, 0x92, 0x44, 0xe0, 0x70, 0xd2, 0xf0, 0x87, + 0x25, 0x09, 0x60, 0x18, 0x9f, 0x24, 0x02, 0xa2, 0x07, 0xa5, 0x6b, 0xe0, 0x30, 0xd2, 0xf0, 0xd3, + 0x22, 0x09, 0x20, 0x4d, 0xa1, 0x86, 0xce, 0x7a, 0x30, 0xad, 0x92, 0xe7, 0x0b, 0x6c, 0x8e, 0x79, + 0x1b, 0x08, 0x3f, 0x8f, 0x8f, 0xd6, 0x36, 0x49, 0xc3, 0x1f, 0x99, 0x24, 0x80, 0x0c, 0x85, 0xc2, + 0x9d, 0xb3, 0x01, 0xfa, 0x2e, 0x08, 0x9f, 0x97, 0xcb, 0x87, 0x36, 0xc1, 0x9c, 0x60, 0xc2, 0x7a, + 0x30, 0xd6, 0x34, 0x37, 0x05, 0x5b, 0xac, 0x0e, 0xc7, 0x49, 0x24, 0x01, 0x64, 0xa9, 0xff, 0x3e, + 0x82, 0xe5, 0x00, 0xee, 0x87, 0xcc, 0x52, 0x6c, 0x0d, 0xe6, 0x76, 0x00, 0xeb, 0xd8, 0x87, 0xa6, + 0xe6, 0x5f, 0x04, 0x8f, 0x59, 0x1d, 0x8e, 0x13, 0x49, 0x02, 0xc8, 0x51, 0xfd, 0x83, 0x51, 0x7f, + 0xc1, 0x69, 0xaa, 0x03, 0x68, 0xa5, 0x54, 0x05, 0x26, 0x60, 0x4e, 0x30, 0xb0, 0x99, 0x80, 0x75, + 0xf1, 0x22, 0x6d, 0x8b, 0x94, 0xf9, 0xb9, 0x91, 0x04, 0xa0, 0xa3, 0x25, 0x2b, 0xa2, 0x65, 0xa4, + 0x28, 0x21, 0x62, 0xdc, 0x2d, 0x63, 0x05, 0x3a, 0x63, 0xde, 0xcd, 0xc0, 0xb3, 0x04, 0xed, 0x39, + 0xaf, 0xde, 0xb5, 0x67, 0x04, 0x49, 0x00, 0x06, 0x09, 0x35, 0x44, 0x2b, 0xc0, 0x4a, 0x08, 0x40, + 0xbd, 0x24, 0x83, 0x2c, 0xa5, 0x1a, 0xfd, 0x7a, 0x52, 0x78, 0x63, 0x64, 0x6d, 0x49, 0x9b, 0xd5, + 0xe1, 0xb8, 0x91, 0x24, 0x00, 0x13, 0x84, 0x1a, 0xa2, 0x15, 0xc4, 0xca, 0x42, 0x06, 0xea, 0x41, + 0x98, 0x2f, 0xdd, 0x84, 0xa1, 0x70, 0x0f, 0x33, 0x7e, 0x4f, 0xc0, 0x56, 0x0d, 0xda, 0xc6, 0xf5, + 0x4d, 0xa5, 0xd2, 0xaf, 0x37, 0x98, 0x24, 0x00, 0x93, 0x7d, 0xa5, 0x21, 0x5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0x72, 0x10, 0xca, 0x99, 0x51, 0x42, 0x40, 0x19, 0x80, 0x12, 0x80, 0x8a, + 0x01, 0x14, 0x30, 0xb8, 0x88, 0x08, 0x7e, 0x60, 0x90, 0xa4, 0xc1, 0x9c, 0x00, 0x21, 0x75, 0x76, + 0x66, 0xea, 0x04, 0x70, 0x1a, 0xe0, 0x6e, 0x00, 0x9d, 0x00, 0x3a, 0x41, 0x38, 0x01, 0x46, 0x07, + 0x80, 0x13, 0x4c, 0x38, 0x46, 0xcc, 0xc7, 0xd8, 0xc7, 0x6d, 0xcd, 0xbf, 0x90, 0x4b, 0x72, 0x4e, + 0xf6, 0xff, 0x01, 0xa1, 0x3f, 0x5d, 0xae, 0x79, 0x6f, 0x76, 0x61, 0x00, 0x00, 0x00, 0x00, 0x49, + 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82, +}; + +inline const std::string kAppIconPng(reinterpret_cast(kAppIconBytes), sizeof kAppIconBytes); diff --git a/src/Application.cpp b/src/Application.cpp new file mode 100644 index 0000000..1dabe93 --- /dev/null +++ b/src/Application.cpp @@ -0,0 +1,361 @@ +#include "Application.h" + +#include +#include +#include +#include +#include +#include +#include + +#include "DiscordWindow.h" +#include "Host.h" +#include "ProgressWindow.h" +#include "SettingsWindow.h" +#include "Sha256.h" + +namespace { + +std::filesystem::path behaviourFile() { + return settingsFolder() / "behaviour.json"; +} + +// Whether minimising keeps the window in the taskbar. The default is to keep it there. +bool loadKeepInTaskbar() { + try { + std::ifstream in(behaviourFile()); + if (!in) { + return true; + } + return Json::parse(in).at("keepInTaskbar").get(); + } catch (const std::exception&) { + return true; + } +} + +void saveKeepInTaskbar(bool keepInTaskbar) { + try { + std::filesystem::create_directories(behaviourFile().parent_path()); + std::ofstream out(behaviourFile(), std::ios::trunc); + out << Json{{"keepInTaskbar", keepInTaskbar}}.dump(2) << '\n'; + } catch (const std::exception&) { + // The choice still applies until the program closes, so a failed save isn't worth stopping for. + } +} + +std::string lowercase(std::string text) { + std::transform(text.begin(), text.end(), text.begin(), [](unsigned char c) { return static_cast(std::tolower(c)); }); + return text; +} + +const char* stageName(UpdateStage stage) { + switch (stage) { + case UpdateStage::Checking: return "checking"; + case UpdateStage::Current: return "current"; + case UpdateStage::Available: return "available"; + case UpdateStage::Failed: return "failed"; + case UpdateStage::Idle: break; + } + return "idle"; +} + +} // namespace + +Application::Application() : keepInTaskbar_(loadKeepInTaskbar()) {} + +Application::~Application() { + *alive_ = false; + progress_.reset(); + settings_.reset(); + discord_.reset(); +} + +void Application::run() { + discord_ = std::make_unique(*this); + discord_->open(); + discord_->restoreFrame(); + showTray(); + // Discord loads hidden, and the loading window covers the wait. The Discord window shows itself once its page is ready. + showLoading(); + checkForUpdateOnStart(); + runEventLoop(); +} + +void Application::showTray() { + trayShown_ = showTrayIcon( + "Discord", [this] { discord_->present(); }, + {{"Show Discord", [this] { discord_->present(); }}, {"Quit", [this] { discord_->close(); }}}); +} + +void Application::showLoading() { + ++jobId_; + loadingDiscord_ = true; + progress_ = std::make_unique( + *this, Json{{"title", "Discord"}, {"heading", "Loading Discord"}, {"note", ""}, {"cancellable", false}}); + progress_->open(); + progress_->present(); +} + +void Application::discordReady() { + if (loadingDiscord_) { + loadingDiscord_ = false; + dismissProgress(); + } +} + +void Application::discordClosed() { + stopEventLoop(); +} + +std::string Application::discordNoticeScript() const { + return std::string("window.gwSetUpdateNotice && window.gwSetUpdateNotice(") + (available_ ? "true" : "false") + ");"; +} + +void Application::setKeepInTaskbar(bool keepInTaskbar) { + keepInTaskbar_ = keepInTaskbar; + saveKeepInTaskbar(keepInTaskbar); + pushSettingsState(); +} + +void Application::openSettings() { + if (!settings_) { + settings_ = std::make_unique(*this); + settings_->open(); + } + settings_->present(); +} + +Json Application::settingsState() const { + return Json{ + {"keepInTaskbar", keepInTaskbar_}, + {"trayAvailable", trayShown_}, + {"update", Json{ + {"stage", stageName(stage_)}, + {"message", message_}, + {"available", available_.has_value()}, + {"busy", busy()}, + }}, + }; +} + +bool Application::busy() const { + return stage_ == UpdateStage::Checking || jobRunning_; +} + +void Application::setStage(UpdateStage stage, const std::string& message) { + stage_ = stage; + message_ = message; + pushSettingsState(); +} + +void Application::setAvailable(const UpdateInfo& update) { + available_ = update; + setStage(UpdateStage::Available, "Version r" + std::to_string(update.build) + " is available."); + pushDiscordNotice(); +} + +void Application::pushDiscordNotice() { + if (discord_) { + discord_->runScript(discordNoticeScript()); + } +} + +void Application::pushSettingsState() { + if (settings_) { + settings_->emit("state", settingsState()); + } +} + +void Application::checkForUpdateOnStart() { + auto alive = alive_; + std::thread([this, alive] { + const auto update = latestUpdate(); + if (!update) { + return; + } + runOnUiThread([this, alive, update = *update] { + if (*alive) { + setAvailable(update); + } + }); + }).detach(); +} + +void Application::checkForUpdate() { + if (busy()) { + return; + } + setStage(UpdateStage::Checking, "Checking for an update..."); + auto alive = alive_; + std::thread([this, alive] { + std::optional update; + std::string error; + try { + update = fetchUpdate(); + } catch (const std::exception& failure) { + error = failure.what(); + } + runOnUiThread([this, alive, update, error] { + if (!*alive) { + return; + } + if (!error.empty()) { + setStage(UpdateStage::Failed, error); + } else if (update) { + setAvailable(*update); + } else { + setStage(UpdateStage::Current, "You have the latest version (r" + std::to_string(kBuildNumber) + ")."); + } + }); + }).detach(); +} + +void Application::updateNow() { + if (!available_ || busy()) { + return; + } + const UpdateInfo info = *available_; + if (info.download.empty()) { + launchUrl(info.url); + return; + } + // Taken before the swap: once the new program is in place, the running file's path is the one that was moved aside. + const std::filesystem::path current = currentExecutable(); + ProgressJob job; + job.title = "Updating Discord Web View"; + job.heading = "Downloading r" + std::to_string(info.build); + job.note = "The program restarts once it's updated."; + job.cancellable = true; + job.failure = "The update failed"; + job.work = [info, current](const ProgressReport& report, const std::atomic& cancel) { + if (current.empty()) { + throw std::runtime_error("The program's file couldn't be found."); + } + const auto staged = current.parent_path() / (".new-" + current.filename().string()); + // A cancelled job removes what it has downloaded, so nothing is left beside the program. + const auto stopIfCancelled = [&cancel, &staged] { + if (cancel.load()) { + std::error_code ignored; + std::filesystem::remove(staged, ignored); + throw std::runtime_error(kCancelledMessage); + } + }; + report("Downloading the update...", std::nullopt); + if (!downloadTo(info.download, staged, cancel)) { + stopIfCancelled(); + throw std::runtime_error("The update couldn't be downloaded."); + } + stopIfCancelled(); + report("Checking the download...", 0.9); + const auto digest = sha256OfFile(staged); + if (!digest || *digest != lowercase(info.sha256)) { + std::error_code ignored; + std::filesystem::remove(staged, ignored); + throw std::runtime_error("The download didn't match GitHub's checksum."); + } + stopIfCancelled(); + report("Installing the update...", std::nullopt); + replaceExecutable(current, staged); + }; + job.done = [this, current](const std::optional& failure) { + if (!failure) { + restartAfterUpdate(current); + return; + } + // A cancelled update leaves the program as it was, with the update still offered. + if (*failure != kCancelledMessage) { + setStage(UpdateStage::Failed, *failure); + } + }; + runWithProgress(std::move(job)); +} + +void Application::restartAfterUpdate(const std::filesystem::path& program) { + restartProgram(program); + if (discord_) { + discord_->close(); + } +} + +void Application::runWithProgress(ProgressJob job) { + const std::uint64_t id = ++jobId_; + loadingDiscord_ = false; + cancel_ = std::make_shared>(false); + progress_ = std::make_unique( + *this, Json{{"title", job.title}, {"heading", job.heading}, {"note", job.note}, {"cancellable", job.cancellable}}); + progress_->open(); + progress_->present(); + jobRunning_ = true; + pushSettingsState(); + + auto cancel = cancel_; + auto alive = alive_; + std::thread([this, id, alive, cancel, job = std::move(job)]() mutable { + // Reports reach the progress window on the UI thread, and only while it's the window of this job. + ProgressReport report = [this, id, alive](const std::string& stage, std::optional fraction) { + runOnUiThread([this, id, alive, stage, fraction] { + if (*alive && id == jobId_ && progress_) { + progress_->update(stage, fraction); + } + }); + }; + std::optional failure; + try { + job.work(report, *cancel); + } catch (const std::exception& error) { + failure = error.what(); + } + runOnUiThread([this, id, alive, job, failure] { + if (*alive) { + finishJob(id, job, failure); + } + }); + }).detach(); +} + +void Application::finishJob(std::uint64_t id, const ProgressJob& job, const std::optional& failure) { + if (id != jobId_) { + return; + } + jobRunning_ = false; + const bool cancelled = failure && *failure == kCancelledMessage; + if (progress_) { + if (failure && !cancelled) { + // A failure stays on screen until the user closes the window. + progress_->failed(job.failure + ": " + *failure); + } else if (!failure && !job.finished.empty()) { + progress_->finished(job.finished); + } else { + dismissProgress(); + } + } + if (job.done) { + job.done(failure); + } + pushSettingsState(); +} + +void Application::cancelProgress() { + if (cancel_) { + *cancel_ = true; + } +} + +void Application::dismissProgress() { + // Closing a running job cancels it, and the window goes once the job has stopped. + if (jobRunning_ && cancel_) { + *cancel_ = true; + } + if (!progress_) { + return; + } + // The window is removed on a later turn of the event loop, since it may be the one calling. + const std::uint64_t id = jobId_; + auto alive = alive_; + runOnUiThread([this, alive, id] { + if (*alive && id == jobId_) { + progress_.reset(); + } + }); +} + diff --git a/src/Application.h b/src/Application.h new file mode 100644 index 0000000..3ad378f --- /dev/null +++ b/src/Application.h @@ -0,0 +1,96 @@ +// The program's windows and what they share: the Discord window, the settings window, the progress window, the tray icon, the saved +// settings, and the update. The windows call back into it, and it pushes state to them. +#pragma once + +#include +#include +#include +#include +#include +#include +#include + +#include "Progress.h" +#include "UpdateCheck.h" +#include "WebViewWindow.h" + +class DiscordWindow; +class SettingsWindow; +class ProgressWindow; + +// Where the update check and the update are. +enum class UpdateStage { Idle, Checking, Current, Available, Failed }; + +// A job the progress window shows while it runs. Done gets the failure, or nothing when the job finished. +struct ProgressJob { + std::string title; + std::string heading; + std::string note; + bool cancellable = false; + // The line shown above a failure's reason. + std::string failure; + // Shown when the job finishes, and kept on screen until the user closes the window. Empty closes the window at once. + std::string finished; + ProgressWork work; + std::function& failure)> done; +}; + +class Application { +public: + Application(); + ~Application(); + Application(const Application&) = delete; + Application& operator=(const Application&) = delete; + + // Opens the Discord window, which loads Discord directly while a loading window covers it, puts the window where it was, adds the + // tray icon, checks for an update in the background, and runs until the Discord window closes. + void run(); + + // Settings. The choices are saved as they change. + bool keepInTaskbar() const { return keepInTaskbar_; } + bool trayShown() const { return trayShown_; } + void setKeepInTaskbar(bool keepInTaskbar); + void openSettings(); + + // Called by the Discord window. + void discordReady(); + void discordClosed(); + // The script that shows or hides the Discord page's update notice, for the state as it is now. + std::string discordNoticeScript() const; + + // Called by the settings window and the progress window. + void checkForUpdate(); + void updateNow(); + void cancelProgress(); + void dismissProgress(); + Json settingsState() const; + +private: + void showTray(); + void showLoading(); + void checkForUpdateOnStart(); + void runWithProgress(ProgressJob job); + void finishJob(std::uint64_t id, const ProgressJob& job, const std::optional& failure); + void restartAfterUpdate(const std::filesystem::path& program); + void setStage(UpdateStage stage, const std::string& message); + void setAvailable(const UpdateInfo& update); + void pushDiscordNotice(); + void pushSettingsState(); + bool busy() const; + + std::unique_ptr discord_; + std::unique_ptr settings_; + std::unique_ptr progress_; + bool keepInTaskbar_ = true; + bool trayShown_ = false; + bool loadingDiscord_ = false; + std::optional available_; + UpdateStage stage_ = UpdateStage::Idle; + std::string message_; + // Whether a job is running, and the id of the latest job or loading window, so one that was replaced reports to nobody. + bool jobRunning_ = false; + std::uint64_t jobId_ = 0; + std::shared_ptr> cancel_; + // Cleared when the application is destroyed, so a background thread that finishes after that does nothing. + std::shared_ptr> alive_ = std::make_shared>(true); +}; diff --git a/src/DiscordWindow.cpp b/src/DiscordWindow.cpp new file mode 100644 index 0000000..becca47 --- /dev/null +++ b/src/DiscordWindow.cpp @@ -0,0 +1,154 @@ +#include "DiscordWindow.h" + +#include +#include +#include +#include + +#include "Application.h" +#include "Host.h" +#include "PageScript.h" +#include "PagePermissions.h" + +namespace { + +constexpr const char* kDiscordUrl = "https://discord.com/app"; +constexpr int kMinWidth = 480; +constexpr int kMinHeight = 360; + +// Opens a web address in the default browser, when it's an http or https address. +void openInBrowser(const std::string& url) { + if (url.rfind("http://", 0) != 0 && url.rfind("https://", 0) != 0) { + return; + } + launchUrl(url); +} + +} // namespace + +namespace { + +std::filesystem::path frameFile() { + return settingsFolder() / "window.json"; +} + +} // namespace + +DiscordWindow::DiscordWindow(Application& app) : WebViewWindow(WindowOptions{ + .title = "Discord", + .width = 1280, + .height = 800, + .minWidth = kMinWidth, + .minHeight = kMinHeight, + // The library draws the resize strips along the edges, so the page doesn't. + .resizeEdges = true, + // Discord's page is opaque, so there is nothing to see through. + .transparent = false, + .hardwareAcceleration = HardwareAcceleration::Always, + }), + app_(app) { + auto& methods = handler(); + methods.on("moveDrag", [](WebViewWindow& window, const Json&, const Reply& reply) { + window.beginMove(); + reply.result(nullptr); + }); + methods.on("minimize", [](WebViewWindow& window, const Json&, const Reply& reply) { + // With the tray icon shown and the taskbar not wanted, minimising hides the window to the tray instead. Its web view is kept, + // so it comes back without loading Discord again. + auto& self = static_cast(window); + if (!self.app_.keepInTaskbar() && self.app_.trayShown()) { + window.hide(); + window.keepWebView(); + } else { + window.minimize(); + } + reply.result(nullptr); + }); + methods.on("openSettings", [](WebViewWindow& window, const Json&, const Reply& reply) { + static_cast(window).app_.openSettings(); + reply.result(nullptr); + }); + methods.on("toggleMaximize", [](WebViewWindow& window, const Json&, const Reply& reply) { + window.toggleMaximize(); + reply.result(nullptr); + }); + methods.on("close", [](WebViewWindow& window, const Json&, const Reply& reply) { + window.close(); + reply.result(nullptr); + }); + methods.on("openDevTools", [](WebViewWindow& window, const Json&, const Reply& reply) { + window.openDevTools(); + reply.result(nullptr); + }); + methods.on("openExternal", [](WebViewWindow&, const Json& args, const Reply& reply) { + openInBrowser(args.at(0).get()); + reply.result(nullptr); + }); +} + +std::string DiscordWindow::devUrl() const { + return kDiscordUrl; +} + +std::string DiscordWindow::title() const { + return "Discord"; +} + +void DiscordWindow::restoreFrame() { + try { + std::ifstream in(frameFile()); + if (in) { + const Json saved = Json::parse(in); + const SavedFrame frame{saved.at("x").get(), saved.at("y").get(), saved.at("width").get(), + saved.at("height").get()}; + // The library keeps the window inside its monitor's work area, so a saved frame that's now off the screen is brought back in. + resize(std::max(frame.width, kMinWidth), std::max(frame.height, kMinHeight)); + move(frame.x, frame.y); + lastSaved_ = frame; + } + } catch (const std::exception&) { + // A missing or unreadable file means the window opens where it would by default. + } + frameRestored_ = true; +} + +void DiscordWindow::onPageLoaded() { + runScript(kPageScript); + runScript(app_.discordNoticeScript()); +} + +void DiscordWindow::onPageReady() { + app_.discordReady(); +} + +// Discord's own page gets the microphone, camera and notifications; see PagePermissions. +std::optional DiscordWindow::onPermissionRequest(PagePermission permission, const std::string& pageUrl) { + return discordPermission(permission, pageUrl); +} + +void DiscordWindow::onClosed() { + app_.discordClosed(); +} + +// Saves the frame after the user moves or resizes the window. Changes before restoreFrame are the window's own starting frame. +void DiscordWindow::onFrameChanged() { + if (!frameRestored_) { + return; + } + const auto bounds = frame(); + const auto size = frameUnscaled(); + if (!bounds || !size) { + return; + } + const SavedFrame current{bounds->x, bounds->y, size->first, size->second}; + if (!lastSaved_ || !(*lastSaved_ == current)) { + try { + std::filesystem::create_directories(frameFile().parent_path()); + std::ofstream out(frameFile(), std::ios::trunc); + out << Json{{"x", current.x}, {"y", current.y}, {"width", current.width}, {"height", current.height}}.dump(2) << '\n'; + } catch (const std::exception&) { + // Failing to save the frame isn't worth stopping the program for. + } + lastSaved_ = current; + } +} diff --git a/src/DiscordWindow.h b/src/DiscordWindow.h new file mode 100644 index 0000000..f243eab --- /dev/null +++ b/src/DiscordWindow.h @@ -0,0 +1,45 @@ +// The window that shows Discord's web client. Discord loads in it directly, hidden until its page reports ready, so the loading window +// covers the wait without a second load. +#pragma once + +#include +#include + +#include "WebViewWindow.h" + +class Application; + +class DiscordWindow : public WebViewWindow { +public: + // The window's position on the screen and its size without the UI scale, as the window saved them. + struct SavedFrame { + int x = 0; + int y = 0; + int width = 0; + int height = 0; + + bool operator==(const SavedFrame& other) const { + return x == other.x && y == other.y && width == other.width && height == other.height; + } + }; + + explicit DiscordWindow(Application& app); + + // Puts the window where it was last saved, at the size it had. Called once, after open. + void restoreFrame(); + + std::string devUrl() const override; + std::string title() const override; + +protected: + void onPageLoaded() override; + void onPageReady() override; + void onClosed() override; + void onFrameChanged() override; + std::optional onPermissionRequest(PagePermission permission, const std::string& pageUrl) override; + +private: + Application& app_; + bool frameRestored_ = false; + std::optional lastSaved_; +}; diff --git a/src/Host.h b/src/Host.h new file mode 100644 index 0000000..75ab103 --- /dev/null +++ b/src/Host.h @@ -0,0 +1,12 @@ +// The desktop functions each platform's host file defines, for the program's own use. + +#pragma once + +#include +#include + +// Opens a web address in the default browser. The address is never run through a shell. +void launchUrl(const std::string& url); + +// The folder the program keeps its settings in. +std::filesystem::path settingsFolder(); diff --git a/src/Host.linux.cpp b/src/Host.linux.cpp index deece0d..6fc3e69 100644 --- a/src/Host.linux.cpp +++ b/src/Host.linux.cpp @@ -5,12 +5,19 @@ #include #include +#include +#include +#include + #include #include #include #include +#include #include +#include #include +#include #include "UpdateCheck.h" #include "WebViewWindow.h" @@ -86,3 +93,95 @@ std::optional httpGet(const std::string& url) { } return body; } + +const char* releaseAssetName() { + return "discord-webview-linux"; +} + +std::filesystem::path currentExecutable() { + std::error_code error; + const auto self = std::filesystem::read_symlink("/proc/self/exe", error); + return error ? std::filesystem::path() : self; +} + +bool downloadTo(const std::string& url, const std::filesystem::path& dest, const std::atomic& cancel) { + const std::string target = dest.string(); + std::vector arguments{"curl", "-sfL", "--max-time", "600", "-o", target, url}; + std::vector argv; + for (const std::string& argument : arguments) { + argv.push_back(const_cast(argument.c_str())); + } + argv.push_back(nullptr); + pid_t pid = 0; + bool ok = false; + if (posix_spawnp(&pid, argv[0], nullptr, nullptr, argv.data(), environ) == 0) { + // The child is polled, so a cancel stops the download part way through rather than when it finishes. + for (;;) { + int status = 0; + const pid_t finished = waitpid(pid, &status, WNOHANG); + if (finished == pid) { + ok = WIFEXITED(status) && WEXITSTATUS(status) == 0; + break; + } + if (finished < 0) { + break; + } + if (cancel.load()) { + kill(pid, SIGTERM); + waitpid(pid, &status, 0); + break; + } + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + } + } + if (!ok) { + std::error_code error; + std::filesystem::remove(dest, error); + } + return ok; +} + +void replaceExecutable(const std::filesystem::path& current, const std::filesystem::path& staged) { + namespace fs = std::filesystem; + const fs::path old = current.parent_path() / (".old-" + current.filename().string()); + std::error_code error; + fs::permissions(staged, + fs::perms::owner_all | fs::perms::group_read | fs::perms::group_exec | fs::perms::others_read | fs::perms::others_exec, + fs::perm_options::replace, error); + if (error) { + fs::remove(staged, error); + throw std::runtime_error("The update couldn't be made runnable: " + error.message()); + } + // The running program is moved aside rather than overwritten, so a failed swap can be undone. + fs::remove(old, error); + fs::rename(current, old, error); + if (error) { + fs::remove(staged, error); + throw std::runtime_error("The program couldn't be moved aside for the update: " + error.message()); + } + fs::rename(staged, current, error); + if (error) { + std::error_code restore; + fs::rename(old, current, restore); + fs::remove(staged, restore); + throw std::runtime_error("The update couldn't be put in place: " + error.message()); + } +} + +void restartProgram(const std::filesystem::path& program) { + const std::string path = program.string(); + char* argv[] = {const_cast(path.c_str()), nullptr}; + pid_t pid = 0; + if (posix_spawn(&pid, path.c_str(), nullptr, nullptr, argv, environ) == 0) { + // Reaped off the UI thread, so the new copy isn't left a zombie if this one keeps running for a moment. + std::thread([pid] { + int status = 0; + waitpid(pid, &status, 0); + }).detach(); + } +} + +void removeUpdateLeftovers(const std::filesystem::path& current) { + std::error_code error; + std::filesystem::remove(current.parent_path() / (".old-" + current.filename().string()), error); +} diff --git a/src/Host.windows.cpp b/src/Host.windows.cpp index b9f6683..6454684 100644 --- a/src/Host.windows.cpp +++ b/src/Host.windows.cpp @@ -2,11 +2,15 @@ #include +#include #include #include #include +#include #include +#include #include +#include #include "UpdateCheck.h" #include "WebViewWindow.h" @@ -86,3 +90,90 @@ std::optional httpGet(const std::string& url) { } return body; } + +const char* releaseAssetName() { + return "discord-webview-windows.exe"; +} + +std::filesystem::path currentExecutable() { + wchar_t path[MAX_PATH * 4]; + const DWORD length = GetModuleFileNameW(nullptr, path, static_cast(std::size(path))); + if (length == 0 || length >= std::size(path)) { + return {}; + } + return std::filesystem::path(std::wstring(path, length)); +} + +bool downloadTo(const std::string& url, const std::filesystem::path& dest, const std::atomic& cancel) { + // curl.exe ships with Windows 10 1803 and later. It's started without a console, as httpGet does. + std::wstring command = L"curl.exe -sfL --max-time 600 -o \"" + dest.wstring() + L"\" \"" + toWide(url) + L"\""; + STARTUPINFOW startup{}; + startup.cb = sizeof(startup); + PROCESS_INFORMATION process{}; + const BOOL started = CreateProcessW(nullptr, command.data(), nullptr, nullptr, FALSE, CREATE_NO_WINDOW, nullptr, nullptr, + &startup, &process); + bool ok = false; + if (started) { + // The child is polled, so a cancel stops the download part way through rather than when it finishes. + for (;;) { + const DWORD wait = WaitForSingleObject(process.hProcess, 100); + if (wait == WAIT_OBJECT_0) { + DWORD exitCode = 1; + GetExitCodeProcess(process.hProcess, &exitCode); + ok = exitCode == 0; + break; + } + if (wait != WAIT_TIMEOUT) { + break; + } + if (cancel.load()) { + TerminateProcess(process.hProcess, 1); + WaitForSingleObject(process.hProcess, INFINITE); + break; + } + } + CloseHandle(process.hThread); + CloseHandle(process.hProcess); + } + if (!ok) { + std::error_code error; + std::filesystem::remove(dest, error); + } + return ok; +} + +void replaceExecutable(const std::filesystem::path& current, const std::filesystem::path& staged) { + namespace fs = std::filesystem; + // Windows locks a running exe against deleting, but not against renaming, so the running one is renamed aside. + const fs::path old = current.parent_path() / ".old.exe"; + std::error_code error; + fs::remove(old, error); + fs::rename(current, old, error); + if (error) { + fs::remove(staged, error); + throw std::runtime_error("The program couldn't be moved aside for the update: " + error.message()); + } + fs::rename(staged, current, error); + if (error) { + std::error_code restore; + fs::rename(old, current, restore); + fs::remove(staged, restore); + throw std::runtime_error("The update couldn't be put in place: " + error.message()); + } +} + +void restartProgram(const std::filesystem::path& program) { + std::wstring command = L"\"" + program.wstring() + L"\""; + STARTUPINFOW startup{}; + startup.cb = sizeof(startup); + PROCESS_INFORMATION process{}; + if (CreateProcessW(nullptr, command.data(), nullptr, nullptr, FALSE, 0, nullptr, nullptr, &startup, &process)) { + CloseHandle(process.hThread); + CloseHandle(process.hProcess); + } +} + +void removeUpdateLeftovers(const std::filesystem::path& current) { + std::error_code error; + std::filesystem::remove(current.parent_path() / ".old.exe", error); +} diff --git a/src/PagePermissions.cpp b/src/PagePermissions.cpp new file mode 100644 index 0000000..7287edc --- /dev/null +++ b/src/PagePermissions.cpp @@ -0,0 +1,42 @@ +#include "PagePermissions.h" + +#include +#include + +bool isDiscordAddress(const std::string& url) { + const std::string scheme = "https://"; + if (url.size() <= scheme.size()) { + return false; + } + std::string lower = url; + std::transform(lower.begin(), lower.end(), lower.begin(), [](unsigned char c) { return static_cast(std::tolower(c)); }); + if (lower.rfind(scheme, 0) != 0) { + return false; + } + // The host runs to the first '/', '?' or '#', and drops any port. + std::string host = lower.substr(scheme.size(), lower.find_first_of("/?#", scheme.size()) - scheme.size()); + if (const auto colon = host.find(':'); colon != std::string::npos) { + host.erase(colon); + } + constexpr const char* kDomain = "discord.com"; + if (host == kDomain) { + return true; + } + const std::string suffix = std::string(".") + kDomain; + return host.size() > suffix.size() && host.compare(host.size() - suffix.size(), suffix.size(), suffix) == 0; +} + +std::optional discordPermission(PagePermission permission, const std::string& pageUrl) { + if (!isDiscordAddress(pageUrl)) { + return std::nullopt; + } + switch (permission) { + case PagePermission::Microphone: + case PagePermission::Camera: + case PagePermission::Notifications: + return true; + case PagePermission::Other: + return std::nullopt; + } + return std::nullopt; +} diff --git a/src/PagePermissions.h b/src/PagePermissions.h new file mode 100644 index 0000000..be75424 --- /dev/null +++ b/src/PagePermissions.h @@ -0,0 +1,14 @@ +// The page permissions the host gives Discord's web client. Only Discord's own address is answered: the microphone, camera and +// notifications are allowed there, and every other request keeps the platform's default. +#pragma once + +#include +#include + +#include "WebViewWindow.h" + +// The answer for a permission request from a page at pageUrl: true to allow, or nothing to leave the platform's default in place. +std::optional discordPermission(PagePermission permission, const std::string& pageUrl); + +// Whether the address is an https address on discord.com or one of its subdomains. +bool isDiscordAddress(const std::string& url); diff --git a/src/PageScript.h b/src/PageScript.h index 06695e7..fe0753b 100644 --- a/src/PageScript.h +++ b/src/PageScript.h @@ -4,14 +4,17 @@ inline constexpr const char* kPageScript = R"JS( (() => { + const install = () => { // The window starts on about:blank, which must not count as the page being ready. if (!/^https?:$/.test(location.protocol) || window.__gwDiscordFrame) return; window.__gwDiscordFrame = true; const BAR = 28; + // WebView2 (Windows) and WebKitGTK (Linux) expose the host under different names. + const bridge = () => (window.chrome && window.chrome.webview) || window.webkit.messageHandlers.host; const post = (method, args) => { try { - window.webkit.messageHandlers.host.postMessage(JSON.stringify({id: Date.now(), method, args})); + bridge().postMessage(JSON.stringify({id: Date.now(), method, args})); } catch (e) {} }; window.hostReceive = window.hostReceive || (() => {}); @@ -21,7 +24,8 @@ inline constexpr const char* kPageScript = R"JS( html { height: 100%; } body { margin-top: ${BAR}px !important; height: calc(100vh - ${BAR}px) !important; overflow: hidden !important; } #app-mount { height: calc(100vh - ${BAR}px) !important; } - #gw-titlebar { position: fixed; top: 0; left: 0; right: 0; height: ${BAR}px; z-index: 2147483647; display: flex; + /* One below the library's resize strips (2147483647), so they stay on top of the bar's top edge. */ + #gw-titlebar { position: fixed; top: 0; left: 0; right: 0; height: ${BAR}px; z-index: 2147483646; display: flex; align-items: stretch; background: #1e1f22; color: #dbdee1; font: 12px sans-serif; user-select: none; cursor: default; } #gw-titlebar .gw-title { flex: 1; min-width: 0; display: flex; align-items: center; padding: 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } @@ -29,7 +33,6 @@ inline constexpr const char* kPageScript = R"JS( #gw-titlebar button:hover { background: #35373c; } #gw-titlebar button.gw-close:hover { background: #da373c; color: #fff; } #gw-titlebar svg { width: 10px; height: 10px; stroke: currentColor; fill: none; stroke-width: 1; } - .gw-edge { position: fixed; z-index: 2147483646; } `; document.documentElement.appendChild(style); @@ -54,45 +57,38 @@ inline constexpr const char* kPageScript = R"JS( b.addEventListener('click', () => post(method, [])); bar.appendChild(b); }; + // Opens the window behaviour dialog, which is built below. + const behaviour = document.createElement('button'); + behaviour.type = 'button'; + behaviour.id = 'gw-behaviour'; + behaviour.setAttribute('aria-label', 'Settings'); + behaviour.title = 'Settings'; + behaviour.innerHTML = ''; + bar.appendChild(behaviour); button('Minimise', 'M1 5.5h8', 'minimize'); button('Maximise', 'M1.5 1.5h7v7h-7z', 'toggleMaximize'); button('Close', 'M1.5 1.5l7 7M8.5 1.5l-7 7', 'close', 'gw-close'); document.body.appendChild(bar); - // Adds a button to the bar that opens a newer release's page. The host calls it when a newer release exists, and again on each - // page load, since the bar is rebuilt with the page. - window.gwShowUpdate = href => { - if (document.getElementById('gw-update')) return; - const b = document.createElement('button'); - b.id = 'gw-update'; - b.type = 'button'; - b.textContent = 'Update available'; - b.title = 'Open the download page for the newer version'; - b.style.cssText = 'width: auto; padding: 0 10px; color: #f0b232; font: 12px sans-serif;'; - b.addEventListener('click', () => post('openExternal', [href])); - bar.insertBefore(b, bar.querySelector('button')); + // The settings button and the update notice open the settings window, which the host runs. + behaviour.addEventListener('click', () => post('openSettings', [])); + // The host says whether a newer release is known. The notice is a button on the bar that opens the settings window. + window.gwSetUpdateNotice = available => { + const notice = document.getElementById('gw-update'); + if (available && !notice) { + const b = document.createElement('button'); + b.id = 'gw-update'; + b.type = 'button'; + b.textContent = 'Update available'; + b.title = 'Open settings to update'; + b.style.cssText = 'width: auto; padding: 0 10px; color: #f0b232; font: 12px sans-serif;'; + b.addEventListener('click', () => post('openSettings', [])); + bar.insertBefore(b, bar.querySelector('button')); + } else if (!available && notice) { + notice.remove(); + } }; - // Resize zones, numbered as the host's ResizeEdge: NW, N, NE, W, E, SW, S, SE. The top edge is the bar's, so only its corners. - const zones = [ - [0, 'left:0;top:0;width:6px;height:6px;cursor:nwse-resize'], - [2, 'right:0;top:0;width:6px;height:6px;cursor:nesw-resize'], - [3, 'left:0;top:6px;bottom:6px;width:6px;cursor:ew-resize'], - [4, 'right:0;top:6px;bottom:6px;width:6px;cursor:ew-resize'], - [5, 'left:0;bottom:0;width:6px;height:6px;cursor:nesw-resize'], - [6, 'left:6px;right:6px;bottom:0;height:6px;cursor:ns-resize'], - [7, 'right:0;bottom:0;width:6px;height:6px;cursor:nwse-resize'], - ]; - for (const [edge, place] of zones) { - const z = document.createElement('div'); - z.className = 'gw-edge'; - z.style.cssText = place; - z.addEventListener('mousedown', e => { - if (e.button === 0) post('resizeDrag', [edge]); - }); - document.body.appendChild(z); - } - // Keeps the bar's title in step with the page's. new MutationObserver(() => { title.textContent = document.title || 'Discord'; }) .observe(document.head || document.documentElement, {subtree: true, childList: true, characterData: true}); @@ -142,6 +138,33 @@ inline constexpr const char* kPageScript = R"JS( }, true); // Tells the host the frame is in place: the window's onPageReady runs for it. - post('ready', []); + // The window is shown when the page is ready. Discord draws its app into #app-mount after its scripts run, so that's the signal, with a + // limit so a page that never draws doesn't hold the window back. + let reported = false; + const reportReady = () => { + if (reported) return; + reported = true; + post('ready', []); + }; + const mountDrawn = () => { + const mount = document.getElementById('app-mount'); + return !!mount && mount.children.length > 0; + }; + if (mountDrawn()) { + reportReady(); + } else { + const drawn = new MutationObserver(() => { + if (mountDrawn()) { + drawn.disconnect(); + reportReady(); + } + }); + drawn.observe(document.documentElement, {childList: true, subtree: true}); + setTimeout(reportReady, 30000); + } + }; + // The page is injected as its navigation completes, and that can come before the document has a body to build the bar in. + if (document.body) install(); + else document.addEventListener('DOMContentLoaded', install, {once: true}); })(); )JS"; diff --git a/src/Pages.h b/src/Pages.h new file mode 100644 index 0000000..7c27e9a --- /dev/null +++ b/src/Pages.h @@ -0,0 +1,171 @@ +// The pages of the program's own windows: settings, progress and loading. Each is a frameless window whose page draws its title bar, +// and each talks to the host through the same bridge the Discord page uses. +#pragma once + +#include + +namespace pages { + +inline constexpr const char* kStyle = R"CSS( + html, body { margin: 0; height: 100%; overflow: hidden; background: #313338; color: #dbdee1; font: 13px sans-serif; user-select: none; } + #bar { position: fixed; top: 0; left: 0; right: 0; height: 28px; display: flex; align-items: stretch; background: #1e1f22; } + #bar .title { flex: 1; min-width: 0; display: flex; align-items: center; padding: 0 10px; font-size: 12px; + overflow: hidden; white-space: nowrap; text-overflow: ellipsis; cursor: default; } + #bar button { width: 44px; border: 0; margin: 0; padding: 0; background: transparent; color: #dbdee1; cursor: default; } + #bar button:hover { background: #da373c; color: #fff; } + #bar svg { width: 10px; height: 10px; stroke: currentColor; fill: none; stroke-width: 1; } + #content { position: absolute; top: 28px; left: 0; right: 0; bottom: 0; padding: 16px 20px; box-sizing: border-box; overflow: auto; } + h2 { margin: 0 0 10px; font-size: 18px; color: #f2f3f5; } + h3 { margin: 0 0 8px; font-size: 14px; color: #f2f3f5; } + .section { margin-top: 14px; padding-top: 12px; border-top: 1px solid #3f4147; } + .option { display: flex; align-items: center; gap: 10px; cursor: pointer; } + .option input:disabled + span { color: #80848e; } + p { margin: 8px 0 0; font-size: 13px; line-height: 1.4; color: #b5bac1; } + .buttons { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 14px; } + button.action { padding: 8px 16px; border: 0; border-radius: 3px; background: #4e5058; color: #fff; cursor: pointer; } + button.action.primary { background: #5865f2; } + button.action:disabled { opacity: 0.5; cursor: default; } + .track { height: 6px; margin-top: 14px; border-radius: 3px; background: #1e1f22; overflow: hidden; position: relative; } + .fill { position: absolute; top: 0; bottom: 0; left: 0; width: 0; background: #5865f2; transition: width 0.2s; } + .fill.indeterminate { width: 35%; animation: slide 1.2s ease-in-out infinite; } + @keyframes slide { 0% { left: -35%; } 100% { left: 100%; } } + .failure { color: #f23f43; } + .finished { color: #23a559; } +)CSS"; + +// The bridge and the title bar's close button, shared by every page. The host is called through post; the page draws no frame. +inline constexpr const char* kChromeScript = R"JS( + const post = (method, args) => { + try { + const channel = (window.chrome && window.chrome.webview) || window.webkit.messageHandlers.host; + channel.postMessage(JSON.stringify({id: Date.now(), method, args})); + } catch (e) {} + }; + document.getElementById('title-drag').addEventListener('mousedown', e => { + if (e.button === 0) post('moveDrag', []); + }); + document.getElementById('close').addEventListener('click', () => post('close', [])); +)JS"; + +inline constexpr const char* kCloseButton = + ""; + +// Wraps a page's body and script in a document with the shared style. +inline std::string document(const std::string& title, const std::string& body, const std::string& script) { + return "" + title + "" + + body + ""; +} + +inline std::string settings() { + const std::string body = + "
Settings
" + std::string(kCloseButton) + "
" + "
" + "

Settings

" + "

Window

" + "" + "

" + "

Updates

" + "

" + "
" + "" + "" + "
"; + const std::string script = R"JS( + const taskbar = document.getElementById('taskbar'); + const taskbarNote = document.getElementById('taskbar-note'); + const status = document.getElementById('update-status'); + const check = document.getElementById('check'); + const updateNow = document.getElementById('update-now'); + taskbar.addEventListener('change', () => post('setTaskbarWhenMinimised', [taskbar.checked])); + check.addEventListener('click', () => post('checkForUpdate', [])); + updateNow.addEventListener('click', () => post('updateNow', [])); + window.addEventListener('keydown', e => { if (e.key === 'Escape') post('close', []); }); + // The host sends the saved choice, whether a tray icon is available here, and the update state. + window.hostReceive = ({event, data}) => { + if (event !== 'state') return; + taskbar.checked = !!data.keepInTaskbar; + taskbar.disabled = !data.trayAvailable; + taskbarNote.textContent = data.trayAvailable + ? 'When this is unticked, minimising hides the window to the system tray. Click its icon to bring the window back.' + : 'The system tray isn\'t available on this platform yet, so minimising always uses the taskbar.'; + const update = data.update || {}; + status.textContent = update.message || ''; + const busy = !!update.busy; + check.disabled = busy; + updateNow.hidden = !update.available; + updateNow.disabled = busy; + }; + post('ready', []); +)JS"; + return document("Settings", body, script); +} + +// A job's window: its heading and note, a progress bar (or an animation when there's no known end), the latest stage, and the +// outcome. Cancel is offered while the job runs when it can be cancelled. +inline std::string progress() { + const std::string body = + "
Working
" + std::string(kCloseButton) + "
" + "
" + "

" + "

" + "
" + "

" + "

" + "

" + "
" + "" + "" + "
"; + const std::string script = R"JS( + const title = document.querySelector('#title-drag'); + const heading = document.getElementById('heading'); + const note = document.getElementById('note'); + const fill = document.getElementById('fill'); + const detail = document.getElementById('detail'); + const failure = document.getElementById('failure'); + const finished = document.getElementById('finished'); + const cancel = document.getElementById('cancel'); + const done = document.getElementById('done'); + cancel.addEventListener('click', () => { + cancel.disabled = true; + cancel.textContent = 'Cancelling...'; + post('cancel', []); + }); + done.addEventListener('click', () => post('close', [])); + window.hostReceive = ({event, data}) => { + if (event !== 'progress') return; + if (data.phase === 'start') { + title.textContent = data.title || 'Working'; + heading.textContent = data.heading || ''; + note.textContent = data.note || ''; + cancel.hidden = !data.cancellable; + } else if (data.phase === 'update') { + detail.textContent = data.detail || ''; + if (data.fraction === null || data.fraction === undefined) { + fill.classList.add('indeterminate'); + } else { + fill.classList.remove('indeterminate'); + fill.style.left = '0'; + fill.style.width = Math.round(data.fraction * 100) + '%'; + } + } else if (data.phase === 'failed') { + failure.textContent = data.text || ''; + cancel.hidden = true; + done.textContent = 'Close'; + done.hidden = false; + } else if (data.phase === 'finished') { + finished.textContent = data.text || ''; + fill.classList.remove('indeterminate'); + fill.style.width = '100%'; + cancel.hidden = true; + done.textContent = 'Done'; + done.hidden = false; + } + }; + post('ready', []); +)JS"; + return document("Working", body, script); +} + +} // namespace pages diff --git a/src/Progress.h b/src/Progress.h new file mode 100644 index 0000000..d13e4c5 --- /dev/null +++ b/src/Progress.h @@ -0,0 +1,17 @@ +// The work a progress window runs: a job on its own thread that reports its stage and how far it has got, and stops when cancelled. + +#pragma once + +#include +#include +#include +#include + +// The message work throws when the user cancels it, so the progress window ends quietly rather than showing a failure. +inline constexpr const char* kCancelledMessage = "cancelled"; + +// Reports a stage and how far through the work it is, from 0 to 1. Without a fraction the window shows an animation rather than a bar. +using ProgressReport = std::function fraction)>; + +// Work on a job thread. It throws std::runtime_error when it fails, or with kCancelledMessage when the user cancels it. +using ProgressWork = std::function& cancel)>; diff --git a/src/ProgressWindow.cpp b/src/ProgressWindow.cpp new file mode 100644 index 0000000..7791bc5 --- /dev/null +++ b/src/ProgressWindow.cpp @@ -0,0 +1,70 @@ +#include "ProgressWindow.h" + +#include "Application.h" +#include "Pages.h" + +ProgressWindow::ProgressWindow(Application& app, Json start) + : WebViewWindow(WindowOptions{ + .title = start.value("title", std::string("Working")), + .width = 420, + .height = 200, + .resizable = false, + }), + app_(app), + start_(std::move(start)) { + start_["phase"] = "start"; + auto& methods = handler(); + methods.on("moveDrag", [](WebViewWindow& window, const Json&, const Reply& reply) { + window.beginMove(); + reply.result(nullptr); + }); + methods.on("cancel", [](WebViewWindow& window, const Json&, const Reply& reply) { + static_cast(window).app_.cancelProgress(); + reply.result(nullptr); + }); + methods.on("close", [](WebViewWindow& window, const Json&, const Reply& reply) { + static_cast(window).app_.dismissProgress(); + reply.result(nullptr); + }); +} + +void ProgressWindow::update(const std::string& stage, std::optional fraction) { + send(Json{ + {"phase", "update"}, + {"fraction", fraction ? Json(*fraction) : Json(nullptr)}, + {"detail", stage}, + }); +} + +void ProgressWindow::failed(const std::string& text) { + send(Json{{"phase", "failed"}, {"text", text}}); +} + +void ProgressWindow::finished(const std::string& text) { + send(Json{{"phase", "finished"}, {"text", text}}); +} + +void ProgressWindow::send(const Json& event) { + latest_ = event; + emit("progress", event); +} + +std::string ProgressWindow::html() const { + return pages::progress(); +} + +std::string ProgressWindow::title() const { + return start_.value("title", std::string("Working")); +} + +void ProgressWindow::onPageReady() { + emit("progress", start_); + if (!latest_.is_null()) { + emit("progress", latest_); + } +} + +bool ProgressWindow::allowClose() { + app_.dismissProgress(); + return false; +} diff --git a/src/ProgressWindow.h b/src/ProgressWindow.h new file mode 100644 index 0000000..c450ab2 --- /dev/null +++ b/src/ProgressWindow.h @@ -0,0 +1,36 @@ +// The progress window: a job's heading, its stage and how far it has got, with a cancel button when the job can be cancelled. The +// loading window is the same window with no job behind it. +#pragma once + +#include +#include + +#include "WebViewWindow.h" + +class Application; + +class ProgressWindow : public WebViewWindow { +public: + // start holds the title, heading, note and whether the job can be cancelled. + ProgressWindow(Application& app, Json start); + + void update(const std::string& stage, std::optional fraction); + void failed(const std::string& text); + void finished(const std::string& text); + + std::string html() const override; + std::string title() const override; + +protected: + // A page that's loaded again is brought up to date with the job's start and its latest event. + void onPageReady() override; + // Closing the window dismisses it: a running job is cancelled, and the window goes once the job has stopped. + bool allowClose() override; + +private: + void send(const Json& event); + + Application& app_; + Json start_; + Json latest_; +}; diff --git a/src/SettingsWindow.cpp b/src/SettingsWindow.cpp new file mode 100644 index 0000000..267fab7 --- /dev/null +++ b/src/SettingsWindow.cpp @@ -0,0 +1,52 @@ +#include "SettingsWindow.h" + +#include "Application.h" +#include "Pages.h" + +SettingsWindow::SettingsWindow(Application& app) + : WebViewWindow(WindowOptions{ + .title = "Settings", + .width = 440, + .height = 440, + .resizable = false, + }), + app_(app) { + auto& methods = handler(); + methods.on("moveDrag", [](WebViewWindow& window, const Json&, const Reply& reply) { + window.beginMove(); + reply.result(nullptr); + }); + methods.on("close", [](WebViewWindow& window, const Json&, const Reply& reply) { + window.close(); + reply.result(nullptr); + }); + methods.on("setTaskbarWhenMinimised", [](WebViewWindow& window, const Json& args, const Reply& reply) { + static_cast(window).app_.setKeepInTaskbar(args.at(0).get()); + reply.result(nullptr); + }); + methods.on("checkForUpdate", [](WebViewWindow& window, const Json&, const Reply& reply) { + static_cast(window).app_.checkForUpdate(); + reply.result(nullptr); + }); + methods.on("updateNow", [](WebViewWindow& window, const Json&, const Reply& reply) { + static_cast(window).app_.updateNow(); + reply.result(nullptr); + }); +} + +std::string SettingsWindow::html() const { + return pages::settings(); +} + +std::string SettingsWindow::title() const { + return "Settings"; +} + +void SettingsWindow::onPageReady() { + emit("state", app_.settingsState()); +} + +bool SettingsWindow::allowClose() { + hide(); + return false; +} diff --git a/src/SettingsWindow.h b/src/SettingsWindow.h new file mode 100644 index 0000000..ff2e83d --- /dev/null +++ b/src/SettingsWindow.h @@ -0,0 +1,25 @@ +// The settings window: the taskbar choice for minimising, and the update check and install. It hides when closed, so it opens again +// straight away. +#pragma once + +#include + +#include "WebViewWindow.h" + +class Application; + +class SettingsWindow : public WebViewWindow { +public: + explicit SettingsWindow(Application& app); + + std::string html() const override; + std::string title() const override; + +protected: + void onPageReady() override; + // Closing hides the window, which the settings window keeps for its next opening. + bool allowClose() override; + +private: + Application& app_; +}; diff --git a/src/Sha256.cpp b/src/Sha256.cpp new file mode 100644 index 0000000..f7377b3 --- /dev/null +++ b/src/Sha256.cpp @@ -0,0 +1,130 @@ +#include "Sha256.h" + +#include +#include +#include +#include + +namespace { + +constexpr std::array kRound = { + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, + 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, + 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, + 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, + 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, + 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, + 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, + 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2, +}; + +std::uint32_t rotateRight(std::uint32_t value, unsigned bits) { + return (value >> bits) | (value << (32 - bits)); +} + +class Sha256 { +public: + void update(const unsigned char* data, std::size_t length) { + for (std::size_t i = 0; i < length; ++i) { + buffer_[bufferLength_++] = data[i]; + if (bufferLength_ == buffer_.size()) { + compress(buffer_.data()); + bufferLength_ = 0; + } + } + totalBytes_ += length; + } + + std::string finish() { + const std::uint64_t bits = totalBytes_ * 8; + const unsigned char one = 0x80; + update(&one, 1); + const unsigned char zero = 0; + while (bufferLength_ != 56) { + update(&zero, 1); + } + std::array length{}; + for (std::size_t i = 0; i < length.size(); ++i) { + length[i] = static_cast(bits >> (56 - 8 * i)); + } + update(length.data(), length.size()); + + std::string hex; + char digits[3]; + for (std::uint32_t word : state_) { + for (int shift = 24; shift >= 0; shift -= 8) { + std::snprintf(digits, sizeof digits, "%02x", (word >> shift) & 0xff); + hex += digits; + } + } + return hex; + } + +private: + void compress(const unsigned char* block) { + std::array schedule{}; + for (std::size_t i = 0; i < 16; ++i) { + schedule[i] = (std::uint32_t(block[4 * i]) << 24) | (std::uint32_t(block[4 * i + 1]) << 16) | + (std::uint32_t(block[4 * i + 2]) << 8) | std::uint32_t(block[4 * i + 3]); + } + for (std::size_t i = 16; i < 64; ++i) { + const std::uint32_t s0 = rotateRight(schedule[i - 15], 7) ^ rotateRight(schedule[i - 15], 18) ^ (schedule[i - 15] >> 3); + const std::uint32_t s1 = rotateRight(schedule[i - 2], 17) ^ rotateRight(schedule[i - 2], 19) ^ (schedule[i - 2] >> 10); + schedule[i] = schedule[i - 16] + s0 + schedule[i - 7] + s1; + } + + std::uint32_t a = state_[0], b = state_[1], c = state_[2], d = state_[3]; + std::uint32_t e = state_[4], f = state_[5], g = state_[6], h = state_[7]; + for (std::size_t i = 0; i < 64; ++i) { + const std::uint32_t sum1 = rotateRight(e, 6) ^ rotateRight(e, 11) ^ rotateRight(e, 25); + const std::uint32_t choose = (e & f) ^ (~e & g); + const std::uint32_t temp1 = h + sum1 + choose + kRound[i] + schedule[i]; + const std::uint32_t sum0 = rotateRight(a, 2) ^ rotateRight(a, 13) ^ rotateRight(a, 22); + const std::uint32_t majority = (a & b) ^ (a & c) ^ (b & c); + const std::uint32_t temp2 = sum0 + majority; + h = g; + g = f; + f = e; + e = d + temp1; + d = c; + c = b; + b = a; + a = temp1 + temp2; + } + state_[0] += a; + state_[1] += b; + state_[2] += c; + state_[3] += d; + state_[4] += e; + state_[5] += f; + state_[6] += g; + state_[7] += h; + } + + std::array state_ = {0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, + 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19}; + std::array buffer_{}; + std::size_t bufferLength_ = 0; + std::uint64_t totalBytes_ = 0; +}; + +} // namespace + +std::optional sha256OfFile(const std::filesystem::path& file) { + std::FILE* in = std::fopen(file.string().c_str(), "rb"); + if (!in) { + return std::nullopt; + } + Sha256 hash; + std::vector chunk(1 << 16); + std::size_t count = 0; + while ((count = std::fread(chunk.data(), 1, chunk.size(), in)) > 0) { + hash.update(chunk.data(), count); + } + const bool failed = std::ferror(in) != 0; + std::fclose(in); + if (failed) { + return std::nullopt; + } + return hash.finish(); +} diff --git a/src/Sha256.h b/src/Sha256.h new file mode 100644 index 0000000..2d1aed0 --- /dev/null +++ b/src/Sha256.h @@ -0,0 +1,9 @@ +// SHA-256, for checking a downloaded update against the checksum GitHub publishes for it. +#pragma once + +#include +#include +#include + +// The SHA-256 digest of a file, as lowercase hex. Missing when the file can't be read. +std::optional sha256OfFile(const std::filesystem::path& file); diff --git a/src/UpdateCheck.cpp b/src/UpdateCheck.cpp index f0d7714..cc1fb81 100644 --- a/src/UpdateCheck.cpp +++ b/src/UpdateCheck.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include "WebViewWindow.h" @@ -26,26 +27,57 @@ std::optional buildOfTag(const std::string& tag) { } // namespace -std::optional latestUpdate() { +std::optional fetchUpdate() { // DISCORD_WEBVIEW_RELEASE_URL points the check at another release feed, for testing. const char* override = std::getenv("DISCORD_WEBVIEW_RELEASE_URL"); const std::string url = override && *override ? override : kLatestReleaseUrl; const auto body = httpGet(url); if (!body) { + throw std::runtime_error("GitHub couldn't be reached."); + } + const Json release = Json::parse(*body, nullptr, false); + if (release.is_discarded() || !release.is_object()) { + throw std::runtime_error("GitHub returned no release."); + } + const auto build = buildOfTag(release.value("tag_name", std::string())); + if (!build) { + throw std::runtime_error("The latest release has no build number."); + } + if (*build <= kBuildNumber) { return std::nullopt; } - try { - const Json release = Json::parse(*body, nullptr, false); - if (release.is_discarded() || !release.is_object()) { - return std::nullopt; - } - const auto build = buildOfTag(release.value("tag_name", std::string())); - const std::string page = release.value("html_url", std::string()); - if (!build || *build <= kBuildNumber || page.rfind("https://", 0) != 0) { - return std::nullopt; + UpdateInfo info; + info.build = *build; + info.url = release.value("html_url", std::string()); + if (info.url.rfind("https://", 0) != 0) { + throw std::runtime_error("The latest release has no page."); + } + if (release.contains("assets") && release["assets"].is_array()) { + for (const Json& asset : release["assets"]) { + if (asset.value("name", std::string()) != releaseAssetName()) { + continue; + } + const std::string digest = asset.value("digest", std::string()); + const std::string prefix = "sha256:"; + if (digest.compare(0, prefix.size(), prefix) != 0) { + throw std::runtime_error("GitHub gave no checksum for the update."); + } + info.download = asset.value("browser_download_url", std::string()); + info.sha256 = digest.substr(prefix.size()); + if (info.download.empty()) { + throw std::runtime_error("GitHub gave no download for the update."); + } + break; } - return UpdateInfo{*build, page}; + } + return info; +} + +std::optional latestUpdate() { + try { + return fetchUpdate(); } catch (const std::exception&) { + // The startup check is quiet: the settings dialog reports a failure when it's asked for. return std::nullopt; } } diff --git a/src/UpdateCheck.h b/src/UpdateCheck.h index 031aae2..e28a5d0 100644 --- a/src/UpdateCheck.h +++ b/src/UpdateCheck.h @@ -1,8 +1,10 @@ -// Checks GitHub for a newer release of the program. The build number is the commit count, which each release's tag carries as -// r, so a release is newer when its count is higher than this build's. +// Checks GitHub for a newer release of the program, and installs it. The build number is the commit count, which each release's tag +// carries as r, so a release is newer when its count is higher than this build's. #pragma once +#include #include +#include #include #include @@ -14,12 +16,34 @@ inline constexpr std::uint32_t kBuildNumber = DW_BUILD_NUMBER; struct UpdateInfo { std::uint32_t build = 0; - // The release's page, which the user opens to download it. + // The release's page, which the user opens when there's no downloadable file for this platform. std::string url; + // The release's file for this platform, and the SHA-256 GitHub publishes for it. Empty when the release has no such file. + std::string download; + std::string sha256; }; -// The latest release, when it's newer than this build. Missing when it isn't newer, or when GitHub can't be read. +// The latest release, when it's newer than this build. Missing when it isn't newer. Throws std::runtime_error with the reason when +// GitHub can't be read, or the release doesn't say what it is. +std::optional fetchUpdate(); + +// The startup check: the latest release when it's newer, and missing otherwise, including when GitHub can't be read. std::optional latestUpdate(); // Fetches the body at a URL, for GitHub's API. Each platform's host file defines it. Missing when the request fails. std::optional httpGet(const std::string& url); + +// The release file for this platform, by its name in the release. Each platform's host file defines it. +const char* releaseAssetName(); +// The running program, which an update replaces. Each platform's host file defines it. +std::filesystem::path currentExecutable(); +// Downloads a URL to dest, stopping the download when cancel is set. Each platform's host file defines it. False when the download +// fails or is cancelled, and dest is then removed. +bool downloadTo(const std::string& url, const std::filesystem::path& dest, const std::atomic& cancel); +// Puts the staged file in place of the running program. The old program is kept beside it until the swap has worked. Throws +// std::runtime_error with the reason when it fails. Each platform's host file defines it. +void replaceExecutable(const std::filesystem::path& current, const std::filesystem::path& staged); +// Starts a new copy of the program, detached from this one. Each platform's host file defines it. +void restartProgram(const std::filesystem::path& program); +// Deletes what a previous update left beside the running program. Each platform's host file defines it. +void removeUpdateLeftovers(const std::filesystem::path& current); diff --git a/src/main.cpp b/src/main.cpp index f1c404b..229e62a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,209 +1,25 @@ // Shows Discord's web client in a WebViewWindow window. Nothing from Discord is bundled here: the page is loaded from -// discord.com at run time, and PageScript.h adds this program's title bar and link handling to it. +// discord.com at run time. The windows and what they share are in Application.h. -#include -#include #include -#include -#include -#include -#include -#include -#include -#include "PageScript.h" +#include "AppIcon.h" +#include "Application.h" +#include "Host.h" #include "UpdateCheck.h" #include "WebViewWindow.h" -// Opens a web address in the default browser. Each platform's host file defines it. The address is never run through a shell. -void launchUrl(const std::string& url); - -// The folder the program keeps its settings in. Each platform's host file defines it. -std::filesystem::path settingsFolder(); - -namespace { - -constexpr const char* kDiscordUrl = "https://discord.com/app"; - -// The window's position on the screen and its size without the UI scale, as the window saved them. -struct SavedFrame { - int x = 0; - int y = 0; - int width = 0; - int height = 0; - - bool operator==(const SavedFrame& other) const { - return x == other.x && y == other.y && width == other.width && height == other.height; - } -}; - -std::filesystem::path frameFile() { - return settingsFolder() / "window.json"; -} - -std::optional loadFrame() { - try { - std::ifstream in(frameFile()); - if (!in) { - return std::nullopt; - } - const Json saved = Json::parse(in); - return SavedFrame{saved.at("x").get(), saved.at("y").get(), saved.at("width").get(), - saved.at("height").get()}; - } catch (const std::exception&) { - // A missing or unreadable file means the window opens where it would by default. - return std::nullopt; - } -} - -void saveFrame(const SavedFrame& frame) { - try { - std::filesystem::create_directories(frameFile().parent_path()); - std::ofstream out(frameFile(), std::ios::trunc); - out << Json{{"x", frame.x}, {"y", frame.y}, {"width", frame.width}, {"height", frame.height}}.dump(2) << '\n'; - } catch (const std::exception&) { - // Failing to save the frame isn't worth stopping the program for. - } -} - -// Opens a web address in the default browser, when it's an http or https address. -void openInBrowser(const std::string& url) { - if (url.rfind("http://", 0) != 0 && url.rfind("https://", 0) != 0) { - return; - } - launchUrl(url); -} - -class DiscordWindow : public WebViewWindow { -public: - DiscordWindow() : WebViewWindow(options()) { - auto& methods = handler(); - methods.on("moveDrag", [](WebViewWindow& window, const Json&, const Reply& reply) { - window.beginMove(); - reply.result(nullptr); - }); - methods.on("resizeDrag", [](WebViewWindow& window, const Json& args, const Reply& reply) { - const int edge = args.at(0).get(); - if (edge >= 0 && edge <= static_cast(ResizeEdge::SouthEast)) { - window.beginResize(static_cast(edge)); - } - reply.result(nullptr); - }); - methods.on("minimize", [](WebViewWindow& window, const Json&, const Reply& reply) { - window.minimize(); - reply.result(nullptr); - }); - methods.on("toggleMaximize", [](WebViewWindow& window, const Json&, const Reply& reply) { - window.toggleMaximize(); - reply.result(nullptr); - }); - methods.on("close", [](WebViewWindow& window, const Json&, const Reply& reply) { - window.close(); - reply.result(nullptr); - }); - methods.on("openDevTools", [](WebViewWindow& window, const Json&, const Reply& reply) { - window.openDevTools(); - reply.result(nullptr); - }); - methods.on("openExternal", [](WebViewWindow&, const Json& args, const Reply& reply) { - openInBrowser(args.at(0).get()); - reply.result(nullptr); - }); - } - - std::string devUrl() const override { return kDiscordUrl; } - std::string title() const override { return "Discord"; } - - // Shows the update button on the bar, now and after each page load. Called on the window's thread. - void showUpdate(const UpdateInfo& update) { - updateUrl_ = update.url; - runScript(updateScript()); - } - - // Puts the window where it was last saved, at the size it had. Called once, after open. The library keeps the window inside - // its monitor's work area, so a saved frame that's now off the screen is brought back in. - void restoreFrame() { - if (const auto saved = loadFrame()) { - resize(std::max(saved->width, options().minWidth), std::max(saved->height, options().minHeight)); - move(saved->x, saved->y); - lastSaved_ = SavedFrame{saved->x, saved->y, saved->width, saved->height}; - } - frameRestored_ = true; - } - -protected: - // Puts the title bar back on each page the window loads, including after navigations, and the update button with it. - void onPageLoaded() override { - runScript(kPageScript); - if (!updateUrl_.empty()) { - runScript(updateScript()); - } - } - // Closing the only window ends the program. - void onClosed() override { stopEventLoop(); } - // Saves the frame after the user moves or resizes the window. Changes before restoreFrame are the window's own starting frame. - void onFrameChanged() override { - if (!frameRestored_) { - return; - } - const auto bounds = frame(); - const auto size = frameUnscaled(); - if (!bounds || !size) { - return; - } - const SavedFrame current{bounds->x, bounds->y, size->first, size->second}; - if (!lastSaved_ || !(*lastSaved_ == current)) { - saveFrame(current); - lastSaved_ = current; - } - } - -private: - static WindowOptions options() { - WindowOptions options; - options.title = "Discord"; - options.width = 1280; - options.height = 800; - options.minWidth = 480; - options.minHeight = 360; - // Discord's page is opaque, so there is nothing to see through. - options.transparent = false; - options.hardwareAcceleration = HardwareAcceleration::Always; - return options; - } - - // The script that adds the update button to the bar, for the address of the newer release. - std::string updateScript() const { - return "window.gwShowUpdate && window.gwShowUpdate(" + Json(updateUrl_).dump() + ");"; - } - - bool frameRestored_ = false; - std::optional lastSaved_; - std::string updateUrl_; -}; - -} // namespace - int main() { try { setApplicationName("Discord"); + setApplicationIcon(kAppIconPng); initializeWindowing(); - DiscordWindow window; - window.open(); - window.restoreFrame(); - // Checks for a newer release in the background. The result comes back on the window's thread, and only while the window is - // still running: the flag is cleared before the window goes. - auto running = std::make_shared>(true); - std::thread([&window, running] { - const auto update = latestUpdate(); - if (update) { - runOnUiThread([&window, running, update = *update] { - if (*running) window.showUpdate(update); - }); - } - }).detach(); - runEventLoop(); - *running = false; + // An update leaves its old program beside the new one, and the new one removes it on its first start. + if (const auto current = currentExecutable(); !current.empty()) { + removeUpdateLeftovers(current); + } + Application app; + app.run(); } catch (const RuntimeMissingError&) { // The dialog has already said what's missing. return 1; diff --git a/tests/PagePermissions_test.cpp b/tests/PagePermissions_test.cpp new file mode 100644 index 0000000..2175670 --- /dev/null +++ b/tests/PagePermissions_test.cpp @@ -0,0 +1,67 @@ +// Unit tests for the permission answers Discord's page is given. Exits with 1 when a check fails, and prints each failure. +#include +#include +#include + +#include "PagePermissions.h" + +namespace { + +int failures = 0; + +void expectAnswer(PagePermission permission, const std::string& url, std::optional want) { + const std::optional got = discordPermission(permission, url); + if (got != want) { + std::printf("FAIL: permission %d from \"%s\" gave %s, want %s\n", static_cast(permission), url.c_str(), + got ? (*got ? "true" : "false") : "nothing", want ? (*want ? "true" : "false") : "nothing"); + ++failures; + } +} + +void expectDiscord(const std::string& url, bool want) { + if (isDiscordAddress(url) != want) { + std::printf("FAIL: isDiscordAddress(\"%s\") is not %s\n", url.c_str(), want ? "true" : "false"); + ++failures; + } +} + +} // namespace + +int main() { + // The three permissions are allowed on Discord's own page. + expectAnswer(PagePermission::Microphone, "https://discord.com/app", true); + expectAnswer(PagePermission::Camera, "https://discord.com/app", true); + expectAnswer(PagePermission::Notifications, "https://discord.com/app", true); + + // Subdomains, the bare address, upper case and an explicit port are Discord's too. + expectAnswer(PagePermission::Microphone, "https://canary.discord.com/app", true); + expectAnswer(PagePermission::Microphone, "https://discord.com", true); + expectAnswer(PagePermission::Notifications, "https://DISCORD.com/app", true); + expectAnswer(PagePermission::Camera, "https://discord.com:443/app", true); + + // Other permission kinds are left to the platform, even on Discord. + expectAnswer(PagePermission::Other, "https://discord.com/app", std::nullopt); + + // Anything else gets no answer: other sites, look-alike hosts, plain http, and malformed addresses. + expectAnswer(PagePermission::Microphone, "https://evil.com/", std::nullopt); + expectAnswer(PagePermission::Microphone, "https://notdiscord.com/", std::nullopt); + expectAnswer(PagePermission::Microphone, "https://xdiscord.com/", std::nullopt); + expectAnswer(PagePermission::Microphone, "https://discord.com.evil.net/", std::nullopt); + expectAnswer(PagePermission::Microphone, "https://evil.com/discord.com", std::nullopt); + expectAnswer(PagePermission::Microphone, "https://evil.com/?discord.com", std::nullopt); + expectAnswer(PagePermission::Microphone, "http://discord.com/app", std::nullopt); + expectAnswer(PagePermission::Microphone, "", std::nullopt); + expectAnswer(PagePermission::Microphone, "https://", std::nullopt); + + expectDiscord("https://discord.com/app", true); + expectDiscord("https://ptb.discord.com/app", true); + expectDiscord("http://discord.com/app", false); + expectDiscord("https://discord.com.evil.net/", false); + + if (failures == 0) { + std::printf("All permission checks passed.\n"); + return 0; + } + std::printf("%d permission check(s) failed.\n", failures); + return 1; +}