meli: restructure pub use melib::* imports

pull/223/head
Manos Pitsidianakis 1 year ago
parent c5ecaceae1
commit 299c8e0f99
No known key found for this signature in database
GPG Key ID: 7729C7707F7E09D0

@ -112,7 +112,6 @@ pub use address::{Address, MessageID, References, StrBuild, StrBuilder};
pub use attachments::{Attachment, AttachmentBuilder}; pub use attachments::{Attachment, AttachmentBuilder};
pub use compose::{attachment_from_file, Draft}; pub use compose::{attachment_from_file, Draft};
pub use headers::*; pub use headers::*;
pub use mailto::*;
use smallvec::SmallVec; use smallvec::SmallVec;
use crate::{ use crate::{

@ -26,7 +26,7 @@
use std::path::PathBuf; use std::path::PathBuf;
pub use melib::thread::{SortField, SortOrder}; pub use melib::thread::{SortField, SortOrder};
use melib::uuid::Uuid; use melib::{email::mailto::Mailto, uuid::Uuid};
use crate::components::Component; use crate::components::Component;
@ -91,7 +91,7 @@ pub enum ComposeAction {
SaveDraft, SaveDraft,
ToggleSign, ToggleSign,
ToggleEncrypt, ToggleEncrypt,
Mailto(melib::Mailto), Mailto(Mailto),
} }
#[derive(Debug)] #[derive(Debug)]

@ -21,6 +21,8 @@
use std::collections::HashMap; use std::collections::HashMap;
use melib::Card;
use super::*; use super::*;
mod contact_list; mod contact_list;

@ -18,12 +18,12 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with meli. If not, see <http://www.gnu.org/licenses/>. * along with meli. If not, see <http://www.gnu.org/licenses/>.
*/ */
use std::cmp; use std::cmp;
use melib::{backends::AccountHash, CardId}; use melib::{backends::AccountHash, text_processing::TextProcessing, CardId, Draft};
use super::*; use super::*;
use crate::melib::text_processing::TextProcessing;
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
enum ViewMode { enum ViewMode {

@ -31,7 +31,8 @@ use std::{
use indexmap::IndexSet; use indexmap::IndexSet;
use melib::{ use melib::{
email::attachment_types::{ContentType, MultipartType}, email::attachment_types::{ContentType, MultipartType},
list_management, Draft, list_management, Address, AddressBook, Draft, HeaderName, SpecialUsageMailbox, SubjectPrefix,
UnixTimestamp,
}; };
use nix::sys::wait::WaitStatus; use nix::sys::wait::WaitStatus;

@ -25,7 +25,7 @@ use std::{
ops::{Deref, DerefMut}, ops::{Deref, DerefMut},
}; };
use melib::backends::EnvelopeHashBatch; use melib::{backends::EnvelopeHashBatch, Address};
use smallvec::SmallVec; use smallvec::SmallVec;
use super::*; use super::*;

@ -22,6 +22,7 @@
use std::{cmp, collections::BTreeMap, convert::TryInto, iter::FromIterator}; use std::{cmp, collections::BTreeMap, convert::TryInto, iter::FromIterator};
use indexmap::IndexSet; use indexmap::IndexSet;
use melib::{TagHash, Threads};
use super::*; use super::*;
use crate::{components::PageMovement, jobs::JoinHandle}; use crate::{components::PageMovement, jobs::JoinHandle};

@ -22,6 +22,7 @@
use std::{collections::BTreeMap, iter::FromIterator}; use std::{collections::BTreeMap, iter::FromIterator};
use indexmap::IndexSet; use indexmap::IndexSet;
use melib::{TagHash, Threads, UnixTimestamp};
use super::*; use super::*;
use crate::{components::PageMovement, jobs::JoinHandle}; use crate::{components::PageMovement, jobs::JoinHandle};

@ -21,6 +21,8 @@
use std::{cmp, iter::FromIterator}; use std::{cmp, iter::FromIterator};
use melib::{Address, ThreadNode};
use super::{EntryStrings, *}; use super::{EntryStrings, *};
use crate::{components::PageMovement, jobs::JoinHandle}; use crate::{components::PageMovement, jobs::JoinHandle};

@ -21,6 +21,8 @@
use std::{cmp, convert::TryInto, fmt::Write, iter::FromIterator}; use std::{cmp, convert::TryInto, fmt::Write, iter::FromIterator};
use melib::{ThreadNode, Threads};
use super::*; use super::*;
use crate::components::PageMovement; use crate::components::PageMovement;

@ -19,6 +19,8 @@
* along with meli. If not, see <http://www.gnu.org/licenses/>. * along with meli. If not, see <http://www.gnu.org/licenses/>.
*/ */
use melib::{MailBackendExtensionStatus, SpecialUsageMailbox};
use super::*; use super::*;
#[derive(Debug)] #[derive(Debug)]

@ -29,7 +29,8 @@ use std::{
}; };
use melib::{ use melib::{
datetime, email::attachment_types::ContentType, list_management, parser::BytesExt, HeaderName, datetime, email::attachment_types::ContentType, list_management, mailto::Mailto,
parser::BytesExt, Card, Draft, HeaderName, SpecialUsageMailbox,
}; };
use smallvec::SmallVec; use smallvec::SmallVec;
@ -46,7 +47,7 @@ pub use self::thread::*;
mod envelope; mod envelope;
use linkify::LinkFinder; use linkify::LinkFinder;
use xdg_utils::query_default_app; use melib::xdg_utils::query_default_app;
pub use self::envelope::*; pub use self::envelope::*;

@ -22,7 +22,7 @@
use std::process::{Command, Stdio}; use std::process::{Command, Stdio};
use linkify::{Link, LinkFinder}; use linkify::{Link, LinkFinder};
use xdg_utils::query_default_app; use melib::xdg_utils::query_default_app;
use super::*; use super::*;

@ -21,6 +21,8 @@
use std::cmp; use std::cmp;
use melib::UnixTimestamp;
use super::*; use super::*;
use crate::components::PageMovement; use crate::components::PageMovement;

@ -21,7 +21,8 @@
/*! Various useful components that can be used in a generic fashion. /*! Various useful components that can be used in a generic fashion.
*/ */
use text_processing::Reflow;
use melib::{text_processing::Reflow, ShellExpandTrait};
pub type AutoCompleteFn = Box<dyn Fn(&Context, &str) -> Vec<AutoCompleteEntry> + Send + Sync>; pub type AutoCompleteFn = Box<dyn Fn(&Context, &str) -> Vec<AutoCompleteEntry> + Send + Sync>;

@ -67,6 +67,7 @@ use melib::{
conf::{AccountSettings, MailboxConf, ToggleFlag}, conf::{AccountSettings, MailboxConf, ToggleFlag},
error::*, error::*,
}; };
use pager::PagerSettings;
use serde::{de, Deserialize, Deserializer, Serialize, Serializer}; use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
pub use self::{accounts::Account, composing::*, pgp::*, shortcuts::*, tags::*}; pub use self::{accounts::Account, composing::*, pgp::*, shortcuts::*, tags::*};
@ -74,7 +75,6 @@ use self::{
default_vals::*, listing::ListingSettings, notifications::NotificationsSettings, default_vals::*, listing::ListingSettings, notifications::NotificationsSettings,
terminal::TerminalSettings, terminal::TerminalSettings,
}; };
use crate::pager::PagerSettings;
#[macro_export] #[macro_export]
macro_rules! split_command { macro_rules! split_command {

@ -2396,77 +2396,82 @@ fn build_mailboxes_order(
} }
} }
#[test] #[cfg(test)]
fn test_mailbox_utf7() { mod tests {
#[derive(Debug)] use super::*;
struct TestMailbox(String);
#[test]
impl melib::BackendMailbox for TestMailbox { fn test_mailbox_utf7() {
fn hash(&self) -> MailboxHash { #[derive(Debug)]
unimplemented!() struct TestMailbox(String);
}
impl melib::BackendMailbox for TestMailbox {
fn hash(&self) -> MailboxHash {
unimplemented!()
}
fn name(&self) -> &str { fn name(&self) -> &str {
&self.0 &self.0
} }
fn path(&self) -> &str { fn path(&self) -> &str {
&self.0 &self.0
} }
fn children(&self) -> &[MailboxHash] { fn children(&self) -> &[MailboxHash] {
unimplemented!() unimplemented!()
} }
fn clone(&self) -> Mailbox { fn clone(&self) -> Mailbox {
unimplemented!() unimplemented!()
} }
fn special_usage(&self) -> SpecialUsageMailbox { fn special_usage(&self) -> SpecialUsageMailbox {
unimplemented!() unimplemented!()
} }
fn parent(&self) -> Option<MailboxHash> { fn parent(&self) -> Option<MailboxHash> {
unimplemented!() unimplemented!()
} }
fn permissions(&self) -> MailboxPermissions { fn permissions(&self) -> MailboxPermissions {
unimplemented!() unimplemented!()
} }
fn is_subscribed(&self) -> bool { fn is_subscribed(&self) -> bool {
unimplemented!() unimplemented!()
} }
fn set_is_subscribed(&mut self, _: bool) -> Result<()> { fn set_is_subscribed(&mut self, _: bool) -> Result<()> {
unimplemented!() unimplemented!()
} }
fn set_special_usage(&mut self, _: SpecialUsageMailbox) -> Result<()> { fn set_special_usage(&mut self, _: SpecialUsageMailbox) -> Result<()> {
unimplemented!() unimplemented!()
} }
fn count(&self) -> Result<(usize, usize)> { fn count(&self) -> Result<(usize, usize)> {
unimplemented!() unimplemented!()
}
}
for (n, d) in [
("~peter/mail/&U,BTFw-/&ZeVnLIqe-", "~peter/mail/台北/日本語"),
("&BB4EQgQ,BEAEMAQyBDsENQQ9BD0ESwQ1-", "Отправленные"),
] {
let ref_mbox = TestMailbox(n.to_string());
let mut conf: melib::MailboxConf = Default::default();
conf.extra.insert("encoding".to_string(), "utf7".into());
let entry = MailboxEntry::new(
MailboxStatus::None,
n.to_string(),
Box::new(ref_mbox),
FileMailboxConf {
mailbox_conf: conf,
..Default::default()
},
);
assert_eq!(&entry.path, d);
} }
}
for (n, d) in [
("~peter/mail/&U,BTFw-/&ZeVnLIqe-", "~peter/mail/台北/日本語"),
("&BB4EQgQ,BEAEMAQyBDsENQQ9BD0ESwQ1-", "Отправленные"),
] {
let ref_mbox = TestMailbox(n.to_string());
let mut conf: melib::MailboxConf = Default::default();
conf.extra.insert("encoding".to_string(), "utf7".into());
let entry = MailboxEntry::new(
MailboxStatus::None,
n.to_string(),
Box::new(ref_mbox),
FileMailboxConf {
mailbox_conf: conf,
..Default::default()
},
);
assert_eq!(&entry.path, d);
} }
} }

