mirror of
https://github.com/SerenityOS/serenity.git
synced 2026-11-07 04:29:30 -10:00
Rather than (re-)open the Downloads folder on every completed file transfer, send a notification when a transfer is complete. The notification includes the file's name, and clicking it will open the Downloads folder (with the file highlighted).
46 lines
1.4 KiB
C++
46 lines
1.4 KiB
C++
/*
|
|
* Copyright (c) 2021, Kyle Pereira <[email protected]>
|
|
* Copyright (c) 2023, Caoimhe Byrne <[email protected]>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include "SpiceAgent.h"
|
|
#include <LibCore/StandardPaths.h>
|
|
#include <LibCore/System.h>
|
|
#include <LibFileSystem/FileSystem.h>
|
|
#include <LibGUI/Application.h>
|
|
#include <LibGUI/Clipboard.h>
|
|
#include <LibIPC/ConnectionToServer.h>
|
|
#include <LibMain/Main.h>
|
|
#include <LibURL/URL.h>
|
|
#include <fcntl.h>
|
|
|
|
static constexpr auto SPICE_DEVICE = "/dev/hvc0p1"sv;
|
|
|
|
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|
{
|
|
if (!FileSystem::exists(SPICE_DEVICE)) {
|
|
return Error::from_string_literal("Failed to find spice device file!");
|
|
}
|
|
|
|
// We use the application to be able to easily write to the user's clipboard.
|
|
auto app = TRY(GUI::Application::create(arguments));
|
|
|
|
TRY(Core::System::pledge("unix rpath wpath cpath stdio sendfd recvfd"));
|
|
TRY(Core::System::unveil(SPICE_DEVICE, "rw"sv));
|
|
TRY(Core::System::unveil("/res", "r"));
|
|
TRY(Core::System::unveil("/tmp/session/%sid/portal/notify", "rw"));
|
|
TRY(Core::System::unveil(Core::StandardPaths::downloads_directory(), "rwc"sv));
|
|
TRY(Core::System::unveil(nullptr, nullptr));
|
|
|
|
auto agent = TRY(SpiceAgent::SpiceAgent::create(SPICE_DEVICE));
|
|
|
|
agent->on_disconnected_from_spice_server = [&]() {
|
|
app->quit();
|
|
};
|
|
|
|
TRY(agent->start());
|
|
return app->exec();
|
|
}
|