1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:17:44 +00:00

LibCore+Userland: Allow canceling promises

To make EventLoop cancel its managed Promises, we need the ability to
cancel them in the first place.
This commit is contained in:
kleines Filmröllchen 2022-12-29 14:53:05 +01:00 committed by Linus Groh
parent afd0f941b7
commit bfd9f681f7
6 changed files with 48 additions and 35 deletions

View file

@ -132,9 +132,9 @@ bool MailWidget::connect_and_login()
auto connection_promise = m_imap_client->connection_promise();
VERIFY(!connection_promise.is_null());
connection_promise->await();
MUST(connection_promise->await());
auto response = m_imap_client->login(username, password)->await().release_value();
auto response = MUST(m_imap_client->login(username, password)->await()).release_value();
if (response.status() != IMAP::ResponseStatus::OK) {
dbgln("Failed to login. The server says: '{}'", response.response_text());
@ -142,7 +142,7 @@ bool MailWidget::connect_and_login()
return false;
}
response = m_imap_client->list(""sv, "*"sv)->await().release_value();
response = MUST(m_imap_client->list(""sv, "*"sv)->await()).release_value();
if (response.status() != IMAP::ResponseStatus::OK) {
dbgln("Failed to retrieve mailboxes. The server says: '{}'", response.response_text());
@ -163,7 +163,7 @@ bool MailWidget::connect_and_login()
void MailWidget::on_window_close()
{
auto response = move(m_imap_client->send_simple_command(IMAP::CommandType::Logout)->await().release_value().get<IMAP::SolidResponse>());
auto response = move(MUST(m_imap_client->send_simple_command(IMAP::CommandType::Logout)->await()).release_value().get<IMAP::SolidResponse>());
VERIFY(response.status() == IMAP::ResponseStatus::OK);
m_imap_client->close();
@ -253,7 +253,7 @@ void MailWidget::selected_mailbox()
if (mailbox.flags & (unsigned)IMAP::MailboxFlag::NoSelect)
return;
auto response = m_imap_client->select(mailbox.name)->await().release_value();
auto response = MUST(m_imap_client->select(mailbox.name)->await()).release_value();
if (response.status() != IMAP::ResponseStatus::OK) {
dbgln("Failed to select mailbox. The server says: '{}'", response.response_text());
@ -280,7 +280,7 @@ void MailWidget::selected_mailbox()
},
};
auto fetch_response = m_imap_client->fetch(fetch_command, false)->await().release_value();
auto fetch_response = MUST(m_imap_client->fetch(fetch_command, false)->await()).release_value();
if (response.status() != IMAP::ResponseStatus::OK) {
dbgln("Failed to retrieve subject/from for e-mails. The server says: '{}'", response.response_text());
@ -396,7 +396,7 @@ void MailWidget::selected_email_to_load()
},
};
auto fetch_response = m_imap_client->fetch(fetch_command, false)->await().release_value();
auto fetch_response = MUST(m_imap_client->fetch(fetch_command, false)->await()).release_value();
if (fetch_response.status() != IMAP::ResponseStatus::OK) {
dbgln("Failed to retrieve the body structure of the selected e-mail. The server says: '{}'", fetch_response.response_text());
@ -457,7 +457,7 @@ void MailWidget::selected_email_to_load()
},
};
fetch_response = m_imap_client->fetch(fetch_command, false)->await().release_value();
fetch_response = MUST(m_imap_client->fetch(fetch_command, false)->await()).release_value();
if (fetch_response.status() != IMAP::ResponseStatus::OK) {
dbgln("Failed to retrieve the body of the selected e-mail. The server says: '{}'", fetch_response.response_text());