diff --git a/melib/src/notmuch/config.rs b/melib/src/notmuch/config.rs new file mode 100644 index 00000000..3343de91 --- /dev/null +++ b/melib/src/notmuch/config.rs @@ -0,0 +1,63 @@ +// +// melib +// +// Copyright 2024 Emmanouil Pitsidianakis +// +// This file is part of melib. +// +// melib is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// melib is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with melib. If not, see . +// +// SPDX-License-Identifier: EUPL-1.2 OR GPL-3.0-or-later + +use crate::{email::Address, SpecialUsageMailbox}; +use indexmap::IndexMap; +use regex::bytes::Regex; +use std::path::PathBuf; + +#[derive(Serialize, Deserialize)] +pub struct FccDirEntry { + pattern: Box, + folder: Option>, + //tags: Vec, +} + +impl FccDirEntry { + pub fn matches<'fcc>(&'fcc self, from: &Address) -> Option<&'fcc str> { + let reg = Regex::new(&self.pattern).ok()?; + if reg.is_match(from.raw()) { + return self.folder.as_ref().map(|s| s.as_ref()); + } + None + } +} + +#[derive(Serialize, Deserialize)] +pub enum FccDirs { + None, + Folder(Box), + SpecialFolder(SpecialUsageMailbox), + Map(Vec), +} + +impl Default for FccDirs { + fn default() -> Self { + Self::SpecialFolder(SpecialUsageMailbox::Sent) + } +} + +#[derive(Default, Serialize, Deserialize)] +pub struct Configuration { + pub library_file_path: Option, + pub fcc_dirs: FccDirs, +} diff --git a/melib/src/notmuch/mod.rs b/melib/src/notmuch/mod.rs index a60a34fc..25956b90 100644 --- a/melib/src/notmuch/mod.rs +++ b/melib/src/notmuch/mod.rs @@ -72,6 +72,7 @@ macro_rules! try_call { }}; } +pub mod config; pub mod query; use query::{MelibQueryToNotmuchQuery, Query}; pub mod mailbox;