Fix compiler warnings

embed
Manos Pitsidianakis 2018-07-24 20:20:32 +03:00
parent 569e710067
commit b7729243ad
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
16 changed files with 65 additions and 50 deletions

View File

@ -16,7 +16,7 @@ serde_derive = "^1.0.8"
serde = "^1.0.8"
nom = "3.2.0"
memmap = "0.5.2"
base64 = "*"
data-encoding = "2.1.1"
encoding = "0.2.33"
bitflags = "1.0"
termion = "1.5.1"

View File

@ -31,7 +31,6 @@ use pager::PagerSettings;
use std::collections::HashMap;
use std::collections::hash_map::DefaultHasher;
use std::hash::Hasher;
use std::io;
use std::fs;
use std::path::{Path, PathBuf};

View File

@ -29,9 +29,9 @@ extern crate serde_derive;
#[macro_use]
extern crate nom;
extern crate chrono;
extern crate base64;
extern crate memmap;
extern crate encoding;
extern crate data_encoding;
#[macro_use]
extern crate bitflags;

View File

@ -85,7 +85,6 @@ 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.path().clone();
if self.sent_folder.is_some() {
let id = self.sent_folder.unwrap();
if id == index {

View File

@ -21,6 +21,9 @@
use mailbox::email::parser;
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
match self.content_transfer_encoding {
ContentTransferEncoding::Base64 => {
match ::base64::decode(&::std::str::from_utf8(&self.raw)
match BASE64_MIME.decode(str::from_utf8(&self.raw)
.unwrap()
.trim()
.lines()
.fold(String::with_capacity(self.raw.len()), |mut acc, x| {
acc.push_str(x);
acc
})) {
}).as_bytes()) {
Ok(ref v) => {
let s = String::from_utf8_lossy(v);
if s.find("\r\n").is_some() {
@ -251,7 +254,7 @@ impl AttachmentBuilder {
eprintln!(
"error {:?}\n\traw: {:?}\n\tboundary: {:?}",
a,
::std::str::from_utf8(raw).unwrap(),
str::from_utf8(raw).unwrap(),
boundary
);
Vec::new()
@ -277,7 +280,7 @@ impl Display for Attachment {
AttachmentType::Data { .. } => {
write!(f, "Data attachment of type {}", self.tag())
}
AttachmentType::Text { content: ref t } => {
AttachmentType::Text { .. } => {
write!(f, "Text attachment")
}
AttachmentType::Multipart {
@ -294,6 +297,9 @@ impl Display for Attachment {
}
impl Attachment {
pub fn bytes(&self) -> &[u8] {
&self.raw
}
fn get_text_recursive(&self, text: &mut String) {
match self.attachment_type {
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());
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()
}
}
}

View File

@ -23,7 +23,6 @@ pub mod parser;
pub mod attachments;
use mailbox::backends::BackendOpGenerator;
use self::attachments::*;
pub use self::attachments::*;
use std::string::String;

View File

@ -20,7 +20,7 @@
*/
use std;
use std::str::from_utf8;
use base64;
use data_encoding::BASE64_MIME;
use chrono;
use nom::{is_hex_digit, le_u8};
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 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,
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!(
quoted_printed_bytes<Vec<u8>>,
pub quoted_printed_bytes<Vec<u8>>,
many0!(alt_complete!(
quoted_printable_byte | qp_underscore_header | le_u8
))

View File

@ -31,7 +31,6 @@ use ui::*;
pub use melib::*;
use std::thread;
use std::io::{stdout,};
#[macro_use]
extern crate chan;

View File

@ -181,7 +181,7 @@ impl fmt::Display for CellBuffer {
'_y: for y in 0..self.rows {
'_x: for x in 0..self.cols {
let c: &char = &self[(x,y)].ch();
write!(f, "{}", *c);
write!(f, "{}", *c).unwrap();
if *c == '\n' {
continue '_y;
}

View File

@ -526,7 +526,6 @@ impl Component for MailListing {
},
_ => { unreachable!() },
}
},
_ => {

View File

@ -7,8 +7,8 @@ use std::process::{Command, Stdio};
enum ViewMode {
Normal,
Url,
Attachment,
Raw,
// Attachment,
// Raw,
}
/// 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 {
ViewMode::Url => {
// URL indexes must be colored (ugh..)
let (cols, _) = buf.size();
let lines: Vec<&str> = text.split('\n').collect();
let mut shift = 0;
for (ridx, r) in lines.iter().enumerate() {
for (lidx, l) in finder.links(&r).enumerate() {
for r in lines.iter() {
for l in finder.links(&r) {
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 - 3, 0)].set_fg(Color::Byte(226));
@ -184,7 +183,7 @@ impl Component for MailView {
self.cmd_buf.clear();
let url = {
{
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 envelope_idx: usize = if threaded {
@ -195,7 +194,8 @@ impl Component for MailView {
let envelope: &Envelope = &mailbox.collection[envelope_idx];
if let Some(u) = envelope.body().attachments().get(lidx) {
eprintln!("{:?}", u);
let p = create_temp_file(&decode(u), None);
eprintln!("{:?}", p);
} else {
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)
.stdin(Stdio::piped())
.stdout(Stdio::piped())
@ -243,7 +243,7 @@ impl Component for MailView {
match self.mode {
ViewMode::Normal => { self.mode = ViewMode::Url },
ViewMode::Url => { self.mode = ViewMode::Normal },
_ => {},
//_ => {},
}
self.dirty = true;
},

View File

@ -43,17 +43,17 @@ const HORZ_BOUNDARY: char = '─';
const VERT_BOUNDARY: char = '│';
/// The top-left corner
const TOP_LEFT_CORNER: char = '┌';
const _TOP_LEFT_CORNER: char = '┌';
/// The top-right corner
const TOP_RIGHT_CORNER: char = '┐';
const _TOP_RIGHT_CORNER: char = '┐';
/// The bottom-left corner
const BOTTOM_LEFT_CORNER: char = '└';
const _BOTTOM_LEFT_CORNER: char = '└';
/// The bottom-right corner
const BOTTOM_RIGHT_CORNER: char = '┘';
const _BOTTOM_RIGHT_CORNER: 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 = '┬';

View File

@ -2,9 +2,6 @@
*/
use super::*;
use melib::mailbox::email::interpret_format_flowed;
use melib::mailbox::email::Attachment;
/// A horizontally split in half container.
pub struct HSplit {
top: Entity,
@ -428,22 +425,22 @@ impl Component for StatusBar {
// A box with a text content.
pub struct TextBox {
content: String,
_content: String,
}
impl TextBox {
pub fn new(s: String) -> Self {
TextBox {
content: s,
_content: s,
}
}
}
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;
}
}

View File

@ -1,7 +1,7 @@
/*! A parser module for user commands passed through the Ex mode.
*/
use std;
use nom::{digit, alpha};
use nom::{digit, };
named!(usize_c<usize>,
@ -12,7 +12,9 @@ named!(pub goto<usize>,
call!(usize_c))
);
/*
named!(pub sort<&str>,
preceded!(tag!("sort "),
map_res!(call!(alpha), std::str::from_utf8))
);
*/

View File

@ -1,10 +1,7 @@
use std;
use std::path::PathBuf;
use std::io::Write;
use std::ops::{Deref, DerefMut};
use std::fs;
use uuid::Uuid;
#[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();
f.write(bytes).unwrap();
f.flush().unwrap();
File {

View File

@ -141,10 +141,10 @@ impl fmt::Display for UIMode {
/// An event notification that is passed to Entities for handling.
pub struct Notification {
title: String,
content: String,
_title: String,
_content: String,
timestamp: std::time::Instant,
_timestamp: std::time::Instant,
}
/// 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
replies: VecDeque<UIEvent>,
backends: Backends,
_backends: Backends,
input_thread: chan::Sender<bool>,
}
@ -225,7 +225,7 @@ impl State<std::io::Stdout> {
context: Context {
accounts: accounts,
backends: backends,
_backends: backends,
settings: settings.clone(),
runtime_settings: settings,
dirty_areas: VecDeque::with_capacity(5),
@ -381,7 +381,7 @@ impl<W: Write> State<W> {
in_pipe.write(&buf).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;
},