Skip to content

Commit

Permalink
Update native dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
filips123 committed Dec 3, 2022
1 parent 66bc65a commit bbbbcb6
Show file tree
Hide file tree
Showing 9 changed files with 614 additions and 424 deletions.
917 changes: 555 additions & 362 deletions native/Cargo.lock

Large diffs are not rendered by default.

43 changes: 20 additions & 23 deletions native/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,41 +20,38 @@ codegen-units = 1
lto = true

[dependencies]
ab_glyph = "0.2.15"
anyhow = "1.0.58"
ab_glyph = "0.2.18"
anyhow = "1.0.66"
byteorder = "1.4.3"
cfg-if = "1.0.0"
clap = { version = "3.2.16", features = ["derive"] }
configparser = "3.0.0"
const_format = "0.2.26"
clap = { version = "4.0.29", features = ["derive"] }
configparser = "3.0.2"
const_format = "0.2.30"
data-url = { git = "https://github.com/filips123/rust-url", branch = "impl-std-error" }
directories = "4.0.1"
fs_extra = "1.2.0"
gag = "1.0.0"
image = "0.24.3"
image = "0.24.5"
log = "0.4.17"
reqwest = { version = "0.11.11", features = ["blocking", "socks", "gzip", "brotli", "deflate", "native-tls"] }
resvg = "0.23.0"
serde = { version = "1.0.140", features = ["derive"] }
serde_json = "1.0.82"
reqwest = { version = "0.11.13", features = ["blocking", "socks", "gzip", "brotli", "deflate", "native-tls"] }
resvg = "0.27.0"
serde = { version = "1.0.148", features = ["derive"] }
serde_json = "1.0.89"
simplelog = "0.12.0"
smart-default = "0.6.0"
tempfile = "3.3.0"
tiny-skia = "0.6.6"
ulid = { version = "0.6.0", features = ["serde"] }
url = "2.2.2"
urlencoding = "2.1.0"
usvg = "0.23.0"
ulid = { version = "1.0.0", features = ["serde"] }
url = "2.3.1"
urlencoding = "2.1.2"
web_app_manifest = { git = "https://github.com/filips123/WebAppManifestRS", branch = "main" }

[target.'cfg(target_os = "windows")'.dependencies]
sanitize-filename = "0.4.0"
winreg = "0.10.1"

