conf: move FolderConf to melib
This will be needed to add notmuch-specific configuration settings in the FolderConf struct in the next commitjmap
parent
8f36678abf
commit
ede512200b
|
@ -18,6 +18,8 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with meli. If not, see <http://www.gnu.org/licenses/>.
|
* along with meli. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
use crate::backends::SpecialUseMailbox;
|
||||||
|
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||||
use std::collections::hash_map::HashMap;
|
use std::collections::hash_map::HashMap;
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Default, Clone)]
|
#[derive(Debug, Serialize, Default, Clone)]
|
||||||
|
@ -29,6 +31,8 @@ pub struct AccountSettings {
|
||||||
pub read_only: bool,
|
pub read_only: bool,
|
||||||
pub display_name: Option<String>,
|
pub display_name: Option<String>,
|
||||||
pub subscribed_folders: Vec<String>,
|
pub subscribed_folders: Vec<String>,
|
||||||
|
#[serde(default)]
|
||||||
|
pub folders: HashMap<String, FolderConf>,
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
pub extra: HashMap<String, String>,
|
pub extra: HashMap<String, String>,
|
||||||
}
|
}
|
||||||
|
@ -60,3 +64,114 @@ impl AccountSettings {
|
||||||
&self.subscribed_folders
|
&self.subscribed_folders
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[serde(default)]
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct FolderConf {
|
||||||
|
pub rename: Option<String>,
|
||||||
|
#[serde(default = "true_val")]
|
||||||
|
pub autoload: bool,
|
||||||
|
#[serde(deserialize_with = "toggleflag_de")]
|
||||||
|
pub subscribe: ToggleFlag,
|
||||||
|
#[serde(deserialize_with = "toggleflag_de")]
|
||||||
|
pub ignore: ToggleFlag,
|
||||||
|
#[serde(default = "none")]
|
||||||
|
pub usage: Option<SpecialUseMailbox>,
|
||||||
|
#[serde(flatten)]
|
||||||
|
pub extra: HashMap<String, String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for FolderConf {
|
||||||
|
fn default() -> Self {
|
||||||
|
FolderConf {
|
||||||
|
rename: None,
|
||||||
|
autoload: true,
|
||||||
|
subscribe: ToggleFlag::Unset,
|
||||||
|
ignore: ToggleFlag::Unset,
|
||||||
|
usage: None,
|
||||||
|
extra: HashMap::default(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FolderConf {
|
||||||
|
pub fn rename(&self) -> Option<&str> {
|
||||||
|
self.rename.as_ref().map(String::as_str)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(in crate::conf) fn true_val() -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(in crate::conf) fn none<T>() -> Option<T> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Debug, Clone, PartialEq)]
|
||||||
|
pub enum ToggleFlag {
|
||||||
|
Unset,
|
||||||
|
InternalVal(bool),
|
||||||
|
False,
|
||||||
|
True,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<bool> for ToggleFlag {
|
||||||
|
fn from(val: bool) -> Self {
|
||||||
|
if val {
|
||||||
|
ToggleFlag::True
|
||||||
|
} else {
|
||||||
|
ToggleFlag::False
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for ToggleFlag {
|
||||||
|
fn default() -> Self {
|
||||||
|
ToggleFlag::Unset
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ToggleFlag {
|
||||||
|
pub fn is_unset(&self) -> bool {
|
||||||
|
ToggleFlag::Unset == *self
|
||||||
|
}
|
||||||
|
pub fn is_internal(&self) -> bool {
|
||||||
|
if let ToggleFlag::InternalVal(_) = *self {
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn is_false(&self) -> bool {
|
||||||
|
ToggleFlag::False == *self || ToggleFlag::InternalVal(false) == *self
|
||||||
|
}
|
||||||
|
pub fn is_true(&self) -> bool {
|
||||||
|
ToggleFlag::True == *self || ToggleFlag::InternalVal(true) == *self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn toggleflag_de<'de, D>(deserializer: D) -> std::result::Result<ToggleFlag, D::Error>
|
||||||
|
where
|
||||||
|
D: Deserializer<'de>,
|
||||||
|
{
|
||||||
|
let s = <bool>::deserialize(deserializer);
|
||||||
|
Ok(match s {
|
||||||
|
Err(_) => ToggleFlag::Unset,
|
||||||
|
Ok(true) => ToggleFlag::True,
|
||||||
|
Ok(false) => ToggleFlag::False,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Serialize for ToggleFlag {
|
||||||
|
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
|
||||||
|
where
|
||||||
|
S: Serializer,
|
||||||
|
{
|
||||||
|
match self {
|
||||||
|
ToggleFlag::Unset | ToggleFlag::InternalVal(_) => serializer.serialize_none(),
|
||||||
|
ToggleFlag::False => serializer.serialize_bool(false),
|
||||||
|
ToggleFlag::True => serializer.serialize_bool(true),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
183
ui/src/conf.rs
183
ui/src/conf.rs
|
@ -42,7 +42,7 @@ use self::notifications::NotificationsSettings;
|
||||||
use self::terminal::TerminalSettings;
|
use self::terminal::TerminalSettings;
|
||||||
use crate::pager::PagerSettings;
|
use crate::pager::PagerSettings;
|
||||||
use melib::backends::SpecialUseMailbox;
|
use melib::backends::SpecialUseMailbox;
|
||||||
use melib::conf::AccountSettings;
|
use melib::conf::{toggleflag_de, AccountSettings, FolderConf, ToggleFlag};
|
||||||
use melib::error::*;
|
use melib::error::*;
|
||||||
|
|
||||||
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
|
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
|
||||||
|
@ -60,49 +60,6 @@ macro_rules! split_command {
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Debug, Clone, PartialEq)]
|
|
||||||
pub enum ToggleFlag {
|
|
||||||
Unset,
|
|
||||||
InternalVal(bool),
|
|
||||||
False,
|
|
||||||
True,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<bool> for ToggleFlag {
|
|
||||||
fn from(val: bool) -> Self {
|
|
||||||
if val {
|
|
||||||
ToggleFlag::True
|
|
||||||
} else {
|
|
||||||
ToggleFlag::False
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for ToggleFlag {
|
|
||||||
fn default() -> Self {
|
|
||||||
ToggleFlag::Unset
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ToggleFlag {
|
|
||||||
pub fn is_unset(&self) -> bool {
|
|
||||||
ToggleFlag::Unset == *self
|
|
||||||
}
|
|
||||||
pub fn is_internal(&self) -> bool {
|
|
||||||
if let ToggleFlag::InternalVal(_) = *self {
|
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pub fn is_false(&self) -> bool {
|
|
||||||
ToggleFlag::False == *self || ToggleFlag::InternalVal(false) == *self
|
|
||||||
}
|
|
||||||
pub fn is_true(&self) -> bool {
|
|
||||||
ToggleFlag::True == *self || ToggleFlag::InternalVal(true) == *self
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
|
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
|
||||||
pub struct MailUIConf {
|
pub struct MailUIConf {
|
||||||
pub pager: Option<PagerSettings>,
|
pub pager: Option<PagerSettings>,
|
||||||
|
@ -114,37 +71,21 @@ pub struct MailUIConf {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
|
||||||
pub struct FolderConf {
|
pub struct FileFolderConf {
|
||||||
pub rename: Option<String>,
|
#[serde(flatten)]
|
||||||
#[serde(default = "true_val")]
|
pub folder_conf: FolderConf,
|
||||||
pub autoload: bool,
|
|
||||||
#[serde(deserialize_with = "toggleflag_de")]
|
|
||||||
pub subscribe: ToggleFlag,
|
|
||||||
#[serde(deserialize_with = "toggleflag_de")]
|
|
||||||
pub ignore: ToggleFlag,
|
|
||||||
#[serde(default = "none")]
|
|
||||||
pub usage: Option<SpecialUseMailbox>,
|
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
pub conf_override: MailUIConf,
|
pub conf_override: MailUIConf,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for FolderConf {
|
impl FileFolderConf {
|
||||||
fn default() -> Self {
|
pub fn conf_override(&self) -> &MailUIConf {
|
||||||
FolderConf {
|
&self.conf_override
|
||||||
rename: None,
|
|
||||||
autoload: true,
|
|
||||||
subscribe: ToggleFlag::Unset,
|
|
||||||
ignore: ToggleFlag::Unset,
|
|
||||||
usage: None,
|
|
||||||
conf_override: MailUIConf::default(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl FolderConf {
|
pub fn folder_conf(&self) -> &FolderConf {
|
||||||
pub fn rename(&self) -> Option<&str> {
|
&self.folder_conf
|
||||||
self.rename.as_ref().map(String::as_str)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,7 +106,8 @@ pub struct FileAccount {
|
||||||
#[serde(default = "false_val")]
|
#[serde(default = "false_val")]
|
||||||
read_only: bool,
|
read_only: bool,
|
||||||
subscribed_folders: Vec<String>,
|
subscribed_folders: Vec<String>,
|
||||||
folders: Option<HashMap<String, FolderConf>>,
|
#[serde(default)]
|
||||||
|
folders: HashMap<String, FileFolderConf>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
cache_type: CacheType,
|
cache_type: CacheType,
|
||||||
}
|
}
|
||||||
|
@ -176,6 +118,11 @@ impl From<FileAccount> for AccountConf {
|
||||||
let root_folder = x.root_folder.clone();
|
let root_folder = x.root_folder.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 folders = x
|
||||||
|
.folders
|
||||||
|
.iter()
|
||||||
|
.map(|(k, v)| (k.clone(), v.folder_conf.clone()))
|
||||||
|
.collect();
|
||||||
|
|
||||||
let mut acc = AccountSettings {
|
let mut acc = AccountSettings {
|
||||||
name: String::new(),
|
name: String::new(),
|
||||||
|
@ -185,6 +132,7 @@ impl From<FileAccount> for AccountConf {
|
||||||
read_only: x.read_only,
|
read_only: x.read_only,
|
||||||
display_name,
|
display_name,
|
||||||
subscribed_folders: x.subscribed_folders.clone(),
|
subscribed_folders: x.subscribed_folders.clone(),
|
||||||
|
folders,
|
||||||
extra: x.extra.clone(),
|
extra: x.extra.clone(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -200,52 +148,58 @@ impl From<FileAccount> for AccountConf {
|
||||||
if !acc.subscribed_folders.contains(&root_tmp) {
|
if !acc.subscribed_folders.contains(&root_tmp) {
|
||||||
acc.subscribed_folders.push(root_tmp);
|
acc.subscribed_folders.push(root_tmp);
|
||||||
}
|
}
|
||||||
let mut folder_confs = x.folders.clone().unwrap_or_else(Default::default);
|
let mut folder_confs = x.folders.clone();
|
||||||
for s in &x.subscribed_folders {
|
for s in &x.subscribed_folders {
|
||||||
if !folder_confs.contains_key(s) {
|
if !folder_confs.contains_key(s) {
|
||||||
folder_confs.insert(
|
folder_confs.insert(
|
||||||
s.to_string(),
|
s.to_string(),
|
||||||
FolderConf {
|
FileFolderConf {
|
||||||
subscribe: ToggleFlag::True,
|
folder_conf: FolderConf {
|
||||||
..FolderConf::default()
|
subscribe: ToggleFlag::True,
|
||||||
|
..FolderConf::default()
|
||||||
|
},
|
||||||
|
..FileFolderConf::default()
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
if !folder_confs[s].subscribe.is_unset() {
|
if !folder_confs[s].folder_conf().subscribe.is_unset() {
|
||||||
eprintln!("Configuration error: folder `{}` cannot both have `subscribe` flag set and be in the `subscribed_folders` array", s);
|
continue;
|
||||||
std::process::exit(1);
|
|
||||||
}
|
}
|
||||||
folder_confs.get_mut(s).unwrap().subscribe = ToggleFlag::True;
|
folder_confs.get_mut(s).unwrap().folder_conf.subscribe = ToggleFlag::True;
|
||||||
}
|
}
|
||||||
|
|
||||||
if folder_confs[s].usage.is_none() {
|
if folder_confs[s].folder_conf().usage.is_none() {
|
||||||
let name = s
|
let name = s
|
||||||
.split(if s.contains('/') { '/' } else { '.' })
|
.split(if s.contains('/') { '/' } else { '.' })
|
||||||
.last()
|
.last()
|
||||||
.unwrap_or("");
|
.unwrap_or("");
|
||||||
folder_confs.get_mut(s).unwrap().usage = if name.eq_ignore_ascii_case("inbox") {
|
folder_confs.get_mut(s).unwrap().folder_conf.usage =
|
||||||
Some(SpecialUseMailbox::Inbox)
|
if name.eq_ignore_ascii_case("inbox") {
|
||||||
} else if name.eq_ignore_ascii_case("archive") {
|
Some(SpecialUseMailbox::Inbox)
|
||||||
Some(SpecialUseMailbox::Archive)
|
} else if name.eq_ignore_ascii_case("archive") {
|
||||||
} else if name.eq_ignore_ascii_case("drafts") {
|
Some(SpecialUseMailbox::Archive)
|
||||||
Some(SpecialUseMailbox::Drafts)
|
} else if name.eq_ignore_ascii_case("drafts") {
|
||||||
} else if name.eq_ignore_ascii_case("junk") {
|
Some(SpecialUseMailbox::Drafts)
|
||||||
Some(SpecialUseMailbox::Junk)
|
} else if name.eq_ignore_ascii_case("junk") {
|
||||||
} else if name.eq_ignore_ascii_case("spam") {
|
Some(SpecialUseMailbox::Junk)
|
||||||
Some(SpecialUseMailbox::Junk)
|
} else if name.eq_ignore_ascii_case("spam") {
|
||||||
} else if name.eq_ignore_ascii_case("sent") {
|
Some(SpecialUseMailbox::Junk)
|
||||||
Some(SpecialUseMailbox::Sent)
|
} else if name.eq_ignore_ascii_case("sent") {
|
||||||
} else if name.eq_ignore_ascii_case("trash") {
|
Some(SpecialUseMailbox::Sent)
|
||||||
Some(SpecialUseMailbox::Trash)
|
} else if name.eq_ignore_ascii_case("trash") {
|
||||||
} else {
|
Some(SpecialUseMailbox::Trash)
|
||||||
Some(SpecialUseMailbox::Normal)
|
} else {
|
||||||
};
|
Some(SpecialUseMailbox::Normal)
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if folder_confs[s].ignore.is_unset() {
|
if folder_confs[s].folder_conf().ignore.is_unset() {
|
||||||
use SpecialUseMailbox::*;
|
use SpecialUseMailbox::*;
|
||||||
if [Junk, Sent, Trash].contains(&folder_confs[s].usage.as_ref().unwrap()) {
|
if [Junk, Sent, Trash]
|
||||||
folder_confs.get_mut(s).unwrap().ignore = ToggleFlag::InternalVal(true);
|
.contains(&folder_confs[s].folder_conf().usage.as_ref().unwrap())
|
||||||
|
{
|
||||||
|
folder_confs.get_mut(s).unwrap().folder_conf.ignore =
|
||||||
|
ToggleFlag::InternalVal(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -259,8 +213,8 @@ impl From<FileAccount> for AccountConf {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FileAccount {
|
impl FileAccount {
|
||||||
pub fn folders(&self) -> Option<&HashMap<String, FolderConf>> {
|
pub fn folders(&self) -> &HashMap<String, FileFolderConf> {
|
||||||
self.folders.as_ref()
|
&self.folders
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn folder(&self) -> &str {
|
pub fn folder(&self) -> &str {
|
||||||
|
@ -296,7 +250,7 @@ struct FileSettings {
|
||||||
pub struct AccountConf {
|
pub struct AccountConf {
|
||||||
pub(crate) account: AccountSettings,
|
pub(crate) account: AccountSettings,
|
||||||
pub(crate) conf: FileAccount,
|
pub(crate) conf: FileAccount,
|
||||||
pub(crate) folder_confs: HashMap<String, FolderConf>,
|
pub(crate) folder_confs: HashMap<String, FileFolderConf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AccountConf {
|
impl AccountConf {
|
||||||
|
@ -427,31 +381,6 @@ impl Default for IndexStyle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn toggleflag_de<'de, D>(deserializer: D) -> std::result::Result<ToggleFlag, D::Error>
|
|
||||||
where
|
|
||||||
D: Deserializer<'de>,
|
|
||||||
{
|
|
||||||
let s = <bool>::deserialize(deserializer);
|
|
||||||
Ok(match s {
|
|
||||||
Err(_) => ToggleFlag::Unset,
|
|
||||||
Ok(true) => ToggleFlag::True,
|
|
||||||
Ok(false) => ToggleFlag::False,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Serialize for ToggleFlag {
|
|
||||||
fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
|
|
||||||
where
|
|
||||||
S: Serializer,
|
|
||||||
{
|
|
||||||
match self {
|
|
||||||
ToggleFlag::Unset | ToggleFlag::InternalVal(_) => serializer.serialize_none(),
|
|
||||||
ToggleFlag::False => serializer.serialize_bool(false),
|
|
||||||
ToggleFlag::True => serializer.serialize_bool(true),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Deserialize default functions
|
* Deserialize default functions
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
* Account management from user configuration.
|
* Account management from user configuration.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use super::{AccountConf, FolderConf};
|
use super::{AccountConf, FileFolderConf};
|
||||||
use fnv::FnvHashMap;
|
use fnv::FnvHashMap;
|
||||||
use melib::async_workers::{Async, AsyncBuilder, AsyncStatus, WorkContext};
|
use melib::async_workers::{Async, AsyncBuilder, AsyncStatus, WorkContext};
|
||||||
use melib::backends::{
|
use melib::backends::{
|
||||||
|
@ -144,7 +144,7 @@ pub struct Account {
|
||||||
name: String,
|
name: String,
|
||||||
pub is_online: bool,
|
pub is_online: bool,
|
||||||
pub(crate) folders: FnvHashMap<FolderHash, MailboxEntry>,
|
pub(crate) folders: FnvHashMap<FolderHash, MailboxEntry>,
|
||||||
pub(crate) folder_confs: FnvHashMap<FolderHash, FolderConf>,
|
pub(crate) folder_confs: FnvHashMap<FolderHash, FileFolderConf>,
|
||||||
pub(crate) folders_order: Vec<FolderHash>,
|
pub(crate) folders_order: Vec<FolderHash>,
|
||||||
pub(crate) folder_names: FnvHashMap<FolderHash, String>,
|
pub(crate) folder_names: FnvHashMap<FolderHash, String>,
|
||||||
tree: Vec<FolderNode>,
|
tree: Vec<FolderNode>,
|
||||||
|
@ -232,7 +232,8 @@ impl Account {
|
||||||
let backend = map.get(settings.account().format())(
|
let backend = map.get(settings.account().format())(
|
||||||
settings.account(),
|
settings.account(),
|
||||||
Box::new(move |path: &str| {
|
Box::new(move |path: &str| {
|
||||||
s.folder_confs.contains_key(path) && s.folder_confs[path].subscribe.is_true()
|
s.folder_confs.contains_key(path)
|
||||||
|
&& s.folder_confs[path].folder_conf().subscribe.is_true()
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
let notify_fn = Arc::new(notify_fn);
|
let notify_fn = Arc::new(notify_fn);
|
||||||
|
@ -293,13 +294,16 @@ impl Account {
|
||||||
let mut sent_folder = None;
|
let mut sent_folder = None;
|
||||||
for f in ref_folders.values_mut() {
|
for f in ref_folders.values_mut() {
|
||||||
if !self.settings.folder_confs.contains_key(f.path())
|
if !self.settings.folder_confs.contains_key(f.path())
|
||||||
|| self.settings.folder_confs[f.path()].subscribe.is_false()
|
|| self.settings.folder_confs[f.path()]
|
||||||
|
.folder_conf()
|
||||||
|
.subscribe
|
||||||
|
.is_false()
|
||||||
{
|
{
|
||||||
/* Skip unsubscribed folder */
|
/* Skip unsubscribed folder */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
match self.settings.folder_confs[f.path()].usage {
|
match self.settings.folder_confs[f.path()].folder_conf().usage {
|
||||||
Some(SpecialUseMailbox::Sent) => {
|
Some(SpecialUseMailbox::Sent) => {
|
||||||
sent_folder = Some(f.hash());
|
sent_folder = Some(f.hash());
|
||||||
}
|
}
|
||||||
|
@ -314,7 +318,10 @@ impl Account {
|
||||||
let mut collection: Collection = Collection::new(Default::default());
|
let mut collection: Collection = Collection::new(Default::default());
|
||||||
for (h, f) in ref_folders.iter() {
|
for (h, f) in ref_folders.iter() {
|
||||||
if !self.settings.folder_confs.contains_key(f.path())
|
if !self.settings.folder_confs.contains_key(f.path())
|
||||||
|| self.settings.folder_confs[f.path()].subscribe.is_false()
|
|| self.settings.folder_confs[f.path()]
|
||||||
|
.folder_conf()
|
||||||
|
.subscribe
|
||||||
|
.is_false()
|
||||||
{
|
{
|
||||||
/* Skip unsubscribed folder */
|
/* Skip unsubscribed folder */
|
||||||
continue;
|
continue;
|
||||||
|
@ -392,7 +399,7 @@ impl Account {
|
||||||
let mut builder = AsyncBuilder::new();
|
let mut builder = AsyncBuilder::new();
|
||||||
let our_tx = builder.tx();
|
let our_tx = builder.tx();
|
||||||
let folder_hash = folder.hash();
|
let folder_hash = folder.hash();
|
||||||
let priority = match settings.folder_confs[folder.path()].usage {
|
let priority = match settings.folder_confs[folder.path()].folder_conf().usage {
|
||||||
Some(SpecialUseMailbox::Inbox) => 0,
|
Some(SpecialUseMailbox::Inbox) => 0,
|
||||||
Some(SpecialUseMailbox::Sent) => 1,
|
Some(SpecialUseMailbox::Sent) => 1,
|
||||||
Some(SpecialUseMailbox::Drafts) | Some(SpecialUseMailbox::Trash) => 2,
|
Some(SpecialUseMailbox::Drafts) | Some(SpecialUseMailbox::Trash) => 2,
|
||||||
|
@ -563,7 +570,7 @@ impl Account {
|
||||||
let ref_folders: FnvHashMap<FolderHash, Folder> =
|
let ref_folders: FnvHashMap<FolderHash, Folder> =
|
||||||
self.backend.read().unwrap().folders();
|
self.backend.read().unwrap().folders();
|
||||||
let folder_conf = &self.settings.folder_confs[&self.folder_names[&folder_hash]];
|
let folder_conf = &self.settings.folder_confs[&self.folder_names[&folder_hash]];
|
||||||
if folder_conf.ignore.is_true() {
|
if folder_conf.folder_conf().ignore.is_true() {
|
||||||
return Some(UIEvent::MailboxUpdate((self.index, folder_hash)));
|
return Some(UIEvent::MailboxUpdate((self.index, folder_hash)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -673,13 +680,12 @@ impl Account {
|
||||||
}
|
}
|
||||||
pub fn list_folders(&self) -> Vec<Folder> {
|
pub fn list_folders(&self) -> Vec<Folder> {
|
||||||
let mut folders = self.backend.read().unwrap().folders();
|
let mut folders = self.backend.read().unwrap().folders();
|
||||||
if let Some(folder_confs) = self.settings.conf().folders() {
|
let folder_confs = self.settings.conf().folders();
|
||||||
//debug!("folder renames: {:?}", folder_renames);
|
//debug!("folder renames: {:?}", folder_renames);
|
||||||
for f in folders.values_mut() {
|
for f in folders.values_mut() {
|
||||||
if let Some(r) = folder_confs.get(f.path()) {
|
if let Some(r) = folder_confs.get(f.path()) {
|
||||||
if let Some(rename) = r.rename() {
|
if let Some(rename) = r.folder_conf().rename() {
|
||||||
f.change_name(rename);
|
f.change_name(rename);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -829,7 +835,7 @@ impl Account {
|
||||||
self.backend.write().unwrap().folder_operation(path, op)
|
self.backend.write().unwrap().folder_operation(path, op)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn folder_confs(&self, folder_hash: FolderHash) -> &FolderConf {
|
pub fn folder_confs(&self, folder_hash: FolderHash) -> &FileFolderConf {
|
||||||
&self.folder_confs[&folder_hash]
|
&self.folder_confs[&folder_hash]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -838,7 +844,7 @@ impl Account {
|
||||||
.settings
|
.settings
|
||||||
.folder_confs
|
.folder_confs
|
||||||
.iter()
|
.iter()
|
||||||
.find(|(_, f)| f.usage == Some(SpecialUseMailbox::Sent));
|
.find(|(_, f)| f.folder_conf().usage == Some(SpecialUseMailbox::Sent));
|
||||||
if let Some(sent_folder) = sent_folder.as_ref() {
|
if let Some(sent_folder) = sent_folder.as_ref() {
|
||||||
sent_folder.0
|
sent_folder.0
|
||||||
} else {
|
} else {
|
||||||
|
@ -851,7 +857,7 @@ impl Account {
|
||||||
.settings
|
.settings
|
||||||
.folder_confs
|
.folder_confs
|
||||||
.iter()
|
.iter()
|
||||||
.find(|(_, f)| f.usage == Some(special_use));
|
.find(|(_, f)| f.folder_conf().usage == Some(special_use));
|
||||||
ret.as_ref().map(|r| r.0.as_str())
|
ret.as_ref().map(|r| r.0.as_str())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue