CH-J ToolsSerververwaltung über SSH
Menü
Veröffentlichte Quellen

CH-J Tools

Durchsuchen Sie Verzeichnisse und Dateien einer bestimmten Anwendungsausgabe.

Quellen als ZIP herunterladen
CH-J / Server Manager 872 Dateien
core-20261030T220507Z-61e4558d889f Hinzugefügt: · Erstellt:
app.rs Hinzugefügt: Datum nicht erfasst 6,4 KB · 151 Zeilen
Code Datei herunterladen
1//! Application info, legal documents, configuration, languages and window controls.
3use super::{logged, main_core, payload, text, CommandResult};
4use crate::core::app::{CoreSlot, CORE_API_VERSION, COPYRIGHT, DATA_SCHEMA, MODULE_API_VERSION};
5use crate::core::error::{CoreError, CoreResult};
6use crate::core::legal::{LICENSE_NAME, LICENSE_VERSION};
7use crate::security::caller::MAIN_LABEL;
8use crate::security::url_policy::is_allowed_external_url;
9use serde_json::{json, Value};
10use tauri::{Manager, State, Webview};
11use tauri_plugin_opener::OpenerExt;
13#[tauri::command]
14pub async fn core_get_info(webview: Webview, slot: State<'_, CoreSlot>) -> CommandResult {
15 let core = main_core(&webview, &slot)?;
16 core.services.modules.install_close_guard(&core)?;
17 let (platform, arch) = crate::core::diagnostics::http::node_platform_arch();
18 Ok(json!({
19 "name": "CH-J Server Manager",
20 "version": core.build.version,
21 "buildId": core.build.build_id,
22 "platform": platform,
23 "arch": arch,
24 "coreApi": CORE_API_VERSION,
25 "pluginApi": MODULE_API_VERSION,
26 "moduleApi": MODULE_API_VERSION,
27 "dataSchema": DATA_SCHEMA,
28 "license": format!("{LICENSE_NAME} {LICENSE_VERSION}"),
29 "copyright": COPYRIGHT,
30 "runtime": "tauri"
31 }))
34#[tauri::command]
35pub async fn core_legal_open(webview: Webview, slot: State<'_, CoreSlot>, payload: Option<Value>) -> CommandResult {
36 let core = main_core(&webview, &slot)?;
37 let payload = super::payload(payload);
38 let result = (|| -> CoreResult<Value> {
39 let key = text(&payload, "document");
40 let path = match key {
41 "documentation" => core.paths.docs().join("README.md"),
42 "safetyCzech" => core.paths.docs().join("provozni-bezpecnost-a-zalohovani.md"),
43 "safetyEnglish" => core.paths.docs().join("operational-safety-and-backup-guidance.md"),
44 "safetyGerman" => core.paths.docs().join("betriebssicherheit-und-datensicherung.md"),
45 "application" => core.paths.licenses().join("APPLICATION_LICENSE.txt"),
46 "notice" => core.paths.licenses().join("NOTICE.txt"),
47 // Electron/Chromium are no longer shipped; their former entries open the
48 // third-party notices that now cover Tauri, WebView and Rust crates.
49 "thirdParty" | "tauri" | "electron" | "chromium" => core.paths.licenses().join("THIRD_PARTY_NOTICES.txt"),
50 "thirdPartyBundle" => core.paths.licenses().join("THIRD_PARTY_LICENSES.zip"),
51 _ => return Err(CoreError::plain("Unknown legal document.")),
52 };
53 core.app.opener().open_path(path.to_string_lossy(), None::<&str>).map_err(|e| CoreError::plain(format!("The legal document could not be opened: {e}")))?;
54 Ok(json!({ "ok": true }))
55 })();
56 logged(&core, "legal:open", result)
59#[tauri::command]
60pub async fn core_open_external(webview: Webview, slot: State<'_, CoreSlot>, payload: Option<Value>) -> CommandResult {
61 let core = main_core(&webview, &slot)?;
62 let payload = super::payload(payload);
63 let url = text(&payload, "url");
64 if !is_allowed_external_url(url) {
65 return logged(&core, "core:openExternal", Err(CoreError::plain("The address is not an allowed external link.")));
66 }
67 core.app.opener().open_url(url, None::<&str>).map_err(|e| CoreError::plain(e.to_string()))?;
68 Ok(json!({ "ok": true }))
71#[tauri::command]
72pub async fn core_config_get(webview: Webview, slot: State<'_, CoreSlot>) -> CommandResult {
73 Ok(main_core(&webview, &slot)?.config.get())
76#[tauri::command]
77pub async fn core_config_update(webview: Webview, slot: State<'_, CoreSlot>, payload: Option<Value>) -> CommandResult {
78 let core = main_core(&webview, &slot)?;
79 let payload = super::payload(payload);
80 let result = async {
81 if payload.get("security").map(|s| !s.is_null()).unwrap_or(false) {
82 core.vault.verify_password(text(&payload, "masterPassword")).await?;
83 if payload["security"]["requireSystemAuthentication"] == true && core.services.biometrics.availability().await["available"] != true {
84 return Err(CoreError::plain("BIOMETRIC_UNAVAILABLE"));
85 }
86 }
87 let config = core.config.update(&payload)?;
88 core.services.modules.notify_language(&core, &core.config.language());
89 Ok(config)
90 }
91 .await;
92 core.services.availability.changed();
93 logged(&core, "config:update", result)
96#[tauri::command]
97pub async fn core_i18n_languages(webview: Webview, slot: State<'_, CoreSlot>) -> CommandResult {
98 Ok(main_core(&webview, &slot)?.i18n.languages_json())
101/// Frameless window controls; every window may control only itself.
102#[tauri::command]
103pub async fn window_control(webview: Webview, payload: Option<Value>) -> CommandResult {
104 let payload = payload_or_empty(payload);
105 let window = webview.window();
106 if text(&payload, "action") == "closeQueryReply" {
107 if let Some(core) = webview.app_handle().state::<CoreSlot>().try_get() {
108 if let (Some(id), Some(dirty)) = (payload["queryId"].as_u64(), payload["dirty"].as_bool()) {
109 core.services.modules.close_query_reply(window.label(), id, dirty);
110 }
111 }
112 return Ok(json!({ "ok": true }));
113 }
114 let result = match text(&payload, "action") {
115 "minimize" => window.minimize(),
116 "toggleMaximize" => {
117 if window.is_maximized().unwrap_or(false) {
118 window.unmaximize()
119 } else {
120 window.maximize()
121 }
122 }
123 "close" => window.close(),
124 "startDrag" => window.start_dragging(),
125 _ => return Err(CoreError::plain("Unknown window action.")),
126 };
127 result.map_err(|e| CoreError::plain(e.to_string()))?;
128 Ok(json!({ "ok": true }))
131fn payload_or_empty(value: Option<Value>) -> Value {
132 payload(value)
135#[tauri::command]
136pub async fn window_is_maximized(webview: Webview) -> CommandResult {
137 Ok(json!(webview.window().is_maximized().unwrap_or(false)))
140/// User activity from any Core-owned window (vault auto-lock).
141#[tauri::command]
142pub fn window_activity(webview: Webview, slot: State<'_, CoreSlot>) -> CommandResult {
143 if let Some(core) = slot.try_get() {
144 let label = webview.label();
145 if label == MAIN_LABEL || core.windows.module_by_label(label).is_some() {
146 core.services.lock.activity();
147 }
148 }
149 let _ = webview.app_handle();
150 Ok(Value::Null)
SHA-2567cfdcd168d76a04ed2222132960f25dd1e15f959daa8857873c3493cb4e2fddf

CH-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 Archivs77380d4805485ffa4027fbe7858b5836f197a4aa9d52358a43e2d12d018744df
Dateien