summaryrefslogtreecommitdiff
path: root/Userland/Applications
diff options
context:
space:
mode:
authorsin-ack <sin-ack@users.noreply.github.com>2021-12-18 12:38:44 +0000
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2022-01-13 15:16:12 +0330
commitaedb013ee365f9abe92c78fae9e6455139cb7d28 (patch)
tree1e8af41c951b018fdf4f8443e0c25c683fc06998 /Userland/Applications
parent53e9d757fed26a42477611cba20c8ede64ae53b8 (diff)
downloadserenity-aedb013ee365f9abe92c78fae9e6455139cb7d28.zip
LibIMAP+Userland: Convert LibIMAP::Client to the Serenity Stream APIs
You now cannot get an unconnected LibIMAP::Client, but you can still close it. This makes for a nicer API where we don't have a Client object in a limbo state between being constructed and being connected. This code still isn't as nice as it should be, as TLS::TLSv12 is still not a Core::Stream::Socket subclass, which would allow for consolidating most of the TLS/non-TLS code into a single implementation.
Diffstat (limited to 'Userland/Applications')
-rw-r--r--Userland/Applications/Mail/MailWidget.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/Userland/Applications/Mail/MailWidget.cpp b/Userland/Applications/Mail/MailWidget.cpp
index 996246d652..15c01513f7 100644
--- a/Userland/Applications/Mail/MailWidget.cpp
+++ b/Userland/Applications/Mail/MailWidget.cpp
@@ -126,12 +126,15 @@ bool MailWidget::connect_and_login()
return false;
}
- m_imap_client = make<IMAP::Client>(server, port, tls);
- auto connection_promise = m_imap_client->connect();
- if (!connection_promise) {
- GUI::MessageBox::show_error(window(), String::formatted("Failed to connect to '{}:{}' over {}.", server, port, tls ? "TLS" : "Plaintext"));
+ auto maybe_imap_client = tls ? IMAP::Client::connect_tls(server, port) : IMAP::Client::connect_plaintext(server, port);
+ if (maybe_imap_client.is_error()) {
+ GUI::MessageBox::show_error(window(), String::formatted("Failed to connect to '{}:{}' over {}: {}", server, port, tls ? "TLS" : "Plaintext", maybe_imap_client.error()));
return false;
}
+ m_imap_client = maybe_imap_client.release_value();
+
+ auto connection_promise = m_imap_client->connection_promise();
+ VERIFY(!connection_promise.is_null());
connection_promise->await();
auto response = m_imap_client->login(username, password)->await().release_value();