mirror of https://github.com/tauri-apps/tauri
Feature/whitelist (#9)
* feat(proton) whitelist API features * feat(whitelist) fix feature name for execute cmd * fix(whitelist) conflicting command names with q-app * feat(rust2018) cleanup (#8) * rust 2018 edition changes * fix whitespace * change super::super to crate
This commit is contained in:
parent
b9cc35ca39
commit
a1c46cd86f
|
@ -1,3 +1,5 @@
|
||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "bitflags"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
|
|
|
@ -1,56 +1,49 @@
|
||||||
extern crate cc;
|
use std::{env, path::PathBuf};
|
||||||
extern crate pkg_config;
|
|
||||||
|
|
||||||
use std::{
|
|
||||||
env,
|
|
||||||
path::{Path, PathBuf},
|
|
||||||
process::Command,
|
|
||||||
};
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let proton_path = PathBuf::from("../../../ui");
|
let proton_path = PathBuf::from("../../../ui");
|
||||||
|
|
||||||
let mut build = cc::Build::new();
|
let mut build = cc::Build::new();
|
||||||
|
|
||||||
|
build
|
||||||
|
.include(&proton_path)
|
||||||
|
.file("proton.c")
|
||||||
|
.flag_if_supported("-std=c11")
|
||||||
|
.flag_if_supported("-w");
|
||||||
|
|
||||||
|
if env::var("DEBUG").is_err() {
|
||||||
|
build.define("NDEBUG", None);
|
||||||
|
} else {
|
||||||
|
build.define("DEBUG", None);
|
||||||
|
}
|
||||||
|
|
||||||
|
let target = env::var("TARGET").unwrap();
|
||||||
|
|
||||||
|
if target.contains("windows") {
|
||||||
|
build.define("WEBVIEW_WINAPI", None);
|
||||||
|
for &lib in &["ole32", "comctl32", "oleaut32", "uuid", "gdi32"] {
|
||||||
|
println!("cargo:rustc-link-lib={}", lib);
|
||||||
|
}
|
||||||
|
} else if target.contains("linux") || target.contains("bsd") {
|
||||||
|
let webkit = pkg_config::Config::new()
|
||||||
|
.atleast_version("2.8")
|
||||||
|
.probe("webkit2gtk-4.0")
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
for path in webkit.include_paths {
|
||||||
|
build.include(path);
|
||||||
|
}
|
||||||
|
build.define("WEBVIEW_GTK", None);
|
||||||
|
} else if target.contains("apple") {
|
||||||
build
|
build
|
||||||
.include(&proton_path)
|
.define("WEBVIEW_COCOA", None)
|
||||||
.file("proton.c")
|
.flag("-x")
|
||||||
.flag_if_supported("-std=c11")
|
.flag("objective-c");
|
||||||
.flag_if_supported("-w");
|
println!("cargo:rustc-link-lib=framework=Cocoa");
|
||||||
|
println!("cargo:rustc-link-lib=framework=WebKit");
|
||||||
|
} else {
|
||||||
|
panic!("unsupported target");
|
||||||
|
}
|
||||||
|
|
||||||
if env::var("DEBUG").is_err() {
|
build.compile("proton");
|
||||||
build.define("NDEBUG", None);
|
|
||||||
} else {
|
|
||||||
build.define("DEBUG", None);
|
|
||||||
}
|
|
||||||
|
|
||||||
let target = env::var("TARGET").unwrap();
|
|
||||||
|
|
||||||
if target.contains("windows") {
|
|
||||||
build.define("WEBVIEW_WINAPI", None);
|
|
||||||
for &lib in &["ole32", "comctl32", "oleaut32", "uuid", "gdi32"] {
|
|
||||||
println!("cargo:rustc-link-lib={}", lib);
|
|
||||||
}
|
|
||||||
} else if target.contains("linux") || target.contains("bsd") {
|
|
||||||
let webkit = pkg_config::Config::new()
|
|
||||||
.atleast_version("2.8")
|
|
||||||
.probe("webkit2gtk-4.0")
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
for path in webkit.include_paths {
|
|
||||||
build.include(path);
|
|
||||||
}
|
|
||||||
build.define("WEBVIEW_GTK", None);
|
|
||||||
} else if target.contains("apple") {
|
|
||||||
build
|
|
||||||
.define("WEBVIEW_COCOA", None)
|
|
||||||
.flag("-x")
|
|
||||||
.flag("objective-c");
|
|
||||||
println!("cargo:rustc-link-lib=framework=Cocoa");
|
|
||||||
println!("cargo:rustc-link-lib=framework=WebKit");
|
|
||||||
} else {
|
|
||||||
panic!("unsupported target");
|
|
||||||
}
|
|
||||||
|
|
||||||
build.compile("proton");
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,41 +6,61 @@ extern crate bitflags;
|
||||||
use std::os::raw::*;
|
use std::os::raw::*;
|
||||||
|
|
||||||
// https://doc.rust-lang.org/nomicon/ffi.html#representing-opaque-structs
|
// https://doc.rust-lang.org/nomicon/ffi.html#representing-opaque-structs
|
||||||
#[repr(C)] pub struct CWebView { _private: [u8; 0] }
|
#[repr(C)]
|
||||||
|
pub struct CWebView {
|
||||||
|
_private: [u8; 0],
|
||||||
|
}
|
||||||
|
|
||||||
type ErasedExternalInvokeFn = extern "C" fn(webview: *mut CWebView, arg: *const c_char);
|
type ErasedExternalInvokeFn = extern "C" fn(webview: *mut CWebView, arg: *const c_char);
|
||||||
type ErasedDispatchFn = extern "C" fn(webview: *mut CWebView, arg: *mut c_void);
|
type ErasedDispatchFn = extern "C" fn(webview: *mut CWebView, arg: *mut c_void);
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub enum DialogType {
|
pub enum DialogType {
|
||||||
Open = 0,
|
Open = 0,
|
||||||
Save = 1,
|
Save = 1,
|
||||||
Alert = 2,
|
Alert = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
bitflags! {
|
bitflags! {
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct DialogFlags: u32 {
|
pub struct DialogFlags: u32 {
|
||||||
const FILE = 0b0000;
|
const FILE = 0b0000;
|
||||||
const DIRECTORY = 0b0001;
|
const DIRECTORY = 0b0001;
|
||||||
const INFO = 0b0010;
|
const INFO = 0b0010;
|
||||||
const WARNING = 0b0100;
|
const WARNING = 0b0100;
|
||||||
const ERROR = 0b0110;
|
const ERROR = 0b0110;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern {
|
extern "C" {
|
||||||
pub fn wrapper_webview_free(this: *mut CWebView);
|
pub fn wrapper_webview_free(this: *mut CWebView);
|
||||||
pub fn wrapper_webview_new(title: *const c_char, url: *const c_char, width: c_int, height: c_int, resizable: c_int, debug: c_int, external_invoke_cb: Option<ErasedExternalInvokeFn>, userdata: *mut c_void) -> *mut CWebView;
|
pub fn wrapper_webview_new(
|
||||||
pub fn webview_loop(this: *mut CWebView, blocking: c_int) -> c_int;
|
title: *const c_char,
|
||||||
pub fn webview_terminate(this: *mut CWebView);
|
url: *const c_char,
|
||||||
pub fn webview_exit(this: *mut CWebView);
|
width: c_int,
|
||||||
pub fn wrapper_webview_get_userdata(this: *mut CWebView) -> *mut c_void;
|
height: c_int,
|
||||||
pub fn webview_dispatch(this: *mut CWebView, f: Option<ErasedDispatchFn>, arg: *mut c_void);
|
resizable: c_int,
|
||||||
pub fn webview_eval(this: *mut CWebView, js: *const c_char) -> c_int;
|
debug: c_int,
|
||||||
pub fn webview_inject_css(this: *mut CWebView, css: *const c_char) -> c_int;
|
external_invoke_cb: Option<ErasedExternalInvokeFn>,
|
||||||
pub fn webview_set_title(this: *mut CWebView, title: *const c_char);
|
userdata: *mut c_void,
|
||||||
pub fn webview_set_fullscreen(this: *mut CWebView, fullscreen: c_int);
|
) -> *mut CWebView;
|
||||||
pub fn webview_set_color(this: *mut CWebView, red: u8, green: u8, blue: u8, alpha: u8);
|
pub fn webview_loop(this: *mut CWebView, blocking: c_int) -> c_int;
|
||||||
pub fn webview_dialog(this: *mut CWebView, dialog_type: DialogType, flags: DialogFlags, title: *const c_char, arg: *const c_char, result: *mut c_char, result_size: usize);
|
pub fn webview_terminate(this: *mut CWebView);
|
||||||
|
pub fn webview_exit(this: *mut CWebView);
|
||||||
|
pub fn wrapper_webview_get_userdata(this: *mut CWebView) -> *mut c_void;
|
||||||
|
pub fn webview_dispatch(this: *mut CWebView, f: Option<ErasedDispatchFn>, arg: *mut c_void);
|
||||||
|
pub fn webview_eval(this: *mut CWebView, js: *const c_char) -> c_int;
|
||||||
|
pub fn webview_inject_css(this: *mut CWebView, css: *const c_char) -> c_int;
|
||||||
|
pub fn webview_set_title(this: *mut CWebView, title: *const c_char);
|
||||||
|
pub fn webview_set_fullscreen(this: *mut CWebView, fullscreen: c_int);
|
||||||
|
pub fn webview_set_color(this: *mut CWebView, red: u8, green: u8, blue: u8, alpha: u8);
|
||||||
|
pub fn webview_dialog(
|
||||||
|
this: *mut CWebView,
|
||||||
|
dialog_type: DialogType,
|
||||||
|
flags: DialogFlags,
|
||||||
|
title: *const c_char,
|
||||||
|
arg: *const c_char,
|
||||||
|
result: *mut c_char,
|
||||||
|
result_size: usize,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ pub enum Error {
|
||||||
/// WebView was dropped.
|
/// WebView was dropped.
|
||||||
Dispatch,
|
Dispatch,
|
||||||
/// An user-specified error occurred. For use inside invoke and dispatch closures.
|
/// An user-specified error occurred. For use inside invoke and dispatch closures.
|
||||||
Custom(Box<CustomError>),
|
Custom(Box<dyn CustomError>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Error {
|
impl Error {
|
||||||
|
@ -36,7 +36,7 @@ impl Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl error::Error for Error {
|
impl error::Error for Error {
|
||||||
fn cause(&self) -> Option<&error::Error> {
|
fn cause(&self) -> Option<&dyn error::Error> {
|
||||||
match self {
|
match self {
|
||||||
Error::NulByte(cause) => Some(cause),
|
Error::NulByte(cause) => Some(cause),
|
||||||
_ => None,
|
_ => None,
|
||||||
|
@ -53,7 +53,7 @@ impl error::Error for Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for Error {
|
impl Display for Error {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
Error::UninitializedField(field) => write!(f, "Required field uninitialized: {}.", field),
|
Error::UninitializedField(field) => write!(f, "Required field uninitialized: {}.", field),
|
||||||
Error::Initialization => write!(f, "Webview failed to initialize."),
|
Error::Initialization => write!(f, "Webview failed to initialize."),
|
||||||
|
|
|
@ -16,7 +16,7 @@ use std::fmt::{self, Write};
|
||||||
///
|
///
|
||||||
/// view.eval(&format!("callback({});", web_view::escape(string)));
|
/// view.eval(&format!("callback({});", web_view::escape(string)));
|
||||||
/// ```
|
/// ```
|
||||||
pub fn escape(string: &str) -> Escaper {
|
pub fn escape(string: &str) -> Escaper<'_> {
|
||||||
Escaper(string)
|
Escaper(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ const SPECIAL: &[char] = &[
|
||||||
];
|
];
|
||||||
|
|
||||||
impl<'a> fmt::Display for Escaper<'a> {
|
impl<'a> fmt::Display for Escaper<'a> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
let &Escaper(mut string) = self;
|
let &Escaper(mut string) = self;
|
||||||
|
|
||||||
f.write_char('\'')?;
|
f.write_char('\'')?;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
extern crate boxfnonce;
|
|
||||||
extern crate proton_sys as ffi;
|
extern crate proton_sys as ffi;
|
||||||
extern crate urlencoding;
|
|
||||||
|
|
||||||
mod color;
|
mod color;
|
||||||
mod dialog;
|
mod dialog;
|
||||||
|
@ -75,7 +75,7 @@ pub struct WebViewBuilder<'a, T: 'a, I, C> {
|
||||||
|
|
||||||
impl<'a, T: 'a, I, C> Default for WebViewBuilder<'a, T, I, C>
|
impl<'a, T: 'a, I, C> Default for WebViewBuilder<'a, T, I, C>
|
||||||
where
|
where
|
||||||
I: FnMut(&mut WebView<T>, &str) -> WVResult + 'a,
|
I: FnMut(&mut WebView<'_, T>, &str) -> WVResult + 'a,
|
||||||
C: AsRef<str>,
|
C: AsRef<str>,
|
||||||
{
|
{
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
|
@ -99,7 +99,7 @@ where
|
||||||
|
|
||||||
impl<'a, T: 'a, I, C> WebViewBuilder<'a, T, I, C>
|
impl<'a, T: 'a, I, C> WebViewBuilder<'a, T, I, C>
|
||||||
where
|
where
|
||||||
I: FnMut(&mut WebView<T>, &str) -> WVResult + 'a,
|
I: FnMut(&mut WebView<'_, T>, &str) -> WVResult + 'a,
|
||||||
C: AsRef<str>,
|
C: AsRef<str>,
|
||||||
{
|
{
|
||||||
/// Alias for [`WebViewBuilder::default()`].
|
/// Alias for [`WebViewBuilder::default()`].
|
||||||
|
@ -215,7 +215,7 @@ where
|
||||||
/// [`WebViewBuilder::default()`]: struct.WebviewBuilder.html#impl-Default
|
/// [`WebViewBuilder::default()`]: struct.WebviewBuilder.html#impl-Default
|
||||||
pub fn builder<'a, T, I, C>() -> WebViewBuilder<'a, T, I, C>
|
pub fn builder<'a, T, I, C>() -> WebViewBuilder<'a, T, I, C>
|
||||||
where
|
where
|
||||||
I: FnMut(&mut WebView<T>, &str) -> WVResult + 'a,
|
I: FnMut(&mut WebView<'_, T>, &str) -> WVResult + 'a,
|
||||||
C: AsRef<str>,
|
C: AsRef<str>,
|
||||||
{
|
{
|
||||||
WebViewBuilder::new()
|
WebViewBuilder::new()
|
||||||
|
@ -224,7 +224,7 @@ where
|
||||||
struct UserData<'a, T> {
|
struct UserData<'a, T> {
|
||||||
inner: T,
|
inner: T,
|
||||||
live: Arc<RwLock<()>>,
|
live: Arc<RwLock<()>>,
|
||||||
invoke_handler: Box<FnMut(&mut WebView<T>, &str) -> WVResult + 'a>,
|
invoke_handler: Box<dyn FnMut(&mut WebView<'_, T>, &str) -> WVResult + 'a>,
|
||||||
result: WVResult,
|
result: WVResult,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ struct UserData<'a, T> {
|
||||||
///
|
///
|
||||||
/// [`WebViewBuilder`]: struct.WebViewBuilder.html
|
/// [`WebViewBuilder`]: struct.WebViewBuilder.html
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct WebView<'a, T: 'a> {
|
pub struct WebView<'a, T> {
|
||||||
inner: *mut CWebView,
|
inner: *mut CWebView,
|
||||||
_phantom: PhantomData<&'a mut T>,
|
_phantom: PhantomData<&'a mut T>,
|
||||||
}
|
}
|
||||||
|
@ -252,7 +252,7 @@ impl<'a, T> WebView<'a, T> {
|
||||||
invoke_handler: I,
|
invoke_handler: I,
|
||||||
) -> WVResult<WebView<'a, T>>
|
) -> WVResult<WebView<'a, T>>
|
||||||
where
|
where
|
||||||
I: FnMut(&mut WebView<T>, &str) -> WVResult + 'a,
|
I: FnMut(&mut WebView<'_, T>, &str) -> WVResult + 'a,
|
||||||
{
|
{
|
||||||
let user_data = Box::new(UserData {
|
let user_data = Box::new(UserData {
|
||||||
inner: user_data,
|
inner: user_data,
|
||||||
|
@ -275,7 +275,7 @@ impl<'a, T> WebView<'a, T> {
|
||||||
);
|
);
|
||||||
|
|
||||||
if inner.is_null() {
|
if inner.is_null() {
|
||||||
Box::<UserData<T>>::from_raw(user_data_ptr);
|
Box::<UserData<'_, T>>::from_raw(user_data_ptr);
|
||||||
Err(Error::Initialization)
|
Err(Error::Initialization)
|
||||||
} else {
|
} else {
|
||||||
Ok(WebView::from_ptr(inner))
|
Ok(WebView::from_ptr(inner))
|
||||||
|
@ -473,7 +473,7 @@ impl<T> Handle<T> {
|
||||||
/// [`step()`]: struct.WebView.html#method.step
|
/// [`step()`]: struct.WebView.html#method.step
|
||||||
pub fn dispatch<F>(&self, f: F) -> WVResult
|
pub fn dispatch<F>(&self, f: F) -> WVResult
|
||||||
where
|
where
|
||||||
F: FnOnce(&mut WebView<T>) -> WVResult + Send + 'static,
|
F: FnOnce(&mut WebView<'_, T>) -> WVResult + Send + 'static,
|
||||||
{
|
{
|
||||||
// Abort if WebView has been dropped. Otherwise, keep it alive until closure has been
|
// Abort if WebView has been dropped. Otherwise, keep it alive until closure has been
|
||||||
// dispatched.
|
// dispatched.
|
||||||
|
@ -509,7 +509,7 @@ extern "C" fn ffi_dispatch_handler<T>(webview: *mut CWebView, arg: *mut c_void)
|
||||||
let mut handle = mem::ManuallyDrop::new(WebView::<T>::from_ptr(webview));
|
let mut handle = mem::ManuallyDrop::new(WebView::<T>::from_ptr(webview));
|
||||||
let result = {
|
let result = {
|
||||||
let callback =
|
let callback =
|
||||||
Box::<SendBoxFnOnce<'static, (&mut WebView<T>,), WVResult>>::from_raw(arg as _);
|
Box::<SendBoxFnOnce<'static, (&mut WebView<'_, T>,), WVResult>>::from_raw(arg as _);
|
||||||
callback.call(&mut handle)
|
callback.call(&mut handle)
|
||||||
};
|
};
|
||||||
handle.user_data_wrapper_mut().result = result;
|
handle.user_data_wrapper_mut().result = result;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -26,3 +26,15 @@ tar = "0.4"
|
||||||
flate2 = "1"
|
flate2 = "1"
|
||||||
hyper-old-types = "0.11.0"
|
hyper-old-types = "0.11.0"
|
||||||
sysinfo = "0.9"
|
sysinfo = "0.9"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
api = []
|
||||||
|
all-api = []
|
||||||
|
readTextFile = []
|
||||||
|
readBinaryFile = []
|
||||||
|
writeFile = []
|
||||||
|
listFiles = []
|
||||||
|
listDirs = []
|
||||||
|
setTitle = []
|
||||||
|
execute = []
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
mod cmd;
|
||||||
|
|
||||||
|
use proton_ui::WebView;
|
||||||
|
|
||||||
|
#[allow(unused_variables)]
|
||||||
|
pub fn handler<T: 'static>(webview: &mut WebView<'_, T>, arg: &str) -> bool {
|
||||||
|
#[cfg(feature = "api")]
|
||||||
|
{
|
||||||
|
use cmd::Cmd::*;
|
||||||
|
match serde_json::from_str(arg) {
|
||||||
|
Err(_) => false,
|
||||||
|
Ok(command) => {
|
||||||
|
match command {
|
||||||
|
#[cfg(any(feature = "all-api", feature = "readTextFile"))]
|
||||||
|
ReadTextFile {
|
||||||
|
path,
|
||||||
|
callback,
|
||||||
|
error,
|
||||||
|
} => {
|
||||||
|
super::file_system::read_text_file(webview, path, callback, error);
|
||||||
|
}
|
||||||
|
#[cfg(any(feature = "all-api", feature = "readBinaryFile"))]
|
||||||
|
ReadBinaryFile {
|
||||||
|
path,
|
||||||
|
callback,
|
||||||
|
error,
|
||||||
|
} => {
|
||||||
|
super::file_system::read_binary_file(webview, path, callback, error);
|
||||||
|
}
|
||||||
|
#[cfg(any(feature = "all-api", feature = "writeFile"))]
|
||||||
|
WriteFile {
|
||||||
|
file,
|
||||||
|
contents,
|
||||||
|
callback,
|
||||||
|
error,
|
||||||
|
} => {
|
||||||
|
super::file_system::write_file(webview, file, contents, callback, error);
|
||||||
|
}
|
||||||
|
#[cfg(any(feature = "all-api", feature = "listDirs"))]
|
||||||
|
ListDirs {
|
||||||
|
path,
|
||||||
|
callback,
|
||||||
|
error,
|
||||||
|
} => {
|
||||||
|
super::file_system::list_dirs(webview, path, callback, error);
|
||||||
|
}
|
||||||
|
#[cfg(any(feature = "all-api", feature = "listFiles"))]
|
||||||
|
ListFiles {
|
||||||
|
path,
|
||||||
|
callback,
|
||||||
|
error,
|
||||||
|
} => {
|
||||||
|
super::file_system::list(webview, path, callback, error);
|
||||||
|
}
|
||||||
|
#[cfg(any(feature = "all-api", feature = "setTitle"))]
|
||||||
|
SetTitle { title } => {
|
||||||
|
webview.set_title(&title).unwrap();
|
||||||
|
}
|
||||||
|
#[cfg(any(feature = "all-api", feature = "execute"))]
|
||||||
|
Execute {
|
||||||
|
command,
|
||||||
|
args,
|
||||||
|
callback,
|
||||||
|
error,
|
||||||
|
} => {
|
||||||
|
super::command::call(webview, command, args, callback, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[cfg(not(feature = "api"))]
|
||||||
|
false
|
||||||
|
}
|
|
@ -1,37 +1,42 @@
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
#[serde(tag = "cmd", rename_all = "camelCase")]
|
#[serde(tag = "cmd", rename_all = "camelCase")]
|
||||||
|
#[cfg(feature = "api")]
|
||||||
pub enum Cmd {
|
pub enum Cmd {
|
||||||
Init,
|
#[cfg(any(feature = "all-api", feature = "readTextFile"))]
|
||||||
ReadAsString {
|
ReadTextFile {
|
||||||
path: String,
|
path: String,
|
||||||
callback: String,
|
callback: String,
|
||||||
error: String,
|
error: String,
|
||||||
},
|
},
|
||||||
ReadAsBinary {
|
#[cfg(any(feature = "all-api", feature = "readBinaryFile"))]
|
||||||
|
ReadBinaryFile {
|
||||||
path: String,
|
path: String,
|
||||||
callback: String,
|
callback: String,
|
||||||
error: String,
|
error: String,
|
||||||
},
|
},
|
||||||
Write {
|
#[cfg(any(feature = "all-api", feature = "writeFile"))]
|
||||||
|
WriteFile {
|
||||||
file: String,
|
file: String,
|
||||||
contents: String,
|
contents: String,
|
||||||
callback: String,
|
callback: String,
|
||||||
error: String,
|
error: String,
|
||||||
},
|
},
|
||||||
List {
|
#[cfg(any(feature = "all-api", feature = "listFiles"))]
|
||||||
|
ListFiles {
|
||||||
path: String,
|
path: String,
|
||||||
callback: String,
|
callback: String,
|
||||||
error: String,
|
error: String,
|
||||||
},
|
},
|
||||||
|
#[cfg(any(feature = "all-api", feature = "listDirs"))]
|
||||||
ListDirs {
|
ListDirs {
|
||||||
path: String,
|
path: String,
|
||||||
callback: String,
|
callback: String,
|
||||||
error: String,
|
error: String,
|
||||||
},
|
},
|
||||||
SetTitle {
|
#[cfg(any(feature = "all-api", feature = "setTitle"))]
|
||||||
title: String,
|
SetTitle { title: String },
|
||||||
},
|
#[cfg(any(feature = "all-api", feature = "execute"))]
|
||||||
Call {
|
Execute {
|
||||||
command: String,
|
command: String,
|
||||||
args: Vec<String>,
|
args: Vec<String>,
|
||||||
callback: String,
|
callback: String,
|
||||||
|
|
|
@ -1,63 +0,0 @@
|
||||||
mod cmd;
|
|
||||||
|
|
||||||
use proton_ui::WebView;
|
|
||||||
|
|
||||||
pub fn handler<T: 'static>(webview: &mut WebView<T>, arg: &str) -> bool {
|
|
||||||
use cmd::Cmd::*;
|
|
||||||
match serde_json::from_str(arg) {
|
|
||||||
Err(_) => false,
|
|
||||||
Ok(command) => {
|
|
||||||
match command {
|
|
||||||
Init => (),
|
|
||||||
ReadAsString {
|
|
||||||
path,
|
|
||||||
callback,
|
|
||||||
error,
|
|
||||||
} => {
|
|
||||||
super::file_system::read_text_file(webview, path, callback, error);
|
|
||||||
}
|
|
||||||
ReadAsBinary {
|
|
||||||
path,
|
|
||||||
callback,
|
|
||||||
error,
|
|
||||||
} => {
|
|
||||||
super::file_system::read_binary_file(webview, path, callback, error);
|
|
||||||
}
|
|
||||||
Write {
|
|
||||||
file,
|
|
||||||
contents,
|
|
||||||
callback,
|
|
||||||
error,
|
|
||||||
} => {
|
|
||||||
super::file_system::write_file(webview, file, contents, callback, error);
|
|
||||||
}
|
|
||||||
ListDirs {
|
|
||||||
path,
|
|
||||||
callback,
|
|
||||||
error,
|
|
||||||
} => {
|
|
||||||
super::file_system::list_dirs(webview, path, callback, error);
|
|
||||||
}
|
|
||||||
List {
|
|
||||||
path,
|
|
||||||
callback,
|
|
||||||
error,
|
|
||||||
} => {
|
|
||||||
super::file_system::list(webview, path, callback, error);
|
|
||||||
}
|
|
||||||
SetTitle { title } => {
|
|
||||||
webview.set_title(&title).unwrap();
|
|
||||||
}
|
|
||||||
Call {
|
|
||||||
command,
|
|
||||||
args,
|
|
||||||
callback,
|
|
||||||
error,
|
|
||||||
} => {
|
|
||||||
super::command::call(webview, command, args, callback, error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -59,7 +59,7 @@ pub fn spawn_relative_command(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn call<T: 'static>(
|
pub fn call<T: 'static>(
|
||||||
webview: &mut WebView<T>,
|
webview: &mut WebView<'_, T>,
|
||||||
command: String,
|
command: String,
|
||||||
args: Vec<String>,
|
args: Vec<String>,
|
||||||
callback: String,
|
callback: String,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
extern crate dirs;
|
|
||||||
extern crate tempfile;
|
use tempfile;
|
||||||
|
|
||||||
mod utils;
|
mod utils;
|
||||||
use ignore::Walk;
|
use ignore::Walk;
|
|
@ -1,7 +1,5 @@
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
extern crate serde_json;
|
|
||||||
|
|
||||||
mod error;
|
mod error;
|
||||||
mod extract;
|
mod extract;
|
||||||
mod file_move;
|
mod file_move;
|
|
@ -9,7 +9,7 @@ pub enum Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Display for Error {
|
impl std::fmt::Display for Error {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
use Error::*;
|
use Error::*;
|
||||||
match *self {
|
match *self {
|
||||||
Extract(ref s) => write!(f, "ExtractError: {}", s),
|
Extract(ref s) => write!(f, "ExtractError: {}", s),
|
||||||
|
@ -24,7 +24,7 @@ impl std::error::Error for Error {
|
||||||
"File Error"
|
"File Error"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cause(&self) -> Option<&std::error::Error> {
|
fn cause(&self) -> Option<&dyn std::error::Error> {
|
||||||
use Error::*;
|
use Error::*;
|
||||||
Some(match *self {
|
Some(match *self {
|
||||||
Io(ref e) => e,
|
Io(ref e) => e,
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
extern crate either;
|
use either;
|
||||||
extern crate flate2;
|
use flate2;
|
||||||
extern crate tar;
|
use tar;
|
||||||
extern crate zip;
|
use zip;
|
||||||
|
|
||||||
use super::error::*;
|
use crate::file::error::*;
|
||||||
use either::Either;
|
use either::Either;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path;
|
use std::path;
|
||||||
|
|
||||||
use super::error::*;
|
use crate::file::error::*;
|
||||||
|
|
||||||
/// Moves a file from the given path to the specified destination.
|
/// Moves a file from the given path to the specified destination.
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,13 +1,18 @@
|
||||||
use proton_ui::WebView;
|
use proton_ui::WebView;
|
||||||
|
|
||||||
use super::dir;
|
use crate::dir;
|
||||||
use super::file;
|
use crate::file;
|
||||||
use super::run_async;
|
use crate::run_async;
|
||||||
|
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
pub fn list<T: 'static>(webview: &mut WebView<T>, path: String, callback: String, error: String) {
|
pub fn list<T: 'static>(
|
||||||
|
webview: &mut WebView<'_, T>,
|
||||||
|
path: String,
|
||||||
|
callback: String,
|
||||||
|
error: String,
|
||||||
|
) {
|
||||||
run_async(
|
run_async(
|
||||||
webview,
|
webview,
|
||||||
move || {
|
move || {
|
||||||
|
@ -20,7 +25,7 @@ pub fn list<T: 'static>(webview: &mut WebView<T>, path: String, callback: String
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn list_dirs<T: 'static>(
|
pub fn list_dirs<T: 'static>(
|
||||||
webview: &mut WebView<T>,
|
webview: &mut WebView<'_, T>,
|
||||||
path: String,
|
path: String,
|
||||||
callback: String,
|
callback: String,
|
||||||
error: String,
|
error: String,
|
||||||
|
@ -37,7 +42,7 @@ pub fn list_dirs<T: 'static>(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_file<T: 'static>(
|
pub fn write_file<T: 'static>(
|
||||||
webview: &mut WebView<T>,
|
webview: &mut WebView<'_, T>,
|
||||||
file: String,
|
file: String,
|
||||||
contents: String,
|
contents: String,
|
||||||
callback: String,
|
callback: String,
|
||||||
|
@ -60,7 +65,7 @@ pub fn write_file<T: 'static>(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read_text_file<T: 'static>(
|
pub fn read_text_file<T: 'static>(
|
||||||
webview: &mut WebView<T>,
|
webview: &mut WebView<'_, T>,
|
||||||
path: String,
|
path: String,
|
||||||
callback: String,
|
callback: String,
|
||||||
error: String,
|
error: String,
|
||||||
|
@ -80,7 +85,7 @@ pub fn read_text_file<T: 'static>(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read_binary_file<T: 'static>(
|
pub fn read_binary_file<T: 'static>(
|
||||||
webview: &mut WebView<T>,
|
webview: &mut WebView<'_, T>,
|
||||||
path: String,
|
path: String,
|
||||||
callback: String,
|
callback: String,
|
||||||
error: String,
|
error: String,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
extern crate pbr;
|
use pbr;
|
||||||
extern crate reqwest;
|
use reqwest;
|
||||||
|
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use std::io;
|
use std::io;
|
|
@ -11,7 +11,7 @@ pub enum Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Display for Error {
|
impl std::fmt::Display for Error {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
use Error::*;
|
use Error::*;
|
||||||
match *self {
|
match *self {
|
||||||
Download(ref s) => write!(f, "DownloadError: {}", s),
|
Download(ref s) => write!(f, "DownloadError: {}", s),
|
||||||
|
@ -27,7 +27,7 @@ impl std::error::Error for Error {
|
||||||
"Http Error"
|
"Http Error"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cause(&self) -> Option<&std::error::Error> {
|
fn cause(&self) -> Option<&dyn std::error::Error> {
|
||||||
use Error::*;
|
use Error::*;
|
||||||
Some(match *self {
|
Some(match *self {
|
||||||
Json(ref e) => e,
|
Json(ref e) => e,
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
extern crate threadpool;
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate serde_derive;
|
extern crate serde_derive;
|
||||||
|
|
||||||
|
@ -18,7 +17,6 @@ pub mod tcp;
|
||||||
pub mod updater;
|
pub mod updater;
|
||||||
pub mod version;
|
pub mod version;
|
||||||
|
|
||||||
extern crate proton_ui;
|
|
||||||
use proton_ui::WebView;
|
use proton_ui::WebView;
|
||||||
|
|
||||||
use threadpool::ThreadPool;
|
use threadpool::ThreadPool;
|
||||||
|
@ -26,7 +24,7 @@ use threadpool::ThreadPool;
|
||||||
thread_local!(static POOL: ThreadPool = ThreadPool::new(4));
|
thread_local!(static POOL: ThreadPool = ThreadPool::new(4));
|
||||||
|
|
||||||
pub fn run_async<T: 'static, F: FnOnce() -> Result<String, String> + Send + 'static>(
|
pub fn run_async<T: 'static, F: FnOnce() -> Result<String, String> + Send + 'static>(
|
||||||
webview: &mut WebView<T>,
|
webview: &mut WebView<'_, T>,
|
||||||
what: F,
|
what: F,
|
||||||
callback: String,
|
callback: String,
|
||||||
error: String,
|
error: String,
|
||||||
|
|
|
@ -8,7 +8,7 @@ pub enum Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Display for Error {
|
impl std::fmt::Display for Error {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
use Error::*;
|
use Error::*;
|
||||||
match *self {
|
match *self {
|
||||||
Arch(ref s) => write!(f, "ArchError: {}", s),
|
Arch(ref s) => write!(f, "ArchError: {}", s),
|
||||||
|
@ -23,7 +23,7 @@ impl std::error::Error for Error {
|
||||||
"Platform Error"
|
"Platform Error"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cause(&self) -> Option<&std::error::Error> {
|
fn cause(&self) -> Option<&dyn std::error::Error> {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
extern crate sysinfo;
|
use sysinfo;
|
||||||
|
|
||||||
pub use sysinfo::{Process, ProcessExt, Signal, System, SystemExt};
|
pub use sysinfo::{Process, ProcessExt, Signal, System, SystemExt};
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::net::TcpListener;
|
use std::net::TcpListener;
|
||||||
|
|
||||||
extern crate rand;
|
use rand;
|
||||||
|
|
||||||
use rand::distributions::{Distribution, Uniform};
|
use rand::distributions::{Distribution, Uniform};
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
extern crate hyper_old_types;
|
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use super::file::{Extract, Move};
|
use crate::file::{Extract, Move};
|
||||||
use super::http;
|
use crate::http;
|
||||||
|
|
||||||
pub mod github;
|
pub mod github;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use super::super::file;
|
use crate::file;
|
||||||
use super::super::http;
|
use crate::http;
|
||||||
use super::super::version;
|
use crate::version;
|
||||||
use reqwest;
|
use reqwest;
|
||||||
use std;
|
use std;
|
||||||
use zip::result::ZipError;
|
use zip::result::ZipError;
|
||||||
|
@ -18,7 +18,7 @@ pub enum Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Display for Error {
|
impl std::fmt::Display for Error {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
use Error::*;
|
use Error::*;
|
||||||
match *self {
|
match *self {
|
||||||
Updater(ref s) => write!(f, "UpdaterError: {}", s),
|
Updater(ref s) => write!(f, "UpdaterError: {}", s),
|
||||||
|
@ -38,7 +38,7 @@ impl std::error::Error for Error {
|
||||||
"Updater Error"
|
"Updater Error"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cause(&self) -> Option<&std::error::Error> {
|
fn cause(&self) -> Option<&dyn std::error::Error> {
|
||||||
use Error::*;
|
use Error::*;
|
||||||
Some(match *self {
|
Some(match *self {
|
||||||
Io(ref e) => e,
|
Io(ref e) => e,
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
mod release;
|
mod release;
|
||||||
pub use super::error::Error;
|
pub use crate::updater::error::Error;
|
||||||
pub use release::*;
|
pub use release::*;
|
||||||
|
|
||||||
use super::super::http;
|
use crate::http;
|
||||||
|
|
||||||
pub fn get_latest_release(repo_owner: &str, repo_name: &str) -> Result<Release, Error> {
|
pub fn get_latest_release(repo_owner: &str, repo_name: &str) -> Result<Release, Error> {
|
||||||
set_ssl_vars!();
|
set_ssl_vars!();
|
|
@ -1,4 +1,4 @@
|
||||||
use super::super::error::*;
|
use crate::updater::error::*;
|
||||||
use hyper_old_types::header::{LinkValue, RelationType};
|
use hyper_old_types::header::{LinkValue, RelationType};
|
||||||
use serde_json;
|
use serde_json;
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ pub enum Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Display for Error {
|
impl std::fmt::Display for Error {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
use Error::*;
|
use Error::*;
|
||||||
match *self {
|
match *self {
|
||||||
SemVer(ref e) => write!(f, "SemVerError: {}", e),
|
SemVer(ref e) => write!(f, "SemVerError: {}", e),
|
||||||
|
@ -20,7 +20,7 @@ impl std::error::Error for Error {
|
||||||
"Version Error"
|
"Version Error"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cause(&self) -> Option<&std::error::Error> {
|
fn cause(&self) -> Option<&dyn std::error::Error> {
|
||||||
use Error::*;
|
use Error::*;
|
||||||
Some(match *self {
|
Some(match *self {
|
||||||
SemVer(ref e) => e,
|
SemVer(ref e) => e,
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "adler32"
|
name = "adler32"
|
||||||
version = "1.0.3"
|
version = "1.0.3"
|
||||||
|
@ -448,7 +450,7 @@ dependencies = [
|
||||||
"crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
"miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"miniz_oxide_c_api 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"miniz_oxide_c_api 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -630,7 +632,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "miniz_oxide"
|
name = "miniz_oxide"
|
||||||
version = "0.2.2"
|
version = "0.3.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
"adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -638,13 +640,13 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "miniz_oxide_c_api"
|
name = "miniz_oxide_c_api"
|
||||||
version = "0.2.2"
|
version = "0.2.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"miniz_oxide 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"miniz_oxide 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1443,8 +1445,8 @@ dependencies = [
|
||||||
"checksum memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2ffa2c986de11a9df78620c01eeaaf27d94d3ff02bf81bfcca953102dd0c6ff"
|
"checksum memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2ffa2c986de11a9df78620c01eeaaf27d94d3ff02bf81bfcca953102dd0c6ff"
|
||||||
"checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3"
|
"checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3"
|
||||||
"checksum miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9e3ae51cea1576ceba0dde3d484d30e6e5b86dee0b2d412fe3a16a15c98202"
|
"checksum miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9e3ae51cea1576ceba0dde3d484d30e6e5b86dee0b2d412fe3a16a15c98202"
|
||||||
"checksum miniz_oxide 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b6c3756d66cf286314d5f7ebe74886188a9a92f5eee68b06f31ac2b4f314c99d"
|
"checksum miniz_oxide 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c061edee74a88eb35d876ce88b94d77a0448a201de111c244b70d047f5820516"
|
||||||
"checksum miniz_oxide_c_api 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5b78ca5446dd9fe0dab00e058731b6b08a8c1d2b9cdb8efb10876e24e9ae2494"
|
"checksum miniz_oxide_c_api 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6c675792957b0d19933816c4e1d56663c341dd9bfa31cb2140ff2267c1d8ecf4"
|
||||||
"checksum msi 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a20bdea5e04f55fae0d8f89e88beec71822f2d63f61487ff2205d9d05b677923"
|
"checksum msi 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a20bdea5e04f55fae0d8f89e88beec71822f2d63f61487ff2205d9d05b677923"
|
||||||
"checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945"
|
"checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945"
|
||||||
"checksum num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09"
|
"checksum num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09"
|
||||||
|
|
|
@ -236,7 +236,7 @@ struct AppCategoryVisitor {
|
||||||
impl<'d> serde::de::Visitor<'d> for AppCategoryVisitor {
|
impl<'d> serde::de::Visitor<'d> for AppCategoryVisitor {
|
||||||
type Value = AppCategory;
|
type Value = AppCategory;
|
||||||
|
|
||||||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self.did_you_mean {
|
match self.did_you_mean {
|
||||||
Some(string) => write!(
|
Some(string) => write!(
|
||||||
formatter,
|
formatter,
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use crate::ResultExt;
|
||||||
use std;
|
use std;
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
use std::fs::{self, File};
|
use std::fs::{self, File};
|
||||||
|
@ -5,7 +6,6 @@ use std::io::{self, BufWriter, Write};
|
||||||
use std::path::{Component, Path, PathBuf};
|
use std::path::{Component, Path, PathBuf};
|
||||||
use term;
|
use term;
|
||||||
use walkdir;
|
use walkdir;
|
||||||
use crate::ResultExt;
|
|
||||||
|
|
||||||
/// Returns true if the path has a filename indicating that it is a high-desity
|
/// Returns true if the path has a filename indicating that it is a high-desity
|
||||||
/// "retina" icon. Specifically, returns true the the file stem ends with
|
/// "retina" icon. Specifically, returns true the the file stem ends with
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
// generate postinst or prerm files.
|
// generate postinst or prerm files.
|
||||||
|
|
||||||
use super::common;
|
use super::common;
|
||||||
|
use crate::{ResultExt, Settings};
|
||||||
use ar;
|
use ar;
|
||||||
use icns;
|
use icns;
|
||||||
use image::png::{PNGDecoder, PNGEncoder};
|
use image::png::{PNGDecoder, PNGEncoder};
|
||||||
|
@ -32,7 +33,6 @@ use std::io::{self, Write};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use tar;
|
use tar;
|
||||||
use walkdir::WalkDir;
|
use walkdir::WalkDir;
|
||||||
use crate::{ResultExt, Settings};
|
|
||||||
|
|
||||||
pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
|
pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
|
||||||
let arch = match settings.binary_arch() {
|
let arch = match settings.binary_arch() {
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
// explanation.
|
// explanation.
|
||||||
|
|
||||||
use super::common;
|
use super::common;
|
||||||
|
use crate::{ResultExt, Settings};
|
||||||
use icns;
|
use icns;
|
||||||
use image::png::{PNGDecoder, PNGEncoder};
|
use image::png::{PNGDecoder, PNGEncoder};
|
||||||
use image::{self, GenericImage, ImageDecoder};
|
use image::{self, GenericImage, ImageDecoder};
|
||||||
|
@ -17,7 +18,6 @@ use std::ffi::OsStr;
|
||||||
use std::fs::{self, File};
|
use std::fs::{self, File};
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use crate::{ResultExt, Settings};
|
|
||||||
|
|
||||||
pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
|
pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
|
||||||
common::print_warning("iOS bundle support is still experimental.")?;
|
common::print_warning("iOS bundle support is still experimental.")?;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use super::common;
|
use super::common;
|
||||||
use super::settings::Settings;
|
use super::settings::Settings;
|
||||||
|
use crate::ResultExt;
|
||||||
use cab;
|
use cab;
|
||||||
use msi;
|
use msi;
|
||||||
use std;
|
use std;
|
||||||
|
@ -9,7 +10,6 @@ use std::fs;
|
||||||
use std::io::{self, Write};
|
use std::io::{self, Write};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
use crate::ResultExt;
|
|
||||||
|
|
||||||
type Package = msi::Package<fs::File>;
|
type Package = msi::Package<fs::File>;
|
||||||
|
|
||||||
|
@ -319,7 +319,10 @@ fn divide_resources_into_cabinets(mut resources: Vec<ResourceInfo>) -> Vec<Cabin
|
||||||
|
|
||||||
// Creates the CAB archives within the package that contain the binary
|
// Creates the CAB archives within the package that contain the binary
|
||||||
// execuable and all the resource files.
|
// execuable and all the resource files.
|
||||||
fn generate_resource_cabinets(package: &mut Package, cabinets: &[CabinetInfo]) -> crate::Result<()> {
|
fn generate_resource_cabinets(
|
||||||
|
package: &mut Package,
|
||||||
|
cabinets: &[CabinetInfo],
|
||||||
|
) -> crate::Result<()> {
|
||||||
for cabinet_info in cabinets.iter() {
|
for cabinet_info in cabinets.iter() {
|
||||||
let mut builder = cab::CabinetBuilder::new();
|
let mut builder = cab::CabinetBuilder::new();
|
||||||
let mut file_map = HashMap::<String, &Path>::new();
|
let mut file_map = HashMap::<String, &Path>::new();
|
||||||
|
@ -351,7 +354,10 @@ fn generate_resource_cabinets(package: &mut Package, cabinets: &[CabinetInfo]) -
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates and populates the `Directory` database table for the package.
|
// Creates and populates the `Directory` database table for the package.
|
||||||
fn create_directory_table(package: &mut Package, directories: &[DirectoryInfo]) -> crate::Result<()> {
|
fn create_directory_table(
|
||||||
|
package: &mut Package,
|
||||||
|
directories: &[DirectoryInfo],
|
||||||
|
) -> crate::Result<()> {
|
||||||
package.create_table(
|
package.create_table(
|
||||||
"Directory",
|
"Directory",
|
||||||
vec![
|
vec![
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
// files into the `Contents` directory of the bundle.
|
// files into the `Contents` directory of the bundle.
|
||||||
|
|
||||||
use super::common;
|
use super::common;
|
||||||
|
use crate::{ResultExt, Settings};
|
||||||
use chrono;
|
use chrono;
|
||||||
use dirs;
|
use dirs;
|
||||||
use icns;
|
use icns;
|
||||||
|
@ -28,7 +29,6 @@ use std::fs::{self, File};
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
use std::io::{self, BufWriter};
|
use std::io::{self, BufWriter};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use crate::{ResultExt, Settings};
|
|
||||||
|
|
||||||
pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
|
pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
|
||||||
let app_bundle_name = format!("{}.app", settings.bundle_name());
|
let app_bundle_name = format!("{}.app", settings.bundle_name());
|
||||||
|
@ -232,7 +232,10 @@ fn copy_frameworks_to_bundle(bundle_directory: &Path, settings: &Settings) -> cr
|
||||||
/// Given a list of icon files, try to produce an ICNS file in the resources
|
/// Given a list of icon files, try to produce an ICNS file in the resources
|
||||||
/// directory and return the path to it. Returns `Ok(None)` if no usable icons
|
/// directory and return the path to it. Returns `Ok(None)` if no usable icons
|
||||||
/// were provided.
|
/// were provided.
|
||||||
fn create_icns_file(resources_dir: &PathBuf, settings: &Settings) -> crate::Result<Option<PathBuf>> {
|
fn create_icns_file(
|
||||||
|
resources_dir: &PathBuf,
|
||||||
|
settings: &Settings,
|
||||||
|
) -> crate::Result<Option<PathBuf>> {
|
||||||
if settings.icon_files().count() == 0 {
|
if settings.icon_files().count() == 0 {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use std::path::PathBuf;
|
|
||||||
use crate::Settings;
|
use crate::Settings;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
pub fn bundle_project(_settings: &Settings) -> crate::Result<Vec<PathBuf>> {
|
pub fn bundle_project(_settings: &Settings) -> crate::Result<Vec<PathBuf>> {
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
|
|
|
@ -138,7 +138,7 @@ impl CargoSettings {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Settings {
|
impl Settings {
|
||||||
pub fn new(current_dir: PathBuf, matches: & ArgMatches) -> crate::Result<Self> {
|
pub fn new(current_dir: PathBuf, matches: &ArgMatches<'_>) -> crate::Result<Self> {
|
||||||
let package_type = match matches.value_of("format") {
|
let package_type = match matches.value_of("format") {
|
||||||
Some(name) => match PackageType::from_short_name(name) {
|
Some(name) => match PackageType::from_short_name(name) {
|
||||||
Some(package_type) => Some(package_type),
|
Some(package_type) => Some(package_type),
|
||||||
|
@ -159,7 +159,13 @@ impl Settings {
|
||||||
None => None,
|
None => None,
|
||||||
};
|
};
|
||||||
let features = if matches.is_present("features") {
|
let features = if matches.is_present("features") {
|
||||||
Some(matches.values_of("features").unwrap().map(|s| s.to_string()).collect())
|
Some(
|
||||||
|
matches
|
||||||
|
.values_of("features")
|
||||||
|
.unwrap()
|
||||||
|
.map(|s| s.to_string())
|
||||||
|
.collect(),
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
@ -347,7 +353,7 @@ impl Settings {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an iterator over the icon files to be used for this bundle.
|
/// Returns an iterator over the icon files to be used for this bundle.
|
||||||
pub fn icon_files(&self) -> ResourcePaths {
|
pub fn icon_files(&self) -> ResourcePaths<'_> {
|
||||||
match self.bundle_settings.icon {
|
match self.bundle_settings.icon {
|
||||||
Some(ref paths) => ResourcePaths::new(paths.as_slice(), false),
|
Some(ref paths) => ResourcePaths::new(paths.as_slice(), false),
|
||||||
None => ResourcePaths::new(&[], false),
|
None => ResourcePaths::new(&[], false),
|
||||||
|
@ -356,7 +362,7 @@ impl Settings {
|
||||||
|
|
||||||
/// Returns an iterator over the resource files to be included in this
|
/// Returns an iterator over the resource files to be included in this
|
||||||
/// bundle.
|
/// bundle.
|
||||||
pub fn resource_files(&self) -> ResourcePaths {
|
pub fn resource_files(&self) -> ResourcePaths<'_> {
|
||||||
match self.bundle_settings.resources {
|
match self.bundle_settings.resources {
|
||||||
Some(ref paths) => ResourcePaths::new(paths.as_slice(), true),
|
Some(ref paths) => ResourcePaths::new(paths.as_slice(), true),
|
||||||
None => ResourcePaths::new(&[], true),
|
None => ResourcePaths::new(&[], true),
|
||||||
|
|
|
@ -1,27 +1,11 @@
|
||||||
extern crate ar;
|
|
||||||
extern crate cab;
|
|
||||||
extern crate chrono;
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate clap;
|
extern crate clap;
|
||||||
extern crate dirs;
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate error_chain;
|
extern crate error_chain;
|
||||||
extern crate glob;
|
|
||||||
extern crate icns;
|
|
||||||
extern crate image;
|
|
||||||
extern crate libflate;
|
|
||||||
extern crate md5;
|
|
||||||
extern crate msi;
|
|
||||||
extern crate serde;
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate serde_derive;
|
extern crate serde_derive;
|
||||||
extern crate strsim;
|
|
||||||
extern crate tar;
|
|
||||||
extern crate target_build_utils;
|
|
||||||
extern crate term;
|
|
||||||
extern crate toml;
|
|
||||||
extern crate uuid;
|
|
||||||
extern crate walkdir;
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
extern crate tempfile;
|
extern crate tempfile;
|
||||||
|
@ -69,7 +53,7 @@ fn build_project_if_unbuilt(settings: &Settings) -> crate::Result<()> {
|
||||||
match settings.build_features() {
|
match settings.build_features() {
|
||||||
Some(features) => {
|
Some(features) => {
|
||||||
args.push(format!("--features={}", features.join(" ")));
|
args.push(format!("--features={}", features.join(" ")));
|
||||||
},
|
}
|
||||||
None => {}
|
None => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue