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