[target.'cfg(target_os = "windows")'.dependencies.windows]
version = "0.38.0"
version = "0.43.0"
features = [
"alloc",
"Win32_Foundation",
"Win32_Storage_EnhancedStorage",
"Win32_System_Com",
Expand All @@ -70,22 +67,22 @@ features = [
[target.'cfg(target_os = "linux")'.dependencies]
bzip2 = "0.4.3"
glob = "0.3.0"
phf = { version = "0.11.0", features = ["macros"] }
phf = { version = "0.11.1", features = ["macros"] }
tar = "0.4.38"

[target.'cfg(target_os = "macos")'.dependencies]
dmg = "0.1.1"
phf = { version = "0.11.0", features = ["macros"] }
phf = { version = "0.11.1", features = ["macros"] }
icns = "0.3.1"
pix = "0.13.2"
plist = "1.3.1"
sanitize-filename = "0.4.0"

[build-dependencies]
clap = { version = "3.2.16", features = ["derive"] }
clap_complete = "3.2.3"
ulid = "0.6.0"
url = "2.2.2"
clap = { version = "4.0.29", features = ["derive"] }
clap_complete = "4.0.6"
ulid = "1.0.0"
url = "2.3.1"

[package.metadata.wix]
include = [
Expand Down
15 changes: 7 additions & 8 deletions native/src/components/_7zip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ use cfg_if::cfg_if;
use const_format::formatcp;
use log::{info, warn};
use tempfile::Builder;
use windows::core::{IntoParam, Param, PCWSTR};
use windows::core::{HSTRING, PCWSTR};
use windows::w;
use windows::Win32::System::Com::{
CoInitializeEx,
COINIT_APARTMENTTHREADED,
Expand Down Expand Up @@ -51,19 +52,17 @@ const fn get_download_url() -> &'static str {

#[inline]
fn run_as_admin<S: AsRef<OsStr>>(cmd: S) -> std::io::Result<ExitStatus> {
unsafe {
CoInitializeEx(std::ptr::null_mut(), COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE)?
};
unsafe { CoInitializeEx(None, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE)? };

let mut code = 1;
let lp_verb: Param<PCWSTR> = "runas".into_param();
let lp_file: Param<PCWSTR> = cmd.as_ref().into_param();
let lp_verb = w!("runas");
let lp_file = PCWSTR::from(&HSTRING::from(cmd.as_ref()));

let mut sei = SHELLEXECUTEINFOW {
cbSize: std::mem::size_of::<SHELLEXECUTEINFOW>() as u32,
fMask: SEE_MASK_NOASYNC | SEE_MASK_NOCLOSEPROCESS,
lpVerb: unsafe { lp_verb.abi() },
lpFile: unsafe { lp_file.abi() },
lpVerb: lp_verb,
lpFile: lp_file,
nShow: 1,
..Default::default()
};
Expand Down
2 changes: 1 addition & 1 deletion native/src/components/profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl Profile {
info!("Patching the profile");
let _ = remove_dir_all(profile.join("startupCache"));
let _ = remove_dir_all(profile.join("chrome/pwa"));
copy(source, &profile, &options).context("Failed to patch the profile")?;
copy(source, profile, &options).context("Failed to patch the profile")?;

info!("Profile patched!");
Ok(())
Expand Down
13 changes: 6 additions & 7 deletions native/src/console/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

use std::path::PathBuf;

use clap::Parser;
use clap::{ArgAction, Parser};
use ulid::Ulid;
use url::Url;

#[derive(Parser, Debug, Eq, PartialEq, Clone)]
#[clap(global_setting(clap::AppSettings::DeriveDisplayOrder))]
#[clap(propagate_version = true)]
#[clap(version)]
pub enum App {
Expand Down Expand Up @@ -97,7 +96,7 @@ pub struct SiteInstallCommand {
pub keywords: Option<Vec<String>>,

/// Disable system integration
#[clap(long = "no-system-integration", parse(from_flag = std::ops::Not::not))]
#[clap(long = "no-system-integration", action = ArgAction::SetFalse)]
pub system_integration: bool,

/// Configuration of the HTTP client.
Expand All @@ -115,7 +114,7 @@ pub struct SiteUninstallCommand {
pub quiet: bool,

/// Disable system integration
#[clap(long = "no-system-integration", parse(from_flag = std::ops::Not::not))]
#[clap(long = "no-system-integration", action = ArgAction::SetFalse)]
pub system_integration: bool,
}

Expand Down Expand Up @@ -153,15 +152,15 @@ pub struct SiteUpdateCommand {
pub enabled_protocol_handlers: Option<Vec<String>>,

/// Disable manifest updates
#[clap(long = "no-manifest-updates", parse(from_flag = std::ops::Not::not))]
#[clap(long = "no-manifest-updates", action = ArgAction::SetFalse)]
pub update_manifest: bool,

/// Disable icon updates
#[clap(long = "no-icon-updates", parse(from_flag = std::ops::Not::not))]
#[clap(long = "no-icon-updates", action = ArgAction::SetFalse)]
pub update_icons: bool,

/// Disable system integration
#[clap(long = "no-system-integration", parse(from_flag = std::ops::Not::not))]
#[clap(long = "no-system-integration", action = ArgAction::SetFalse)]
pub system_integration: bool,

/// Configuration of the HTTP client.
Expand Down
2 changes: 1 addition & 1 deletion native/src/console/site.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl Run for SiteLaunchCommand {
.iter()
.find(|handler| handler.protocol == scheme)
})
.context(format!("Scheme {} not found", scheme))?
.context(format!("Scheme {scheme} not found"))?
.to_owned()
.url
.try_into()
Expand Down
1 change: 1 addition & 0 deletions native/src/integrations/implementation/macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use image::imageops::FilterType::Gaussian;
use image::{DynamicImage, Rgba, RgbaImage};
use log::{debug, error, warn};
use reqwest::blocking::Client;
use resvg::{tiny_skia, usvg};
use url::Url;
use web_app_manifest::resources::IconResource;
use web_app_manifest::types::{ImagePurpose, ImageSize, Url as ManifestUrl};
Expand Down
44 changes: 22 additions & 22 deletions native/src/integrations/implementation/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use reqwest::blocking::Client;
use url::Url;
use web_app_manifest::resources::IconResource;
use web_app_manifest::types::ImageSize;
use windows::core::{Interface, Result as WindowsResult, GUID, PWSTR};
use windows::core::{Interface, Result as WindowsResult, GUID, HSTRING, PWSTR};
use windows::Win32::Storage::EnhancedStorage::{PKEY_AppUserModel_ID, PKEY_Title};
use windows::Win32::System::Com::{
CoCreateInstance,
Expand Down Expand Up @@ -47,7 +47,7 @@ const START_MENU_PROGRAMS_PATH: &str = r"Microsoft\Windows\Start Menu\Programs";
/// Initialize COM for use by the calling thread for the multi-threaded apartment (MTA).
#[inline]
fn initialize_windows() -> WindowsResult<()> {
unsafe { CoInitializeEx(std::ptr::null_mut(), COINIT_MULTITHREADED | COINIT_DISABLE_OLE1DDE) }
unsafe { CoInitializeEx(None, COINIT_MULTITHREADED | COINIT_DISABLE_OLE1DDE) }
}

/// Create a COM object with the given CLSID.
Expand All @@ -60,7 +60,7 @@ fn create_instance<T: Interface>(clsid: &GUID) -> WindowsResult<T> {
///
/// See: https://github.com/microsoft/windows-rs/issues/973#issue-942298423
#[inline]
fn string_to_pwstr(str: &str) -> PWSTR {
fn str_to_pwstr(str: &str) -> PWSTR {
let mut encoded = str.encode_utf16().chain([0u16]).collect::<Vec<u16>>();
PWSTR(encoded.as_mut_ptr())
}
Expand All @@ -83,8 +83,8 @@ impl SiteIds {
let name = site.name();
let description = site.description();
let ulid = site.ulid.to_string();
let regid = format!("FFPWA-{}", ulid);
let appid = format!("filips.firefoxpwa.{}", ulid);
let regid = format!("FFPWA-{ulid}");
let appid = format!("filips.firefoxpwa.{ulid}");
Self { name, description, ulid, regid, appid }
}
}
Expand Down Expand Up @@ -160,22 +160,22 @@ fn create_menu_shortcut(

unsafe {
// Set general shortcut properties
link.SetPath(exe)?;
link.SetArguments(format!("site launch {}", ids.ulid))?;
link.SetDescription(ids.description.chars().take(240).collect::<String>())?;
link.SetIconLocation(icon, 0)?;
link.SetPath(&HSTRING::from(exe))?;
link.SetArguments(&HSTRING::from(format!("site launch {}", ids.ulid)))?;
link.SetDescription(&HSTRING::from(ids.description.chars().take(240).collect::<String>()))?;
link.SetIconLocation(&HSTRING::from(icon), 0)?;
link.SetShowCmd(7)?;

// Set app user model ID property
// Docs: https://docs.microsoft.com/en-us/windows/win32/properties/props-system-appusermodel-id
let store: IPropertyStore = link.cast()?;
let variant = InitPropVariantFromStringVector(&[string_to_pwstr(&ids.appid)])?;
let variant = InitPropVariantFromStringVector(Some(&[str_to_pwstr(&ids.appid)]))?;
store.SetValue(&PKEY_AppUserModel_ID, &variant)?;
store.Commit()?;

// Save shortcut to file
let persist: IPersistFile = link.cast()?;
persist.Save(filename.display().to_string(), true)?;
persist.Save(&HSTRING::from(filename.display().to_string()), true)?;
}

Ok(())
Expand All @@ -194,10 +194,10 @@ fn create_jump_list_tasks(

unsafe {
if shortcuts.is_empty() {
list.DeleteList(&*ids.appid)?;
list.DeleteList(&HSTRING::from(&ids.appid))?;
return Ok(());
} else {
list.SetAppID(&*ids.appid)?;
list.SetAppID(&HSTRING::from(&ids.appid))?;
let _: IObjectArray = list.BeginList(&mut (shortcuts.len() as u32))?;
}
}
Expand All @@ -208,7 +208,7 @@ fn create_jump_list_tasks(
for (i, shortcut) in shortcuts.iter().enumerate() {
let url: Url = shortcut.url.clone().try_into().context("Failed to convert shortcut URL")?;
let description = shortcut.description.clone().unwrap_or_else(|| "".into());
let icon = icons.join(format!("shortcut{}.ico", i));
let icon = icons.join(format!("shortcut{i}.ico",));

if args.update_icons {
store_icon(&shortcut.name, &shortcut.icons, &icon, args.client.unwrap())
Expand All @@ -221,25 +221,25 @@ fn create_jump_list_tasks(

unsafe {
// Set general shortcut properties
link.SetPath(exe)?;
link.SetArguments(format!("site launch {} --url {}", ids.ulid, url))?;
link.SetDescription(description.chars().take(240).collect::<String>())?;
link.SetIconLocation(icon.display().to_string(), 0)?;
link.SetPath(&HSTRING::from(exe))?;
link.SetArguments(&HSTRING::from(format!("site launch {} --url {}", ids.ulid, url)))?;
link.SetDescription(&HSTRING::from(description.chars().take(240).collect::<String>()))?;
link.SetIconLocation(&HSTRING::from(icon.display().to_string()), 0)?;
link.SetShowCmd(7)?;

// Set app user model ID property
// Docs: https://docs.microsoft.com/en-us/windows/win32/properties/props-system-appusermodel-id
let variant = InitPropVariantFromStringVector(&[string_to_pwstr(&ids.appid)])?;
let variant = InitPropVariantFromStringVector(Some(&[str_to_pwstr(&ids.appid)]))?;
store.SetValue(&PKEY_AppUserModel_ID, &variant)?;

// Set title property
// Docs: https://docs.microsoft.com/en-us/windows/win32/properties/props-system-title
let variant = InitPropVariantFromStringVector(&[string_to_pwstr(&shortcut.name)])?;
let variant = InitPropVariantFromStringVector(Some(&[str_to_pwstr(&shortcut.name)]))?;
store.SetValue(&PKEY_Title, &variant)?;

// Commit store and add it to collection
store.Commit()?;
collection.AddObject(link)?;
collection.AddObject(&link)?;
}
}

Expand Down Expand Up @@ -389,7 +389,7 @@ pub fn uninstall(args: &IntegrationUninstallArgs) -> Result<()> {
unsafe {
initialize_windows()?;
let list: ICustomDestinationList = create_instance(&DestinationList)?;
let _ = list.DeleteList(ids.appid);
let _ = list.DeleteList(&HSTRING::from(ids.appid));
}

// Remove protocol handlers
Expand Down
1 change: 1 addition & 0 deletions native/src/integrations/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use image::imageops::FilterType::Gaussian;
use image::{ImageBuffer, Rgb, RgbImage};
use log::{debug, error, warn};
use reqwest::blocking::Client;
use resvg::{tiny_skia, usvg};
use url::Url;
use web_app_manifest::resources::IconResource;
use web_app_manifest::types::{ImagePurpose, ImageSize, Url as ManifestUrl};
Expand Down

0 comments on commit bbbbcb6

Please sign in to comment.