@ -48,8 +48,11 @@ pub use structopt::StructOpt;
static GLOBAL: System = System; static GLOBAL: System = System;
#[macro_use] #[macro_use]
extern crate melib; pub extern crate melib;
pub use melib::*; pub use melib::{
error::*, log, AccountHash, Envelope, EnvelopeHash, EnvelopeRef, Flag, LogLevel, Mail, Mailbox,
MailboxHash, ThreadHash, ToggleFlag,
};
#[macro_use] #[macro_use]
pub mod types; pub mod types;
@ -71,7 +74,9 @@ pub use crate::components::*;
#[macro_use] #[macro_use]
pub mod conf; pub mod conf;
pub use crate::conf::*; pub use crate::conf::{
Account, DotAddressable, IndexStyle, SearchBackend, Settings, Shortcuts, ThemeAttribute,
};
#[cfg(feature = "sqlite3")] #[cfg(feature = "sqlite3")]
pub mod sqlite3; pub mod sqlite3;

@ -324,7 +324,9 @@ fn run_app(opt: Opt) -> Result<()> {
recv(receiver) -> r => { recv(receiver) -> r => {
match r { match r {
Ok(ThreadEvent::Pulse) | Ok(ThreadEvent::UIEvent(UIEvent::Timer(_))) => {}, Ok(ThreadEvent::Pulse) | Ok(ThreadEvent::UIEvent(UIEvent::Timer(_))) => {},
_ => {debug!(&r);} _ => {
log::debug!("{:?}", &r);
}
} }
match r.unwrap() { match r.unwrap() {
ThreadEvent::Input((Key::Ctrl('z'), _)) if state.mode != UIMode::Embed => { ThreadEvent::Input((Key::Ctrl('z'), _)) if state.mode != UIMode::Embed => {
@ -424,7 +426,7 @@ fn run_app(opt: Opt) -> Result<()> {
state.redraw(); state.redraw();
}, },
ThreadEvent::JobFinished(id) => { ThreadEvent::JobFinished(id) => {
debug!("Job finished {}", id); log::debug!("Job finished {}", id);
for account in state.context.accounts.values_mut() { for account in state.context.accounts.values_mut() {
if account.process_event(&id) { if account.process_event(&id) {
break; break;
@ -449,7 +451,7 @@ fn run_app(opt: Opt) -> Result<()> {
} }
other => { other => {
debug!("got other signal: {:?}", other); log::debug!("got other signal: {:?}", other);
} }
} }
}, },

@ -33,7 +33,10 @@ use std::{env, os::unix::io::RawFd, sync::Arc, thread};
use crossbeam::channel::{unbounded, Receiver, Sender}; use crossbeam::channel::{unbounded, Receiver, Sender};
use indexmap::IndexMap; use indexmap::IndexMap;
//use crate::plugins::PluginManager; //use crate::plugins::PluginManager;
use melib::backends::{AccountHash, BackendEventConsumer}; use melib::{
backends::{AccountHash, BackendEvent, BackendEventConsumer, Backends, RefreshEvent},
UnixTimestamp,
};
use smallvec::SmallVec; use smallvec::SmallVec;
use super::*; use super::*;
@ -177,7 +180,7 @@ impl Context {
let settings = Box::new(Settings::new().unwrap()); let settings = Box::new(Settings::new().unwrap());
let accounts = vec![{ let accounts = vec![{
let name = "test".to_string(); let name = "test".to_string();
let mut account_conf = AccountConf::default(); let mut account_conf = crate::conf::AccountConf::default();
account_conf.conf.format = "maildir".to_string(); account_conf.conf.format = "maildir".to_string();
account_conf.account.format = "maildir".to_string(); account_conf.account.format = "maildir".to_string();
account_conf.account.root_mailbox = dir.path().display().to_string(); account_conf.account.root_mailbox = dir.path().display().to_string();

@ -433,7 +433,9 @@ fn main() -> std::io::Result<()> {
recv(receiver) -> r => { recv(receiver) -> r => {
match r { match r {
Ok(ThreadEvent::Pulse) | Ok(ThreadEvent::UIEvent(UIEvent::Timer(_))) => {}, Ok(ThreadEvent::Pulse) | Ok(ThreadEvent::UIEvent(UIEvent::Timer(_))) => {},
_ => {debug!(&r);} _ => {
log::debug!("{:?}", &r);
}
} }
match r.unwrap() { match r.unwrap() {
ThreadEvent::Input((Key::Ctrl('z'), _)) if state.mode != UIMode::Embed => { ThreadEvent::Input((Key::Ctrl('z'), _)) if state.mode != UIMode::Embed => {
@ -528,7 +530,7 @@ fn main() -> std::io::Result<()> {
state.redraw(); state.redraw();
}, },
ThreadEvent::JobFinished(id) => { ThreadEvent::JobFinished(id) => {
debug!("Job finished {}", id); log::debug!("Job finished {}", id);
for account in state.context.accounts.values_mut() { for account in state.context.accounts.values_mut() {
if account.process_event(&id) { if account.process_event(&id) {
break; break;
@ -553,7 +555,7 @@ fn main() -> std::io::Result<()> {
} }
other => { other => {
debug!("got other signal: {:?}", other); log::debug!("got other signal: {:?}", other);
} }
} }
}, },

Loading…
Cancel
Save