mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-17 18:21:14 +10:00
Compare commits
2 Commits
ea6fa551a2
...
52-feature
| Author | SHA1 | Date | |
|---|---|---|---|
| 96df57ac54 | |||
| 8069616f2b |
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "view",
|
"name": "view",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.3.3",
|
"version": "0.3.2",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "nuxt generate",
|
"build": "nuxt generate",
|
||||||
|
|||||||
@ -1,25 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="grow w-full h-full flex items-center justify-center">
|
|
||||||
<div class="flex flex-col items-center">
|
|
||||||
<WrenchScrewdriverIcon
|
|
||||||
class="h-12 w-12 text-blue-600"
|
|
||||||
aria-hidden="true"
|
|
||||||
/>
|
|
||||||
<div class="mt-3 text-center sm:mt-5">
|
|
||||||
<h1 class="text-3xl font-semibold font-display leading-6 text-zinc-100">
|
|
||||||
Under construction
|
|
||||||
</h1>
|
|
||||||
<div class="mt-4">
|
|
||||||
<p class="text-sm text-zinc-400 max-w-lg">
|
|
||||||
This page hasn't been implemented yet.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<script setup lang="ts">
|
|
||||||
import {
|
|
||||||
WrenchScrewdriverIcon,
|
|
||||||
} from "@heroicons/vue/20/solid";
|
|
||||||
</script>
|
|
||||||
16
main/pages/community/index.vue
Normal file
16
main/pages/community/index.vue
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<template>
|
||||||
|
<div class="mx-auto flex flex-col items-center gap-y-4 max-w-2xl py-32 sm:py-48 lg:py-56">
|
||||||
|
<div>
|
||||||
|
<Wordmark />
|
||||||
|
</div>
|
||||||
|
<div class="text-center">
|
||||||
|
<h1 class="text-balance text-4xl font-bold font-display tracking-tight text-zinc-100 sm:text-6xl">
|
||||||
|
Under construction
|
||||||
|
</h1>
|
||||||
|
<p class="mt-6 text-lg leading-8 text-zinc-400">
|
||||||
|
Yes, we know. We're working on it <a class="text-white" target="_blank"
|
||||||
|
href="https://github.com/Drop-OSS/drop-app/issues/52">here.</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@ -1,25 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="grow w-full h-full flex items-center justify-center">
|
|
||||||
<div class="flex flex-col items-center">
|
|
||||||
<WrenchScrewdriverIcon
|
|
||||||
class="h-12 w-12 text-blue-600"
|
|
||||||
aria-hidden="true"
|
|
||||||
/>
|
|
||||||
<div class="mt-3 text-center sm:mt-5">
|
|
||||||
<h1 class="text-3xl font-semibold font-display leading-6 text-zinc-100">
|
|
||||||
Under construction
|
|
||||||
</h1>
|
|
||||||
<div class="mt-4">
|
|
||||||
<p class="text-sm text-zinc-400 max-w-lg">
|
|
||||||
This page hasn't been implemented yet.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<script setup lang="ts">
|
|
||||||
import {
|
|
||||||
WrenchScrewdriverIcon,
|
|
||||||
} from "@heroicons/vue/20/solid";
|
|
||||||
</script>
|
|
||||||
16
main/pages/news/index.vue
Normal file
16
main/pages/news/index.vue
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<template>
|
||||||
|
<div class="mx-auto flex flex-col items-center gap-y-4 max-w-2xl py-32 sm:py-48 lg:py-56">
|
||||||
|
<div>
|
||||||
|
<Wordmark />
|
||||||
|
</div>
|
||||||
|
<div class="text-center">
|
||||||
|
<h1 class="text-balance text-4xl font-bold font-display tracking-tight text-zinc-100 sm:text-6xl">
|
||||||
|
Under construction
|
||||||
|
</h1>
|
||||||
|
<p class="mt-6 text-lg leading-8 text-zinc-400">
|
||||||
|
Yes, we know. We're working on it <a class="text-white" target="_blank"
|
||||||
|
href="https://github.com/Drop-OSS/drop-app/issues/52">here.</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@ -1,23 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="grow w-full h-full flex items-center justify-center">
|
|
||||||
<div class="flex flex-col items-center">
|
|
||||||
<WrenchScrewdriverIcon
|
|
||||||
class="h-12 w-12 text-blue-600"
|
|
||||||
aria-hidden="true"
|
|
||||||
/>
|
|
||||||
<div class="mt-3 text-center sm:mt-5">
|
|
||||||
<h1 class="text-3xl font-semibold font-display leading-6 text-zinc-100">
|
|
||||||
Under construction
|
|
||||||
</h1>
|
|
||||||
<div class="mt-4">
|
|
||||||
<p class="text-sm text-zinc-400 max-w-lg">
|
|
||||||
This page hasn't been implemented yet.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { WrenchScrewdriverIcon } from "@heroicons/vue/20/solid";
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
2
src-tauri/Cargo.lock
generated
2
src-tauri/Cargo.lock
generated
@ -1284,7 +1284,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "drop-app"
|
name = "drop-app"
|
||||||
version = "0.3.3"
|
version = "0.3.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"atomic-instant-full",
|
"atomic-instant-full",
|
||||||
"bitcode",
|
"bitcode",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "drop-app"
|
name = "drop-app"
|
||||||
version = "0.3.3"
|
version = "0.3.2"
|
||||||
description = "The client application for the open-source, self-hosted game distribution platform Drop"
|
description = "The client application for the open-source, self-hosted game distribution platform Drop"
|
||||||
authors = ["Drop OSS"]
|
authors = ["Drop OSS"]
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|||||||
@ -23,7 +23,6 @@ pub enum RemoteAccessError {
|
|||||||
ManifestDownloadFailed(StatusCode, String),
|
ManifestDownloadFailed(StatusCode, String),
|
||||||
OutOfSync,
|
OutOfSync,
|
||||||
Cache(std::io::Error),
|
Cache(std::io::Error),
|
||||||
CorruptedState,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for RemoteAccessError {
|
impl Display for RemoteAccessError {
|
||||||
@ -82,10 +81,6 @@ impl Display for RemoteAccessError {
|
|||||||
"server's and client's time are out of sync. Please ensure they are within at least 30 seconds of each other"
|
"server's and client's time are out of sync. Please ensure they are within at least 30 seconds of each other"
|
||||||
),
|
),
|
||||||
RemoteAccessError::Cache(error) => write!(f, "Cache Error: {error}"),
|
RemoteAccessError::Cache(error) => write!(f, "Cache Error: {error}"),
|
||||||
RemoteAccessError::CorruptedState => write!(
|
|
||||||
f,
|
|
||||||
"Drop encountered a corrupted internal state. Please report this to the developers, with details of reproduction."
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,8 +22,8 @@ use crate::remote::requests::generate_url;
|
|||||||
use crate::remote::utils::{DROP_CLIENT_ASYNC, DROP_CLIENT_SYNC};
|
use crate::remote::utils::{DROP_CLIENT_ASYNC, DROP_CLIENT_SYNC};
|
||||||
use log::{debug, error, info, warn};
|
use log::{debug, error, info, warn};
|
||||||
use rayon::ThreadPoolBuilder;
|
use rayon::ThreadPoolBuilder;
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::HashMap;
|
||||||
use std::fs::{create_dir_all, OpenOptions};
|
use std::fs::{OpenOptions, create_dir_all};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::sync::mpsc::Sender;
|
use std::sync::mpsc::Sender;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
@ -242,8 +242,12 @@ impl GameDownloadAgent {
|
|||||||
|
|
||||||
let mut buckets = Vec::new();
|
let mut buckets = Vec::new();
|
||||||
|
|
||||||
let mut current_buckets = HashMap::<String, DownloadBucket>::new();
|
let mut current_bucket = DownloadBucket {
|
||||||
let mut current_bucket_sizes = HashMap::<String, usize>::new();
|
game_id: game_id.clone(),
|
||||||
|
version: self.version.clone(),
|
||||||
|
drops: Vec::new(),
|
||||||
|
};
|
||||||
|
let mut current_bucket_size = 0;
|
||||||
|
|
||||||
for (raw_path, chunk) in manifest {
|
for (raw_path, chunk) in manifest {
|
||||||
let path = base_path.join(Path::new(&raw_path));
|
let path = base_path.join(Path::new(&raw_path));
|
||||||
@ -278,41 +282,28 @@ impl GameDownloadAgent {
|
|||||||
|
|
||||||
buckets.push(DownloadBucket {
|
buckets.push(DownloadBucket {
|
||||||
game_id: game_id.clone(),
|
game_id: game_id.clone(),
|
||||||
version: chunk.version_name.clone(),
|
version: self.version.clone(),
|
||||||
drops: vec![drop],
|
drops: vec![drop],
|
||||||
});
|
});
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let current_bucket_size = current_bucket_sizes
|
if current_bucket_size + *length >= TARGET_BUCKET_SIZE
|
||||||
.entry(chunk.version_name.clone())
|
|
||||||
.or_insert_with(|| 0);
|
|
||||||
let c_version_name = chunk.version_name.clone();
|
|
||||||
let c_game_id = game_id.clone();
|
|
||||||
let current_bucket = current_buckets
|
|
||||||
.entry(chunk.version_name.clone())
|
|
||||||
.or_insert_with(|| DownloadBucket {
|
|
||||||
game_id: c_game_id,
|
|
||||||
version: c_version_name,
|
|
||||||
drops: vec![],
|
|
||||||
});
|
|
||||||
|
|
||||||
if *current_bucket_size + length >= TARGET_BUCKET_SIZE
|
|
||||||
&& !current_bucket.drops.is_empty()
|
&& !current_bucket.drops.is_empty()
|
||||||
{
|
{
|
||||||
// Move current bucket into list and make a new one
|
// Move current bucket into list and make a new one
|
||||||
buckets.push(current_bucket.clone());
|
buckets.push(current_bucket);
|
||||||
*current_bucket = DownloadBucket {
|
current_bucket = DownloadBucket {
|
||||||
game_id: game_id.clone(),
|
game_id: game_id.clone(),
|
||||||
version: chunk.version_name.clone(),
|
version: self.version.clone(),
|
||||||
drops: vec![],
|
drops: Vec::new(),
|
||||||
};
|
};
|
||||||
*current_bucket_size = 0;
|
current_bucket_size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
current_bucket.drops.push(drop);
|
current_bucket.drops.push(drop);
|
||||||
*current_bucket_size += *length;
|
current_bucket_size += *length;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
@ -321,10 +312,8 @@ impl GameDownloadAgent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (_, bucket) in current_buckets.into_iter() {
|
if !current_bucket.drops.is_empty() {
|
||||||
if !bucket.drops.is_empty() {
|
buckets.push(current_bucket);
|
||||||
buckets.push(bucket);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
info!("buckets: {}", buckets.len());
|
info!("buckets: {}", buckets.len());
|
||||||
@ -359,46 +348,27 @@ impl GameDownloadAgent {
|
|||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let buckets = self.buckets.lock().unwrap();
|
|
||||||
|
|
||||||
let mut download_contexts = HashMap::<String, DownloadContext>::new();
|
|
||||||
|
|
||||||
let versions = buckets
|
|
||||||
.iter()
|
|
||||||
.map(|e| &e.version)
|
|
||||||
.collect::<HashSet<_>>()
|
|
||||||
.into_iter().cloned()
|
|
||||||
.collect::<Vec<String>>();
|
|
||||||
|
|
||||||
info!("downloading across these versions: {versions:?}");
|
|
||||||
|
|
||||||
let completed_contexts = Arc::new(boxcar::Vec::new());
|
let completed_contexts = Arc::new(boxcar::Vec::new());
|
||||||
let completed_indexes_loop_arc = completed_contexts.clone();
|
let completed_indexes_loop_arc = completed_contexts.clone();
|
||||||
|
|
||||||
for version in versions {
|
let download_context = DROP_CLIENT_SYNC
|
||||||
let download_context = DROP_CLIENT_SYNC
|
.post(generate_url(&["/api/v2/client/context"], &[]).unwrap())
|
||||||
.post(generate_url(&["/api/v2/client/context"], &[]).unwrap())
|
.json(&ManifestBody {
|
||||||
.json(&ManifestBody {
|
game: self.id.clone(),
|
||||||
game: self.id.clone(),
|
version: self.version.clone(),
|
||||||
version: version.clone(),
|
})
|
||||||
})
|
.header("Authorization", generate_authorization_header())
|
||||||
.header("Authorization", generate_authorization_header())
|
.send()?;
|
||||||
.send()?;
|
|
||||||
|
|
||||||
if download_context.status() != 200 {
|
if download_context.status() != 200 {
|
||||||
return Err(RemoteAccessError::InvalidResponse(download_context.json()?));
|
return Err(RemoteAccessError::InvalidResponse(download_context.json()?));
|
||||||
}
|
|
||||||
|
|
||||||
let download_context = download_context.json::<DownloadContext>()?;
|
|
||||||
info!(
|
|
||||||
"download context: ({}) {}",
|
|
||||||
&version, download_context.context
|
|
||||||
);
|
|
||||||
download_contexts.insert(version, download_context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let download_contexts = &download_contexts;
|
let download_context = &download_context.json::<DownloadContext>()?;
|
||||||
|
|
||||||
|
info!("download context: {}", download_context.context);
|
||||||
|
|
||||||
|
let buckets = self.buckets.lock().unwrap();
|
||||||
pool.scope(|scope| {
|
pool.scope(|scope| {
|
||||||
let context_map = self.context_map.lock().unwrap();
|
let context_map = self.context_map.lock().unwrap();
|
||||||
for (index, bucket) in buckets.iter().enumerate() {
|
for (index, bucket) in buckets.iter().enumerate() {
|
||||||
@ -430,11 +400,6 @@ impl GameDownloadAgent {
|
|||||||
|
|
||||||
let sender = self.sender.clone();
|
let sender = self.sender.clone();
|
||||||
|
|
||||||
let download_context = download_contexts
|
|
||||||
.get(&bucket.version)
|
|
||||||
.ok_or(RemoteAccessError::CorruptedState)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
scope.spawn(move |_| {
|
scope.spawn(move |_| {
|
||||||
// 3 attempts
|
// 3 attempts
|
||||||
for i in 0..RETRY_COUNT {
|
for i in 0..RETRY_COUNT {
|
||||||
|
|||||||
@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize)]
|
#[derive(Debug, Clone)]
|
||||||
// Drops go in buckets
|
// Drops go in buckets
|
||||||
pub struct DownloadDrop {
|
pub struct DownloadDrop {
|
||||||
pub index: usize,
|
pub index: usize,
|
||||||
@ -14,7 +14,7 @@ pub struct DownloadDrop {
|
|||||||
pub permissions: u32,
|
pub permissions: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct DownloadBucket {
|
pub struct DownloadBucket {
|
||||||
pub game_id: String,
|
pub game_id: String,
|
||||||
pub version: String,
|
pub version: String,
|
||||||
|
|||||||
@ -4,7 +4,6 @@
|
|||||||
#![feature(duration_millis_float)]
|
#![feature(duration_millis_float)]
|
||||||
#![feature(iterator_try_collect)]
|
#![feature(iterator_try_collect)]
|
||||||
#![deny(clippy::all)]
|
#![deny(clippy::all)]
|
||||||
#![deny(clippy::unwrap_used)]
|
|
||||||
|
|
||||||
mod database;
|
mod database;
|
||||||
mod games;
|
mod games;
|
||||||
@ -14,7 +13,6 @@ mod download_manager;
|
|||||||
mod error;
|
mod error;
|
||||||
mod process;
|
mod process;
|
||||||
mod remote;
|
mod remote;
|
||||||
mod utils;
|
|
||||||
|
|
||||||
use crate::database::scan::scan_install_dirs;
|
use crate::database::scan::scan_install_dirs;
|
||||||
use crate::process::commands::open_process_logs;
|
use crate::process::commands::open_process_logs;
|
||||||
@ -47,7 +45,7 @@ use games::commands::{
|
|||||||
};
|
};
|
||||||
use games::downloads::commands::download_game;
|
use games::downloads::commands::download_game;
|
||||||
use games::library::{Game, update_game_configuration};
|
use games::library::{Game, update_game_configuration};
|
||||||
use log::{LevelFilter, debug, info, warn, error};
|
use log::{LevelFilter, debug, info, warn};
|
||||||
use log4rs::Config;
|
use log4rs::Config;
|
||||||
use log4rs::append::console::ConsoleAppender;
|
use log4rs::append::console::ConsoleAppender;
|
||||||
use log4rs::append::file::FileAppender;
|
use log4rs::append::file::FileAppender;
|
||||||
@ -66,7 +64,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::panic::PanicHookInfo;
|
use std::panic::PanicHookInfo;
|
||||||
use std::path::Path;
|
use std::path::{Path, PathBuf};
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::SystemTime;
|
use std::time::SystemTime;
|
||||||
@ -111,7 +109,7 @@ fn create_new_compat_info() -> Option<CompatInfo> {
|
|||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
return None;
|
return None;
|
||||||
|
|
||||||
let has_umu_installed = UMU_LAUNCHER_EXECUTABLE.is_some();
|
let has_umu_installed = *UMU_LAUNCHER_EXECUTABLE == PathBuf::new();
|
||||||
Some(CompatInfo {
|
Some(CompatInfo {
|
||||||
umu_installed: has_umu_installed,
|
umu_installed: has_umu_installed,
|
||||||
})
|
})
|
||||||
@ -139,7 +137,7 @@ async fn setup(handle: AppHandle) -> AppState<'static> {
|
|||||||
)))
|
)))
|
||||||
.append(false)
|
.append(false)
|
||||||
.build(DATA_ROOT_DIR.join("./drop.log"))
|
.build(DATA_ROOT_DIR.join("./drop.log"))
|
||||||
.expect("Failed to setup logfile");
|
.unwrap();
|
||||||
|
|
||||||
let console = ConsoleAppender::builder()
|
let console = ConsoleAppender::builder()
|
||||||
.encoder(Box::new(PatternEncoder::new(
|
.encoder(Box::new(PatternEncoder::new(
|
||||||
@ -159,9 +157,9 @@ async fn setup(handle: AppHandle) -> AppState<'static> {
|
|||||||
.appenders(vec!["logfile", "console"])
|
.appenders(vec!["logfile", "console"])
|
||||||
.build(LevelFilter::from_str(&log_level).expect("Invalid log level")),
|
.build(LevelFilter::from_str(&log_level).expect("Invalid log level")),
|
||||||
)
|
)
|
||||||
.expect("Failed to build config");
|
.unwrap();
|
||||||
|
|
||||||
log4rs::init_config(config).expect("Failed to initialise log4rs");
|
log4rs::init_config(config).unwrap();
|
||||||
|
|
||||||
let games = HashMap::new();
|
let games = HashMap::new();
|
||||||
let download_manager = Arc::new(DownloadManagerBuilder::build(handle.clone()));
|
let download_manager = Arc::new(DownloadManagerBuilder::build(handle.clone()));
|
||||||
@ -372,57 +370,42 @@ pub fn run() {
|
|||||||
.shadow(false)
|
.shadow(false)
|
||||||
.data_directory(DATA_ROOT_DIR.join(".webview"))
|
.data_directory(DATA_ROOT_DIR.join(".webview"))
|
||||||
.build()
|
.build()
|
||||||
.expect("Failed to build main window");
|
.unwrap();
|
||||||
|
|
||||||
app.deep_link().on_open_url(move |event| {
|
app.deep_link().on_open_url(move |event| {
|
||||||
debug!("handling drop:// url");
|
debug!("handling drop:// url");
|
||||||
let binding = event.urls();
|
let binding = event.urls();
|
||||||
let url = match binding.first() {
|
let url = binding.first().unwrap();
|
||||||
Some(url) => url,
|
if url.host_str().unwrap() == "handshake" {
|
||||||
None => {
|
tauri::async_runtime::spawn(recieve_handshake(
|
||||||
warn!("No value recieved from deep link. Is this a drop server?");
|
handle.clone(),
|
||||||
return;
|
url.path().to_string(),
|
||||||
}
|
));
|
||||||
};
|
|
||||||
if let Some("handshake") = url.host_str() {
|
|
||||||
tauri::async_runtime::spawn(recieve_handshake(
|
|
||||||
handle.clone(),
|
|
||||||
url.path().to_string(),
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
let open_menu_item = MenuItem::with_id(app, "open", "Open", true, None::<&str>).expect("Failed to generate open menu item");
|
|
||||||
|
|
||||||
let sep = PredefinedMenuItem::separator(app).expect("Failed to generate menu separator item");
|
|
||||||
|
|
||||||
let quit_menu_item = MenuItem::with_id(app, "quit", "Quit", true, None::<&str>).expect("Failed to generate quit menu item");
|
|
||||||
|
|
||||||
let menu = Menu::with_items(
|
let menu = Menu::with_items(
|
||||||
app,
|
app,
|
||||||
&[
|
&[
|
||||||
&open_menu_item,
|
&MenuItem::with_id(app, "open", "Open", true, None::<&str>).unwrap(),
|
||||||
&sep,
|
&PredefinedMenuItem::separator(app).unwrap(),
|
||||||
/*
|
/*
|
||||||
&MenuItem::with_id(app, "show_library", "Library", true, None::<&str>)?,
|
&MenuItem::with_id(app, "show_library", "Library", true, None::<&str>)?,
|
||||||
&MenuItem::with_id(app, "show_settings", "Settings", true, None::<&str>)?,
|
&MenuItem::with_id(app, "show_settings", "Settings", true, None::<&str>)?,
|
||||||
&PredefinedMenuItem::separator(app)?,
|
&PredefinedMenuItem::separator(app)?,
|
||||||
*/
|
*/
|
||||||
&quit_menu_item,
|
&MenuItem::with_id(app, "quit", "Quit", true, None::<&str>).unwrap(),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
.expect("Failed to generate menu");
|
.unwrap();
|
||||||
|
|
||||||
run_on_tray(|| {
|
run_on_tray(|| {
|
||||||
TrayIconBuilder::new()
|
TrayIconBuilder::new()
|
||||||
.icon(app.default_window_icon().expect("Failed to get default window icon").clone())
|
.icon(app.default_window_icon().unwrap().clone())
|
||||||
.menu(&menu)
|
.menu(&menu)
|
||||||
.on_menu_event(|app, event| match event.id.as_ref() {
|
.on_menu_event(|app, event| match event.id.as_ref() {
|
||||||
"open" => {
|
"open" => {
|
||||||
app.webview_windows()
|
app.webview_windows().get("main").unwrap().show().unwrap();
|
||||||
.get("main")
|
|
||||||
.expect("Failed to get webview")
|
|
||||||
.show()
|
|
||||||
.expect("Failed to show window");
|
|
||||||
}
|
}
|
||||||
"quit" => {
|
"quit" => {
|
||||||
cleanup_and_exit(app, &app.state());
|
cleanup_and_exit(app, &app.state());
|
||||||
@ -439,19 +422,15 @@ pub fn run() {
|
|||||||
{
|
{
|
||||||
let mut db_handle = borrow_db_mut_checked();
|
let mut db_handle = borrow_db_mut_checked();
|
||||||
if let Some(original) = db_handle.prev_database.take() {
|
if let Some(original) = db_handle.prev_database.take() {
|
||||||
let canonicalised = match original.canonicalize() {
|
|
||||||
Ok(o) => o,
|
|
||||||
Err(_) => original,
|
|
||||||
};
|
|
||||||
warn!(
|
warn!(
|
||||||
"Database corrupted. Original file at {}",
|
"Database corrupted. Original file at {}",
|
||||||
canonicalised.display()
|
original.canonicalize().unwrap().to_string_lossy()
|
||||||
);
|
);
|
||||||
app.dialog()
|
app.dialog()
|
||||||
.message(format!(
|
.message(
|
||||||
"Database corrupted. A copy has been saved at: {}",
|
"Database corrupted. A copy has been saved at: ".to_string()
|
||||||
canonicalised.display()
|
+ original.to_str().unwrap(),
|
||||||
))
|
)
|
||||||
.title("Database corrupted")
|
.title("Database corrupted")
|
||||||
.show(|_| {});
|
.show(|_| {});
|
||||||
}
|
}
|
||||||
@ -484,7 +463,7 @@ pub fn run() {
|
|||||||
.on_window_event(|window, event| {
|
.on_window_event(|window, event| {
|
||||||
if let WindowEvent::CloseRequested { api, .. } = event {
|
if let WindowEvent::CloseRequested { api, .. } = event {
|
||||||
run_on_tray(|| {
|
run_on_tray(|| {
|
||||||
window.hide().expect("Failed to close window in tray");
|
window.hide().unwrap();
|
||||||
api.prevent_close();
|
api.prevent_close();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@ use std::{
|
|||||||
sync::LazyLock,
|
sync::LazyLock,
|
||||||
};
|
};
|
||||||
|
|
||||||
use log::{debug, info};
|
use log::debug;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
AppState,
|
AppState,
|
||||||
@ -31,29 +31,29 @@ impl ProcessHandler for NativeGameLauncher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub static UMU_LAUNCHER_EXECUTABLE: LazyLock<Option<PathBuf>> = LazyLock::new(|| {
|
pub static UMU_LAUNCHER_EXECUTABLE: LazyLock<PathBuf> = LazyLock::new(|| {
|
||||||
let x = get_umu_executable();
|
let x = get_umu_executable();
|
||||||
info!("{:?}", &x);
|
println!("{:?}", &x);
|
||||||
x
|
x
|
||||||
});
|
});
|
||||||
const UMU_BASE_LAUNCHER_EXECUTABLE: &str = "umu-run";
|
const UMU_BASE_LAUNCHER_EXECUTABLE: &str = "umu-run";
|
||||||
const UMU_INSTALL_DIRS: [&str; 4] = ["/app/share", "/use/local/share", "/usr/share", "/opt"];
|
const UMU_INSTALL_DIRS: [&str; 4] = ["/app/share", "/use/local/share", "/usr/share", "/opt"];
|
||||||
|
|
||||||
fn get_umu_executable() -> Option<PathBuf> {
|
fn get_umu_executable() -> PathBuf {
|
||||||
if check_executable_exists(UMU_BASE_LAUNCHER_EXECUTABLE) {
|
if check_executable_exists(UMU_BASE_LAUNCHER_EXECUTABLE) {
|
||||||
return Some(PathBuf::from(UMU_BASE_LAUNCHER_EXECUTABLE));
|
return PathBuf::from(UMU_BASE_LAUNCHER_EXECUTABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
for dir in UMU_INSTALL_DIRS {
|
for dir in UMU_INSTALL_DIRS {
|
||||||
let p = PathBuf::from(dir).join(UMU_BASE_LAUNCHER_EXECUTABLE);
|
let p = PathBuf::from(dir).join(UMU_BASE_LAUNCHER_EXECUTABLE);
|
||||||
if check_executable_exists(&p) {
|
if check_executable_exists(&p) {
|
||||||
return Some(p);
|
return p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None
|
PathBuf::new()
|
||||||
}
|
}
|
||||||
fn check_executable_exists<P: AsRef<OsStr>>(exec: P) -> bool {
|
fn check_executable_exists<P: AsRef<OsStr>>(exec: P) -> bool {
|
||||||
let has_umu_installed = Command::new(exec).stdout(Stdio::null()).output();
|
let has_umu_installed = Command::new(exec).stdout(Stdio::null()).spawn();
|
||||||
has_umu_installed.is_ok()
|
has_umu_installed.is_ok()
|
||||||
}
|
}
|
||||||
pub struct UMULauncher;
|
pub struct UMULauncher;
|
||||||
@ -79,7 +79,7 @@ impl ProcessHandler for UMULauncher {
|
|||||||
};
|
};
|
||||||
format!(
|
format!(
|
||||||
"GAMEID={game_id} {umu:?} \"{launch}\" {args}",
|
"GAMEID={game_id} {umu:?} \"{launch}\" {args}",
|
||||||
umu = UMU_LAUNCHER_EXECUTABLE.as_ref().unwrap(),
|
umu = &*UMU_LAUNCHER_EXECUTABLE,
|
||||||
launch = launch_command,
|
launch = launch_command,
|
||||||
args = args.join(" ")
|
args = args.join(" ")
|
||||||
)
|
)
|
||||||
|
|||||||
@ -14,7 +14,6 @@ use crate::{
|
|||||||
AppState, AppStatus,
|
AppState, AppStatus,
|
||||||
database::db::{DATA_ROOT_DIR, borrow_db_mut_checked},
|
database::db::{DATA_ROOT_DIR, borrow_db_mut_checked},
|
||||||
error::remote_access_error::RemoteAccessError,
|
error::remote_access_error::RemoteAccessError,
|
||||||
state_lock,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
@ -38,40 +37,16 @@ fn fetch_certificates() -> Vec<Certificate> {
|
|||||||
match entry {
|
match entry {
|
||||||
Ok(c) => {
|
Ok(c) => {
|
||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
match File::open(c.path()) {
|
File::open(c.path()).unwrap().read_to_end(&mut buf).unwrap();
|
||||||
Ok(f) => f,
|
|
||||||
Err(e) => {
|
|
||||||
warn!(
|
|
||||||
"Failed to open file at {} with error {}",
|
|
||||||
c.path().display(),
|
|
||||||
e
|
|
||||||
);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.read_to_end(&mut buf)
|
|
||||||
.expect(&format!(
|
|
||||||
"Failed to read to end of certificate file {}",
|
|
||||||
c.path().display()
|
|
||||||
));
|
|
||||||
|
|
||||||
match Certificate::from_pem_bundle(&buf) {
|
for cert in Certificate::from_pem_bundle(&buf).unwrap() {
|
||||||
Ok(certificates) => {
|
certs.push(cert);
|
||||||
for cert in certificates {
|
|
||||||
certs.push(cert);
|
|
||||||
}
|
|
||||||
info!(
|
|
||||||
"added {} certificate(s) from {}",
|
|
||||||
certs.len(),
|
|
||||||
c.file_name().display()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
Err(e) => warn!(
|
|
||||||
"Invalid certificate file {} with error {}",
|
|
||||||
c.path().display(),
|
|
||||||
e
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
|
info!(
|
||||||
|
"added {} certificate(s) from {}",
|
||||||
|
certs.len(),
|
||||||
|
c.file_name().into_string().unwrap()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
Err(_) => todo!(),
|
Err(_) => todo!(),
|
||||||
}
|
}
|
||||||
@ -90,7 +65,7 @@ pub fn get_client_sync() -> reqwest::blocking::Client {
|
|||||||
for cert in DROP_CERT_BUNDLE.iter() {
|
for cert in DROP_CERT_BUNDLE.iter() {
|
||||||
client = client.add_root_certificate(cert.clone());
|
client = client.add_root_certificate(cert.clone());
|
||||||
}
|
}
|
||||||
client.use_rustls_tls().build().expect("Failed to build synchronous client")
|
client.use_rustls_tls().build().unwrap()
|
||||||
}
|
}
|
||||||
pub fn get_client_async() -> reqwest::Client {
|
pub fn get_client_async() -> reqwest::Client {
|
||||||
let mut client = reqwest::ClientBuilder::new();
|
let mut client = reqwest::ClientBuilder::new();
|
||||||
@ -98,7 +73,7 @@ pub fn get_client_async() -> reqwest::Client {
|
|||||||
for cert in DROP_CERT_BUNDLE.iter() {
|
for cert in DROP_CERT_BUNDLE.iter() {
|
||||||
client = client.add_root_certificate(cert.clone());
|
client = client.add_root_certificate(cert.clone());
|
||||||
}
|
}
|
||||||
client.use_rustls_tls().build().expect("Failed to build asynchronous client")
|
client.use_rustls_tls().build().unwrap()
|
||||||
}
|
}
|
||||||
pub fn get_client_ws() -> reqwest::Client {
|
pub fn get_client_ws() -> reqwest::Client {
|
||||||
let mut client = reqwest::ClientBuilder::new();
|
let mut client = reqwest::ClientBuilder::new();
|
||||||
@ -106,11 +81,7 @@ pub fn get_client_ws() -> reqwest::Client {
|
|||||||
for cert in DROP_CERT_BUNDLE.iter() {
|
for cert in DROP_CERT_BUNDLE.iter() {
|
||||||
client = client.add_root_certificate(cert.clone());
|
client = client.add_root_certificate(cert.clone());
|
||||||
}
|
}
|
||||||
client
|
client.use_rustls_tls().http1_only().build().unwrap()
|
||||||
.use_rustls_tls()
|
|
||||||
.http1_only()
|
|
||||||
.build()
|
|
||||||
.expect("Failed to build websocket client")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn use_remote_logic(
|
pub async fn use_remote_logic(
|
||||||
@ -136,7 +107,7 @@ pub async fn use_remote_logic(
|
|||||||
return Err(RemoteAccessError::InvalidEndpoint);
|
return Err(RemoteAccessError::InvalidEndpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut app_state = state_lock!(state);
|
let mut app_state = state.lock().unwrap();
|
||||||
app_state.status = AppStatus::SignedOut;
|
app_state.status = AppStatus::SignedOut;
|
||||||
drop(app_state);
|
drop(app_state);
|
||||||
|
|
||||||
|
|||||||
@ -1 +0,0 @@
|
|||||||
pub mod state_lock;
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
#[macro_export]
|
|
||||||
macro_rules! state_lock {
|
|
||||||
($state:expr) => {
|
|
||||||
$state.lock().expect("Failed to lock onto state")
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://schema.tauri.app/config/2.0.0",
|
"$schema": "https://schema.tauri.app/config/2.0.0",
|
||||||
"productName": "Drop Desktop Client",
|
"productName": "Drop Desktop Client",
|
||||||
"version": "0.3.3",
|
"version": "0.3.2",
|
||||||
"identifier": "dev.drop.client",
|
"identifier": "dev.drop.client",
|
||||||
"build": {
|
"build": {
|
||||||
"beforeDevCommand": "yarn --cwd main dev --port 1432",
|
"beforeDevCommand": "yarn --cwd main dev --port 1432",
|
||||||
|
|||||||
Reference in New Issue
Block a user