mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-07 19:57:45 +03:00
LibIMAP: Stop leaking a Core::Promise<bool> in IMAP::Client::connect()
This commit is contained in:
parent
f4c4b42db9
commit
51ae913bfe
Notes:
sideshowbarker
2024-07-18 04:55:39 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/51ae913bfe3
@ -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();
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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());
|
||||
|
Loading…
Reference in New Issue
Block a user