Veröffentlichte Quellen
Quellen als ZIP herunterladen
CH-J Tools
Durchsuchen Sie Verzeichnisse und Dateien einer bestimmten Anwendungsausgabe.
CH-J / Server Manager
872 Dateien
core-20261030T220507Z-61e4558d889f
Hinzugefügt: · Erstellt:
1
//! License window commands (port of `legal/showLicenseWindow.js`). The flow is enforced in2
//! the Core: guidance must be read before `license_show`, `license_show` before accept.4
use super::{payload, CommandResult};5
use crate::core::error::CoreError;6
use crate::core::legal::LicenseAcceptance;7
use crate::security::caller::require_license;8
use parking_lot::Mutex;9
use serde_json::{json, Value};10
use std::sync::Arc;11
use tauri::{Manager, State, Webview};13
pub struct LicenseFlow {14
pub acceptance: Arc<LicenseAcceptance>,15
pub language: String,16
pub presented: bool,17
pub shown: bool,18
pub accepted: bool,19
pub done: Option<tokio::sync::oneshot::Sender<bool>>,20
}22
#[derive(Default)]23
pub struct LicenseSlot(pub Mutex<Option<LicenseFlow>>);25
fn guard(webview: &Webview) -> Result<(), CoreError> {26
require_license(webview.label(), webview.url().ok())27
}29
#[tauri::command]30
pub async fn license_read(webview: Webview, slot: State<'_, LicenseSlot>) -> CommandResult {31
guard(&webview)?;32
let mut flow = slot.0.lock();33
let flow = flow.as_mut().ok_or_else(|| CoreError::plain("License dialog is not active."))?;34
flow.presented = true;35
let mut value = json!({ "text": flow.acceptance.text, "guidance": flow.acceptance.guidance });36
for (k, v) in &flow.acceptance.identity {37
value[k] = v.clone();38
}39
value["language"] = json!(flow.language);40
Ok(value)41
}43
#[tauri::command]44
pub async fn license_show(webview: Webview, slot: State<'_, LicenseSlot>, payload: Option<Value>) -> CommandResult {45
guard(&webview)?;46
let payload = super::payload(payload);47
let mut flow = slot.0.lock();48
let flow = flow.as_mut().ok_or_else(|| CoreError::plain("License dialog is not active."))?;49
if !flow.presented || payload.get("guidanceSha256").and_then(Value::as_str) != Some(flow.acceptance.identity_value("guidanceSha256")) {50
return Err(CoreError::plain("Display the current operational guidance before continuing."));51
}52
flow.shown = true;53
Ok(json!({ "ok": true }))54
}56
#[tauri::command]57
pub async fn license_accept(webview: Webview, slot: State<'_, LicenseSlot>, payload: Option<Value>) -> CommandResult {58
guard(&webview)?;59
let payload = super::payload(payload);60
{61
let mut flow = slot.0.lock();62
let flow = flow.as_mut().ok_or_else(|| CoreError::plain("License dialog is not active."))?;63
if !flow.shown {64
return Err(CoreError::plain("Display operational guidance before accepting the license."));65
}66
flow.acceptance.accept(&payload, flow.shown)?;67
flow.accepted = true;68
}69
close_later(&webview);70
Ok(json!({ "ok": true }))71
}73
#[tauri::command]74
pub async fn license_decline(webview: Webview) -> CommandResult {75
guard(&webview)?;76
close_later(&webview);77
Ok(json!({ "ok": true }))78
}80
/// Lets the IPC reply reach the renderer before the window closes.81
fn close_later(webview: &Webview) {82
let window = webview.window();83
let _ = window.app_handle();84
tauri::async_runtime::spawn(async move {85
tokio::time::sleep(std::time::Duration::from_millis(50)).await;86
let _ = window.close();87
});88
}90
pub fn _unused(value: Option<Value>) -> Value {91
payload(value)92
}SHA-256
e6f41fce65551696c238ad7744f4bbb4e7b3f32a30cdae77276816169b127ec0CH-J Proprietary Software License 1.14 · Die Quellen werden unter der CH-J Proprietary Software License 1.14 bereitgestellt. Ihre Verfügbarkeit ändert die Lizenzbedingungen nicht und gewährt keine zusätzlichen Rechte.
SHA-256 des Archivs
77380d4805485ffa4027fbe7858b5836f197a4aa9d52358a43e2d12d018744df