conf.rs: handle a per account mail order parameter
The new order parameter adds the possibility to specify a sort order on a per account basis. Signed-off-by: Guillaume Ranquet <granquet@baylibre.com>tables
parent
97ff3e787f
commit
9205f3b8af
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
//! Basic mail account configuration to use with [`backends`](./backends/index.html)
|
//! Basic mail account configuration to use with [`backends`](./backends/index.html)
|
||||||
use crate::backends::SpecialUsageMailbox;
|
use crate::backends::SpecialUsageMailbox;
|
||||||
|
pub use crate::{SortField, SortOrder};
|
||||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
@ -33,6 +34,8 @@ pub struct AccountSettings {
|
||||||
pub extra_identities: Vec<String>,
|
pub extra_identities: Vec<String>,
|
||||||
pub read_only: bool,
|
pub read_only: bool,
|
||||||
pub display_name: Option<String>,
|
pub display_name: Option<String>,
|
||||||
|
#[serde(default)]
|
||||||
|
pub order: (SortField, SortOrder),
|
||||||
pub subscribed_mailboxes: Vec<String>,
|
pub subscribed_mailboxes: Vec<String>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub mailboxes: HashMap<String, MailboxConf>,
|
pub mailboxes: HashMap<String, MailboxConf>,
|
||||||
|
@ -64,6 +67,9 @@ impl AccountSettings {
|
||||||
pub fn display_name(&self) -> Option<&String> {
|
pub fn display_name(&self) -> Option<&String> {
|
||||||
self.display_name.as_ref()
|
self.display_name.as_ref()
|
||||||
}
|
}
|
||||||
|
pub fn order(&self) -> Option<(SortField, SortOrder)> {
|
||||||
|
Some(self.order)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn subscribed_mailboxes(&self) -> &Vec<String> {
|
pub fn subscribed_mailboxes(&self) -> &Vec<String> {
|
||||||
&self.subscribed_mailboxes
|
&self.subscribed_mailboxes
|
||||||
|
|
|
@ -50,6 +50,7 @@ pub use self::composing::*;
|
||||||
pub use self::pgp::*;
|
pub use self::pgp::*;
|
||||||
pub use self::shortcuts::*;
|
pub use self::shortcuts::*;
|
||||||
pub use self::tags::*;
|
pub use self::tags::*;
|
||||||
|
pub use melib::thread::{SortField, SortOrder};
|
||||||
|
|
||||||
use self::default_vals::*;
|
use self::default_vals::*;
|
||||||
use self::listing::ListingSettings;
|
use self::listing::ListingSettings;
|
||||||
|
@ -170,6 +171,8 @@ pub struct FileAccount {
|
||||||
mailboxes: IndexMap<String, FileMailboxConf>,
|
mailboxes: IndexMap<String, FileMailboxConf>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
search_backend: SearchBackend,
|
search_backend: SearchBackend,
|
||||||
|
#[serde(default)]
|
||||||
|
order: (SortField, SortOrder),
|
||||||
#[serde(default = "false_val")]
|
#[serde(default = "false_val")]
|
||||||
pub manual_refresh: bool,
|
pub manual_refresh: bool,
|
||||||
#[serde(default = "none")]
|
#[serde(default = "none")]
|
||||||
|
@ -247,6 +250,7 @@ impl From<FileAccount> for AccountConf {
|
||||||
let root_mailbox = x.root_mailbox.clone();
|
let root_mailbox = x.root_mailbox.clone();
|
||||||
let identity = x.identity.clone();
|
let identity = x.identity.clone();
|
||||||
let display_name = x.display_name.clone();
|
let display_name = x.display_name.clone();
|
||||||
|
let order = x.order.clone();
|
||||||
let mailboxes = x
|
let mailboxes = x
|
||||||
.mailboxes
|
.mailboxes
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -261,6 +265,7 @@ impl From<FileAccount> for AccountConf {
|
||||||
extra_identities: x.extra_identities.clone(),
|
extra_identities: x.extra_identities.clone(),
|
||||||
read_only: x.read_only,
|
read_only: x.read_only,
|
||||||
display_name,
|
display_name,
|
||||||
|
order,
|
||||||
subscribed_mailboxes: x.subscribed_mailboxes.clone(),
|
subscribed_mailboxes: x.subscribed_mailboxes.clone(),
|
||||||
mailboxes,
|
mailboxes,
|
||||||
manual_refresh: x.manual_refresh,
|
manual_refresh: x.manual_refresh,
|
||||||
|
@ -452,6 +457,7 @@ This is required so that you don't accidentally start meli and find out later th
|
||||||
extra_identities,
|
extra_identities,
|
||||||
read_only,
|
read_only,
|
||||||
display_name,
|
display_name,
|
||||||
|
order,
|
||||||
subscribed_mailboxes,
|
subscribed_mailboxes,
|
||||||
mailboxes,
|
mailboxes,
|
||||||
extra,
|
extra,
|
||||||
|
@ -470,6 +476,7 @@ This is required so that you don't accidentally start meli and find out later th
|
||||||
extra_identities,
|
extra_identities,
|
||||||
read_only,
|
read_only,
|
||||||
display_name,
|
display_name,
|
||||||
|
order,
|
||||||
subscribed_mailboxes,
|
subscribed_mailboxes,
|
||||||
manual_refresh,
|
manual_refresh,
|
||||||
mailboxes: mailboxes
|
mailboxes: mailboxes
|
||||||
|
@ -945,6 +952,7 @@ mod dotaddressable {
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
impl<K: DotAddressable + std::cmp::Eq + std::hash::Hash> DotAddressable for HashSet<K> {}
|
impl<K: DotAddressable + std::cmp::Eq + std::hash::Hash> DotAddressable for HashSet<K> {}
|
||||||
|
impl DotAddressable for (SortField, SortOrder) {}
|
||||||
|
|
||||||
impl DotAddressable for LogSettings {
|
impl DotAddressable for LogSettings {
|
||||||
fn lookup(&self, parent_field: &str, path: &[&str]) -> Result<String> {
|
fn lookup(&self, parent_field: &str, path: &[&str]) -> Result<String> {
|
||||||
|
@ -1079,6 +1087,7 @@ mod dotaddressable {
|
||||||
"refresh_command" => self.refresh_command.lookup(field, tail),
|
"refresh_command" => self.refresh_command.lookup(field, tail),
|
||||||
"conf_override" => self.conf_override.lookup(field, tail),
|
"conf_override" => self.conf_override.lookup(field, tail),
|
||||||
"extra" => self.extra.lookup(field, tail),
|
"extra" => self.extra.lookup(field, tail),
|
||||||
|
"order" => self.order.lookup(field, tail),
|
||||||
other => Err(MeliError::new(format!(
|
other => Err(MeliError::new(format!(
|
||||||
"{} has no field named {}",
|
"{} has no field named {}",
|
||||||
parent_field, other
|
parent_field, other
|
||||||
|
|
Loading…
Reference in New Issue