1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 19:58:11 +00:00

LibIMAP: Support for remaining IMAP commands

These include APPEND, AUTHENTICATE, CHECK, CLOSE, EXAMINE, EXPUNGE,
LSUB, SUBSCRIBE, UNSUBSCRIBE
This commit is contained in:
x-yl 2021-06-02 18:53:08 +04:00 committed by Ali Mohammad Pur
parent 16995dc3d9
commit 9174fabf05
4 changed files with 93 additions and 0 deletions

View file

@ -146,6 +146,22 @@ static ReadonlyBytes command_byte_buffer(CommandType command)
return "UID SEARCH"sv.bytes();
case CommandType::Append:
return "APPEND"sv.bytes();
case CommandType::Examine:
return "EXAMINE"sv.bytes();
case CommandType::ListSub:
return "LSUB"sv.bytes();
case CommandType::Expunge:
return "EXPUNGE"sv.bytes();
case CommandType::Subscribe:
return "SUBSCRIBE"sv.bytes();
case CommandType::Unsubscribe:
return "UNSUBSCRIBE"sv.bytes();
case CommandType::Authenticate:
return "AUTHENTICATE"sv.bytes();
case CommandType::Check:
return "CHECK"sv.bytes();
case CommandType::Close:
return "CLOSE"sv.bytes();
case CommandType::Rename:
return "RENAME"sv.bytes();
case CommandType::Status:
@ -203,6 +219,14 @@ RefPtr<Promise<Optional<SolidResponse>>> Client::list(StringView reference_name,
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) } };
return cast_promise<SolidResponse>(send_command(move(command)));
}
RefPtr<Promise<Optional<SolidResponse>>> Client::fetch(FetchCommand request, bool uid)
{
auto command = Command { uid ? CommandType::UIDFetch : CommandType::Fetch, m_current_command, { request.serialize() } };
@ -266,6 +290,13 @@ void Client::send_next_command()
send_raw(buffer);
m_expecting_response = true;
}
RefPtr<Promise<Optional<SolidResponse>>> Client::examine(StringView string)
{
auto command = Command { CommandType::Examine, m_current_command, { string } };
return cast_promise<SolidResponse>(send_command(move(command)));
}
RefPtr<Promise<Optional<SolidResponse>>> Client::create_mailbox(StringView name)
{
auto command = Command { CommandType::Create, m_current_command, { name } };
@ -393,6 +424,21 @@ RefPtr<Promise<Optional<SolidResponse>>> Client::append(StringView mailbox, Mess
return cast_promise<SolidResponse>(response_promise);
}
RefPtr<Promise<Optional<SolidResponse>>> Client::subscribe(StringView mailbox)
{
auto command = Command { CommandType::Subscribe, m_current_command, { mailbox } };
return cast_promise<SolidResponse>(send_command(move(command)));
}
RefPtr<Promise<Optional<SolidResponse>>> Client::unsubscribe(StringView mailbox)
{
auto command = Command { CommandType::Unsubscribe, m_current_command, { mailbox } };
return cast_promise<SolidResponse>(send_command(move(command)));
}
RefPtr<Promise<Optional<Response>>> Client::authenticate(StringView method)
{
auto command = Command { CommandType::Authenticate, m_current_command, { method } };
return send_command(move(command));
}
RefPtr<Promise<Optional<SolidResponse>>> Client::rename(StringView from, StringView to)
{
auto command = Command { CommandType::Rename, m_current_command, { from, to } };