mirror of
https://github.com/soywod/himalaya.git
synced 2024-11-25 04:20:22 +00:00
rename existing cargo features, fix imports
This commit is contained in:
parent
ea9c28b9d7
commit
8b1a289f4d
30 changed files with 224 additions and 206 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -2068,6 +2068,7 @@ dependencies = [
|
||||||
"indicatif",
|
"indicatif",
|
||||||
"keyring-lib",
|
"keyring-lib",
|
||||||
"log",
|
"log",
|
||||||
|
"mail-builder",
|
||||||
"md5",
|
"md5",
|
||||||
"mml-lib",
|
"mml-lib",
|
||||||
"oauth-lib 0.1.0",
|
"oauth-lib 0.1.0",
|
||||||
|
|
24
Cargo.toml
24
Cargo.toml
|
@ -10,20 +10,27 @@ keywords = ["cli", "mail", "email", "client", "imap"]
|
||||||
homepage = "https://pimalaya.org/himalaya"
|
homepage = "https://pimalaya.org/himalaya"
|
||||||
documentation = "https://pimalaya.org/himalaya/"
|
documentation = "https://pimalaya.org/himalaya/"
|
||||||
repository = "https://github.com/soywod/himalaya/"
|
repository = "https://github.com/soywod/himalaya/"
|
||||||
metadata.docs.rs.all-features = true
|
|
||||||
|
[package.metadata.docs.rs]
|
||||||
|
all-features = true
|
||||||
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = [
|
default = [
|
||||||
"imap-backend",
|
"maildir",
|
||||||
# "notmuch-backend",
|
"imap",
|
||||||
"smtp-sender",
|
# "notmuch",
|
||||||
|
"smtp",
|
||||||
|
"sendmail",
|
||||||
# "pgp-commands",
|
# "pgp-commands",
|
||||||
# "pgp-gpg",
|
# "pgp-gpg",
|
||||||
# "pgp-native",
|
# "pgp-native",
|
||||||
]
|
]
|
||||||
imap-backend = ["email-lib/imap-backend"]
|
maildir = ["email-lib/maildir"]
|
||||||
notmuch-backend = ["email-lib/notmuch-backend"]
|
imap = ["email-lib/imap"]
|
||||||
smtp-sender = ["email-lib/smtp-sender"]
|
notmuch = ["email-lib/notmuch"]
|
||||||
|
smtp = ["email-lib/smtp"]
|
||||||
|
sendmail = ["email-lib/sendmail"]
|
||||||
pgp = []
|
pgp = []
|
||||||
pgp-commands = ["pgp", "mml-lib/pgp-commands", "email-lib/pgp-commands"]
|
pgp-commands = ["pgp", "mml-lib/pgp-commands", "email-lib/pgp-commands"]
|
||||||
pgp-gpg = ["pgp", "mml-lib/pgp-gpg", "email-lib/pgp-gpg"]
|
pgp-gpg = ["pgp", "mml-lib/pgp-gpg", "email-lib/pgp-gpg"]
|
||||||
|
@ -98,6 +105,9 @@ path = "/home/soywod/sourcehut/pimalaya/email"
|
||||||
[dependencies.keyring-lib]
|
[dependencies.keyring-lib]
|
||||||
version = "=0.1.0"
|
version = "=0.1.0"
|
||||||
|
|
||||||
|
[dependencies.mail-builder]
|
||||||
|
version = "0.3"
|
||||||
|
|
||||||
[dependencies.oauth-lib]
|
[dependencies.oauth-lib]
|
||||||
# version = "=0.1.0"
|
# version = "=0.1.0"
|
||||||
path = "/home/soywod/sourcehut/pimalaya/oauth"
|
path = "/home/soywod/sourcehut/pimalaya/oauth"
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
use email::imap::ImapConfig;
|
use email::imap::config::ImapConfig;
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch")]
|
||||||
use email::notmuch::NotmuchConfig;
|
use email::notmuch::config::NotmuchConfig;
|
||||||
#[cfg(feature = "smtp-sender")]
|
#[cfg(feature = "smtp")]
|
||||||
use email::smtp::SmtpConfig;
|
use email::smtp::config::SmtpConfig;
|
||||||
use email::{maildir::MaildirConfig, sendmail::SendmailConfig};
|
use email::{maildir::config::MaildirConfig, sendmail::config::SendmailConfig};
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
pub enum BackendConfig {
|
pub enum BackendConfig {
|
||||||
Maildir(MaildirConfig),
|
Maildir(MaildirConfig),
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
Imap(ImapConfig),
|
Imap(ImapConfig),
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch")]
|
||||||
Notmuch(NotmuchConfig),
|
Notmuch(NotmuchConfig),
|
||||||
#[cfg(feature = "smtp-sender")]
|
#[cfg(feature = "smtp")]
|
||||||
Smtp(SmtpConfig),
|
Smtp(SmtpConfig),
|
||||||
Sendmail(SendmailConfig),
|
Sendmail(SendmailConfig),
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,36 +5,23 @@ use anyhow::Result;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
use email::imap::{ImapSessionBuilder, ImapSessionSync};
|
use email::imap::{ImapSessionBuilder, ImapSessionSync};
|
||||||
#[cfg(feature = "smtp-sender")]
|
#[cfg(feature = "smtp")]
|
||||||
use email::smtp::{SmtpClientBuilder, SmtpClientSync};
|
use email::smtp::{SmtpClientBuilder, SmtpClientSync};
|
||||||
use email::{
|
use email::{
|
||||||
account::AccountConfig,
|
account::config::AccountConfig,
|
||||||
email::{
|
envelope::{
|
||||||
envelope::{
|
get::{imap::GetEnvelopeImap, maildir::GetEnvelopeMaildir},
|
||||||
get::{imap::GetEnvelopeImap, maildir::GetEnvelopeMaildir},
|
list::{imap::ListEnvelopesImap, maildir::ListEnvelopesMaildir},
|
||||||
list::{imap::ListEnvelopesImap, maildir::ListEnvelopesMaildir},
|
Id, SingleId,
|
||||||
},
|
},
|
||||||
flag::{
|
flag::{
|
||||||
add::{imap::AddFlagsImap, maildir::AddFlagsMaildir},
|
add::{imap::AddFlagsImap, maildir::AddFlagsMaildir},
|
||||||
remove::{imap::RemoveFlagsImap, maildir::RemoveFlagsMaildir},
|
remove::{imap::RemoveFlagsImap, maildir::RemoveFlagsMaildir},
|
||||||
set::{imap::SetFlagsImap, maildir::SetFlagsMaildir},
|
set::{imap::SetFlagsImap, maildir::SetFlagsMaildir},
|
||||||
},
|
Flags,
|
||||||
message::{
|
|
||||||
add_raw::imap::AddRawMessageImap,
|
|
||||||
add_raw_with_flags::{
|
|
||||||
imap::AddRawMessageWithFlagsImap, maildir::AddRawMessageWithFlagsMaildir,
|
|
||||||
},
|
|
||||||
copy::{imap::CopyMessagesImap, maildir::CopyMessagesMaildir},
|
|
||||||
get::imap::GetMessagesImap,
|
|
||||||
move_::{imap::MoveMessagesImap, maildir::MoveMessagesMaildir},
|
|
||||||
peek::{imap::PeekMessagesImap, maildir::PeekMessagesMaildir},
|
|
||||||
send_raw::{sendmail::SendRawMessageSendmail, smtp::SendRawMessageSmtp},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
envelope::{Id, SingleId},
|
|
||||||
flag::Flags,
|
|
||||||
folder::{
|
folder::{
|
||||||
add::{imap::AddFolderImap, maildir::AddFolderMaildir},
|
add::{imap::AddFolderImap, maildir::AddFolderMaildir},
|
||||||
delete::{imap::DeleteFolderImap, maildir::DeleteFolderMaildir},
|
delete::{imap::DeleteFolderImap, maildir::DeleteFolderMaildir},
|
||||||
|
@ -42,8 +29,19 @@ use email::{
|
||||||
list::{imap::ListFoldersImap, maildir::ListFoldersMaildir},
|
list::{imap::ListFoldersImap, maildir::ListFoldersMaildir},
|
||||||
purge::imap::PurgeFolderImap,
|
purge::imap::PurgeFolderImap,
|
||||||
},
|
},
|
||||||
maildir::{MaildirConfig, MaildirSessionBuilder, MaildirSessionSync},
|
maildir::{config::MaildirConfig, MaildirSessionBuilder, MaildirSessionSync},
|
||||||
message::Messages,
|
message::{
|
||||||
|
add_raw::imap::AddRawMessageImap,
|
||||||
|
add_raw_with_flags::{
|
||||||
|
imap::AddRawMessageWithFlagsImap, maildir::AddRawMessageWithFlagsMaildir,
|
||||||
|
},
|
||||||
|
copy::{imap::CopyMessagesImap, maildir::CopyMessagesMaildir},
|
||||||
|
get::imap::GetMessagesImap,
|
||||||
|
move_::{imap::MoveMessagesImap, maildir::MoveMessagesMaildir},
|
||||||
|
peek::{imap::PeekMessagesImap, maildir::PeekMessagesMaildir},
|
||||||
|
send_raw::{sendmail::SendRawMessageSendmail, smtp::SendRawMessageSmtp},
|
||||||
|
Messages,
|
||||||
|
},
|
||||||
sendmail::SendmailContext,
|
sendmail::SendmailContext,
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
@ -56,11 +54,11 @@ pub enum BackendKind {
|
||||||
Maildir,
|
Maildir,
|
||||||
#[serde(skip_deserializing)]
|
#[serde(skip_deserializing)]
|
||||||
MaildirForSync,
|
MaildirForSync,
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
Imap,
|
Imap,
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch")]
|
||||||
Notmuch,
|
Notmuch,
|
||||||
#[cfg(feature = "smtp-sender")]
|
#[cfg(feature = "smtp")]
|
||||||
Smtp,
|
Smtp,
|
||||||
Sendmail,
|
Sendmail,
|
||||||
}
|
}
|
||||||
|
@ -70,11 +68,11 @@ impl ToString for BackendKind {
|
||||||
let kind = match self {
|
let kind = match self {
|
||||||
Self::Maildir => "Maildir",
|
Self::Maildir => "Maildir",
|
||||||
Self::MaildirForSync => "Maildir",
|
Self::MaildirForSync => "Maildir",
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
Self::Imap => "IMAP",
|
Self::Imap => "IMAP",
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch")]
|
||||||
Self::Notmuch => "Notmuch",
|
Self::Notmuch => "Notmuch",
|
||||||
#[cfg(feature = "smtp-sender")]
|
#[cfg(feature = "smtp")]
|
||||||
Self::Smtp => "SMTP",
|
Self::Smtp => "SMTP",
|
||||||
Self::Sendmail => "Sendmail",
|
Self::Sendmail => "Sendmail",
|
||||||
};
|
};
|
||||||
|
@ -87,9 +85,9 @@ impl ToString for BackendKind {
|
||||||
pub struct BackendContextBuilder {
|
pub struct BackendContextBuilder {
|
||||||
maildir: Option<MaildirSessionBuilder>,
|
maildir: Option<MaildirSessionBuilder>,
|
||||||
maildir_for_sync: Option<MaildirSessionBuilder>,
|
maildir_for_sync: Option<MaildirSessionBuilder>,
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
imap: Option<ImapSessionBuilder>,
|
imap: Option<ImapSessionBuilder>,
|
||||||
#[cfg(feature = "smtp-sender")]
|
#[cfg(feature = "smtp")]
|
||||||
smtp: Option<SmtpClientBuilder>,
|
smtp: Option<SmtpClientBuilder>,
|
||||||
sendmail: Option<SendmailContext>,
|
sendmail: Option<SendmailContext>,
|
||||||
}
|
}
|
||||||
|
@ -109,17 +107,17 @@ impl email::backend::BackendContextBuilder for BackendContextBuilder {
|
||||||
ctx.maildir_for_sync = Some(maildir.build().await?);
|
ctx.maildir_for_sync = Some(maildir.build().await?);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
if let Some(imap) = self.imap {
|
if let Some(imap) = self.imap {
|
||||||
ctx.imap = Some(imap.build().await?);
|
ctx.imap = Some(imap.build().await?);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch")]
|
||||||
if let Some(notmuch) = self.notmuch {
|
if let Some(notmuch) = self.notmuch {
|
||||||
ctx.notmuch = Some(notmuch.build().await?);
|
ctx.notmuch = Some(notmuch.build().await?);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "smtp-sender")]
|
#[cfg(feature = "smtp")]
|
||||||
if let Some(smtp) = self.smtp {
|
if let Some(smtp) = self.smtp {
|
||||||
ctx.smtp = Some(smtp.build().await?);
|
ctx.smtp = Some(smtp.build().await?);
|
||||||
}
|
}
|
||||||
|
@ -136,9 +134,9 @@ impl email::backend::BackendContextBuilder for BackendContextBuilder {
|
||||||
pub struct BackendContext {
|
pub struct BackendContext {
|
||||||
pub maildir: Option<MaildirSessionSync>,
|
pub maildir: Option<MaildirSessionSync>,
|
||||||
pub maildir_for_sync: Option<MaildirSessionSync>,
|
pub maildir_for_sync: Option<MaildirSessionSync>,
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
pub imap: Option<ImapSessionSync>,
|
pub imap: Option<ImapSessionSync>,
|
||||||
#[cfg(feature = "smtp-sender")]
|
#[cfg(feature = "smtp")]
|
||||||
pub smtp: Option<SmtpClientSync>,
|
pub smtp: Option<SmtpClientSync>,
|
||||||
pub sendmail: Option<SendmailContext>,
|
pub sendmail: Option<SendmailContext>,
|
||||||
}
|
}
|
||||||
|
@ -158,11 +156,11 @@ impl BackendBuilder {
|
||||||
|
|
||||||
let is_maildir_used = used_backends.contains(&BackendKind::Maildir);
|
let is_maildir_used = used_backends.contains(&BackendKind::Maildir);
|
||||||
let is_maildir_for_sync_used = used_backends.contains(&BackendKind::MaildirForSync);
|
let is_maildir_for_sync_used = used_backends.contains(&BackendKind::MaildirForSync);
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
let is_imap_used = used_backends.contains(&BackendKind::Imap);
|
let is_imap_used = used_backends.contains(&BackendKind::Imap);
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch")]
|
||||||
let is_notmuch_used = used_backends.contains(&BackendKind::Notmuch);
|
let is_notmuch_used = used_backends.contains(&BackendKind::Notmuch);
|
||||||
#[cfg(feature = "smtp-sender")]
|
#[cfg(feature = "smtp")]
|
||||||
let is_smtp_used = used_backends.contains(&BackendKind::Smtp);
|
let is_smtp_used = used_backends.contains(&BackendKind::Smtp);
|
||||||
let is_sendmail_used = used_backends.contains(&BackendKind::Sendmail);
|
let is_sendmail_used = used_backends.contains(&BackendKind::Sendmail);
|
||||||
|
|
||||||
|
@ -180,7 +178,7 @@ impl BackendBuilder {
|
||||||
.filter(|_| is_maildir_for_sync_used)
|
.filter(|_| is_maildir_for_sync_used)
|
||||||
.map(|mdir_config| MaildirSessionBuilder::new(account_config.clone(), mdir_config)),
|
.map(|mdir_config| MaildirSessionBuilder::new(account_config.clone(), mdir_config)),
|
||||||
|
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
imap: {
|
imap: {
|
||||||
let ctx_builder = toml_account_config
|
let ctx_builder = toml_account_config
|
||||||
.imap
|
.imap
|
||||||
|
@ -196,7 +194,7 @@ impl BackendBuilder {
|
||||||
None => None,
|
None => None,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch")]
|
||||||
notmuch: toml_account_config
|
notmuch: toml_account_config
|
||||||
.notmuch
|
.notmuch
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
@ -204,7 +202,7 @@ impl BackendBuilder {
|
||||||
.map(|notmuch_config| {
|
.map(|notmuch_config| {
|
||||||
NotmuchSessionBuilder::new(account_config.clone(), notmuch_config.clone())
|
NotmuchSessionBuilder::new(account_config.clone(), notmuch_config.clone())
|
||||||
}),
|
}),
|
||||||
#[cfg(feature = "smtp-sender")]
|
#[cfg(feature = "smtp")]
|
||||||
smtp: toml_account_config
|
smtp: toml_account_config
|
||||||
.smtp
|
.smtp
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
@ -238,12 +236,12 @@ impl BackendBuilder {
|
||||||
.and_then(AddFolderMaildir::new)
|
.and_then(AddFolderMaildir::new)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
Some(BackendKind::Imap) => {
|
Some(BackendKind::Imap) => {
|
||||||
backend_builder = backend_builder
|
backend_builder = backend_builder
|
||||||
.with_add_folder(|ctx| ctx.imap.as_ref().and_then(AddFolderImap::new));
|
.with_add_folder(|ctx| ctx.imap.as_ref().and_then(AddFolderImap::new));
|
||||||
}
|
}
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch")]
|
||||||
Some(BackendKind::Notmuch) => {
|
Some(BackendKind::Notmuch) => {
|
||||||
backend_builder = backend_builder
|
backend_builder = backend_builder
|
||||||
.with_add_folder(|ctx| ctx.notmuch.as_ref().and_then(AddFolderNotmuch::new));
|
.with_add_folder(|ctx| ctx.notmuch.as_ref().and_then(AddFolderNotmuch::new));
|
||||||
|
@ -264,12 +262,12 @@ impl BackendBuilder {
|
||||||
.and_then(ListFoldersMaildir::new)
|
.and_then(ListFoldersMaildir::new)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
Some(BackendKind::Imap) => {
|
Some(BackendKind::Imap) => {
|
||||||
backend_builder = backend_builder
|
backend_builder = backend_builder
|
||||||
.with_list_folders(|ctx| ctx.imap.as_ref().and_then(ListFoldersImap::new));
|
.with_list_folders(|ctx| ctx.imap.as_ref().and_then(ListFoldersImap::new));
|
||||||
}
|
}
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch")]
|
||||||
Some(BackendKind::Notmuch) => {
|
Some(BackendKind::Notmuch) => {
|
||||||
backend_builder = backend_builder.with_list_folders(|ctx| {
|
backend_builder = backend_builder.with_list_folders(|ctx| {
|
||||||
ctx.notmuch.as_ref().and_then(ListFoldersNotmuch::new)
|
ctx.notmuch.as_ref().and_then(ListFoldersNotmuch::new)
|
||||||
|
@ -291,12 +289,12 @@ impl BackendBuilder {
|
||||||
.and_then(ExpungeFolderMaildir::new)
|
.and_then(ExpungeFolderMaildir::new)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
Some(BackendKind::Imap) => {
|
Some(BackendKind::Imap) => {
|
||||||
backend_builder = backend_builder
|
backend_builder = backend_builder
|
||||||
.with_expunge_folder(|ctx| ctx.imap.as_ref().and_then(ExpungeFolderImap::new));
|
.with_expunge_folder(|ctx| ctx.imap.as_ref().and_then(ExpungeFolderImap::new));
|
||||||
}
|
}
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch")]
|
||||||
Some(BackendKind::Notmuch) => {
|
Some(BackendKind::Notmuch) => {
|
||||||
backend_builder = backend_builder.with_expunge_folder(|ctx| {
|
backend_builder = backend_builder.with_expunge_folder(|ctx| {
|
||||||
ctx.notmuch.as_ref().and_then(ExpungeFolderNotmuch::new)
|
ctx.notmuch.as_ref().and_then(ExpungeFolderNotmuch::new)
|
||||||
|
@ -316,12 +314,12 @@ impl BackendBuilder {
|
||||||
// backend_builder = backend_builder
|
// backend_builder = backend_builder
|
||||||
// .with_purge_folder(|ctx| ctx.maildir_for_sync.as_ref().and_then(PurgeFolderMaildir::new));
|
// .with_purge_folder(|ctx| ctx.maildir_for_sync.as_ref().and_then(PurgeFolderMaildir::new));
|
||||||
// }
|
// }
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
Some(BackendKind::Imap) => {
|
Some(BackendKind::Imap) => {
|
||||||
backend_builder = backend_builder
|
backend_builder = backend_builder
|
||||||
.with_purge_folder(|ctx| ctx.imap.as_ref().and_then(PurgeFolderImap::new));
|
.with_purge_folder(|ctx| ctx.imap.as_ref().and_then(PurgeFolderImap::new));
|
||||||
}
|
}
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch")]
|
||||||
Some(BackendKind::Notmuch) => {
|
Some(BackendKind::Notmuch) => {
|
||||||
backend_builder = backend_builder.with_purge_folder(|ctx| {
|
backend_builder = backend_builder.with_purge_folder(|ctx| {
|
||||||
ctx.notmuch.as_ref().and_then(PurgeFolderNotmuch::new)
|
ctx.notmuch.as_ref().and_then(PurgeFolderNotmuch::new)
|
||||||
|
@ -343,12 +341,12 @@ impl BackendBuilder {
|
||||||
.and_then(DeleteFolderMaildir::new)
|
.and_then(DeleteFolderMaildir::new)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
Some(BackendKind::Imap) => {
|
Some(BackendKind::Imap) => {
|
||||||
backend_builder = backend_builder
|
backend_builder = backend_builder
|
||||||
.with_delete_folder(|ctx| ctx.imap.as_ref().and_then(DeleteFolderImap::new));
|
.with_delete_folder(|ctx| ctx.imap.as_ref().and_then(DeleteFolderImap::new));
|
||||||
}
|
}
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch")]
|
||||||
Some(BackendKind::Notmuch) => {
|
Some(BackendKind::Notmuch) => {
|
||||||
backend_builder = backend_builder.with_delete_folder(|ctx| {
|
backend_builder = backend_builder.with_delete_folder(|ctx| {
|
||||||
ctx.notmuch.as_ref().and_then(DeleteFolderNotmuch::new)
|
ctx.notmuch.as_ref().and_then(DeleteFolderNotmuch::new)
|
||||||
|
@ -370,12 +368,12 @@ impl BackendBuilder {
|
||||||
.and_then(GetEnvelopeMaildir::new)
|
.and_then(GetEnvelopeMaildir::new)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
Some(BackendKind::Imap) => {
|
Some(BackendKind::Imap) => {
|
||||||
backend_builder = backend_builder
|
backend_builder = backend_builder
|
||||||
.with_get_envelope(|ctx| ctx.imap.as_ref().and_then(GetEnvelopeImap::new));
|
.with_get_envelope(|ctx| ctx.imap.as_ref().and_then(GetEnvelopeImap::new));
|
||||||
}
|
}
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch")]
|
||||||
Some(BackendKind::Notmuch) => {
|
Some(BackendKind::Notmuch) => {
|
||||||
backend_builder = backend_builder.with_get_envelope(|ctx| {
|
backend_builder = backend_builder.with_get_envelope(|ctx| {
|
||||||
ctx.notmuch.as_ref().and_then(GetEnvelopeNotmuch::new)
|
ctx.notmuch.as_ref().and_then(GetEnvelopeNotmuch::new)
|
||||||
|
@ -397,12 +395,12 @@ impl BackendBuilder {
|
||||||
.and_then(ListEnvelopesMaildir::new)
|
.and_then(ListEnvelopesMaildir::new)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
Some(BackendKind::Imap) => {
|
Some(BackendKind::Imap) => {
|
||||||
backend_builder = backend_builder
|
backend_builder = backend_builder
|
||||||
.with_list_envelopes(|ctx| ctx.imap.as_ref().and_then(ListEnvelopesImap::new));
|
.with_list_envelopes(|ctx| ctx.imap.as_ref().and_then(ListEnvelopesImap::new));
|
||||||
}
|
}
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch")]
|
||||||
Some(BackendKind::Notmuch) => {
|
Some(BackendKind::Notmuch) => {
|
||||||
backend_builder = backend_builder.with_list_envelopes(|ctx| {
|
backend_builder = backend_builder.with_list_envelopes(|ctx| {
|
||||||
ctx.notmuch.as_ref().and_then(ListEnvelopesNotmuch::new)
|
ctx.notmuch.as_ref().and_then(ListEnvelopesNotmuch::new)
|
||||||
|
@ -421,12 +419,12 @@ impl BackendBuilder {
|
||||||
ctx.maildir_for_sync.as_ref().and_then(AddFlagsMaildir::new)
|
ctx.maildir_for_sync.as_ref().and_then(AddFlagsMaildir::new)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
Some(BackendKind::Imap) => {
|
Some(BackendKind::Imap) => {
|
||||||
backend_builder = backend_builder
|
backend_builder = backend_builder
|
||||||
.with_add_flags(|ctx| ctx.imap.as_ref().and_then(AddFlagsImap::new));
|
.with_add_flags(|ctx| ctx.imap.as_ref().and_then(AddFlagsImap::new));
|
||||||
}
|
}
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch")]
|
||||||
Some(BackendKind::Notmuch) => {
|
Some(BackendKind::Notmuch) => {
|
||||||
backend_builder = backend_builder
|
backend_builder = backend_builder
|
||||||
.with_add_flags(|ctx| ctx.notmuch.as_ref().and_then(AddFlagsNotmuch::new));
|
.with_add_flags(|ctx| ctx.notmuch.as_ref().and_then(AddFlagsNotmuch::new));
|
||||||
|
@ -444,12 +442,12 @@ impl BackendBuilder {
|
||||||
ctx.maildir_for_sync.as_ref().and_then(SetFlagsMaildir::new)
|
ctx.maildir_for_sync.as_ref().and_then(SetFlagsMaildir::new)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
Some(BackendKind::Imap) => {
|
Some(BackendKind::Imap) => {
|
||||||
backend_builder = backend_builder
|
backend_builder = backend_builder
|
||||||
.with_set_flags(|ctx| ctx.imap.as_ref().and_then(SetFlagsImap::new));
|
.with_set_flags(|ctx| ctx.imap.as_ref().and_then(SetFlagsImap::new));
|
||||||
}
|
}
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch")]
|
||||||
Some(BackendKind::Notmuch) => {
|
Some(BackendKind::Notmuch) => {
|
||||||
backend_builder = backend_builder
|
backend_builder = backend_builder
|
||||||
.with_set_flags(|ctx| ctx.notmuch.as_ref().and_then(SetFlagsNotmuch::new));
|
.with_set_flags(|ctx| ctx.notmuch.as_ref().and_then(SetFlagsNotmuch::new));
|
||||||
|
@ -470,12 +468,12 @@ impl BackendBuilder {
|
||||||
.and_then(RemoveFlagsMaildir::new)
|
.and_then(RemoveFlagsMaildir::new)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
Some(BackendKind::Imap) => {
|
Some(BackendKind::Imap) => {
|
||||||
backend_builder = backend_builder
|
backend_builder = backend_builder
|
||||||
.with_remove_flags(|ctx| ctx.imap.as_ref().and_then(RemoveFlagsImap::new));
|
.with_remove_flags(|ctx| ctx.imap.as_ref().and_then(RemoveFlagsImap::new));
|
||||||
}
|
}
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch")]
|
||||||
Some(BackendKind::Notmuch) => {
|
Some(BackendKind::Notmuch) => {
|
||||||
backend_builder = backend_builder.with_remove_flags(|ctx| {
|
backend_builder = backend_builder.with_remove_flags(|ctx| {
|
||||||
ctx.notmuch.as_ref().and_then(RemoveFlagsNotmuch::new)
|
ctx.notmuch.as_ref().and_then(RemoveFlagsNotmuch::new)
|
||||||
|
@ -485,7 +483,7 @@ impl BackendBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
match toml_account_config.send_raw_message_kind() {
|
match toml_account_config.send_raw_message_kind() {
|
||||||
#[cfg(feature = "smtp-sender")]
|
#[cfg(feature = "smtp")]
|
||||||
Some(BackendKind::Smtp) => {
|
Some(BackendKind::Smtp) => {
|
||||||
backend_builder = backend_builder.with_send_raw_message(|ctx| {
|
backend_builder = backend_builder.with_send_raw_message(|ctx| {
|
||||||
ctx.smtp.as_ref().and_then(SendRawMessageSmtp::new)
|
ctx.smtp.as_ref().and_then(SendRawMessageSmtp::new)
|
||||||
|
@ -514,7 +512,7 @@ impl BackendBuilder {
|
||||||
.and_then(AddRawMessageWithFlagsMaildir::new)
|
.and_then(AddRawMessageWithFlagsMaildir::new)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
Some(BackendKind::Imap) => {
|
Some(BackendKind::Imap) => {
|
||||||
backend_builder = backend_builder
|
backend_builder = backend_builder
|
||||||
.with_add_raw_message(|ctx| ctx.imap.as_ref().and_then(AddRawMessageImap::new))
|
.with_add_raw_message(|ctx| ctx.imap.as_ref().and_then(AddRawMessageImap::new))
|
||||||
|
@ -522,7 +520,7 @@ impl BackendBuilder {
|
||||||
ctx.imap.as_ref().and_then(AddRawMessageWithFlagsImap::new)
|
ctx.imap.as_ref().and_then(AddRawMessageWithFlagsImap::new)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch")]
|
||||||
Some(BackendKind::Notmuch) => {
|
Some(BackendKind::Notmuch) => {
|
||||||
backend_builder = backend_builder.with_add_raw_message(|ctx| {
|
backend_builder = backend_builder.with_add_raw_message(|ctx| {
|
||||||
ctx.notmuch.as_ref().and_then(AddRawMessageNotmuch::new)
|
ctx.notmuch.as_ref().and_then(AddRawMessageNotmuch::new)
|
||||||
|
@ -544,12 +542,12 @@ impl BackendBuilder {
|
||||||
.and_then(PeekMessagesMaildir::new)
|
.and_then(PeekMessagesMaildir::new)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
Some(BackendKind::Imap) => {
|
Some(BackendKind::Imap) => {
|
||||||
backend_builder = backend_builder
|
backend_builder = backend_builder
|
||||||
.with_peek_messages(|ctx| ctx.imap.as_ref().and_then(PeekMessagesImap::new));
|
.with_peek_messages(|ctx| ctx.imap.as_ref().and_then(PeekMessagesImap::new));
|
||||||
}
|
}
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch")]
|
||||||
Some(BackendKind::Notmuch) => {
|
Some(BackendKind::Notmuch) => {
|
||||||
backend_builder = backend_builder.with_peek_messages(|ctx| {
|
backend_builder = backend_builder.with_peek_messages(|ctx| {
|
||||||
ctx.notmuch.as_ref().and_then(PeekMessagesNotmuch::new)
|
ctx.notmuch.as_ref().and_then(PeekMessagesNotmuch::new)
|
||||||
|
@ -559,12 +557,12 @@ impl BackendBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
match toml_account_config.get_messages_kind() {
|
match toml_account_config.get_messages_kind() {
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
Some(BackendKind::Imap) => {
|
Some(BackendKind::Imap) => {
|
||||||
backend_builder = backend_builder
|
backend_builder = backend_builder
|
||||||
.with_get_messages(|ctx| ctx.imap.as_ref().and_then(GetMessagesImap::new));
|
.with_get_messages(|ctx| ctx.imap.as_ref().and_then(GetMessagesImap::new));
|
||||||
}
|
}
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch")]
|
||||||
Some(BackendKind::Notmuch) => {
|
Some(BackendKind::Notmuch) => {
|
||||||
backend_builder = backend_builder.with_get_messages(|ctx| {
|
backend_builder = backend_builder.with_get_messages(|ctx| {
|
||||||
ctx.notmuch.as_ref().and_then(GetMessagesNotmuch::new)
|
ctx.notmuch.as_ref().and_then(GetMessagesNotmuch::new)
|
||||||
|
@ -586,12 +584,12 @@ impl BackendBuilder {
|
||||||
.and_then(CopyMessagesMaildir::new)
|
.and_then(CopyMessagesMaildir::new)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
Some(BackendKind::Imap) => {
|
Some(BackendKind::Imap) => {
|
||||||
backend_builder = backend_builder
|
backend_builder = backend_builder
|
||||||
.with_copy_messages(|ctx| ctx.imap.as_ref().and_then(CopyMessagesImap::new));
|
.with_copy_messages(|ctx| ctx.imap.as_ref().and_then(CopyMessagesImap::new));
|
||||||
}
|
}
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch")]
|
||||||
Some(BackendKind::Notmuch) => {
|
Some(BackendKind::Notmuch) => {
|
||||||
backend_builder = backend_builder.with_copy_messages(|ctx| {
|
backend_builder = backend_builder.with_copy_messages(|ctx| {
|
||||||
ctx.notmuch.as_ref().and_then(CopyMessagesNotmuch::new)
|
ctx.notmuch.as_ref().and_then(CopyMessagesNotmuch::new)
|
||||||
|
@ -613,12 +611,12 @@ impl BackendBuilder {
|
||||||
.and_then(MoveMessagesMaildir::new)
|
.and_then(MoveMessagesMaildir::new)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
Some(BackendKind::Imap) => {
|
Some(BackendKind::Imap) => {
|
||||||
backend_builder = backend_builder
|
backend_builder = backend_builder
|
||||||
.with_move_messages(|ctx| ctx.imap.as_ref().and_then(MoveMessagesImap::new));
|
.with_move_messages(|ctx| ctx.imap.as_ref().and_then(MoveMessagesImap::new));
|
||||||
}
|
}
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch")]
|
||||||
Some(BackendKind::Notmuch) => {
|
Some(BackendKind::Notmuch) => {
|
||||||
backend_builder = backend_builder.with_move_messages(|ctx| {
|
backend_builder = backend_builder.with_move_messages(|ctx| {
|
||||||
ctx.notmuch.as_ref().and_then(MoveMessagesNotmuch::new)
|
ctx.notmuch.as_ref().and_then(MoveMessagesNotmuch::new)
|
||||||
|
@ -696,7 +694,7 @@ impl Backend {
|
||||||
self.backend.account_config.sync_dir()?,
|
self.backend.account_config.sync_dir()?,
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch")]
|
||||||
Some(BackendKind::Notmuch) => {
|
Some(BackendKind::Notmuch) => {
|
||||||
if let Some(notmuch_config) = &self.toml_account_config.notmuch {
|
if let Some(notmuch_config) = &self.toml_account_config.notmuch {
|
||||||
id_mapper = IdMapper::new(
|
id_mapper = IdMapper::new(
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use dialoguer::Select;
|
use dialoguer::Select;
|
||||||
|
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
use crate::imap;
|
use crate::imap;
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch")]
|
||||||
use crate::notmuch;
|
use crate::notmuch;
|
||||||
#[cfg(feature = "smtp-sender")]
|
#[cfg(feature = "smtp")]
|
||||||
use crate::smtp;
|
use crate::smtp;
|
||||||
use crate::{config::wizard::THEME, maildir, sendmail};
|
use crate::{config::wizard::THEME, maildir, sendmail};
|
||||||
|
|
||||||
use super::{config::BackendConfig, BackendKind};
|
use super::{config::BackendConfig, BackendKind};
|
||||||
|
|
||||||
const DEFAULT_BACKEND_KINDS: &[BackendKind] = &[
|
const DEFAULT_BACKEND_KINDS: &[BackendKind] = &[
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
BackendKind::Imap,
|
BackendKind::Imap,
|
||||||
BackendKind::Maildir,
|
BackendKind::Maildir,
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch")]
|
||||||
BackendKind::Notmuch,
|
BackendKind::Notmuch,
|
||||||
];
|
];
|
||||||
|
|
||||||
const SEND_MESSAGE_BACKEND_KINDS: &[BackendKind] = &[
|
const SEND_MESSAGE_BACKEND_KINDS: &[BackendKind] = &[
|
||||||
#[cfg(feature = "smtp-sender")]
|
#[cfg(feature = "smtp")]
|
||||||
BackendKind::Smtp,
|
BackendKind::Smtp,
|
||||||
BackendKind::Sendmail,
|
BackendKind::Sendmail,
|
||||||
];
|
];
|
||||||
|
@ -35,11 +35,11 @@ pub(crate) async fn configure(account_name: &str, email: &str) -> Result<Option<
|
||||||
|
|
||||||
let config = match kind {
|
let config = match kind {
|
||||||
Some(kind) if kind == BackendKind::Maildir => Some(maildir::wizard::configure()?),
|
Some(kind) if kind == BackendKind::Maildir => Some(maildir::wizard::configure()?),
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
Some(kind) if kind == BackendKind::Imap => {
|
Some(kind) if kind == BackendKind::Imap => {
|
||||||
Some(imap::wizard::configure(account_name, email).await?)
|
Some(imap::wizard::configure(account_name, email).await?)
|
||||||
}
|
}
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch")]
|
||||||
Some(kind) if kind == BackendKind::Notmuch => Some(notmuch::wizard::configure()?),
|
Some(kind) if kind == BackendKind::Notmuch => Some(notmuch::wizard::configure()?),
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
|
@ -60,7 +60,7 @@ pub(crate) async fn configure_sender(
|
||||||
|
|
||||||
let config = match kind {
|
let config = match kind {
|
||||||
Some(kind) if kind == BackendKind::Sendmail => Some(sendmail::wizard::configure()?),
|
Some(kind) if kind == BackendKind::Sendmail => Some(sendmail::wizard::configure()?),
|
||||||
#[cfg(feature = "smtp-sender")]
|
#[cfg(feature = "smtp")]
|
||||||
Some(kind) if kind == BackendKind::Smtp => {
|
Some(kind) if kind == BackendKind::Smtp => {
|
||||||
Some(smtp::wizard::configure(account_name, email).await?)
|
Some(smtp::wizard::configure(account_name, email).await?)
|
||||||
}
|
}
|
||||||
|
|
2
src/cache/id_mapper.rs
vendored
2
src/cache/id_mapper.rs
vendored
|
@ -1,5 +1,5 @@
|
||||||
use anyhow::{anyhow, Context, Result};
|
use anyhow::{anyhow, Context, Result};
|
||||||
use email::account::AccountConfig;
|
use email::account::config::AccountConfig;
|
||||||
use log::{debug, trace};
|
use log::{debug, trace};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,9 @@ use anyhow::{anyhow, Context, Result};
|
||||||
use dialoguer::Confirm;
|
use dialoguer::Confirm;
|
||||||
use dirs::{config_dir, home_dir};
|
use dirs::{config_dir, home_dir};
|
||||||
use email::{
|
use email::{
|
||||||
account::AccountConfig,
|
account::config::AccountConfig,
|
||||||
config::Config,
|
config::Config,
|
||||||
email::{EmailHooks, EmailTextPlainFormat},
|
email::config::{EmailHooks, EmailTextPlainFormat},
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::{
|
use std::{
|
||||||
|
@ -184,14 +184,14 @@ impl TomlConfig {
|
||||||
.ok_or_else(|| anyhow!("cannot find account {name}")),
|
.ok_or_else(|| anyhow!("cannot find account {name}")),
|
||||||
}?;
|
}?;
|
||||||
|
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
if let Some(imap_config) = toml_account_config.imap.as_mut() {
|
if let Some(imap_config) = toml_account_config.imap.as_mut() {
|
||||||
imap_config
|
imap_config
|
||||||
.auth
|
.auth
|
||||||
.replace_undefined_keyring_entries(&account_name);
|
.replace_undefined_keyring_entries(&account_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "smtp-sender")]
|
#[cfg(feature = "smtp")]
|
||||||
if let Some(smtp_config) = toml_account_config.smtp.as_mut() {
|
if let Some(smtp_config) = toml_account_config.smtp.as_mut() {
|
||||||
smtp_config
|
smtp_config
|
||||||
.auth
|
.auth
|
||||||
|
@ -268,18 +268,17 @@ impl TomlConfig {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use email::{
|
use email::{
|
||||||
account::PasswdConfig,
|
account::config::passwd::PasswdConfig, maildir::config::MaildirConfig,
|
||||||
backend::{BackendConfig, MaildirConfig},
|
sendmail::config::SendmailConfig,
|
||||||
sender::{SenderConfig, SendmailConfig},
|
|
||||||
};
|
};
|
||||||
use secret::Secret;
|
use secret::Secret;
|
||||||
|
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch")]
|
||||||
use email::backend::NotmuchConfig;
|
use email::backend::NotmuchConfig;
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
use email::backend::{ImapAuthConfig, ImapConfig};
|
use email::imap::config::{ImapAuthConfig, ImapConfig};
|
||||||
#[cfg(feature = "smtp-sender")]
|
#[cfg(feature = "smtp")]
|
||||||
use email::sender::{SmtpAuthConfig, SmtpConfig};
|
use email::smtp::config::{SmtpAuthConfig, SmtpConfig};
|
||||||
|
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use tempfile::NamedTempFile;
|
use tempfile::NamedTempFile;
|
||||||
|
@ -435,7 +434,7 @@ mod tests {
|
||||||
.contains("missing field `maildir-root-dir`"));
|
.contains("missing field `maildir-root-dir`"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch")]
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn account_backend_notmuch_missing_db_path_field() {
|
async fn account_backend_notmuch_missing_db_path_field() {
|
||||||
let config = make_config(
|
let config = make_config(
|
||||||
|
@ -588,7 +587,7 @@ mod tests {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "smtp-sender")]
|
#[cfg(feature = "smtp")]
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn account_smtp_sender_minimum_config() {
|
async fn account_smtp_sender_minimum_config() {
|
||||||
use email::sender::SenderConfig;
|
use email::sender::SenderConfig;
|
||||||
|
@ -727,7 +726,7 @@ mod tests {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch")]
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn account_backend_notmuch_minimum_config() {
|
async fn account_backend_notmuch_minimum_config() {
|
||||||
let config = make_config(
|
let config = make_config(
|
||||||
|
|
|
@ -6,18 +6,21 @@ use email::account::GpgConfig;
|
||||||
use email::account::PgpConfig;
|
use email::account::PgpConfig;
|
||||||
#[cfg(feature = "pgp-native")]
|
#[cfg(feature = "pgp-native")]
|
||||||
use email::account::{NativePgpConfig, NativePgpSecretKey, SignedSecretKey};
|
use email::account::{NativePgpConfig, NativePgpSecretKey, SignedSecretKey};
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch")]
|
||||||
use email::backend::NotmuchConfig;
|
use email::backend::NotmuchConfig;
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
use email::imap::{ImapAuthConfig, ImapConfig};
|
use email::imap::config::{ImapAuthConfig, ImapConfig};
|
||||||
#[cfg(feature = "smtp-sender")]
|
#[cfg(feature = "smtp")]
|
||||||
use email::smtp::{SmtpAuthConfig, SmtpConfig};
|
use email::smtp::config::{SmtpAuthConfig, SmtpConfig};
|
||||||
use email::{
|
use email::{
|
||||||
account::{OAuth2Config, OAuth2Method, OAuth2Scopes, PasswdConfig},
|
account::config::{
|
||||||
email::{EmailHooks, EmailTextPlainFormat},
|
oauth2::{OAuth2Config, OAuth2Method, OAuth2Scopes},
|
||||||
|
passwd::PasswdConfig,
|
||||||
|
},
|
||||||
|
email::config::{EmailHooks, EmailTextPlainFormat},
|
||||||
folder::sync::FolderSyncStrategy,
|
folder::sync::FolderSyncStrategy,
|
||||||
maildir::MaildirConfig,
|
maildir::config::MaildirConfig,
|
||||||
sendmail::SendmailConfig,
|
sendmail::config::SendmailConfig,
|
||||||
};
|
};
|
||||||
use keyring::Entry;
|
use keyring::Entry;
|
||||||
use process::{Cmd, Pipeline, SingleCmd};
|
use process::{Cmd, Pipeline, SingleCmd};
|
||||||
|
@ -159,7 +162,7 @@ impl Into<OptionImapConfig> for Option<ImapConfig> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
||||||
#[serde(remote = "ImapConfig", rename_all = "kebab-case")]
|
#[serde(remote = "ImapConfig", rename_all = "kebab-case")]
|
||||||
pub struct ImapConfigDef {
|
pub struct ImapConfigDef {
|
||||||
|
@ -176,7 +179,7 @@ pub struct ImapConfigDef {
|
||||||
pub watch_cmds: Option<Vec<String>>,
|
pub watch_cmds: Option<Vec<String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
||||||
#[serde(remote = "ImapAuthConfig", tag = "auth")]
|
#[serde(remote = "ImapAuthConfig", tag = "auth")]
|
||||||
pub enum ImapAuthConfigDef {
|
pub enum ImapAuthConfigDef {
|
||||||
|
@ -303,7 +306,7 @@ pub struct MaildirConfigDef {
|
||||||
pub root_dir: PathBuf,
|
pub root_dir: PathBuf,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch")]
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
|
||||||
#[serde(
|
#[serde(
|
||||||
remote = "Option<NotmuchConfig>",
|
remote = "Option<NotmuchConfig>",
|
||||||
|
@ -312,7 +315,7 @@ pub struct MaildirConfigDef {
|
||||||
)]
|
)]
|
||||||
pub struct OptionNotmuchConfigDef;
|
pub struct OptionNotmuchConfigDef;
|
||||||
|
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch")]
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
|
||||||
pub struct OptionNotmuchConfig {
|
pub struct OptionNotmuchConfig {
|
||||||
#[serde(default, skip)]
|
#[serde(default, skip)]
|
||||||
|
@ -321,7 +324,7 @@ pub struct OptionNotmuchConfig {
|
||||||
inner: NotmuchConfig,
|
inner: NotmuchConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch")]
|
||||||
impl From<OptionNotmuchConfig> for Option<NotmuchConfig> {
|
impl From<OptionNotmuchConfig> for Option<NotmuchConfig> {
|
||||||
fn from(config: OptionNotmuchConfig) -> Option<NotmuchConfig> {
|
fn from(config: OptionNotmuchConfig) -> Option<NotmuchConfig> {
|
||||||
if config.is_none {
|
if config.is_none {
|
||||||
|
@ -332,7 +335,7 @@ impl From<OptionNotmuchConfig> for Option<NotmuchConfig> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch")]
|
||||||
impl Into<OptionNotmuchConfig> for Option<NotmuchConfig> {
|
impl Into<OptionNotmuchConfig> for Option<NotmuchConfig> {
|
||||||
fn into(self) -> OptionNotmuchConfig {
|
fn into(self) -> OptionNotmuchConfig {
|
||||||
match self {
|
match self {
|
||||||
|
@ -348,7 +351,7 @@ impl Into<OptionNotmuchConfig> for Option<NotmuchConfig> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch")]
|
||||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
|
||||||
#[serde(remote = "NotmuchConfig", rename_all = "kebab-case")]
|
#[serde(remote = "NotmuchConfig", rename_all = "kebab-case")]
|
||||||
pub struct NotmuchConfigDef {
|
pub struct NotmuchConfigDef {
|
||||||
|
@ -452,7 +455,7 @@ impl Into<OptionSmtpConfig> for Option<SmtpConfig> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "smtp-sender")]
|
#[cfg(feature = "smtp")]
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
||||||
#[serde(remote = "SmtpConfig")]
|
#[serde(remote = "SmtpConfig")]
|
||||||
struct SmtpConfigDef {
|
struct SmtpConfigDef {
|
||||||
|
@ -466,7 +469,7 @@ struct SmtpConfigDef {
|
||||||
pub auth: SmtpAuthConfig,
|
pub auth: SmtpAuthConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "smtp-sender")]
|
#[cfg(feature = "smtp")]
|
||||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
|
||||||
#[serde(remote = "SmtpAuthConfig", tag = "auth")]
|
#[serde(remote = "SmtpAuthConfig", tag = "auth")]
|
||||||
pub enum SmtpAuthConfigDef {
|
pub enum SmtpAuthConfigDef {
|
||||||
|
|
|
@ -128,17 +128,17 @@ pub(crate) async fn configure(path: PathBuf) -> Result<TomlConfig> {
|
||||||
});
|
});
|
||||||
|
|
||||||
set_table_dotted(item, "maildir");
|
set_table_dotted(item, "maildir");
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
{
|
{
|
||||||
set_table_dotted(item, "imap");
|
set_table_dotted(item, "imap");
|
||||||
get_table_mut(item, "imap").map(|item| {
|
get_table_mut(item, "imap").map(|item| {
|
||||||
set_tables_dotted(item, ["passwd", "oauth2"]);
|
set_tables_dotted(item, ["passwd", "oauth2"]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch")]
|
||||||
set_table_dotted(item, "notmuch");
|
set_table_dotted(item, "notmuch");
|
||||||
set_table_dotted(item, "sendmail");
|
set_table_dotted(item, "sendmail");
|
||||||
#[cfg(feature = "smtp-sender")]
|
#[cfg(feature = "smtp")]
|
||||||
{
|
{
|
||||||
set_table_dotted(item, "smtp");
|
set_table_dotted(item, "smtp");
|
||||||
get_table_mut(item, "smtp").map(|item| {
|
get_table_mut(item, "smtp").map(|item| {
|
||||||
|
|
|
@ -42,7 +42,7 @@ impl From<Iter<'_, String, TomlAccountConfig>> for Accounts {
|
||||||
.map(|(name, account)| {
|
.map(|(name, account)| {
|
||||||
let mut backends = String::new();
|
let mut backends = String::new();
|
||||||
|
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
if account.imap.is_some() {
|
if account.imap.is_some() {
|
||||||
backends.push_str("imap");
|
backends.push_str("imap");
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ impl From<Iter<'_, String, TomlAccountConfig>> for Accounts {
|
||||||
backends.push_str("maildir");
|
backends.push_str("maildir");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch")]
|
||||||
if account.imap.is_some() {
|
if account.imap.is_some() {
|
||||||
if !backends.is_empty() {
|
if !backends.is_empty() {
|
||||||
backends.push_str(", ")
|
backends.push_str(", ")
|
||||||
|
@ -62,7 +62,7 @@ impl From<Iter<'_, String, TomlAccountConfig>> for Accounts {
|
||||||
backends.push_str("notmuch");
|
backends.push_str("notmuch");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "smtp-sender")]
|
#[cfg(feature = "smtp")]
|
||||||
if account.smtp.is_some() {
|
if account.smtp.is_some() {
|
||||||
if !backends.is_empty() {
|
if !backends.is_empty() {
|
||||||
backends.push_str(", ")
|
backends.push_str(", ")
|
||||||
|
|
|
@ -5,15 +5,15 @@
|
||||||
|
|
||||||
#[cfg(feature = "pgp")]
|
#[cfg(feature = "pgp")]
|
||||||
use email::account::PgpConfig;
|
use email::account::PgpConfig;
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
use email::imap::ImapConfig;
|
use email::imap::config::ImapConfig;
|
||||||
#[cfg(feature = "smtp-sender")]
|
#[cfg(feature = "smtp")]
|
||||||
use email::smtp::SmtpConfig;
|
use email::smtp::config::SmtpConfig;
|
||||||
use email::{
|
use email::{
|
||||||
email::{EmailHooks, EmailTextPlainFormat},
|
email::config::{EmailHooks, EmailTextPlainFormat},
|
||||||
folder::sync::FolderSyncStrategy,
|
folder::sync::FolderSyncStrategy,
|
||||||
maildir::MaildirConfig,
|
maildir::config::MaildirConfig,
|
||||||
sendmail::SendmailConfig,
|
sendmail::config::SendmailConfig,
|
||||||
};
|
};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::{
|
use std::{
|
||||||
|
@ -79,7 +79,7 @@ pub struct TomlAccountConfig {
|
||||||
pub flag: Option<FlagConfig>,
|
pub flag: Option<FlagConfig>,
|
||||||
pub message: Option<MessageConfig>,
|
pub message: Option<MessageConfig>,
|
||||||
|
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
#[serde(
|
#[serde(
|
||||||
default,
|
default,
|
||||||
with = "OptionImapConfigDef",
|
with = "OptionImapConfigDef",
|
||||||
|
@ -94,7 +94,7 @@ pub struct TomlAccountConfig {
|
||||||
)]
|
)]
|
||||||
pub maildir: Option<MaildirConfig>,
|
pub maildir: Option<MaildirConfig>,
|
||||||
|
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch")]
|
||||||
#[serde(
|
#[serde(
|
||||||
default,
|
default,
|
||||||
with = "OptionNotmuchConfigDef",
|
with = "OptionNotmuchConfigDef",
|
||||||
|
@ -102,7 +102,7 @@ pub struct TomlAccountConfig {
|
||||||
)]
|
)]
|
||||||
pub notmuch: Option<NotmuchConfig>,
|
pub notmuch: Option<NotmuchConfig>,
|
||||||
|
|
||||||
#[cfg(feature = "smtp-sender")]
|
#[cfg(feature = "smtp")]
|
||||||
#[serde(
|
#[serde(
|
||||||
default,
|
default,
|
||||||
with = "OptionSmtpConfigDef",
|
with = "OptionSmtpConfigDef",
|
||||||
|
|
|
@ -4,13 +4,13 @@
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use email::account::{
|
use email::account::{
|
||||||
|
config::AccountConfig,
|
||||||
sync::{AccountSyncBuilder, AccountSyncProgressEvent},
|
sync::{AccountSyncBuilder, AccountSyncProgressEvent},
|
||||||
AccountConfig,
|
|
||||||
};
|
};
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
use email::imap::ImapAuthConfig;
|
use email::imap::config::ImapAuthConfig;
|
||||||
#[cfg(feature = "smtp-sender")]
|
#[cfg(feature = "smtp")]
|
||||||
use email::smtp::SmtpAuthConfig;
|
use email::smtp::config::SmtpAuthConfig;
|
||||||
use indicatif::{MultiProgress, ProgressBar, ProgressFinish, ProgressStyle};
|
use indicatif::{MultiProgress, ProgressBar, ProgressFinish, ProgressStyle};
|
||||||
use log::{debug, info, trace, warn};
|
use log::{debug, info, trace, warn};
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
|
@ -48,7 +48,7 @@ pub async fn configure(config: &TomlAccountConfig, reset: bool) -> Result<()> {
|
||||||
info!("entering the configure account handler");
|
info!("entering the configure account handler");
|
||||||
|
|
||||||
if reset {
|
if reset {
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
if let Some(ref config) = config.imap {
|
if let Some(ref config) = config.imap {
|
||||||
let reset = match &config.auth {
|
let reset = match &config.auth {
|
||||||
ImapAuthConfig::Passwd(config) => config.reset(),
|
ImapAuthConfig::Passwd(config) => config.reset(),
|
||||||
|
@ -60,7 +60,7 @@ pub async fn configure(config: &TomlAccountConfig, reset: bool) -> Result<()> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "smtp-sender")]
|
#[cfg(feature = "smtp")]
|
||||||
if let Some(ref config) = config.smtp {
|
if let Some(ref config) = config.smtp {
|
||||||
let reset = match &config.auth {
|
let reset = match &config.auth {
|
||||||
SmtpAuthConfig::Passwd(config) => config.reset(),
|
SmtpAuthConfig::Passwd(config) => config.reset(),
|
||||||
|
@ -78,7 +78,7 @@ pub async fn configure(config: &TomlAccountConfig, reset: bool) -> Result<()> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
if let Some(ref config) = config.imap {
|
if let Some(ref config) = config.imap {
|
||||||
match &config.auth {
|
match &config.auth {
|
||||||
ImapAuthConfig::Passwd(config) => {
|
ImapAuthConfig::Passwd(config) => {
|
||||||
|
@ -92,7 +92,7 @@ pub async fn configure(config: &TomlAccountConfig, reset: bool) -> Result<()> {
|
||||||
}?;
|
}?;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "smtp-sender")]
|
#[cfg(feature = "smtp")]
|
||||||
if let Some(ref config) = config.smtp {
|
if let Some(ref config) = config.smtp {
|
||||||
match &config.auth {
|
match &config.auth {
|
||||||
SmtpAuthConfig::Passwd(config) => {
|
SmtpAuthConfig::Passwd(config) => {
|
||||||
|
@ -299,12 +299,13 @@ pub async fn sync<P: Printer>(
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use email::{account::AccountConfig, backend::ImapConfig};
|
use email::{account::config::AccountConfig, imap::config::ImapConfig};
|
||||||
use std::{collections::HashMap, fmt::Debug, io};
|
use std::{collections::HashMap, fmt::Debug, io};
|
||||||
use termcolor::ColorSpec;
|
use termcolor::ColorSpec;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
account::TomlAccountConfig,
|
account::TomlAccountConfig,
|
||||||
|
backend::BackendKind,
|
||||||
printer::{Print, PrintTable, WriteColor},
|
printer::{Print, PrintTable, WriteColor},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -378,8 +379,9 @@ mod tests {
|
||||||
"account-1".into(),
|
"account-1".into(),
|
||||||
TomlAccountConfig {
|
TomlAccountConfig {
|
||||||
default: Some(true),
|
default: Some(true),
|
||||||
backend: BackendConfig::Imap(ImapConfig::default()),
|
backend: Some(BackendKind::Imap),
|
||||||
..TomlAccountConfig::default()
|
imap: Some(ImapConfig::default()),
|
||||||
|
..Default::default()
|
||||||
},
|
},
|
||||||
)]),
|
)]),
|
||||||
..TomlConfig::default()
|
..TomlConfig::default()
|
||||||
|
|
|
@ -40,12 +40,12 @@ pub(crate) async fn configure() -> Result<Option<(String, TomlAccountConfig)>> {
|
||||||
config.maildir = Some(mdir_config);
|
config.maildir = Some(mdir_config);
|
||||||
config.backend = Some(BackendKind::Maildir);
|
config.backend = Some(BackendKind::Maildir);
|
||||||
}
|
}
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
Some(BackendConfig::Imap(imap_config)) => {
|
Some(BackendConfig::Imap(imap_config)) => {
|
||||||
config.imap = Some(imap_config);
|
config.imap = Some(imap_config);
|
||||||
config.backend = Some(BackendKind::Imap);
|
config.backend = Some(BackendKind::Imap);
|
||||||
}
|
}
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch")]
|
||||||
Some(BackendConfig::Notmuch(notmuch_config)) => {
|
Some(BackendConfig::Notmuch(notmuch_config)) => {
|
||||||
config.notmuch = Some(notmuch_config);
|
config.notmuch = Some(notmuch_config);
|
||||||
config.backend = Some(BackendKind::Notmuch);
|
config.backend = Some(BackendKind::Notmuch);
|
||||||
|
@ -64,7 +64,7 @@ pub(crate) async fn configure() -> Result<Option<(String, TomlAccountConfig)>> {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
#[cfg(feature = "smtp-sender")]
|
#[cfg(feature = "smtp")]
|
||||||
Some(BackendConfig::Smtp(smtp_config)) => {
|
Some(BackendConfig::Smtp(smtp_config)) => {
|
||||||
config.smtp = Some(smtp_config);
|
config.smtp = Some(smtp_config);
|
||||||
config.message = Some(MessageConfig {
|
config.message = Some(MessageConfig {
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
use anyhow::{anyhow, Context, Result};
|
use anyhow::{anyhow, Context, Result};
|
||||||
use atty::Stream;
|
use atty::Stream;
|
||||||
use email::{
|
use email::{
|
||||||
account::AccountConfig,
|
account::config::AccountConfig, envelope::Id, flag::Flag, message::Message,
|
||||||
email::{envelope::Id, template::FilterParts, Flag, Message, MessageBuilder},
|
template::FilterParts,
|
||||||
};
|
};
|
||||||
use log::{debug, trace};
|
use log::{debug, trace};
|
||||||
|
use mail_builder::MessageBuilder;
|
||||||
use std::{
|
use std::{
|
||||||
fs,
|
fs,
|
||||||
io::{self, BufRead},
|
io::{self, BufRead},
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use email::account::AccountConfig;
|
use email::account::config::AccountConfig;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use std::ops;
|
use std::ops;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ impl Envelopes {
|
||||||
pub fn from_backend(
|
pub fn from_backend(
|
||||||
config: &AccountConfig,
|
config: &AccountConfig,
|
||||||
id_mapper: &IdMapper,
|
id_mapper: &IdMapper,
|
||||||
envelopes: email::email::Envelopes,
|
envelopes: email::envelope::Envelopes,
|
||||||
) -> Result<Envelopes> {
|
) -> Result<Envelopes> {
|
||||||
let envelopes = envelopes
|
let envelopes = envelopes
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -59,7 +59,7 @@ impl PrintTable for Envelopes {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use chrono::DateTime;
|
use chrono::DateTime;
|
||||||
use email::account::AccountConfig;
|
use email::account::config::AccountConfig;
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
use crate::{Envelopes, IdMapper};
|
use crate::{Envelopes, IdMapper};
|
||||||
|
@ -69,7 +69,7 @@ mod tests {
|
||||||
let config = AccountConfig::default();
|
let config = AccountConfig::default();
|
||||||
let id_mapper = IdMapper::Dummy;
|
let id_mapper = IdMapper::Dummy;
|
||||||
|
|
||||||
let envelopes = email::email::Envelopes::from_iter([email::email::Envelope {
|
let envelopes = email::envelope::Envelopes::from_iter([email::envelope::Envelope {
|
||||||
date: DateTime::parse_from_rfc3339("2023-06-15T09:42:00+04:00").unwrap(),
|
date: DateTime::parse_from_rfc3339("2023-06-15T09:42:00+04:00").unwrap(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}]);
|
}]);
|
||||||
|
@ -89,7 +89,7 @@ mod tests {
|
||||||
..AccountConfig::default()
|
..AccountConfig::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let envelopes = email::email::Envelopes::from_iter([email::email::Envelope {
|
let envelopes = email::envelope::Envelopes::from_iter([email::envelope::Envelope {
|
||||||
date: DateTime::parse_from_rfc3339("2023-06-15T09:42:00+04:00").unwrap(),
|
date: DateTime::parse_from_rfc3339("2023-06-15T09:42:00+04:00").unwrap(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}]);
|
}]);
|
||||||
|
@ -112,7 +112,7 @@ mod tests {
|
||||||
..AccountConfig::default()
|
..AccountConfig::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let envelopes = email::email::Envelopes::from_iter([email::email::Envelope {
|
let envelopes = email::envelope::Envelopes::from_iter([email::envelope::Envelope {
|
||||||
date: DateTime::parse_from_rfc3339("2023-06-15T09:42:00+04:00").unwrap(),
|
date: DateTime::parse_from_rfc3339("2023-06-15T09:42:00+04:00").unwrap(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}]);
|
}]);
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
//! This module contains the command matcher, the subcommands and the
|
//! This module contains the command matcher, the subcommands and the
|
||||||
//! arguments related to the email flag domain.
|
//! arguments related to the email flag domain.
|
||||||
|
|
||||||
use ::email::email::{Flag, Flags};
|
use ::email::flag::{Flag, Flags};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use clap::{Arg, ArgMatches, Command};
|
use clap::{Arg, ArgMatches, Command};
|
||||||
use log::{debug, info};
|
use log::{debug, info};
|
||||||
|
|
|
@ -11,9 +11,9 @@ pub enum Flag {
|
||||||
Custom(String),
|
Custom(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&email::email::Flag> for Flag {
|
impl From<&email::flag::Flag> for Flag {
|
||||||
fn from(flag: &email::email::Flag) -> Self {
|
fn from(flag: &email::flag::Flag) -> Self {
|
||||||
use email::email::Flag::*;
|
use email::flag::Flag::*;
|
||||||
match flag {
|
match flag {
|
||||||
Seen => Flag::Seen,
|
Seen => Flag::Seen,
|
||||||
Answered => Flag::Answered,
|
Answered => Flag::Answered,
|
||||||
|
|
|
@ -14,8 +14,8 @@ impl ops::Deref for Flags {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<email::email::Flags> for Flags {
|
impl From<email::flag::Flags> for Flags {
|
||||||
fn from(flags: email::email::Flags) -> Self {
|
fn from(flags: email::flag::Flags) -> Self {
|
||||||
Flags(flags.iter().map(Flag::from).collect())
|
Flags(flags.iter().map(Flag::from).collect())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use email::email::Flags;
|
use email::flag::Flags;
|
||||||
|
|
||||||
use crate::{backend::Backend, printer::Printer};
|
use crate::{backend::Backend, printer::Printer};
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use dialoguer::Confirm;
|
use dialoguer::Confirm;
|
||||||
use email::account::AccountConfig;
|
use email::account::config::AccountConfig;
|
||||||
use std::process;
|
use std::process;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use atty::Stream;
|
use atty::Stream;
|
||||||
use email::{
|
use email::{account::config::AccountConfig, flag::Flag, message::Message};
|
||||||
account::AccountConfig,
|
|
||||||
email::{Flag, Message},
|
|
||||||
};
|
|
||||||
use mml::MmlCompilerBuilder;
|
use mml::MmlCompilerBuilder;
|
||||||
use std::io::{stdin, BufRead};
|
use std::io::{stdin, BufRead};
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use dialoguer::{Confirm, Input, Password, Select};
|
use dialoguer::{Confirm, Input, Password, Select};
|
||||||
use email::{
|
use email::{
|
||||||
account::{OAuth2Config, OAuth2Method, OAuth2Scopes, PasswdConfig},
|
account::config::{
|
||||||
imap::{ImapAuthConfig, ImapConfig},
|
oauth2::{OAuth2Config, OAuth2Method, OAuth2Scopes},
|
||||||
|
passwd::PasswdConfig,
|
||||||
|
},
|
||||||
|
imap::config::{ImapAuthConfig, ImapConfig},
|
||||||
};
|
};
|
||||||
use oauth::v2_0::{AuthorizationCodeGrant, Client};
|
use oauth::v2_0::{AuthorizationCodeGrant, Client};
|
||||||
use secret::Secret;
|
use secret::Secret;
|
||||||
|
|
|
@ -3,16 +3,16 @@ pub mod cache;
|
||||||
pub mod compl;
|
pub mod compl;
|
||||||
pub mod config;
|
pub mod config;
|
||||||
pub mod domain;
|
pub mod domain;
|
||||||
#[cfg(feature = "imap-backend")]
|
#[cfg(feature = "imap")]
|
||||||
pub mod imap;
|
pub mod imap;
|
||||||
pub mod maildir;
|
pub mod maildir;
|
||||||
pub mod man;
|
pub mod man;
|
||||||
#[cfg(feature = "notmuch-backend")]
|
#[cfg(feature = "notmuch")]
|
||||||
pub mod notmuch;
|
pub mod notmuch;
|
||||||
pub mod output;
|
pub mod output;
|
||||||
pub mod printer;
|
pub mod printer;
|
||||||
pub mod sendmail;
|
pub mod sendmail;
|
||||||
#[cfg(feature = "smtp-sender")]
|
#[cfg(feature = "smtp")]
|
||||||
pub mod smtp;
|
pub mod smtp;
|
||||||
pub mod ui;
|
pub mod ui;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use dialoguer::Input;
|
use dialoguer::Input;
|
||||||
use dirs::home_dir;
|
use dirs::home_dir;
|
||||||
use email::maildir::MaildirConfig;
|
use email::maildir::config::MaildirConfig;
|
||||||
|
|
||||||
use crate::{backend::config::BackendConfig, config::wizard::THEME};
|
use crate::{backend::config::BackendConfig, config::wizard::THEME};
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use ::email::account::{sync::AccountSyncBuilder, DEFAULT_INBOX_FOLDER};
|
use ::email::account::{config::DEFAULT_INBOX_FOLDER, sync::AccountSyncBuilder};
|
||||||
use anyhow::{anyhow, Context, Result};
|
use anyhow::{anyhow, Context, Result};
|
||||||
use clap::Command;
|
use clap::Command;
|
||||||
use log::{debug, warn};
|
use log::{debug, warn};
|
||||||
|
@ -91,7 +91,7 @@ async fn main() -> Result<()> {
|
||||||
let mut printer = StdoutPrinter::try_from(&m)?;
|
let mut printer = StdoutPrinter::try_from(&m)?;
|
||||||
|
|
||||||
// FIXME
|
// FIXME
|
||||||
// #[cfg(feature = "imap-backend")]
|
// #[cfg(feature = "imap")]
|
||||||
// if let BackendConfig::Imap(imap_config) = &account_config.backend {
|
// if let BackendConfig::Imap(imap_config) = &account_config.backend {
|
||||||
// let folder = folder.unwrap_or(DEFAULT_INBOX_FOLDER);
|
// let folder = folder.unwrap_or(DEFAULT_INBOX_FOLDER);
|
||||||
// match imap::args::matches(&m)? {
|
// match imap::args::matches(&m)? {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use email::email::EmailTextPlainFormat;
|
use email::email::config::EmailTextPlainFormat;
|
||||||
use std::io;
|
use std::io;
|
||||||
use termcolor::{self, StandardStream};
|
use termcolor::{self, StandardStream};
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use dialoguer::Input;
|
use dialoguer::Input;
|
||||||
use email::sendmail::SendmailConfig;
|
use email::sendmail::config::SendmailConfig;
|
||||||
|
|
||||||
use crate::{backend::config::BackendConfig, config::wizard::THEME};
|
use crate::{backend::config::BackendConfig, config::wizard::THEME};
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use dialoguer::{Confirm, Input, Select};
|
use dialoguer::{Confirm, Input, Select};
|
||||||
use email::{
|
use email::{
|
||||||
account::{OAuth2Config, OAuth2Method, OAuth2Scopes, PasswdConfig},
|
account::config::{
|
||||||
smtp::{SmtpAuthConfig, SmtpConfig},
|
oauth2::{OAuth2Config, OAuth2Method, OAuth2Scopes},
|
||||||
|
passwd::PasswdConfig,
|
||||||
|
},
|
||||||
|
smtp::config::{SmtpAuthConfig, SmtpConfig},
|
||||||
};
|
};
|
||||||
use oauth::v2_0::{AuthorizationCodeGrant, Client};
|
use oauth::v2_0::{AuthorizationCodeGrant, Client};
|
||||||
use secret::Secret;
|
use secret::Secret;
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use email::{
|
use email::{
|
||||||
account::AccountConfig,
|
account::config::AccountConfig,
|
||||||
email::{local_draft_path, remove_local_draft, Flag, Flags},
|
email::utils::{local_draft_path, remove_local_draft},
|
||||||
|
flag::{Flag, Flags},
|
||||||
};
|
};
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use mml::MmlCompilerBuilder;
|
use mml::MmlCompilerBuilder;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
//! [builder design pattern]: https://refactoring.guru/design-patterns/builder
|
//! [builder design pattern]: https://refactoring.guru/design-patterns/builder
|
||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use email::email::EmailTextPlainFormat;
|
use email::email::config::EmailTextPlainFormat;
|
||||||
use log::trace;
|
use log::trace;
|
||||||
use termcolor::{Color, ColorSpec};
|
use termcolor::{Color, ColorSpec};
|
||||||
use terminal_size::terminal_size;
|
use terminal_size::terminal_size;
|
||||||
|
@ -267,7 +267,7 @@ where
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use email::email::EmailTextPlainFormat;
|
use email::email::config::EmailTextPlainFormat;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
Loading…
Reference in a new issue