parent
8c98d3a5a0
commit
0092496632
|
@ -54,13 +54,13 @@ impl Folder {
|
|||
children: children,
|
||||
}
|
||||
}
|
||||
pub fn get_path(&self) -> &str {
|
||||
pub fn path(&self) -> &str {
|
||||
&self.path
|
||||
}
|
||||
pub fn get_name(&self) -> &str {
|
||||
pub fn name(&self) -> &str {
|
||||
&self.name
|
||||
}
|
||||
pub fn get_children(&self) -> &Vec<usize> {
|
||||
pub fn children(&self) -> &Vec<usize> {
|
||||
&self.children
|
||||
}
|
||||
}
|
||||
|
@ -91,10 +91,10 @@ pub struct AccountSettings {
|
|||
}
|
||||
|
||||
impl AccountSettings {
|
||||
pub fn get_format(&self) -> &str {
|
||||
pub fn format(&self) -> &str {
|
||||
&self.format
|
||||
}
|
||||
pub fn get_name(&self) -> &str {
|
||||
pub fn name(&self) -> &str {
|
||||
&self.name
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,12 +41,12 @@ impl Account {
|
|||
let sent_folder = settings
|
||||
.folders
|
||||
.iter()
|
||||
.position(|x| *x.get_path() == settings.sent_folder);
|
||||
.position(|x| *x.path() == settings.sent_folder);
|
||||
let mut folders = Vec::with_capacity(settings.folders.len());
|
||||
for _ in 0..settings.folders.len() {
|
||||
folders.push(None);
|
||||
}
|
||||
let backend = backends.get(settings.get_format());
|
||||
let backend = backends.get(settings.format());
|
||||
Account {
|
||||
name: name,
|
||||
folders: folders,
|
||||
|
@ -67,7 +67,7 @@ impl Account {
|
|||
pub fn list_folders(&self) -> Vec<Folder> {
|
||||
self.settings.folders.clone()
|
||||
}
|
||||
pub fn get_name(&self) -> &str {
|
||||
pub fn name(&self) -> &str {
|
||||
&self.name
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ impl IndexMut<usize> for Account {
|
|||
fn index_mut(&mut self, index: usize) -> &mut Option<Result<Mailbox>> {
|
||||
if self.folders[index].is_none() {
|
||||
let folder = &self.settings.folders[index];
|
||||
let path = folder.get_path().clone();
|
||||
let path = folder.path().clone();
|
||||
if self.sent_folder.is_some() {
|
||||
let id = self.sent_folder.unwrap();
|
||||
if id == index {
|
||||
|
|
|
@ -124,7 +124,7 @@ pub struct MaildirType {
|
|||
|
||||
impl MailBackend for MaildirType {
|
||||
fn get(&self, folder: &Folder) -> Result<Vec<Envelope>> {
|
||||
self.get_multicore(4, folder)
|
||||
self.multicore(4, folder)
|
||||
}
|
||||
fn watch(&self, sender: RefreshEventConsumer, folders: &[Folder]) -> () {
|
||||
let folders = folders.to_vec();
|
||||
|
@ -136,7 +136,7 @@ impl MailBackend for MaildirType {
|
|||
if MaildirType::is_valid(&f).is_err() {
|
||||
continue;
|
||||
}
|
||||
let mut p = PathBuf::from(&f.get_path());
|
||||
let mut p = PathBuf::from(&f.path());
|
||||
p.push("cur");
|
||||
watcher.watch(&p, RecursiveMode::NonRecursive).unwrap();
|
||||
p.pop();
|
||||
|
@ -167,7 +167,7 @@ impl MaildirType {
|
|||
}
|
||||
}
|
||||
fn is_valid(f: &Folder) -> Result<()> {
|
||||
let path = f.get_path();
|
||||
let path = f.path();
|
||||
let mut p = PathBuf::from(path);
|
||||
for d in &["cur", "new", "tmp"] {
|
||||
p.push(d);
|
||||
|
@ -180,9 +180,9 @@ impl MaildirType {
|
|||
}
|
||||
Ok(())
|
||||
}
|
||||
pub fn get_multicore(&self, cores: usize, folder: &Folder) -> Result<Vec<Envelope>> {
|
||||
pub fn multicore(&self, cores: usize, folder: &Folder) -> Result<Vec<Envelope>> {
|
||||
MaildirType::is_valid(folder)?;
|
||||
let path = folder.get_path();
|
||||
let path = folder.path();
|
||||
let mut path = PathBuf::from(path);
|
||||
path.push("cur");
|
||||
let iter = path.read_dir()?;
|
||||
|
@ -209,7 +209,7 @@ impl MaildirType {
|
|||
let mut local_r: Vec<Envelope> = Vec::with_capacity(chunk.len());
|
||||
for e in chunk {
|
||||
let e_copy = e.to_string();
|
||||
if let Some(mut e) = Envelope::from(Box::new(BackendOpGenerator::new(
|
||||
if let Some(mut e) = Envelope::from_token(Box::new(BackendOpGenerator::new(
|
||||
Box::new(move || Box::new(MaildirOp::new(e_copy.clone()))),
|
||||
))) {
|
||||
e.populate_headers();
|
||||
|
|
|
@ -275,7 +275,7 @@ impl Attachment {
|
|||
fn get_text_recursive(&self, text: &mut String) {
|
||||
match self.attachment_type {
|
||||
AttachmentType::Data { .. } => {
|
||||
text.push_str(&format!("Data attachment of type {}", self.get_tag()));
|
||||
text.push_str(&format!("Data attachment of type {}", self.tag()));
|
||||
}
|
||||
AttachmentType::Text { content: ref t } => {
|
||||
text.push_str(t);
|
||||
|
@ -298,19 +298,19 @@ impl Attachment {
|
|||
},
|
||||
}
|
||||
}
|
||||
pub fn get_text(&self) -> String {
|
||||
pub fn text(&self) -> String {
|
||||
let mut text = String::with_capacity(self.raw.len());
|
||||
self.get_text_recursive(&mut text);
|
||||
text
|
||||
}
|
||||
pub fn get_description(&self) -> String {
|
||||
pub fn description(&self) -> String {
|
||||
unimplemented!()
|
||||
}
|
||||
pub fn get_tag(&self) -> String {
|
||||
pub fn tag(&self) -> String {
|
||||
format!("{}/{}", self.content_type.0, self.content_type.1).to_string()
|
||||
}
|
||||
pub fn count_attachments(&mut self) -> usize {
|
||||
let mut counter = 0;
|
||||
let mut counter = 0;
|
||||
|
||||
fn count_recursive(att: &Attachment, counter: &mut usize) {
|
||||
match att.attachment_type {
|
||||
|
|
|
@ -46,9 +46,9 @@ pub trait StrBuild {
|
|||
/// Create a new `Self` out of a string and a slice
|
||||
fn new(string: &str, slice: &str) -> Self;
|
||||
/// Get the slice part of the string
|
||||
fn get_raw(&self) -> &str;
|
||||
fn raw(&self) -> &str;
|
||||
/// Get the entire string as a slice
|
||||
fn get_val(&self) -> &str;
|
||||
fn val(&self) -> &str;
|
||||
}
|
||||
|
||||
/// `MessageID` is accessed through the `StrBuild` trait.
|
||||
|
@ -64,14 +64,14 @@ impl StrBuild for MessageID {
|
|||
offset: offset,
|
||||
length: slice.len() + 1,
|
||||
},
|
||||
)
|
||||
)
|
||||
}
|
||||
fn get_raw(&self) -> &str {
|
||||
fn raw(&self) -> &str {
|
||||
let offset = self.1.offset;
|
||||
let length = self.1.length;
|
||||
&self.0[offset..length]
|
||||
}
|
||||
fn get_val(&self) -> &str {
|
||||
fn val(&self) -> &str {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
@ -88,18 +88,18 @@ fn test_strbuilder() {
|
|||
offset: 1,
|
||||
length: 43,
|
||||
}
|
||||
)
|
||||
);
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
impl PartialEq for MessageID {
|
||||
fn eq(&self, other: &MessageID) -> bool {
|
||||
self.get_raw() == other.get_raw()
|
||||
self.raw() == other.raw()
|
||||
}
|
||||
}
|
||||
impl fmt::Debug for MessageID {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}", self.get_raw())
|
||||
write!(f, "{}", self.raw())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ bitflags! {
|
|||
|
||||
/// `Envelope` represents all the data of an email we need to know.
|
||||
///
|
||||
/// Attachments (the email's body) is parsed on demand with `get_body`.
|
||||
/// Attachments (the email's body) is parsed on demand with `body`.
|
||||
///
|
||||
/// Access to the underlying email object in the account's backend (for example the file or the
|
||||
/// entry in an IMAP server) is given through `operation_token`. For more information see
|
||||
|
@ -171,7 +171,7 @@ impl Envelope {
|
|||
flags: Flag::default(),
|
||||
}
|
||||
}
|
||||
pub fn from(operation_token: Box<BackendOpGenerator>) -> Option<Envelope> {
|
||||
pub fn from_token(operation_token: Box<BackendOpGenerator>) -> Option<Envelope> {
|
||||
let operation = operation_token.generate();
|
||||
let mut e = Envelope::new(operation_token);
|
||||
e.flags = operation.fetch_flags();
|
||||
|
@ -243,7 +243,7 @@ impl Envelope {
|
|||
/*
|
||||
* https://tools.ietf.org/html/rfc5322#section-3.6.4
|
||||
*
|
||||
* if self.message_id.is_none() { ...
|
||||
* if self.message_id.is_none() ...
|
||||
*/
|
||||
if let Some(ref mut x) = in_reply_to {
|
||||
self.push_references(x);
|
||||
|
@ -254,200 +254,200 @@ if let Some(ref mut d) = datetime {
|
|||
}
|
||||
}
|
||||
}
|
||||
pub fn get_date(&self) -> i64 {
|
||||
self.timestamp
|
||||
pub fn date(&self) -> i64 {
|
||||
self.timestamp
|
||||
}
|
||||
pub fn datetime(&self) -> chrono::DateTime<chrono::FixedOffset> {
|
||||
self.datetime.unwrap_or_else(|| {
|
||||
chrono::FixedOffset::west(0)
|
||||
.ymd(1970, 1, 1)
|
||||
.and_hms(0, 0, 0)
|
||||
})
|
||||
}
|
||||
pub fn date_as_str(&self) -> &str {
|
||||
&self.date
|
||||
}
|
||||
pub fn from(&self) -> &str {
|
||||
match self.from {
|
||||
Some(ref s) => s,
|
||||
None => "",
|
||||
}
|
||||
pub fn get_datetime(&self) -> chrono::DateTime<chrono::FixedOffset> {
|
||||
self.datetime.unwrap_or_else(|| {
|
||||
chrono::FixedOffset::west(0)
|
||||
.ymd(1970, 1, 1)
|
||||
.and_hms(0, 0, 0)
|
||||
})
|
||||
}
|
||||
pub fn to(&self) -> &str {
|
||||
match self.to {
|
||||
Some(ref s) => s,
|
||||
None => "",
|
||||
}
|
||||
pub fn get_date_as_str(&self) -> &str {
|
||||
&self.date
|
||||
}
|
||||
pub fn get_from(&self) -> &str {
|
||||
match self.from {
|
||||
Some(ref s) => s,
|
||||
None => "",
|
||||
}
|
||||
pub fn body(&self) -> Attachment {
|
||||
let mut operation = self.operation_token.generate();
|
||||
let file = operation.as_bytes();
|
||||
let (headers, body) = match parser::mail(file.unwrap()).to_full_result() {
|
||||
Ok(v) => v,
|
||||
Err(_) => {
|
||||
let operation = self.operation_token.generate();
|
||||
eprintln!("error in parsing mail\n{}", operation.description());
|
||||
panic!()
|
||||
}
|
||||
};
|
||||
let mut builder = AttachmentBuilder::new(body);
|
||||
for (name, value) in headers {
|
||||
if value.len() == 1 && value.is_empty() {
|
||||
continue;
|
||||
}
|
||||
if name.eq_ignore_ascii_case("content-transfer-encoding") {
|
||||
builder.content_transfer_encoding(value);
|
||||
} else if name.eq_ignore_ascii_case("content-type") {
|
||||
builder.content_type(value);
|
||||
}
|
||||
}
|
||||
pub fn get_to(&self) -> &str {
|
||||
match self.to {
|
||||
Some(ref s) => s,
|
||||
None => "",
|
||||
builder.build()
|
||||
}
|
||||
pub fn subject(&self) -> &str {
|
||||
match self.subject {
|
||||
Some(ref s) => s,
|
||||
_ => "",
|
||||
}
|
||||
}
|
||||
pub fn in_reply_to(&self) -> &str {
|
||||
match self.in_reply_to {
|
||||
Some(ref s) => s.val(),
|
||||
_ => "",
|
||||
}
|
||||
}
|
||||
pub fn in_reply_to_raw(&self) -> &str {
|
||||
match self.in_reply_to {
|
||||
Some(ref s) => s.raw(),
|
||||
_ => "",
|
||||
}
|
||||
}
|
||||
pub fn message_id(&self) -> &str {
|
||||
match self.message_id {
|
||||
Some(ref s) => s.val(),
|
||||
_ => "",
|
||||
}
|
||||
}
|
||||
pub fn message_id_raw(&self) -> &str {
|
||||
match self.message_id {
|
||||
Some(ref s) => s.raw(),
|
||||
_ => "",
|
||||
}
|
||||
}
|
||||
fn set_date(&mut self, new_val: String) -> () {
|
||||
self.date = new_val;
|
||||
}
|
||||
fn set_from(&mut self, new_val: String) -> () {
|
||||
self.from = Some(new_val);
|
||||
}
|
||||
fn set_to(&mut self, new_val: String) -> () {
|
||||
self.to = Some(new_val);
|
||||
}
|
||||
fn set_in_reply_to(&mut self, new_val: &str) -> () {
|
||||
let slice = match parser::message_id(new_val.as_bytes()).to_full_result() {
|
||||
Ok(v) => v,
|
||||
Err(v) => {
|
||||
self.in_reply_to = None;
|
||||
return;
|
||||
}
|
||||
}
|
||||
pub fn get_body(&self) -> Attachment {
|
||||
let mut operation = self.operation_token.generate();
|
||||
let file = operation.as_bytes();
|
||||
let (headers, body) = match parser::mail(file.unwrap()).to_full_result() {
|
||||
Ok(v) => v,
|
||||
Err(_) => {
|
||||
let operation = self.operation_token.generate();
|
||||
eprintln!("error in parsing mail\n{}", operation.description());
|
||||
panic!()
|
||||
}
|
||||
};
|
||||
let mut builder = AttachmentBuilder::new(body);
|
||||
for (name, value) in headers {
|
||||
if value.len() == 1 && value.is_empty() {
|
||||
continue;
|
||||
}
|
||||
if name.eq_ignore_ascii_case("content-transfer-encoding") {
|
||||
builder.content_transfer_encoding(value);
|
||||
} else if name.eq_ignore_ascii_case("content-type") {
|
||||
builder.content_type(value);
|
||||
}
|
||||
};
|
||||
self.in_reply_to = Some(MessageID::new(new_val, slice));
|
||||
}
|
||||
fn set_subject(&mut self, new_val: String) -> () {
|
||||
self.subject = Some(new_val);
|
||||
}
|
||||
fn set_message_id(&mut self, new_val: &str) -> () {
|
||||
let slice = match parser::message_id(new_val.as_bytes()).to_full_result() {
|
||||
Ok(v) => v,
|
||||
Err(v) => {
|
||||
self.message_id = None;
|
||||
return;
|
||||
}
|
||||
builder.build()
|
||||
}
|
||||
pub fn get_subject(&self) -> &str {
|
||||
match self.subject {
|
||||
Some(ref s) => s,
|
||||
_ => "",
|
||||
};
|
||||
self.message_id = Some(MessageID::new(new_val, slice));
|
||||
}
|
||||
fn push_references(&mut self, new_val: &str) -> () {
|
||||
let slice = match parser::message_id(new_val.as_bytes()).to_full_result() {
|
||||
Ok(v) => v,
|
||||
Err(v) => {
|
||||
return;
|
||||
}
|
||||
}
|
||||
pub fn get_in_reply_to(&self) -> &str {
|
||||
match self.in_reply_to {
|
||||
Some(ref s) => s.get_val(),
|
||||
_ => "",
|
||||
}
|
||||
}
|
||||
pub fn get_in_reply_to_raw(&self) -> &str {
|
||||
match self.in_reply_to {
|
||||
Some(ref s) => s.get_raw(),
|
||||
_ => "",
|
||||
}
|
||||
}
|
||||
pub fn get_message_id(&self) -> &str {
|
||||
match self.message_id {
|
||||
Some(ref s) => s.get_val(),
|
||||
_ => "",
|
||||
}
|
||||
}
|
||||
pub fn get_message_id_raw(&self) -> &str {
|
||||
match self.message_id {
|
||||
Some(ref s) => s.get_raw(),
|
||||
_ => "",
|
||||
}
|
||||
}
|
||||
fn set_date(&mut self, new_val: String) -> () {
|
||||
self.date = new_val;
|
||||
}
|
||||
fn set_from(&mut self, new_val: String) -> () {
|
||||
self.from = Some(new_val);
|
||||
}
|
||||
fn set_to(&mut self, new_val: String) -> () {
|
||||
self.to = Some(new_val);
|
||||
}
|
||||
fn set_in_reply_to(&mut self, new_val: &str) -> () {
|
||||
let slice = match parser::message_id(new_val.as_bytes()).to_full_result() {
|
||||
Ok(v) => v,
|
||||
Err(v) => {
|
||||
self.in_reply_to = None;
|
||||
return;
|
||||
}
|
||||
};
|
||||
self.in_reply_to = Some(MessageID::new(new_val, slice));
|
||||
}
|
||||
fn set_subject(&mut self, new_val: String) -> () {
|
||||
self.subject = Some(new_val);
|
||||
}
|
||||
fn set_message_id(&mut self, new_val: &str) -> () {
|
||||
let slice = match parser::message_id(new_val.as_bytes()).to_full_result() {
|
||||
Ok(v) => v,
|
||||
Err(v) => {
|
||||
self.message_id = None;
|
||||
return;
|
||||
}
|
||||
};
|
||||
self.message_id = Some(MessageID::new(new_val, slice));
|
||||
}
|
||||
fn push_references(&mut self, new_val: &str) -> () {
|
||||
let slice = match parser::message_id(new_val.as_bytes()).to_full_result() {
|
||||
Ok(v) => v,
|
||||
Err(v) => {
|
||||
return;
|
||||
}
|
||||
};
|
||||
let new_ref = MessageID::new(new_val, slice);
|
||||
match self.references {
|
||||
Some(ref mut s) => {
|
||||
if s.refs.contains(&new_ref) {
|
||||
if s.refs[s.refs.len() - 1] != new_ref {
|
||||
if let Some(index) = s.refs.iter().position(|x| *x == new_ref) {
|
||||
s.refs.remove(index);
|
||||
} else {
|
||||
panic!();
|
||||
}
|
||||
};
|
||||
let new_ref = MessageID::new(new_val, slice);
|
||||
match self.references {
|
||||
Some(ref mut s) => {
|
||||
if s.refs.contains(&new_ref) {
|
||||
if s.refs[s.refs.len() - 1] != new_ref {
|
||||
if let Some(index) = s.refs.iter().position(|x| *x == new_ref) {
|
||||
s.refs.remove(index);
|
||||
} else {
|
||||
return;
|
||||
panic!();
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
s.refs.push(new_ref);
|
||||
}
|
||||
None => {
|
||||
let mut v = Vec::new();
|
||||
v.push(new_ref);
|
||||
self.references = Some(References {
|
||||
raw: "".to_string(),
|
||||
refs: v,
|
||||
});
|
||||
}
|
||||
s.refs.push(new_ref);
|
||||
}
|
||||
None => {
|
||||
let mut v = Vec::new();
|
||||
v.push(new_ref);
|
||||
self.references = Some(References {
|
||||
raw: "".to_string(),
|
||||
refs: v,
|
||||
});
|
||||
}
|
||||
}
|
||||
fn set_references(&mut self, new_val: String) -> () {
|
||||
match self.references {
|
||||
Some(ref mut s) => {
|
||||
s.raw = new_val;
|
||||
}
|
||||
None => {
|
||||
let v = Vec::new();
|
||||
self.references = Some(References {
|
||||
raw: new_val,
|
||||
refs: v,
|
||||
});
|
||||
}
|
||||
}
|
||||
fn set_references(&mut self, new_val: String) -> () {
|
||||
match self.references {
|
||||
Some(ref mut s) => {
|
||||
s.raw = new_val;
|
||||
}
|
||||
None => {
|
||||
let v = Vec::new();
|
||||
self.references = Some(References {
|
||||
raw: new_val,
|
||||
refs: v,
|
||||
});
|
||||
}
|
||||
}
|
||||
pub fn get_references(&self) -> Vec<&MessageID> {
|
||||
match self.references {
|
||||
Some(ref s) => s.refs
|
||||
.iter()
|
||||
.fold(Vec::with_capacity(s.refs.len()), |mut acc, x| {
|
||||
acc.push(x);
|
||||
acc
|
||||
}),
|
||||
None => Vec::new(),
|
||||
}
|
||||
}
|
||||
pub fn set_body(&mut self, new_val: Attachment) -> () {
|
||||
self.body = Some(new_val);
|
||||
}
|
||||
pub fn get_thread(&self) -> usize {
|
||||
self.thread
|
||||
}
|
||||
pub fn set_thread(&mut self, new_val: usize) -> () {
|
||||
self.thread = new_val;
|
||||
}
|
||||
pub fn set_datetime(&mut self, new_val: chrono::DateTime<chrono::FixedOffset>) -> () {
|
||||
self.datetime = Some(new_val);
|
||||
self.timestamp = new_val.timestamp();
|
||||
}
|
||||
pub fn get_flags(&self) -> Flag {
|
||||
self.flags
|
||||
}
|
||||
pub fn is_seen(&self) -> bool {
|
||||
!(self.flags & Flag::SEEN).is_empty()
|
||||
}
|
||||
pub fn references(&self) -> Vec<&MessageID> {
|
||||
match self.references {
|
||||
Some(ref s) => s.refs
|
||||
.iter()
|
||||
.fold(Vec::with_capacity(s.refs.len()), |mut acc, x| {
|
||||
acc.push(x);
|
||||
acc
|
||||
}),
|
||||
None => Vec::new(),
|
||||
}
|
||||
}
|
||||
pub fn set_body(&mut self, new_val: Attachment) -> () {
|
||||
self.body = Some(new_val);
|
||||
}
|
||||
pub fn thread(&self) -> usize {
|
||||
self.thread
|
||||
}
|
||||
pub fn set_thread(&mut self, new_val: usize) -> () {
|
||||
self.thread = new_val;
|
||||
}
|
||||
pub fn set_datetime(&mut self, new_val: chrono::DateTime<chrono::FixedOffset>) -> () {
|
||||
self.datetime = Some(new_val);
|
||||
self.timestamp = new_val.timestamp();
|
||||
}
|
||||
pub fn flags(&self) -> Flag {
|
||||
self.flags
|
||||
}
|
||||
pub fn is_seen(&self) -> bool {
|
||||
!(self.flags & Flag::SEEN).is_empty()
|
||||
}
|
||||
}
|
||||
|
||||
impl Eq for Envelope {}
|
||||
impl Ord for Envelope {
|
||||
fn cmp(&self, other: &Envelope) -> Ordering {
|
||||
self.get_datetime().cmp(&other.get_datetime())
|
||||
self.datetime().cmp(&other.datetime())
|
||||
}
|
||||
}
|
||||
impl PartialOrd for Envelope {
|
||||
|
@ -458,6 +458,6 @@ impl PartialOrd for Envelope {
|
|||
|
||||
impl PartialEq for Envelope {
|
||||
fn eq(&self, other: &Envelope) -> bool {
|
||||
self.get_message_id_raw() == other.get_message_id_raw()
|
||||
self.message_id_raw() == other.message_id_raw()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -178,7 +178,7 @@ fn encoded_word(input: &[u8]) -> IResult<&[u8], Vec<u8>> {
|
|||
Ok(v) => v,
|
||||
Err(_) => encoded.to_vec(),
|
||||
},
|
||||
b'q' | b'Q' => match get_quoted_printed_bytes(encoded) {
|
||||
b'q' | b'Q' => match quoted_printed_bytes(encoded) {
|
||||
IResult::Done(b"", s) => s,
|
||||
_ => return IResult::Error(error_code!(ErrorKind::Custom(43))),
|
||||
},
|
||||
|
@ -239,7 +239,7 @@ fn encoded_word(input: &[u8]) -> IResult<&[u8], Vec<u8>> {
|
|||
named!(qp_underscore_header<u8>, do_parse!(tag!("_") >> ({ b' ' })));
|
||||
|
||||
named!(
|
||||
get_quoted_printed_bytes<Vec<u8>>,
|
||||
quoted_printed_bytes<Vec<u8>>,
|
||||
many0!(alt_complete!(
|
||||
quoted_printable_byte | qp_underscore_header | le_u8
|
||||
))
|
||||
|
|
|
@ -56,7 +56,7 @@ impl Mailbox {
|
|||
}
|
||||
pub fn new(folder: &Folder, sent_folder: &Option<Result<Mailbox>>, collection: Result<Vec<Envelope>>) -> Result<Mailbox> {
|
||||
let mut collection: Vec<Envelope> = collection?;
|
||||
collection.sort_by(|a, b| a.get_date().cmp(&b.get_date()));
|
||||
collection.sort_by(|a, b| a.date().cmp(&b.date()));
|
||||
let (threads, threaded_collection) = build_threads(&mut collection, sent_folder);
|
||||
Ok(Mailbox {
|
||||
folder: folder.clone(),
|
||||
|
@ -68,16 +68,16 @@ impl Mailbox {
|
|||
pub fn len(&self) -> usize {
|
||||
self.collection.len()
|
||||
}
|
||||
pub fn get_threaded_mail(&self, i: usize) -> usize {
|
||||
pub fn threaded_mail(&self, i: usize) -> usize {
|
||||
let thread = self.threads[self.threaded_collection[i]];
|
||||
thread.get_message().unwrap()
|
||||
thread.message().unwrap()
|
||||
}
|
||||
pub fn get_mail_and_thread(&mut self, i: usize) -> (&mut Envelope, Container) {
|
||||
pub fn mail_and_thread(&mut self, i: usize) -> (&mut Envelope, Container) {
|
||||
let x = &mut self.collection.as_mut_slice()[i];
|
||||
let thread = self.threads[x.get_thread()];
|
||||
let thread = self.threads[x.thread()];
|
||||
(x, thread)
|
||||
}
|
||||
pub fn get_thread(&self, i: usize) -> &Container {
|
||||
pub fn thread(&self, i: usize) -> &Container {
|
||||
&self.threads[i]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,19 +51,19 @@ pub struct Container {
|
|||
}
|
||||
|
||||
impl Container {
|
||||
pub fn get_message(&self) -> Option<usize> {
|
||||
pub fn message(&self) -> Option<usize> {
|
||||
self.message
|
||||
}
|
||||
pub fn get_parent(&self) -> Option<usize> {
|
||||
pub fn parent(&self) -> Option<usize> {
|
||||
self.parent
|
||||
}
|
||||
pub fn has_parent(&self) -> bool {
|
||||
self.parent.is_some()
|
||||
}
|
||||
pub fn get_first_child(&self) -> Option<usize> {
|
||||
pub fn first_child(&self) -> Option<usize> {
|
||||
self.first_child
|
||||
}
|
||||
pub fn get_next_sibling(&self) -> Option<usize> {
|
||||
pub fn next_sibling(&self) -> Option<usize> {
|
||||
self.next_sibling
|
||||
}
|
||||
pub fn has_children(&self) -> bool {
|
||||
|
@ -78,7 +78,7 @@ impl Container {
|
|||
fn set_indentation(&mut self, i: usize) {
|
||||
self.indentation = i;
|
||||
}
|
||||
pub fn get_indentation(&self) -> usize {
|
||||
pub fn indentation(&self) -> usize {
|
||||
self.indentation
|
||||
}
|
||||
fn is_descendant(&self, threads: &[Container], other: &Container) -> bool {
|
||||
|
@ -101,7 +101,7 @@ impl Container {
|
|||
fn set_show_subject(&mut self, set: bool) -> () {
|
||||
self.show_subject = set;
|
||||
}
|
||||
pub fn get_show_subject(&self) -> bool {
|
||||
pub fn show_subject(&self) -> bool {
|
||||
self.show_subject
|
||||
}
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ fn build_collection(
|
|||
) -> () {
|
||||
for (i, x) in collection.iter_mut().enumerate() {
|
||||
let x_index; /* x's index in threads */
|
||||
let m_id = x.get_message_id_raw().to_string();
|
||||
let m_id = x.message_id_raw().to_string();
|
||||
/* TODO: Check for missing Message-ID.
|
||||
* Solutions: generate a hidden one
|
||||
*/
|
||||
|
@ -136,7 +136,7 @@ fn build_collection(
|
|||
}
|
||||
x_index = t;
|
||||
/* Store this message in the Container's message slot. */
|
||||
threads[t].date = x.get_date();
|
||||
threads[t].date = x.date();
|
||||
x.set_thread(t);
|
||||
threads[t].message = Some(i);
|
||||
} else {
|
||||
|
@ -148,7 +148,7 @@ fn build_collection(
|
|||
parent: None,
|
||||
first_child: None,
|
||||
next_sibling: None,
|
||||
date: x.get_date(),
|
||||
date: x.date(),
|
||||
indentation: 0,
|
||||
show_subject: true,
|
||||
});
|
||||
|
@ -167,13 +167,13 @@ fn build_collection(
|
|||
*/
|
||||
let mut curr_ref = x_index;
|
||||
let mut iasf = 0;
|
||||
for &r in x.get_references().iter().rev() {
|
||||
for &r in x.references().iter().rev() {
|
||||
if iasf == 1 {
|
||||
continue;
|
||||
}
|
||||
iasf += 1;
|
||||
let parent_id = if id_table.contains_key(r.get_raw()) {
|
||||
let p = id_table[r.get_raw()];
|
||||
let parent_id = if id_table.contains_key(r.raw()) {
|
||||
let p = id_table[r.raw()];
|
||||
if !(threads[p].is_descendant(threads, &threads[curr_ref]) ||
|
||||
threads[curr_ref].is_descendant(threads, &threads[p]))
|
||||
{
|
||||
|
@ -199,22 +199,22 @@ fn build_collection(
|
|||
parent: None,
|
||||
first_child: Some(curr_ref),
|
||||
next_sibling: None,
|
||||
date: x.get_date(),
|
||||
date: x.date(),
|
||||
indentation: 0,
|
||||
show_subject: true,
|
||||
});
|
||||
if threads[curr_ref].parent.is_none() {
|
||||
threads[curr_ref].parent = Some(idx);
|
||||
}
|
||||
id_table.insert(r.get_raw().to_string(), idx);
|
||||
id_table.insert(r.raw().to_string(), idx);
|
||||
idx
|
||||
};
|
||||
/* update thread date */
|
||||
let mut parent_iter = parent_id;
|
||||
'date: loop {
|
||||
let p = &mut threads[parent_iter];
|
||||
if p.date < x.get_date() {
|
||||
p.date = x.get_date();
|
||||
if p.date < x.date() {
|
||||
p.date = x.date();
|
||||
}
|
||||
match p.parent {
|
||||
Some(p) => {
|
||||
|
@ -264,27 +264,27 @@ pub fn build_threads(
|
|||
let sent_mailbox = sent_mailbox.unwrap();
|
||||
|
||||
for x in &sent_mailbox.collection {
|
||||
if id_table.contains_key(x.get_message_id_raw()) ||
|
||||
(!x.get_in_reply_to_raw().is_empty() &&
|
||||
id_table.contains_key(x.get_in_reply_to_raw()))
|
||||
if id_table.contains_key(x.message_id_raw()) ||
|
||||
(!x.in_reply_to_raw().is_empty() &&
|
||||
id_table.contains_key(x.in_reply_to_raw()))
|
||||
{
|
||||
let mut x: Envelope = (*x).clone();
|
||||
if id_table.contains_key(x.get_message_id_raw()) {
|
||||
let c = id_table[x.get_message_id_raw()];
|
||||
if id_table.contains_key(x.message_id_raw()) {
|
||||
let c = id_table[x.message_id_raw()];
|
||||
if threads[c].message.is_some() {
|
||||
/* skip duplicate message-id, but this should be handled instead */
|
||||
continue;
|
||||
}
|
||||
threads[c].message = Some(idx);
|
||||
assert!(threads[c].has_children());
|
||||
threads[c].date = x.get_date();
|
||||
threads[c].date = x.date();
|
||||
x.set_thread(c);
|
||||
} else if !x.get_in_reply_to_raw().is_empty() &&
|
||||
id_table.contains_key(x.get_in_reply_to_raw())
|
||||
} else if !x.in_reply_to_raw().is_empty() &&
|
||||
id_table.contains_key(x.in_reply_to_raw())
|
||||
{
|
||||
let p = id_table[x.get_in_reply_to_raw()];
|
||||
let c = if id_table.contains_key(x.get_message_id_raw()) {
|
||||
id_table[x.get_message_id_raw()]
|
||||
let p = id_table[x.in_reply_to_raw()];
|
||||
let c = if id_table.contains_key(x.message_id_raw()) {
|
||||
id_table[x.message_id_raw()]
|
||||
} else {
|
||||
threads.push(Container {
|
||||
message: Some(idx),
|
||||
|
@ -292,11 +292,11 @@ pub fn build_threads(
|
|||
parent: Some(p),
|
||||
first_child: None,
|
||||
next_sibling: None,
|
||||
date: x.get_date(),
|
||||
date: x.date(),
|
||||
indentation: 0,
|
||||
show_subject: true,
|
||||
});
|
||||
id_table.insert(x.get_message_id_raw().to_string(), tidx);
|
||||
id_table.insert(x.message_id_raw().to_string(), tidx);
|
||||
x.set_thread(tidx);
|
||||
tidx += 1;
|
||||
tidx - 1
|
||||
|
@ -322,8 +322,8 @@ pub fn build_threads(
|
|||
let mut parent_iter = p;
|
||||
'date: loop {
|
||||
let p = &mut threads[parent_iter];
|
||||
if p.date < x.get_date() {
|
||||
p.date = x.get_date();
|
||||
if p.date < x.date() {
|
||||
p.date = x.date();
|
||||
}
|
||||
match p.parent {
|
||||
Some(p) => {
|
||||
|
@ -372,12 +372,12 @@ pub fn build_threads(
|
|||
let thread = threads[i];
|
||||
if threads[root_subject_idx].has_message() {
|
||||
let root_subject =
|
||||
collection[threads[root_subject_idx].get_message().unwrap()].get_subject();
|
||||
collection[threads[root_subject_idx].message().unwrap()].subject();
|
||||
/* If the Container has no Message, but does have children, remove this container but
|
||||
* promote its children to this level (that is, splice them in to the current child
|
||||
* list.) */
|
||||
if indentation > 0 && thread.has_message() {
|
||||
let subject = collection[thread.get_message().unwrap()].get_subject();
|
||||
let subject = collection[thread.message().unwrap()].subject();
|
||||
if subject == root_subject ||
|
||||
subject.starts_with("Re: ") && subject.ends_with(root_subject)
|
||||
{
|
||||
|
@ -385,7 +385,7 @@ pub fn build_threads(
|
|||
}
|
||||
}
|
||||
}
|
||||
if thread.has_parent() && !threads[thread.get_parent().unwrap()].has_message() {
|
||||
if thread.has_parent() && !threads[thread.parent().unwrap()].has_message() {
|
||||
threads[i].parent = None;
|
||||
}
|
||||
let indentation = if thread.has_message() {
|
||||
|
@ -400,14 +400,14 @@ pub fn build_threads(
|
|||
indentation + 1
|
||||
};
|
||||
if thread.has_children() {
|
||||
let mut fc = thread.get_first_child().unwrap();
|
||||
let mut fc = thread.first_child().unwrap();
|
||||
loop {
|
||||
build_threaded(threads, indentation, threaded, fc, i, collection);
|
||||
let thread_ = threads[fc];
|
||||
if !thread_.has_sibling() {
|
||||
break;
|
||||
}
|
||||
fc = thread_.get_next_sibling().unwrap();
|
||||
fc = thread_.next_sibling().unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ fn main() {
|
|||
|
||||
'inner: loop {
|
||||
/* Check if any entities have sent reply events to State. */
|
||||
let events: Vec<UIEvent> = state.context.get_replies();
|
||||
let events: Vec<UIEvent> = state.context.replies();
|
||||
for e in events {
|
||||
state.rcv_event(e);
|
||||
}
|
||||
|
|
|
@ -273,7 +273,7 @@ impl Cell {
|
|||
/// let mut cell = Cell::with_style(Color::Blue, Color::Default, Attr::Default);
|
||||
/// assert_eq!(cell.fg(), Color::Blue);
|
||||
/// ```
|
||||
pub fn get_fg(&self) -> Color {
|
||||
pub fn fg(&self) -> Color {
|
||||
self.fg
|
||||
}
|
||||
|
||||
|
@ -305,7 +305,7 @@ impl Cell {
|
|||
/// let mut cell = Cell::with_style(Color::Default, Color::Green, Attr::Default);
|
||||
/// assert_eq!(cell.bg(), Color::Green);
|
||||
/// ```
|
||||
pub fn get_bg(&self) -> Color {
|
||||
pub fn bg(&self) -> Color {
|
||||
self.bg
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ impl MailListing {
|
|||
/// Helper function to format entry strings for MailListing */
|
||||
/* TODO: Make this configurable */
|
||||
fn make_entry_string(e: &Envelope, idx: usize) -> String {
|
||||
format!("{} {} {:.85}",idx,&e.get_datetime().format("%Y-%m-%d %H:%M:%S").to_string(),e.get_subject())
|
||||
format!("{} {} {:.85}",idx,&e.datetime().format("%Y-%m-%d %H:%M:%S").to_string(),e.subject())
|
||||
}
|
||||
|
||||
pub fn new() -> Self {
|
||||
|
@ -61,7 +61,7 @@ impl MailListing {
|
|||
let mut content = CellBuffer::new(MAX_COLS, self.length+1, Cell::with_char(' '));
|
||||
if self.length == 0 {
|
||||
write_string_to_grid(&format!("Folder `{}` is empty.",
|
||||
mailbox.folder.get_name()),
|
||||
mailbox.folder.name()),
|
||||
&mut content,
|
||||
Color::Default,
|
||||
Color::Default,
|
||||
|
@ -83,13 +83,13 @@ impl MailListing {
|
|||
.peekable();
|
||||
/* This is just a desugared for loop so that we can use .peek() */
|
||||
while let Some((idx, i)) = iter.next() {
|
||||
let container = mailbox.get_thread(*i);
|
||||
let indentation = container.get_indentation();
|
||||
let container = mailbox.thread(*i);
|
||||
let indentation = container.indentation();
|
||||
|
||||
assert_eq!(container.has_message(), true);
|
||||
match iter.peek() {
|
||||
Some(&(_, x))
|
||||
if mailbox.get_thread(*x).get_indentation() == indentation =>
|
||||
if mailbox.thread(*x).indentation() == indentation =>
|
||||
{
|
||||
indentations.pop();
|
||||
indentations.push(true);
|
||||
|
@ -103,7 +103,7 @@ impl MailListing {
|
|||
indentations.pop();
|
||||
indentations.push(true);
|
||||
}
|
||||
let envelope : &Envelope = &mailbox.collection[container.get_message().unwrap()];
|
||||
let envelope : &Envelope = &mailbox.collection[container.message().unwrap()];
|
||||
let fg_color = if !envelope.is_seen() {
|
||||
Color::Byte(0)
|
||||
} else {
|
||||
|
@ -129,14 +129,14 @@ impl MailListing {
|
|||
|
||||
match iter.peek() {
|
||||
Some(&(_, x))
|
||||
if mailbox.get_thread(*x).get_indentation() > indentation =>
|
||||
if mailbox.thread(*x).indentation() > indentation =>
|
||||
{
|
||||
indentations.push(false);
|
||||
}
|
||||
Some(&(_, x))
|
||||
if mailbox.get_thread(*x).get_indentation() < indentation =>
|
||||
if mailbox.thread(*x).indentation() < indentation =>
|
||||
{
|
||||
for _ in 0..(indentation - mailbox.get_thread(*x).get_indentation()) {
|
||||
for _ in 0..(indentation - mailbox.thread(*x).indentation()) {
|
||||
indentations.pop();
|
||||
}
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ impl MailListing {
|
|||
let threaded = context.accounts[self.cursor_pos.0].settings.threaded;
|
||||
let mailbox = &context.accounts[self.cursor_pos.0][self.cursor_pos.1].as_ref().unwrap().as_ref().unwrap();
|
||||
let envelope: &Envelope = if threaded {
|
||||
let i = mailbox.get_threaded_mail(idx);
|
||||
let i = mailbox.threaded_mail(idx);
|
||||
&mailbox.collection[i]
|
||||
} else {
|
||||
&mailbox.collection[idx]
|
||||
|
@ -268,7 +268,7 @@ impl MailListing {
|
|||
let threaded = context.accounts[self.cursor_pos.0].settings.threaded;
|
||||
let mailbox = &mut context.accounts[self.cursor_pos.0][self.cursor_pos.1].as_ref().unwrap().as_ref().unwrap();
|
||||
let envelope: &Envelope = if threaded {
|
||||
let i = mailbox.get_threaded_mail(self.cursor_pos.2);
|
||||
let i = mailbox.threaded_mail(self.cursor_pos.2);
|
||||
&mailbox.collection[i]
|
||||
} else {
|
||||
&mailbox.collection[self.cursor_pos.2]
|
||||
|
@ -283,9 +283,9 @@ impl MailListing {
|
|||
container: &Container, indentations: &Vec<bool>) -> String {
|
||||
let has_sibling = container.has_sibling();
|
||||
let has_parent = container.has_parent();
|
||||
let show_subject = container.get_show_subject();
|
||||
let show_subject = container.show_subject();
|
||||
|
||||
let mut s = format!("{} {} ", idx, &envelope.get_datetime().format("%Y-%m-%d %H:%M:%S").to_string());
|
||||
let mut s = format!("{} {} ", idx, &envelope.datetime().format("%Y-%m-%d %H:%M:%S").to_string());
|
||||
for i in 0..indent {
|
||||
if indentations.len() > i && indentations[i]
|
||||
{
|
||||
|
@ -307,10 +307,10 @@ impl MailListing {
|
|||
}
|
||||
s.push('─'); s.push('>');
|
||||
}
|
||||
s.push_str(&format!(" {}∞ ", envelope.get_body().count_attachments()));
|
||||
s.push_str(&format!(" {}∞ ", envelope.body().count_attachments()));
|
||||
|
||||
if show_subject {
|
||||
s.push_str(&format!("{:.85}", envelope.get_subject()));
|
||||
s.push_str(&format!("{:.85}", envelope.subject()));
|
||||
}
|
||||
s
|
||||
}
|
||||
|
@ -373,13 +373,13 @@ impl Component for MailListing {
|
|||
let threaded = context.accounts[self.cursor_pos.0].settings.threaded;
|
||||
let mailbox = &mut context.accounts[self.cursor_pos.0][self.cursor_pos.1].as_ref().unwrap().as_ref().unwrap();
|
||||
let envelope: &Envelope = if threaded {
|
||||
let i = mailbox.get_threaded_mail(self.cursor_pos.2);
|
||||
let i = mailbox.threaded_mail(self.cursor_pos.2);
|
||||
&mailbox.collection[i]
|
||||
} else {
|
||||
&mailbox.collection[self.cursor_pos.2]
|
||||
};
|
||||
|
||||
let (x,y) = write_string_to_grid(&format!("Date: {}", envelope.get_date_as_str()),
|
||||
let (x,y) = write_string_to_grid(&format!("Date: {}", envelope.date_as_str()),
|
||||
grid,
|
||||
Color::Byte(33),
|
||||
Color::Default,
|
||||
|
@ -390,7 +390,7 @@ impl Component for MailListing {
|
|||
grid[(x, y)].set_bg(Color::Default);
|
||||
grid[(x, y)].set_fg(Color::Default);
|
||||
}
|
||||
let (x,y) = write_string_to_grid(&format!("From: {}", envelope.get_from()),
|
||||
let (x,y) = write_string_to_grid(&format!("From: {}", envelope.from()),
|
||||
grid,
|
||||
Color::Byte(33),
|
||||
Color::Default,
|
||||
|
@ -401,7 +401,7 @@ impl Component for MailListing {
|
|||
grid[(x, y)].set_bg(Color::Default);
|
||||
grid[(x, y)].set_fg(Color::Default);
|
||||
}
|
||||
let (x,y) = write_string_to_grid(&format!("To: {}", envelope.get_to()),
|
||||
let (x,y) = write_string_to_grid(&format!("To: {}", envelope.to()),
|
||||
grid,
|
||||
Color::Byte(33),
|
||||
Color::Default,
|
||||
|
@ -412,7 +412,7 @@ impl Component for MailListing {
|
|||
grid[(x, y)].set_bg(Color::Default);
|
||||
grid[(x, y)].set_fg(Color::Default);
|
||||
}
|
||||
let (x,y) = write_string_to_grid(&format!("Subject: {}", envelope.get_subject()),
|
||||
let (x,y) = write_string_to_grid(&format!("Subject: {}", envelope.subject()),
|
||||
grid,
|
||||
Color::Byte(33),
|
||||
Color::Default,
|
||||
|
@ -423,7 +423,7 @@ impl Component for MailListing {
|
|||
grid[(x, y)].set_bg(Color::Default);
|
||||
grid[(x, y)].set_fg(Color::Default);
|
||||
}
|
||||
let (x, y) = write_string_to_grid(&format!("Message-ID: {}", envelope.get_message_id_raw()),
|
||||
let (x, y) = write_string_to_grid(&format!("Message-ID: {}", envelope.message_id_raw()),
|
||||
grid,
|
||||
Color::Byte(33),
|
||||
Color::Default,
|
||||
|
|
|
@ -25,7 +25,7 @@ impl AccountMenu {
|
|||
pub fn new(accounts: &Vec<Account>) -> Self {
|
||||
let accounts = accounts.iter().enumerate().map(|(i, a)| {
|
||||
AccountMenuEntry {
|
||||
name: a.get_name().to_string(),
|
||||
name: a.name().to_string(),
|
||||
index: i,
|
||||
entries: {
|
||||
let mut entries = Vec::with_capacity(a.len());
|
||||
|
@ -54,7 +54,7 @@ impl AccountMenu {
|
|||
let mut parents: Vec<Option<usize>> = vec!(None; a.entries.len());
|
||||
|
||||
for (idx, e) in a.entries.iter().enumerate() {
|
||||
for c in e.1.get_children() {
|
||||
for c in e.1.children() {
|
||||
parents[*c] = Some(idx);
|
||||
}
|
||||
}
|
||||
|
@ -79,10 +79,10 @@ impl AccountMenu {
|
|||
|
||||
fn print(root: usize, parents: &Vec<Option<usize>>, depth: &mut String, entries: &Vec<(usize, Folder)>, s: &mut String, inc: &mut usize) -> () {
|
||||
let len = s.len();
|
||||
s.insert_str(len, &format!("{} {}\n ", *inc, &entries[root].1.get_name()));
|
||||
s.insert_str(len, &format!("{} {}\n ", *inc, &entries[root].1.name()));
|
||||
*inc += 1;
|
||||
let children_no = entries[root].1.get_children().len();
|
||||
for (idx, child) in entries[root].1.get_children().iter().enumerate() {
|
||||
let children_no = entries[root].1.children().len();
|
||||
for (idx, child) in entries[root].1.children().iter().enumerate() {
|
||||
let len = s.len();
|
||||
s.insert_str(len, &format!("{}├─", depth));
|
||||
push(depth, if idx == children_no - 1 {'│'} else { ' ' });
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
use notify_rust::Notification as notify_Notification;
|
||||
|
||||
use super::*;
|
||||
use super::components::*;
|
||||
|
||||
/// Passes notifications to the OS using the XDG specifications.
|
||||
pub struct XDGNotifications {}
|
||||
|
|
|
@ -135,7 +135,7 @@ pub struct Pager {
|
|||
// TODO: Make the `new` method content agnostic.
|
||||
impl Pager {
|
||||
pub fn new(mail: &Envelope, pager_filter: Option<String>) -> Self {
|
||||
let mut text = mail.get_body().get_text();
|
||||
let mut text = mail.body().text();
|
||||
if let Some(bin) = pager_filter {
|
||||
use std::io::Write;
|
||||
use std::process::{Command, Stdio};
|
||||
|
@ -219,7 +219,7 @@ impl Component for Pager {
|
|||
|
||||
//let pager_context: usize = context.settings.pager.pager_context;
|
||||
//let pager_stop: bool = context.settings.pager.pager_stop;
|
||||
//let rows = get_y(bottom_right) - get_y(upper_left);
|
||||
//let rows = y(bottom_right) - y(upper_left);
|
||||
//let page_length = rows / self.height;
|
||||
copy_area(grid, &self.content, area, ((0, self.cursor_pos), (self.width - 1, self.height - 1)));
|
||||
context.dirty_areas.push_back(area);
|
||||
|
@ -336,7 +336,7 @@ impl Component for StatusBar {
|
|||
match event.event_type {
|
||||
UIEventType::RefreshMailbox((idx_a, idx_f)) => {
|
||||
let m = &context.accounts[idx_a][idx_f].as_ref().unwrap().as_ref().unwrap();
|
||||
self.status = format!("{} |Mailbox: {}, Messages: {}, New: {}", self.mode, m.folder.get_name(), m.collection.len(), m.collection.iter().filter(|e| !e.is_seen()).count());
|
||||
self.status = format!("{} |Mailbox: {}, Messages: {}, New: {}", self.mode, m.folder.name(), m.collection.len(), m.collection.iter().filter(|e| !e.is_seen()).count());
|
||||
self.dirty = true;
|
||||
|
||||
},
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
|
||||
/*!
|
||||
The UI module has an Entity-Component-System design. The System part, is also the application's state, so they're both merged in the `State` struct.
|
||||
The UI crate has an Entity-Component-System design. The System part, is also the application's state, so they're both merged in the `State` struct.
|
||||
|
||||
`State` owns all the Entities of the UI, which are currently plain Containers for `Component`s. In the application's main event loop, input is handed to the state in the form of `UIEvent` objects which traverse the entity graph. Components decide to handle each input or not.
|
||||
|
||||
|
@ -133,7 +133,7 @@ pub struct Context {
|
|||
}
|
||||
|
||||
impl Context {
|
||||
pub fn get_replies(&mut self) -> Vec<UIEvent> {
|
||||
pub fn replies(&mut self) -> Vec<UIEvent> {
|
||||
self.replies.drain(0..).collect()
|
||||
}
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ impl<W: Write> State<W> {
|
|||
let cols = termcols.unwrap_or(0) as usize;
|
||||
let rows = termrows.unwrap_or(0) as usize;
|
||||
let mut accounts: Vec<Account> = settings.accounts.iter().map(|(n, a_s)| { Account::new(n.to_string(), a_s.clone(), &backends) }).collect();
|
||||
accounts.sort_by(|a,b| a.get_name().cmp(&b.get_name()) );
|
||||
accounts.sort_by(|a,b| a.name().cmp(&b.name()) );
|
||||
let mut s = State {
|
||||
cols: cols,
|
||||
rows: rows,
|
||||
|
@ -233,17 +233,17 @@ impl<W: Write> State<W> {
|
|||
for x in get_x(upper_left)..=get_x(bottom_right) {
|
||||
let c = self.grid[(x,y)];
|
||||
|
||||
if c.get_bg() != cells::Color::Default {
|
||||
write!(self.stdout, "{}", termion::color::Bg(c.get_bg().as_termion())).unwrap();
|
||||
if c.bg() != cells::Color::Default {
|
||||
write!(self.stdout, "{}", termion::color::Bg(c.bg().as_termion())).unwrap();
|
||||
}
|
||||
if c.get_fg() != cells::Color::Default {
|
||||
write!(self.stdout, "{}", termion::color::Fg(c.get_fg().as_termion())).unwrap();
|
||||
if c.fg() != cells::Color::Default {
|
||||
write!(self.stdout, "{}", termion::color::Fg(c.fg().as_termion())).unwrap();
|
||||
}
|
||||
write!(self.stdout, "{}",c.ch()).unwrap();
|
||||
if c.get_bg() != cells::Color::Default {
|
||||
if c.bg() != cells::Color::Default {
|
||||
write!(self.stdout, "{}", termion::color::Bg(termion::color::Reset)).unwrap();
|
||||
}
|
||||
if c.get_fg() != cells::Color::Default {
|
||||
if c.fg() != cells::Color::Default {
|
||||
write!(self.stdout, "{}", termion::color::Fg(termion::color::Reset)).unwrap();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue