Fix compiler warnings
parent
569e710067
commit
b7729243ad
|
@ -16,7 +16,7 @@ serde_derive = "^1.0.8"
|
||||||
serde = "^1.0.8"
|
serde = "^1.0.8"
|
||||||
nom = "3.2.0"
|
nom = "3.2.0"
|
||||||
memmap = "0.5.2"
|
memmap = "0.5.2"
|
||||||
base64 = "*"
|
data-encoding = "2.1.1"
|
||||||
encoding = "0.2.33"
|
encoding = "0.2.33"
|
||||||
bitflags = "1.0"
|
bitflags = "1.0"
|
||||||
termion = "1.5.1"
|
termion = "1.5.1"
|
||||||
|
|
|
@ -31,7 +31,6 @@ use pager::PagerSettings;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::collections::hash_map::DefaultHasher;
|
use std::collections::hash_map::DefaultHasher;
|
||||||
use std::hash::Hasher;
|
use std::hash::Hasher;
|
||||||
use std::io;
|
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
|
|
|
@ -29,9 +29,9 @@ extern crate serde_derive;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate nom;
|
extern crate nom;
|
||||||
extern crate chrono;
|
extern crate chrono;
|
||||||
extern crate base64;
|
|
||||||
extern crate memmap;
|
extern crate memmap;
|
||||||
extern crate encoding;
|
extern crate encoding;
|
||||||
|
extern crate data_encoding;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate bitflags;
|
extern crate bitflags;
|
||||||
|
|
|
@ -85,7 +85,6 @@ impl IndexMut<usize> for Account {
|
||||||
fn index_mut(&mut self, index: usize) -> &mut Option<Result<Mailbox>> {
|
fn index_mut(&mut self, index: usize) -> &mut Option<Result<Mailbox>> {
|
||||||
if self.folders[index].is_none() {
|
if self.folders[index].is_none() {
|
||||||
let folder = &self.settings.folders[index];
|
let folder = &self.settings.folders[index];
|
||||||
let path = folder.path().clone();
|
|
||||||
if self.sent_folder.is_some() {
|
if self.sent_folder.is_some() {
|
||||||
let id = self.sent_folder.unwrap();
|
let id = self.sent_folder.unwrap();
|
||||||
if id == index {
|
if id == index {
|
||||||
|
|
|
@ -21,6 +21,9 @@
|
||||||
use mailbox::email::parser;
|
use mailbox::email::parser;
|
||||||
|
|
||||||
use std::fmt::{Display, Formatter, Result as FmtResult};
|
use std::fmt::{Display, Formatter, Result as FmtResult};
|
||||||
|
use std::str;
|
||||||
|
|
||||||
|
use data_encoding::BASE64_MIME;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
|
@ -158,14 +161,14 @@ impl AttachmentBuilder {
|
||||||
// TODO: Use charset for decoding
|
// TODO: Use charset for decoding
|
||||||
match self.content_transfer_encoding {
|
match self.content_transfer_encoding {
|
||||||
ContentTransferEncoding::Base64 => {
|
ContentTransferEncoding::Base64 => {
|
||||||
match ::base64::decode(&::std::str::from_utf8(&self.raw)
|
match BASE64_MIME.decode(str::from_utf8(&self.raw)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.trim()
|
.trim()
|
||||||
.lines()
|
.lines()
|
||||||
.fold(String::with_capacity(self.raw.len()), |mut acc, x| {
|
.fold(String::with_capacity(self.raw.len()), |mut acc, x| {
|
||||||
acc.push_str(x);
|
acc.push_str(x);
|
||||||
acc
|
acc
|
||||||
})) {
|
}).as_bytes()) {
|
||||||
Ok(ref v) => {
|
Ok(ref v) => {
|
||||||
let s = String::from_utf8_lossy(v);
|
let s = String::from_utf8_lossy(v);
|
||||||
if s.find("\r\n").is_some() {
|
if s.find("\r\n").is_some() {
|
||||||
|
@ -251,7 +254,7 @@ impl AttachmentBuilder {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"error {:?}\n\traw: {:?}\n\tboundary: {:?}",
|
"error {:?}\n\traw: {:?}\n\tboundary: {:?}",
|
||||||
a,
|
a,
|
||||||
::std::str::from_utf8(raw).unwrap(),
|
str::from_utf8(raw).unwrap(),
|
||||||
boundary
|
boundary
|
||||||
);
|
);
|
||||||
Vec::new()
|
Vec::new()
|
||||||
|
@ -277,7 +280,7 @@ impl Display for Attachment {
|
||||||
AttachmentType::Data { .. } => {
|
AttachmentType::Data { .. } => {
|
||||||
write!(f, "Data attachment of type {}", self.tag())
|
write!(f, "Data attachment of type {}", self.tag())
|
||||||
}
|
}
|
||||||
AttachmentType::Text { content: ref t } => {
|
AttachmentType::Text { .. } => {
|
||||||
write!(f, "Text attachment")
|
write!(f, "Text attachment")
|
||||||
}
|
}
|
||||||
AttachmentType::Multipart {
|
AttachmentType::Multipart {
|
||||||
|
@ -294,6 +297,9 @@ impl Display for Attachment {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Attachment {
|
impl Attachment {
|
||||||
|
pub fn bytes(&self) -> &[u8] {
|
||||||
|
&self.raw
|
||||||
|
}
|
||||||
fn get_text_recursive(&self, text: &mut String) {
|
fn get_text_recursive(&self, text: &mut String) {
|
||||||
match self.attachment_type {
|
match self.attachment_type {
|
||||||
AttachmentType::Data { .. } => {
|
AttachmentType::Data { .. } => {
|
||||||
|
@ -361,10 +367,27 @@ impl Attachment {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub fn interpret_format_flowed(t: &str) -> String {
|
pub fn interpret_format_flowed(_t: &str) -> String {
|
||||||
//let mut n = String::with_capacity(t.len());
|
//let mut n = String::with_capacity(t.len());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn decode(a: &Attachment) -> Vec<u8> {
|
||||||
|
// TODO: Use charset for decoding
|
||||||
|
match a.content_transfer_encoding {
|
||||||
|
ContentTransferEncoding::Base64 => {
|
||||||
|
match BASE64_MIME.decode(a.bytes()) {
|
||||||
|
Ok(v) => {
|
||||||
|
v
|
||||||
|
}
|
||||||
|
_ => a.bytes().to_vec(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ContentTransferEncoding::QuotedPrintable => parser::quoted_printed_bytes(&a.bytes()).to_full_result() .unwrap(),
|
||||||
|
ContentTransferEncoding::_7Bit |
|
||||||
|
ContentTransferEncoding::_8Bit |
|
||||||
|
ContentTransferEncoding::Other { .. } => {
|
||||||
|
a.bytes().to_vec()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@ pub mod parser;
|
||||||
pub mod attachments;
|
pub mod attachments;
|
||||||
|
|
||||||
use mailbox::backends::BackendOpGenerator;
|
use mailbox::backends::BackendOpGenerator;
|
||||||
use self::attachments::*;
|
|
||||||
pub use self::attachments::*;
|
pub use self::attachments::*;
|
||||||
|
|
||||||
use std::string::String;
|
use std::string::String;
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
*/
|
*/
|
||||||
use std;
|
use std;
|
||||||
use std::str::from_utf8;
|
use std::str::from_utf8;
|
||||||
use base64;
|
use data_encoding::BASE64_MIME;
|
||||||
use chrono;
|
use chrono;
|
||||||
use nom::{is_hex_digit, le_u8};
|
use nom::{is_hex_digit, le_u8};
|
||||||
use nom::{ErrorKind, IResult, Needed};
|
use nom::{ErrorKind, IResult, Needed};
|
||||||
|
@ -174,7 +174,7 @@ fn encoded_word(input: &[u8]) -> IResult<&[u8], Vec<u8>> {
|
||||||
let encoded = &input[5 + tag_len..encoded_idx.unwrap()];
|
let encoded = &input[5 + tag_len..encoded_idx.unwrap()];
|
||||||
|
|
||||||
let s: Vec<u8> = match input[2 + tag_len + 1] {
|
let s: Vec<u8> = match input[2 + tag_len + 1] {
|
||||||
b'b' | b'B' => match base64::decode(encoded) {
|
b'b' | b'B' => match BASE64_MIME.decode(encoded) {
|
||||||
Ok(v) => v,
|
Ok(v) => v,
|
||||||
Err(_) => encoded.to_vec(),
|
Err(_) => encoded.to_vec(),
|
||||||
},
|
},
|
||||||
|
@ -239,7 +239,7 @@ fn encoded_word(input: &[u8]) -> IResult<&[u8], Vec<u8>> {
|
||||||
named!(qp_underscore_header<u8>, do_parse!(tag!("_") >> ({ b' ' })));
|
named!(qp_underscore_header<u8>, do_parse!(tag!("_") >> ({ b' ' })));
|
||||||
|
|
||||||
named!(
|
named!(
|
||||||
quoted_printed_bytes<Vec<u8>>,
|
pub quoted_printed_bytes<Vec<u8>>,
|
||||||
many0!(alt_complete!(
|
many0!(alt_complete!(
|
||||||
quoted_printable_byte | qp_underscore_header | le_u8
|
quoted_printable_byte | qp_underscore_header | le_u8
|
||||||
))
|
))
|
||||||
|
|
|
@ -31,7 +31,6 @@ use ui::*;
|
||||||
pub use melib::*;
|
pub use melib::*;
|
||||||
|
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use std::io::{stdout,};
|
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate chan;
|
extern crate chan;
|
||||||
|
|
|
@ -181,7 +181,7 @@ impl fmt::Display for CellBuffer {
|
||||||
'_y: for y in 0..self.rows {
|
'_y: for y in 0..self.rows {
|
||||||
'_x: for x in 0..self.cols {
|
'_x: for x in 0..self.cols {
|
||||||
let c: &char = &self[(x,y)].ch();
|
let c: &char = &self[(x,y)].ch();
|
||||||
write!(f, "{}", *c);
|
write!(f, "{}", *c).unwrap();
|
||||||
if *c == '\n' {
|
if *c == '\n' {
|
||||||
continue '_y;
|
continue '_y;
|
||||||
}
|
}
|
||||||
|
|
|
@ -526,7 +526,6 @@ impl Component for MailListing {
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
_ => { unreachable!() },
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
|
|
|
@ -7,8 +7,8 @@ use std::process::{Command, Stdio};
|
||||||
enum ViewMode {
|
enum ViewMode {
|
||||||
Normal,
|
Normal,
|
||||||
Url,
|
Url,
|
||||||
Attachment,
|
// Attachment,
|
||||||
Raw,
|
// Raw,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Contains an Envelope view, with sticky headers, a pager for the body, and subviews for more
|
/// Contains an Envelope view, with sticky headers, a pager for the body, and subviews for more
|
||||||
|
@ -140,11 +140,10 @@ impl Component for MailView {
|
||||||
match self.mode {
|
match self.mode {
|
||||||
ViewMode::Url => {
|
ViewMode::Url => {
|
||||||
// URL indexes must be colored (ugh..)
|
// URL indexes must be colored (ugh..)
|
||||||
let (cols, _) = buf.size();
|
|
||||||
let lines: Vec<&str> = text.split('\n').collect();
|
let lines: Vec<&str> = text.split('\n').collect();
|
||||||
let mut shift = 0;
|
let mut shift = 0;
|
||||||
for (ridx, r) in lines.iter().enumerate() {
|
for r in lines.iter() {
|
||||||
for (lidx, l) in finder.links(&r).enumerate() {
|
for l in finder.links(&r) {
|
||||||
buf[(l.start() + shift - 1, 0)].set_fg(Color::Byte(226));
|
buf[(l.start() + shift - 1, 0)].set_fg(Color::Byte(226));
|
||||||
buf[(l.start() + shift - 2, 0)].set_fg(Color::Byte(226));
|
buf[(l.start() + shift - 2, 0)].set_fg(Color::Byte(226));
|
||||||
buf[(l.start() + shift - 3, 0)].set_fg(Color::Byte(226));
|
buf[(l.start() + shift - 3, 0)].set_fg(Color::Byte(226));
|
||||||
|
@ -184,7 +183,7 @@ impl Component for MailView {
|
||||||
self.cmd_buf.clear();
|
self.cmd_buf.clear();
|
||||||
|
|
||||||
|
|
||||||
let url = {
|
{
|
||||||
let threaded = context.accounts[self.coordinates.0].runtime_settings.threaded;
|
let threaded = context.accounts[self.coordinates.0].runtime_settings.threaded;
|
||||||
let mailbox = &mut context.accounts[self.coordinates.0][self.coordinates.1].as_ref().unwrap().as_ref().unwrap();
|
let mailbox = &mut context.accounts[self.coordinates.0][self.coordinates.1].as_ref().unwrap().as_ref().unwrap();
|
||||||
let envelope_idx: usize = if threaded {
|
let envelope_idx: usize = if threaded {
|
||||||
|
@ -195,7 +194,8 @@ impl Component for MailView {
|
||||||
|
|
||||||
let envelope: &Envelope = &mailbox.collection[envelope_idx];
|
let envelope: &Envelope = &mailbox.collection[envelope_idx];
|
||||||
if let Some(u) = envelope.body().attachments().get(lidx) {
|
if let Some(u) = envelope.body().attachments().get(lidx) {
|
||||||
eprintln!("{:?}", u);
|
let p = create_temp_file(&decode(u), None);
|
||||||
|
eprintln!("{:?}", p);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
context.replies.push_back(UIEvent { id: 0, event_type: UIEventType::StatusNotification(format!("Attachment `{}` not found.", lidx)) });
|
context.replies.push_back(UIEvent { id: 0, event_type: UIEventType::StatusNotification(format!("Attachment `{}` not found.", lidx)) });
|
||||||
|
@ -231,7 +231,7 @@ impl Component for MailView {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
let open_url = Command::new("xdg-open")
|
Command::new("xdg-open")
|
||||||
.arg(url)
|
.arg(url)
|
||||||
.stdin(Stdio::piped())
|
.stdin(Stdio::piped())
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
|
@ -243,7 +243,7 @@ impl Component for MailView {
|
||||||
match self.mode {
|
match self.mode {
|
||||||
ViewMode::Normal => { self.mode = ViewMode::Url },
|
ViewMode::Normal => { self.mode = ViewMode::Url },
|
||||||
ViewMode::Url => { self.mode = ViewMode::Normal },
|
ViewMode::Url => { self.mode = ViewMode::Normal },
|
||||||
_ => {},
|
//_ => {},
|
||||||
}
|
}
|
||||||
self.dirty = true;
|
self.dirty = true;
|
||||||
},
|
},
|
||||||
|
|
|
@ -43,17 +43,17 @@ const HORZ_BOUNDARY: char = '─';
|
||||||
const VERT_BOUNDARY: char = '│';
|
const VERT_BOUNDARY: char = '│';
|
||||||
|
|
||||||
/// The top-left corner
|
/// The top-left corner
|
||||||
const TOP_LEFT_CORNER: char = '┌';
|
const _TOP_LEFT_CORNER: char = '┌';
|
||||||
/// The top-right corner
|
/// The top-right corner
|
||||||
const TOP_RIGHT_CORNER: char = '┐';
|
const _TOP_RIGHT_CORNER: char = '┐';
|
||||||
/// The bottom-left corner
|
/// The bottom-left corner
|
||||||
const BOTTOM_LEFT_CORNER: char = '└';
|
const _BOTTOM_LEFT_CORNER: char = '└';
|
||||||
/// The bottom-right corner
|
/// The bottom-right corner
|
||||||
const BOTTOM_RIGHT_CORNER: char = '┘';
|
const _BOTTOM_RIGHT_CORNER: char = '┘';
|
||||||
|
|
||||||
const LIGHT_VERTICAL_AND_RIGHT: char = '├';
|
const LIGHT_VERTICAL_AND_RIGHT: char = '├';
|
||||||
|
|
||||||
const LIGHT_VERTICAL_AND_LEFT: char = '┤';
|
const _LIGHT_VERTICAL_AND_LEFT: char = '┤';
|
||||||
|
|
||||||
const LIGHT_DOWN_AND_HORIZONTAL: char = '┬';
|
const LIGHT_DOWN_AND_HORIZONTAL: char = '┬';
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,6 @@
|
||||||
*/
|
*/
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
use melib::mailbox::email::interpret_format_flowed;
|
|
||||||
use melib::mailbox::email::Attachment;
|
|
||||||
|
|
||||||
/// A horizontally split in half container.
|
/// A horizontally split in half container.
|
||||||
pub struct HSplit {
|
pub struct HSplit {
|
||||||
top: Entity,
|
top: Entity,
|
||||||
|
@ -428,22 +425,22 @@ impl Component for StatusBar {
|
||||||
|
|
||||||
// A box with a text content.
|
// A box with a text content.
|
||||||
pub struct TextBox {
|
pub struct TextBox {
|
||||||
content: String,
|
_content: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TextBox {
|
impl TextBox {
|
||||||
pub fn new(s: String) -> Self {
|
pub fn new(s: String) -> Self {
|
||||||
TextBox {
|
TextBox {
|
||||||
content: s,
|
_content: s,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Component for TextBox {
|
impl Component for TextBox {
|
||||||
fn draw(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
|
fn draw(&mut self, _grid: &mut CellBuffer, _area: Area, _context: &mut Context) {
|
||||||
|
|
||||||
}
|
}
|
||||||
fn process_event(&mut self, event: &UIEvent, context: &mut Context) {
|
fn process_event(&mut self, _event: &UIEvent, _context: &mut Context) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*! A parser module for user commands passed through the Ex mode.
|
/*! A parser module for user commands passed through the Ex mode.
|
||||||
*/
|
*/
|
||||||
use std;
|
use std;
|
||||||
use nom::{digit, alpha};
|
use nom::{digit, };
|
||||||
|
|
||||||
|
|
||||||
named!(usize_c<usize>,
|
named!(usize_c<usize>,
|
||||||
|
@ -12,7 +12,9 @@ named!(pub goto<usize>,
|
||||||
call!(usize_c))
|
call!(usize_c))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/*
|
||||||
named!(pub sort<&str>,
|
named!(pub sort<&str>,
|
||||||
preceded!(tag!("sort "),
|
preceded!(tag!("sort "),
|
||||||
map_res!(call!(alpha), std::str::from_utf8))
|
map_res!(call!(alpha), std::str::from_utf8))
|
||||||
);
|
);
|
||||||
|
*/
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
use std;
|
use std;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::ops::{Deref, DerefMut};
|
|
||||||
|
|
||||||
|
|
||||||
use std::fs;
|
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -37,6 +34,7 @@ pub fn create_temp_file(bytes: &[u8], filename: Option<&PathBuf>) -> File {
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut f = std::fs::File::create(path).unwrap();
|
let mut f = std::fs::File::create(path).unwrap();
|
||||||
|
|
||||||
f.write(bytes).unwrap();
|
f.write(bytes).unwrap();
|
||||||
f.flush().unwrap();
|
f.flush().unwrap();
|
||||||
File {
|
File {
|
||||||
|
|
|
@ -141,10 +141,10 @@ impl fmt::Display for UIMode {
|
||||||
|
|
||||||
/// An event notification that is passed to Entities for handling.
|
/// An event notification that is passed to Entities for handling.
|
||||||
pub struct Notification {
|
pub struct Notification {
|
||||||
title: String,
|
_title: String,
|
||||||
content: String,
|
_content: String,
|
||||||
|
|
||||||
timestamp: std::time::Instant,
|
_timestamp: std::time::Instant,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A context container for loaded settings, accounts, UI changes, etc.
|
/// A context container for loaded settings, accounts, UI changes, etc.
|
||||||
|
@ -158,7 +158,7 @@ pub struct Context {
|
||||||
|
|
||||||
/// Events queue that components send back to the state
|
/// Events queue that components send back to the state
|
||||||
replies: VecDeque<UIEvent>,
|
replies: VecDeque<UIEvent>,
|
||||||
backends: Backends,
|
_backends: Backends,
|
||||||
|
|
||||||
input_thread: chan::Sender<bool>,
|
input_thread: chan::Sender<bool>,
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,7 @@ impl State<std::io::Stdout> {
|
||||||
|
|
||||||
context: Context {
|
context: Context {
|
||||||
accounts: accounts,
|
accounts: accounts,
|
||||||
backends: backends,
|
_backends: backends,
|
||||||
settings: settings.clone(),
|
settings: settings.clone(),
|
||||||
runtime_settings: settings,
|
runtime_settings: settings,
|
||||||
dirty_areas: VecDeque::with_capacity(5),
|
dirty_areas: VecDeque::with_capacity(5),
|
||||||
|
@ -381,7 +381,7 @@ impl<W: Write> State<W> {
|
||||||
in_pipe.write(&buf).unwrap();
|
in_pipe.write(&buf).unwrap();
|
||||||
std::fs::remove_file(file.path()).unwrap();
|
std::fs::remove_file(file.path()).unwrap();
|
||||||
}
|
}
|
||||||
let output = output.wait_with_output().expect("Failed to read stdout");
|
output.wait_with_output().expect("Failed to read stdout");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue