melib: add metadata field to MailBackendCapabilities

Add field for arbitrary metadata as a serde_json::Value.

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
pull/425/head
Manos Pitsidianakis 2 months ago
parent d40ee6928f
commit af6838c20c
No known key found for this signature in database
GPG Key ID: 7729C7707F7E09D0

@ -170,6 +170,23 @@ impl AccountStatus {
None,
);
line += 1;
self.content.grid_mut().write_string(
&format!(
"Metadata: {}",
a.backend_capabilities
.metadata
.as_ref()
.map(|v| v.to_string())
.unwrap_or_default()
),
self.theme_default.fg,
self.theme_default.bg,
self.theme_default.attrs,
area,
None,
None,
);
line += 1;
let area = self.content.area().skip(1, line);
let (_x, _y) = self.content.grid_mut().write_string(
"Search backend: ",
@ -272,6 +289,8 @@ impl AccountStatus {
);
line += 1;
for (name, status) in extensions.iter() {
use MailBackendExtensionStatus as Ext;
let area = self.content.area().skip(1, line);
self.content.grid_mut().write_string(
name.trim_at_boundary(30),
@ -285,15 +304,9 @@ impl AccountStatus {
let (x, y) = {
let (status, color) = match status {
MailBackendExtensionStatus::Unsupported { comment: _ } => {
("not supported", Color::Red)
}
MailBackendExtensionStatus::Supported { comment: _ } => {
("supported", Color::Green)
}
MailBackendExtensionStatus::Enabled { comment: _ } => {
("enabled", Color::Green)
}
Ext::Unsupported { comment: _ } => ("not supported", Color::Red),
Ext::Supported { comment: _ } => ("supported", Color::Green),
Ext::Enabled { comment: _ } => ("enabled", Color::Green),
};
let area = self.content.area().skip(max_name_width + 6, line);
self.content.grid_mut().write_string(
@ -306,57 +319,55 @@ impl AccountStatus {
None,
)
};
match status {
MailBackendExtensionStatus::Unsupported { comment }
| MailBackendExtensionStatus::Supported { comment }
| MailBackendExtensionStatus::Enabled { comment } => {
if let Some(s) = comment {
let area = self
.content
.area()
.skip(max_name_width + 6, line)
.skip(x, y);
let (_x, _y) = self.content.grid_mut().write_string(
" (",
self.theme_default.fg,
self.theme_default.bg,
self.theme_default.attrs,
area,
None,
None,
);
let area = self
.content
.area()
.skip(max_name_width + 6, line)
.skip(x, y)
.skip(_x, _y);
let (__x, __y) = self.content.grid_mut().write_string(
s,
self.theme_default.fg,
self.theme_default.bg,
self.theme_default.attrs,
area,
None,
None,
);
let area = self
.content
.area()
.skip(max_name_width + 6, line)
.skip(x + _x + __x, y + _y + __y);
self.content.grid_mut().write_string(
")",
self.theme_default.fg,
self.theme_default.bg,
self.theme_default.attrs,
area,
None,
None,
);
}
}
};
if let Ext::Unsupported { comment: Some(s) }
| Ext::Supported { comment: Some(s) }
| Ext::Enabled { comment: Some(s) } = status
{
let area = self
.content
.area()
.skip(max_name_width + 6, line)
.skip(x, y);
let (_x, _y) = self.content.grid_mut().write_string(
" (",
self.theme_default.fg,
self.theme_default.bg,
self.theme_default.attrs,
area,
None,
None,
);
let area = self
.content
.area()
.skip(max_name_width + 6, line)
.skip(x, y)
.skip(_x, _y);
let (__x, __y) = self.content.grid_mut().write_string(
s,
self.theme_default.fg,
self.theme_default.bg,
self.theme_default.attrs,
area,
None,
None,
);
let area = self
.content
.area()
.skip(max_name_width + 6, line)
.skip(x + _x + __x, y + _y + __y);
self.content.grid_mut().write_string(
")",
self.theme_default.fg,
self.theme_default.bg,
self.theme_default.attrs,
area,
None,
None,
);
}
line += 1;
}
}

@ -378,6 +378,7 @@ pub struct MailBackendCapabilities {
pub supports_tags: bool,
pub supports_submission: bool,
pub extra_submission_headers: &'static [HeaderName],
pub metadata: Option<serde_json::Value>,
}
#[derive(Clone, Copy, Debug)]

@ -346,6 +346,7 @@ impl MailBackend for ImapType {
supports_tags: true,
supports_submission: false,
extra_submission_headers: &[],
metadata: None,
}
}

@ -381,6 +381,7 @@ impl MailBackend for JmapType {
supports_tags: true,
supports_submission: true,
extra_submission_headers: &[],
metadata: None,
};
let supports_submission: bool = self
.store

@ -180,6 +180,7 @@ impl MailBackend for MaildirType {
supports_tags: false,
supports_submission: false,
extra_submission_headers: &[],
metadata: None,
};
CAPABILITIES
}

@ -834,6 +834,7 @@ impl MailBackend for MboxType {
supports_tags: false,
supports_submission: false,
extra_submission_headers: &[],
metadata: None,
};
CAPABILITIES
}

@ -212,6 +212,7 @@ impl MailBackend for NntpType {
supports_tags: false,
supports_submission,
extra_submission_headers: &[HeaderName::NEWSGROUPS],
metadata: None,
}
}

@ -566,6 +566,7 @@ impl MailBackend for NotmuchDb {
supports_tags: true,
supports_submission: false,
extra_submission_headers: &[],
metadata: None,
};
CAPABILITIES
}

Loading…
Cancel
Save