mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 21:07:34 +00:00
LibIMAP: Support for COPY, CREATE, DELETE and RENAME
This commit is contained in:
parent
076c708d0a
commit
7021413d30
3 changed files with 44 additions and 0 deletions
|
@ -128,14 +128,24 @@ static ReadonlyBytes command_byte_buffer(CommandType command)
|
|||
return "FETCH"sv.bytes();
|
||||
case CommandType::Store:
|
||||
return "STORE"sv.bytes();
|
||||
case CommandType::Copy:
|
||||
return "COPY"sv.bytes();
|
||||
case CommandType::Create:
|
||||
return "CREATE"sv.bytes();
|
||||
case CommandType::Delete:
|
||||
return "DELETE"sv.bytes();
|
||||
case CommandType::Search:
|
||||
return "SEARCH"sv.bytes();
|
||||
case CommandType::UIDFetch:
|
||||
return "UID FETCH"sv.bytes();
|
||||
case CommandType::UIDStore:
|
||||
return "UID STORE"sv.bytes();
|
||||
case CommandType::UIDCopy:
|
||||
return "UID COPY"sv.bytes();
|
||||
case CommandType::UIDSearch:
|
||||
return "UID SEARCH"sv.bytes();
|
||||
case CommandType::Rename:
|
||||
return "RENAME"sv.bytes();
|
||||
case CommandType::Status:
|
||||
return "STATUS"sv.bytes();
|
||||
}
|
||||
|
@ -254,6 +264,18 @@ void Client::send_next_command()
|
|||
send_raw(buffer);
|
||||
m_expecting_response = true;
|
||||
}
|
||||
RefPtr<Promise<Optional<SolidResponse>>> Client::create_mailbox(StringView name)
|
||||
{
|
||||
auto command = Command { CommandType::Create, m_current_command, { name } };
|
||||
return cast_promise<SolidResponse>(send_command(move(command)));
|
||||
}
|
||||
|
||||
RefPtr<Promise<Optional<SolidResponse>>> Client::delete_mailbox(StringView name)
|
||||
{
|
||||
auto command = Command { CommandType::Delete, m_current_command, { 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)
|
||||
{
|
||||
StringBuilder data_item_name;
|
||||
|
@ -338,6 +360,19 @@ RefPtr<Promise<Optional<SolidResponse>>> Client::status(StringView mailbox, Vect
|
|||
return cast_promise<SolidResponse>(send_command(move(command)));
|
||||
}
|
||||
|
||||
RefPtr<Promise<Optional<SolidResponse>>> Client::rename(StringView from, StringView to)
|
||||
{
|
||||
auto command = Command { CommandType::Rename, m_current_command, { from, to } };
|
||||
return cast_promise<SolidResponse>(send_command(move(command)));
|
||||
}
|
||||
RefPtr<Promise<Optional<SolidResponse>>> Client::copy(Sequence sequence_set, StringView name, bool uid)
|
||||
{
|
||||
auto command = Command {
|
||||
uid ? CommandType::UIDCopy : CommandType::Copy, m_current_command, { sequence_set.serialize(), name }
|
||||
};
|
||||
|
||||
return cast_promise<SolidResponse>(send_command(move(command)));
|
||||
}
|
||||
void Client::close()
|
||||
{
|
||||
if (m_tls) {
|
||||
|
|
|
@ -27,6 +27,10 @@ public:
|
|||
RefPtr<Promise<Optional<SolidResponse>>> search(Optional<String> 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>>> copy(Sequence sequence_set, StringView name, bool uid);
|
||||
RefPtr<Promise<Optional<SolidResponse>>> create_mailbox(StringView name);
|
||||
RefPtr<Promise<Optional<SolidResponse>>> delete_mailbox(StringView name);
|
||||
RefPtr<Promise<Optional<SolidResponse>>> rename(StringView from, StringView to);
|
||||
RefPtr<Promise<Optional<ContinueRequest>>> idle();
|
||||
RefPtr<Promise<Optional<SolidResponse>>> finish_idle();
|
||||
RefPtr<Promise<Optional<SolidResponse>>> status(StringView mailbox, Vector<StatusItemType> const& types);
|
||||
|
|
|
@ -18,16 +18,21 @@
|
|||
namespace IMAP {
|
||||
enum class CommandType {
|
||||
Capability,
|
||||
Copy,
|
||||
Create,
|
||||
Delete,
|
||||
Fetch,
|
||||
Idle,
|
||||
List,
|
||||
Login,
|
||||
Logout,
|
||||
Noop,
|
||||
Rename,
|
||||
Search,
|
||||
Select,
|
||||
Status,
|
||||
Store,
|
||||
UIDCopy,
|
||||
UIDFetch,
|
||||
UIDSearch,
|
||||
UIDStore,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue