mirror of
https://github.com/RGBCube/serenity
synced 2025-07-29 04:07:34 +00:00
Everywhere: Rename {Deprecated => Byte}String
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')
This commit is contained in:
parent
38d62563b3
commit
5e1499d104
1615 changed files with 10257 additions and 10257 deletions
|
@ -2,5 +2,5 @@
|
|||
|
||||
endpoint ClipboardClient
|
||||
{
|
||||
clipboard_data_changed([UTF8] DeprecatedString mime_type) =|
|
||||
clipboard_data_changed([UTF8] ByteString mime_type) =|
|
||||
}
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
|
||||
endpoint ClipboardServer
|
||||
{
|
||||
get_clipboard_data() => (Core::AnonymousBuffer data, [UTF8] DeprecatedString mime_type, HashMap<DeprecatedString,DeprecatedString> metadata)
|
||||
set_clipboard_data(Core::AnonymousBuffer data, [UTF8] DeprecatedString mime_type, HashMap<DeprecatedString,DeprecatedString> metadata) =|
|
||||
get_clipboard_data() => (Core::AnonymousBuffer data, [UTF8] ByteString mime_type, HashMap<ByteString,ByteString> metadata)
|
||||
set_clipboard_data(Core::AnonymousBuffer data, [UTF8] ByteString mime_type, HashMap<ByteString,ByteString> metadata) =|
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ void ConnectionFromClient::die()
|
|||
s_connections.remove(client_id());
|
||||
}
|
||||
|
||||
void ConnectionFromClient::set_clipboard_data(Core::AnonymousBuffer const& data, DeprecatedString const& mime_type, HashMap<DeprecatedString, DeprecatedString> const& metadata)
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ private:
|
|||
explicit ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket>, int client_id);
|
||||
|
||||
virtual Messages::ClipboardServer::GetClipboardDataResponse get_clipboard_data() override;
|
||||
virtual void set_clipboard_data(Core::AnonymousBuffer const&, DeprecatedString const&, HashMap<DeprecatedString, DeprecatedString> const&) override;
|
||||
virtual void set_clipboard_data(Core::AnonymousBuffer const&, ByteString const&, HashMap<ByteString, ByteString> const&) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ Storage& Storage::the()
|
|||
return s_the;
|
||||
}
|
||||
|
||||
void Storage::set_data(Core::AnonymousBuffer data, DeprecatedString const& mime_type, HashMap<DeprecatedString, DeprecatedString> const& metadata)
|
||||
void Storage::set_data(Core::AnonymousBuffer data, ByteString const& mime_type, HashMap<ByteString, ByteString> const& metadata)
|
||||
{
|
||||
m_buffer = move(data);
|
||||
m_data_size = data.size();
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <LibCore/AnonymousBuffer.h>
|
||||
|
@ -20,8 +20,8 @@ public:
|
|||
|
||||
bool has_data() const { return m_buffer.is_valid(); }
|
||||
|
||||
DeprecatedString const& mime_type() const { return m_mime_type; }
|
||||
HashMap<DeprecatedString, DeprecatedString> const& metadata() const { return m_metadata; }
|
||||
ByteString const& mime_type() const { return m_mime_type; }
|
||||
HashMap<ByteString, ByteString> const& metadata() const { return m_metadata; }
|
||||
|
||||
u8 const* data() const
|
||||
{
|
||||
|
@ -37,7 +37,7 @@ public:
|
|||
return 0;
|
||||
}
|
||||
|
||||
void set_data(Core::AnonymousBuffer, DeprecatedString const& mime_type, HashMap<DeprecatedString, DeprecatedString> const& metadata);
|
||||
void set_data(Core::AnonymousBuffer, ByteString const& mime_type, HashMap<ByteString, ByteString> const& metadata);
|
||||
|
||||
Function<void()> on_content_change;
|
||||
|
||||
|
@ -46,10 +46,10 @@ public:
|
|||
private:
|
||||
Storage() = default;
|
||||
|
||||
DeprecatedString m_mime_type;
|
||||
ByteString m_mime_type;
|
||||
Core::AnonymousBuffer m_buffer;
|
||||
size_t m_data_size { 0 };
|
||||
HashMap<DeprecatedString, DeprecatedString> m_metadata;
|
||||
HashMap<ByteString, ByteString> m_metadata;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
endpoint ConfigClient
|
||||
{
|
||||
notify_changed_string_value(DeprecatedString domain, DeprecatedString group, DeprecatedString key, DeprecatedString value) =|
|
||||
notify_changed_i32_value(DeprecatedString domain, DeprecatedString group, DeprecatedString key, i32 value) =|
|
||||
notify_changed_u32_value(DeprecatedString domain, DeprecatedString group, DeprecatedString key, u32 value) =|
|
||||
notify_changed_bool_value(DeprecatedString domain, DeprecatedString group, DeprecatedString key, bool value) =|
|
||||
notify_removed_key(DeprecatedString domain, DeprecatedString group, DeprecatedString key) =|
|
||||
notify_removed_group(DeprecatedString domain, DeprecatedString group) =|
|
||||
notify_added_group(DeprecatedString domain, DeprecatedString group) =|
|
||||
notify_changed_string_value(ByteString domain, ByteString group, ByteString key, ByteString value) =|
|
||||
notify_changed_i32_value(ByteString domain, ByteString group, ByteString key, i32 value) =|
|
||||
notify_changed_u32_value(ByteString domain, ByteString group, ByteString key, u32 value) =|
|
||||
notify_changed_bool_value(ByteString domain, ByteString group, ByteString key, bool value) =|
|
||||
notify_removed_key(ByteString domain, ByteString group, ByteString key) =|
|
||||
notify_removed_group(ByteString domain, ByteString group) =|
|
||||
notify_added_group(ByteString domain, ByteString group) =|
|
||||
}
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
endpoint ConfigServer
|
||||
{
|
||||
pledge_domains(Vector<DeprecatedString> domains) =|
|
||||
pledge_domains(Vector<ByteString> domains) =|
|
||||
|
||||
monitor_domain(DeprecatedString domain) =|
|
||||
monitor_domain(ByteString domain) =|
|
||||
|
||||
list_config_groups(DeprecatedString domain) => (Vector<DeprecatedString> groups)
|
||||
list_config_keys(DeprecatedString domain, DeprecatedString group) => (Vector<DeprecatedString> keys)
|
||||
list_config_groups(ByteString domain) => (Vector<ByteString> groups)
|
||||
list_config_keys(ByteString domain, ByteString group) => (Vector<ByteString> keys)
|
||||
|
||||
read_string_value(DeprecatedString domain, DeprecatedString group, DeprecatedString key) => (Optional<DeprecatedString> value)
|
||||
read_i32_value(DeprecatedString domain, DeprecatedString group, DeprecatedString key) => (Optional<i32> value)
|
||||
read_u32_value(DeprecatedString domain, DeprecatedString group, DeprecatedString key) => (Optional<u32> value)
|
||||
read_bool_value(DeprecatedString domain, DeprecatedString group, DeprecatedString key) => (Optional<bool> value)
|
||||
read_string_value(ByteString domain, ByteString group, ByteString key) => (Optional<ByteString> value)
|
||||
read_i32_value(ByteString domain, ByteString group, ByteString key) => (Optional<i32> value)
|
||||
read_u32_value(ByteString domain, ByteString group, ByteString key) => (Optional<u32> value)
|
||||
read_bool_value(ByteString domain, ByteString group, ByteString key) => (Optional<bool> value)
|
||||
|
||||
write_string_value(DeprecatedString domain, DeprecatedString group, DeprecatedString key, DeprecatedString value) => ()
|
||||
write_i32_value(DeprecatedString domain, DeprecatedString group, DeprecatedString key, i32 value) => ()
|
||||
write_u32_value(DeprecatedString domain, DeprecatedString group, DeprecatedString key, u32 value) => ()
|
||||
write_bool_value(DeprecatedString domain, DeprecatedString group, DeprecatedString key, bool value) => ()
|
||||
remove_key_entry(DeprecatedString domain, DeprecatedString group, DeprecatedString key) => ()
|
||||
remove_group_entry(DeprecatedString domain, DeprecatedString group) => ()
|
||||
add_group_entry(DeprecatedString domain, DeprecatedString group) => ()
|
||||
write_string_value(ByteString domain, ByteString group, ByteString key, ByteString value) => ()
|
||||
write_i32_value(ByteString domain, ByteString group, ByteString key, i32 value) => ()
|
||||
write_u32_value(ByteString domain, ByteString group, ByteString key, u32 value) => ()
|
||||
write_bool_value(ByteString domain, ByteString group, ByteString key, bool value) => ()
|
||||
remove_key_entry(ByteString domain, ByteString group, ByteString key) => ()
|
||||
remove_group_entry(ByteString domain, ByteString group) => ()
|
||||
add_group_entry(ByteString domain, ByteString group) => ()
|
||||
}
|
||||
|
|
|
@ -15,15 +15,15 @@ namespace ConfigServer {
|
|||
static HashMap<int, RefPtr<ConnectionFromClient>> s_connections;
|
||||
|
||||
struct CachedDomain {
|
||||
DeprecatedString domain;
|
||||
ByteString domain;
|
||||
NonnullRefPtr<Core::ConfigFile> config;
|
||||
RefPtr<Core::FileWatcher> watcher;
|
||||
};
|
||||
|
||||
static HashMap<DeprecatedString, NonnullOwnPtr<CachedDomain>> s_cache;
|
||||
static HashMap<ByteString, NonnullOwnPtr<CachedDomain>> s_cache;
|
||||
static constexpr int s_disk_sync_delay_ms = 5'000;
|
||||
|
||||
static void for_each_monitoring_connection(DeprecatedString const& domain, ConnectionFromClient* excluded_connection, Function<void(ConnectionFromClient&)> callback)
|
||||
static void for_each_monitoring_connection(ByteString const& domain, ConnectionFromClient* excluded_connection, Function<void(ConnectionFromClient&)> callback)
|
||||
{
|
||||
for (auto& it : s_connections) {
|
||||
if (it.value->is_monitoring_domain(domain) && (!excluded_connection || it.value != excluded_connection))
|
||||
|
@ -31,7 +31,7 @@ static void for_each_monitoring_connection(DeprecatedString const& domain, Conne
|
|||
}
|
||||
}
|
||||
|
||||
static Core::ConfigFile& ensure_domain_config(DeprecatedString const& domain)
|
||||
static Core::ConfigFile& ensure_domain_config(ByteString const& domain)
|
||||
{
|
||||
auto it = s_cache.find(domain);
|
||||
if (it != s_cache.end())
|
||||
|
@ -88,7 +88,7 @@ void ConnectionFromClient::die()
|
|||
sync_dirty_domains_to_disk();
|
||||
}
|
||||
|
||||
void ConnectionFromClient::pledge_domains(Vector<DeprecatedString> const& domains)
|
||||
void ConnectionFromClient::pledge_domains(Vector<ByteString> const& domains)
|
||||
{
|
||||
if (m_has_pledged) {
|
||||
did_misbehave("Tried to pledge domains twice.");
|
||||
|
@ -99,7 +99,7 @@ void ConnectionFromClient::pledge_domains(Vector<DeprecatedString> const& domain
|
|||
m_pledged_domains.set(domain);
|
||||
}
|
||||
|
||||
void ConnectionFromClient::monitor_domain(DeprecatedString const& domain)
|
||||
void ConnectionFromClient::monitor_domain(ByteString const& domain)
|
||||
{
|
||||
if (m_has_pledged && !m_pledged_domains.contains(domain)) {
|
||||
did_misbehave("Attempt to monitor non-pledged domain");
|
||||
|
@ -109,13 +109,13 @@ void ConnectionFromClient::monitor_domain(DeprecatedString const& domain)
|
|||
m_monitored_domains.set(domain);
|
||||
}
|
||||
|
||||
bool ConnectionFromClient::validate_access(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key)
|
||||
bool ConnectionFromClient::validate_access(ByteString const& domain, ByteString const& group, ByteString const& key)
|
||||
{
|
||||
if (!m_has_pledged)
|
||||
return true;
|
||||
if (m_pledged_domains.contains(domain))
|
||||
return true;
|
||||
did_misbehave(DeprecatedString::formatted("Blocked attempt to access domain '{}', group={}, key={}", domain, group, key).characters());
|
||||
did_misbehave(ByteString::formatted("Blocked attempt to access domain '{}', group={}, key={}", domain, group, key).characters());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -135,34 +135,34 @@ void ConnectionFromClient::sync_dirty_domains_to_disk()
|
|||
}
|
||||
}
|
||||
|
||||
Messages::ConfigServer::ListConfigKeysResponse ConnectionFromClient::list_config_keys(DeprecatedString const& domain, DeprecatedString const& group)
|
||||
Messages::ConfigServer::ListConfigKeysResponse ConnectionFromClient::list_config_keys(ByteString const& domain, ByteString const& group)
|
||||
{
|
||||
if (!validate_access(domain, group, ""))
|
||||
return Vector<DeprecatedString> {};
|
||||
return Vector<ByteString> {};
|
||||
auto& config = ensure_domain_config(domain);
|
||||
return { config.keys(group) };
|
||||
}
|
||||
|
||||
Messages::ConfigServer::ListConfigGroupsResponse ConnectionFromClient::list_config_groups(DeprecatedString const& domain)
|
||||
Messages::ConfigServer::ListConfigGroupsResponse ConnectionFromClient::list_config_groups(ByteString const& domain)
|
||||
{
|
||||
if (!validate_access(domain, "", ""))
|
||||
return Vector<DeprecatedString> {};
|
||||
return Vector<ByteString> {};
|
||||
auto& config = ensure_domain_config(domain);
|
||||
return { config.groups() };
|
||||
}
|
||||
|
||||
Messages::ConfigServer::ReadStringValueResponse ConnectionFromClient::read_string_value(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key)
|
||||
Messages::ConfigServer::ReadStringValueResponse ConnectionFromClient::read_string_value(ByteString const& domain, ByteString const& group, ByteString const& key)
|
||||
{
|
||||
if (!validate_access(domain, group, key))
|
||||
return nullptr;
|
||||
|
||||
auto& config = ensure_domain_config(domain);
|
||||
if (!config.has_key(group, key))
|
||||
return Optional<DeprecatedString> {};
|
||||
return Optional<DeprecatedString> { config.read_entry(group, key) };
|
||||
return Optional<ByteString> {};
|
||||
return Optional<ByteString> { config.read_entry(group, key) };
|
||||
}
|
||||
|
||||
Messages::ConfigServer::ReadI32ValueResponse ConnectionFromClient::read_i32_value(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key)
|
||||
Messages::ConfigServer::ReadI32ValueResponse ConnectionFromClient::read_i32_value(ByteString const& domain, ByteString const& group, ByteString const& key)
|
||||
{
|
||||
if (!validate_access(domain, group, key))
|
||||
return nullptr;
|
||||
|
@ -173,7 +173,7 @@ Messages::ConfigServer::ReadI32ValueResponse ConnectionFromClient::read_i32_valu
|
|||
return Optional<i32> { config.read_num_entry(group, key) };
|
||||
}
|
||||
|
||||
Messages::ConfigServer::ReadU32ValueResponse ConnectionFromClient::read_u32_value(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key)
|
||||
Messages::ConfigServer::ReadU32ValueResponse ConnectionFromClient::read_u32_value(ByteString const& domain, ByteString const& group, ByteString const& key)
|
||||
{
|
||||
if (!validate_access(domain, group, key))
|
||||
return nullptr;
|
||||
|
@ -184,7 +184,7 @@ Messages::ConfigServer::ReadU32ValueResponse ConnectionFromClient::read_u32_valu
|
|||
return Optional<u32> { config.read_num_entry<u32>(group, key) };
|
||||
}
|
||||
|
||||
Messages::ConfigServer::ReadBoolValueResponse ConnectionFromClient::read_bool_value(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key)
|
||||
Messages::ConfigServer::ReadBoolValueResponse ConnectionFromClient::read_bool_value(ByteString const& domain, ByteString const& group, ByteString const& key)
|
||||
{
|
||||
if (!validate_access(domain, group, key))
|
||||
return nullptr;
|
||||
|
@ -203,7 +203,7 @@ void ConnectionFromClient::start_or_restart_sync_timer()
|
|||
m_sync_timer->start();
|
||||
}
|
||||
|
||||
void ConnectionFromClient::write_string_value(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key, DeprecatedString const& value)
|
||||
void ConnectionFromClient::write_string_value(ByteString const& domain, ByteString const& group, ByteString const& key, ByteString const& value)
|
||||
{
|
||||
if (!validate_access(domain, group, key))
|
||||
return;
|
||||
|
@ -222,7 +222,7 @@ void ConnectionFromClient::write_string_value(DeprecatedString const& domain, De
|
|||
});
|
||||
}
|
||||
|
||||
void ConnectionFromClient::write_i32_value(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key, i32 value)
|
||||
void ConnectionFromClient::write_i32_value(ByteString const& domain, ByteString const& group, ByteString const& key, i32 value)
|
||||
{
|
||||
if (!validate_access(domain, group, key))
|
||||
return;
|
||||
|
@ -241,7 +241,7 @@ void ConnectionFromClient::write_i32_value(DeprecatedString const& domain, Depre
|
|||
});
|
||||
}
|
||||
|
||||
void ConnectionFromClient::write_u32_value(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key, u32 value)
|
||||
void ConnectionFromClient::write_u32_value(ByteString const& domain, ByteString const& group, ByteString const& key, u32 value)
|
||||
{
|
||||
if (!validate_access(domain, group, key))
|
||||
return;
|
||||
|
@ -260,7 +260,7 @@ void ConnectionFromClient::write_u32_value(DeprecatedString const& domain, Depre
|
|||
});
|
||||
}
|
||||
|
||||
void ConnectionFromClient::write_bool_value(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key, bool value)
|
||||
void ConnectionFromClient::write_bool_value(ByteString const& domain, ByteString const& group, ByteString const& key, bool value)
|
||||
{
|
||||
if (!validate_access(domain, group, key))
|
||||
return;
|
||||
|
@ -279,7 +279,7 @@ void ConnectionFromClient::write_bool_value(DeprecatedString const& domain, Depr
|
|||
});
|
||||
}
|
||||
|
||||
void ConnectionFromClient::remove_key_entry(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key)
|
||||
void ConnectionFromClient::remove_key_entry(ByteString const& domain, ByteString const& group, ByteString const& key)
|
||||
{
|
||||
if (!validate_access(domain, group, key))
|
||||
return;
|
||||
|
@ -297,7 +297,7 @@ void ConnectionFromClient::remove_key_entry(DeprecatedString const& domain, Depr
|
|||
});
|
||||
}
|
||||
|
||||
void ConnectionFromClient::remove_group_entry(DeprecatedString const& domain, DeprecatedString const& group)
|
||||
void ConnectionFromClient::remove_group_entry(ByteString const& domain, ByteString const& group)
|
||||
{
|
||||
if (!validate_access(domain, group, {}))
|
||||
return;
|
||||
|
@ -315,7 +315,7 @@ void ConnectionFromClient::remove_group_entry(DeprecatedString const& domain, De
|
|||
});
|
||||
}
|
||||
|
||||
void ConnectionFromClient::add_group_entry(DeprecatedString const& domain, DeprecatedString const& group)
|
||||
void ConnectionFromClient::add_group_entry(ByteString const& domain, ByteString const& group)
|
||||
{
|
||||
if (!validate_access(domain, group, {}))
|
||||
return;
|
||||
|
|
|
@ -20,38 +20,38 @@ public:
|
|||
|
||||
virtual void die() override;
|
||||
|
||||
bool is_monitoring_domain(DeprecatedString const& domain) const { return m_monitored_domains.contains(domain); }
|
||||
bool is_monitoring_domain(ByteString const& domain) const { return m_monitored_domains.contains(domain); }
|
||||
|
||||
private:
|
||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket>, int client_id);
|
||||
|
||||
virtual void pledge_domains(Vector<DeprecatedString> const&) override;
|
||||
virtual void monitor_domain(DeprecatedString const&) override;
|
||||
virtual Messages::ConfigServer::ListConfigGroupsResponse list_config_groups([[maybe_unused]] DeprecatedString const& domain) override;
|
||||
virtual Messages::ConfigServer::ListConfigKeysResponse list_config_keys([[maybe_unused]] DeprecatedString const& domain, [[maybe_unused]] DeprecatedString const& group) override;
|
||||
virtual Messages::ConfigServer::ReadStringValueResponse read_string_value([[maybe_unused]] DeprecatedString const& domain, [[maybe_unused]] DeprecatedString const& group, [[maybe_unused]] DeprecatedString const& key) override;
|
||||
virtual Messages::ConfigServer::ReadI32ValueResponse read_i32_value([[maybe_unused]] DeprecatedString const& domain, [[maybe_unused]] DeprecatedString const& group, [[maybe_unused]] DeprecatedString const& key) override;
|
||||
virtual Messages::ConfigServer::ReadU32ValueResponse read_u32_value([[maybe_unused]] DeprecatedString const& domain, [[maybe_unused]] DeprecatedString const& group, [[maybe_unused]] DeprecatedString const& key) override;
|
||||
virtual Messages::ConfigServer::ReadBoolValueResponse read_bool_value([[maybe_unused]] DeprecatedString const& domain, [[maybe_unused]] DeprecatedString const& group, [[maybe_unused]] DeprecatedString const& key) override;
|
||||
virtual void write_string_value([[maybe_unused]] DeprecatedString const& domain, [[maybe_unused]] DeprecatedString const& group, [[maybe_unused]] DeprecatedString const& key, [[maybe_unused]] DeprecatedString const& value) override;
|
||||
virtual void write_i32_value([[maybe_unused]] DeprecatedString const& domain, [[maybe_unused]] DeprecatedString const& group, [[maybe_unused]] DeprecatedString const& key, [[maybe_unused]] i32 value) override;
|
||||
virtual void write_u32_value([[maybe_unused]] DeprecatedString const& domain, [[maybe_unused]] DeprecatedString const& group, [[maybe_unused]] DeprecatedString const& key, [[maybe_unused]] u32 value) override;
|
||||
virtual void write_bool_value([[maybe_unused]] DeprecatedString const& domain, [[maybe_unused]] DeprecatedString const& group, [[maybe_unused]] DeprecatedString const& key, [[maybe_unused]] bool value) override;
|
||||
virtual void remove_key_entry([[maybe_unused]] DeprecatedString const& domain, [[maybe_unused]] DeprecatedString const& group, [[maybe_unused]] DeprecatedString const& key) override;
|
||||
virtual void remove_group_entry([[maybe_unused]] DeprecatedString const& domain, [[maybe_unused]] DeprecatedString const& group) override;
|
||||
virtual void add_group_entry([[maybe_unused]] DeprecatedString const& domain, [[maybe_unused]] DeprecatedString const& group) override;
|
||||
virtual void pledge_domains(Vector<ByteString> const&) override;
|
||||
virtual void monitor_domain(ByteString const&) override;
|
||||
virtual Messages::ConfigServer::ListConfigGroupsResponse list_config_groups([[maybe_unused]] ByteString const& domain) override;
|
||||
virtual Messages::ConfigServer::ListConfigKeysResponse list_config_keys([[maybe_unused]] ByteString const& domain, [[maybe_unused]] ByteString const& group) override;
|
||||
virtual Messages::ConfigServer::ReadStringValueResponse read_string_value([[maybe_unused]] ByteString const& domain, [[maybe_unused]] ByteString const& group, [[maybe_unused]] ByteString const& key) override;
|
||||
virtual Messages::ConfigServer::ReadI32ValueResponse read_i32_value([[maybe_unused]] ByteString const& domain, [[maybe_unused]] ByteString const& group, [[maybe_unused]] ByteString const& key) override;
|
||||
virtual Messages::ConfigServer::ReadU32ValueResponse read_u32_value([[maybe_unused]] ByteString const& domain, [[maybe_unused]] ByteString const& group, [[maybe_unused]] ByteString const& key) override;
|
||||
virtual Messages::ConfigServer::ReadBoolValueResponse read_bool_value([[maybe_unused]] ByteString const& domain, [[maybe_unused]] ByteString const& group, [[maybe_unused]] ByteString const& key) override;
|
||||
virtual void write_string_value([[maybe_unused]] ByteString const& domain, [[maybe_unused]] ByteString const& group, [[maybe_unused]] ByteString const& key, [[maybe_unused]] ByteString const& value) override;
|
||||
virtual void write_i32_value([[maybe_unused]] ByteString const& domain, [[maybe_unused]] ByteString const& group, [[maybe_unused]] ByteString const& key, [[maybe_unused]] i32 value) override;
|
||||
virtual void write_u32_value([[maybe_unused]] ByteString const& domain, [[maybe_unused]] ByteString const& group, [[maybe_unused]] ByteString const& key, [[maybe_unused]] u32 value) override;
|
||||
virtual void write_bool_value([[maybe_unused]] ByteString const& domain, [[maybe_unused]] ByteString const& group, [[maybe_unused]] ByteString const& key, [[maybe_unused]] bool value) override;
|
||||
virtual void remove_key_entry([[maybe_unused]] ByteString const& domain, [[maybe_unused]] ByteString const& group, [[maybe_unused]] ByteString const& key) override;
|
||||
virtual void remove_group_entry([[maybe_unused]] ByteString const& domain, [[maybe_unused]] ByteString const& group) override;
|
||||
virtual void add_group_entry([[maybe_unused]] ByteString const& domain, [[maybe_unused]] ByteString const& group) override;
|
||||
|
||||
bool validate_access(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key);
|
||||
bool validate_access(ByteString const& domain, ByteString const& group, ByteString const& key);
|
||||
void sync_dirty_domains_to_disk();
|
||||
void start_or_restart_sync_timer();
|
||||
|
||||
bool m_has_pledged { false };
|
||||
HashTable<DeprecatedString> m_pledged_domains;
|
||||
HashTable<ByteString> m_pledged_domains;
|
||||
|
||||
HashTable<DeprecatedString> m_monitored_domains;
|
||||
HashTable<ByteString> m_monitored_domains;
|
||||
|
||||
NonnullRefPtr<Core::Timer> m_sync_timer;
|
||||
HashTable<DeprecatedString> m_dirty_domains;
|
||||
HashTable<ByteString> m_dirty_domains;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static void wait_until_coredump_is_ready(DeprecatedString const& coredump_path)
|
||||
static void wait_until_coredump_is_ready(ByteString const& coredump_path)
|
||||
{
|
||||
while (true) {
|
||||
struct stat statbuf;
|
||||
|
@ -32,7 +32,7 @@ static void wait_until_coredump_is_ready(DeprecatedString const& coredump_path)
|
|||
}
|
||||
}
|
||||
|
||||
static void launch_crash_reporter(DeprecatedString const& coredump_path, bool unlink_on_exit)
|
||||
static void launch_crash_reporter(ByteString const& coredump_path, bool unlink_on_exit)
|
||||
{
|
||||
auto pid = Core::Process::spawn("/bin/CrashReporter"sv,
|
||||
unlink_on_exit
|
||||
|
|
|
@ -151,7 +151,7 @@ struct ParsedDHCPv4Options {
|
|||
return values;
|
||||
}
|
||||
|
||||
DeprecatedString to_deprecated_string() const
|
||||
ByteString to_byte_string() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.append("DHCP Options ("sv);
|
||||
|
@ -163,7 +163,7 @@ struct ParsedDHCPv4Options {
|
|||
builder.appendff(" {} ", ((u8 const*)opt.value.value)[i]);
|
||||
builder.append('\n');
|
||||
}
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
struct DHCPOptionValue {
|
||||
|
|
|
@ -18,14 +18,14 @@
|
|||
#include <LibCore/Timer.h>
|
||||
#include <stdio.h>
|
||||
|
||||
static u8 mac_part(Vector<DeprecatedString> const& parts, size_t index)
|
||||
static u8 mac_part(Vector<ByteString> const& parts, size_t index)
|
||||
{
|
||||
auto result = AK::StringUtils::convert_to_uint_from_hex(parts.at(index));
|
||||
VERIFY(result.has_value());
|
||||
return result.value();
|
||||
}
|
||||
|
||||
static MACAddress mac_from_string(DeprecatedString const& str)
|
||||
static MACAddress mac_from_string(ByteString const& str)
|
||||
{
|
||||
auto chunks = str.split(':');
|
||||
VERIFY(chunks.size() == 6); // should we...worry about this?
|
||||
|
@ -117,7 +117,7 @@ static void set_params(InterfaceDescriptor const& iface, IPv4Address const& ipv4
|
|||
}
|
||||
}
|
||||
|
||||
DHCPv4Client::DHCPv4Client(Vector<DeprecatedString> interfaces_with_dhcp_enabled)
|
||||
DHCPv4Client::DHCPv4Client(Vector<ByteString> interfaces_with_dhcp_enabled)
|
||||
: m_interfaces_with_dhcp_enabled(move(interfaces_with_dhcp_enabled))
|
||||
{
|
||||
m_server = Core::UDPServer::construct(this);
|
||||
|
@ -193,13 +193,13 @@ ErrorOr<DHCPv4Client::Interfaces> DHCPv4Client::get_discoverable_interfaces()
|
|||
json.value().as_array().for_each([&ifnames_to_immediately_discover, &ifnames_to_attempt_later](auto& value) {
|
||||
auto if_object = value.as_object();
|
||||
|
||||
if (if_object.get_deprecated_string("class_name"sv).value_or({}) == "LoopbackAdapter")
|
||||
if (if_object.get_byte_string("class_name"sv).value_or({}) == "LoopbackAdapter")
|
||||
return;
|
||||
|
||||
auto name = if_object.get_deprecated_string("name"sv).value_or({});
|
||||
auto mac = if_object.get_deprecated_string("mac_address"sv).value_or({});
|
||||
auto name = if_object.get_byte_string("name"sv).value_or({});
|
||||
auto mac = if_object.get_byte_string("mac_address"sv).value_or({});
|
||||
auto is_up = if_object.get_bool("link_up"sv).value_or(false);
|
||||
auto ipv4_addr_maybe = IPv4Address::from_string(if_object.get_deprecated_string("ipv4_address"sv).value_or({}));
|
||||
auto ipv4_addr_maybe = IPv4Address::from_string(if_object.get_byte_string("ipv4_address"sv).value_or({}));
|
||||
auto ipv4_addr = ipv4_addr_maybe.has_value() ? ipv4_addr_maybe.value() : IPv4Address { 0, 0, 0, 0 };
|
||||
if (is_up) {
|
||||
dbgln_if(DHCPV4_DEBUG, "Found adapter '{}' with mac {}, and it was up!", name, mac);
|
||||
|
@ -218,7 +218,7 @@ ErrorOr<DHCPv4Client::Interfaces> DHCPv4Client::get_discoverable_interfaces()
|
|||
|
||||
void DHCPv4Client::handle_offer(DHCPv4Packet const& packet, ParsedDHCPv4Options const& options)
|
||||
{
|
||||
dbgln("We were offered {} for {}", packet.yiaddr().to_deprecated_string(), options.get<u32>(DHCPOption::IPAddressLeaseTime).value_or(0));
|
||||
dbgln("We were offered {} for {}", packet.yiaddr().to_byte_string(), options.get<u32>(DHCPOption::IPAddressLeaseTime).value_or(0));
|
||||
auto* transaction = const_cast<DHCPv4Transaction*>(m_ongoing_transactions.get(packet.xid()).value_or(nullptr));
|
||||
if (!transaction) {
|
||||
dbgln("we're not looking for {}", packet.xid());
|
||||
|
@ -239,8 +239,8 @@ void DHCPv4Client::handle_offer(DHCPv4Packet const& packet, ParsedDHCPv4Options
|
|||
void DHCPv4Client::handle_ack(DHCPv4Packet const& packet, ParsedDHCPv4Options const& options)
|
||||
{
|
||||
if constexpr (DHCPV4CLIENT_DEBUG) {
|
||||
dbgln("The DHCP server handed us {}", packet.yiaddr().to_deprecated_string());
|
||||
dbgln("Here are the options: {}", options.to_deprecated_string());
|
||||
dbgln("The DHCP server handed us {}", packet.yiaddr().to_byte_string());
|
||||
dbgln("Here are the options: {}", options.to_byte_string());
|
||||
}
|
||||
|
||||
auto* transaction = const_cast<DHCPv4Transaction*>(m_ongoing_transactions.get(packet.xid()).value_or(nullptr));
|
||||
|
@ -273,8 +273,8 @@ void DHCPv4Client::handle_ack(DHCPv4Packet const& packet, ParsedDHCPv4Options co
|
|||
|
||||
void DHCPv4Client::handle_nak(DHCPv4Packet const& packet, ParsedDHCPv4Options const& options)
|
||||
{
|
||||
dbgln("The DHCP server told us to go chase our own tail about {}", packet.yiaddr().to_deprecated_string());
|
||||
dbgln("Here are the options: {}", options.to_deprecated_string());
|
||||
dbgln("The DHCP server told us to go chase our own tail about {}", packet.yiaddr().to_byte_string());
|
||||
dbgln("Here are the options: {}", options.to_byte_string());
|
||||
// make another request a bit later :shrug:
|
||||
auto* transaction = const_cast<DHCPv4Transaction*>(m_ongoing_transactions.get(packet.xid()).value_or(nullptr));
|
||||
if (!transaction) {
|
||||
|
@ -297,7 +297,7 @@ void DHCPv4Client::process_incoming(DHCPv4Packet const& packet)
|
|||
{
|
||||
auto options = packet.parse_options();
|
||||
|
||||
dbgln_if(DHCPV4CLIENT_DEBUG, "Here are the options: {}", options.to_deprecated_string());
|
||||
dbgln_if(DHCPV4CLIENT_DEBUG, "Here are the options: {}", options.to_byte_string());
|
||||
|
||||
auto value_or_error = options.get<DHCPMessageType>(DHCPOption::DHCPMessageType);
|
||||
if (!value_or_error.has_value())
|
||||
|
@ -336,7 +336,7 @@ void DHCPv4Client::dhcp_discover(InterfaceDescriptor const& iface)
|
|||
if constexpr (DHCPV4CLIENT_DEBUG) {
|
||||
dbgln("Trying to lease an IP for {} with ID {}", iface.ifname, transaction_id);
|
||||
if (!iface.current_ip_address.is_zero())
|
||||
dbgln("going to request the server to hand us {}", iface.current_ip_address.to_deprecated_string());
|
||||
dbgln("going to request the server to hand us {}", iface.current_ip_address.to_byte_string());
|
||||
}
|
||||
|
||||
DHCPv4PacketBuilder builder;
|
||||
|
@ -364,7 +364,7 @@ void DHCPv4Client::dhcp_discover(InterfaceDescriptor const& iface)
|
|||
void DHCPv4Client::dhcp_request(DHCPv4Transaction& transaction, DHCPv4Packet const& offer)
|
||||
{
|
||||
auto& iface = transaction.interface;
|
||||
dbgln("Leasing the IP {} for adapter {}", offer.yiaddr().to_deprecated_string(), iface.ifname);
|
||||
dbgln("Leasing the IP {} for adapter {}", offer.yiaddr().to_byte_string(), iface.ifname);
|
||||
DHCPv4PacketBuilder builder;
|
||||
|
||||
DHCPv4Packet& packet = builder.peek();
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "DHCPv4.h"
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Error.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
|
@ -19,7 +19,7 @@
|
|||
#include <sys/socket.h>
|
||||
|
||||
struct InterfaceDescriptor {
|
||||
DeprecatedString ifname;
|
||||
ByteString ifname;
|
||||
MACAddress mac_address;
|
||||
IPv4Address current_ip_address;
|
||||
};
|
||||
|
@ -54,11 +54,11 @@ public:
|
|||
static ErrorOr<Interfaces> get_discoverable_interfaces();
|
||||
|
||||
private:
|
||||
explicit DHCPv4Client(Vector<DeprecatedString> interfaces_with_dhcp_enabled);
|
||||
explicit DHCPv4Client(Vector<ByteString> interfaces_with_dhcp_enabled);
|
||||
|
||||
void try_discover_ifs();
|
||||
|
||||
Vector<DeprecatedString> m_interfaces_with_dhcp_enabled;
|
||||
Vector<ByteString> m_interfaces_with_dhcp_enabled;
|
||||
HashMap<u32, OwnPtr<DHCPv4Transaction>> m_ongoing_transactions;
|
||||
RefPtr<Core::UDPServer> m_server;
|
||||
RefPtr<Core::Timer> m_check_timer;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
ErrorOr<int> serenity_main(Main::Arguments args)
|
||||
{
|
||||
Vector<DeprecatedString> interfaces;
|
||||
Vector<ByteString> interfaces;
|
||||
|
||||
Core::ArgsParser parser;
|
||||
parser.add_positional_argument(interfaces, "Interfaces to run DHCP server on", "interfaces");
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Format.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/StringView.h>
|
||||
|
@ -26,24 +26,24 @@ struct WorkItem {
|
|||
DeleteFile,
|
||||
};
|
||||
Type type;
|
||||
DeprecatedString source;
|
||||
DeprecatedString destination;
|
||||
ByteString source;
|
||||
ByteString destination;
|
||||
off_t size;
|
||||
mode_t mode { 0 };
|
||||
};
|
||||
|
||||
static void report_warning(StringView message);
|
||||
static void report_error(StringView message);
|
||||
static ErrorOr<int> perform_copy(Vector<StringView> const& sources, DeprecatedString const& destination);
|
||||
static ErrorOr<int> perform_move(Vector<StringView> const& sources, DeprecatedString const& destination);
|
||||
static ErrorOr<int> perform_copy(Vector<StringView> const& sources, ByteString const& destination);
|
||||
static ErrorOr<int> perform_move(Vector<StringView> const& sources, ByteString const& destination);
|
||||
static ErrorOr<int> perform_delete(Vector<StringView> const& sources);
|
||||
static ErrorOr<int> execute_work_items(Vector<WorkItem> const& items);
|
||||
static ErrorOr<NonnullOwnPtr<Core::File>> open_destination_file(DeprecatedString const& destination, mode_t mode);
|
||||
static DeprecatedString deduplicate_destination_file_name(DeprecatedString const& destination);
|
||||
static ErrorOr<NonnullOwnPtr<Core::File>> open_destination_file(ByteString const& destination, mode_t mode);
|
||||
static ByteString deduplicate_destination_file_name(ByteString const& destination);
|
||||
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
{
|
||||
DeprecatedString operation;
|
||||
ByteString operation;
|
||||
Vector<StringView> paths;
|
||||
|
||||
Core::ArgsParser args_parser;
|
||||
|
@ -54,7 +54,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
if (operation == "Delete")
|
||||
return perform_delete(paths);
|
||||
|
||||
DeprecatedString destination = paths.take_last();
|
||||
ByteString destination = paths.take_last();
|
||||
if (paths.is_empty())
|
||||
return Error::from_string_literal("At least one source and destination are required");
|
||||
|
||||
|
@ -64,7 +64,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
return perform_move(paths, destination);
|
||||
|
||||
// FIXME: Return the formatted string directly. There is no way to do this right now without the temporary going out of scope and being destroyed.
|
||||
report_error(DeprecatedString::formatted("Unknown operation '{}'", operation));
|
||||
report_error(ByteString::formatted("Unknown operation '{}'", operation));
|
||||
return Error::from_string_literal("Unknown operation");
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ static void report_error(StringView message)
|
|||
outln("ERROR {}", message);
|
||||
}
|
||||
|
||||
static ErrorOr<int> collect_copy_work_items(DeprecatedString const& source, DeprecatedString const& destination, Vector<WorkItem>& items)
|
||||
static ErrorOr<int> collect_copy_work_items(ByteString const& source, ByteString const& destination, Vector<WorkItem>& items)
|
||||
{
|
||||
auto const st = TRY(Core::System::lstat(source));
|
||||
if (!S_ISDIR(st.st_mode)) {
|
||||
|
@ -114,7 +114,7 @@ static ErrorOr<int> collect_copy_work_items(DeprecatedString const& source, Depr
|
|||
return 0;
|
||||
}
|
||||
|
||||
ErrorOr<int> perform_copy(Vector<StringView> const& sources, DeprecatedString const& destination)
|
||||
ErrorOr<int> perform_copy(Vector<StringView> const& sources, ByteString const& destination)
|
||||
{
|
||||
Vector<WorkItem> items;
|
||||
|
||||
|
@ -125,7 +125,7 @@ ErrorOr<int> perform_copy(Vector<StringView> const& sources, DeprecatedString co
|
|||
return execute_work_items(items);
|
||||
}
|
||||
|
||||
static ErrorOr<int> collect_move_work_items(DeprecatedString const& source, DeprecatedString const& destination, Vector<WorkItem>& items)
|
||||
static ErrorOr<int> collect_move_work_items(ByteString const& source, ByteString const& destination, Vector<WorkItem>& items)
|
||||
{
|
||||
auto const st = TRY(Core::System::lstat(source));
|
||||
if (!S_ISDIR(st.st_mode)) {
|
||||
|
@ -168,7 +168,7 @@ static ErrorOr<int> collect_move_work_items(DeprecatedString const& source, Depr
|
|||
return 0;
|
||||
}
|
||||
|
||||
ErrorOr<int> perform_move(Vector<StringView> const& sources, DeprecatedString const& destination)
|
||||
ErrorOr<int> perform_move(Vector<StringView> const& sources, ByteString const& destination)
|
||||
{
|
||||
Vector<WorkItem> items;
|
||||
|
||||
|
@ -179,7 +179,7 @@ ErrorOr<int> perform_move(Vector<StringView> const& sources, DeprecatedString co
|
|||
return execute_work_items(items);
|
||||
}
|
||||
|
||||
static ErrorOr<int> collect_delete_work_items(DeprecatedString const& source, Vector<WorkItem>& items)
|
||||
static ErrorOr<int> collect_delete_work_items(ByteString const& source, Vector<WorkItem>& items)
|
||||
{
|
||||
if (auto const st = TRY(Core::System::lstat(source)); !S_ISDIR(st.st_mode)) {
|
||||
// It's a file.
|
||||
|
@ -235,7 +235,7 @@ ErrorOr<int> execute_work_items(Vector<WorkItem> const& items)
|
|||
outln("PROGRESS {} {} {} {} {} {} {}", i, items.size(), executed_work_bytes, total_work_bytes, item_done, item.size, item.source);
|
||||
};
|
||||
|
||||
auto copy_file = [&](DeprecatedString const& source, DeprecatedString const& destination, mode_t mode) -> ErrorOr<int> {
|
||||
auto copy_file = [&](ByteString const& source, ByteString const& destination, mode_t mode) -> ErrorOr<int> {
|
||||
auto source_file = TRY(Core::File::open(source, Core::File::OpenMode::Read));
|
||||
// FIXME: When the file already exists, let the user choose the next action instead of renaming it by default.
|
||||
auto destination_file = TRY(open_destination_file(destination, mode));
|
||||
|
@ -248,7 +248,7 @@ ErrorOr<int> execute_work_items(Vector<WorkItem> const& items)
|
|||
break;
|
||||
if (auto result = destination_file->write_until_depleted(bytes_read); result.is_error()) {
|
||||
// FIXME: Return the formatted string directly. There is no way to do this right now without the temporary going out of scope and being destroyed.
|
||||
report_warning(DeprecatedString::formatted("Failed to write to destination file: {}", result.error()));
|
||||
report_warning(ByteString::formatted("Failed to write to destination file: {}", result.error()));
|
||||
return result.release_error();
|
||||
}
|
||||
item_done += bytes_read.size();
|
||||
|
@ -288,7 +288,7 @@ ErrorOr<int> execute_work_items(Vector<WorkItem> const& items)
|
|||
}
|
||||
|
||||
case WorkItem::Type::MoveFile: {
|
||||
DeprecatedString destination = item.destination;
|
||||
ByteString destination = item.destination;
|
||||
while (true) {
|
||||
auto maybe_error = Core::System::rename(item.source, destination);
|
||||
if (!maybe_error.is_error()) {
|
||||
|
@ -306,7 +306,7 @@ ErrorOr<int> execute_work_items(Vector<WorkItem> const& items)
|
|||
|
||||
if (error_code != EXDEV) {
|
||||
// FIXME: Return the formatted string directly. There is no way to do this right now without the temporary going out of scope and being destroyed.
|
||||
report_warning(DeprecatedString::formatted("Failed to move {}: {}", item.source, strerror(error_code)));
|
||||
report_warning(ByteString::formatted("Failed to move {}: {}", item.source, strerror(error_code)));
|
||||
return Error::from_errno(error_code);
|
||||
}
|
||||
|
||||
|
@ -338,7 +338,7 @@ ErrorOr<int> execute_work_items(Vector<WorkItem> const& items)
|
|||
return 0;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullOwnPtr<Core::File>> open_destination_file(DeprecatedString const& destination, mode_t mode)
|
||||
ErrorOr<NonnullOwnPtr<Core::File>> open_destination_file(ByteString const& destination, mode_t mode)
|
||||
{
|
||||
auto old_mask = umask(0);
|
||||
auto destination_file_or_error = Core::File::open(destination, (Core::File::OpenMode::Write | Core::File::OpenMode::Truncate | Core::File::OpenMode::MustBeNew), mode);
|
||||
|
@ -349,7 +349,7 @@ ErrorOr<NonnullOwnPtr<Core::File>> open_destination_file(DeprecatedString const&
|
|||
return destination_file_or_error;
|
||||
}
|
||||
|
||||
DeprecatedString deduplicate_destination_file_name(DeprecatedString const& destination)
|
||||
ByteString deduplicate_destination_file_name(ByteString const& destination)
|
||||
{
|
||||
LexicalPath destination_path(destination);
|
||||
auto title_without_counter = destination_path.title();
|
||||
|
@ -372,5 +372,5 @@ DeprecatedString deduplicate_destination_file_name(DeprecatedString const& desti
|
|||
basename.append(destination_path.extension());
|
||||
}
|
||||
|
||||
return LexicalPath::join(destination_path.dirname(), basename.to_deprecated_string()).string();
|
||||
return LexicalPath::join(destination_path.dirname(), basename.to_byte_string()).string();
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ void ConnectionFromClient::die()
|
|||
GUI::Application::the()->quit();
|
||||
}
|
||||
|
||||
void ConnectionFromClient::request_file_handler(i32 request_id, i32 window_server_client_id, i32 parent_window_id, DeprecatedString const& path, Core::File::OpenMode requested_access, ShouldPrompt prompt)
|
||||
void ConnectionFromClient::request_file_handler(i32 request_id, i32 window_server_client_id, i32 parent_window_id, ByteString const& path, Core::File::OpenMode requested_access, ShouldPrompt prompt)
|
||||
{
|
||||
VERIFY(path.starts_with("/"sv));
|
||||
|
||||
|
@ -41,7 +41,7 @@ void ConnectionFromClient::request_file_handler(i32 request_id, i32 window_serve
|
|||
approved = has_flag(maybe_permissions.value(), relevant_permissions);
|
||||
|
||||
if (!approved) {
|
||||
DeprecatedString access_string;
|
||||
ByteString access_string;
|
||||
|
||||
if (has_flag(requested_access, Core::File::OpenMode::ReadWrite))
|
||||
access_string = "read and write";
|
||||
|
@ -51,12 +51,12 @@ void ConnectionFromClient::request_file_handler(i32 request_id, i32 window_serve
|
|||
access_string = "write to";
|
||||
|
||||
auto pid = this->socket().peer_pid().release_value_but_fixme_should_propagate_errors();
|
||||
auto exe_link = LexicalPath("/proc").append(DeprecatedString::number(pid)).append("exe"sv).string();
|
||||
auto exe_link = LexicalPath("/proc").append(ByteString::number(pid)).append("exe"sv).string();
|
||||
auto exe_path = FileSystem::real_path(exe_link).release_value_but_fixme_should_propagate_errors();
|
||||
|
||||
if (prompt == ShouldPrompt::Yes) {
|
||||
VERIFY(window_server_client_id != -1 && parent_window_id != -1);
|
||||
auto exe_name = LexicalPath::basename(exe_path.to_deprecated_string());
|
||||
auto exe_name = LexicalPath::basename(exe_path.to_byte_string());
|
||||
auto text = String::formatted("Allow {} ({}) to {} \"{}\"?", exe_name, pid, access_string, path).release_value_but_fixme_should_propagate_errors();
|
||||
auto result = GUI::MessageBox::try_show({}, window_server_client_id, parent_window_id, text, "File Permissions Requested"sv).release_value_but_fixme_should_propagate_errors();
|
||||
approved = result == GUI::MessageBox::ExecResult::Yes;
|
||||
|
@ -88,40 +88,40 @@ void ConnectionFromClient::request_file_handler(i32 request_id, i32 window_serve
|
|||
}
|
||||
}
|
||||
|
||||
void ConnectionFromClient::request_file_read_only_approved(i32 request_id, DeprecatedString const& path)
|
||||
void ConnectionFromClient::request_file_read_only_approved(i32 request_id, ByteString const& path)
|
||||
{
|
||||
request_file_handler(request_id, -1, -1, path, Core::File::OpenMode::Read, ShouldPrompt::No);
|
||||
}
|
||||
|
||||
void ConnectionFromClient::request_file(i32 request_id, i32 window_server_client_id, i32 parent_window_id, DeprecatedString const& path, Core::File::OpenMode requested_access)
|
||||
void ConnectionFromClient::request_file(i32 request_id, i32 window_server_client_id, i32 parent_window_id, ByteString const& path, Core::File::OpenMode requested_access)
|
||||
{
|
||||
request_file_handler(request_id, window_server_client_id, parent_window_id, path, requested_access, ShouldPrompt::Yes);
|
||||
}
|
||||
|
||||
void ConnectionFromClient::prompt_open_file(i32 request_id, i32 window_server_client_id, i32 parent_window_id, DeprecatedString const& window_title, DeprecatedString const& path_to_view, Core::File::OpenMode requested_access, Optional<Vector<GUI::FileTypeFilter>> const& allowed_file_types)
|
||||
void ConnectionFromClient::prompt_open_file(i32 request_id, i32 window_server_client_id, i32 parent_window_id, ByteString const& window_title, ByteString const& path_to_view, Core::File::OpenMode requested_access, Optional<Vector<GUI::FileTypeFilter>> const& allowed_file_types)
|
||||
{
|
||||
auto relevant_permissions = requested_access & (Core::File::OpenMode::Read | Core::File::OpenMode::Write);
|
||||
VERIFY(relevant_permissions != Core::File::OpenMode::NotOpen);
|
||||
|
||||
auto user_picked_file = GUI::FilePicker::get_filepath({}, window_server_client_id, parent_window_id, GUI::FilePicker::Mode::Open, window_title, {}, path_to_view, allowed_file_types).release_value_but_fixme_should_propagate_errors();
|
||||
auto user_picked_file_but_fixme_should_use_string = user_picked_file.has_value() ? user_picked_file.release_value().to_deprecated_string() : Optional<DeprecatedString> {};
|
||||
auto user_picked_file_but_fixme_should_use_string = user_picked_file.has_value() ? user_picked_file.release_value().to_byte_string() : Optional<ByteString> {};
|
||||
|
||||
prompt_helper(request_id, user_picked_file_but_fixme_should_use_string, requested_access);
|
||||
}
|
||||
|
||||
void ConnectionFromClient::prompt_save_file(i32 request_id, i32 window_server_client_id, i32 parent_window_id, DeprecatedString const& name, DeprecatedString const& ext, DeprecatedString const& path_to_view, Core::File::OpenMode requested_access)
|
||||
void ConnectionFromClient::prompt_save_file(i32 request_id, i32 window_server_client_id, i32 parent_window_id, ByteString const& name, ByteString const& ext, ByteString const& path_to_view, Core::File::OpenMode requested_access)
|
||||
{
|
||||
auto relevant_permissions = requested_access & (Core::File::OpenMode::Read | Core::File::OpenMode::Write);
|
||||
VERIFY(relevant_permissions != Core::File::OpenMode::NotOpen);
|
||||
|
||||
auto basename = String::formatted("{}.{}", name, ext).release_value_but_fixme_should_propagate_errors();
|
||||
auto user_picked_file = GUI::FilePicker::get_filepath({}, window_server_client_id, parent_window_id, GUI::FilePicker::Mode::Save, {}, basename, path_to_view).release_value_but_fixme_should_propagate_errors();
|
||||
auto user_picked_file_but_fixme_should_use_string = user_picked_file.has_value() ? user_picked_file.release_value().to_deprecated_string() : Optional<DeprecatedString> {};
|
||||
auto user_picked_file_but_fixme_should_use_string = user_picked_file.has_value() ? user_picked_file.release_value().to_byte_string() : Optional<ByteString> {};
|
||||
|
||||
prompt_helper(request_id, user_picked_file_but_fixme_should_use_string, requested_access);
|
||||
}
|
||||
|
||||
void ConnectionFromClient::prompt_helper(i32 request_id, Optional<DeprecatedString> const& user_picked_file, Core::File::OpenMode requested_access)
|
||||
void ConnectionFromClient::prompt_helper(i32 request_id, Optional<ByteString> const& user_picked_file, Core::File::OpenMode requested_access)
|
||||
{
|
||||
if (user_picked_file.has_value()) {
|
||||
VERIFY(user_picked_file->starts_with("/"sv));
|
||||
|
@ -141,7 +141,7 @@ void ConnectionFromClient::prompt_helper(i32 request_id, Optional<DeprecatedStri
|
|||
async_handle_prompt_end(request_id, 0, IPC::File(*file.release_value()), user_picked_file);
|
||||
}
|
||||
} else {
|
||||
async_handle_prompt_end(request_id, ECANCELED, Optional<IPC::File> {}, Optional<DeprecatedString> {});
|
||||
async_handle_prompt_end(request_id, ECANCELED, Optional<IPC::File> {}, Optional<ByteString> {});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,22 +28,22 @@ public:
|
|||
private:
|
||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket>);
|
||||
|
||||
virtual void request_file_read_only_approved(i32, DeprecatedString const&) override;
|
||||
virtual void request_file(i32, i32, i32, DeprecatedString const&, Core::File::OpenMode) override;
|
||||
virtual void prompt_open_file(i32, i32, i32, DeprecatedString const&, DeprecatedString const&, Core::File::OpenMode, Optional<Vector<GUI::FileTypeFilter>> const&) override;
|
||||
virtual void prompt_save_file(i32, i32, i32, DeprecatedString const&, DeprecatedString const&, DeprecatedString const&, Core::File::OpenMode) override;
|
||||
virtual void request_file_read_only_approved(i32, ByteString const&) override;
|
||||
virtual void request_file(i32, i32, i32, ByteString const&, Core::File::OpenMode) override;
|
||||
virtual void prompt_open_file(i32, i32, i32, ByteString const&, ByteString const&, Core::File::OpenMode, Optional<Vector<GUI::FileTypeFilter>> const&) override;
|
||||
virtual void prompt_save_file(i32, i32, i32, ByteString const&, ByteString const&, ByteString const&, Core::File::OpenMode) override;
|
||||
|
||||
void prompt_helper(i32, Optional<DeprecatedString> const&, Core::File::OpenMode);
|
||||
void prompt_helper(i32, Optional<ByteString> const&, Core::File::OpenMode);
|
||||
|
||||
enum class ShouldPrompt {
|
||||
No,
|
||||
Yes
|
||||
};
|
||||
void request_file_handler(i32, i32, i32, DeprecatedString const&, Core::File::OpenMode, ShouldPrompt);
|
||||
void request_file_handler(i32, i32, i32, ByteString const&, Core::File::OpenMode, ShouldPrompt);
|
||||
|
||||
virtual Messages::FileSystemAccessServer::ExposeWindowServerClientIdResponse expose_window_server_client_id() override;
|
||||
|
||||
HashMap<DeprecatedString, Core::File::OpenMode> m_approved_files;
|
||||
HashMap<ByteString, Core::File::OpenMode> m_approved_files;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
endpoint FileSystemAccessClient
|
||||
{
|
||||
handle_prompt_end(i32 request_id, i32 error, Optional<IPC::File> fd, Optional<DeprecatedString> chosen_file) =|
|
||||
handle_prompt_end(i32 request_id, i32 error, Optional<IPC::File> fd, Optional<ByteString> chosen_file) =|
|
||||
}
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
|
||||
endpoint FileSystemAccessServer
|
||||
{
|
||||
request_file_read_only_approved(i32 request_id, DeprecatedString path) =|
|
||||
request_file(i32 request_id, i32 window_server_client_id, i32 window_id, DeprecatedString path, Core::File::OpenMode requested_access) =|
|
||||
prompt_open_file(i32 request_id, i32 window_server_client_id, i32 window_id, DeprecatedString window_title, DeprecatedString path_to_view, Core::File::OpenMode requested_access, Optional<Vector<GUI::FileTypeFilter>> allowed_file_types) =|
|
||||
prompt_save_file(i32 request_id, i32 window_server_client_id, i32 window_id, DeprecatedString title, DeprecatedString ext, DeprecatedString path_to_view, Core::File::OpenMode requested_access) =|
|
||||
request_file_read_only_approved(i32 request_id, ByteString path) =|
|
||||
request_file(i32 request_id, i32 window_server_client_id, i32 window_id, ByteString path, Core::File::OpenMode requested_access) =|
|
||||
prompt_open_file(i32 request_id, i32 window_server_client_id, i32 window_id, ByteString window_title, ByteString path_to_view, Core::File::OpenMode requested_access, Optional<Vector<GUI::FileTypeFilter>> allowed_file_types) =|
|
||||
prompt_save_file(i32 request_id, i32 window_server_client_id, i32 window_id, ByteString title, ByteString ext, ByteString path_to_view, Core::File::OpenMode requested_access) =|
|
||||
|
||||
expose_window_server_client_id() => (i32 client_id)
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ static void decode_image_to_bitmaps_and_durations_with_decoder(Gfx::ImageDecoder
|
|||
}
|
||||
}
|
||||
|
||||
static void decode_image_to_details(Core::AnonymousBuffer const& encoded_buffer, Optional<DeprecatedString> const& known_mime_type, bool& is_animated, u32& loop_count, Vector<Gfx::ShareableBitmap>& bitmaps, Vector<u32>& durations)
|
||||
static void decode_image_to_details(Core::AnonymousBuffer const& encoded_buffer, Optional<ByteString> const& known_mime_type, bool& is_animated, u32& loop_count, Vector<Gfx::ShareableBitmap>& bitmaps, Vector<u32>& durations)
|
||||
{
|
||||
VERIFY(bitmaps.size() == 0);
|
||||
VERIFY(durations.size() == 0);
|
||||
|
@ -57,7 +57,7 @@ static void decode_image_to_details(Core::AnonymousBuffer const& encoded_buffer,
|
|||
decode_image_to_bitmaps_and_durations_with_decoder(*decoder, bitmaps, durations);
|
||||
}
|
||||
|
||||
Messages::ImageDecoderServer::DecodeImageResponse ConnectionFromClient::decode_image(Core::AnonymousBuffer const& encoded_buffer, Optional<DeprecatedString> const& mime_type)
|
||||
Messages::ImageDecoderServer::DecodeImageResponse ConnectionFromClient::decode_image(Core::AnonymousBuffer const& encoded_buffer, Optional<ByteString> const& mime_type)
|
||||
{
|
||||
if (!encoded_buffer.is_valid()) {
|
||||
dbgln_if(IMAGE_DECODER_DEBUG, "Encoded data is invalid");
|
||||
|
|
|
@ -26,7 +26,7 @@ public:
|
|||
private:
|
||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket>);
|
||||
|
||||
virtual Messages::ImageDecoderServer::DecodeImageResponse decode_image(Core::AnonymousBuffer const&, Optional<DeprecatedString> const& mime_type) override;
|
||||
virtual Messages::ImageDecoderServer::DecodeImageResponse decode_image(Core::AnonymousBuffer const&, Optional<ByteString> const& mime_type) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
|
||||
endpoint ImageDecoderServer
|
||||
{
|
||||
decode_image(Core::AnonymousBuffer data, Optional<DeprecatedString> mime_type) => (bool is_animated, u32 loop_count, Vector<Gfx::ShareableBitmap> bitmaps, Vector<u32> durations)
|
||||
decode_image(Core::AnonymousBuffer data, Optional<ByteString> mime_type) => (bool is_animated, u32 loop_count, Vector<Gfx::ShareableBitmap> bitmaps, Vector<u32> durations)
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ void ConnectionFromClient::die()
|
|||
s_connections.remove(client_id());
|
||||
}
|
||||
|
||||
Messages::LaunchServer::OpenUrlResponse ConnectionFromClient::open_url(URL const& url, DeprecatedString const& handler_name)
|
||||
Messages::LaunchServer::OpenUrlResponse ConnectionFromClient::open_url(URL const& url, ByteString const& handler_name)
|
||||
{
|
||||
if (!m_allowlist.is_empty()) {
|
||||
bool allowed = false;
|
||||
|
@ -39,7 +39,7 @@ Messages::LaunchServer::OpenUrlResponse ConnectionFromClient::open_url(URL const
|
|||
}
|
||||
if (!allowed) {
|
||||
// You are not on the list, go home!
|
||||
did_misbehave(DeprecatedString::formatted("Client requested a combination of handler/URL that was not on the list: '{}' with '{}'", handler_name, url).characters());
|
||||
did_misbehave(ByteString::formatted("Client requested a combination of handler/URL that was not on the list: '{}' with '{}'", handler_name, url).characters());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -69,10 +69,10 @@ void ConnectionFromClient::add_allowed_url(URL const& url)
|
|||
return;
|
||||
}
|
||||
|
||||
m_allowlist.empend(DeprecatedString(), false, Vector<URL> { url });
|
||||
m_allowlist.empend(ByteString(), false, Vector<URL> { url });
|
||||
}
|
||||
|
||||
void ConnectionFromClient::add_allowed_handler_with_any_url(DeprecatedString const& handler_name)
|
||||
void ConnectionFromClient::add_allowed_handler_with_any_url(ByteString const& handler_name)
|
||||
{
|
||||
if (m_allowlist_is_sealed) {
|
||||
did_misbehave("Got request to add more allowed handlers after list was sealed");
|
||||
|
@ -87,7 +87,7 @@ void ConnectionFromClient::add_allowed_handler_with_any_url(DeprecatedString con
|
|||
m_allowlist.empend(handler_name, true, Vector<URL>());
|
||||
}
|
||||
|
||||
void ConnectionFromClient::add_allowed_handler_with_only_specific_urls(DeprecatedString const& handler_name, Vector<URL> const& urls)
|
||||
void ConnectionFromClient::add_allowed_handler_with_only_specific_urls(ByteString const& handler_name, Vector<URL> const& urls)
|
||||
{
|
||||
if (m_allowlist_is_sealed) {
|
||||
did_misbehave("Got request to add more allowed handlers after list was sealed");
|
||||
|
|
|
@ -22,16 +22,16 @@ public:
|
|||
private:
|
||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket>, int client_id);
|
||||
|
||||
virtual Messages::LaunchServer::OpenUrlResponse open_url(URL const&, DeprecatedString const&) override;
|
||||
virtual Messages::LaunchServer::OpenUrlResponse open_url(URL const&, ByteString const&) override;
|
||||
virtual Messages::LaunchServer::GetHandlersForUrlResponse get_handlers_for_url(URL const&) override;
|
||||
virtual Messages::LaunchServer::GetHandlersWithDetailsForUrlResponse get_handlers_with_details_for_url(URL const&) override;
|
||||
virtual void add_allowed_url(URL const&) override;
|
||||
virtual void add_allowed_handler_with_any_url(DeprecatedString const&) override;
|
||||
virtual void add_allowed_handler_with_only_specific_urls(DeprecatedString const&, Vector<URL> const&) override;
|
||||
virtual void add_allowed_handler_with_any_url(ByteString const&) override;
|
||||
virtual void add_allowed_handler_with_only_specific_urls(ByteString const&, Vector<URL> const&) override;
|
||||
virtual void seal_allowlist() override;
|
||||
|
||||
struct AllowlistEntry {
|
||||
DeprecatedString handler_name;
|
||||
ByteString handler_name;
|
||||
bool any_url { false };
|
||||
Vector<URL> urls;
|
||||
};
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
endpoint LaunchServer
|
||||
{
|
||||
open_url(URL url, DeprecatedString handler_name) => (bool response)
|
||||
get_handlers_for_url(URL url) => (Vector<DeprecatedString> handlers)
|
||||
get_handlers_with_details_for_url(URL url) => (Vector<DeprecatedString> handlers_details)
|
||||
open_url(URL url, ByteString handler_name) => (bool response)
|
||||
get_handlers_for_url(URL url) => (Vector<ByteString> handlers)
|
||||
get_handlers_with_details_for_url(URL url) => (Vector<ByteString> handlers_details)
|
||||
|
||||
add_allowed_url(URL url) => ()
|
||||
add_allowed_handler_with_any_url(DeprecatedString handler_name) => ()
|
||||
add_allowed_handler_with_only_specific_urls(DeprecatedString handler_name, Vector<URL> urls) => ()
|
||||
add_allowed_handler_with_any_url(ByteString handler_name) => ()
|
||||
add_allowed_handler_with_only_specific_urls(ByteString handler_name, Vector<URL> urls) => ()
|
||||
seal_allowlist() => ()
|
||||
}
|
||||
|
|
|
@ -25,9 +25,9 @@
|
|||
namespace LaunchServer {
|
||||
|
||||
static Launcher* s_the;
|
||||
static bool spawn(DeprecatedString executable, Vector<DeprecatedString> const& arguments);
|
||||
static bool spawn(ByteString executable, Vector<ByteString> const& arguments);
|
||||
|
||||
DeprecatedString Handler::name_from_executable(StringView executable)
|
||||
ByteString Handler::name_from_executable(StringView executable)
|
||||
{
|
||||
auto separator = executable.find_last('/');
|
||||
if (separator.has_value()) {
|
||||
|
@ -37,14 +37,14 @@ DeprecatedString Handler::name_from_executable(StringView executable)
|
|||
return executable;
|
||||
}
|
||||
|
||||
void Handler::from_executable(Type handler_type, DeprecatedString const& executable)
|
||||
void Handler::from_executable(Type handler_type, ByteString const& executable)
|
||||
{
|
||||
this->handler_type = handler_type;
|
||||
this->name = name_from_executable(executable);
|
||||
this->executable = executable;
|
||||
}
|
||||
|
||||
DeprecatedString Handler::to_details_str() const
|
||||
ByteString Handler::to_details_str() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
auto obj = MUST(JsonObjectSerializer<>::try_create(builder));
|
||||
|
@ -64,7 +64,7 @@ DeprecatedString Handler::to_details_str() const
|
|||
break;
|
||||
}
|
||||
MUST(obj.finish());
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
Launcher::Launcher()
|
||||
|
@ -79,18 +79,18 @@ Launcher& Launcher::the()
|
|||
return *s_the;
|
||||
}
|
||||
|
||||
void Launcher::load_handlers(DeprecatedString const& af_dir)
|
||||
void Launcher::load_handlers(ByteString const& af_dir)
|
||||
{
|
||||
Desktop::AppFile::for_each([&](auto af) {
|
||||
auto app_name = af->name();
|
||||
auto app_executable = af->executable();
|
||||
HashTable<DeprecatedString> mime_types;
|
||||
HashTable<ByteString> mime_types;
|
||||
for (auto& mime_type : af->launcher_mime_types())
|
||||
mime_types.set(mime_type);
|
||||
HashTable<DeprecatedString> file_types;
|
||||
HashTable<ByteString> file_types;
|
||||
for (auto& file_type : af->launcher_file_types())
|
||||
file_types.set(file_type);
|
||||
HashTable<DeprecatedString> protocols;
|
||||
HashTable<ByteString> protocols;
|
||||
for (auto& protocol : af->launcher_protocols())
|
||||
protocols.set(protocol);
|
||||
if (access(app_executable.characters(), X_OK) == 0)
|
||||
|
@ -129,7 +129,7 @@ void Launcher::load_config(Core::ConfigFile const& cfg)
|
|||
}
|
||||
}
|
||||
|
||||
bool Launcher::has_mime_handlers(DeprecatedString const& mime_type)
|
||||
bool Launcher::has_mime_handlers(ByteString const& mime_type)
|
||||
{
|
||||
for (auto& handler : m_handlers)
|
||||
if (handler.value.mime_types.contains(mime_type))
|
||||
|
@ -137,17 +137,17 @@ bool Launcher::has_mime_handlers(DeprecatedString const& mime_type)
|
|||
return false;
|
||||
}
|
||||
|
||||
Vector<DeprecatedString> Launcher::handlers_for_url(const URL& url)
|
||||
Vector<ByteString> Launcher::handlers_for_url(const URL& url)
|
||||
{
|
||||
Vector<DeprecatedString> handlers;
|
||||
Vector<ByteString> handlers;
|
||||
if (url.scheme() == "file") {
|
||||
for_each_handler_for_path(url.serialize_path(), [&](auto& handler) -> bool {
|
||||
handlers.append(handler.executable);
|
||||
return true;
|
||||
});
|
||||
} else {
|
||||
for_each_handler(url.scheme().to_deprecated_string(), m_protocol_handlers, [&](auto const& handler) -> bool {
|
||||
if (handler.handler_type != Handler::Type::Default || handler.protocols.contains(url.scheme().to_deprecated_string())) {
|
||||
for_each_handler(url.scheme().to_byte_string(), m_protocol_handlers, [&](auto const& handler) -> bool {
|
||||
if (handler.handler_type != Handler::Type::Default || handler.protocols.contains(url.scheme().to_byte_string())) {
|
||||
handlers.append(handler.executable);
|
||||
return true;
|
||||
}
|
||||
|
@ -157,17 +157,17 @@ Vector<DeprecatedString> Launcher::handlers_for_url(const URL& url)
|
|||
return handlers;
|
||||
}
|
||||
|
||||
Vector<DeprecatedString> Launcher::handlers_with_details_for_url(const URL& url)
|
||||
Vector<ByteString> Launcher::handlers_with_details_for_url(const URL& url)
|
||||
{
|
||||
Vector<DeprecatedString> handlers;
|
||||
Vector<ByteString> handlers;
|
||||
if (url.scheme() == "file") {
|
||||
for_each_handler_for_path(url.serialize_path(), [&](auto& handler) -> bool {
|
||||
handlers.append(handler.to_details_str());
|
||||
return true;
|
||||
});
|
||||
} else {
|
||||
for_each_handler(url.scheme().to_deprecated_string(), m_protocol_handlers, [&](auto const& handler) -> bool {
|
||||
if (handler.handler_type != Handler::Type::Default || handler.protocols.contains(url.scheme().to_deprecated_string())) {
|
||||
for_each_handler(url.scheme().to_byte_string(), m_protocol_handlers, [&](auto const& handler) -> bool {
|
||||
if (handler.handler_type != Handler::Type::Default || handler.protocols.contains(url.scheme().to_byte_string())) {
|
||||
handlers.append(handler.to_details_str());
|
||||
return true;
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ Vector<DeprecatedString> Launcher::handlers_with_details_for_url(const URL& url)
|
|||
return handlers;
|
||||
}
|
||||
|
||||
Optional<StringView> Launcher::mime_type_for_file(DeprecatedString path)
|
||||
Optional<StringView> Launcher::mime_type_for_file(ByteString path)
|
||||
{
|
||||
auto file_or_error = Core::File::open(path, Core::File::OpenMode::Read);
|
||||
if (file_or_error.is_error())
|
||||
|
@ -186,7 +186,7 @@ Optional<StringView> Launcher::mime_type_for_file(DeprecatedString path)
|
|||
return Core::guess_mime_type_based_on_sniffed_bytes(*file_or_error.release_value());
|
||||
}
|
||||
|
||||
bool Launcher::open_url(const URL& url, DeprecatedString const& handler_name)
|
||||
bool Launcher::open_url(const URL& url, ByteString const& handler_name)
|
||||
{
|
||||
if (!handler_name.is_empty())
|
||||
return open_with_handler_name(url, handler_name);
|
||||
|
@ -194,30 +194,30 @@ bool Launcher::open_url(const URL& url, DeprecatedString const& handler_name)
|
|||
if (url.scheme() == "file")
|
||||
return open_file_url(url);
|
||||
|
||||
return open_with_user_preferences(m_protocol_handlers, url.scheme().to_deprecated_string(), { url.to_deprecated_string() });
|
||||
return open_with_user_preferences(m_protocol_handlers, url.scheme().to_byte_string(), { url.to_byte_string() });
|
||||
}
|
||||
|
||||
bool Launcher::open_with_handler_name(const URL& url, DeprecatedString const& handler_name)
|
||||
bool Launcher::open_with_handler_name(const URL& url, ByteString const& handler_name)
|
||||
{
|
||||
auto handler_optional = m_handlers.get(handler_name);
|
||||
if (!handler_optional.has_value())
|
||||
return false;
|
||||
|
||||
auto& handler = handler_optional.value();
|
||||
DeprecatedString argument;
|
||||
ByteString argument;
|
||||
if (url.scheme() == "file")
|
||||
argument = url.serialize_path();
|
||||
else
|
||||
argument = url.to_deprecated_string();
|
||||
argument = url.to_byte_string();
|
||||
return spawn(handler.executable, { argument });
|
||||
}
|
||||
|
||||
bool spawn(DeprecatedString executable, Vector<DeprecatedString> const& arguments)
|
||||
bool spawn(ByteString executable, Vector<ByteString> const& arguments)
|
||||
{
|
||||
return !Core::Process::spawn(executable, arguments).is_error();
|
||||
}
|
||||
|
||||
Handler Launcher::get_handler_for_executable(Handler::Type handler_type, DeprecatedString const& executable) const
|
||||
Handler Launcher::get_handler_for_executable(Handler::Type handler_type, ByteString const& executable) const
|
||||
{
|
||||
Handler handler;
|
||||
auto existing_handler = m_handlers.get(executable);
|
||||
|
@ -230,13 +230,13 @@ Handler Launcher::get_handler_for_executable(Handler::Type handler_type, Depreca
|
|||
return handler;
|
||||
}
|
||||
|
||||
bool Launcher::open_with_user_preferences(HashMap<DeprecatedString, DeprecatedString> const& user_preferences, DeprecatedString const& key, Vector<DeprecatedString> const& arguments, DeprecatedString const& default_program)
|
||||
bool Launcher::open_with_user_preferences(HashMap<ByteString, ByteString> const& user_preferences, ByteString const& key, Vector<ByteString> const& arguments, ByteString const& default_program)
|
||||
{
|
||||
auto program_path = user_preferences.get(key);
|
||||
if (program_path.has_value())
|
||||
return spawn(program_path.value(), arguments);
|
||||
|
||||
DeprecatedString executable = "";
|
||||
ByteString executable = "";
|
||||
if (for_each_handler(key, user_preferences, [&](auto const& handler) -> bool {
|
||||
if (executable.is_empty() && (handler.mime_types.contains(key) || handler.file_types.contains(key) || handler.protocols.contains(key))) {
|
||||
executable = handler.executable;
|
||||
|
@ -259,7 +259,7 @@ bool Launcher::open_with_user_preferences(HashMap<DeprecatedString, DeprecatedSt
|
|||
return false;
|
||||
}
|
||||
|
||||
size_t Launcher::for_each_handler(DeprecatedString const& key, HashMap<DeprecatedString, DeprecatedString> const& user_preference, Function<bool(Handler const&)> f)
|
||||
size_t Launcher::for_each_handler(ByteString const& key, HashMap<ByteString, ByteString> const& user_preference, Function<bool(Handler const&)> f)
|
||||
{
|
||||
auto user_preferred = user_preference.get(key);
|
||||
if (user_preferred.has_value())
|
||||
|
@ -282,7 +282,7 @@ size_t Launcher::for_each_handler(DeprecatedString const& key, HashMap<Deprecate
|
|||
return counted;
|
||||
}
|
||||
|
||||
void Launcher::for_each_handler_for_path(DeprecatedString const& path, Function<bool(Handler const&)> f)
|
||||
void Launcher::for_each_handler_for_path(ByteString const& path, Function<bool(Handler const&)> f)
|
||||
{
|
||||
struct stat st;
|
||||
if (lstat(path.characters(), &st) < 0) {
|
||||
|
@ -309,7 +309,7 @@ void Launcher::for_each_handler_for_path(DeprecatedString const& path, Function<
|
|||
return;
|
||||
}
|
||||
|
||||
auto link_target = LexicalPath { link_target_or_error.release_value().to_deprecated_string() };
|
||||
auto link_target = LexicalPath { link_target_or_error.release_value().to_byte_string() };
|
||||
LexicalPath absolute_link_target = link_target.is_absolute() ? link_target : LexicalPath::join(LexicalPath::dirname(path), link_target.string());
|
||||
auto real_path_or_error = FileSystem::real_path(absolute_link_target.string());
|
||||
if (real_path_or_error.is_error()) {
|
||||
|
@ -318,7 +318,7 @@ void Launcher::for_each_handler_for_path(DeprecatedString const& path, Function<
|
|||
}
|
||||
auto real_path = real_path_or_error.release_value();
|
||||
|
||||
return for_each_handler_for_path(real_path.to_deprecated_string(), [&](auto const& handler) -> bool {
|
||||
return for_each_handler_for_path(real_path.to_byte_string(), [&](auto const& handler) -> bool {
|
||||
return f(handler);
|
||||
});
|
||||
}
|
||||
|
@ -356,13 +356,13 @@ bool Launcher::open_file_url(const URL& url)
|
|||
}
|
||||
|
||||
if (S_ISDIR(st.st_mode)) {
|
||||
Vector<DeprecatedString> fm_arguments;
|
||||
Vector<ByteString> fm_arguments;
|
||||
if (!url.fragment().has_value() || url.fragment()->is_empty()) {
|
||||
fm_arguments.append(file_path);
|
||||
} else {
|
||||
fm_arguments.append("-s");
|
||||
fm_arguments.append("-r");
|
||||
fm_arguments.append(DeprecatedString::formatted("{}/{}", file_path, *url.fragment()));
|
||||
fm_arguments.append(ByteString::formatted("{}/{}", file_path, *url.fragment()));
|
||||
}
|
||||
|
||||
auto handler_optional = m_file_handlers.get("directory");
|
||||
|
@ -385,13 +385,13 @@ bool Launcher::open_file_url(const URL& url)
|
|||
mime_type_or_extension = mime_type.value();
|
||||
|
||||
auto handler_optional = m_file_handlers.get("txt");
|
||||
DeprecatedString default_handler = "";
|
||||
ByteString default_handler = "";
|
||||
if (handler_optional.has_value())
|
||||
default_handler = handler_optional.value();
|
||||
|
||||
// Additional parameters parsing, specific for the file protocol and txt file handlers
|
||||
Vector<DeprecatedString> additional_parameters;
|
||||
DeprecatedString filepath = url.serialize_path();
|
||||
Vector<ByteString> additional_parameters;
|
||||
ByteString filepath = url.serialize_path();
|
||||
|
||||
if (url.query().has_value()) {
|
||||
url.query()->bytes_as_string_view().for_each_split_view('&', SplitBehavior::Nothing, [&](auto parameter) {
|
||||
|
@ -400,7 +400,7 @@ bool Launcher::open_file_url(const URL& url)
|
|||
auto line = pair[1].to_int();
|
||||
if (line.has_value())
|
||||
// TextEditor uses file:line:col to open a file at a specific line number
|
||||
filepath = DeprecatedString::formatted("{}:{}", filepath, line.value());
|
||||
filepath = ByteString::formatted("{}:{}", filepath, line.value());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -22,15 +22,15 @@ struct Handler {
|
|||
UserDefault
|
||||
};
|
||||
Type handler_type;
|
||||
DeprecatedString name;
|
||||
DeprecatedString executable;
|
||||
HashTable<DeprecatedString> mime_types {};
|
||||
HashTable<DeprecatedString> file_types {};
|
||||
HashTable<DeprecatedString> protocols {};
|
||||
ByteString name;
|
||||
ByteString executable;
|
||||
HashTable<ByteString> mime_types {};
|
||||
HashTable<ByteString> file_types {};
|
||||
HashTable<ByteString> protocols {};
|
||||
|
||||
static DeprecatedString name_from_executable(StringView);
|
||||
void from_executable(Type, DeprecatedString const&);
|
||||
DeprecatedString to_details_str() const;
|
||||
static ByteString name_from_executable(StringView);
|
||||
void from_executable(Type, ByteString const&);
|
||||
ByteString to_details_str() const;
|
||||
};
|
||||
|
||||
class Launcher {
|
||||
|
@ -38,25 +38,25 @@ public:
|
|||
Launcher();
|
||||
static Launcher& the();
|
||||
|
||||
void load_handlers(DeprecatedString const& af_dir = Desktop::AppFile::APP_FILES_DIRECTORY);
|
||||
void load_handlers(ByteString const& af_dir = Desktop::AppFile::APP_FILES_DIRECTORY);
|
||||
void load_config(Core::ConfigFile const&);
|
||||
bool open_url(const URL&, DeprecatedString const& handler_name);
|
||||
Vector<DeprecatedString> handlers_for_url(const URL&);
|
||||
Vector<DeprecatedString> handlers_with_details_for_url(const URL&);
|
||||
bool open_url(const URL&, ByteString const& handler_name);
|
||||
Vector<ByteString> handlers_for_url(const URL&);
|
||||
Vector<ByteString> handlers_with_details_for_url(const URL&);
|
||||
|
||||
private:
|
||||
HashMap<DeprecatedString, Handler> m_handlers;
|
||||
HashMap<DeprecatedString, DeprecatedString> m_protocol_handlers;
|
||||
HashMap<DeprecatedString, DeprecatedString> m_file_handlers;
|
||||
HashMap<DeprecatedString, DeprecatedString> m_mime_handlers;
|
||||
HashMap<ByteString, Handler> m_handlers;
|
||||
HashMap<ByteString, ByteString> m_protocol_handlers;
|
||||
HashMap<ByteString, ByteString> m_file_handlers;
|
||||
HashMap<ByteString, ByteString> m_mime_handlers;
|
||||
|
||||
bool has_mime_handlers(DeprecatedString const&);
|
||||
Optional<StringView> mime_type_for_file(DeprecatedString path);
|
||||
Handler get_handler_for_executable(Handler::Type, DeprecatedString const&) const;
|
||||
size_t for_each_handler(DeprecatedString const& key, HashMap<DeprecatedString, DeprecatedString> const& user_preferences, Function<bool(Handler const&)> f);
|
||||
void for_each_handler_for_path(DeprecatedString const&, Function<bool(Handler const&)> f);
|
||||
bool has_mime_handlers(ByteString const&);
|
||||
Optional<StringView> mime_type_for_file(ByteString path);
|
||||
Handler get_handler_for_executable(Handler::Type, ByteString const&) const;
|
||||
size_t for_each_handler(ByteString const& key, HashMap<ByteString, ByteString> const& user_preferences, Function<bool(Handler const&)> f);
|
||||
void for_each_handler_for_path(ByteString const&, Function<bool(Handler const&)> f);
|
||||
bool open_file_url(const URL&);
|
||||
bool open_with_user_preferences(HashMap<DeprecatedString, DeprecatedString> const& user_preferences, DeprecatedString const& key, Vector<DeprecatedString> const& arguments, DeprecatedString const& default_program = {});
|
||||
bool open_with_handler_name(const URL&, DeprecatedString const& handler_name);
|
||||
bool open_with_user_preferences(HashMap<ByteString, ByteString> const& user_preferences, ByteString const& key, Vector<ByteString> const& arguments, ByteString const& default_program = {});
|
||||
bool open_with_handler_name(const URL&, ByteString const& handler_name);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -20,10 +20,10 @@ public:
|
|||
|
||||
Function<void()> on_submit;
|
||||
|
||||
DeprecatedString username() const { return m_username->text(); }
|
||||
ByteString username() const { return m_username->text(); }
|
||||
void set_username(StringView username) { m_username->set_text(username); }
|
||||
|
||||
DeprecatedString password() const { return m_password->text(); }
|
||||
ByteString password() const { return m_password->text(); }
|
||||
void set_password(StringView password) { m_password->set_text(password); }
|
||||
|
||||
void set_fail_message(StringView message) { m_fail_message->set_text(String::from_utf8(message).release_value_but_fixme_should_propagate_errors()); }
|
||||
|
|
|
@ -26,7 +26,7 @@ void ConnectionFromClient::die()
|
|||
s_connections.remove(client_id());
|
||||
}
|
||||
|
||||
Messages::LookupServer::LookupNameResponse ConnectionFromClient::lookup_name(DeprecatedString const& name)
|
||||
Messages::LookupServer::LookupNameResponse ConnectionFromClient::lookup_name(ByteString const& name)
|
||||
{
|
||||
auto maybe_answers = LookupServer::the().lookup(name, RecordType::A);
|
||||
if (maybe_answers.is_error()) {
|
||||
|
@ -35,19 +35,19 @@ Messages::LookupServer::LookupNameResponse ConnectionFromClient::lookup_name(Dep
|
|||
}
|
||||
|
||||
auto answers = maybe_answers.release_value();
|
||||
Vector<DeprecatedString> addresses;
|
||||
Vector<ByteString> addresses;
|
||||
for (auto& answer : answers) {
|
||||
addresses.append(answer.record_data());
|
||||
}
|
||||
return { 0, move(addresses) };
|
||||
}
|
||||
|
||||
Messages::LookupServer::LookupAddressResponse ConnectionFromClient::lookup_address(DeprecatedString const& address)
|
||||
Messages::LookupServer::LookupAddressResponse ConnectionFromClient::lookup_address(ByteString const& address)
|
||||
{
|
||||
if (address.length() != 4)
|
||||
return { 1, DeprecatedString() };
|
||||
return { 1, ByteString() };
|
||||
IPv4Address ip_address { (u8 const*)address.characters() };
|
||||
auto name = DeprecatedString::formatted("{}.{}.{}.{}.in-addr.arpa",
|
||||
auto name = ByteString::formatted("{}.{}.{}.{}.in-addr.arpa",
|
||||
ip_address[3],
|
||||
ip_address[2],
|
||||
ip_address[1],
|
||||
|
@ -56,12 +56,12 @@ Messages::LookupServer::LookupAddressResponse ConnectionFromClient::lookup_addre
|
|||
auto maybe_answers = LookupServer::the().lookup(name, RecordType::PTR);
|
||||
if (maybe_answers.is_error()) {
|
||||
dbgln("LookupServer: Failed to lookup PTR record: {}", maybe_answers.error());
|
||||
return { 1, DeprecatedString() };
|
||||
return { 1, ByteString() };
|
||||
}
|
||||
|
||||
auto answers = maybe_answers.release_value();
|
||||
if (answers.is_empty())
|
||||
return { 1, DeprecatedString() };
|
||||
return { 1, ByteString() };
|
||||
return { 0, answers[0].record_data() };
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,8 +25,8 @@ public:
|
|||
private:
|
||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket>, int client_id);
|
||||
|
||||
virtual Messages::LookupServer::LookupNameResponse lookup_name(DeprecatedString const&) override;
|
||||
virtual Messages::LookupServer::LookupAddressResponse lookup_address(DeprecatedString const&) override;
|
||||
virtual Messages::LookupServer::LookupNameResponse lookup_name(ByteString const&) override;
|
||||
virtual Messages::LookupServer::LookupAddressResponse lookup_address(ByteString const&) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
#include "LookupServer.h"
|
||||
#include "ConnectionFromClient.h"
|
||||
#include <AK/BufferedStream.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Debug.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/Random.h>
|
||||
#include <AK/StdLibExtras.h>
|
||||
|
@ -89,7 +89,7 @@ void LookupServer::load_etc_hosts()
|
|||
ErrorOr<HashMap<Name, Vector<Answer>, Name::Traits>> LookupServer::try_load_etc_hosts()
|
||||
{
|
||||
HashMap<Name, Vector<Answer>, Name::Traits> map;
|
||||
auto add_answer = [&map](Name const& name, RecordType record_type, DeprecatedString data) -> ErrorOr<void> {
|
||||
auto add_answer = [&map](Name const& name, RecordType record_type, ByteString data) -> ErrorOr<void> {
|
||||
// FIXME: Since try_ensure does not return a reference to the contained value, we have to
|
||||
// retrieve it separately. This is a try_ensure bug that should be fixed.
|
||||
TRY(map.try_ensure(name, []() { return Vector<Answer> {}; }));
|
||||
|
@ -132,18 +132,18 @@ ErrorOr<HashMap<Name, Vector<Answer>, Name::Traits>> LookupServer::try_load_etc_
|
|||
auto raw_addr = maybe_address->to_in_addr_t();
|
||||
|
||||
Name name { fields[1] };
|
||||
TRY(add_answer(name, RecordType::A, DeprecatedString { (char const*)&raw_addr, sizeof(raw_addr) }));
|
||||
TRY(add_answer(name, RecordType::A, ByteString { (char const*)&raw_addr, sizeof(raw_addr) }));
|
||||
|
||||
StringBuilder builder;
|
||||
TRY(builder.try_append(maybe_address->to_deprecated_string_reversed()));
|
||||
TRY(builder.try_append(maybe_address->to_byte_string_reversed()));
|
||||
TRY(builder.try_append(".in-addr.arpa"sv));
|
||||
TRY(add_answer(builder.to_deprecated_string(), RecordType::PTR, name.as_string()));
|
||||
TRY(add_answer(builder.to_byte_string(), RecordType::PTR, name.as_string()));
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
static DeprecatedString get_hostname()
|
||||
static ByteString get_hostname()
|
||||
{
|
||||
char buffer[_POSIX_HOST_NAME_MAX];
|
||||
VERIFY(gethostname(buffer, sizeof(buffer)) == 0);
|
||||
|
@ -182,7 +182,7 @@ ErrorOr<Vector<Answer>> LookupServer::lookup(Name const& name, RecordType record
|
|||
if (record_type == RecordType::A && get_hostname() == name) {
|
||||
IPv4Address address = { 127, 0, 0, 1 };
|
||||
auto raw_address = address.to_in_addr_t();
|
||||
Answer answer { name, RecordType::A, RecordClass::IN, s_static_ttl, DeprecatedString { (char const*)&raw_address, sizeof(raw_address) }, false };
|
||||
Answer answer { name, RecordType::A, RecordClass::IN, s_static_ttl, ByteString { (char const*)&raw_address, sizeof(raw_address) }, false };
|
||||
answers.append(move(answer));
|
||||
return answers;
|
||||
}
|
||||
|
@ -245,7 +245,7 @@ ErrorOr<Vector<Answer>> LookupServer::lookup(Name const& name, RecordType record
|
|||
return answers;
|
||||
}
|
||||
|
||||
ErrorOr<Vector<Answer>> LookupServer::lookup(Name const& name, DeprecatedString const& nameserver, bool& did_get_response, RecordType record_type, ShouldRandomizeCase should_randomize_case)
|
||||
ErrorOr<Vector<Answer>> LookupServer::lookup(Name const& name, ByteString const& nameserver, bool& did_get_response, RecordType record_type, ShouldRandomizeCase should_randomize_case)
|
||||
{
|
||||
Packet request;
|
||||
request.set_is_query();
|
||||
|
|
|
@ -33,12 +33,12 @@ private:
|
|||
void load_etc_hosts();
|
||||
void put_in_cache(Answer const&);
|
||||
|
||||
ErrorOr<Vector<Answer>> lookup(Name const& hostname, DeprecatedString const& nameserver, bool& did_get_response, RecordType record_type, ShouldRandomizeCase = ShouldRandomizeCase::Yes);
|
||||
ErrorOr<Vector<Answer>> lookup(Name const& hostname, ByteString const& nameserver, bool& did_get_response, RecordType record_type, ShouldRandomizeCase = ShouldRandomizeCase::Yes);
|
||||
|
||||
OwnPtr<IPC::MultiServer<ConnectionFromClient>> m_server;
|
||||
RefPtr<DNSServer> m_dns_server;
|
||||
RefPtr<MulticastDNS> m_mdns;
|
||||
Vector<DeprecatedString> m_nameservers;
|
||||
Vector<ByteString> m_nameservers;
|
||||
RefPtr<Core::FileWatcher> m_file_watcher;
|
||||
HashMap<Name, Vector<Answer>, Name::Traits> m_etc_hosts;
|
||||
HashMap<Name, Vector<Answer>, Name::Traits> m_lookup_cache;
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
endpoint LookupServer
|
||||
{
|
||||
// Keep these definitions synchronized with gethostbyname and gethostbyaddr in netdb.cpp
|
||||
lookup_name(DeprecatedString name) => (int code, Vector<DeprecatedString> addresses)
|
||||
lookup_address(DeprecatedString address) => (int code, DeprecatedString name)
|
||||
lookup_name(ByteString name) => (int code, Vector<ByteString> addresses)
|
||||
lookup_address(ByteString address) => (int code, ByteString name)
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
#include "MulticastDNS.h"
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/IPv4Address.h>
|
||||
#include <AK/JsonArray.h>
|
||||
#include <AK/JsonObject.h>
|
||||
|
@ -28,7 +28,7 @@ MulticastDNS::MulticastDNS(Core::EventReceiver* parent)
|
|||
if (gethostname(buffer, sizeof(buffer)) < 0) {
|
||||
perror("gethostname");
|
||||
} else {
|
||||
m_hostname = DeprecatedString::formatted("{}.local", buffer);
|
||||
m_hostname = ByteString::formatted("{}.local", buffer);
|
||||
}
|
||||
|
||||
u8 zero = 0;
|
||||
|
@ -92,7 +92,7 @@ void MulticastDNS::announce()
|
|||
RecordType::A,
|
||||
RecordClass::IN,
|
||||
120,
|
||||
DeprecatedString { (char const*)&raw_addr, sizeof(raw_addr) },
|
||||
ByteString { (char const*)&raw_addr, sizeof(raw_addr) },
|
||||
true,
|
||||
};
|
||||
response.add_answer(answer);
|
||||
|
@ -133,7 +133,7 @@ Vector<IPv4Address> MulticastDNS::local_addresses() const
|
|||
|
||||
json_or_error.value().as_array().for_each([&addresses](auto& value) {
|
||||
auto if_object = value.as_object();
|
||||
auto address = if_object.get_deprecated_string("ipv4_address"sv).value_or({});
|
||||
auto address = if_object.get_byte_string("ipv4_address"sv).value_or({});
|
||||
auto ipv4_address = IPv4Address::from_string(address);
|
||||
// Skip unconfigured interfaces.
|
||||
if (!ipv4_address.has_value())
|
||||
|
|
|
@ -42,15 +42,15 @@ ErrorOr<int> serenity_main(Main::Arguments)
|
|||
struct InterfaceConfig {
|
||||
bool enabled = false;
|
||||
bool dhcp_enabled = false;
|
||||
DeprecatedString ipv4_address = "0.0.0.0"sv;
|
||||
DeprecatedString ipv4_netmask = "0.0.0.0"sv;
|
||||
DeprecatedString ipv4_gateway = "0.0.0.0"sv;
|
||||
ByteString ipv4_address = "0.0.0.0"sv;
|
||||
ByteString ipv4_netmask = "0.0.0.0"sv;
|
||||
ByteString ipv4_gateway = "0.0.0.0"sv;
|
||||
};
|
||||
|
||||
Vector<DeprecatedString> interfaces_with_dhcp_enabled;
|
||||
Vector<ByteString> interfaces_with_dhcp_enabled;
|
||||
proc_net_adapters_json.as_array().for_each([&](auto& value) {
|
||||
auto& if_object = value.as_object();
|
||||
auto ifname = if_object.get_deprecated_string("name"sv).value_or({});
|
||||
auto ifname = if_object.get_byte_string("name"sv).value_or({});
|
||||
|
||||
if (ifname == "loop"sv)
|
||||
return;
|
||||
|
|
|
@ -23,7 +23,7 @@ void request_did_finish(URL const& url, Core::Socket const* socket)
|
|||
|
||||
dbgln_if(REQUESTSERVER_DEBUG, "Request for {} finished", url);
|
||||
|
||||
ConnectionKey partial_key { url.serialized_host().release_value_but_fixme_should_propagate_errors().to_deprecated_string(), url.port_or_default() };
|
||||
ConnectionKey partial_key { url.serialized_host().release_value_but_fixme_should_propagate_errors().to_byte_string(), url.port_or_default() };
|
||||
auto fire_off_next_job = [&](auto& cache) {
|
||||
auto it = find_if(cache.begin(), cache.end(), [&](auto& connection) { return connection.key.hostname == partial_key.hostname && connection.key.port == partial_key.port; });
|
||||
if (it == cache.end()) {
|
||||
|
|
|
@ -37,14 +37,14 @@ struct Proxy {
|
|||
ErrorOr<NonnullOwnPtr<StorageType>> tunnel(URL const& url, Args&&... args)
|
||||
{
|
||||
if (data.type == Core::ProxyData::Direct) {
|
||||
return TRY(SocketType::connect(url.serialized_host().release_value_but_fixme_should_propagate_errors().to_deprecated_string(), url.port_or_default(), forward<Args>(args)...));
|
||||
return TRY(SocketType::connect(url.serialized_host().release_value_but_fixme_should_propagate_errors().to_byte_string(), url.port_or_default(), forward<Args>(args)...));
|
||||
}
|
||||
if (data.type == Core::ProxyData::SOCKS5) {
|
||||
if constexpr (requires { SocketType::connect(declval<DeprecatedString>(), *proxy_client_storage, forward<Args>(args)...); }) {
|
||||
proxy_client_storage = TRY(Core::SOCKSProxyClient::connect(data.host_ipv4, data.port, Core::SOCKSProxyClient::Version::V5, url.serialized_host().release_value_but_fixme_should_propagate_errors().to_deprecated_string(), url.port_or_default()));
|
||||
return TRY(SocketType::connect(url.serialized_host().release_value_but_fixme_should_propagate_errors().to_deprecated_string(), *proxy_client_storage, forward<Args>(args)...));
|
||||
if constexpr (requires { SocketType::connect(declval<ByteString>(), *proxy_client_storage, forward<Args>(args)...); }) {
|
||||
proxy_client_storage = TRY(Core::SOCKSProxyClient::connect(data.host_ipv4, data.port, Core::SOCKSProxyClient::Version::V5, url.serialized_host().release_value_but_fixme_should_propagate_errors().to_byte_string(), url.port_or_default()));
|
||||
return TRY(SocketType::connect(url.serialized_host().release_value_but_fixme_should_propagate_errors().to_byte_string(), *proxy_client_storage, forward<Args>(args)...));
|
||||
} else if constexpr (IsSame<SocketType, Core::TCPSocket>) {
|
||||
return TRY(Core::SOCKSProxyClient::connect(data.host_ipv4, data.port, Core::SOCKSProxyClient::Version::V5, url.serialized_host().release_value_but_fixme_should_propagate_errors().to_deprecated_string(), url.port_or_default()));
|
||||
return TRY(Core::SOCKSProxyClient::connect(data.host_ipv4, data.port, Core::SOCKSProxyClient::Version::V5, url.serialized_host().release_value_but_fixme_should_propagate_errors().to_byte_string(), url.port_or_default()));
|
||||
} else {
|
||||
return Error::from_string_literal("SOCKS5 not supported for this socket type");
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ struct Connection {
|
|||
};
|
||||
|
||||
struct ConnectionKey {
|
||||
DeprecatedString hostname;
|
||||
ByteString hostname;
|
||||
u16 port { 0 };
|
||||
Core::ProxyData proxy_data {};
|
||||
|
||||
|
@ -173,7 +173,7 @@ ErrorOr<void> recreate_socket_if_needed(T& connection, URL const& url)
|
|||
decltype(auto) get_or_create_connection(auto& cache, URL const& url, auto& job, Core::ProxyData proxy_data = {})
|
||||
{
|
||||
using CacheEntryType = RemoveCVReference<decltype(*cache.begin()->value)>;
|
||||
auto& sockets_for_url = *cache.ensure({ url.serialized_host().release_value_but_fixme_should_propagate_errors().to_deprecated_string(), url.port_or_default(), proxy_data }, [] { return make<CacheEntryType>(); });
|
||||
auto& sockets_for_url = *cache.ensure({ url.serialized_host().release_value_but_fixme_should_propagate_errors().to_byte_string(), url.port_or_default(), proxy_data }, [] { return make<CacheEntryType>(); });
|
||||
|
||||
Proxy proxy { proxy_data };
|
||||
|
||||
|
|
|
@ -30,19 +30,19 @@ void ConnectionFromClient::die()
|
|||
Core::EventLoop::current().quit(0);
|
||||
}
|
||||
|
||||
Messages::RequestServer::IsSupportedProtocolResponse ConnectionFromClient::is_supported_protocol(DeprecatedString const& protocol)
|
||||
Messages::RequestServer::IsSupportedProtocolResponse ConnectionFromClient::is_supported_protocol(ByteString const& protocol)
|
||||
{
|
||||
bool supported = Protocol::find_by_name(protocol.to_lowercase());
|
||||
return supported;
|
||||
}
|
||||
|
||||
Messages::RequestServer::StartRequestResponse ConnectionFromClient::start_request(DeprecatedString const& method, URL const& url, HashMap<DeprecatedString, DeprecatedString> const& request_headers, ByteBuffer const& request_body, Core::ProxyData const& proxy_data)
|
||||
Messages::RequestServer::StartRequestResponse ConnectionFromClient::start_request(ByteString const& method, URL const& url, HashMap<ByteString, ByteString> const& request_headers, ByteBuffer const& request_body, Core::ProxyData const& proxy_data)
|
||||
{
|
||||
if (!url.is_valid()) {
|
||||
dbgln("StartRequest: Invalid URL requested: '{}'", url);
|
||||
return { -1, Optional<IPC::File> {} };
|
||||
}
|
||||
auto* protocol = Protocol::find_by_name(url.scheme().to_deprecated_string());
|
||||
auto* protocol = Protocol::find_by_name(url.scheme().to_byte_string());
|
||||
if (!protocol) {
|
||||
dbgln("StartRequest: No protocol handler for URL: '{}'", url);
|
||||
return { -1, Optional<IPC::File> {} };
|
||||
|
@ -94,7 +94,7 @@ void ConnectionFromClient::did_request_certificates(Badge<Request>, Request& req
|
|||
async_certificate_requested(request.id());
|
||||
}
|
||||
|
||||
Messages::RequestServer::SetCertificateResponse ConnectionFromClient::set_certificate(i32 request_id, DeprecatedString const& certificate, DeprecatedString const& key)
|
||||
Messages::RequestServer::SetCertificateResponse ConnectionFromClient::set_certificate(i32 request_id, ByteString const& certificate, ByteString const& key)
|
||||
{
|
||||
auto* request = const_cast<Request*>(m_requests.get(request_id).value_or(nullptr));
|
||||
bool success = false;
|
||||
|
@ -147,7 +147,7 @@ void ConnectionFromClient::ensure_connection(URL const& url, ::RequestServer::Ca
|
|||
}
|
||||
|
||||
if (cache_level == CacheLevel::ResolveOnly) {
|
||||
return Core::deferred_invoke([host = url.serialized_host().release_value_but_fixme_should_propagate_errors().to_deprecated_string()] {
|
||||
return Core::deferred_invoke([host = url.serialized_host().release_value_but_fixme_should_propagate_errors().to_byte_string()] {
|
||||
dbgln("EnsureConnection: DNS-preload for {}", host);
|
||||
(void)gethostbyname(host.characters());
|
||||
});
|
||||
|
@ -156,7 +156,7 @@ void ConnectionFromClient::ensure_connection(URL const& url, ::RequestServer::Ca
|
|||
auto& job = Job::ensure(url);
|
||||
dbgln("EnsureConnection: Pre-connect to {}", url);
|
||||
auto do_preconnect = [&](auto& cache) {
|
||||
auto serialized_host = url.serialized_host().release_value_but_fixme_should_propagate_errors().to_deprecated_string();
|
||||
auto serialized_host = url.serialized_host().release_value_but_fixme_should_propagate_errors().to_byte_string();
|
||||
auto it = cache.find({ serialized_host, url.port_or_default() });
|
||||
if (it == cache.end() || it->value->is_empty())
|
||||
ConnectionCache::get_or_create_connection(cache, url, job);
|
||||
|
|
|
@ -31,10 +31,10 @@ public:
|
|||
private:
|
||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket>);
|
||||
|
||||
virtual Messages::RequestServer::IsSupportedProtocolResponse is_supported_protocol(DeprecatedString const&) override;
|
||||
virtual Messages::RequestServer::StartRequestResponse start_request(DeprecatedString const&, URL const&, HashMap<DeprecatedString, DeprecatedString> const&, ByteBuffer const&, Core::ProxyData const&) override;
|
||||
virtual Messages::RequestServer::IsSupportedProtocolResponse is_supported_protocol(ByteString const&) override;
|
||||
virtual Messages::RequestServer::StartRequestResponse start_request(ByteString const&, URL const&, HashMap<ByteString, ByteString> const&, ByteBuffer const&, Core::ProxyData const&) override;
|
||||
virtual Messages::RequestServer::StopRequestResponse stop_request(i32) override;
|
||||
virtual Messages::RequestServer::SetCertificateResponse set_certificate(i32, DeprecatedString const&, DeprecatedString const&) override;
|
||||
virtual Messages::RequestServer::SetCertificateResponse set_certificate(i32, ByteString const&, ByteString const&) override;
|
||||
virtual void ensure_connection(URL const& url, ::RequestServer::CacheLevel const& cache_level) override;
|
||||
|
||||
HashMap<i32, OwnPtr<Request>> m_requests;
|
||||
|
|
|
@ -17,7 +17,7 @@ GeminiProtocol::GeminiProtocol()
|
|||
{
|
||||
}
|
||||
|
||||
OwnPtr<Request> GeminiProtocol::start_request(ConnectionFromClient& client, DeprecatedString const&, const URL& url, HashMap<DeprecatedString, DeprecatedString> const&, ReadonlyBytes, Core::ProxyData proxy_data)
|
||||
OwnPtr<Request> GeminiProtocol::start_request(ConnectionFromClient& client, ByteString const&, const URL& url, HashMap<ByteString, ByteString> const&, ReadonlyBytes, Core::ProxyData proxy_data)
|
||||
{
|
||||
Gemini::GeminiRequest request;
|
||||
request.set_url(url);
|
||||
|
|
|
@ -15,7 +15,7 @@ public:
|
|||
GeminiProtocol();
|
||||
virtual ~GeminiProtocol() override = default;
|
||||
|
||||
virtual OwnPtr<Request> start_request(ConnectionFromClient&, DeprecatedString const& method, const URL&, HashMap<DeprecatedString, DeprecatedString> const&, ReadonlyBytes body, Core::ProxyData proxy_data = {}) override;
|
||||
virtual OwnPtr<Request> start_request(ConnectionFromClient&, ByteString const& method, const URL&, HashMap<ByteString, ByteString> const&, ReadonlyBytes body, Core::ProxyData proxy_data = {}) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ GeminiRequest::GeminiRequest(ConnectionFromClient& client, NonnullRefPtr<Gemini:
|
|||
if (auto* response = m_job->response()) {
|
||||
set_downloaded_size(MUST(m_job->response_length()));
|
||||
if (!response->meta().is_empty()) {
|
||||
HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> headers;
|
||||
HashMap<ByteString, ByteString, CaseInsensitiveStringTraits> headers;
|
||||
headers.set("meta", response->meta());
|
||||
// Note: We're setting content-type to meta only on status==SUCCESS
|
||||
// we should perhaps have a better mechanism for this, since we
|
||||
|
@ -46,7 +46,7 @@ GeminiRequest::GeminiRequest(ConnectionFromClient& client, NonnullRefPtr<Gemini:
|
|||
};
|
||||
}
|
||||
|
||||
void GeminiRequest::set_certificate(DeprecatedString, DeprecatedString)
|
||||
void GeminiRequest::set_certificate(ByteString, ByteString)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
private:
|
||||
explicit GeminiRequest(ConnectionFromClient&, NonnullRefPtr<Gemini::Job>, NonnullOwnPtr<Core::File>&&);
|
||||
|
||||
virtual void set_certificate(DeprecatedString certificate, DeprecatedString key) override;
|
||||
virtual void set_certificate(ByteString certificate, ByteString key) override;
|
||||
|
||||
NonnullRefPtr<Gemini::Job> m_job;
|
||||
};
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/NonnullOwnPtr.h>
|
||||
#include <AK/Optional.h>
|
||||
|
@ -61,7 +61,7 @@ void init(TSelf* self, TJob job)
|
|||
}
|
||||
|
||||
template<typename TBadgedProtocol, typename TPipeResult>
|
||||
OwnPtr<Request> start_request(TBadgedProtocol&& protocol, ConnectionFromClient& client, DeprecatedString const& method, const URL& url, HashMap<DeprecatedString, DeprecatedString> const& headers, ReadonlyBytes body, TPipeResult&& pipe_result, Core::ProxyData proxy_data = {})
|
||||
OwnPtr<Request> start_request(TBadgedProtocol&& protocol, ConnectionFromClient& client, ByteString const& method, const URL& url, HashMap<ByteString, ByteString> const& headers, ReadonlyBytes body, TPipeResult&& pipe_result, Core::ProxyData proxy_data = {})
|
||||
{
|
||||
using TJob = typename TBadgedProtocol::Type::JobType;
|
||||
using TRequest = typename TBadgedProtocol::Type::RequestType;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <AK/Badge.h>
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/URL.h>
|
||||
|
@ -22,7 +22,7 @@ HttpProtocol::HttpProtocol()
|
|||
{
|
||||
}
|
||||
|
||||
OwnPtr<Request> HttpProtocol::start_request(ConnectionFromClient& client, DeprecatedString const& method, const URL& url, HashMap<DeprecatedString, DeprecatedString> const& headers, ReadonlyBytes body, Core::ProxyData proxy_data)
|
||||
OwnPtr<Request> HttpProtocol::start_request(ConnectionFromClient& client, ByteString const& method, const URL& url, HashMap<ByteString, ByteString> const& headers, ReadonlyBytes body, Core::ProxyData proxy_data)
|
||||
{
|
||||
return Detail::start_request(Badge<HttpProtocol> {}, client, method, url, headers, body, get_pipe_for_request(), proxy_data);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/URL.h>
|
||||
|
@ -27,7 +27,7 @@ public:
|
|||
HttpProtocol();
|
||||
~HttpProtocol() override = default;
|
||||
|
||||
virtual OwnPtr<Request> start_request(ConnectionFromClient&, DeprecatedString const& method, const URL&, HashMap<DeprecatedString, DeprecatedString> const& headers, ReadonlyBytes body, Core::ProxyData proxy_data = {}) override;
|
||||
virtual OwnPtr<Request> start_request(ConnectionFromClient&, ByteString const& method, const URL&, HashMap<ByteString, ByteString> const& headers, ReadonlyBytes body, Core::ProxyData proxy_data = {}) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <AK/Badge.h>
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/URL.h>
|
||||
|
@ -22,7 +22,7 @@ HttpsProtocol::HttpsProtocol()
|
|||
{
|
||||
}
|
||||
|
||||
OwnPtr<Request> HttpsProtocol::start_request(ConnectionFromClient& client, DeprecatedString const& method, const URL& url, HashMap<DeprecatedString, DeprecatedString> const& headers, ReadonlyBytes body, Core::ProxyData proxy_data)
|
||||
OwnPtr<Request> HttpsProtocol::start_request(ConnectionFromClient& client, ByteString const& method, const URL& url, HashMap<ByteString, ByteString> const& headers, ReadonlyBytes body, Core::ProxyData proxy_data)
|
||||
{
|
||||
return Detail::start_request(Badge<HttpsProtocol> {}, client, method, url, headers, body, get_pipe_for_request(), proxy_data);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/URL.h>
|
||||
|
@ -27,7 +27,7 @@ public:
|
|||
HttpsProtocol();
|
||||
~HttpsProtocol() override = default;
|
||||
|
||||
virtual OwnPtr<Request> start_request(ConnectionFromClient&, DeprecatedString const& method, const URL&, HashMap<DeprecatedString, DeprecatedString> const& headers, ReadonlyBytes body, Core::ProxyData proxy_data = {}) override;
|
||||
virtual OwnPtr<Request> start_request(ConnectionFromClient&, ByteString const& method, const URL&, HashMap<ByteString, ByteString> const& headers, ReadonlyBytes body, Core::ProxyData proxy_data = {}) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ HttpsRequest::HttpsRequest(ConnectionFromClient& client, NonnullRefPtr<HTTP::Htt
|
|||
Detail::init(this, job);
|
||||
}
|
||||
|
||||
void HttpsRequest::set_certificate(DeprecatedString certificate, DeprecatedString key)
|
||||
void HttpsRequest::set_certificate(ByteString certificate, ByteString key)
|
||||
{
|
||||
m_job->set_certificate(move(certificate), move(key));
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public:
|
|||
private:
|
||||
explicit HttpsRequest(ConnectionFromClient&, NonnullRefPtr<HTTP::HttpsJob>, NonnullOwnPtr<Core::File>&&);
|
||||
|
||||
virtual void set_certificate(DeprecatedString certificate, DeprecatedString key) override;
|
||||
virtual void set_certificate(ByteString certificate, ByteString key) override;
|
||||
|
||||
NonnullRefPtr<HTTP::HttpsJob> m_job;
|
||||
};
|
||||
|
|
|
@ -13,18 +13,18 @@
|
|||
|
||||
namespace RequestServer {
|
||||
|
||||
static HashMap<DeprecatedString, Protocol*>& all_protocols()
|
||||
static HashMap<ByteString, Protocol*>& all_protocols()
|
||||
{
|
||||
static HashMap<DeprecatedString, Protocol*> map;
|
||||
static HashMap<ByteString, Protocol*> map;
|
||||
return map;
|
||||
}
|
||||
|
||||
Protocol* Protocol::find_by_name(DeprecatedString const& name)
|
||||
Protocol* Protocol::find_by_name(ByteString const& name)
|
||||
{
|
||||
return all_protocols().get(name).value_or(nullptr);
|
||||
}
|
||||
|
||||
Protocol::Protocol(DeprecatedString const& name)
|
||||
Protocol::Protocol(ByteString const& name)
|
||||
{
|
||||
all_protocols().set(name, this);
|
||||
}
|
||||
|
|
|
@ -17,13 +17,13 @@ class Protocol {
|
|||
public:
|
||||
virtual ~Protocol();
|
||||
|
||||
DeprecatedString const& name() const { return m_name; }
|
||||
virtual OwnPtr<Request> start_request(ConnectionFromClient&, DeprecatedString const& method, const URL&, HashMap<DeprecatedString, DeprecatedString> const& headers, ReadonlyBytes body, Core::ProxyData proxy_data = {}) = 0;
|
||||
ByteString const& name() const { return m_name; }
|
||||
virtual OwnPtr<Request> start_request(ConnectionFromClient&, ByteString const& method, const URL&, HashMap<ByteString, ByteString> const& headers, ReadonlyBytes body, Core::ProxyData proxy_data = {}) = 0;
|
||||
|
||||
static Protocol* find_by_name(DeprecatedString const&);
|
||||
static Protocol* find_by_name(ByteString const&);
|
||||
|
||||
protected:
|
||||
explicit Protocol(DeprecatedString const& name);
|
||||
explicit Protocol(ByteString const& name);
|
||||
struct Pipe {
|
||||
int read_fd { -1 };
|
||||
int write_fd { -1 };
|
||||
|
@ -31,7 +31,7 @@ protected:
|
|||
static ErrorOr<Pipe> get_pipe_for_request();
|
||||
|
||||
private:
|
||||
DeprecatedString m_name;
|
||||
ByteString m_name;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -24,13 +24,13 @@ void Request::stop()
|
|||
m_client.did_finish_request({}, *this, false);
|
||||
}
|
||||
|
||||
void Request::set_response_headers(HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> const& response_headers)
|
||||
void Request::set_response_headers(HashMap<ByteString, ByteString, CaseInsensitiveStringTraits> const& response_headers)
|
||||
{
|
||||
m_response_headers = response_headers;
|
||||
m_client.did_receive_headers({}, *this);
|
||||
}
|
||||
|
||||
void Request::set_certificate(DeprecatedString, DeprecatedString)
|
||||
void Request::set_certificate(ByteString, ByteString)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -25,10 +25,10 @@ public:
|
|||
Optional<u32> status_code() const { return m_status_code; }
|
||||
Optional<u64> total_size() const { return m_total_size; }
|
||||
size_t downloaded_size() const { return m_downloaded_size; }
|
||||
HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> const& response_headers() const { return m_response_headers; }
|
||||
HashMap<ByteString, ByteString, CaseInsensitiveStringTraits> const& response_headers() const { return m_response_headers; }
|
||||
|
||||
void stop();
|
||||
virtual void set_certificate(DeprecatedString, DeprecatedString);
|
||||
virtual void set_certificate(ByteString, ByteString);
|
||||
|
||||
// FIXME: Want Badge<Protocol>, but can't make one from HttpProtocol, etc.
|
||||
void set_request_fd(int fd) { m_request_fd = fd; }
|
||||
|
@ -38,7 +38,7 @@ public:
|
|||
void did_progress(Optional<u64> total_size, u64 downloaded_size);
|
||||
void set_status_code(u32 status_code) { m_status_code = status_code; }
|
||||
void did_request_certificates();
|
||||
void set_response_headers(HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> const&);
|
||||
void set_response_headers(HashMap<ByteString, ByteString, CaseInsensitiveStringTraits> const&);
|
||||
void set_downloaded_size(size_t size) { m_downloaded_size = size; }
|
||||
Core::File const& output_stream() const { return *m_output_stream; }
|
||||
|
||||
|
@ -53,7 +53,7 @@ private:
|
|||
Optional<u64> m_total_size {};
|
||||
size_t m_downloaded_size { 0 };
|
||||
NonnullOwnPtr<Core::File> m_output_stream;
|
||||
HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> m_response_headers;
|
||||
HashMap<ByteString, ByteString, CaseInsensitiveStringTraits> m_response_headers;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ endpoint RequestClient
|
|||
{
|
||||
request_progress(i32 request_id, Optional<u64> total_size, u64 downloaded_size) =|
|
||||
request_finished(i32 request_id, bool success, u64 total_size) =|
|
||||
headers_became_available(i32 request_id, HashMap<DeprecatedString,DeprecatedString,CaseInsensitiveStringTraits> response_headers, Optional<u32> status_code) =|
|
||||
headers_became_available(i32 request_id, HashMap<ByteString,ByteString,CaseInsensitiveStringTraits> response_headers, Optional<u32> status_code) =|
|
||||
|
||||
// Certificate requests
|
||||
certificate_requested(i32 request_id) =|
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
endpoint RequestServer
|
||||
{
|
||||
// Test if a specific protocol is supported, e.g "http"
|
||||
is_supported_protocol(DeprecatedString protocol) => (bool supported)
|
||||
is_supported_protocol(ByteString protocol) => (bool supported)
|
||||
|
||||
start_request(DeprecatedString method, URL url, HashMap<DeprecatedString,DeprecatedString> request_headers, ByteBuffer request_body, Core::ProxyData proxy_data) => (i32 request_id, Optional<IPC::File> response_fd)
|
||||
start_request(ByteString method, URL url, HashMap<ByteString,ByteString> request_headers, ByteBuffer request_body, Core::ProxyData proxy_data) => (i32 request_id, Optional<IPC::File> response_fd)
|
||||
stop_request(i32 request_id) => (bool success)
|
||||
set_certificate(i32 request_id, DeprecatedString certificate, DeprecatedString key) => (bool success)
|
||||
set_certificate(i32 request_id, ByteString certificate, ByteString key) => (bool success)
|
||||
|
||||
ensure_connection(URL url, ::RequestServer::CacheLevel cache_level) =|
|
||||
}
|
||||
|
|
|
@ -23,14 +23,14 @@ RefPtr<ConnectionFromClient> ConnectionFromClient::client_connection_for(int cli
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void ConnectionFromClient::set_database_path(DeprecatedString database_path)
|
||||
void ConnectionFromClient::set_database_path(ByteString database_path)
|
||||
{
|
||||
m_database_path = move(database_path);
|
||||
}
|
||||
|
||||
ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket> socket, int client_id)
|
||||
: IPC::ConnectionFromClient<SQLClientEndpoint, SQLServerEndpoint>(*this, move(socket), client_id)
|
||||
, m_database_path(DeprecatedString::formatted("{}/sql", Core::StandardPaths::data_directory()))
|
||||
, m_database_path(ByteString::formatted("{}/sql", Core::StandardPaths::data_directory()))
|
||||
{
|
||||
s_connections.set(client_id, *this);
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ void ConnectionFromClient::die()
|
|||
on_disconnect();
|
||||
}
|
||||
|
||||
Messages::SQLServer::ConnectResponse ConnectionFromClient::connect(DeprecatedString const& database_name)
|
||||
Messages::SQLServer::ConnectResponse ConnectionFromClient::connect(ByteString const& database_name)
|
||||
{
|
||||
dbgln_if(SQLSERVER_DEBUG, "ConnectionFromClient::connect(database_name: {})", database_name);
|
||||
|
||||
|
@ -62,7 +62,7 @@ void ConnectionFromClient::disconnect(SQL::ConnectionID connection_id)
|
|||
dbgln("Database connection has disappeared");
|
||||
}
|
||||
|
||||
Messages::SQLServer::PrepareStatementResponse ConnectionFromClient::prepare_statement(SQL::ConnectionID connection_id, DeprecatedString const& sql)
|
||||
Messages::SQLServer::PrepareStatementResponse ConnectionFromClient::prepare_statement(SQL::ConnectionID connection_id, ByteString const& sql)
|
||||
{
|
||||
dbgln_if(SQLSERVER_DEBUG, "ConnectionFromClient::prepare_statement(connection_id: {}, sql: '{}')", connection_id, sql);
|
||||
|
||||
|
@ -93,7 +93,7 @@ Messages::SQLServer::ExecuteStatementResponse ConnectionFromClient::execute_stat
|
|||
}
|
||||
|
||||
dbgln_if(SQLSERVER_DEBUG, "Statement has disappeared");
|
||||
async_execution_error(statement_id, -1, SQL::SQLErrorCode::StatementUnavailable, DeprecatedString::formatted("{}", statement_id));
|
||||
async_execution_error(statement_id, -1, SQL::SQLErrorCode::StatementUnavailable, ByteString::formatted("{}", statement_id));
|
||||
return Optional<SQL::ExecutionID> {};
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/Vector.h>
|
||||
|
@ -28,18 +28,18 @@ public:
|
|||
|
||||
static RefPtr<ConnectionFromClient> client_connection_for(int client_id);
|
||||
|
||||
void set_database_path(DeprecatedString);
|
||||
void set_database_path(ByteString);
|
||||
Function<void()> on_disconnect;
|
||||
|
||||
private:
|
||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket>, int client_id);
|
||||
|
||||
virtual Messages::SQLServer::ConnectResponse connect(DeprecatedString const&) override;
|
||||
virtual Messages::SQLServer::PrepareStatementResponse prepare_statement(SQL::ConnectionID, DeprecatedString const&) override;
|
||||
virtual Messages::SQLServer::ConnectResponse connect(ByteString const&) override;
|
||||
virtual Messages::SQLServer::PrepareStatementResponse prepare_statement(SQL::ConnectionID, ByteString const&) override;
|
||||
virtual Messages::SQLServer::ExecuteStatementResponse execute_statement(SQL::StatementID, Vector<SQL::Value> const& placeholder_values) override;
|
||||
virtual void disconnect(SQL::ConnectionID) override;
|
||||
|
||||
DeprecatedString m_database_path;
|
||||
ByteString m_database_path;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ static ErrorOr<NonnullRefPtr<SQL::Database>> find_or_create_database(StringView
|
|||
return connection.value->database();
|
||||
}
|
||||
|
||||
auto database_file = DeprecatedString::formatted("{}/{}.db", database_path, database_name);
|
||||
auto database_file = ByteString::formatted("{}/{}.db", database_path, database_name);
|
||||
return SQL::Database::create(move(database_file));
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ RefPtr<DatabaseConnection> DatabaseConnection::connection_for(SQL::ConnectionID
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<DatabaseConnection>> DatabaseConnection::create(StringView database_path, DeprecatedString database_name, int client_id)
|
||||
ErrorOr<NonnullRefPtr<DatabaseConnection>> DatabaseConnection::create(StringView database_path, ByteString database_name, int client_id)
|
||||
{
|
||||
if (LexicalPath path(database_name); (path.title() != database_name) || (path.dirname() != "."))
|
||||
return Error::from_string_view("Invalid database name"sv);
|
||||
|
@ -48,7 +48,7 @@ ErrorOr<NonnullRefPtr<DatabaseConnection>> DatabaseConnection::create(StringView
|
|||
return adopt_nonnull_ref_or_enomem(new (nothrow) DatabaseConnection(move(database), move(database_name), client_id));
|
||||
}
|
||||
|
||||
DatabaseConnection::DatabaseConnection(NonnullRefPtr<SQL::Database> database, DeprecatedString database_name, int client_id)
|
||||
DatabaseConnection::DatabaseConnection(NonnullRefPtr<SQL::Database> database, ByteString database_name, int client_id)
|
||||
: m_database(move(database))
|
||||
, m_database_name(move(database_name))
|
||||
, m_connection_id(s_next_connection_id++)
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace SQLServer {
|
|||
|
||||
class DatabaseConnection final : public RefCounted<DatabaseConnection> {
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<DatabaseConnection>> create(StringView database_path, DeprecatedString database_name, int client_id);
|
||||
static ErrorOr<NonnullRefPtr<DatabaseConnection>> create(StringView database_path, ByteString database_name, int client_id);
|
||||
|
||||
static RefPtr<DatabaseConnection> connection_for(SQL::ConnectionID connection_id);
|
||||
SQL::ConnectionID connection_id() const { return m_connection_id; }
|
||||
|
@ -28,10 +28,10 @@ public:
|
|||
SQL::ResultOr<SQL::StatementID> prepare_statement(StringView sql);
|
||||
|
||||
private:
|
||||
DatabaseConnection(NonnullRefPtr<SQL::Database> database, DeprecatedString database_name, int client_id);
|
||||
DatabaseConnection(NonnullRefPtr<SQL::Database> database, ByteString database_name, int client_id);
|
||||
|
||||
NonnullRefPtr<SQL::Database> m_database;
|
||||
DeprecatedString m_database_name;
|
||||
ByteString m_database_name;
|
||||
SQL::ConnectionID m_connection_id { 0 };
|
||||
int m_client_id { 0 };
|
||||
};
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
endpoint SQLClient
|
||||
{
|
||||
execution_success(u64 statement_id, u64 execution_id, Vector<DeprecatedString> column_names, bool has_results, size_t created, size_t updated, size_t deleted) =|
|
||||
execution_success(u64 statement_id, u64 execution_id, Vector<ByteString> column_names, bool has_results, size_t created, size_t updated, size_t deleted) =|
|
||||
next_result(u64 statement_id, u64 execution_id, Vector<SQL::Value> row) =|
|
||||
results_exhausted(u64 statement_id, u64 execution_id, size_t total_rows) =|
|
||||
execution_error(u64 statement_id, u64 execution_id, SQL::SQLErrorCode code, DeprecatedString message) =|
|
||||
execution_error(u64 statement_id, u64 execution_id, SQL::SQLErrorCode code, ByteString message) =|
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
endpoint SQLServer
|
||||
{
|
||||
connect(DeprecatedString name) => (Optional<u64> connection_id)
|
||||
prepare_statement(u64 connection_id, DeprecatedString statement) => (Optional<u64> statement_id)
|
||||
connect(ByteString name) => (Optional<u64> connection_id)
|
||||
prepare_statement(u64 connection_id, ByteString statement) => (Optional<u64> statement_id)
|
||||
execute_statement(u64 statement_id, Vector<SQL::Value> placeholder_values) => (Optional<u64> execution_id)
|
||||
disconnect(u64 connection_id) => ()
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ SQL::ResultOr<NonnullRefPtr<SQLStatement>> SQLStatement::create(DatabaseConnecti
|
|||
auto statement = parser.next_statement();
|
||||
|
||||
if (parser.has_errors())
|
||||
return SQL::Result { SQL::SQLCommand::Unknown, SQL::SQLErrorCode::SyntaxError, parser.errors()[0].to_deprecated_string() };
|
||||
return SQL::Result { SQL::SQLCommand::Unknown, SQL::SQLErrorCode::SyntaxError, parser.errors()[0].to_byte_string() };
|
||||
|
||||
return TRY(adopt_nonnull_ref_or_enomem(new (nothrow) SQLStatement(connection, move(statement))));
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
|
|||
{
|
||||
TRY(Core::System::pledge("stdio accept unix rpath wpath cpath"));
|
||||
|
||||
auto database_path = DeprecatedString::formatted("{}/sql", Core::StandardPaths::data_directory());
|
||||
auto database_path = ByteString::formatted("{}/sql", Core::StandardPaths::data_directory());
|
||||
TRY(Core::Directory::create(database_path, Core::Directory::CreateDirectories::Yes));
|
||||
|
||||
TRY(Core::System::unveil(database_path, "rwc"sv));
|
||||
|
|
|
@ -71,7 +71,7 @@ ErrorOr<void> FileTransferOperation::complete_transfer(SpiceAgent& agent)
|
|||
// Open the file manager for the user :^)
|
||||
// FIXME: This currently opens a new window for each successful file transfer...
|
||||
// Is there a way/can we make a way for it to highlight a new file in an already-open window?
|
||||
Desktop::Launcher::open(URL::create_with_file_scheme(Core::StandardPaths::downloads_directory(), m_metadata.name.to_deprecated_string()));
|
||||
Desktop::Launcher::open(URL::create_with_file_scheme(Core::StandardPaths::downloads_directory(), m_metadata.name.to_byte_string()));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ ErrorOr<void> SpiceAgent::start()
|
|||
TRY(this->send_message(capabilities_message));
|
||||
|
||||
GUI::Clipboard::the().on_change = [this](auto const& mime_type) {
|
||||
auto result = this->on_clipboard_update(String::from_deprecated_string(mime_type).release_value_but_fixme_should_propagate_errors());
|
||||
auto result = this->on_clipboard_update(String::from_byte_string(mime_type).release_value_but_fixme_should_propagate_errors());
|
||||
if (result.is_error()) {
|
||||
dbgln("Failed to inform the spice server of a clipboard update: {}", result.release_error());
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ ErrorOr<void> SpiceAgent::send_clipboard_contents(ClipboardDataType data_type)
|
|||
|
||||
// We have an exception for `image/x-serenityos`, where we treat it as a PNG when talking to the spice server.
|
||||
auto is_serenity_image = data_and_type.mime_type == "image/x-serenityos" && data_type == ClipboardDataType::PNG;
|
||||
if (!is_serenity_image && requested_mime_type.to_deprecated_string() != data_and_type.mime_type) {
|
||||
if (!is_serenity_image && requested_mime_type.to_byte_string() != data_and_type.mime_type) {
|
||||
// If the requested mime type doesn't match what's on the clipboard, we won't send anything back.
|
||||
return Error::from_string_literal("Requested mime type doesn't match the clipboard's contents!");
|
||||
}
|
||||
|
@ -255,8 +255,8 @@ ErrorOr<void> SpiceAgent::did_receive_clipboard_message(ClipboardMessage& messag
|
|||
case ClipboardDataType::TIFF: {
|
||||
auto mime_type = TRY(clipboard_data_type_to_mime_type(message.data_type()));
|
||||
|
||||
// FIXME: It should be trivial to make `try_create_for_raw_bytes` take a `StringView` instead of a direct `DeprecatedString`.
|
||||
auto decoder = Gfx::ImageDecoder::try_create_for_raw_bytes(message.contents(), mime_type.to_deprecated_string());
|
||||
// FIXME: It should be trivial to make `try_create_for_raw_bytes` take a `StringView` instead of a direct `ByteString`.
|
||||
auto decoder = Gfx::ImageDecoder::try_create_for_raw_bytes(message.contents(), mime_type.to_byte_string());
|
||||
if (!decoder || (decoder->frame_count() == 0)) {
|
||||
return Error::from_string_literal("Failed to find a suitable decoder for a pasted image!");
|
||||
}
|
||||
|
|
|
@ -287,7 +287,7 @@ Service::Service(Core::ConfigFile const& config, StringView name)
|
|||
VERIFY(config.has_group(name));
|
||||
|
||||
set_name(name);
|
||||
m_executable_path = config.read_entry(name, "Executable", DeprecatedString::formatted("/bin/{}", this->name()));
|
||||
m_executable_path = config.read_entry(name, "Executable", ByteString::formatted("/bin/{}", this->name()));
|
||||
m_extra_arguments = config.read_entry(name, "Arguments");
|
||||
m_stdio_file_path = config.read_entry_optional(name, "StdIO");
|
||||
|
||||
|
@ -321,12 +321,12 @@ Service::Service(Core::ConfigFile const& config, StringView name)
|
|||
m_multi_instance = config.read_bool_entry(name, "MultiInstance");
|
||||
m_accept_socket_connections = config.read_bool_entry(name, "AcceptSocketConnections");
|
||||
|
||||
DeprecatedString socket_entry = config.read_entry(name, "Socket");
|
||||
DeprecatedString socket_permissions_entry = config.read_entry(name, "SocketPermissions", "0600");
|
||||
ByteString socket_entry = config.read_entry(name, "Socket");
|
||||
ByteString socket_permissions_entry = config.read_entry(name, "SocketPermissions", "0600");
|
||||
|
||||
if (!socket_entry.is_empty()) {
|
||||
Vector<DeprecatedString> socket_paths = socket_entry.split(',');
|
||||
Vector<DeprecatedString> socket_perms = socket_permissions_entry.split(',');
|
||||
Vector<ByteString> socket_paths = socket_entry.split(',');
|
||||
Vector<ByteString> socket_perms = socket_permissions_entry.split(',');
|
||||
m_sockets.ensure_capacity(socket_paths.size());
|
||||
|
||||
// Need i here to iterate along with all other vectors.
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <LibCore/Account.h>
|
||||
#include <LibCore/ElapsedTimer.h>
|
||||
|
@ -42,7 +42,7 @@ private:
|
|||
/// requested by a service.
|
||||
struct SocketDescriptor {
|
||||
/// The path of the socket.
|
||||
DeprecatedString path;
|
||||
ByteString path;
|
||||
/// File descriptor of the socket. -1 if the socket hasn't been opened.
|
||||
int fd { -1 };
|
||||
/// File permissions of the socket.
|
||||
|
@ -50,11 +50,11 @@ private:
|
|||
};
|
||||
|
||||
// Path to the executable. By default this is /bin/{m_name}.
|
||||
DeprecatedString m_executable_path;
|
||||
ByteString m_executable_path;
|
||||
// Extra arguments, starting from argv[1], to pass when exec'ing.
|
||||
DeprecatedString m_extra_arguments;
|
||||
ByteString m_extra_arguments;
|
||||
// File path to open as stdio fds.
|
||||
Optional<DeprecatedString> m_stdio_file_path;
|
||||
Optional<ByteString> m_stdio_file_path;
|
||||
int m_priority { 1 };
|
||||
// Whether we should re-launch it if it exits.
|
||||
bool m_keep_alive { false };
|
||||
|
@ -65,15 +65,15 @@ private:
|
|||
// Whether we should only spawn this service once somebody connects to the socket.
|
||||
bool m_lazy;
|
||||
// The name of the user we should run this service as.
|
||||
Optional<DeprecatedString> m_user;
|
||||
Optional<ByteString> m_user;
|
||||
// The working directory in which to spawn the service.
|
||||
Optional<DeprecatedString> m_working_directory;
|
||||
Optional<ByteString> m_working_directory;
|
||||
// System modes in which to run this service. By default, this is the graphical mode.
|
||||
Vector<DeprecatedString> m_system_modes;
|
||||
Vector<ByteString> m_system_modes;
|
||||
// Whether several instances of this service can run at once.
|
||||
bool m_multi_instance { false };
|
||||
// Environment variables to pass to the service.
|
||||
DeprecatedString m_environment;
|
||||
ByteString m_environment;
|
||||
// Socket descriptors for this service.
|
||||
Vector<SocketDescriptor> m_sockets;
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
static constexpr StringView text_system_mode = "text"sv;
|
||||
static constexpr StringView selftest_system_mode = "self-test"sv;
|
||||
static constexpr StringView graphical_system_mode = "graphical"sv;
|
||||
DeprecatedString g_system_mode = graphical_system_mode;
|
||||
ByteString g_system_mode = graphical_system_mode;
|
||||
Vector<NonnullRefPtr<Service>> g_services;
|
||||
|
||||
// NOTE: This handler ensures that the destructor of g_services is called.
|
||||
|
@ -91,7 +91,7 @@ static ErrorOr<void> determine_system_mode()
|
|||
// Continue and assume "text" mode.
|
||||
return {};
|
||||
}
|
||||
DeprecatedString const system_mode = DeprecatedString::copy(system_mode_buf_or_error.value(), Chomp);
|
||||
ByteString const system_mode = ByteString::copy(system_mode_buf_or_error.value(), Chomp);
|
||||
|
||||
g_system_mode = system_mode;
|
||||
declare_text_mode_on_failure.disarm();
|
||||
|
|
|
@ -122,17 +122,17 @@ ClockWidget::ClockWidget()
|
|||
};
|
||||
}
|
||||
|
||||
void ClockWidget::update_format(DeprecatedString const& format)
|
||||
void ClockWidget::update_format(ByteString const& format)
|
||||
{
|
||||
m_time_format = format;
|
||||
m_time_width = font().width(Core::DateTime::create(122, 2, 22, 22, 22, 22).to_deprecated_string(format));
|
||||
m_time_width = font().width(Core::DateTime::create(122, 2, 22, 22, 22, 22).to_byte_string(format));
|
||||
set_fixed_size(m_time_width + 20, 21);
|
||||
}
|
||||
|
||||
void ClockWidget::paint_event(GUI::PaintEvent& event)
|
||||
{
|
||||
GUI::Frame::paint_event(event);
|
||||
auto time_text = Core::DateTime::now().to_deprecated_string(m_time_format);
|
||||
auto time_text = Core::DateTime::now().to_byte_string(m_time_format);
|
||||
GUI::Painter painter(*this);
|
||||
painter.add_clip_rect(frame_inner_rect());
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ class ClockWidget final : public GUI::Frame {
|
|||
public:
|
||||
virtual ~ClockWidget() override = default;
|
||||
|
||||
void update_format(DeprecatedString const&);
|
||||
void update_format(ByteString const&);
|
||||
|
||||
private:
|
||||
ClockWidget();
|
||||
|
@ -47,7 +47,7 @@ private:
|
|||
|
||||
void update_selected_calendar_button();
|
||||
|
||||
DeprecatedString m_time_format;
|
||||
ByteString m_time_format;
|
||||
RefPtr<GUI::Window> m_calendar_window;
|
||||
RefPtr<GUI::Calendar> m_calendar;
|
||||
RefPtr<GUI::Button> m_next_date;
|
||||
|
|
|
@ -27,22 +27,22 @@
|
|||
|
||||
namespace Taskbar {
|
||||
|
||||
static DeprecatedString sanitize_name(DeprecatedString const& name)
|
||||
static ByteString sanitize_name(ByteString const& name)
|
||||
{
|
||||
return name.replace(" "sv, ""sv).replace("="sv, ""sv);
|
||||
}
|
||||
|
||||
static DeprecatedString entry_to_config_string(size_t index, NonnullOwnPtr<QuickLaunchEntry> const& entry)
|
||||
static ByteString entry_to_config_string(size_t index, NonnullOwnPtr<QuickLaunchEntry> const& entry)
|
||||
{
|
||||
return DeprecatedString::formatted("{}:{}", index, entry->path());
|
||||
return ByteString::formatted("{}:{}", index, entry->path());
|
||||
}
|
||||
|
||||
OwnPtr<QuickLaunchEntry> QuickLaunchEntry::create_from_path(StringView path)
|
||||
{
|
||||
if (path.ends_with(".af"sv)) {
|
||||
auto af_path = path.to_deprecated_string();
|
||||
auto af_path = path.to_byte_string();
|
||||
if (!path.starts_with('/'))
|
||||
af_path = DeprecatedString::formatted("{}/{}", Desktop::AppFile::APP_FILES_DIRECTORY, path);
|
||||
af_path = ByteString::formatted("{}/{}", Desktop::AppFile::APP_FILES_DIRECTORY, path);
|
||||
|
||||
return make<QuickLaunchEntryAppFile>(Desktop::AppFile::open(af_path));
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ GUI::Icon QuickLaunchEntryExecutable::icon() const
|
|||
return GUI::FileIconProvider::icon_for_executable(m_path);
|
||||
}
|
||||
|
||||
DeprecatedString QuickLaunchEntryExecutable::name() const
|
||||
ByteString QuickLaunchEntryExecutable::name() const
|
||||
{
|
||||
return LexicalPath { m_path }.basename();
|
||||
}
|
||||
|
@ -128,11 +128,11 @@ ErrorOr<bool> QuickLaunchWidget::add_from_pid(pid_t pid_to_add)
|
|||
if (pid != pid_to_add)
|
||||
continue;
|
||||
|
||||
auto executable = process_object.get_deprecated_string("executable"sv);
|
||||
auto executable = process_object.get_byte_string("executable"sv);
|
||||
if (!executable.has_value())
|
||||
break;
|
||||
|
||||
auto maybe_name = process_object.get_deprecated_string("name"sv);
|
||||
auto maybe_name = process_object.get_byte_string("name"sv);
|
||||
if (!maybe_name.has_value())
|
||||
break;
|
||||
|
||||
|
@ -184,7 +184,7 @@ void QuickLaunchWidget::drop_event(GUI::DropEvent& event)
|
|||
if (entry) {
|
||||
auto result = update_entry(entry->name(), entry.release_nonnull());
|
||||
if (result.is_error())
|
||||
GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Failed to add quick launch entry: {}", result.release_error()));
|
||||
GUI::MessageBox::show_error(window(), ByteString::formatted("Failed to add quick launch entry: {}", result.release_error()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -212,7 +212,7 @@ void QuickLaunchWidget::mousemove_event(GUI::MouseEvent& event)
|
|||
m_dragging = true;
|
||||
|
||||
if (entry->is_hovered())
|
||||
GUI::Application::the()->show_tooltip(String::from_deprecated_string(entry->name()).release_value_but_fixme_should_propagate_errors(), this);
|
||||
GUI::Application::the()->show_tooltip(String::from_byte_string(entry->name()).release_value_but_fixme_should_propagate_errors(), this);
|
||||
});
|
||||
|
||||
if (m_dragging)
|
||||
|
@ -228,7 +228,7 @@ void QuickLaunchWidget::mouseup_event(GUI::MouseEvent& event)
|
|||
auto result = entry->launch();
|
||||
if (result.is_error()) {
|
||||
// FIXME: This message box is displayed in a weird position
|
||||
GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Failed to open quick launch entry: {}", result.release_error()));
|
||||
GUI::MessageBox::show_error(window(), ByteString::formatted("Failed to open quick launch entry: {}", result.release_error()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -330,7 +330,7 @@ void QuickLaunchWidget::load_entries(bool save)
|
|||
{
|
||||
struct ConfigEntry {
|
||||
int index;
|
||||
DeprecatedString path;
|
||||
ByteString path;
|
||||
};
|
||||
|
||||
Vector<ConfigEntry> config_entries;
|
||||
|
@ -386,7 +386,7 @@ void QuickLaunchWidget::add_entries(Vector<NonnullOwnPtr<QuickLaunchEntry>> entr
|
|||
repaint();
|
||||
}
|
||||
|
||||
ErrorOr<void> QuickLaunchWidget::update_entry(DeprecatedString const& button_name, NonnullOwnPtr<QuickLaunchEntry> entry, bool save)
|
||||
ErrorOr<void> QuickLaunchWidget::update_entry(ByteString const& button_name, NonnullOwnPtr<QuickLaunchEntry> entry, bool save)
|
||||
{
|
||||
auto file_name_to_watch = entry->file_name_to_watch();
|
||||
if (!file_name_to_watch.is_empty()) {
|
||||
|
@ -446,7 +446,7 @@ void QuickLaunchWidget::set_or_insert_entry(NonnullOwnPtr<QuickLaunchEntry> entr
|
|||
m_entries.append(move(entry));
|
||||
}
|
||||
|
||||
void QuickLaunchWidget::remove_entry(DeprecatedString const& name, bool save)
|
||||
void QuickLaunchWidget::remove_entry(ByteString const& name, bool save)
|
||||
{
|
||||
for (size_t i = 0; i < m_entries.size(); i++) {
|
||||
if (m_entries[i]->name() != name)
|
||||
|
|
|
@ -25,10 +25,10 @@ public:
|
|||
virtual ~QuickLaunchEntry() = default;
|
||||
virtual ErrorOr<void> launch() const = 0;
|
||||
virtual GUI::Icon icon() const = 0;
|
||||
virtual DeprecatedString name() const = 0;
|
||||
virtual DeprecatedString file_name_to_watch() const = 0;
|
||||
virtual ByteString name() const = 0;
|
||||
virtual ByteString file_name_to_watch() const = 0;
|
||||
|
||||
virtual DeprecatedString path() = 0;
|
||||
virtual ByteString path() = 0;
|
||||
|
||||
bool is_hovered() const { return m_hovered; }
|
||||
void set_hovered(bool hovered) { m_hovered = hovered; }
|
||||
|
@ -50,10 +50,10 @@ public:
|
|||
|
||||
virtual ErrorOr<void> launch() const override;
|
||||
virtual GUI::Icon icon() const override { return m_app_file->icon(); }
|
||||
virtual DeprecatedString name() const override { return m_app_file->name(); }
|
||||
virtual DeprecatedString file_name_to_watch() const override { return {}; }
|
||||
virtual ByteString name() const override { return m_app_file->name(); }
|
||||
virtual ByteString file_name_to_watch() const override { return {}; }
|
||||
|
||||
virtual DeprecatedString path() override { return m_app_file->filename(); }
|
||||
virtual ByteString path() override { return m_app_file->filename(); }
|
||||
|
||||
private:
|
||||
NonnullRefPtr<Desktop::AppFile> m_app_file;
|
||||
|
@ -61,37 +61,37 @@ private:
|
|||
|
||||
class QuickLaunchEntryExecutable : public QuickLaunchEntry {
|
||||
public:
|
||||
explicit QuickLaunchEntryExecutable(DeprecatedString path)
|
||||
explicit QuickLaunchEntryExecutable(ByteString path)
|
||||
: m_path(move(path))
|
||||
{
|
||||
}
|
||||
|
||||
virtual ErrorOr<void> launch() const override;
|
||||
virtual GUI::Icon icon() const override;
|
||||
virtual DeprecatedString name() const override;
|
||||
virtual DeprecatedString file_name_to_watch() const override { return m_path; }
|
||||
virtual ByteString name() const override;
|
||||
virtual ByteString file_name_to_watch() const override { return m_path; }
|
||||
|
||||
virtual DeprecatedString path() override { return m_path; }
|
||||
virtual ByteString path() override { return m_path; }
|
||||
|
||||
private:
|
||||
DeprecatedString m_path;
|
||||
ByteString m_path;
|
||||
};
|
||||
class QuickLaunchEntryFile : public QuickLaunchEntry {
|
||||
public:
|
||||
explicit QuickLaunchEntryFile(DeprecatedString path)
|
||||
explicit QuickLaunchEntryFile(ByteString path)
|
||||
: m_path(move(path))
|
||||
{
|
||||
}
|
||||
|
||||
virtual ErrorOr<void> launch() const override;
|
||||
virtual GUI::Icon icon() const override;
|
||||
virtual DeprecatedString name() const override { return m_path; }
|
||||
virtual DeprecatedString file_name_to_watch() const override { return m_path; }
|
||||
virtual ByteString name() const override { return m_path; }
|
||||
virtual ByteString file_name_to_watch() const override { return m_path; }
|
||||
|
||||
virtual DeprecatedString path() override { return m_path; }
|
||||
virtual ByteString path() override { return m_path; }
|
||||
|
||||
private:
|
||||
DeprecatedString m_path;
|
||||
ByteString m_path;
|
||||
};
|
||||
|
||||
class QuickLaunchWidget : public GUI::Frame
|
||||
|
@ -131,7 +131,7 @@ private:
|
|||
ErrorOr<void> create_context_menu();
|
||||
|
||||
void load_entries(bool save = true);
|
||||
ErrorOr<void> update_entry(DeprecatedString const&, NonnullOwnPtr<QuickLaunchEntry>, bool save = true);
|
||||
ErrorOr<void> update_entry(ByteString const&, NonnullOwnPtr<QuickLaunchEntry>, bool save = true);
|
||||
void add_entries(Vector<NonnullOwnPtr<QuickLaunchEntry>> entries, bool save = true);
|
||||
|
||||
template<typename Callback>
|
||||
|
@ -142,7 +142,7 @@ private:
|
|||
void repaint();
|
||||
|
||||
void set_or_insert_entry(NonnullOwnPtr<QuickLaunchEntry>, bool save = true);
|
||||
void remove_entry(DeprecatedString const&, bool save = true);
|
||||
void remove_entry(ByteString const&, bool save = true);
|
||||
void recalculate_order();
|
||||
|
||||
bool m_dragging { false };
|
||||
|
@ -151,7 +151,7 @@ private:
|
|||
|
||||
RefPtr<GUI::Menu> m_context_menu;
|
||||
RefPtr<GUI::Action> m_context_menu_default_action;
|
||||
DeprecatedString m_context_menu_app_name;
|
||||
ByteString m_context_menu_app_name;
|
||||
RefPtr<Core::FileWatcher> m_watcher;
|
||||
|
||||
Vector<NonnullOwnPtr<QuickLaunchEntry>> m_entries;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
#include "ShutdownDialog.h"
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibGUI/BoxLayout.h>
|
||||
#include <LibGUI/Button.h>
|
||||
|
@ -17,7 +17,7 @@
|
|||
#include <LibGfx/Font/FontDatabase.h>
|
||||
|
||||
struct Option {
|
||||
DeprecatedString title;
|
||||
ByteString title;
|
||||
ShutdownDialog::Command command;
|
||||
bool enabled;
|
||||
bool default_action;
|
||||
|
@ -74,7 +74,7 @@ ShutdownDialog::ShutdownDialog()
|
|||
auto action = options[i];
|
||||
auto& radio = right_container.add<GUI::RadioButton>();
|
||||
radio.set_enabled(action.enabled);
|
||||
radio.set_text(String::from_deprecated_string(action.title).release_value_but_fixme_should_propagate_errors());
|
||||
radio.set_text(String::from_byte_string(action.title).release_value_but_fixme_should_propagate_errors());
|
||||
|
||||
radio.on_checked = [this, i](auto) {
|
||||
m_selected_option = i;
|
||||
|
|
|
@ -200,8 +200,8 @@ void TaskbarWindow::update_window_button(::Window& window, bool show_as_active)
|
|||
auto* button = window.button();
|
||||
if (!button)
|
||||
return;
|
||||
button->set_text(String::from_deprecated_string(window.title()).release_value_but_fixme_should_propagate_errors());
|
||||
button->set_tooltip(String::from_deprecated_string(window.title()).release_value_but_fixme_should_propagate_errors());
|
||||
button->set_text(String::from_byte_string(window.title()).release_value_but_fixme_should_propagate_errors());
|
||||
button->set_tooltip(String::from_byte_string(window.title()).release_value_but_fixme_should_propagate_errors());
|
||||
button->set_checked(show_as_active);
|
||||
button->set_visible(is_window_on_current_workspace(window));
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "WindowIdentifier.h"
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <LibGUI/Button.h>
|
||||
#include <LibGfx/Rect.h>
|
||||
|
@ -27,8 +27,8 @@ public:
|
|||
|
||||
WindowIdentifier const& identifier() const { return m_identifier; }
|
||||
|
||||
DeprecatedString title() const { return m_title; }
|
||||
void set_title(DeprecatedString const& title) { m_title = title; }
|
||||
ByteString title() const { return m_title; }
|
||||
void set_title(ByteString const& title) { m_title = title; }
|
||||
|
||||
Gfx::IntRect rect() const { return m_rect; }
|
||||
void set_rect(Gfx::IntRect const& rect) { m_rect = rect; }
|
||||
|
@ -68,7 +68,7 @@ public:
|
|||
|
||||
private:
|
||||
WindowIdentifier m_identifier;
|
||||
DeprecatedString m_title;
|
||||
ByteString m_title;
|
||||
Gfx::IntRect m_rect;
|
||||
RefPtr<GUI::Button> m_button;
|
||||
RefPtr<Gfx::Bitmap> m_icon;
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static ErrorOr<Vector<DeprecatedString>> discover_apps_and_categories();
|
||||
static ErrorOr<Vector<ByteString>> discover_apps_and_categories();
|
||||
static ErrorOr<NonnullRefPtr<GUI::Menu>> build_system_menu(GUI::Window&);
|
||||
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
|
@ -76,10 +76,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
}
|
||||
|
||||
struct AppMetadata {
|
||||
DeprecatedString executable;
|
||||
DeprecatedString name;
|
||||
DeprecatedString category;
|
||||
DeprecatedString working_directory;
|
||||
ByteString executable;
|
||||
ByteString name;
|
||||
ByteString category;
|
||||
ByteString working_directory;
|
||||
GUI::Icon icon;
|
||||
bool run_in_terminal;
|
||||
bool requires_root;
|
||||
|
@ -92,9 +92,9 @@ Vector<Gfx::SystemThemeMetaData> g_themes;
|
|||
RefPtr<GUI::Menu> g_themes_menu;
|
||||
GUI::ActionGroup g_themes_group;
|
||||
|
||||
ErrorOr<Vector<DeprecatedString>> discover_apps_and_categories()
|
||||
ErrorOr<Vector<ByteString>> discover_apps_and_categories()
|
||||
{
|
||||
HashTable<DeprecatedString> seen_app_categories;
|
||||
HashTable<ByteString> seen_app_categories;
|
||||
Desktop::AppFile::for_each([&](auto af) {
|
||||
if (af->exclude_from_system_menu())
|
||||
return;
|
||||
|
@ -105,7 +105,7 @@ ErrorOr<Vector<DeprecatedString>> discover_apps_and_categories()
|
|||
});
|
||||
quick_sort(g_apps, [](auto& a, auto& b) { return a.name < b.name; });
|
||||
|
||||
Vector<DeprecatedString> sorted_app_categories;
|
||||
Vector<ByteString> sorted_app_categories;
|
||||
TRY(sorted_app_categories.try_ensure_capacity(seen_app_categories.size()));
|
||||
for (auto const& category : seen_app_categories)
|
||||
sorted_app_categories.unchecked_append(category);
|
||||
|
@ -116,7 +116,7 @@ ErrorOr<Vector<DeprecatedString>> discover_apps_and_categories()
|
|||
|
||||
ErrorOr<NonnullRefPtr<GUI::Menu>> build_system_menu(GUI::Window& window)
|
||||
{
|
||||
Vector<DeprecatedString> const sorted_app_categories = TRY(discover_apps_and_categories());
|
||||
Vector<ByteString> const sorted_app_categories = TRY(discover_apps_and_categories());
|
||||
auto system_menu = GUI::Menu::construct("\xE2\x9A\xA1"_string); // HIGH VOLTAGE SIGN
|
||||
|
||||
system_menu->add_action(GUI::Action::create("&About SerenityOS", TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/ladyball.png"sv)), [&](auto&) {
|
||||
|
@ -127,13 +127,13 @@ ErrorOr<NonnullRefPtr<GUI::Menu>> build_system_menu(GUI::Window& window)
|
|||
|
||||
// First we construct all the necessary app category submenus.
|
||||
auto category_icons = TRY(Core::ConfigFile::open("/res/icons/SystemMenu.ini"));
|
||||
HashMap<DeprecatedString, NonnullRefPtr<GUI::Menu>> app_category_menus;
|
||||
HashMap<ByteString, NonnullRefPtr<GUI::Menu>> app_category_menus;
|
||||
|
||||
Function<void(DeprecatedString const&)> create_category_menu;
|
||||
create_category_menu = [&](DeprecatedString const& category) {
|
||||
Function<void(ByteString const&)> create_category_menu;
|
||||
create_category_menu = [&](ByteString const& category) {
|
||||
if (app_category_menus.contains(category))
|
||||
return;
|
||||
DeprecatedString parent_category, child_category = category;
|
||||
ByteString parent_category, child_category = category;
|
||||
for (ssize_t i = category.length() - 1; i >= 0; i--) {
|
||||
if (category[i] == '/') {
|
||||
parent_category = category.substring(0, i);
|
||||
|
@ -151,7 +151,7 @@ ErrorOr<NonnullRefPtr<GUI::Menu>> build_system_menu(GUI::Window& window)
|
|||
VERIFY(parent_menu);
|
||||
}
|
||||
}
|
||||
auto category_menu = parent_menu->add_submenu(String::from_deprecated_string(child_category).release_value_but_fixme_should_propagate_errors());
|
||||
auto category_menu = parent_menu->add_submenu(String::from_byte_string(child_category).release_value_but_fixme_should_propagate_errors());
|
||||
auto category_icon_path = category_icons->read_entry("16x16", category);
|
||||
if (!category_icon_path.is_empty()) {
|
||||
auto icon_or_error = Gfx::Bitmap::load_from_file(category_icon_path);
|
||||
|
@ -181,7 +181,7 @@ ErrorOr<NonnullRefPtr<GUI::Menu>> build_system_menu(GUI::Window& window)
|
|||
StringView executable;
|
||||
Vector<char const*, 2> arguments;
|
||||
// FIXME: These single quotes won't be enough for executables with single quotes in their name.
|
||||
auto pls_with_executable = DeprecatedString::formatted("/bin/pls '{}'", app.executable);
|
||||
auto pls_with_executable = ByteString::formatted("/bin/pls '{}'", app.executable);
|
||||
if (app.run_in_terminal && !app.requires_root) {
|
||||
executable = "/bin/Terminal"sv;
|
||||
arguments = { "-e", app.executable.characters() };
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <AK/Types.h>
|
||||
|
||||
|
@ -21,7 +21,7 @@ struct Command {
|
|||
u8 command;
|
||||
u8 subcommand;
|
||||
|
||||
DeprecatedString to_deprecated_string() const
|
||||
ByteString to_byte_string() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
|
||||
|
@ -39,7 +39,7 @@ struct Command {
|
|||
builder.append("DONT"sv);
|
||||
break;
|
||||
default:
|
||||
builder.append(DeprecatedString::formatted("UNKNOWN<{:02x}>", command));
|
||||
builder.append(ByteString::formatted("UNKNOWN<{:02x}>", command));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -53,10 +53,10 @@ struct Command {
|
|||
builder.append("SUPPRESS_GO_AHEAD"sv);
|
||||
break;
|
||||
default:
|
||||
builder.append(DeprecatedString::formatted("UNKNOWN<{:02x}>", subcommand));
|
||||
builder.append(ByteString::formatted("UNKNOWN<{:02x}>", subcommand));
|
||||
break;
|
||||
}
|
||||
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
#include "Client.h"
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/Types.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
|
@ -20,7 +20,7 @@
|
|||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static void run_command(int ptm_fd, DeprecatedString command)
|
||||
static void run_command(int ptm_fd, ByteString command)
|
||||
{
|
||||
pid_t pid = fork();
|
||||
if (pid == 0) {
|
||||
|
|
|
@ -86,7 +86,7 @@ void ConnectionFromClient::set_window_handle(String const& handle)
|
|||
page().page().top_level_browsing_context().set_window_handle(handle);
|
||||
}
|
||||
|
||||
void ConnectionFromClient::connect_to_webdriver(DeprecatedString const& webdriver_ipc_path)
|
||||
void ConnectionFromClient::connect_to_webdriver(ByteString const& webdriver_ipc_path)
|
||||
{
|
||||
// FIXME: Propagate this error back to the browser.
|
||||
if (auto result = page().connect_to_webdriver(webdriver_ipc_path); result.is_error())
|
||||
|
@ -100,7 +100,7 @@ void ConnectionFromClient::update_system_theme(Core::AnonymousBuffer const& them
|
|||
page().set_palette_impl(*impl);
|
||||
}
|
||||
|
||||
void ConnectionFromClient::update_system_fonts(DeprecatedString const& default_font_query, DeprecatedString const& fixed_width_font_query, DeprecatedString const& window_title_font_query)
|
||||
void ConnectionFromClient::update_system_fonts(ByteString const& default_font_query, ByteString const& fixed_width_font_query, ByteString const& window_title_font_query)
|
||||
{
|
||||
Gfx::FontDatabase::set_default_font_query(default_font_query);
|
||||
Gfx::FontDatabase::set_fixed_width_font_query(fixed_width_font_query);
|
||||
|
@ -117,11 +117,11 @@ void ConnectionFromClient::load_url(const URL& url)
|
|||
dbgln_if(SPAM_DEBUG, "handle: WebContentServer::LoadURL: url={}", url);
|
||||
|
||||
#if defined(AK_OS_SERENITY)
|
||||
DeprecatedString process_name;
|
||||
ByteString process_name;
|
||||
if (url.host().has<Empty>() || url.host() == String {})
|
||||
process_name = "WebContent";
|
||||
else
|
||||
process_name = DeprecatedString::formatted("WebContent: {}", url.serialized_host().release_value_but_fixme_should_propagate_errors());
|
||||
process_name = ByteString::formatted("WebContent: {}", url.serialized_host().release_value_but_fixme_should_propagate_errors());
|
||||
|
||||
pthread_setname_np(pthread_self(), process_name.characters());
|
||||
#endif
|
||||
|
@ -129,7 +129,7 @@ void ConnectionFromClient::load_url(const URL& url)
|
|||
page().page().load(url);
|
||||
}
|
||||
|
||||
void ConnectionFromClient::load_html(DeprecatedString const& html)
|
||||
void ConnectionFromClient::load_html(ByteString const& html)
|
||||
{
|
||||
dbgln_if(SPAM_DEBUG, "handle: WebContentServer::LoadHTML: html={}", html);
|
||||
page().page().load_html(html);
|
||||
|
@ -364,7 +364,7 @@ void ConnectionFromClient::report_finished_handling_input_event(bool event_was_h
|
|||
async_did_finish_handling_input_event(event_was_handled);
|
||||
}
|
||||
|
||||
void ConnectionFromClient::debug_request(DeprecatedString const& request, DeprecatedString const& argument)
|
||||
void ConnectionFromClient::debug_request(ByteString const& request, ByteString const& argument)
|
||||
{
|
||||
if (request == "dump-session-history") {
|
||||
auto const& traversable = page().page().top_level_traversable();
|
||||
|
@ -452,7 +452,7 @@ void ConnectionFromClient::debug_request(DeprecatedString const& request, Deprec
|
|||
}
|
||||
|
||||
if (request == "spoof-user-agent") {
|
||||
Web::ResourceLoader::the().set_user_agent(MUST(String::from_deprecated_string(argument)));
|
||||
Web::ResourceLoader::the().set_user_agent(MUST(String::from_byte_string(argument)));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -496,14 +496,14 @@ void ConnectionFromClient::debug_request(DeprecatedString const& request, Deprec
|
|||
void ConnectionFromClient::get_source()
|
||||
{
|
||||
if (auto* doc = page().page().top_level_browsing_context().active_document()) {
|
||||
async_did_get_source(doc->url(), doc->source().to_deprecated_string());
|
||||
async_did_get_source(doc->url(), doc->source().to_byte_string());
|
||||
}
|
||||
}
|
||||
|
||||
void ConnectionFromClient::inspect_dom_tree()
|
||||
{
|
||||
if (auto* doc = page().page().top_level_browsing_context().active_document()) {
|
||||
async_did_get_dom_tree(doc->dump_dom_tree_as_json().to_deprecated_string());
|
||||
async_did_get_dom_tree(doc->dump_dom_tree_as_json().to_byte_string());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -531,19 +531,19 @@ Messages::WebContentServer::InspectDomNodeResponse ConnectionFromClient::inspect
|
|||
if (!element.computed_css_values())
|
||||
return { false, "", "", "", "", "" };
|
||||
|
||||
auto serialize_json = [](Web::CSS::StyleProperties const& properties) -> DeprecatedString {
|
||||
auto serialize_json = [](Web::CSS::StyleProperties const& properties) -> ByteString {
|
||||
StringBuilder builder;
|
||||
|
||||
auto serializer = MUST(JsonObjectSerializer<>::try_create(builder));
|
||||
properties.for_each_property([&](auto property_id, auto& value) {
|
||||
MUST(serializer.add(Web::CSS::string_from_property_id(property_id), value.to_string().to_deprecated_string()));
|
||||
MUST(serializer.add(Web::CSS::string_from_property_id(property_id), value.to_string().to_byte_string()));
|
||||
});
|
||||
MUST(serializer.finish());
|
||||
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
};
|
||||
|
||||
auto serialize_custom_properties_json = [](Web::DOM::Element const& element, Optional<Web::CSS::Selector::PseudoElement::Type> pseudo_element) -> DeprecatedString {
|
||||
auto serialize_custom_properties_json = [](Web::DOM::Element const& element, Optional<Web::CSS::Selector::PseudoElement::Type> pseudo_element) -> ByteString {
|
||||
StringBuilder builder;
|
||||
auto serializer = MUST(JsonObjectSerializer<>::try_create(builder));
|
||||
HashTable<FlyString> seen_properties;
|
||||
|
@ -562,9 +562,9 @@ Messages::WebContentServer::InspectDomNodeResponse ConnectionFromClient::inspect
|
|||
|
||||
MUST(serializer.finish());
|
||||
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
};
|
||||
auto serialize_node_box_sizing_json = [](Web::Layout::Node const* layout_node) -> DeprecatedString {
|
||||
auto serialize_node_box_sizing_json = [](Web::Layout::Node const* layout_node) -> ByteString {
|
||||
if (!layout_node || !layout_node->is_box()) {
|
||||
return "{}";
|
||||
}
|
||||
|
@ -593,10 +593,10 @@ Messages::WebContentServer::InspectDomNodeResponse ConnectionFromClient::inspect
|
|||
}
|
||||
|
||||
MUST(serializer.finish());
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
};
|
||||
|
||||
auto serialize_aria_properties_state_json = [](Web::DOM::Element const& element) -> DeprecatedString {
|
||||
auto serialize_aria_properties_state_json = [](Web::DOM::Element const& element) -> ByteString {
|
||||
auto role_name = element.role_or_default();
|
||||
if (!role_name.has_value()) {
|
||||
return "";
|
||||
|
@ -608,7 +608,7 @@ Messages::WebContentServer::InspectDomNodeResponse ConnectionFromClient::inspect
|
|||
auto serializer = MUST(JsonObjectSerializer<>::try_create(builder));
|
||||
MUST(role->serialize_as_json(serializer));
|
||||
MUST(serializer.finish());
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
};
|
||||
|
||||
if (pseudo_element.has_value()) {
|
||||
|
@ -620,18 +620,18 @@ Messages::WebContentServer::InspectDomNodeResponse ConnectionFromClient::inspect
|
|||
// in a format we can use. So, we run the StyleComputer again to get the specified
|
||||
// values, and have to ignore the computed values and custom properties.
|
||||
auto pseudo_element_style = MUST(page().page().focused_context().active_document()->style_computer().compute_style(element, pseudo_element));
|
||||
DeprecatedString computed_values = serialize_json(pseudo_element_style);
|
||||
DeprecatedString resolved_values = "{}";
|
||||
DeprecatedString custom_properties_json = serialize_custom_properties_json(element, pseudo_element);
|
||||
DeprecatedString node_box_sizing_json = serialize_node_box_sizing_json(pseudo_element_node.ptr());
|
||||
ByteString computed_values = serialize_json(pseudo_element_style);
|
||||
ByteString resolved_values = "{}";
|
||||
ByteString custom_properties_json = serialize_custom_properties_json(element, pseudo_element);
|
||||
ByteString node_box_sizing_json = serialize_node_box_sizing_json(pseudo_element_node.ptr());
|
||||
return { true, computed_values, resolved_values, custom_properties_json, node_box_sizing_json, "" };
|
||||
}
|
||||
|
||||
DeprecatedString computed_values = serialize_json(*element.computed_css_values());
|
||||
DeprecatedString resolved_values_json = serialize_json(element.resolved_css_values());
|
||||
DeprecatedString custom_properties_json = serialize_custom_properties_json(element, {});
|
||||
DeprecatedString node_box_sizing_json = serialize_node_box_sizing_json(element.layout_node());
|
||||
DeprecatedString aria_properties_state_json = serialize_aria_properties_state_json(element);
|
||||
ByteString computed_values = serialize_json(*element.computed_css_values());
|
||||
ByteString resolved_values_json = serialize_json(element.resolved_css_values());
|
||||
ByteString custom_properties_json = serialize_custom_properties_json(element, {});
|
||||
ByteString node_box_sizing_json = serialize_node_box_sizing_json(element.layout_node());
|
||||
ByteString aria_properties_state_json = serialize_aria_properties_state_json(element);
|
||||
return { true, computed_values, resolved_values_json, custom_properties_json, node_box_sizing_json, aria_properties_state_json };
|
||||
}
|
||||
|
||||
|
@ -668,7 +668,7 @@ Messages::WebContentServer::SetDomNodeTagResponse ConnectionFromClient::set_dom_
|
|||
auto new_element = Web::DOM::create_element(element.document(), name, element.namespace_uri(), element.prefix(), element.is_value()).release_value_but_fixme_should_propagate_errors();
|
||||
|
||||
element.for_each_attribute([&](auto const& attribute) {
|
||||
new_element->set_attribute_value(attribute.local_name(), attribute.value().to_deprecated_string(), attribute.prefix(), attribute.namespace_uri());
|
||||
new_element->set_attribute_value(attribute.local_name(), attribute.value().to_byte_string(), attribute.prefix(), attribute.namespace_uri());
|
||||
});
|
||||
|
||||
while (auto* child_node = element.first_child()) {
|
||||
|
@ -799,13 +799,13 @@ void ConnectionFromClient::destroy_js_console(Badge<PageClient>, Web::DOM::Docum
|
|||
m_console_clients.remove(&document);
|
||||
}
|
||||
|
||||
void ConnectionFromClient::js_console_input(DeprecatedString const& js_source)
|
||||
void ConnectionFromClient::js_console_input(ByteString const& js_source)
|
||||
{
|
||||
if (m_top_level_document_console_client)
|
||||
m_top_level_document_console_client->handle_input(js_source);
|
||||
}
|
||||
|
||||
void ConnectionFromClient::run_javascript(DeprecatedString const& js_source)
|
||||
void ConnectionFromClient::run_javascript(ByteString const& js_source)
|
||||
{
|
||||
auto* active_document = page().page().top_level_browsing_context().active_document();
|
||||
|
||||
|
@ -870,7 +870,7 @@ Messages::WebContentServer::TakeDomNodeScreenshotResponse ConnectionFromClient::
|
|||
Messages::WebContentServer::DumpGcGraphResponse ConnectionFromClient::dump_gc_graph()
|
||||
{
|
||||
auto gc_graph_json = Web::Bindings::main_thread_vm().heap().dump_graph();
|
||||
return MUST(String::from_deprecated_string(gc_graph_json.to_deprecated_string()));
|
||||
return MUST(String::from_byte_string(gc_graph_json.to_byte_string()));
|
||||
}
|
||||
|
||||
Messages::WebContentServer::GetSelectedTextResponse ConnectionFromClient::get_selected_text()
|
||||
|
@ -888,39 +888,39 @@ Messages::WebContentServer::DumpLayoutTreeResponse ConnectionFromClient::dump_la
|
|||
{
|
||||
auto* document = page().page().top_level_browsing_context().active_document();
|
||||
if (!document)
|
||||
return DeprecatedString { "(no DOM tree)" };
|
||||
return ByteString { "(no DOM tree)" };
|
||||
document->update_layout();
|
||||
auto* layout_root = document->layout_node();
|
||||
if (!layout_root)
|
||||
return DeprecatedString { "(no layout tree)" };
|
||||
return ByteString { "(no layout tree)" };
|
||||
StringBuilder builder;
|
||||
Web::dump_tree(builder, *layout_root);
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
Messages::WebContentServer::DumpPaintTreeResponse ConnectionFromClient::dump_paint_tree()
|
||||
{
|
||||
auto* document = page().page().top_level_browsing_context().active_document();
|
||||
if (!document)
|
||||
return DeprecatedString { "(no DOM tree)" };
|
||||
return ByteString { "(no DOM tree)" };
|
||||
document->update_layout();
|
||||
auto* layout_root = document->layout_node();
|
||||
if (!layout_root)
|
||||
return DeprecatedString { "(no layout tree)" };
|
||||
return ByteString { "(no layout tree)" };
|
||||
if (!layout_root->paintable())
|
||||
return DeprecatedString { "(no paint tree)" };
|
||||
return ByteString { "(no paint tree)" };
|
||||
StringBuilder builder;
|
||||
Web::dump_tree(builder, *layout_root->paintable());
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
Messages::WebContentServer::DumpTextResponse ConnectionFromClient::dump_text()
|
||||
{
|
||||
auto* document = page().page().top_level_browsing_context().active_document();
|
||||
if (!document)
|
||||
return DeprecatedString { "(no DOM tree)" };
|
||||
return ByteString { "(no DOM tree)" };
|
||||
if (!document->body())
|
||||
return DeprecatedString { "(no body)" };
|
||||
return ByteString { "(no body)" };
|
||||
return document->body()->inner_text();
|
||||
}
|
||||
|
||||
|
@ -941,12 +941,12 @@ void ConnectionFromClient::set_autoplay_allowlist(Vector<String> const& allowlis
|
|||
autoplay_allowlist.enable_for_origins(allowlist).release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
void ConnectionFromClient::set_proxy_mappings(Vector<DeprecatedString> const& proxies, HashMap<DeprecatedString, size_t> const& mappings)
|
||||
void ConnectionFromClient::set_proxy_mappings(Vector<ByteString> const& proxies, HashMap<ByteString, size_t> const& mappings)
|
||||
{
|
||||
auto keys = mappings.keys();
|
||||
quick_sort(keys, [&](auto& a, auto& b) { return a.length() < b.length(); });
|
||||
|
||||
OrderedHashMap<DeprecatedString, size_t> sorted_mappings;
|
||||
OrderedHashMap<ByteString, size_t> sorted_mappings;
|
||||
for (auto& key : keys) {
|
||||
auto value = *mappings.get(key);
|
||||
if (value >= proxies.size())
|
||||
|
@ -1082,7 +1082,7 @@ void ConnectionFromClient::set_user_style(String const& source)
|
|||
void ConnectionFromClient::inspect_accessibility_tree()
|
||||
{
|
||||
if (auto* doc = page().page().top_level_browsing_context().active_document()) {
|
||||
async_did_get_accessibility_tree(doc->dump_accessibility_tree_as_json().to_deprecated_string());
|
||||
async_did_get_accessibility_tree(doc->dump_accessibility_tree_as_json().to_byte_string());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -52,12 +52,12 @@ private:
|
|||
|
||||
virtual Messages::WebContentServer::GetWindowHandleResponse get_window_handle() override;
|
||||
virtual void set_window_handle(String const& handle) override;
|
||||
virtual void connect_to_webdriver(DeprecatedString const& webdriver_ipc_path) override;
|
||||
virtual void connect_to_webdriver(ByteString const& webdriver_ipc_path) override;
|
||||
virtual void update_system_theme(Core::AnonymousBuffer const&) override;
|
||||
virtual void update_system_fonts(DeprecatedString const&, DeprecatedString const&, DeprecatedString const&) override;
|
||||
virtual void update_system_fonts(ByteString const&, ByteString const&, ByteString const&) override;
|
||||
virtual void update_screen_rects(Vector<Web::DevicePixelRect> const&, u32) override;
|
||||
virtual void load_url(URL const&) override;
|
||||
virtual void load_html(DeprecatedString const&) override;
|
||||
virtual void load_html(ByteString const&) override;
|
||||
virtual void paint(Web::DevicePixelRect const&, i32) override;
|
||||
virtual void set_viewport_rect(Web::DevicePixelRect const&) override;
|
||||
virtual void mouse_down(Web::DevicePixelPoint, Web::DevicePixelPoint, unsigned, unsigned, unsigned) override;
|
||||
|
@ -69,7 +69,7 @@ private:
|
|||
virtual void key_up(i32, unsigned, u32) override;
|
||||
virtual void add_backing_store(i32, Gfx::ShareableBitmap const&) override;
|
||||
virtual void remove_backing_store(i32) override;
|
||||
virtual void debug_request(DeprecatedString const&, DeprecatedString const&) override;
|
||||
virtual void debug_request(ByteString const&, ByteString const&) override;
|
||||
virtual void get_source() override;
|
||||
virtual void inspect_dom_tree() override;
|
||||
virtual Messages::WebContentServer::InspectDomNodeResponse inspect_dom_node(i32 node_id, Optional<Web::CSS::Selector::PseudoElement::Type> const& pseudo_element) override;
|
||||
|
@ -92,7 +92,7 @@ private:
|
|||
virtual void set_content_filters(Vector<String> const&) override;
|
||||
virtual void set_autoplay_allowed_on_all_websites() override;
|
||||
virtual void set_autoplay_allowlist(Vector<String> const& allowlist) override;
|
||||
virtual void set_proxy_mappings(Vector<DeprecatedString> const&, HashMap<DeprecatedString, size_t> const&) override;
|
||||
virtual void set_proxy_mappings(Vector<ByteString> const&, HashMap<ByteString, size_t> const&) override;
|
||||
virtual void set_preferred_color_scheme(Web::CSS::PreferredColorScheme const&) override;
|
||||
virtual void set_has_focus(bool) override;
|
||||
virtual void set_is_scripting_enabled(bool) override;
|
||||
|
@ -102,8 +102,8 @@ private:
|
|||
virtual void handle_file_return(i32 error, Optional<IPC::File> const& file, i32 request_id) override;
|
||||
virtual void set_system_visibility_state(bool visible) override;
|
||||
|
||||
virtual void js_console_input(DeprecatedString const&) override;
|
||||
virtual void run_javascript(DeprecatedString const&) override;
|
||||
virtual void js_console_input(ByteString const&) override;
|
||||
virtual void run_javascript(ByteString const&) override;
|
||||
virtual void js_console_request_messages(i32) override;
|
||||
|
||||
virtual void alert_closed() override;
|
||||
|
|
|
@ -68,7 +68,7 @@ JS_DEFINE_NATIVE_FUNCTION(ConsoleGlobalEnvironmentExtensions::$_function)
|
|||
auto* console_global_object = TRY(get_console(vm));
|
||||
auto& window = *console_global_object->m_window_object;
|
||||
|
||||
auto selector = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
auto selector = TRY(vm.argument(0).to_byte_string(vm));
|
||||
|
||||
if (vm.argument_count() > 1) {
|
||||
auto element_value = vm.argument(1);
|
||||
|
@ -92,7 +92,7 @@ JS_DEFINE_NATIVE_FUNCTION(ConsoleGlobalEnvironmentExtensions::$$_function)
|
|||
auto* console_global_object = TRY(get_console(vm));
|
||||
auto& window = *console_global_object->m_window_object;
|
||||
|
||||
auto selector = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
auto selector = TRY(vm.argument(0).to_byte_string(vm));
|
||||
|
||||
Web::DOM::ParentNode* element = &window.associated_document();
|
||||
|
||||
|
|
|
@ -224,7 +224,7 @@ void PageClient::page_did_layout()
|
|||
client().async_did_layout(m_content_size.to_type<int>());
|
||||
}
|
||||
|
||||
void PageClient::page_did_change_title(DeprecatedString const& title)
|
||||
void PageClient::page_did_change_title(ByteString const& title)
|
||||
{
|
||||
client().async_did_change_title(title);
|
||||
}
|
||||
|
@ -294,7 +294,7 @@ void PageClient::page_did_request_scroll_into_view(Web::CSSPixelRect const& rect
|
|||
device_pixel_rect.height().value() });
|
||||
}
|
||||
|
||||
void PageClient::page_did_enter_tooltip_area(Web::CSSPixelPoint content_position, DeprecatedString const& title)
|
||||
void PageClient::page_did_enter_tooltip_area(Web::CSSPixelPoint content_position, ByteString const& title)
|
||||
{
|
||||
client().async_did_enter_tooltip_area({ content_position.x().to_int(), content_position.y().to_int() }, title);
|
||||
}
|
||||
|
@ -314,12 +314,12 @@ void PageClient::page_did_unhover_link()
|
|||
client().async_did_unhover_link();
|
||||
}
|
||||
|
||||
void PageClient::page_did_click_link(const URL& url, DeprecatedString const& target, unsigned modifiers)
|
||||
void PageClient::page_did_click_link(const URL& url, ByteString const& target, unsigned modifiers)
|
||||
{
|
||||
client().async_did_click_link(url, target, modifiers);
|
||||
}
|
||||
|
||||
void PageClient::page_did_middle_click_link(const URL& url, [[maybe_unused]] DeprecatedString const& target, [[maybe_unused]] unsigned modifiers)
|
||||
void PageClient::page_did_middle_click_link(const URL& url, [[maybe_unused]] ByteString const& target, [[maybe_unused]] unsigned modifiers)
|
||||
{
|
||||
client().async_did_middle_click_link(url, target, modifiers);
|
||||
}
|
||||
|
@ -354,18 +354,18 @@ void PageClient::page_did_request_context_menu(Web::CSSPixelPoint content_positi
|
|||
client().async_did_request_context_menu(page().css_to_device_point(content_position).to_type<int>());
|
||||
}
|
||||
|
||||
void PageClient::page_did_request_link_context_menu(Web::CSSPixelPoint content_position, URL const& url, DeprecatedString const& target, unsigned modifiers)
|
||||
void PageClient::page_did_request_link_context_menu(Web::CSSPixelPoint content_position, URL const& url, ByteString const& target, unsigned modifiers)
|
||||
{
|
||||
client().async_did_request_link_context_menu(page().css_to_device_point(content_position).to_type<int>(), url, target, modifiers);
|
||||
}
|
||||
|
||||
void PageClient::page_did_request_image_context_menu(Web::CSSPixelPoint content_position, URL const& url, DeprecatedString const& target, unsigned modifiers, Gfx::Bitmap const* bitmap_pointer)
|
||||
void PageClient::page_did_request_image_context_menu(Web::CSSPixelPoint content_position, URL const& url, ByteString const& target, unsigned modifiers, Gfx::Bitmap const* bitmap_pointer)
|
||||
{
|
||||
auto bitmap = bitmap_pointer ? bitmap_pointer->to_shareable_bitmap() : Gfx::ShareableBitmap();
|
||||
client().async_did_request_image_context_menu(page().css_to_device_point(content_position).to_type<int>(), url, target, modifiers, bitmap);
|
||||
}
|
||||
|
||||
void PageClient::page_did_request_media_context_menu(Web::CSSPixelPoint content_position, DeprecatedString const& target, unsigned modifiers, Web::Page::MediaContextMenu menu)
|
||||
void PageClient::page_did_request_media_context_menu(Web::CSSPixelPoint content_position, ByteString const& target, unsigned modifiers, Web::Page::MediaContextMenu menu)
|
||||
{
|
||||
client().async_did_request_media_context_menu(page().css_to_device_point(content_position).to_type<int>(), target, modifiers, move(menu));
|
||||
}
|
||||
|
@ -460,12 +460,12 @@ Vector<Web::Cookie::Cookie> PageClient::page_did_request_all_cookies(URL const&
|
|||
return client().did_request_all_cookies(url);
|
||||
}
|
||||
|
||||
Optional<Web::Cookie::Cookie> PageClient::page_did_request_named_cookie(URL const& url, DeprecatedString const& name)
|
||||
Optional<Web::Cookie::Cookie> PageClient::page_did_request_named_cookie(URL const& url, ByteString const& name)
|
||||
{
|
||||
return client().did_request_named_cookie(url, name);
|
||||
}
|
||||
|
||||
DeprecatedString PageClient::page_did_request_cookie(const URL& url, Web::Cookie::Source source)
|
||||
ByteString PageClient::page_did_request_cookie(const URL& url, Web::Cookie::Source source)
|
||||
{
|
||||
auto response = client().send_sync_but_allow_failure<Messages::WebContentClient::DidRequestCookie>(move(url), static_cast<u8>(source));
|
||||
if (!response) {
|
||||
|
@ -589,7 +589,7 @@ void PageClient::inspector_did_execute_console_script(String const& script)
|
|||
client().async_inspector_did_execute_console_script(script);
|
||||
}
|
||||
|
||||
ErrorOr<void> PageClient::connect_to_webdriver(DeprecatedString const& webdriver_ipc_path)
|
||||
ErrorOr<void> PageClient::connect_to_webdriver(ByteString const& webdriver_ipc_path)
|
||||
{
|
||||
VERIFY(!m_webdriver);
|
||||
m_webdriver = TRY(WebDriverConnection::connect(*this, webdriver_ipc_path));
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
virtual Web::Page& page() override { return *m_page; }
|
||||
virtual Web::Page const& page() const override { return *m_page; }
|
||||
|
||||
ErrorOr<void> connect_to_webdriver(DeprecatedString const& webdriver_ipc_path);
|
||||
ErrorOr<void> connect_to_webdriver(ByteString const& webdriver_ipc_path);
|
||||
|
||||
virtual void paint(Web::DevicePixelRect const& content_rect, Gfx::Bitmap&, Web::PaintOptions = {}) override;
|
||||
|
||||
|
@ -78,7 +78,7 @@ private:
|
|||
virtual void page_did_change_selection() override;
|
||||
virtual void page_did_request_cursor_change(Gfx::StandardCursor) override;
|
||||
virtual void page_did_layout() override;
|
||||
virtual void page_did_change_title(DeprecatedString const&) override;
|
||||
virtual void page_did_change_title(ByteString const&) override;
|
||||
virtual void page_did_request_navigate_back() override;
|
||||
virtual void page_did_request_navigate_forward() override;
|
||||
virtual void page_did_request_refresh() override;
|
||||
|
@ -91,16 +91,16 @@ private:
|
|||
virtual void page_did_request_scroll(i32, i32) override;
|
||||
virtual void page_did_request_scroll_to(Web::CSSPixelPoint) override;
|
||||
virtual void page_did_request_scroll_into_view(Web::CSSPixelRect const&) override;
|
||||
virtual void page_did_enter_tooltip_area(Web::CSSPixelPoint, DeprecatedString const&) override;
|
||||
virtual void page_did_enter_tooltip_area(Web::CSSPixelPoint, ByteString const&) override;
|
||||
virtual void page_did_leave_tooltip_area() override;
|
||||
virtual void page_did_hover_link(const URL&) override;
|
||||
virtual void page_did_unhover_link() override;
|
||||
virtual void page_did_click_link(const URL&, DeprecatedString const& target, unsigned modifiers) override;
|
||||
virtual void page_did_middle_click_link(const URL&, DeprecatedString const& target, unsigned modifiers) override;
|
||||
virtual void page_did_click_link(const URL&, ByteString const& target, unsigned modifiers) override;
|
||||
virtual void page_did_middle_click_link(const URL&, ByteString const& target, unsigned modifiers) override;
|
||||
virtual void page_did_request_context_menu(Web::CSSPixelPoint) override;
|
||||
virtual void page_did_request_link_context_menu(Web::CSSPixelPoint, URL const&, DeprecatedString const& target, unsigned modifiers) override;
|
||||
virtual void page_did_request_image_context_menu(Web::CSSPixelPoint, const URL&, DeprecatedString const& target, unsigned modifiers, Gfx::Bitmap const*) override;
|
||||
virtual void page_did_request_media_context_menu(Web::CSSPixelPoint, DeprecatedString const& target, unsigned modifiers, Web::Page::MediaContextMenu) override;
|
||||
virtual void page_did_request_link_context_menu(Web::CSSPixelPoint, URL const&, ByteString const& target, unsigned modifiers) override;
|
||||
virtual void page_did_request_image_context_menu(Web::CSSPixelPoint, const URL&, ByteString const& target, unsigned modifiers, Gfx::Bitmap const*) override;
|
||||
virtual void page_did_request_media_context_menu(Web::CSSPixelPoint, ByteString const& target, unsigned modifiers, Web::Page::MediaContextMenu) override;
|
||||
virtual void page_did_start_loading(const URL&, bool) override;
|
||||
virtual void page_did_create_new_document(Web::DOM::Document&) override;
|
||||
virtual void page_did_destroy_document(Web::DOM::Document&) override;
|
||||
|
@ -113,8 +113,8 @@ private:
|
|||
virtual void page_did_request_dismiss_dialog() override;
|
||||
virtual void page_did_change_favicon(Gfx::Bitmap const&) override;
|
||||
virtual Vector<Web::Cookie::Cookie> page_did_request_all_cookies(URL const&) override;
|
||||
virtual Optional<Web::Cookie::Cookie> page_did_request_named_cookie(URL const&, DeprecatedString const&) override;
|
||||
virtual DeprecatedString page_did_request_cookie(const URL&, Web::Cookie::Source) override;
|
||||
virtual Optional<Web::Cookie::Cookie> page_did_request_named_cookie(URL const&, ByteString const&) override;
|
||||
virtual ByteString page_did_request_cookie(const URL&, Web::Cookie::Source) override;
|
||||
virtual void page_did_set_cookie(const URL&, Web::Cookie::ParsedCookie const&, Web::Cookie::Source) override;
|
||||
virtual void page_did_update_cookie(Web::Cookie::Cookie) override;
|
||||
virtual void page_did_update_resource_count(i32) override;
|
||||
|
|
|
@ -22,33 +22,33 @@ endpoint WebContentClient
|
|||
did_change_selection() =|
|
||||
did_request_cursor_change(i32 cursor_type) =|
|
||||
did_layout(Gfx::IntSize content_size) =|
|
||||
did_change_title(DeprecatedString title) =|
|
||||
did_change_title(ByteString title) =|
|
||||
did_request_scroll(i32 x_delta, i32 y_delta) =|
|
||||
did_request_scroll_to(Gfx::IntPoint scroll_position) =|
|
||||
did_request_scroll_into_view(Gfx::IntRect rect) =|
|
||||
did_enter_tooltip_area(Gfx::IntPoint content_position, DeprecatedString title) =|
|
||||
did_enter_tooltip_area(Gfx::IntPoint content_position, ByteString title) =|
|
||||
did_leave_tooltip_area() =|
|
||||
did_hover_link(URL url) =|
|
||||
did_unhover_link() =|
|
||||
did_click_link(URL url, DeprecatedString target, unsigned modifiers) =|
|
||||
did_middle_click_link(URL url, DeprecatedString target, unsigned modifiers) =|
|
||||
did_click_link(URL url, ByteString target, unsigned modifiers) =|
|
||||
did_middle_click_link(URL url, ByteString target, unsigned modifiers) =|
|
||||
did_request_context_menu(Gfx::IntPoint content_position) =|
|
||||
did_request_link_context_menu(Gfx::IntPoint content_position, URL url, DeprecatedString target, unsigned modifiers) =|
|
||||
did_request_image_context_menu(Gfx::IntPoint content_position, URL url, DeprecatedString target, unsigned modifiers, Gfx::ShareableBitmap bitmap) =|
|
||||
did_request_media_context_menu(Gfx::IntPoint content_position, DeprecatedString target, unsigned modifiers, Web::Page::MediaContextMenu menu) =|
|
||||
did_request_link_context_menu(Gfx::IntPoint content_position, URL url, ByteString target, unsigned modifiers) =|
|
||||
did_request_image_context_menu(Gfx::IntPoint content_position, URL url, ByteString target, unsigned modifiers, Gfx::ShareableBitmap bitmap) =|
|
||||
did_request_media_context_menu(Gfx::IntPoint content_position, ByteString target, unsigned modifiers, Web::Page::MediaContextMenu menu) =|
|
||||
did_request_alert(String message) =|
|
||||
did_request_confirm(String message) =|
|
||||
did_request_prompt(String message, String default_) =|
|
||||
did_request_set_prompt_text(String message) =|
|
||||
did_request_accept_dialog() =|
|
||||
did_request_dismiss_dialog() =|
|
||||
did_get_source(URL url, DeprecatedString source) =|
|
||||
did_get_dom_tree(DeprecatedString dom_tree) =|
|
||||
did_get_accessibility_tree(DeprecatedString accessibility_tree) =|
|
||||
did_get_source(URL url, ByteString source) =|
|
||||
did_get_dom_tree(ByteString dom_tree) =|
|
||||
did_get_accessibility_tree(ByteString accessibility_tree) =|
|
||||
did_change_favicon(Gfx::ShareableBitmap favicon) =|
|
||||
did_request_all_cookies(URL url) => (Vector<Web::Cookie::Cookie> cookies)
|
||||
did_request_named_cookie(URL url, DeprecatedString name) => (Optional<Web::Cookie::Cookie> cookie)
|
||||
did_request_cookie(URL url, u8 source) => (DeprecatedString cookie)
|
||||
did_request_named_cookie(URL url, ByteString name) => (Optional<Web::Cookie::Cookie> cookie)
|
||||
did_request_cookie(URL url, u8 source) => (ByteString cookie)
|
||||
did_set_cookie(URL url, Web::Cookie::ParsedCookie cookie, u8 source) =|
|
||||
did_update_cookie(Web::Cookie::Cookie cookie) =|
|
||||
did_update_resource_count(i32 count_waiting) =|
|
||||
|
@ -61,7 +61,7 @@ endpoint WebContentClient
|
|||
did_request_maximize_window() => (Gfx::IntRect window_rect)
|
||||
did_request_minimize_window() => (Gfx::IntRect window_rect)
|
||||
did_request_fullscreen_window() => (Gfx::IntRect window_rect)
|
||||
did_request_file(DeprecatedString path, i32 request_id) =|
|
||||
did_request_file(ByteString path, i32 request_id) =|
|
||||
did_request_color_picker(Color current_color) =|
|
||||
did_request_select_dropdown(Gfx::IntPoint content_position, i32 minimum_width, Vector<Web::HTML::SelectItem> items) =|
|
||||
did_finish_handling_input_event(bool event_was_accepted) =|
|
||||
|
@ -69,7 +69,7 @@ endpoint WebContentClient
|
|||
did_insert_clipboard_entry(String data, String presentation_style, String mime_type) =|
|
||||
|
||||
did_output_js_console_message(i32 message_index) =|
|
||||
did_get_js_console_messages(i32 start_index, Vector<DeprecatedString> message_types, Vector<DeprecatedString> messages) =|
|
||||
did_get_js_console_messages(i32 start_index, Vector<ByteString> message_types, Vector<ByteString> messages) =|
|
||||
|
||||
did_finish_text_test() =|
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ WebContentConsoleClient::WebContentConsoleClient(JS::Console& console, JS::Realm
|
|||
m_console_global_environment_extensions = realm.heap().allocate<ConsoleGlobalEnvironmentExtensions>(realm, realm, window);
|
||||
}
|
||||
|
||||
void WebContentConsoleClient::handle_input(DeprecatedString const& js_source)
|
||||
void WebContentConsoleClient::handle_input(ByteString const& js_source)
|
||||
{
|
||||
if (!m_console_global_environment_extensions)
|
||||
return;
|
||||
|
@ -46,16 +46,16 @@ void WebContentConsoleClient::handle_input(DeprecatedString const& js_source)
|
|||
|
||||
if (result.value().has_value()) {
|
||||
m_console_global_environment_extensions->set_most_recent_result(result.value().value());
|
||||
print_html(JS::MarkupGenerator::html_from_value(*result.value()).release_value_but_fixme_should_propagate_errors().to_deprecated_string());
|
||||
print_html(JS::MarkupGenerator::html_from_value(*result.value()).release_value_but_fixme_should_propagate_errors().to_byte_string());
|
||||
}
|
||||
}
|
||||
|
||||
void WebContentConsoleClient::report_exception(JS::Error const& exception, bool in_promise)
|
||||
{
|
||||
print_html(JS::MarkupGenerator::html_from_error(exception, in_promise).release_value_but_fixme_should_propagate_errors().to_deprecated_string());
|
||||
print_html(JS::MarkupGenerator::html_from_error(exception, in_promise).release_value_but_fixme_should_propagate_errors().to_byte_string());
|
||||
}
|
||||
|
||||
void WebContentConsoleClient::print_html(DeprecatedString const& line)
|
||||
void WebContentConsoleClient::print_html(ByteString const& line)
|
||||
{
|
||||
m_message_log.append({ .type = ConsoleOutput::Type::HTML, .data = line });
|
||||
m_client.async_did_output_js_console_message(m_message_log.size() - 1);
|
||||
|
@ -67,7 +67,7 @@ void WebContentConsoleClient::clear_output()
|
|||
m_client.async_did_output_js_console_message(m_message_log.size() - 1);
|
||||
}
|
||||
|
||||
void WebContentConsoleClient::begin_group(DeprecatedString const& label, bool start_expanded)
|
||||
void WebContentConsoleClient::begin_group(ByteString const& label, bool start_expanded)
|
||||
{
|
||||
m_message_log.append({ .type = start_expanded ? ConsoleOutput::Type::BeginGroup : ConsoleOutput::Type::BeginGroupCollapsed, .data = label });
|
||||
m_client.async_did_output_js_console_message(m_message_log.size() - 1);
|
||||
|
@ -93,8 +93,8 @@ void WebContentConsoleClient::send_messages(i32 start_index)
|
|||
}
|
||||
|
||||
// FIXME: Replace with a single Vector of message structs
|
||||
Vector<DeprecatedString> message_types;
|
||||
Vector<DeprecatedString> messages;
|
||||
Vector<ByteString> message_types;
|
||||
Vector<ByteString> messages;
|
||||
message_types.ensure_capacity(messages_to_send);
|
||||
messages.ensure_capacity(messages_to_send);
|
||||
|
||||
|
@ -152,7 +152,7 @@ JS::ThrowCompletionOr<JS::Value> WebContentConsoleClient::printer(JS::Console::L
|
|||
|
||||
if (log_level == JS::Console::LogLevel::Group || log_level == JS::Console::LogLevel::GroupCollapsed) {
|
||||
auto group = arguments.get<JS::Console::Group>();
|
||||
begin_group(DeprecatedString::formatted("<span style='{}'>{}</span>", styling, escape_html_entities(group.label)), log_level == JS::Console::LogLevel::Group);
|
||||
begin_group(ByteString::formatted("<span style='{}'>{}</span>", styling, escape_html_entities(group.label)), log_level == JS::Console::LogLevel::Group);
|
||||
return JS::js_undefined();
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ class WebContentConsoleClient final : public JS::ConsoleClient
|
|||
public:
|
||||
WebContentConsoleClient(JS::Console&, JS::Realm&, ConnectionFromClient&);
|
||||
|
||||
void handle_input(DeprecatedString const& js_source);
|
||||
void handle_input(ByteString const& js_source);
|
||||
void send_messages(i32 start_index);
|
||||
void report_exception(JS::Error const&, bool) override;
|
||||
|
||||
|
@ -39,8 +39,8 @@ private:
|
|||
JS::Handle<ConsoleGlobalEnvironmentExtensions> m_console_global_environment_extensions;
|
||||
|
||||
void clear_output();
|
||||
void print_html(DeprecatedString const& line);
|
||||
void begin_group(DeprecatedString const& label, bool start_expanded);
|
||||
void print_html(ByteString const& line);
|
||||
void begin_group(ByteString const& label, bool start_expanded);
|
||||
virtual void end_group() override;
|
||||
|
||||
struct ConsoleOutput {
|
||||
|
@ -52,7 +52,7 @@ private:
|
|||
EndGroup,
|
||||
};
|
||||
Type type;
|
||||
DeprecatedString data;
|
||||
ByteString data;
|
||||
};
|
||||
Vector<ConsoleOutput> m_message_log;
|
||||
|
||||
|
|
|
@ -13,14 +13,14 @@ endpoint WebContentServer
|
|||
get_window_handle() => (String handle)
|
||||
set_window_handle(String handle) =|
|
||||
|
||||
connect_to_webdriver(DeprecatedString webdriver_ipc_path) =|
|
||||
connect_to_webdriver(ByteString webdriver_ipc_path) =|
|
||||
|
||||
update_system_theme(Core::AnonymousBuffer theme_buffer) =|
|
||||
update_system_fonts(DeprecatedString default_font_query, DeprecatedString fixed_width_font_query, DeprecatedString window_title_font_query) =|
|
||||
update_system_fonts(ByteString default_font_query, ByteString fixed_width_font_query, ByteString window_title_font_query) =|
|
||||
update_screen_rects(Vector<Web::DevicePixelRect> rects, u32 main_screen_index) =|
|
||||
|
||||
load_url(URL url) =|
|
||||
load_html(DeprecatedString html) =|
|
||||
load_html(ByteString html) =|
|
||||
|
||||
add_backing_store(i32 backing_store_id, Gfx::ShareableBitmap bitmap) =|
|
||||
remove_backing_store(i32 backing_store_id) =|
|
||||
|
@ -37,13 +37,13 @@ endpoint WebContentServer
|
|||
key_down(i32 key, unsigned modifiers, u32 code_point) =|
|
||||
key_up(i32 key, unsigned modifiers, u32 code_point) =|
|
||||
|
||||
debug_request(DeprecatedString request, DeprecatedString argument) =|
|
||||
debug_request(ByteString request, ByteString argument) =|
|
||||
get_source() =|
|
||||
inspect_dom_tree() =|
|
||||
inspect_dom_node(i32 node_id, Optional<Web::CSS::Selector::PseudoElement::Type> pseudo_element) => (bool has_style, DeprecatedString computed_style, DeprecatedString resolved_style, DeprecatedString custom_properties, DeprecatedString node_box_sizing, DeprecatedString aria_properties_state)
|
||||
inspect_dom_node(i32 node_id, Optional<Web::CSS::Selector::PseudoElement::Type> pseudo_element) => (bool has_style, ByteString computed_style, ByteString resolved_style, ByteString custom_properties, ByteString node_box_sizing, ByteString aria_properties_state)
|
||||
inspect_accessibility_tree() =|
|
||||
get_hovered_node_id() => (i32 node_id)
|
||||
js_console_input(DeprecatedString js_source) =|
|
||||
js_console_input(ByteString js_source) =|
|
||||
js_console_request_messages(i32 start_index) =|
|
||||
|
||||
set_dom_node_text(i32 node_id, String text) =|
|
||||
|
@ -61,19 +61,19 @@ endpoint WebContentServer
|
|||
|
||||
dump_gc_graph() => (String json)
|
||||
|
||||
run_javascript(DeprecatedString js_source) =|
|
||||
run_javascript(ByteString js_source) =|
|
||||
|
||||
dump_layout_tree() => (DeprecatedString dump)
|
||||
dump_paint_tree() => (DeprecatedString dump)
|
||||
dump_text() => (DeprecatedString dump)
|
||||
dump_layout_tree() => (ByteString dump)
|
||||
dump_paint_tree() => (ByteString dump)
|
||||
dump_text() => (ByteString dump)
|
||||
|
||||
get_selected_text() => (DeprecatedString selection)
|
||||
get_selected_text() => (ByteString selection)
|
||||
select_all() =|
|
||||
|
||||
set_content_filters(Vector<String> filters) =|
|
||||
set_autoplay_allowed_on_all_websites() =|
|
||||
set_autoplay_allowlist(Vector<String> allowlist) =|
|
||||
set_proxy_mappings(Vector<DeprecatedString> proxies, HashMap<DeprecatedString,size_t> mappings) =|
|
||||
set_proxy_mappings(Vector<ByteString> proxies, HashMap<ByteString,size_t> mappings) =|
|
||||
set_preferred_color_scheme(Web::CSS::PreferredColorScheme color_scheme) =|
|
||||
set_has_focus(bool has_focus) =|
|
||||
set_is_scripting_enabled(bool is_scripting_enabled) =|
|
||||
|
|
|
@ -51,10 +51,10 @@ namespace WebContent {
|
|||
static JsonValue serialize_cookie(Web::Cookie::Cookie const& cookie)
|
||||
{
|
||||
JsonObject serialized_cookie;
|
||||
serialized_cookie.set("name"sv, cookie.name.to_deprecated_string());
|
||||
serialized_cookie.set("value"sv, cookie.value.to_deprecated_string());
|
||||
serialized_cookie.set("path"sv, cookie.path.to_deprecated_string());
|
||||
serialized_cookie.set("domain"sv, cookie.domain.to_deprecated_string());
|
||||
serialized_cookie.set("name"sv, cookie.name.to_byte_string());
|
||||
serialized_cookie.set("value"sv, cookie.value.to_byte_string());
|
||||
serialized_cookie.set("path"sv, cookie.path.to_byte_string());
|
||||
serialized_cookie.set("domain"sv, cookie.domain.to_byte_string());
|
||||
serialized_cookie.set("secure"sv, cookie.secure);
|
||||
serialized_cookie.set("httpOnly"sv, cookie.http_only);
|
||||
serialized_cookie.set("expiry"sv, cookie.expiry_time.seconds_since_epoch());
|
||||
|
@ -116,21 +116,21 @@ static Gfx::IntRect calculate_absolute_rect_of_element(Web::Page const& page, We
|
|||
}
|
||||
|
||||
// https://w3c.github.io/webdriver/#dfn-get-or-create-a-web-element-reference
|
||||
static DeprecatedString get_or_create_a_web_element_reference(Web::DOM::Node const& element)
|
||||
static ByteString get_or_create_a_web_element_reference(Web::DOM::Node const& element)
|
||||
{
|
||||
// FIXME: 1. For each known element of the current browsing context’s list of known elements:
|
||||
// FIXME: 1. If known element equals element, return success with known element’s web element reference.
|
||||
// FIXME: 2. Add element to the list of known elements of the current browsing context.
|
||||
// FIXME: 3. Return success with the element’s web element reference.
|
||||
|
||||
return DeprecatedString::number(element.unique_id());
|
||||
return ByteString::number(element.unique_id());
|
||||
}
|
||||
|
||||
// https://w3c.github.io/webdriver/#dfn-web-element-reference-object
|
||||
static JsonObject web_element_reference_object(Web::DOM::Node const& element)
|
||||
{
|
||||
// https://w3c.github.io/webdriver/#dfn-web-element-identifier
|
||||
static DeprecatedString const web_element_identifier = "element-6066-11e4-a52e-4f735466cecf"sv;
|
||||
static ByteString const web_element_identifier = "element-6066-11e4-a52e-4f735466cecf"sv;
|
||||
|
||||
// 1. Let identifier be the web element identifier.
|
||||
auto identifier = web_element_identifier;
|
||||
|
@ -157,27 +157,27 @@ static ErrorOr<Web::DOM::Element*, Web::WebDriver::Error> get_known_connected_el
|
|||
auto* node = Web::DOM::Node::from_unique_id(*element);
|
||||
|
||||
if (!node || !node->is_element())
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::NoSuchElement, DeprecatedString::formatted("Could not find element with ID: {}", element_id));
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::NoSuchElement, ByteString::formatted("Could not find element with ID: {}", element_id));
|
||||
|
||||
return static_cast<Web::DOM::Element*>(node);
|
||||
}
|
||||
|
||||
// https://w3c.github.io/webdriver/#dfn-get-or-create-a-shadow-root-reference
|
||||
static DeprecatedString get_or_create_a_shadow_root_reference(Web::DOM::ShadowRoot const& shadow_root)
|
||||
static ByteString get_or_create_a_shadow_root_reference(Web::DOM::ShadowRoot const& shadow_root)
|
||||
{
|
||||
// FIXME: 1. For each known shadow root of the current browsing context’s list of known shadow roots:
|
||||
// FIXME: 1. If known shadow root equals shadow root, return success with known shadow root’s shadow root reference.
|
||||
// FIXME: 2. Add shadow to the list of known shadow roots of the current browsing context.
|
||||
// FIXME: 3. Return success with the shadow’s shadow root reference.
|
||||
|
||||
return DeprecatedString::number(shadow_root.unique_id());
|
||||
return ByteString::number(shadow_root.unique_id());
|
||||
}
|
||||
|
||||
// https://w3c.github.io/webdriver/#dfn-shadow-root-reference-object
|
||||
static JsonObject shadow_root_reference_object(Web::DOM::ShadowRoot const& shadow_root)
|
||||
{
|
||||
// https://w3c.github.io/webdriver/#dfn-shadow-root-identifier
|
||||
static DeprecatedString const shadow_root_identifier = "shadow-6066-11e4-a52e-4f735466cecf"sv;
|
||||
static ByteString const shadow_root_identifier = "shadow-6066-11e4-a52e-4f735466cecf"sv;
|
||||
|
||||
// 1. Let identifier be the shadow root identifier.
|
||||
auto identifier = shadow_root_identifier;
|
||||
|
@ -204,7 +204,7 @@ static ErrorOr<Web::DOM::ShadowRoot*, Web::WebDriver::Error> get_known_shadow_ro
|
|||
auto* node = Web::DOM::Node::from_unique_id(*shadow_root);
|
||||
|
||||
if (!node || !node->is_shadow_root())
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::NoSuchElement, DeprecatedString::formatted("Could not find shadow root with ID: {}", shadow_id));
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::NoSuchElement, ByteString::formatted("Could not find shadow root with ID: {}", shadow_id));
|
||||
|
||||
return static_cast<Web::DOM::ShadowRoot*>(node);
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ static ErrorOr<void> scroll_element_into_view(Web::DOM::Element& element)
|
|||
return {};
|
||||
}
|
||||
|
||||
template<typename PropertyType = DeprecatedString>
|
||||
template<typename PropertyType = ByteString>
|
||||
static ErrorOr<PropertyType, Web::WebDriver::Error> get_property(JsonValue const& payload, StringView key)
|
||||
{
|
||||
if (!payload.is_object())
|
||||
|
@ -236,27 +236,27 @@ static ErrorOr<PropertyType, Web::WebDriver::Error> get_property(JsonValue const
|
|||
auto property = payload.as_object().get(key);
|
||||
|
||||
if (!property.has_value())
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, DeprecatedString::formatted("No property called '{}' present", key));
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, ByteString::formatted("No property called '{}' present", key));
|
||||
|
||||
if constexpr (IsSame<PropertyType, DeprecatedString>) {
|
||||
if constexpr (IsSame<PropertyType, ByteString>) {
|
||||
if (!property->is_string())
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, DeprecatedString::formatted("Property '{}' is not a String", key));
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, ByteString::formatted("Property '{}' is not a String", key));
|
||||
return property->as_string();
|
||||
} else if constexpr (IsSame<PropertyType, bool>) {
|
||||
if (!property->is_bool())
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, DeprecatedString::formatted("Property '{}' is not a Boolean", key));
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, ByteString::formatted("Property '{}' is not a Boolean", key));
|
||||
return property->as_bool();
|
||||
} else if constexpr (IsSame<PropertyType, u32>) {
|
||||
if (!property->is_u32())
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, DeprecatedString::formatted("Property '{}' is not a Number", key));
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, ByteString::formatted("Property '{}' is not a Number", key));
|
||||
return property->as_u32();
|
||||
} else if constexpr (IsSame<PropertyType, JsonArray const*>) {
|
||||
if (!property->is_array())
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, DeprecatedString::formatted("Property '{}' is not an Array", key));
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, ByteString::formatted("Property '{}' is not an Array", key));
|
||||
return &property->as_array();
|
||||
} else if constexpr (IsSame<PropertyType, JsonObject const*>) {
|
||||
if (!property->is_object())
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, DeprecatedString::formatted("Property '{}' is not an Object", key));
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, ByteString::formatted("Property '{}' is not an Object", key));
|
||||
return &property->as_object();
|
||||
} else {
|
||||
static_assert(DependentFalse<PropertyType>, "get_property invoked with unknown property type");
|
||||
|
@ -321,7 +321,7 @@ static bool fire_an_event(FlyString name, Optional<Web::DOM::Element&> target)
|
|||
return target->dispatch_event(event);
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<WebDriverConnection>> WebDriverConnection::connect(Web::PageClient& page_client, DeprecatedString const& webdriver_ipc_path)
|
||||
ErrorOr<NonnullRefPtr<WebDriverConnection>> WebDriverConnection::connect(Web::PageClient& page_client, ByteString const& webdriver_ipc_path)
|
||||
{
|
||||
dbgln_if(WEBDRIVER_DEBUG, "Trying to connect to {}", webdriver_ipc_path);
|
||||
auto socket = TRY(Core::LocalSocket::connect(webdriver_ipc_path));
|
||||
|
@ -403,7 +403,7 @@ Messages::WebDriverClient::NavigateToResponse WebDriverConnection::navigate_to(J
|
|||
// 2. Let url be the result of getting the property url from the parameters argument.
|
||||
if (!payload.is_object() || !payload.as_object().has_string("url"sv))
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, "Payload doesn't have a string `url`"sv);
|
||||
URL url(payload.as_object().get_deprecated_string("url"sv).value());
|
||||
URL url(payload.as_object().get_byte_string("url"sv).value());
|
||||
|
||||
// FIXME: 3. If url is not an absolute URL or is not an absolute URL with fragment or not a local scheme, return error with error code invalid argument.
|
||||
|
||||
|
@ -445,7 +445,7 @@ Messages::WebDriverClient::GetCurrentUrlResponse WebDriverConnection::get_curren
|
|||
TRY(handle_any_user_prompts());
|
||||
|
||||
// 3. Let url be the serialization of the current top-level browsing context’s active document’s document URL.
|
||||
auto url = m_page_client.page().top_level_browsing_context().active_document()->url().to_deprecated_string();
|
||||
auto url = m_page_client.page().top_level_browsing_context().active_document()->url().to_byte_string();
|
||||
|
||||
// 4. Return success with data url.
|
||||
return url;
|
||||
|
@ -523,7 +523,7 @@ Messages::WebDriverClient::GetTitleResponse WebDriverConnection::get_title()
|
|||
auto title = m_page_client.page().top_level_browsing_context().active_document()->title();
|
||||
|
||||
// 4. Return success with data title.
|
||||
return title.to_deprecated_string();
|
||||
return title.to_byte_string();
|
||||
}
|
||||
|
||||
// 11.1 Get Window Handle, https://w3c.github.io/webdriver/#get-window-handle
|
||||
|
@ -621,14 +621,14 @@ Messages::WebDriverClient::SetWindowRectResponse WebDriverConnection::set_window
|
|||
if (property.is_null())
|
||||
return Optional<i32> {};
|
||||
if (!property.is_number())
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, DeprecatedString::formatted("Property '{}' is not a Number", name));
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, ByteString::formatted("Property '{}' is not a Number", name));
|
||||
|
||||
auto number = property.template to_number<i64>();
|
||||
|
||||
if (number < min)
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, DeprecatedString::formatted("Property '{}' value {} exceeds the minimum allowed value {}", name, number, min));
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, ByteString::formatted("Property '{}' value {} exceeds the minimum allowed value {}", name, number, min));
|
||||
if (number > max)
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, DeprecatedString::formatted("Property '{}' value {} exceeds the maximum allowed value {}", name, number, max));
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, ByteString::formatted("Property '{}' value {} exceeds the maximum allowed value {}", name, number, max));
|
||||
|
||||
return static_cast<i32>(number);
|
||||
};
|
||||
|
@ -766,7 +766,7 @@ Messages::WebDriverClient::FindElementResponse WebDriverConnection::find_element
|
|||
|
||||
// 2. If location strategy is not present as a keyword in the table of location strategies, return error with error code invalid argument.
|
||||
if (!location_strategy.has_value())
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, DeprecatedString::formatted("Location strategy '{}' is invalid", location_strategy_string));
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, ByteString::formatted("Location strategy '{}' is invalid", location_strategy_string));
|
||||
|
||||
// 3. Let selector be the result of getting a property called "value".
|
||||
// 4. If selector is undefined, return error with error code invalid argument.
|
||||
|
@ -808,7 +808,7 @@ Messages::WebDriverClient::FindElementsResponse WebDriverConnection::find_elemen
|
|||
|
||||
// 2. If location strategy is not present as a keyword in the table of location strategies, return error with error code invalid argument.
|
||||
if (!location_strategy.has_value())
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, DeprecatedString::formatted("Location strategy '{}' is invalid", location_strategy_string));
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, ByteString::formatted("Location strategy '{}' is invalid", location_strategy_string));
|
||||
|
||||
// 3. Let selector be the result of getting a property called "value".
|
||||
// 4. If selector is undefined, return error with error code invalid argument.
|
||||
|
@ -844,7 +844,7 @@ Messages::WebDriverClient::FindElementFromElementResponse WebDriverConnection::f
|
|||
|
||||
// 2. If location strategy is not present as a keyword in the table of location strategies, return error with error code invalid argument.
|
||||
if (!location_strategy.has_value())
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, DeprecatedString::formatted("Location strategy '{}' is invalid", location_strategy_string));
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, ByteString::formatted("Location strategy '{}' is invalid", location_strategy_string));
|
||||
|
||||
// 3. Let selector be the result of getting a property called "value".
|
||||
// 4. If selector is undefined, return error with error code invalid argument.
|
||||
|
@ -880,7 +880,7 @@ Messages::WebDriverClient::FindElementsFromElementResponse WebDriverConnection::
|
|||
|
||||
// 2. If location strategy is not present as a keyword in the table of location strategies, return error with error code invalid argument.
|
||||
if (!location_strategy.has_value())
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, DeprecatedString::formatted("Location strategy '{}' is invalid", location_strategy_string));
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, ByteString::formatted("Location strategy '{}' is invalid", location_strategy_string));
|
||||
|
||||
// 3. Let selector be the result of getting a property called "value".
|
||||
// 4. If selector is undefined, return error with error code invalid argument.
|
||||
|
@ -910,7 +910,7 @@ Messages::WebDriverClient::FindElementFromShadowRootResponse WebDriverConnection
|
|||
|
||||
// 2. If location strategy is not present as a keyword in the table of location strategies, return error with error code invalid argument.
|
||||
if (!location_strategy.has_value())
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, DeprecatedString::formatted("Location strategy '{}' is invalid", location_strategy_string));
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, ByteString::formatted("Location strategy '{}' is invalid", location_strategy_string));
|
||||
|
||||
// 3. Let selector be the result of getting a property called "value".
|
||||
// 4. If selector is undefined, return error with error code invalid argument.
|
||||
|
@ -946,7 +946,7 @@ Messages::WebDriverClient::FindElementsFromShadowRootResponse WebDriverConnectio
|
|||
|
||||
// 2. If location strategy is not present as a keyword in the table of location strategies, return error with error code invalid argument.
|
||||
if (!location_strategy.has_value())
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, DeprecatedString::formatted("Location strategy '{}' is invalid", location_strategy_string));
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, ByteString::formatted("Location strategy '{}' is invalid", location_strategy_string));
|
||||
|
||||
// 3. Let selector be the result of getting a property called "value".
|
||||
// 4. If selector is undefined, return error with error code invalid argument.
|
||||
|
@ -982,7 +982,7 @@ Messages::WebDriverClient::GetActiveElementResponse WebDriverConnection::get_act
|
|||
// 4. If active element is a non-null element, return success with data set to web element reference object for active element.
|
||||
// Otherwise, return error with error code no such element.
|
||||
if (active_element)
|
||||
return DeprecatedString::number(active_element->unique_id());
|
||||
return ByteString::number(active_element->unique_id());
|
||||
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::NoSuchElement, "The current document does not have an active element"sv);
|
||||
}
|
||||
|
@ -1004,7 +1004,7 @@ Messages::WebDriverClient::GetElementShadowRootResponse WebDriverConnection::get
|
|||
|
||||
// 5. If shadow root is null, return error with error code no such shadow root.
|
||||
if (!shadow_root)
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::NoSuchShadowRoot, DeprecatedString::formatted("Element with ID '{}' does not have a shadow root", element_id));
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::NoSuchShadowRoot, ByteString::formatted("Element with ID '{}' does not have a shadow root", element_id));
|
||||
|
||||
// 6. Let serialized be the shadow root reference object for shadow root.
|
||||
auto serialized = shadow_root_reference_object(*shadow_root);
|
||||
|
@ -1062,7 +1062,7 @@ Messages::WebDriverClient::GetElementAttributeResponse WebDriverConnection::get_
|
|||
auto* element = TRY(get_known_connected_element(element_id));
|
||||
|
||||
// 4. Let result be the result of the first matching condition:
|
||||
Optional<DeprecatedString> result;
|
||||
Optional<ByteString> result;
|
||||
|
||||
// -> If name is a boolean attribute
|
||||
if (Web::HTML::is_boolean_attribute(name)) {
|
||||
|
@ -1094,15 +1094,15 @@ Messages::WebDriverClient::GetElementPropertyResponse WebDriverConnection::get_e
|
|||
// 3. Let element be the result of trying to get a known connected element with url variable element id.
|
||||
auto* element = TRY(get_known_connected_element(element_id));
|
||||
|
||||
Optional<DeprecatedString> result;
|
||||
Optional<ByteString> result;
|
||||
|
||||
// 4. Let property be the result of calling the Object.[[GetProperty]](name) on element.
|
||||
if (auto property_or_error = element->get(name.to_deprecated_string()); !property_or_error.is_throw_completion()) {
|
||||
if (auto property_or_error = element->get(name.to_byte_string()); !property_or_error.is_throw_completion()) {
|
||||
auto property = property_or_error.release_value();
|
||||
|
||||
// 5. Let result be the value of property if not undefined, or null.
|
||||
if (!property.is_undefined()) {
|
||||
if (auto string_or_error = property.to_deprecated_string(element->vm()); !string_or_error.is_error())
|
||||
if (auto string_or_error = property.to_byte_string(element->vm()); !string_or_error.is_error())
|
||||
result = string_or_error.release_value();
|
||||
}
|
||||
}
|
||||
|
@ -1126,20 +1126,20 @@ Messages::WebDriverClient::GetElementCssValueResponse WebDriverConnection::get_e
|
|||
auto* element = TRY(get_known_connected_element(element_id));
|
||||
|
||||
// 4. Let computed value be the result of the first matching condition:
|
||||
DeprecatedString computed_value;
|
||||
ByteString computed_value;
|
||||
|
||||
// -> current browsing context’s active document’s type is not "xml"
|
||||
if (!m_page_client.page().top_level_browsing_context().active_document()->is_xml_document()) {
|
||||
// computed value of parameter property name from element’s style declarations. property name is obtained from url variables.
|
||||
if (auto property = Web::CSS::property_id_from_string(name); property.has_value()) {
|
||||
if (auto* computed_values = element->computed_css_values())
|
||||
computed_value = computed_values->property(property.value())->to_string().to_deprecated_string();
|
||||
computed_value = computed_values->property(property.value())->to_string().to_byte_string();
|
||||
}
|
||||
}
|
||||
// -> Otherwise
|
||||
else {
|
||||
// "" (empty string)
|
||||
computed_value = DeprecatedString::empty();
|
||||
computed_value = ByteString::empty();
|
||||
}
|
||||
|
||||
// 5. Return success with data computed value.
|
||||
|
@ -1162,7 +1162,7 @@ Messages::WebDriverClient::GetElementTextResponse WebDriverConnection::get_eleme
|
|||
auto rendered_text = element->text_content();
|
||||
|
||||
// 5. Return success with data rendered text.
|
||||
return rendered_text.value_or(String {}).to_deprecated_string();
|
||||
return rendered_text.value_or(String {}).to_byte_string();
|
||||
}
|
||||
|
||||
// 12.4.6 Get Element Tag Name, https://w3c.github.io/webdriver/#dfn-get-element-tag-name
|
||||
|
@ -1278,7 +1278,7 @@ Messages::WebDriverClient::GetComputedLabelResponse WebDriverConnection::get_com
|
|||
auto label = element->accessible_name(element->document()).release_value_but_fixme_should_propagate_errors();
|
||||
|
||||
// 5. Return success with data label.
|
||||
return label.to_deprecated_string();
|
||||
return label.to_byte_string();
|
||||
}
|
||||
|
||||
// 12.5.1 Element Click, https://w3c.github.io/webdriver/#element-click
|
||||
|
@ -1418,15 +1418,15 @@ Messages::WebDriverClient::GetSourceResponse WebDriverConnection::get_source()
|
|||
TRY(handle_any_user_prompts());
|
||||
|
||||
auto* document = m_page_client.page().top_level_browsing_context().active_document();
|
||||
Optional<DeprecatedString> source;
|
||||
Optional<ByteString> source;
|
||||
|
||||
// 3. Let source be the result of invoking the fragment serializing algorithm on a fictional node whose only child is the document element providing true for the require well-formed flag. If this causes an exception to be thrown, let source be null.
|
||||
if (auto result = document->serialize_fragment(Web::DOMParsing::RequireWellFormed::Yes); !result.is_error())
|
||||
source = result.release_value().to_deprecated_string();
|
||||
source = result.release_value().to_byte_string();
|
||||
|
||||
// 4. Let source be the result of serializing to string the current browsing context active document, if source is null.
|
||||
if (!source.has_value())
|
||||
source = MUST(document->serialize_fragment(Web::DOMParsing::RequireWellFormed::No)).to_deprecated_string();
|
||||
source = MUST(document->serialize_fragment(Web::DOMParsing::RequireWellFormed::No)).to_byte_string();
|
||||
|
||||
// 5. Return success with data source.
|
||||
return source.release_value();
|
||||
|
@ -1539,13 +1539,13 @@ Messages::WebDriverClient::GetNamedCookieResponse WebDriverConnection::get_named
|
|||
// 3. If the url variable name is equal to a cookie’s cookie name amongst all associated cookies of the current browsing context’s active document, return success with the serialized cookie as data.
|
||||
auto* document = m_page_client.page().top_level_browsing_context().active_document();
|
||||
|
||||
if (auto cookie = m_page_client.page_did_request_named_cookie(document->url(), name.to_deprecated_string()); cookie.has_value()) {
|
||||
if (auto cookie = m_page_client.page_did_request_named_cookie(document->url(), name.to_byte_string()); cookie.has_value()) {
|
||||
auto serialized_cookie = serialize_cookie(*cookie);
|
||||
return serialized_cookie;
|
||||
}
|
||||
|
||||
// 4. Otherwise, return error with error code no such cookie.
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::NoSuchCookie, DeprecatedString::formatted("Cookie '{}' not found", name));
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::NoSuchCookie, ByteString::formatted("Cookie '{}' not found", name));
|
||||
}
|
||||
|
||||
// 14.3 Add Cookie, https://w3c.github.io/webdriver/#dfn-adding-a-cookie
|
||||
|
@ -1570,13 +1570,13 @@ Messages::WebDriverClient::AddCookieResponse WebDriverConnection::add_cookie(Jso
|
|||
|
||||
// 7. Create a cookie in the cookie store associated with the active document’s address using cookie name name, cookie value value, and an attribute-value list of the following cookie concepts listed in the table for cookie conversion from data:
|
||||
Web::Cookie::ParsedCookie cookie {};
|
||||
cookie.name = MUST(String::from_deprecated_string(TRY(get_property(data, "name"sv))));
|
||||
cookie.value = MUST(String::from_deprecated_string(TRY(get_property(data, "value"sv))));
|
||||
cookie.name = MUST(String::from_byte_string(TRY(get_property(data, "name"sv))));
|
||||
cookie.value = MUST(String::from_byte_string(TRY(get_property(data, "value"sv))));
|
||||
|
||||
// Cookie path
|
||||
// The value if the entry exists, otherwise "/".
|
||||
if (data.has("path"sv))
|
||||
cookie.path = MUST(String::from_deprecated_string(TRY(get_property(data, "path"sv))));
|
||||
cookie.path = MUST(String::from_byte_string(TRY(get_property(data, "path"sv))));
|
||||
else
|
||||
cookie.path = "/"_string;
|
||||
|
||||
|
@ -1584,7 +1584,7 @@ Messages::WebDriverClient::AddCookieResponse WebDriverConnection::add_cookie(Jso
|
|||
// The value if the entry exists, otherwise the current browsing context’s active document’s URL domain.
|
||||
// NOTE: The otherwise case is handled by the CookieJar
|
||||
if (data.has("domain"sv))
|
||||
cookie.domain = MUST(String::from_deprecated_string(TRY(get_property(data, "domain"sv))));
|
||||
cookie.domain = MUST(String::from_byte_string(TRY(get_property(data, "domain"sv))));
|
||||
|
||||
// Cookie secure only
|
||||
// The value if the entry exists, otherwise false.
|
||||
|
@ -1722,7 +1722,7 @@ Messages::WebDriverClient::GetAlertTextResponse WebDriverConnection::get_alert_t
|
|||
|
||||
// 4. Return success with data message.
|
||||
if (message.has_value())
|
||||
return message->to_deprecated_string();
|
||||
return message->to_byte_string();
|
||||
return JsonValue {};
|
||||
}
|
||||
|
||||
|
@ -1761,7 +1761,7 @@ Messages::WebDriverClient::SendAlertTextResponse WebDriverConnection::send_alert
|
|||
}
|
||||
|
||||
// 6. Perform user agent dependent steps to set the value of current user prompt’s text field to text.
|
||||
m_page_client.page_did_request_set_prompt_text(TRY(String::from_deprecated_string(text)));
|
||||
m_page_client.page_did_request_set_prompt_text(TRY(String::from_byte_string(text)));
|
||||
|
||||
// 7. Return success with data null.
|
||||
return JsonValue {};
|
||||
|
@ -1997,7 +1997,7 @@ ErrorOr<JsonArray, Web::WebDriver::Error> WebDriverConnection::find(StartNodeGet
|
|||
|
||||
// 5. If a DOMException, SyntaxError, XPathException, or other error occurs during the execution of the element location strategy, return error invalid selector.
|
||||
if (elements.is_error())
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidSelector, DeprecatedString::formatted("The location strategy could not finish: {}", elements.error().message));
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidSelector, ByteString::formatted("The location strategy could not finish: {}", elements.error().message));
|
||||
|
||||
return elements.release_value();
|
||||
};
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/String.h>
|
||||
|
@ -31,7 +31,7 @@ class WebDriverConnection final
|
|||
C_OBJECT_ABSTRACT(WebDriverConnection)
|
||||
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<WebDriverConnection>> connect(Web::PageClient& page_client, DeprecatedString const& webdriver_ipc_path);
|
||||
static ErrorOr<NonnullRefPtr<WebDriverConnection>> connect(Web::PageClient& page_client, ByteString const& webdriver_ipc_path);
|
||||
virtual ~WebDriverConnection() = default;
|
||||
|
||||
private:
|
||||
|
@ -111,7 +111,7 @@ private:
|
|||
ErrorOr<JsonArray, Web::WebDriver::Error> find(StartNodeGetter&& start_node_getter, Web::WebDriver::LocationStrategy using_, StringView value);
|
||||
|
||||
struct ScriptArguments {
|
||||
DeprecatedString script;
|
||||
ByteString script;
|
||||
JS::MarkedVector<JS::Value> arguments;
|
||||
};
|
||||
ErrorOr<ScriptArguments, Web::WebDriver::Error> extract_the_script_arguments_from_a_request(JsonValue const& payload);
|
||||
|
|
|
@ -30,7 +30,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
|
|||
TRY(Core::System::pledge("stdio recvfd sendfd accept unix rpath thread proc"));
|
||||
|
||||
// This must be first; we can't check if /tmp/webdriver exists once we've unveiled other paths.
|
||||
auto webdriver_socket_path = DeprecatedString::formatted("{}/webdriver", TRY(Core::StandardPaths::runtime_directory()));
|
||||
auto webdriver_socket_path = ByteString::formatted("{}/webdriver", TRY(Core::StandardPaths::runtime_directory()));
|
||||
if (FileSystem::exists(webdriver_socket_path))
|
||||
TRY(Core::System::unveil(webdriver_socket_path, "rw"sv));
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ void Client::close_session(unsigned session_id)
|
|||
static void initialize_session_from_capabilities(WebContentConnection& web_content_connection, JsonObject& capabilities)
|
||||
{
|
||||
// 1. Let strategy be the result of getting property "pageLoadStrategy" from capabilities.
|
||||
auto strategy = capabilities.get_deprecated_string("pageLoadStrategy"sv);
|
||||
auto strategy = capabilities.get_byte_string("pageLoadStrategy"sv);
|
||||
|
||||
// 2. If strategy is a string, set the current session’s page loading strategy to strategy. Otherwise, set the page loading strategy to normal and set a property of capabilities with name "pageLoadStrategy" and value "normal".
|
||||
if (strategy.has_value())
|
||||
|
@ -97,7 +97,7 @@ static void initialize_session_from_capabilities(WebContentConnection& web_conte
|
|||
}
|
||||
|
||||
// 8. Apply changes to the user agent for any implementation-defined capabilities selected during the capabilities processing step.
|
||||
auto behavior = capabilities.get_deprecated_string("unhandledPromptBehavior"sv);
|
||||
auto behavior = capabilities.get_byte_string("unhandledPromptBehavior"sv);
|
||||
if (behavior.has_value())
|
||||
web_content_connection.async_set_unhandled_prompt_behavior(Web::WebDriver::unhandled_prompt_behavior_from_string(*behavior));
|
||||
else
|
||||
|
@ -139,7 +139,7 @@ Web::WebDriver::Response Client::new_session(Web::WebDriver::Parameters, JsonVal
|
|||
auto session = make_ref_counted<Session>(session_id, *this, move(options));
|
||||
|
||||
if (auto start_result = session->start(m_callbacks); start_result.is_error())
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::SessionNotCreated, DeprecatedString::formatted("Failed to start session: {}", start_result.error()));
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::SessionNotCreated, ByteString::formatted("Failed to start session: {}", start_result.error()));
|
||||
|
||||
auto& web_content_connection = session->web_content_connection();
|
||||
|
||||
|
@ -160,7 +160,7 @@ Web::WebDriver::Response Client::new_session(Web::WebDriver::Parameters, JsonVal
|
|||
JsonObject body;
|
||||
// "sessionId"
|
||||
// session id
|
||||
body.set("sessionId", DeprecatedString::number(session_id));
|
||||
body.set("sessionId", ByteString::number(session_id));
|
||||
// "capabilities"
|
||||
// capabilities
|
||||
body.set("capabilities", move(capabilities));
|
||||
|
@ -323,7 +323,7 @@ Web::WebDriver::Response Client::switch_to_window(Web::WebDriver::Parameters par
|
|||
if (!handle.has_value())
|
||||
return Web::WebDriver::Error::from_code(Web::WebDriver::ErrorCode::InvalidArgument, "No property called 'handle' present");
|
||||
|
||||
return session->switch_to_window(handle->to_deprecated_string());
|
||||
return session->switch_to_window(handle->to_byte_string());
|
||||
}
|
||||
|
||||
// 11.4 Get Window Handles, https://w3c.github.io/webdriver/#dfn-get-window-handles
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
namespace WebDriver {
|
||||
|
||||
struct LaunchBrowserCallbacks {
|
||||
Function<ErrorOr<pid_t>(DeprecatedString const&)> launch_browser;
|
||||
Function<ErrorOr<pid_t>(DeprecatedString const&)> launch_headless_browser;
|
||||
Function<ErrorOr<pid_t>(ByteString const&)> launch_browser;
|
||||
Function<ErrorOr<pid_t>(ByteString const&)> launch_headless_browser;
|
||||
};
|
||||
|
||||
class Client final : public Web::WebDriver::Client {
|
||||
|
|
|
@ -98,7 +98,7 @@ ErrorOr<void> Session::start(LaunchBrowserCallbacks const& callbacks)
|
|||
{
|
||||
auto promise = TRY(ServerPromise::try_create());
|
||||
|
||||
m_web_content_socket_path = DeprecatedString::formatted("{}/webdriver/session_{}_{}", TRY(Core::StandardPaths::runtime_directory()), getpid(), m_id);
|
||||
m_web_content_socket_path = ByteString::formatted("{}/webdriver/session_{}_{}", TRY(Core::StandardPaths::runtime_directory()), getpid(), m_id);
|
||||
m_web_content_server = TRY(create_server(promise));
|
||||
|
||||
if (m_options.headless)
|
||||
|
|
|
@ -66,7 +66,7 @@ private:
|
|||
HashMap<String, Window> m_windows;
|
||||
String m_current_window_handle;
|
||||
|
||||
Optional<DeprecatedString> m_web_content_socket_path;
|
||||
Optional<ByteString> m_web_content_socket_path;
|
||||
Optional<pid_t> m_browser_pid;
|
||||
|
||||
RefPtr<Core::LocalServer> m_web_content_server;
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include <LibMain/Main.h>
|
||||
#include <WebDriver/Client.h>
|
||||
|
||||
static ErrorOr<pid_t> launch_browser(DeprecatedString const& socket_path)
|
||||
static ErrorOr<pid_t> launch_browser(ByteString const& socket_path)
|
||||
{
|
||||
return Core::Process::spawn("/bin/Browser"sv,
|
||||
Array {
|
||||
|
@ -24,7 +24,7 @@ static ErrorOr<pid_t> launch_browser(DeprecatedString const& socket_path)
|
|||
});
|
||||
}
|
||||
|
||||
static ErrorOr<pid_t> launch_headless_browser(DeprecatedString const& socket_path)
|
||||
static ErrorOr<pid_t> launch_headless_browser(ByteString const& socket_path)
|
||||
{
|
||||
return Core::Process::spawn("/bin/headless-browser"sv,
|
||||
Array {
|
||||
|
@ -36,10 +36,10 @@ static ErrorOr<pid_t> launch_headless_browser(DeprecatedString const& socket_pat
|
|||
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
{
|
||||
DeprecatedString default_listen_address = "0.0.0.0";
|
||||
ByteString default_listen_address = "0.0.0.0";
|
||||
u16 default_port = 8000;
|
||||
|
||||
DeprecatedString listen_address = default_listen_address;
|
||||
ByteString listen_address = default_listen_address;
|
||||
int port = default_port;
|
||||
|
||||
Core::ArgsParser args_parser;
|
||||
|
@ -60,7 +60,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
TRY(Core::System::pledge("stdio accept cpath rpath recvfd inet unix proc exec fattr"));
|
||||
|
||||
auto webdriver_socket_path = DeprecatedString::formatted("{}/webdriver", TRY(Core::StandardPaths::runtime_directory()));
|
||||
auto webdriver_socket_path = ByteString::formatted("{}/webdriver", TRY(Core::StandardPaths::runtime_directory()));
|
||||
TRY(Core::Directory::create(webdriver_socket_path, Core::Directory::CreateDirectories::Yes));
|
||||
|
||||
Core::EventLoop loop;
|
||||
|
|
|
@ -79,7 +79,7 @@ ErrorOr<void, Client::WrappedError> Client::on_ready_to_read()
|
|||
return {};
|
||||
|
||||
auto request = TRY(m_remaining_request.to_byte_buffer());
|
||||
dbgln_if(WEBSERVER_DEBUG, "Got raw request: '{}'", DeprecatedString::copy(request));
|
||||
dbgln_if(WEBSERVER_DEBUG, "Got raw request: '{}'", ByteString::copy(request));
|
||||
|
||||
auto maybe_parsed_request = HTTP::HttpRequest::from_raw_request(TRY(m_remaining_request.to_byte_buffer()));
|
||||
if (maybe_parsed_request.is_error()) {
|
||||
|
@ -125,7 +125,7 @@ ErrorOr<bool> Client::handle_request(HTTP::HttpRequest const& request)
|
|||
}
|
||||
}
|
||||
|
||||
auto requested_path = TRY(String::from_deprecated_string(LexicalPath::join("/"sv, resource_decoded).string()));
|
||||
auto requested_path = TRY(String::from_byte_string(LexicalPath::join("/"sv, resource_decoded).string()));
|
||||
dbgln_if(WEBSERVER_DEBUG, "Canonical requested path: '{}'", requested_path);
|
||||
|
||||
auto real_path = TRY(String::formatted("{}{}", Configuration::the().document_root_path(), requested_path));
|
||||
|
@ -240,24 +240,24 @@ ErrorOr<void> Client::send_redirect(StringView redirect_path, HTTP::HttpRequest
|
|||
return {};
|
||||
}
|
||||
|
||||
static DeprecatedString folder_image_data()
|
||||
static ByteString folder_image_data()
|
||||
{
|
||||
static DeprecatedString cache;
|
||||
static ByteString cache;
|
||||
if (cache.is_empty()) {
|
||||
auto file = Core::MappedFile::map("/res/icons/16x16/filetype-folder.png"sv).release_value_but_fixme_should_propagate_errors();
|
||||
// FIXME: change to TRY() and make method fallible
|
||||
cache = MUST(encode_base64(file->bytes())).to_deprecated_string();
|
||||
cache = MUST(encode_base64(file->bytes())).to_byte_string();
|
||||
}
|
||||
return cache;
|
||||
}
|
||||
|
||||
static DeprecatedString file_image_data()
|
||||
static ByteString file_image_data()
|
||||
{
|
||||
static DeprecatedString cache;
|
||||
static ByteString cache;
|
||||
if (cache.is_empty()) {
|
||||
auto file = Core::MappedFile::map("/res/icons/16x16/filetype-unknown.png"sv).release_value_but_fixme_should_propagate_errors();
|
||||
// FIXME: change to TRY() and make method fallible
|
||||
cache = MUST(encode_base64(file->bytes())).to_deprecated_string();
|
||||
cache = MUST(encode_base64(file->bytes())).to_byte_string();
|
||||
}
|
||||
return cache;
|
||||
}
|
||||
|
@ -286,7 +286,7 @@ ErrorOr<void> Client::handle_directory_listing(String const& requested_path, Str
|
|||
TRY(builder.try_append("<code><table>\n"sv));
|
||||
|
||||
Core::DirIterator dt(real_path.bytes_as_string_view());
|
||||
Vector<DeprecatedString> names;
|
||||
Vector<ByteString> names;
|
||||
while (dt.has_next())
|
||||
TRY(names.try_append(dt.next_path()));
|
||||
quick_sort(names);
|
||||
|
@ -337,7 +337,7 @@ ErrorOr<void> Client::handle_directory_listing(String const& requested_path, Str
|
|||
TRY(builder.try_append("</body>\n"sv));
|
||||
TRY(builder.try_append("</html>\n"sv));
|
||||
|
||||
auto response = builder.to_deprecated_string();
|
||||
auto response = builder.to_byte_string();
|
||||
FixedMemoryStream stream { response.bytes() };
|
||||
return send_response(stream, request, { .type = "text/html"_string, .length = response.length() });
|
||||
}
|
||||
|
@ -373,7 +373,7 @@ ErrorOr<void> Client::send_error_response(unsigned code, HTTP::HttpRequest const
|
|||
|
||||
void Client::log_response(unsigned code, HTTP::HttpRequest const& request)
|
||||
{
|
||||
outln("{} :: {:03d} :: {} {}", Core::DateTime::now().to_deprecated_string(), code, request.method_name(), request.url().serialize().substring(1));
|
||||
outln("{} :: {:03d} :: {} {}", Core::DateTime::now().to_byte_string(), code, request.method_name(), request.url().serialize().substring(1));
|
||||
}
|
||||
|
||||
bool Client::verify_credentials(Vector<HTTP::HttpRequest::Header> const& headers)
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <LibHTTP/HttpRequest.h>
|
||||
|
||||
|
|
|
@ -26,11 +26,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
static auto const default_port = 8000;
|
||||
static auto const default_document_root_path = "/www"_string;
|
||||
|
||||
DeprecatedString listen_address = default_listen_address.to_deprecated_string();
|
||||
ByteString listen_address = default_listen_address.to_byte_string();
|
||||
int port = default_port;
|
||||
DeprecatedString username;
|
||||
DeprecatedString password;
|
||||
DeprecatedString document_root_path = default_document_root_path.to_deprecated_string();
|
||||
ByteString username;
|
||||
ByteString password;
|
||||
ByteString document_root_path = default_document_root_path.to_byte_string();
|
||||
|
||||
Core::ArgsParser args_parser;
|
||||
args_parser.add_option(listen_address, "IP address to listen on", "listen-address", 'l', "listen_address");
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue