LibIMAP: Stop leaking a Core::Promise<bool> in IMAP::Client::connect()

This commit is contained in:
Andreas Kling 2021-09-01 22:56:31 +02:00
parent f4c4b42db9
commit 51ae913bfe
Notes: sideshowbarker 2024-07-18 04:55:39 +09:00
4 changed files with 6 additions and 6 deletions

View File

@ -125,11 +125,11 @@ bool MailWidget::connect_and_login()
m_imap_client = make<IMAP::Client>(server, port, tls);
auto connection_promise = m_imap_client->connect();
if (!connection_promise.has_value()) {
if (!connection_promise) {
GUI::MessageBox::show_error(window(), String::formatted("Failed to connect to '{}:{}' over {}.", server, port, tls ? "TLS" : "Plaintext"));
return false;
}
connection_promise.value()->await();
connection_promise->await();
auto response = m_imap_client->login(username, password)->await().release_value();

View File

@ -21,7 +21,7 @@ Client::Client(StringView host, unsigned int port, bool start_with_tls)
}
}
Optional<RefPtr<Promise<Empty>>> Client::connect()
RefPtr<Promise<Empty>> Client::connect()
{
bool success;
if (m_tls) {
@ -31,7 +31,7 @@ Optional<RefPtr<Promise<Empty>>> Client::connect()
}
if (!success)
return {};
m_connect_pending = new Promise<bool> {};
m_connect_pending = Promise<bool>::construct();
return m_connect_pending;
}

View File

@ -21,7 +21,7 @@ class Client {
public:
Client(StringView host, unsigned port, bool start_with_tls);
Optional<RefPtr<Promise<Empty>>> connect();
RefPtr<Promise<Empty>> connect();
RefPtr<Promise<Optional<Response>>> send_command(Command&&);
RefPtr<Promise<Optional<Response>>> send_simple_command(CommandType);
void send_raw(StringView data);

View File

@ -48,7 +48,7 @@ int main(int argc, char** argv)
Core::EventLoop loop;
auto client = IMAP::Client(host, port, tls);
client.connect().value()->await();
client.connect()->await();
auto response = client.login(username, password)->await().release_value();
outln("[LOGIN] Login response: {}", response.response_text());