Skip to content

Commit

Permalink
Updated dependencies. Fixed errors
Browse files Browse the repository at this point in the history
  • Loading branch information
core1024 committed Mar 7, 2024
1 parent 47befd6 commit bdfbc38
Show file tree
Hide file tree
Showing 14 changed files with 440 additions and 338 deletions.
677 changes: 385 additions & 292 deletions Cargo.lock

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,35 @@ version = "5.0.0"
edition = "2018"

[dependencies]
once_cell = "1.3.1"
native-windows-gui = { version = "1.0.4", features = [
once_cell = "1.19"
native-windows-gui = { version = "1", features = [
"high-dpi",
"notice",
"tray-notification",
"menu",
] }
native-windows-derive = "1.0.3"
native-windows-derive = "1"
winapi = { version = "0.3.9", features = [
"libloaderapi",
"handleapi",
"wincon",
"winuser",
"namedpipeapi"
] }
webview2 = "0.1.0"
webview2-sys = "0.1.0-beta.1"
libmpv = "2.0.1"
libmpv-sys = "3.1.0"
webview2 = "0.1.4"
webview2-sys = "0.1.1"
libmpv-sirno = "2.0.2-fork.1"
libmpv-sys-sirno = "2.0.0-fork.1"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
clap = { version = "3.1.12", features = ["derive", "unicode"] }
open = "2"
urlencoding = "2.1.0"
bitflags = "1.2.1"
win32job = "1"
parse-display = "0.5.1"
flume = "0.10.9"
kernel32-sys = "0.2"
whoami = "1.2.1"
clap = { version = "4", features = ["derive", "unicode"] }
open = "5"
urlencoding = "2"
bitflags = "2"
win32job = "2"
parse-display = "0.9"
flume = "0.11"
whoami = "1.5"

[build-dependencies]
winres = "0.1"
Expand Down
17 changes: 17 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@ fn main() {
let copyright = format!("Copyright © {} Smart Code OOD", now.year());
let exe_name = format!("{}.exe", env::var("CARGO_PKG_NAME").unwrap());
let mut res = winres::WindowsResource::new();
res.set_manifest(r#"
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>
"#);
res.set("FileDescription", "Freedom to Stream");
res.set("LegalCopyright", &copyright);
res.set("OriginalFilename", &exe_name);
Expand Down
Binary file modified images/stremio.ico
Binary file not shown.
Binary file modified images/stremio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/stremio_gray.ico
Binary file not shown.
Binary file modified images/windows-installer-header.bmp
Binary file not shown.
Binary file modified images/windows-installer.bmp
Binary file not shown.
Binary file modified mpv.dll
Binary file not shown.
8 changes: 1 addition & 7 deletions src/stremio_app/mod.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
pub mod app;
pub use app::MainWindow;
pub mod stremio_wevbiew;
pub use stremio_wevbiew::WebView;
pub mod stremio_player;
pub use stremio_player::Player;
pub mod stremio_server;
pub use stremio_server::StremioServer;
pub mod ipc;
pub use ipc::{Channel, RPCRequest, RPCResponse, RPCResponseData, RPCResponseDataTransport};
pub use ipc::RPCResponse;
pub mod systray;
pub use systray::SystemTray;
pub mod splash;
pub use splash::SplashImage;
pub mod window_helper;
pub use window_helper::WindowStyle;
pub mod named_pipe;
pub use named_pipe::{PipeClient, PipeServer};
20 changes: 11 additions & 9 deletions src/stremio_app/named_pipe.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
// Based on
// https://gitlab.com/tbsaunde/windows-named-pipe/-/blob/f4fd29191f0541f85f818885275dc4573d4059ec/src/lib.rs

use kernel32::{
CloseHandle, ConnectNamedPipe, CreateFileW, CreateNamedPipeW, DisconnectNamedPipe,
FlushFileBuffers, ReadFile, WaitNamedPipeW, WriteFile,
};
use std::ffi::OsStr;
use std::ffi::OsString;
// use kernel32::{
// CloseHandle, ConnectNamedPipe, CreateFileW, CreateNamedPipeW, DisconnectNamedPipe,
// FlushFileBuffers, ReadFile, WaitNamedPipeW, WriteFile,
// };
use std::ffi::{OsStr, OsString};
use std::io::{self, Read, Write};
use std::os::windows::prelude::OsStrExt;
use std::path::Path;
use winapi::shared::minwindef::{DWORD, LPCVOID, LPVOID};
use winapi::shared::winerror;
use winapi::um::fileapi::OPEN_EXISTING;
use winapi::um::handleapi::INVALID_HANDLE_VALUE;
use winapi::um::fileapi::{CreateFileW, FlushFileBuffers, ReadFile, WriteFile};
use winapi::um::handleapi::{CloseHandle, INVALID_HANDLE_VALUE};
use winapi::um::namedpipeapi::{
ConnectNamedPipe, CreateNamedPipeW, DisconnectNamedPipe, WaitNamedPipeW,
};
use winapi::um::winbase::{
FILE_FLAG_FIRST_PIPE_INSTANCE, PIPE_ACCESS_DUPLEX, PIPE_READMODE_BYTE, PIPE_TYPE_BYTE,
PIPE_UNLIMITED_INSTANCES, PIPE_WAIT,
};
use winapi::um::winnt::{FILE_ATTRIBUTE_NORMAL, GENERIC_READ, GENERIC_WRITE, HANDLE};

#[derive(Debug)]
pub struct PipeClient {
is_server: bool,
Expand All @@ -33,7 +35,7 @@ impl PipeClient {
let u16_slice = os_str.encode_wide().collect::<Vec<u16>>();

unsafe { WaitNamedPipeW(u16_slice.as_ptr(), 0) };
let handle = unsafe {
let handle: *mut winapi::ctypes::c_void = unsafe {
CreateFileW(
u16_slice.as_ptr(),
GENERIC_READ | GENERIC_WRITE,
Expand Down
4 changes: 2 additions & 2 deletions src/stremio_app/stremio_player/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ pub mod player;
pub use player::Player;
pub mod communication;
pub use communication::{
BoolProp, CmdVal, FpProp, InMsg, InMsgArgs, InMsgFn, IntProp, MpvCmd, PlayerEnded, PlayerError,
PlayerEvent, PlayerProprChange, PlayerResponse, PropKey, PropVal, StrProp,
CmdVal, InMsg, InMsgArgs, InMsgFn, PlayerEnded,
PlayerEvent, PlayerProprChange, PlayerResponse, PropKey, PropVal,
};
#[cfg(test)]
mod communication_tests;
2 changes: 1 addition & 1 deletion src/stremio_app/stremio_server/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl StremioServer {
let job = Job::create().expect("Cannont create job");
let mut info = job.query_extended_limit_info().expect("Cannont get info");
info.limit_kill_on_job_close();
job.set_extended_limit_info(&mut info).ok();
job.set_extended_limit_info(&info).ok();
job.assign_current_process().ok();
loop {
let child = Command::new("./stremio-runtime")
Expand Down
18 changes: 7 additions & 11 deletions src/stremio_app/stremio_wevbiew/wevbiew.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,30 +94,25 @@ impl PartialUi for WebView {
tx_web.clone().send(ipc::RPCResponse::response_message(Some(json!(["app-error", format!("Cannot load WEB UI at '{}'", &endpoint)])))).ok();
};
}
webview
.add_script_to_execute_on_document_created(
r##"
try{if(window.self === window.top) {
webview.execute_script(r##"
try{console.log('Shell JS injected');if(window.self === window.top) {
window.qt={webChannelTransport:{send:window.chrome.webview.postMessage}};
window.chrome.webview.addEventListener('message',ev=>window.qt.webChannelTransport.onmessage(ev));
window.onload=()=>{try{initShellComm();}catch(e){window.chrome.webview.postMessage('{"id":1,"args":["app-error","'+e.message+'"]}')}};
}}catch(e){}
"##,
|_| Ok(()),
)
.ok();
"##, |_| Ok(())).expect("Cannot add script to webview");
webview.add_web_message_received(move |_w, msg| {
let msg = msg.try_get_web_message_as_string()?;
tx_web.send(msg).ok();
Ok(())
}).ok();
}).expect("Cannot add web message received");
webview.add_new_window_requested(move |_w, msg| {
if let Some(file) = msg.get_uri().ok().and_then(|str| {decode(str.as_str()).ok().map(Cow::into_owned)}) {
tx_drag_drop.send(ipc::RPCResponse::response_message(Some(json!(["dragdrop" ,[file]])))).ok();
msg.put_handled(true).ok();
}
Ok(())
}).ok();
}).expect("Cannot add D&D handler");

WebView::resize_to_window_bounds_and_show(Some(&controller), Some(hwnd));
controller_clone
Expand All @@ -128,7 +123,7 @@ impl PartialUi for WebView {
});
if let Err(e) = result {
nwg::modal_fatal_message(
&parent,
parent,
"Failed to Create WebView2 Environment",
&format!("{}", e),
);
Expand Down Expand Up @@ -170,6 +165,7 @@ impl PartialUi for WebView {
use nwg::Event as E;
match evt {
E::OnPaint => {
// TODO: somehow debounce this
WebView::resize_to_window_bounds_and_show(self.controller.get(), handle.hwnd());
}
E::OnWindowMinimize => {
Expand Down

0 comments on commit bdfbc38

Please sign in to comment.