diff options
author | x-yl <kylepereira@mail.com> | 2021-06-02 18:50:13 +0400 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2021-06-11 23:58:28 +0430 |
commit | 7021413d309953a5b399296c2de905cc55c165ed (patch) | |
tree | 52efef69a45d68364336faaca204b6ccd2390a1b /Userland/Libraries | |
parent | 076c708d0a970c121d193770fac05f8798d59225 (diff) | |
download | serenity-7021413d309953a5b399296c2de905cc55c165ed.zip |
LibIMAP: Support for COPY, CREATE, DELETE and RENAME
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibIMAP/Client.cpp | 35 | ||||
-rw-r--r-- | Userland/Libraries/LibIMAP/Client.h | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibIMAP/Objects.h | 5 |
3 files changed, 44 insertions, 0 deletions
diff --git a/Userland/Libraries/LibIMAP/Client.cpp b/Userland/Libraries/LibIMAP/Client.cpp index a0d79412b4..b5543d881a 100644 --- a/Userland/Libraries/LibIMAP/Client.cpp +++ b/Userland/Libraries/LibIMAP/Client.cpp @@ -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) { diff --git a/Userland/Libraries/LibIMAP/Client.h b/Userland/Libraries/LibIMAP/Client.h index f6329547d8..2e79d7eb13 100644 --- a/Userland/Libraries/LibIMAP/Client.h +++ b/Userland/Libraries/LibIMAP/Client.h @@ -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); diff --git a/Userland/Libraries/LibIMAP/Objects.h b/Userland/Libraries/LibIMAP/Objects.h index 76f2da186a..3ad9b51bed 100644 --- a/Userland/Libraries/LibIMAP/Objects.h +++ b/Userland/Libraries/LibIMAP/Objects.h @@ -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, |