1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 05:37:44 +00:00

AK+Everywhere: Rename String to DeprecatedString

We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
This commit is contained in:
Linus Groh 2022-12-04 18:02:33 +00:00 committed by Andreas Kling
parent f74251606d
commit 6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions

View file

@ -185,16 +185,16 @@ RefPtr<Promise<Optional<SolidResponse>>> Client::login(StringView username, Stri
RefPtr<Promise<Optional<SolidResponse>>> Client::list(StringView reference_name, StringView mailbox)
{
auto command = Command { CommandType::List, m_current_command,
{ String::formatted("\"{}\"", reference_name),
String::formatted("\"{}\"", mailbox) } };
{ DeprecatedString::formatted("\"{}\"", reference_name),
DeprecatedString::formatted("\"{}\"", mailbox) } };
return cast_promise<SolidResponse>(send_command(move(command)));
}
RefPtr<Promise<Optional<SolidResponse>>> Client::lsub(StringView reference_name, StringView mailbox)
{
auto command = Command { CommandType::ListSub, m_current_command,
{ String::formatted("\"{}\"", reference_name),
String::formatted("\"{}\"", mailbox) } };
{ DeprecatedString::formatted("\"{}\"", reference_name),
DeprecatedString::formatted("\"{}\"", mailbox) } };
return cast_promise<SolidResponse>(send_command(move(command)));
}
@ -250,7 +250,7 @@ ErrorOr<void> Client::send_next_command()
{
auto command = m_command_queue.take_first();
ByteBuffer buffer;
auto tag = AK::String::formatted("A{} ", m_current_command);
auto tag = AK::DeprecatedString::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());
@ -283,7 +283,7 @@ RefPtr<Promise<Optional<SolidResponse>>> Client::delete_mailbox(StringView name)
return cast_promise<SolidResponse>(send_command(move(command)));
}
RefPtr<Promise<Optional<SolidResponse>>> Client::store(StoreMethod method, Sequence sequence_set, bool silent, Vector<String> const& flags, bool uid)
RefPtr<Promise<Optional<SolidResponse>>> Client::store(StoreMethod method, Sequence sequence_set, bool silent, Vector<DeprecatedString> const& flags, bool uid)
{
StringBuilder data_item_name;
switch (method) {
@ -309,9 +309,9 @@ RefPtr<Promise<Optional<SolidResponse>>> Client::store(StoreMethod method, Seque
auto command = Command { uid ? CommandType::UIDStore : CommandType::Store, m_current_command, { sequence_set.serialize(), data_item_name.build(), flags_builder.build() } };
return cast_promise<SolidResponse>(send_command(move(command)));
}
RefPtr<Promise<Optional<SolidResponse>>> Client::search(Optional<String> charset, Vector<SearchKey>&& keys, bool uid)
RefPtr<Promise<Optional<SolidResponse>>> Client::search(Optional<DeprecatedString> charset, Vector<SearchKey>&& keys, bool uid)
{
Vector<String> args;
Vector<DeprecatedString> args;
if (charset.has_value()) {
args.append("CHARSET "sv);
args.append(charset.value());
@ -339,7 +339,7 @@ RefPtr<Promise<Optional<SolidResponse>>> Client::finish_idle()
RefPtr<Promise<Optional<SolidResponse>>> Client::status(StringView mailbox, Vector<StatusItemType> const& types)
{
Vector<String> args;
Vector<DeprecatedString> args;
for (auto type : types) {
switch (type) {
case StatusItemType::Recent:
@ -367,9 +367,9 @@ RefPtr<Promise<Optional<SolidResponse>>> Client::status(StringView mailbox, Vect
return cast_promise<SolidResponse>(send_command(move(command)));
}
RefPtr<Promise<Optional<SolidResponse>>> Client::append(StringView mailbox, Message&& message, Optional<Vector<String>> flags, Optional<Core::DateTime> date_time)
RefPtr<Promise<Optional<SolidResponse>>> Client::append(StringView mailbox, Message&& message, Optional<Vector<DeprecatedString>> flags, Optional<Core::DateTime> date_time)
{
Vector<String> args = { mailbox };
Vector<DeprecatedString> args = { mailbox };
if (flags.has_value()) {
StringBuilder flags_sb;
flags_sb.append('(');
@ -380,7 +380,7 @@ RefPtr<Promise<Optional<SolidResponse>>> Client::append(StringView mailbox, Mess
if (date_time.has_value())
args.append(date_time.value().to_string("\"%d-%b-%Y %H:%M:%S +0000\""sv));
args.append(String::formatted("{{{}}}", message.data.length()));
args.append(DeprecatedString::formatted("{{{}}}", message.data.length()));
auto continue_req = send_command(Command { CommandType::Append, m_current_command, args });

View file

@ -39,9 +39,9 @@ public:
RefPtr<Promise<Optional<SolidResponse>>> lsub(StringView reference_name, StringView mailbox_name);
RefPtr<Promise<Optional<SolidResponse>>> select(StringView string);
RefPtr<Promise<Optional<SolidResponse>>> examine(StringView string);
RefPtr<Promise<Optional<SolidResponse>>> search(Optional<String> charset, Vector<SearchKey>&& search_keys, bool uid);
RefPtr<Promise<Optional<SolidResponse>>> search(Optional<DeprecatedString> charset, Vector<SearchKey>&& search_keys, bool uid);
RefPtr<Promise<Optional<SolidResponse>>> fetch(FetchCommand request, bool uid);
RefPtr<Promise<Optional<SolidResponse>>> store(StoreMethod, Sequence, bool silent, Vector<String> const& flags, bool uid);
RefPtr<Promise<Optional<SolidResponse>>> store(StoreMethod, Sequence, bool silent, Vector<DeprecatedString> const& flags, bool uid);
RefPtr<Promise<Optional<SolidResponse>>> copy(Sequence sequence_set, StringView name, bool uid);
RefPtr<Promise<Optional<SolidResponse>>> create_mailbox(StringView name);
RefPtr<Promise<Optional<SolidResponse>>> delete_mailbox(StringView name);
@ -52,7 +52,7 @@ public:
RefPtr<Promise<Optional<ContinueRequest>>> idle();
RefPtr<Promise<Optional<SolidResponse>>> finish_idle();
RefPtr<Promise<Optional<SolidResponse>>> status(StringView mailbox, Vector<StatusItemType> const& types);
RefPtr<Promise<Optional<SolidResponse>>> append(StringView mailbox, Message&& message, Optional<Vector<String>> flags = {}, Optional<Core::DateTime> date_time = {});
RefPtr<Promise<Optional<SolidResponse>>> append(StringView mailbox, Message&& message, Optional<Vector<DeprecatedString>> flags = {}, Optional<Core::DateTime> date_time = {});
bool is_open();
void close();

View file

@ -9,18 +9,18 @@
namespace IMAP {
String Sequence::serialize() const
DeprecatedString Sequence::serialize() const
{
if (start == end) {
return AK::String::formatted("{}", start);
return AK::DeprecatedString::formatted("{}", start);
} else {
auto start_char = start != -1 ? String::formatted("{}", start) : "*";
auto end_char = end != -1 ? String::formatted("{}", end) : "*";
return String::formatted("{}:{}", start_char, end_char);
auto start_char = start != -1 ? DeprecatedString::formatted("{}", start) : "*";
auto end_char = end != -1 ? DeprecatedString::formatted("{}", end) : "*";
return DeprecatedString::formatted("{}:{}", start_char, end_char);
}
}
String FetchCommand::DataItem::Section::serialize() const
DeprecatedString FetchCommand::DataItem::Section::serialize() const
{
StringBuilder headers_builder;
switch (type) {
@ -62,7 +62,7 @@ String FetchCommand::DataItem::Section::serialize() const
}
VERIFY_NOT_REACHED();
}
String FetchCommand::DataItem::serialize() const
DeprecatedString FetchCommand::DataItem::serialize() const
{
switch (type) {
case DataItemType::Envelope:
@ -89,7 +89,7 @@ String FetchCommand::DataItem::serialize() const
}
VERIFY_NOT_REACHED();
}
String FetchCommand::serialize()
DeprecatedString FetchCommand::serialize()
{
StringBuilder sequence_builder;
bool first = true;
@ -111,9 +111,9 @@ String FetchCommand::serialize()
first = false;
}
return AK::String::formatted("{} ({})", sequence_builder.build(), data_items_builder.build());
return AK::DeprecatedString::formatted("{} ({})", sequence_builder.build(), data_items_builder.build());
}
String serialize_astring(StringView string)
DeprecatedString serialize_astring(StringView string)
{
// Try to send an atom
auto is_non_atom_char = [](char x) {
@ -129,31 +129,31 @@ String 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 String::formatted("\"{}\"", escaped_str);
return DeprecatedString::formatted("\"{}\"", escaped_str);
}
// Just send a literal
return String::formatted("{{{}}}\r\n{}", string.length(), string);
return DeprecatedString::formatted("{{{}}}\r\n{}", string.length(), string);
}
String SearchKey::serialize() const
DeprecatedString SearchKey::serialize() const
{
return data.visit(
[&](All const&) { return String("ALL"); },
[&](Answered const&) { return String("ANSWERED"); },
[&](Bcc const& x) { return String::formatted("BCC {}", serialize_astring(x.bcc)); },
[&](Cc const& x) { return String::formatted("CC {}", serialize_astring(x.cc)); },
[&](Deleted const&) { return String("DELETED"); },
[&](Draft const&) { return String("DRAFT"); },
[&](From const& x) { return String::formatted("FROM {}", serialize_astring(x.from)); },
[&](Header const& x) { return String::formatted("HEADER {} {}", serialize_astring(x.header), serialize_astring(x.value)); },
[&](Keyword const& x) { return String::formatted("KEYWORD {}", x.keyword); },
[&](Larger const& x) { return String::formatted("LARGER {}", x.number); },
[&](New const&) { return String("NEW"); },
[&](Not const& x) { return String::formatted("NOT {}", x.operand->serialize()); },
[&](Old const&) { return String("OLD"); },
[&](On const& x) { return String::formatted("ON {}", x.date.to_string("%d-%b-%Y"sv)); },
[&](Or const& x) { return String::formatted("OR {} {}", x.lhs->serialize(), x.rhs->serialize()); },
[&](Recent const&) { return String("RECENT"); },
[&](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_string("%d-%b-%Y"sv)); },
[&](Or const& x) { return DeprecatedString::formatted("OR {} {}", x.lhs->serialize(), x.rhs->serialize()); },
[&](Recent const&) { return DeprecatedString("RECENT"); },
[&](SearchKeys const& x) {
StringBuilder sb;
sb.append('(');
@ -166,21 +166,21 @@ String SearchKey::serialize() const
}
return sb.build();
},
[&](Seen const&) { return String("SEEN"); },
[&](SentBefore const& x) { return String::formatted("SENTBEFORE {}", x.date.to_string("%d-%b-%Y"sv)); },
[&](SentOn const& x) { return String::formatted("SENTON {}", x.date.to_string("%d-%b-%Y"sv)); },
[&](SentSince const& x) { return String::formatted("SENTSINCE {}", x.date.to_string("%d-%b-%Y"sv)); },
[&](Seen const&) { return DeprecatedString("SEEN"); },
[&](SentBefore const& x) { return DeprecatedString::formatted("SENTBEFORE {}", x.date.to_string("%d-%b-%Y"sv)); },
[&](SentOn const& x) { return DeprecatedString::formatted("SENTON {}", x.date.to_string("%d-%b-%Y"sv)); },
[&](SentSince const& x) { return DeprecatedString::formatted("SENTSINCE {}", x.date.to_string("%d-%b-%Y"sv)); },
[&](SequenceSet const& x) { return x.sequence.serialize(); },
[&](Since const& x) { return String::formatted("SINCE {}", x.date.to_string("%d-%b-%Y"sv)); },
[&](Smaller const& x) { return String::formatted("SMALLER {}", x.number); },
[&](Subject const& x) { return String::formatted("SUBJECT {}", serialize_astring(x.subject)); },
[&](Text const& x) { return String::formatted("TEXT {}", serialize_astring(x.text)); },
[&](To const& x) { return String::formatted("TO {}", serialize_astring(x.to)); },
[&](UID const& x) { return String::formatted("UID {}", x.uid); },
[&](Unanswered const&) { return String("UNANSWERED"); },
[&](Undeleted const&) { return String("UNDELETED"); },
[&](Undraft const&) { return String("UNDRAFT"); },
[&](Unkeyword const& x) { return String::formatted("UNKEYWORD {}", serialize_astring(x.flag_keyword)); },
[&](Unseen const&) { return String("UNSEEN"); });
[&](Since const& x) { return DeprecatedString::formatted("SINCE {}", x.date.to_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"); });
}
}

View file

@ -116,8 +116,8 @@ public:
m_status_items |= static_cast<unsigned>(type);
}
void set_mailbox(String&& mailbox) { m_mailbox = move(mailbox); }
String& mailbox() { return m_mailbox; }
void set_mailbox(DeprecatedString&& mailbox) { m_mailbox = move(mailbox); }
DeprecatedString& mailbox() { return m_mailbox; }
unsigned get(StatusItemType type) const
{
@ -166,60 +166,60 @@ private:
unsigned m_uid_next { 0 };
unsigned m_uid_validity { 0 };
unsigned m_unseen { 0 };
String m_mailbox;
DeprecatedString m_mailbox;
};
struct Address {
Optional<String> name;
Optional<String> source_route;
Optional<String> mailbox;
Optional<String> host;
Optional<DeprecatedString> name;
Optional<DeprecatedString> source_route;
Optional<DeprecatedString> mailbox;
Optional<DeprecatedString> host;
};
struct Envelope {
Optional<String> date; // Format of date not specified.
Optional<String> subject;
Optional<DeprecatedString> date; // Format of date not specified.
Optional<DeprecatedString> subject;
Optional<Vector<Address>> from;
Optional<Vector<Address>> sender;
Optional<Vector<Address>> reply_to;
Optional<Vector<Address>> to;
Optional<Vector<Address>> cc;
Optional<Vector<Address>> bcc;
Optional<String> in_reply_to;
Optional<String> message_id;
Optional<DeprecatedString> in_reply_to;
Optional<DeprecatedString> message_id;
};
class BodyStructure;
struct BodyExtension {
AK::Variant<Optional<String>, unsigned, Vector<OwnPtr<BodyExtension>>> data;
AK::Variant<Optional<DeprecatedString>, unsigned, Vector<OwnPtr<BodyExtension>>> data;
};
struct MultiPartBodyStructureData {
Optional<Tuple<String, HashMap<String, String>>> disposition;
Optional<Tuple<DeprecatedString, HashMap<DeprecatedString, DeprecatedString>>> disposition;
Vector<OwnPtr<BodyStructure>> bodies;
Vector<String> langs;
String media_type;
Optional<HashMap<String, String>> params;
Optional<String> location;
Vector<DeprecatedString> langs;
DeprecatedString media_type;
Optional<HashMap<DeprecatedString, DeprecatedString>> params;
Optional<DeprecatedString> location;
Optional<Vector<BodyExtension>> extensions;
};
struct BodyStructureData {
String type;
String subtype;
Optional<String> id {};
Optional<String> desc {};
String encoding;
HashMap<String, String> fields;
DeprecatedString type;
DeprecatedString subtype;
Optional<DeprecatedString> id {};
Optional<DeprecatedString> desc {};
DeprecatedString encoding;
HashMap<DeprecatedString, DeprecatedString> fields;
unsigned bytes { 0 };
unsigned lines { 0 };
Optional<Envelope> envelope;
Optional<String> md5 {};
Optional<Tuple<String, HashMap<String, String>>> disposition {};
Optional<Vector<String>> langs {};
Optional<String> location {};
Optional<DeprecatedString> md5 {};
Optional<Tuple<DeprecatedString, HashMap<DeprecatedString, DeprecatedString>>> disposition {};
Optional<Vector<DeprecatedString>> langs {};
Optional<DeprecatedString> location {};
Optional<Vector<BodyExtension>> extensions {};
};
@ -249,7 +249,7 @@ struct Sequence {
int start;
int end;
[[nodiscard]] String serialize() const;
[[nodiscard]] DeprecatedString serialize() const;
};
struct FetchCommand {
@ -277,9 +277,9 @@ struct FetchCommand {
Optional<Vector<unsigned>> parts {};
bool ends_with_mime {};
Optional<Vector<String>> headers {};
Optional<Vector<DeprecatedString>> headers {};
[[nodiscard]] String serialize() const;
[[nodiscard]] DeprecatedString serialize() const;
};
DataItemType type;
@ -289,19 +289,19 @@ struct FetchCommand {
int start { 0 };
int octets { 0 };
[[nodiscard]] String serialize() const;
[[nodiscard]] DeprecatedString serialize() const;
};
Vector<Sequence> sequence_set;
Vector<DataItem> data_items;
String serialize();
DeprecatedString serialize();
};
struct Command {
public:
CommandType type;
int tag;
Vector<String> args;
Vector<DeprecatedString> args;
};
enum class ResponseStatus {
@ -312,8 +312,8 @@ enum class ResponseStatus {
struct ListItem {
unsigned flags;
String reference;
String name;
DeprecatedString reference;
DeprecatedString name;
};
class FetchResponseData {
@ -333,13 +333,13 @@ public:
m_response_type |= static_cast<unsigned>(type);
}
void add_body_data(FetchCommand::DataItem&& data_item, Optional<String>&& body)
void add_body_data(FetchCommand::DataItem&& data_item, Optional<DeprecatedString>&& body)
{
add_response_type(FetchResponseType::Body);
m_bodies.append({ move(data_item), move(body) });
}
Vector<Tuple<FetchCommand::DataItem, Optional<String>>>& body_data()
Vector<Tuple<FetchCommand::DataItem, Optional<DeprecatedString>>>& body_data()
{
VERIFY(contains_response_type(FetchResponseType::Body));
return m_bodies;
@ -381,13 +381,13 @@ public:
return m_envelope;
}
void set_flags(Vector<String>&& flags)
void set_flags(Vector<DeprecatedString>&& flags)
{
add_response_type(FetchResponseType::Flags);
m_flags = move(flags);
}
Vector<String>& flags()
Vector<DeprecatedString>& flags()
{
VERIFY(contains_response_type(FetchResponseType::Flags));
return m_flags;
@ -411,8 +411,8 @@ public:
}
private:
Vector<String> m_flags;
Vector<Tuple<FetchCommand::DataItem, Optional<String>>> m_bodies;
Vector<DeprecatedString> m_flags;
Vector<Tuple<FetchCommand::DataItem, Optional<DeprecatedString>>> m_bodies;
Core::DateTime m_internal_date;
Envelope m_envelope;
unsigned m_uid { 0 };
@ -420,20 +420,20 @@ private:
BodyStructure m_body_structure;
};
String serialize_astring(StringView string);
DeprecatedString serialize_astring(StringView string);
struct SearchKey {
public:
// clang-format off
struct All { };
struct Answered { };
struct Bcc { String bcc; };
struct Cc { String cc; };
struct Bcc { DeprecatedString bcc; };
struct Cc { DeprecatedString cc; };
struct Deleted { };
struct Draft { };
struct From { String from; };
struct Header { String header; String value; };
struct Keyword { String keyword; };
struct From { DeprecatedString from; };
struct Header { DeprecatedString header; DeprecatedString value; };
struct Keyword { DeprecatedString keyword; };
struct Larger { unsigned number; };
struct New { };
struct Not { OwnPtr<SearchKey> operand; };
@ -449,14 +449,14 @@ public:
struct SequenceSet { Sequence sequence; };
struct Since { Core::DateTime date; };
struct Smaller { unsigned number; };
struct Subject { String subject; };
struct Text { String text; };
struct To { String to; };
struct Subject { DeprecatedString subject; };
struct Text { DeprecatedString text; };
struct To { DeprecatedString to; };
struct UID { unsigned uid; };
struct Unanswered { };
struct Undeleted { };
struct Undraft { };
struct Unkeyword { String flag_keyword; };
struct Unkeyword { DeprecatedString flag_keyword; };
struct Unseen { };
// clang-format on
@ -488,7 +488,7 @@ public:
return *this;
}
[[nodiscard]] String serialize() const;
[[nodiscard]] DeprecatedString serialize() const;
};
class ResponseData {
@ -518,13 +518,13 @@ public:
m_response_type = m_response_type | static_cast<unsigned>(response_type);
}
void add_capabilities(Vector<String>&& capabilities)
void add_capabilities(Vector<DeprecatedString>&& capabilities)
{
m_capabilities = move(capabilities);
add_response_type(ResponseType::Capability);
}
Vector<String>& capabilities()
Vector<DeprecatedString>& capabilities()
{
VERIFY(contains_response_type(ResponseType::Capability));
return m_capabilities;
@ -614,25 +614,25 @@ public:
return m_unseen;
}
void set_flags(Vector<String>&& flags)
void set_flags(Vector<DeprecatedString>&& flags)
{
m_response_type |= static_cast<unsigned>(ResponseType::Flags);
m_flags = move(flags);
}
Vector<String>& flags()
Vector<DeprecatedString>& flags()
{
VERIFY(contains_response_type(ResponseType::Flags));
return m_flags;
}
void set_permanent_flags(Vector<String>&& flags)
void set_permanent_flags(Vector<DeprecatedString>&& flags)
{
add_response_type(ResponseType::PermanentFlags);
m_permanent_flags = move(flags);
}
Vector<String>& permanent_flags()
Vector<DeprecatedString>& permanent_flags()
{
VERIFY(contains_response_type(ResponseType::PermanentFlags));
return m_permanent_flags;
@ -674,13 +674,13 @@ public:
return m_expunged;
}
void set_bye(Optional<String> message)
void set_bye(Optional<DeprecatedString> message)
{
add_response_type(ResponseType::Bye);
m_bye_message = move(message);
}
Optional<String>& bye_message()
Optional<DeprecatedString>& bye_message()
{
VERIFY(contains_response_type(ResponseType::Bye));
return m_bye_message;
@ -700,7 +700,7 @@ public:
private:
unsigned m_response_type;
Vector<String> m_capabilities;
Vector<DeprecatedString> m_capabilities;
Vector<ListItem> m_list_items;
Vector<ListItem> m_lsub_items;
Vector<unsigned> m_expunged;
@ -711,11 +711,11 @@ private:
unsigned m_uid_next {};
unsigned m_uid_validity {};
unsigned m_unseen {};
Vector<String> m_permanent_flags;
Vector<String> m_flags;
Vector<DeprecatedString> m_permanent_flags;
Vector<DeprecatedString> m_flags;
Vector<Tuple<unsigned, FetchResponseData>> m_fetch_responses;
Vector<unsigned> m_search_results;
Optional<String> m_bye_message;
Optional<DeprecatedString> m_bye_message;
StatusItem m_status_item;
};
@ -736,7 +736,7 @@ public:
ResponseData& data() { return m_data; }
String response_text() { return m_response_text; };
DeprecatedString response_text() { return m_response_text; };
SolidResponse()
: SolidResponse(ResponseStatus::Bad, -1)
@ -752,14 +752,14 @@ public:
private:
ResponseStatus m_status;
String m_response_text;
DeprecatedString m_response_text;
unsigned m_tag;
ResponseData m_data;
};
struct ContinueRequest {
String data;
DeprecatedString data;
};
using Response = Variant<SolidResponse, ContinueRequest>;
@ -768,5 +768,5 @@ using Response = Variant<SolidResponse, ContinueRequest>;
// An RFC 2822 message
// https://datatracker.ietf.org/doc/html/rfc2822
struct Message {
String data;
DeprecatedString data;
};

View file

@ -157,7 +157,7 @@ void Parser::parse_untagged()
m_response.data().add_lsub_item(move(item));
} else if (try_consume("FLAGS"sv)) {
consume(" "sv);
auto flags = parse_list(+[](StringView x) { return String(x); });
auto flags = parse_list(+[](StringView x) { return DeprecatedString(x); });
m_response.data().set_flags(move(flags));
consume("\r\n"sv);
} else if (try_consume("OK"sv)) {
@ -180,7 +180,7 @@ void Parser::parse_untagged()
m_response.data().set_unseen(n);
} else if (actual_type == "PERMANENTFLAGS"sv) {
consume(" "sv);
auto flags = parse_list(+[](StringView x) { return String(x); });
auto flags = parse_list(+[](StringView x) { return DeprecatedString(x); });
m_response.data().set_permanent_flags(move(flags));
} else if (actual_type == "HIGHESTMODSEQ"sv) {
consume(" "sv);
@ -205,7 +205,7 @@ void Parser::parse_untagged()
} else if (try_consume("BYE"sv)) {
auto message = consume_until_end_of_line();
consume("\r\n"sv);
m_response.data().set_bye(message.is_empty() ? Optional<String>() : Optional<String>(message));
m_response.data().set_bye(message.is_empty() ? Optional<DeprecatedString>() : Optional<DeprecatedString>(message));
} else if (try_consume("STATUS"sv)) {
consume(" "sv);
auto mailbox = parse_astring();
@ -292,7 +292,7 @@ FetchResponseData Parser::parse_fetch_response()
}
case FetchCommand::DataItemType::Flags: {
consume(" "sv);
auto flags = parse_list(+[](StringView x) { return String(x); });
auto flags = parse_list(+[](StringView x) { return DeprecatedString(x); });
fetch_response.set_flags(move(flags));
break;
}
@ -315,7 +315,7 @@ FetchResponseData Parser::parse_fetch_response()
break;
case FetchCommand::DataItemType::BodySection: {
auto body = parse_nstring();
fetch_response.add_body_data(move(data_item), Optional<String>(move(body)));
fetch_response.add_body_data(move(data_item), Optional<DeprecatedString>(move(body)));
break;
}
}
@ -349,16 +349,16 @@ Envelope Parser::parse_envelope()
auto message_id = parse_nstring();
consume(")"sv);
Envelope envelope = {
date.has_value() ? AK::Optional<String>(date.value()) : AK::Optional<String>(),
subject.has_value() ? AK::Optional<String>(subject.value()) : AK::Optional<String>(),
date.has_value() ? AK::Optional<DeprecatedString>(date.value()) : AK::Optional<DeprecatedString>(),
subject.has_value() ? AK::Optional<DeprecatedString>(subject.value()) : AK::Optional<DeprecatedString>(),
from,
sender,
reply_to,
to,
cc,
bcc,
in_reply_to.has_value() ? AK::Optional<String>(in_reply_to.value()) : AK::Optional<String>(),
message_id.has_value() ? AK::Optional<String>(message_id.value()) : AK::Optional<String>(),
in_reply_to.has_value() ? AK::Optional<DeprecatedString>(in_reply_to.value()) : AK::Optional<DeprecatedString>(),
message_id.has_value() ? AK::Optional<DeprecatedString>(message_id.value()) : AK::Optional<DeprecatedString>(),
};
return envelope;
}
@ -375,7 +375,7 @@ BodyStructure Parser::parse_body_structure()
if (!try_consume(")"sv)) {
consume(" "sv);
data.params = try_consume("NIL"sv) ? Optional<HashMap<String, String>>() : parse_body_fields_params();
data.params = try_consume("NIL"sv) ? Optional<HashMap<DeprecatedString, DeprecatedString>>() : parse_body_fields_params();
if (!try_consume(")"sv)) {
consume(" "sv);
if (!try_consume("NIL"sv)) {
@ -390,7 +390,7 @@ BodyStructure Parser::parse_body_structure()
if (!try_consume(")"sv)) {
consume(" "sv);
data.location = try_consume("NIL"sv) ? Optional<String>() : Optional<String>(parse_string());
data.location = try_consume("NIL"sv) ? Optional<DeprecatedString>() : Optional<DeprecatedString>(parse_string());
if (!try_consume(")"sv)) {
consume(" "sv);
@ -434,8 +434,8 @@ BodyStructure Parser::parse_one_part_body()
auto data = BodyStructureData {
type,
subtype,
Optional<String>(move(id)),
Optional<String>(move(description)),
Optional<DeprecatedString>(move(id)),
Optional<DeprecatedString>(move(description)),
encoding,
params,
num_octets,
@ -496,8 +496,8 @@ BodyStructure Parser::parse_one_part_body()
BodyStructureData data {
type,
subtype,
Optional<String>(move(id)),
Optional<String>(move(description)),
Optional<DeprecatedString>(move(id)),
Optional<DeprecatedString>(move(description)),
encoding,
params,
num_octets,
@ -522,8 +522,8 @@ BodyStructure Parser::parse_one_part_body()
BodyStructureData data {
type,
subtype,
Optional<String>(move(id)),
Optional<String>(move(description)),
Optional<DeprecatedString>(move(id)),
Optional<DeprecatedString>(move(description)),
encoding,
params,
num_octets,
@ -534,9 +534,9 @@ BodyStructure Parser::parse_one_part_body()
return BodyStructure(move(data));
}
}
Vector<String> Parser::parse_langs()
Vector<DeprecatedString> Parser::parse_langs()
{
AK::Vector<String> langs;
AK::Vector<DeprecatedString> langs;
if (!try_consume("("sv)) {
langs.append(parse_string());
} else {
@ -547,7 +547,7 @@ Vector<String> Parser::parse_langs()
}
return langs;
}
Tuple<String, HashMap<String, String>> Parser::parse_disposition()
Tuple<DeprecatedString, HashMap<DeprecatedString, DeprecatedString>> Parser::parse_disposition()
{
auto disposition_type = parse_string();
consume(" "sv);
@ -584,15 +584,15 @@ ListItem Parser::parse_list_item()
consume("\" "sv);
auto mailbox = parse_astring();
consume("\r\n"sv);
return ListItem { flags, String(reference), String(mailbox) };
return ListItem { flags, DeprecatedString(reference), DeprecatedString(mailbox) };
}
void Parser::parse_capability_response()
{
auto capability = AK::Vector<String>();
auto capability = AK::Vector<DeprecatedString>();
while (!try_consume("\r\n"sv)) {
consume(" "sv);
auto x = String(parse_atom());
auto x = DeprecatedString(parse_atom());
capability.append(x);
}
m_response.data().add_capabilities(move(capability));
@ -709,7 +709,7 @@ FetchCommand::DataItem Parser::parse_fetch_data_item()
auto section_type = consume_while([](u8 x) { return x != ']' && x != ' '; });
if (section_type.equals_ignoring_case("HEADER.FIELDS"sv)) {
data_item.section->type = FetchCommand::DataItem::SectionType::HeaderFields;
data_item.section->headers = Vector<String>();
data_item.section->headers = Vector<DeprecatedString>();
consume(" "sv);
auto headers = parse_list(+[](StringView x) { return x; });
for (auto& header : headers) {
@ -718,7 +718,7 @@ FetchCommand::DataItem Parser::parse_fetch_data_item()
consume("]"sv);
} else if (section_type.equals_ignoring_case("HEADER.FIELDS.NOT"sv)) {
data_item.section->type = FetchCommand::DataItem::SectionType::HeaderFieldsNot;
data_item.section->headers = Vector<String>();
data_item.section->headers = Vector<DeprecatedString>();
consume(" ("sv);
auto headers = parse_list(+[](StringView x) { return x; });
for (auto& header : headers) {
@ -803,16 +803,16 @@ Address Parser::parse_address()
consume("("sv);
auto address = Address();
auto name = parse_nstring();
address.name = Optional<String>(move(name));
address.name = Optional<DeprecatedString>(move(name));
consume(" "sv);
auto source_route = parse_nstring();
address.source_route = Optional<String>(move(source_route));
address.source_route = Optional<DeprecatedString>(move(source_route));
consume(" "sv);
auto mailbox = parse_nstring();
address.mailbox = Optional<String>(move(mailbox));
address.mailbox = Optional<DeprecatedString>(move(mailbox));
consume(" "sv);
auto host = parse_nstring();
address.host = Optional<String>(move(host));
address.host = Optional<DeprecatedString>(move(host));
consume(")"sv);
return address;
}
@ -823,12 +823,12 @@ StringView Parser::parse_astring()
else
return parse_atom();
}
HashMap<String, String> Parser::parse_body_fields_params()
HashMap<DeprecatedString, DeprecatedString> Parser::parse_body_fields_params()
{
if (try_consume("NIL"sv))
return {};
HashMap<String, String> fields;
HashMap<DeprecatedString, DeprecatedString> fields;
consume("("sv);
while (!try_consume(")"sv)) {
auto key = parse_string();
@ -843,7 +843,7 @@ HashMap<String, String> Parser::parse_body_fields_params()
BodyExtension Parser::parse_body_extension()
{
if (try_consume("NIL"sv)) {
return BodyExtension { Optional<String> {} };
return BodyExtension { Optional<DeprecatedString> {} };
} else if (try_consume("("sv)) {
Vector<OwnPtr<BodyExtension>> extensions;
while (!try_consume(")"sv)) {

View file

@ -52,12 +52,12 @@ private:
FetchResponseData parse_fetch_response();
Optional<Vector<Address>> parse_address_list();
Address parse_address();
HashMap<String, String> parse_body_fields_params();
HashMap<DeprecatedString, DeprecatedString> parse_body_fields_params();
BodyStructure parse_body_structure();
BodyStructure parse_one_part_body();
BodyExtension parse_body_extension();
Tuple<String, HashMap<String, String>> parse_disposition();
Vector<String> parse_langs();
Tuple<DeprecatedString, HashMap<DeprecatedString, DeprecatedString>> parse_disposition();
Vector<DeprecatedString> parse_langs();
Envelope parse_envelope();
template<typename T>