diff options
-rw-r--r-- | Userland/Libraries/LibIMAP/Client.cpp | 15 | ||||
-rw-r--r-- | Userland/Libraries/LibIMAP/Client.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibIMAP/Objects.h | 1 |
3 files changed, 18 insertions, 0 deletions
diff --git a/Userland/Libraries/LibIMAP/Client.cpp b/Userland/Libraries/LibIMAP/Client.cpp index c3a2496aa7..f18c617f9a 100644 --- a/Userland/Libraries/LibIMAP/Client.cpp +++ b/Userland/Libraries/LibIMAP/Client.cpp @@ -116,6 +116,8 @@ static ReadonlyBytes command_byte_buffer(CommandType command) return "CAPABILITY"sv.bytes(); case CommandType::Logout: return "LOGOUT"sv.bytes(); + case CommandType ::Idle: + return "IDLE"sv.bytes(); case CommandType::Login: return "LOGIN"sv.bytes(); case CommandType::List: @@ -232,6 +234,19 @@ void Client::send_next_command() send_raw(buffer); m_expecting_response = true; } +RefPtr<Promise<Optional<ContinueRequest>>> Client::idle() +{ + auto promise = send_simple_command(CommandType::Idle); + return cast_promise<ContinueRequest>(promise); +} +RefPtr<Promise<Optional<SolidResponse>>> Client::finish_idle() +{ + auto promise = Promise<Optional<Response>>::construct(); + m_pending_promises.append(promise); + send_raw("DONE"); + m_expecting_response = true; + return cast_promise<SolidResponse>(promise); +} void Client::close() { diff --git a/Userland/Libraries/LibIMAP/Client.h b/Userland/Libraries/LibIMAP/Client.h index 2709cef594..8ff6fc8802 100644 --- a/Userland/Libraries/LibIMAP/Client.h +++ b/Userland/Libraries/LibIMAP/Client.h @@ -24,6 +24,8 @@ public: RefPtr<Promise<Optional<SolidResponse>>> login(StringView username, StringView password); RefPtr<Promise<Optional<SolidResponse>>> list(StringView reference_name, StringView mailbox_name); RefPtr<Promise<Optional<SolidResponse>>> select(StringView string); + RefPtr<Promise<Optional<ContinueRequest>>> idle(); + RefPtr<Promise<Optional<SolidResponse>>> finish_idle(); void close(); diff --git a/Userland/Libraries/LibIMAP/Objects.h b/Userland/Libraries/LibIMAP/Objects.h index be79e6f624..6f102ce8ce 100644 --- a/Userland/Libraries/LibIMAP/Objects.h +++ b/Userland/Libraries/LibIMAP/Objects.h @@ -18,6 +18,7 @@ namespace IMAP { enum class CommandType { Capability, + Idle, List, Login, Logout, |