LibIMAP: Support for the IDLE command

This commit is contained in:
x-yl 2021-06-02 17:17:22 +04:00 committed by Ali Mohammad Pur
parent f00c2c0192
commit 1e9dfdcdcc
3 changed files with 18 additions and 0 deletions

View file

@ -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()
{

View file

@ -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();

View file

@ -18,6 +18,7 @@
namespace IMAP {
enum class CommandType {
Capability,
Idle,
List,
Login,
Logout,