mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 08:34:57 +00:00

This commit un-deprecates DeprecatedString, and repurposes it as a byte string. As the null state has already been removed, there are no other particularly hairy blockers in repurposing this type as a byte string (what it _really_ is). This commit is auto-generated: $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \ Meta Ports Ladybird Tests Kernel) $ perl -pie 's/\bDeprecatedString\b/ByteString/g; s/deprecated_string/byte_string/g' $xs $ clang-format --style=file -i \ $(git diff --name-only | grep \.cpp\|\.h) $ gn format $(git ls-files '*.gn' '*.gni')
49 lines
1.4 KiB
C++
49 lines
1.4 KiB
C++
/*
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <Clipboard/ClipboardClientEndpoint.h>
|
|
#include <Clipboard/ConnectionFromClient.h>
|
|
#include <Clipboard/Storage.h>
|
|
|
|
namespace Clipboard {
|
|
|
|
static HashMap<int, RefPtr<ConnectionFromClient>> s_connections;
|
|
|
|
void ConnectionFromClient::for_each_client(Function<void(ConnectionFromClient&)> callback)
|
|
{
|
|
for (auto& it : s_connections) {
|
|
callback(*it.value);
|
|
}
|
|
}
|
|
|
|
ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket> socket, int client_id)
|
|
: IPC::ConnectionFromClient<ClipboardClientEndpoint, ClipboardServerEndpoint>(*this, move(socket), client_id)
|
|
{
|
|
s_connections.set(client_id, *this);
|
|
}
|
|
|
|
void ConnectionFromClient::die()
|
|
{
|
|
s_connections.remove(client_id());
|
|
}
|
|
|
|
void ConnectionFromClient::set_clipboard_data(Core::AnonymousBuffer const& data, ByteString const& mime_type, HashMap<ByteString, ByteString> const& metadata)
|
|
{
|
|
Storage::the().set_data(data, mime_type, metadata);
|
|
}
|
|
|
|
Messages::ClipboardServer::GetClipboardDataResponse ConnectionFromClient::get_clipboard_data()
|
|
{
|
|
auto& storage = Storage::the();
|
|
return { storage.buffer(), storage.mime_type(), storage.metadata().clone().release_value_but_fixme_should_propagate_errors() };
|
|
}
|
|
|
|
void ConnectionFromClient::notify_about_clipboard_change()
|
|
{
|
|
async_clipboard_data_changed(Storage::the().mime_type());
|
|
}
|
|
|
|
}
|