mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 01:47: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
|
@ -64,7 +64,7 @@ bool Client::verify_response_is_complete()
|
|||
auto slice_data = MUST(m_buffer.slice(m_buffer.size() - slice_size, slice_size));
|
||||
StringView slice = StringView(slice_data);
|
||||
for (auto status : statuses) {
|
||||
DeprecatedString pattern = DeprecatedString::formatted("A{} {}", m_current_command, status);
|
||||
ByteString pattern = ByteString::formatted("A{} {}", m_current_command, status);
|
||||
if (slice.contains(pattern)) {
|
||||
dbgln("IMAP server replied {}, sending to parser", pattern);
|
||||
return true;
|
||||
|
@ -207,16 +207,16 @@ NonnullRefPtr<Promise<SolidResponse>> Client::login(StringView username, StringV
|
|||
NonnullRefPtr<Promise<SolidResponse>> Client::list(StringView reference_name, StringView mailbox)
|
||||
{
|
||||
auto command = Command { CommandType::List, m_current_command,
|
||||
{ DeprecatedString::formatted("\"{}\"", reference_name),
|
||||
DeprecatedString::formatted("\"{}\"", mailbox) } };
|
||||
{ ByteString::formatted("\"{}\"", reference_name),
|
||||
ByteString::formatted("\"{}\"", mailbox) } };
|
||||
return cast_promise<SolidResponse>(send_command(move(command)));
|
||||
}
|
||||
|
||||
NonnullRefPtr<Promise<SolidResponse>> Client::lsub(StringView reference_name, StringView mailbox)
|
||||
{
|
||||
auto command = Command { CommandType::ListSub, m_current_command,
|
||||
{ DeprecatedString::formatted("\"{}\"", reference_name),
|
||||
DeprecatedString::formatted("\"{}\"", mailbox) } };
|
||||
{ ByteString::formatted("\"{}\"", reference_name),
|
||||
ByteString::formatted("\"{}\"", mailbox) } };
|
||||
return cast_promise<SolidResponse>(send_command(move(command)));
|
||||
}
|
||||
|
||||
|
@ -270,7 +270,7 @@ ErrorOr<void> Client::send_next_command()
|
|||
{
|
||||
auto command = m_command_queue.take_first();
|
||||
ByteBuffer buffer;
|
||||
auto tag = AK::DeprecatedString::formatted("A{} ", m_current_command);
|
||||
auto tag = AK::ByteString::formatted("A{} ", m_current_command);
|
||||
buffer += tag.to_byte_buffer();
|
||||
auto command_type = command_byte_buffer(command.type);
|
||||
buffer.append(command_type.data(), command_type.size());
|
||||
|
@ -303,7 +303,7 @@ NonnullRefPtr<Promise<SolidResponse>> Client::delete_mailbox(StringView name)
|
|||
return cast_promise<SolidResponse>(send_command(move(command)));
|
||||
}
|
||||
|
||||
NonnullRefPtr<Promise<SolidResponse>> Client::store(StoreMethod method, Sequence sequence_set, bool silent, Vector<DeprecatedString> const& flags, bool uid)
|
||||
NonnullRefPtr<Promise<SolidResponse>> Client::store(StoreMethod method, Sequence sequence_set, bool silent, Vector<ByteString> const& flags, bool uid)
|
||||
{
|
||||
StringBuilder data_item_name;
|
||||
switch (method) {
|
||||
|
@ -326,12 +326,12 @@ NonnullRefPtr<Promise<SolidResponse>> Client::store(StoreMethod method, Sequence
|
|||
flags_builder.join(' ', flags);
|
||||
flags_builder.append(')');
|
||||
|
||||
auto command = Command { uid ? CommandType::UIDStore : CommandType::Store, m_current_command, { sequence_set.serialize(), data_item_name.to_deprecated_string(), flags_builder.to_deprecated_string() } };
|
||||
auto command = Command { uid ? CommandType::UIDStore : CommandType::Store, m_current_command, { sequence_set.serialize(), data_item_name.to_byte_string(), flags_builder.to_byte_string() } };
|
||||
return cast_promise<SolidResponse>(send_command(move(command)));
|
||||
}
|
||||
NonnullRefPtr<Promise<SolidResponse>> Client::search(Optional<DeprecatedString> charset, Vector<SearchKey>&& keys, bool uid)
|
||||
NonnullRefPtr<Promise<SolidResponse>> Client::search(Optional<ByteString> charset, Vector<SearchKey>&& keys, bool uid)
|
||||
{
|
||||
Vector<DeprecatedString> args;
|
||||
Vector<ByteString> args;
|
||||
if (charset.has_value()) {
|
||||
args.append("CHARSET "sv);
|
||||
args.append(charset.value());
|
||||
|
@ -359,7 +359,7 @@ NonnullRefPtr<Promise<SolidResponse>> Client::finish_idle()
|
|||
|
||||
NonnullRefPtr<Promise<SolidResponse>> Client::status(StringView mailbox, Vector<StatusItemType> const& types)
|
||||
{
|
||||
Vector<DeprecatedString> args;
|
||||
Vector<ByteString> args;
|
||||
for (auto type : types) {
|
||||
switch (type) {
|
||||
case StatusItemType::Recent:
|
||||
|
@ -383,24 +383,24 @@ NonnullRefPtr<Promise<SolidResponse>> Client::status(StringView mailbox, Vector<
|
|||
types_list.append('(');
|
||||
types_list.join(' ', args);
|
||||
types_list.append(')');
|
||||
auto command = Command { CommandType::Status, m_current_command, { mailbox, types_list.to_deprecated_string() } };
|
||||
auto command = Command { CommandType::Status, m_current_command, { mailbox, types_list.to_byte_string() } };
|
||||
return cast_promise<SolidResponse>(send_command(move(command)));
|
||||
}
|
||||
|
||||
NonnullRefPtr<Promise<SolidResponse>> Client::append(StringView mailbox, Message&& message, Optional<Vector<DeprecatedString>> flags, Optional<Core::DateTime> date_time)
|
||||
NonnullRefPtr<Promise<SolidResponse>> Client::append(StringView mailbox, Message&& message, Optional<Vector<ByteString>> flags, Optional<Core::DateTime> date_time)
|
||||
{
|
||||
Vector<DeprecatedString> args = { mailbox };
|
||||
Vector<ByteString> args = { mailbox };
|
||||
if (flags.has_value()) {
|
||||
StringBuilder flags_sb;
|
||||
flags_sb.append('(');
|
||||
flags_sb.join(' ', flags.value());
|
||||
flags_sb.append(')');
|
||||
args.append(flags_sb.to_deprecated_string());
|
||||
args.append(flags_sb.to_byte_string());
|
||||
}
|
||||
if (date_time.has_value())
|
||||
args.append(date_time.value().to_deprecated_string("\"%d-%b-%Y %H:%M:%S +0000\""sv));
|
||||
args.append(date_time.value().to_byte_string("\"%d-%b-%Y %H:%M:%S +0000\""sv));
|
||||
|
||||
args.append(DeprecatedString::formatted("{{{}}}", message.data.length()));
|
||||
args.append(ByteString::formatted("{{{}}}", message.data.length()));
|
||||
|
||||
auto continue_req = send_command(Command { CommandType::Append, m_current_command, args });
|
||||
|
||||
|
|
|
@ -38,9 +38,9 @@ public:
|
|||
NonnullRefPtr<Promise<SolidResponse>> lsub(StringView reference_name, StringView mailbox_name);
|
||||
NonnullRefPtr<Promise<SolidResponse>> select(StringView string);
|
||||
NonnullRefPtr<Promise<SolidResponse>> examine(StringView string);
|
||||
NonnullRefPtr<Promise<SolidResponse>> search(Optional<DeprecatedString> charset, Vector<SearchKey>&& search_keys, bool uid);
|
||||
NonnullRefPtr<Promise<SolidResponse>> search(Optional<ByteString> charset, Vector<SearchKey>&& search_keys, bool uid);
|
||||
NonnullRefPtr<Promise<SolidResponse>> fetch(FetchCommand request, bool uid);
|
||||
NonnullRefPtr<Promise<SolidResponse>> store(StoreMethod, Sequence, bool silent, Vector<DeprecatedString> const& flags, bool uid);
|
||||
NonnullRefPtr<Promise<SolidResponse>> store(StoreMethod, Sequence, bool silent, Vector<ByteString> const& flags, bool uid);
|
||||
NonnullRefPtr<Promise<SolidResponse>> copy(Sequence sequence_set, StringView name, bool uid);
|
||||
NonnullRefPtr<Promise<SolidResponse>> create_mailbox(StringView name);
|
||||
NonnullRefPtr<Promise<SolidResponse>> delete_mailbox(StringView name);
|
||||
|
@ -51,7 +51,7 @@ public:
|
|||
NonnullRefPtr<Promise<ContinueRequest>> idle();
|
||||
NonnullRefPtr<Promise<SolidResponse>> finish_idle();
|
||||
NonnullRefPtr<Promise<SolidResponse>> status(StringView mailbox, Vector<StatusItemType> const& types);
|
||||
NonnullRefPtr<Promise<SolidResponse>> append(StringView mailbox, Message&& message, Optional<Vector<DeprecatedString>> flags = {}, Optional<Core::DateTime> date_time = {});
|
||||
NonnullRefPtr<Promise<SolidResponse>> append(StringView mailbox, Message&& message, Optional<Vector<ByteString>> flags = {}, Optional<Core::DateTime> date_time = {});
|
||||
|
||||
bool is_open();
|
||||
void close();
|
||||
|
|
|
@ -20,7 +20,7 @@ ErrorOr<ByteBuffer> decode_rfc2047_encoded_words(StringView input)
|
|||
|
||||
while (!lexer.is_eof()) {
|
||||
auto ascii_view = lexer.consume_until("=?"sv);
|
||||
DeprecatedString ascii = ascii_view.replace("\r"sv, " "sv, ReplaceMode::All);
|
||||
ByteString ascii = ascii_view.replace("\r"sv, " "sv, ReplaceMode::All);
|
||||
ascii = ascii.replace("\n"sv, " "sv, ReplaceMode::All);
|
||||
TRY(output.try_append(ascii));
|
||||
if (lexer.is_eof())
|
||||
|
|
|
@ -9,18 +9,18 @@
|
|||
|
||||
namespace IMAP {
|
||||
|
||||
DeprecatedString Sequence::serialize() const
|
||||
ByteString Sequence::serialize() const
|
||||
{
|
||||
if (start == end) {
|
||||
return AK::DeprecatedString::formatted("{}", start);
|
||||
return AK::ByteString::formatted("{}", start);
|
||||
} else {
|
||||
auto start_char = start != -1 ? DeprecatedString::formatted("{}", start) : "*";
|
||||
auto end_char = end != -1 ? DeprecatedString::formatted("{}", end) : "*";
|
||||
return DeprecatedString::formatted("{}:{}", start_char, end_char);
|
||||
auto start_char = start != -1 ? ByteString::formatted("{}", start) : "*";
|
||||
auto end_char = end != -1 ? ByteString::formatted("{}", end) : "*";
|
||||
return ByteString::formatted("{}:{}", start_char, end_char);
|
||||
}
|
||||
}
|
||||
|
||||
DeprecatedString FetchCommand::DataItem::Section::serialize() const
|
||||
ByteString FetchCommand::DataItem::Section::serialize() const
|
||||
{
|
||||
StringBuilder headers_builder;
|
||||
switch (type) {
|
||||
|
@ -41,7 +41,7 @@ DeprecatedString FetchCommand::DataItem::Section::serialize() const
|
|||
first = false;
|
||||
}
|
||||
headers_builder.append(')');
|
||||
return headers_builder.to_deprecated_string();
|
||||
return headers_builder.to_byte_string();
|
||||
}
|
||||
case SectionType::Text:
|
||||
return "TEXT";
|
||||
|
@ -57,12 +57,12 @@ DeprecatedString FetchCommand::DataItem::Section::serialize() const
|
|||
if (ends_with_mime) {
|
||||
sb.append(".MIME"sv);
|
||||
}
|
||||
return sb.to_deprecated_string();
|
||||
return sb.to_byte_string();
|
||||
}
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
DeprecatedString FetchCommand::DataItem::serialize() const
|
||||
ByteString FetchCommand::DataItem::serialize() const
|
||||
{
|
||||
switch (type) {
|
||||
case DataItemType::Envelope:
|
||||
|
@ -84,14 +84,14 @@ DeprecatedString FetchCommand::DataItem::serialize() const
|
|||
sb.appendff("<{}.{}>", start, octets);
|
||||
}
|
||||
|
||||
return sb.to_deprecated_string();
|
||||
return sb.to_byte_string();
|
||||
}
|
||||
case DataItemType::BodyStructure:
|
||||
return "BODYSTRUCTURE";
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
DeprecatedString FetchCommand::serialize()
|
||||
ByteString FetchCommand::serialize()
|
||||
{
|
||||
StringBuilder sequence_builder;
|
||||
bool first = true;
|
||||
|
@ -113,9 +113,9 @@ DeprecatedString FetchCommand::serialize()
|
|||
first = false;
|
||||
}
|
||||
|
||||
return AK::DeprecatedString::formatted("{} ({})", sequence_builder.to_deprecated_string(), data_items_builder.to_deprecated_string());
|
||||
return AK::ByteString::formatted("{} ({})", sequence_builder.to_byte_string(), data_items_builder.to_byte_string());
|
||||
}
|
||||
DeprecatedString serialize_astring(StringView string)
|
||||
ByteString serialize_astring(StringView string)
|
||||
{
|
||||
// Try to send an atom
|
||||
auto is_non_atom_char = [](char x) {
|
||||
|
@ -131,31 +131,31 @@ DeprecatedString serialize_astring(StringView string)
|
|||
auto can_be_quoted = !(string.contains('\n') || string.contains('\r'));
|
||||
if (can_be_quoted) {
|
||||
auto escaped_str = string.replace("\\"sv, "\\\\"sv, ReplaceMode::All).replace("\""sv, "\\\""sv, ReplaceMode::All);
|
||||
return DeprecatedString::formatted("\"{}\"", escaped_str);
|
||||
return ByteString::formatted("\"{}\"", escaped_str);
|
||||
}
|
||||
|
||||
// Just send a literal
|
||||
return DeprecatedString::formatted("{{{}}}\r\n{}", string.length(), string);
|
||||
return ByteString::formatted("{{{}}}\r\n{}", string.length(), string);
|
||||
}
|
||||
DeprecatedString SearchKey::serialize() const
|
||||
ByteString SearchKey::serialize() const
|
||||
{
|
||||
return data.visit(
|
||||
[&](All const&) { return DeprecatedString("ALL"); },
|
||||
[&](Answered const&) { return DeprecatedString("ANSWERED"); },
|
||||
[&](Bcc const& x) { return DeprecatedString::formatted("BCC {}", serialize_astring(x.bcc)); },
|
||||
[&](Cc const& x) { return DeprecatedString::formatted("CC {}", serialize_astring(x.cc)); },
|
||||
[&](Deleted const&) { return DeprecatedString("DELETED"); },
|
||||
[&](Draft const&) { return DeprecatedString("DRAFT"); },
|
||||
[&](From const& x) { return DeprecatedString::formatted("FROM {}", serialize_astring(x.from)); },
|
||||
[&](Header const& x) { return DeprecatedString::formatted("HEADER {} {}", serialize_astring(x.header), serialize_astring(x.value)); },
|
||||
[&](Keyword const& x) { return DeprecatedString::formatted("KEYWORD {}", x.keyword); },
|
||||
[&](Larger const& x) { return DeprecatedString::formatted("LARGER {}", x.number); },
|
||||
[&](New const&) { return DeprecatedString("NEW"); },
|
||||
[&](Not const& x) { return DeprecatedString::formatted("NOT {}", x.operand->serialize()); },
|
||||
[&](Old const&) { return DeprecatedString("OLD"); },
|
||||
[&](On const& x) { return DeprecatedString::formatted("ON {}", x.date.to_deprecated_string("%d-%b-%Y"sv)); },
|
||||
[&](Or const& x) { return DeprecatedString::formatted("OR {} {}", x.lhs->serialize(), x.rhs->serialize()); },
|
||||
[&](Recent const&) { return DeprecatedString("RECENT"); },
|
||||
[&](All const&) { return ByteString("ALL"); },
|
||||
[&](Answered const&) { return ByteString("ANSWERED"); },
|
||||
[&](Bcc const& x) { return ByteString::formatted("BCC {}", serialize_astring(x.bcc)); },
|
||||
[&](Cc const& x) { return ByteString::formatted("CC {}", serialize_astring(x.cc)); },
|
||||
[&](Deleted const&) { return ByteString("DELETED"); },
|
||||
[&](Draft const&) { return ByteString("DRAFT"); },
|
||||
[&](From const& x) { return ByteString::formatted("FROM {}", serialize_astring(x.from)); },
|
||||
[&](Header const& x) { return ByteString::formatted("HEADER {} {}", serialize_astring(x.header), serialize_astring(x.value)); },
|
||||
[&](Keyword const& x) { return ByteString::formatted("KEYWORD {}", x.keyword); },
|
||||
[&](Larger const& x) { return ByteString::formatted("LARGER {}", x.number); },
|
||||
[&](New const&) { return ByteString("NEW"); },
|
||||
[&](Not const& x) { return ByteString::formatted("NOT {}", x.operand->serialize()); },
|
||||
[&](Old const&) { return ByteString("OLD"); },
|
||||
[&](On const& x) { return ByteString::formatted("ON {}", x.date.to_byte_string("%d-%b-%Y"sv)); },
|
||||
[&](Or const& x) { return ByteString::formatted("OR {} {}", x.lhs->serialize(), x.rhs->serialize()); },
|
||||
[&](Recent const&) { return ByteString("RECENT"); },
|
||||
[&](SearchKeys const& x) {
|
||||
StringBuilder sb;
|
||||
sb.append('(');
|
||||
|
@ -166,23 +166,23 @@ DeprecatedString SearchKey::serialize() const
|
|||
sb.append(item->serialize());
|
||||
first = false;
|
||||
}
|
||||
return sb.to_deprecated_string();
|
||||
return sb.to_byte_string();
|
||||
},
|
||||
[&](Seen const&) { return DeprecatedString("SEEN"); },
|
||||
[&](SentBefore const& x) { return DeprecatedString::formatted("SENTBEFORE {}", x.date.to_deprecated_string("%d-%b-%Y"sv)); },
|
||||
[&](SentOn const& x) { return DeprecatedString::formatted("SENTON {}", x.date.to_deprecated_string("%d-%b-%Y"sv)); },
|
||||
[&](SentSince const& x) { return DeprecatedString::formatted("SENTSINCE {}", x.date.to_deprecated_string("%d-%b-%Y"sv)); },
|
||||
[&](Seen const&) { return ByteString("SEEN"); },
|
||||
[&](SentBefore const& x) { return ByteString::formatted("SENTBEFORE {}", x.date.to_byte_string("%d-%b-%Y"sv)); },
|
||||
[&](SentOn const& x) { return ByteString::formatted("SENTON {}", x.date.to_byte_string("%d-%b-%Y"sv)); },
|
||||
[&](SentSince const& x) { return ByteString::formatted("SENTSINCE {}", x.date.to_byte_string("%d-%b-%Y"sv)); },
|
||||
[&](SequenceSet const& x) { return x.sequence.serialize(); },
|
||||
[&](Since const& x) { return DeprecatedString::formatted("SINCE {}", x.date.to_deprecated_string("%d-%b-%Y"sv)); },
|
||||
[&](Smaller const& x) { return DeprecatedString::formatted("SMALLER {}", x.number); },
|
||||
[&](Subject const& x) { return DeprecatedString::formatted("SUBJECT {}", serialize_astring(x.subject)); },
|
||||
[&](Text const& x) { return DeprecatedString::formatted("TEXT {}", serialize_astring(x.text)); },
|
||||
[&](To const& x) { return DeprecatedString::formatted("TO {}", serialize_astring(x.to)); },
|
||||
[&](UID const& x) { return DeprecatedString::formatted("UID {}", x.uid); },
|
||||
[&](Unanswered const&) { return DeprecatedString("UNANSWERED"); },
|
||||
[&](Undeleted const&) { return DeprecatedString("UNDELETED"); },
|
||||
[&](Undraft const&) { return DeprecatedString("UNDRAFT"); },
|
||||
[&](Unkeyword const& x) { return DeprecatedString::formatted("UNKEYWORD {}", serialize_astring(x.flag_keyword)); },
|
||||
[&](Unseen const&) { return DeprecatedString("UNSEEN"); });
|
||||
[&](Since const& x) { return ByteString::formatted("SINCE {}", x.date.to_byte_string("%d-%b-%Y"sv)); },
|
||||
[&](Smaller const& x) { return ByteString::formatted("SMALLER {}", x.number); },
|
||||
[&](Subject const& x) { return ByteString::formatted("SUBJECT {}", serialize_astring(x.subject)); },
|
||||
[&](Text const& x) { return ByteString::formatted("TEXT {}", serialize_astring(x.text)); },
|
||||
[&](To const& x) { return ByteString::formatted("TO {}", serialize_astring(x.to)); },
|
||||
[&](UID const& x) { return ByteString::formatted("UID {}", x.uid); },
|
||||
[&](Unanswered const&) { return ByteString("UNANSWERED"); },
|
||||
[&](Undeleted const&) { return ByteString("UNDELETED"); },
|
||||
[&](Undraft const&) { return ByteString("UNDRAFT"); },
|
||||
[&](Unkeyword const& x) { return ByteString::formatted("UNKEYWORD {}", serialize_astring(x.flag_keyword)); },
|
||||
[&](Unseen const&) { return ByteString("UNSEEN"); });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,8 +115,8 @@ public:
|
|||
m_status_items |= static_cast<unsigned>(type);
|
||||
}
|
||||
|
||||
void set_mailbox(DeprecatedString&& mailbox) { m_mailbox = move(mailbox); }
|
||||
DeprecatedString& mailbox() { return m_mailbox; }
|
||||
void set_mailbox(ByteString&& mailbox) { m_mailbox = move(mailbox); }
|
||||
ByteString& mailbox() { return m_mailbox; }
|
||||
|
||||
unsigned get(StatusItemType type) const
|
||||
{
|
||||
|
@ -165,60 +165,60 @@ private:
|
|||
unsigned m_uid_next { 0 };
|
||||
unsigned m_uid_validity { 0 };
|
||||
unsigned m_unseen { 0 };
|
||||
DeprecatedString m_mailbox;
|
||||
ByteString m_mailbox;
|
||||
};
|
||||
|
||||
struct Address {
|
||||
DeprecatedString name;
|
||||
DeprecatedString source_route;
|
||||
DeprecatedString mailbox;
|
||||
DeprecatedString host;
|
||||
ByteString name;
|
||||
ByteString source_route;
|
||||
ByteString mailbox;
|
||||
ByteString host;
|
||||
};
|
||||
|
||||
struct Envelope {
|
||||
DeprecatedString date; // Format of date not specified.
|
||||
DeprecatedString subject;
|
||||
ByteString date; // Format of date not specified.
|
||||
ByteString subject;
|
||||
Vector<Address> from;
|
||||
Vector<Address> sender;
|
||||
Vector<Address> reply_to;
|
||||
Vector<Address> to;
|
||||
Vector<Address> cc;
|
||||
Vector<Address> bcc;
|
||||
DeprecatedString in_reply_to;
|
||||
DeprecatedString message_id;
|
||||
ByteString in_reply_to;
|
||||
ByteString message_id;
|
||||
};
|
||||
|
||||
class BodyStructure;
|
||||
|
||||
struct BodyExtension {
|
||||
AK::Variant<Optional<DeprecatedString>, unsigned, Vector<OwnPtr<BodyExtension>>> data;
|
||||
AK::Variant<Optional<ByteString>, unsigned, Vector<OwnPtr<BodyExtension>>> data;
|
||||
};
|
||||
|
||||
struct MultiPartBodyStructureData {
|
||||
Optional<Tuple<DeprecatedString, HashMap<DeprecatedString, DeprecatedString>>> disposition;
|
||||
Optional<Tuple<ByteString, HashMap<ByteString, ByteString>>> disposition;
|
||||
Vector<OwnPtr<BodyStructure>> bodies;
|
||||
Vector<DeprecatedString> langs;
|
||||
DeprecatedString multipart_subtype;
|
||||
HashMap<DeprecatedString, DeprecatedString> params;
|
||||
DeprecatedString location;
|
||||
Vector<ByteString> langs;
|
||||
ByteString multipart_subtype;
|
||||
HashMap<ByteString, ByteString> params;
|
||||
ByteString location;
|
||||
Vector<BodyExtension> extensions;
|
||||
};
|
||||
|
||||
struct BodyStructureData {
|
||||
DeprecatedString type;
|
||||
DeprecatedString subtype;
|
||||
DeprecatedString id {};
|
||||
DeprecatedString desc {};
|
||||
DeprecatedString encoding;
|
||||
HashMap<DeprecatedString, DeprecatedString> fields;
|
||||
ByteString type;
|
||||
ByteString subtype;
|
||||
ByteString id {};
|
||||
ByteString desc {};
|
||||
ByteString encoding;
|
||||
HashMap<ByteString, ByteString> fields;
|
||||
unsigned bytes { 0 };
|
||||
unsigned lines { 0 };
|
||||
Optional<Tuple<Envelope, NonnullOwnPtr<BodyStructure>>> contanied_message;
|
||||
|
||||
DeprecatedString md5 {};
|
||||
Optional<Tuple<DeprecatedString, HashMap<DeprecatedString, DeprecatedString>>> disposition {};
|
||||
Optional<Vector<DeprecatedString>> langs {};
|
||||
DeprecatedString location {};
|
||||
ByteString md5 {};
|
||||
Optional<Tuple<ByteString, HashMap<ByteString, ByteString>>> disposition {};
|
||||
Optional<Vector<ByteString>> langs {};
|
||||
ByteString location {};
|
||||
|
||||
Vector<BodyExtension> extensions {};
|
||||
};
|
||||
|
@ -248,7 +248,7 @@ struct Sequence {
|
|||
int start;
|
||||
int end;
|
||||
|
||||
[[nodiscard]] DeprecatedString serialize() const;
|
||||
[[nodiscard]] ByteString serialize() const;
|
||||
};
|
||||
|
||||
struct FetchCommand {
|
||||
|
@ -276,9 +276,9 @@ struct FetchCommand {
|
|||
Optional<Vector<unsigned>> parts {};
|
||||
bool ends_with_mime {};
|
||||
|
||||
Optional<Vector<DeprecatedString>> headers {};
|
||||
Optional<Vector<ByteString>> headers {};
|
||||
|
||||
[[nodiscard]] DeprecatedString serialize() const;
|
||||
[[nodiscard]] ByteString serialize() const;
|
||||
};
|
||||
|
||||
DataItemType type;
|
||||
|
@ -288,19 +288,19 @@ struct FetchCommand {
|
|||
int start { 0 };
|
||||
int octets { 0 };
|
||||
|
||||
[[nodiscard]] DeprecatedString serialize() const;
|
||||
[[nodiscard]] ByteString serialize() const;
|
||||
};
|
||||
|
||||
Vector<Sequence> sequence_set;
|
||||
Vector<DataItem> data_items;
|
||||
|
||||
DeprecatedString serialize();
|
||||
ByteString serialize();
|
||||
};
|
||||
struct Command {
|
||||
public:
|
||||
CommandType type;
|
||||
int tag;
|
||||
Vector<DeprecatedString> args;
|
||||
Vector<ByteString> args;
|
||||
};
|
||||
|
||||
enum class ResponseStatus {
|
||||
|
@ -311,8 +311,8 @@ enum class ResponseStatus {
|
|||
|
||||
struct ListItem {
|
||||
unsigned flags;
|
||||
DeprecatedString reference;
|
||||
DeprecatedString name;
|
||||
ByteString reference;
|
||||
ByteString name;
|
||||
};
|
||||
|
||||
class FetchResponseData {
|
||||
|
@ -332,13 +332,13 @@ public:
|
|||
m_response_type |= static_cast<unsigned>(type);
|
||||
}
|
||||
|
||||
void add_body_data(FetchCommand::DataItem&& data_item, DeprecatedString&& body)
|
||||
void add_body_data(FetchCommand::DataItem&& data_item, ByteString&& body)
|
||||
{
|
||||
add_response_type(FetchResponseType::Body);
|
||||
m_bodies.append({ move(data_item), move(body) });
|
||||
}
|
||||
|
||||
Vector<Tuple<FetchCommand::DataItem, DeprecatedString>>& body_data()
|
||||
Vector<Tuple<FetchCommand::DataItem, ByteString>>& body_data()
|
||||
{
|
||||
VERIFY(contains_response_type(FetchResponseType::Body));
|
||||
return m_bodies;
|
||||
|
@ -380,13 +380,13 @@ public:
|
|||
return m_envelope;
|
||||
}
|
||||
|
||||
void set_flags(Vector<DeprecatedString>&& flags)
|
||||
void set_flags(Vector<ByteString>&& flags)
|
||||
{
|
||||
add_response_type(FetchResponseType::Flags);
|
||||
m_flags = move(flags);
|
||||
}
|
||||
|
||||
Vector<DeprecatedString>& flags()
|
||||
Vector<ByteString>& flags()
|
||||
{
|
||||
VERIFY(contains_response_type(FetchResponseType::Flags));
|
||||
return m_flags;
|
||||
|
@ -410,8 +410,8 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
Vector<DeprecatedString> m_flags;
|
||||
Vector<Tuple<FetchCommand::DataItem, DeprecatedString>> m_bodies;
|
||||
Vector<ByteString> m_flags;
|
||||
Vector<Tuple<FetchCommand::DataItem, ByteString>> m_bodies;
|
||||
Core::DateTime m_internal_date;
|
||||
Envelope m_envelope;
|
||||
unsigned m_uid { 0 };
|
||||
|
@ -419,20 +419,20 @@ private:
|
|||
BodyStructure m_body_structure;
|
||||
};
|
||||
|
||||
DeprecatedString serialize_astring(StringView string);
|
||||
ByteString serialize_astring(StringView string);
|
||||
|
||||
struct SearchKey {
|
||||
public:
|
||||
// clang-format off
|
||||
struct All { };
|
||||
struct Answered { };
|
||||
struct Bcc { DeprecatedString bcc; };
|
||||
struct Cc { DeprecatedString cc; };
|
||||
struct Bcc { ByteString bcc; };
|
||||
struct Cc { ByteString cc; };
|
||||
struct Deleted { };
|
||||
struct Draft { };
|
||||
struct From { DeprecatedString from; };
|
||||
struct Header { DeprecatedString header; DeprecatedString value; };
|
||||
struct Keyword { DeprecatedString keyword; };
|
||||
struct From { ByteString from; };
|
||||
struct Header { ByteString header; ByteString value; };
|
||||
struct Keyword { ByteString keyword; };
|
||||
struct Larger { unsigned number; };
|
||||
struct New { };
|
||||
struct Not { OwnPtr<SearchKey> operand; };
|
||||
|
@ -448,14 +448,14 @@ public:
|
|||
struct SequenceSet { Sequence sequence; };
|
||||
struct Since { Core::DateTime date; };
|
||||
struct Smaller { unsigned number; };
|
||||
struct Subject { DeprecatedString subject; };
|
||||
struct Text { DeprecatedString text; };
|
||||
struct To { DeprecatedString to; };
|
||||
struct Subject { ByteString subject; };
|
||||
struct Text { ByteString text; };
|
||||
struct To { ByteString to; };
|
||||
struct UID { unsigned uid; };
|
||||
struct Unanswered { };
|
||||
struct Undeleted { };
|
||||
struct Undraft { };
|
||||
struct Unkeyword { DeprecatedString flag_keyword; };
|
||||
struct Unkeyword { ByteString flag_keyword; };
|
||||
struct Unseen { };
|
||||
// clang-format on
|
||||
|
||||
|
@ -487,7 +487,7 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
[[nodiscard]] DeprecatedString serialize() const;
|
||||
[[nodiscard]] ByteString serialize() const;
|
||||
};
|
||||
|
||||
class ResponseData {
|
||||
|
@ -517,13 +517,13 @@ public:
|
|||
m_response_type = m_response_type | static_cast<unsigned>(response_type);
|
||||
}
|
||||
|
||||
void add_capabilities(Vector<DeprecatedString>&& capabilities)
|
||||
void add_capabilities(Vector<ByteString>&& capabilities)
|
||||
{
|
||||
m_capabilities = move(capabilities);
|
||||
add_response_type(ResponseType::Capability);
|
||||
}
|
||||
|
||||
Vector<DeprecatedString>& capabilities()
|
||||
Vector<ByteString>& capabilities()
|
||||
{
|
||||
VERIFY(contains_response_type(ResponseType::Capability));
|
||||
return m_capabilities;
|
||||
|
@ -613,25 +613,25 @@ public:
|
|||
return m_unseen;
|
||||
}
|
||||
|
||||
void set_flags(Vector<DeprecatedString>&& flags)
|
||||
void set_flags(Vector<ByteString>&& flags)
|
||||
{
|
||||
m_response_type |= static_cast<unsigned>(ResponseType::Flags);
|
||||
m_flags = move(flags);
|
||||
}
|
||||
|
||||
Vector<DeprecatedString>& flags()
|
||||
Vector<ByteString>& flags()
|
||||
{
|
||||
VERIFY(contains_response_type(ResponseType::Flags));
|
||||
return m_flags;
|
||||
}
|
||||
|
||||
void set_permanent_flags(Vector<DeprecatedString>&& flags)
|
||||
void set_permanent_flags(Vector<ByteString>&& flags)
|
||||
{
|
||||
add_response_type(ResponseType::PermanentFlags);
|
||||
m_permanent_flags = move(flags);
|
||||
}
|
||||
|
||||
Vector<DeprecatedString>& permanent_flags()
|
||||
Vector<ByteString>& permanent_flags()
|
||||
{
|
||||
VERIFY(contains_response_type(ResponseType::PermanentFlags));
|
||||
return m_permanent_flags;
|
||||
|
@ -673,13 +673,13 @@ public:
|
|||
return m_expunged;
|
||||
}
|
||||
|
||||
void set_bye(Optional<DeprecatedString> message)
|
||||
void set_bye(Optional<ByteString> message)
|
||||
{
|
||||
add_response_type(ResponseType::Bye);
|
||||
m_bye_message = move(message);
|
||||
}
|
||||
|
||||
Optional<DeprecatedString>& bye_message()
|
||||
Optional<ByteString>& bye_message()
|
||||
{
|
||||
VERIFY(contains_response_type(ResponseType::Bye));
|
||||
return m_bye_message;
|
||||
|
@ -699,7 +699,7 @@ public:
|
|||
private:
|
||||
unsigned m_response_type;
|
||||
|
||||
Vector<DeprecatedString> m_capabilities;
|
||||
Vector<ByteString> m_capabilities;
|
||||
Vector<ListItem> m_list_items;
|
||||
Vector<ListItem> m_lsub_items;
|
||||
Vector<unsigned> m_expunged;
|
||||
|
@ -710,11 +710,11 @@ private:
|
|||
unsigned m_uid_next {};
|
||||
unsigned m_uid_validity {};
|
||||
unsigned m_unseen {};
|
||||
Vector<DeprecatedString> m_permanent_flags;
|
||||
Vector<DeprecatedString> m_flags;
|
||||
Vector<ByteString> m_permanent_flags;
|
||||
Vector<ByteString> m_flags;
|
||||
Vector<Tuple<unsigned, FetchResponseData>> m_fetch_responses;
|
||||
Vector<unsigned> m_search_results;
|
||||
Optional<DeprecatedString> m_bye_message;
|
||||
Optional<ByteString> m_bye_message;
|
||||
StatusItem m_status_item;
|
||||
};
|
||||
|
||||
|
@ -735,7 +735,7 @@ public:
|
|||
|
||||
ResponseData& data() { return m_data; }
|
||||
|
||||
DeprecatedString response_text() { return m_response_text; }
|
||||
ByteString response_text() { return m_response_text; }
|
||||
|
||||
SolidResponse()
|
||||
: SolidResponse(ResponseStatus::Bad, -1)
|
||||
|
@ -751,14 +751,14 @@ public:
|
|||
|
||||
private:
|
||||
ResponseStatus m_status;
|
||||
DeprecatedString m_response_text;
|
||||
ByteString m_response_text;
|
||||
unsigned m_tag;
|
||||
|
||||
ResponseData m_data;
|
||||
};
|
||||
|
||||
struct ContinueRequest {
|
||||
DeprecatedString data;
|
||||
ByteString data;
|
||||
};
|
||||
|
||||
using Response = Variant<SolidResponse, ContinueRequest>;
|
||||
|
@ -767,5 +767,5 @@ using Response = Variant<SolidResponse, ContinueRequest>;
|
|||
// An RFC 2822 message
|
||||
// https://datatracker.ietf.org/doc/html/rfc2822
|
||||
struct Message {
|
||||
DeprecatedString data;
|
||||
ByteString data;
|
||||
};
|
||||
|
|
|
@ -94,7 +94,7 @@ ErrorOr<void> Parser::parse_response_done()
|
|||
}
|
||||
|
||||
TRY(consume("\r\n"sv));
|
||||
m_response.m_response_text = response_data.to_deprecated_string();
|
||||
m_response.m_response_text = response_data.to_byte_string();
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -174,7 +174,7 @@ ErrorOr<void> Parser::parse_untagged()
|
|||
m_response.data().add_lsub_item(move(item));
|
||||
} else if (consume_if("FLAGS"sv)) {
|
||||
TRY(consume(" "sv));
|
||||
auto flags = TRY(parse_list(+[](StringView x) { return DeprecatedString(x); }));
|
||||
auto flags = TRY(parse_list(+[](StringView x) { return ByteString(x); }));
|
||||
m_response.data().set_flags(move(flags));
|
||||
TRY(consume("\r\n"sv));
|
||||
} else if (consume_if("OK"sv)) {
|
||||
|
@ -197,7 +197,7 @@ ErrorOr<void> Parser::parse_untagged()
|
|||
m_response.data().set_unseen(n);
|
||||
} else if (actual_type == "PERMANENTFLAGS"sv) {
|
||||
TRY(consume(" "sv));
|
||||
auto flags = TRY(parse_list(+[](StringView x) { return DeprecatedString(x); }));
|
||||
auto flags = TRY(parse_list(+[](StringView x) { return ByteString(x); }));
|
||||
m_response.data().set_permanent_flags(move(flags));
|
||||
} else if (actual_type == "HIGHESTMODSEQ"sv) {
|
||||
TRY(consume(" "sv));
|
||||
|
@ -222,7 +222,7 @@ ErrorOr<void> Parser::parse_untagged()
|
|||
} else if (consume_if("BYE"sv)) {
|
||||
auto message = consume_until_end_of_line();
|
||||
TRY(consume("\r\n"sv));
|
||||
m_response.data().set_bye(message.is_empty() ? Optional<DeprecatedString>() : Optional<DeprecatedString>(message));
|
||||
m_response.data().set_bye(message.is_empty() ? Optional<ByteString>() : Optional<ByteString>(message));
|
||||
} else if (consume_if("STATUS"sv)) {
|
||||
TRY(consume(" "sv));
|
||||
auto mailbox = TRY(parse_astring());
|
||||
|
@ -314,7 +314,7 @@ ErrorOr<FetchResponseData> Parser::parse_fetch_response()
|
|||
}
|
||||
case FetchCommand::DataItemType::Flags: {
|
||||
TRY(consume(" "sv));
|
||||
auto flags = TRY(parse_list(+[](StringView x) { return DeprecatedString(x); }));
|
||||
auto flags = TRY(parse_list(+[](StringView x) { return ByteString(x); }));
|
||||
fetch_response.set_flags(move(flags));
|
||||
break;
|
||||
}
|
||||
|
@ -398,7 +398,7 @@ ErrorOr<BodyStructure> Parser::parse_body_structure()
|
|||
|
||||
if (!consume_if(")"sv)) {
|
||||
TRY(consume(" "sv));
|
||||
data.params = consume_if("NIL"sv) ? HashMap<DeprecatedString, DeprecatedString> {} : TRY(parse_body_fields_params());
|
||||
data.params = consume_if("NIL"sv) ? HashMap<ByteString, ByteString> {} : TRY(parse_body_fields_params());
|
||||
if (!consume_if(")"sv)) {
|
||||
TRY(consume(" "sv));
|
||||
if (!consume_if("NIL"sv)) {
|
||||
|
@ -413,7 +413,7 @@ ErrorOr<BodyStructure> Parser::parse_body_structure()
|
|||
|
||||
if (!consume_if(")"sv)) {
|
||||
TRY(consume(" "sv));
|
||||
data.location = consume_if("NIL"sv) ? DeprecatedString {} : DeprecatedString(TRY(parse_string()));
|
||||
data.location = consume_if("NIL"sv) ? ByteString {} : ByteString(TRY(parse_string()));
|
||||
|
||||
if (!consume_if(")"sv)) {
|
||||
TRY(consume(" "sv));
|
||||
|
@ -519,9 +519,9 @@ ErrorOr<BodyStructure> Parser::parse_one_part_body()
|
|||
return BodyStructure(move(data));
|
||||
}
|
||||
|
||||
ErrorOr<Vector<DeprecatedString>> Parser::parse_langs()
|
||||
ErrorOr<Vector<ByteString>> Parser::parse_langs()
|
||||
{
|
||||
AK::Vector<DeprecatedString> langs;
|
||||
AK::Vector<ByteString> langs;
|
||||
if (!consume_if("("sv)) {
|
||||
langs.append(TRY(parse_string()));
|
||||
} else {
|
||||
|
@ -533,14 +533,14 @@ ErrorOr<Vector<DeprecatedString>> Parser::parse_langs()
|
|||
return langs;
|
||||
}
|
||||
|
||||
ErrorOr<Tuple<DeprecatedString, HashMap<DeprecatedString, DeprecatedString>>> Parser::parse_disposition()
|
||||
ErrorOr<Tuple<ByteString, HashMap<ByteString, ByteString>>> Parser::parse_disposition()
|
||||
{
|
||||
TRY(consume("("sv));
|
||||
auto disposition_type = TRY(parse_string());
|
||||
TRY(consume(" "sv));
|
||||
auto disposition_vals = TRY(parse_body_fields_params());
|
||||
TRY(consume(")"sv));
|
||||
return Tuple<DeprecatedString, HashMap<DeprecatedString, DeprecatedString>> { move(disposition_type), move(disposition_vals) };
|
||||
return Tuple<ByteString, HashMap<ByteString, ByteString>> { move(disposition_type), move(disposition_vals) };
|
||||
}
|
||||
|
||||
ErrorOr<StringView> Parser::parse_literal_string()
|
||||
|
@ -574,12 +574,12 @@ ErrorOr<ListItem> Parser::parse_list_item()
|
|||
TRY(consume("\" "sv));
|
||||
auto mailbox = TRY(parse_astring());
|
||||
TRY(consume("\r\n"sv));
|
||||
return ListItem { flags, DeprecatedString(reference), DeprecatedString(mailbox) };
|
||||
return ListItem { flags, ByteString(reference), ByteString(mailbox) };
|
||||
}
|
||||
|
||||
ErrorOr<void> Parser::parse_capability_response()
|
||||
{
|
||||
auto capability = AK::Vector<DeprecatedString>();
|
||||
auto capability = AK::Vector<ByteString>();
|
||||
while (!consume_if("\r\n"sv)) {
|
||||
TRY(consume(" "sv));
|
||||
capability.append(TRY(parse_atom()));
|
||||
|
@ -709,7 +709,7 @@ ErrorOr<FetchCommand::DataItem> Parser::parse_fetch_data_item()
|
|||
auto section_type = consume_while([](u8 x) { return x != ']' && x != ' '; });
|
||||
if (section_type.equals_ignoring_ascii_case("HEADER.FIELDS"sv)) {
|
||||
data_item.section->type = FetchCommand::DataItem::SectionType::HeaderFields;
|
||||
data_item.section->headers = Vector<DeprecatedString>();
|
||||
data_item.section->headers = Vector<ByteString>();
|
||||
TRY(consume(" "sv));
|
||||
auto headers = TRY(parse_list(+[](StringView x) { return x; }));
|
||||
for (auto& header : headers) {
|
||||
|
@ -718,7 +718,7 @@ ErrorOr<FetchCommand::DataItem> Parser::parse_fetch_data_item()
|
|||
TRY(consume("]"sv));
|
||||
} else if (section_type.equals_ignoring_ascii_case("HEADER.FIELDS.NOT"sv)) {
|
||||
data_item.section->type = FetchCommand::DataItem::SectionType::HeaderFieldsNot;
|
||||
data_item.section->headers = Vector<DeprecatedString>();
|
||||
data_item.section->headers = Vector<ByteString>();
|
||||
TRY(consume(" ("sv));
|
||||
auto headers = TRY(parse_list(+[](StringView x) { return x; }));
|
||||
for (auto& header : headers) {
|
||||
|
@ -825,12 +825,12 @@ ErrorOr<StringView> Parser::parse_astring()
|
|||
return parse_atom();
|
||||
}
|
||||
|
||||
ErrorOr<HashMap<DeprecatedString, DeprecatedString>> Parser::parse_body_fields_params()
|
||||
ErrorOr<HashMap<ByteString, ByteString>> Parser::parse_body_fields_params()
|
||||
{
|
||||
if (consume_if("NIL"sv))
|
||||
return HashMap<DeprecatedString, DeprecatedString> {};
|
||||
return HashMap<ByteString, ByteString> {};
|
||||
|
||||
HashMap<DeprecatedString, DeprecatedString> fields;
|
||||
HashMap<ByteString, ByteString> fields;
|
||||
TRY(consume("("sv));
|
||||
while (!consume_if(")"sv)) {
|
||||
auto key = TRY(parse_string());
|
||||
|
@ -846,7 +846,7 @@ ErrorOr<HashMap<DeprecatedString, DeprecatedString>> Parser::parse_body_fields_p
|
|||
ErrorOr<BodyExtension> Parser::parse_body_extension()
|
||||
{
|
||||
if (consume_if("NIL"sv))
|
||||
return BodyExtension { Optional<DeprecatedString> {} };
|
||||
return BodyExtension { Optional<ByteString> {} };
|
||||
|
||||
if (consume_if("("sv)) {
|
||||
Vector<OwnPtr<BodyExtension>> extensions;
|
||||
|
|
|
@ -54,12 +54,12 @@ private:
|
|||
ErrorOr<FetchResponseData> parse_fetch_response();
|
||||
ErrorOr<Vector<Address>> parse_address_list();
|
||||
ErrorOr<Address> parse_address();
|
||||
ErrorOr<HashMap<DeprecatedString, DeprecatedString>> parse_body_fields_params();
|
||||
ErrorOr<HashMap<ByteString, ByteString>> parse_body_fields_params();
|
||||
ErrorOr<BodyStructure> parse_body_structure();
|
||||
ErrorOr<BodyStructure> parse_one_part_body();
|
||||
ErrorOr<BodyExtension> parse_body_extension();
|
||||
ErrorOr<Tuple<DeprecatedString, HashMap<DeprecatedString, DeprecatedString>>> parse_disposition();
|
||||
ErrorOr<Vector<DeprecatedString>> parse_langs();
|
||||
ErrorOr<Tuple<ByteString, HashMap<ByteString, ByteString>>> parse_disposition();
|
||||
ErrorOr<Vector<ByteString>> parse_langs();
|
||||
ErrorOr<Envelope> parse_envelope();
|
||||
|
||||
template<typename T>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue