This commit is contained in:
Jon Gjengset 2017-09-26 11:00:46 -04:00
parent 57a3955925
commit 69b31275db
No known key found for this signature in database
GPG Key ID: D64AC9D67176DC71
1 changed files with 17 additions and 12 deletions

View File

@ -1,11 +1,11 @@
extern crate xdg;
extern crate toml;
extern crate imap; extern crate imap;
extern crate rayon;
extern crate openssl;
extern crate systray;
extern crate mailparse; extern crate mailparse;
extern crate notify_rust; extern crate notify_rust;
extern crate openssl;
extern crate rayon;
extern crate systray;
extern crate toml;
extern crate xdg;
use openssl::ssl::{SslConnectorBuilder, SslMethod}; use openssl::ssl::{SslConnectorBuilder, SslMethod};
use imap::client::Client; use imap::client::Client;
@ -116,12 +116,14 @@ fn main() {
return; return;
} }
}; };
if let Err(e) = app.set_icon_from_file( if let Err(e) = app.set_icon_from_file(&"/usr/share/icons/Faenza/stock/24/stock_disconnect.png"
&"/usr/share/icons/Faenza/stock/24/stock_disconnect.png".to_string(), .to_string())
) { {
println!("Could not set application icon: {}", e); println!("Could not set application icon: {}", e);
} }
if let Err(e) = app.add_menu_item(&"Quit".to_string(), |window| { window.quit(); }) { if let Err(e) = app.add_menu_item(&"Quit".to_string(), |window| {
window.quit();
}) {
println!("Could not add application Quit menu option: {}", e); println!("Could not add application Quit menu option: {}", e);
} }
@ -134,8 +136,8 @@ fn main() {
let mut wait = 1; let mut wait = 1;
for _ in 0..5 { for _ in 0..5 {
let tls = SslConnectorBuilder::new(SslMethod::tls()).unwrap().build(); let tls = SslConnectorBuilder::new(SslMethod::tls()).unwrap().build();
let c = Client::secure_connect(account.server, account.server.0, tls) let c = Client::secure_connect(account.server, account.server.0, tls).and_then(
.and_then(|mut c| { |mut c| {
try!(c.login(account.username, &account.password)); try!(c.login(account.username, &account.password));
let cap = try!(c.capability()); let cap = try!(c.capability());
if !cap.iter().any(|c| c == "IDLE") { if !cap.iter().any(|c| c == "IDLE") {
@ -143,7 +145,8 @@ fn main() {
} }
try!(c.select("INBOX")); try!(c.select("INBOX"));
Ok((String::from(account.name), c)) Ok((String::from(account.name), c))
}); },
);
match c { match c {
Ok(c) => return Some(c), Ok(c) => return Some(c),
@ -277,6 +280,8 @@ fn main() {
break; break;
} }
} }
// TODO: this call will likely fail, since the connection has probably failed
// TODO: reconnect
imap_socket.logout().unwrap(); imap_socket.logout().unwrap();
}); });
} }