mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:27:45 +00:00
Mail: Fetch mails with their sequence number
The FETCH response doesn't have return the sequence in order, or at very least one of my mail providers doesn't do it.
This commit is contained in:
parent
720c27efbd
commit
0132c30eda
3 changed files with 11 additions and 3 deletions
|
@ -57,5 +57,7 @@ GUI::Variant InboxModel::data(GUI::ModelIndex const& index, GUI::ModelRole role)
|
||||||
if (!value.seen)
|
if (!value.seen)
|
||||||
return Gfx::FontDatabase::default_font().bold_variant();
|
return Gfx::FontDatabase::default_font().bold_variant();
|
||||||
}
|
}
|
||||||
|
if (role == static_cast<GUI::ModelRole>(InboxModelCustomRole::Sequence))
|
||||||
|
return value.sequence_number;
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,12 +11,18 @@
|
||||||
#include <LibIMAP/Objects.h>
|
#include <LibIMAP/Objects.h>
|
||||||
|
|
||||||
struct InboxEntry {
|
struct InboxEntry {
|
||||||
|
u32 sequence_number;
|
||||||
DeprecatedString from;
|
DeprecatedString from;
|
||||||
DeprecatedString subject;
|
DeprecatedString subject;
|
||||||
DeprecatedString date;
|
DeprecatedString date;
|
||||||
bool seen;
|
bool seen;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class InboxModelCustomRole {
|
||||||
|
__DONOTUSE = (int)GUI::ModelRole::Custom,
|
||||||
|
Sequence,
|
||||||
|
};
|
||||||
|
|
||||||
class InboxModel final : public GUI::Model {
|
class InboxModel final : public GUI::Model {
|
||||||
public:
|
public:
|
||||||
enum Column {
|
enum Column {
|
||||||
|
|
|
@ -309,6 +309,7 @@ void MailWidget::selected_mailbox()
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (auto& fetch_data : fetch_response.data().fetch_data()) {
|
for (auto& fetch_data : fetch_response.data().fetch_data()) {
|
||||||
|
auto sequence_number = fetch_data.get<unsigned>();
|
||||||
auto& response_data = fetch_data.get<IMAP::FetchResponseData>();
|
auto& response_data = fetch_data.get<IMAP::FetchResponseData>();
|
||||||
auto& body_data = response_data.body_data();
|
auto& body_data = response_data.body_data();
|
||||||
|
|
||||||
|
@ -420,7 +421,7 @@ void MailWidget::selected_mailbox()
|
||||||
if (from.is_empty())
|
if (from.is_empty())
|
||||||
from = "(Unknown sender)";
|
from = "(Unknown sender)";
|
||||||
|
|
||||||
InboxEntry inbox_entry { from, subject, date, seen };
|
InboxEntry inbox_entry { sequence_number, from, subject, date, seen };
|
||||||
m_statusbar->set_text(String::formatted("[{}]: Loading entry {}", mailbox.name, ++i).release_value_but_fixme_should_propagate_errors());
|
m_statusbar->set_text(String::formatted("[{}]: Loading entry {}", mailbox.name, ++i).release_value_but_fixme_should_propagate_errors());
|
||||||
|
|
||||||
active_inbox_entries.append(inbox_entry);
|
active_inbox_entries.append(inbox_entry);
|
||||||
|
@ -438,8 +439,7 @@ void MailWidget::selected_email_to_load()
|
||||||
if (!index.is_valid())
|
if (!index.is_valid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// IMAP is 1-based.
|
int id_of_email_to_load = index.data(static_cast<GUI::ModelRole>(InboxModelCustomRole::Sequence)).as_u32();
|
||||||
int id_of_email_to_load = index.row() + 1;
|
|
||||||
|
|
||||||
m_statusbar->set_text("Fetching message..."_string);
|
m_statusbar->set_text("Fetching message..."_string);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue