mirror of
https://github.com/safing/portmaster
synced 2025-09-01 18:19:12 +00:00
[WIP] Fix tauri notifications
This commit is contained in:
parent
d15ede9f53
commit
5ae261f062
7 changed files with 39 additions and 35 deletions
|
@ -474,10 +474,11 @@ tauri-build:
|
||||||
# Binaries
|
# Binaries
|
||||||
SAVE ARTIFACT --if-exists --keep-ts "target/${target}/release/portmaster" AS LOCAL "${outputDir}/${GO_ARCH_STRING}/portmaster"
|
SAVE ARTIFACT --if-exists --keep-ts "target/${target}/release/portmaster" AS LOCAL "${outputDir}/${GO_ARCH_STRING}/portmaster"
|
||||||
SAVE ARTIFACT --if-exists --keep-ts "target/${target}/release/portmaster.exe" AS LOCAL "${outputDir}/${GO_ARCH_STRING}/portmaster.exe"
|
SAVE ARTIFACT --if-exists --keep-ts "target/${target}/release/portmaster.exe" AS LOCAL "${outputDir}/${GO_ARCH_STRING}/portmaster.exe"
|
||||||
# SAVE ARTIFACT --if-exists --keep-ts "target/${target}/release/WebView2Loader.dll" AS LOCAL "${outputDir}/${GO_ARCH_STRING}/WebView2Loader.dll"
|
SAVE ARTIFACT --if-exists --keep-ts "target/${target}/release/WebView2Loader.dll" AS LOCAL "${outputDir}/${GO_ARCH_STRING}/WebView2Loader.dll"
|
||||||
|
|
||||||
SAVE ARTIFACT --if-exists --keep-ts "target/${target}/release/portmaster" ./output/portmaster
|
SAVE ARTIFACT --if-exists --keep-ts "target/${target}/release/portmaster" ./output/portmaster
|
||||||
SAVE ARTIFACT --if-exists --keep-ts "target/${target}/release/portmaster.exe" ./output/portmaster.exe
|
SAVE ARTIFACT --if-exists --keep-ts "target/${target}/release/portmaster.exe" ./output/portmaster.exe
|
||||||
|
SAVE ARTIFACT --if-exists --keep-ts "target/${target}/release/WebView2Loader.dll" ./output/WebView2Loader.dll
|
||||||
|
|
||||||
|
|
||||||
tauri-release:
|
tauri-release:
|
||||||
|
@ -517,9 +518,11 @@ release-prep:
|
||||||
|
|
||||||
# Windows specific
|
# Windows specific
|
||||||
COPY (+tauri-build/output/portmaster.exe --target="x86_64-pc-windows-gnu") ./output/binary/windows_amd64/portmaster.exe
|
COPY (+tauri-build/output/portmaster.exe --target="x86_64-pc-windows-gnu") ./output/binary/windows_amd64/portmaster.exe
|
||||||
|
COPY (+tauri-build/output/WebView2Loader.dll --target="x86_64-pc-windows-gnu") ./output/binary/windows_amd64/WebView2Loader.dll
|
||||||
COPY (+go-build/output/portmaster-core.exe --GOARCH=amd64 --GOOS=windows --CMDS=portmaster-core) ./output/binary/windows_amd64/portmaster-core.exe
|
COPY (+go-build/output/portmaster-core.exe --GOARCH=amd64 --GOOS=windows --CMDS=portmaster-core) ./output/binary/windows_amd64/portmaster-core.exe
|
||||||
# TODO(vladimir): figure out a way to get the lastest release of the kext.
|
# TODO(vladimir): figure out a way to get the lastest release of the kext and dll.
|
||||||
RUN touch ./output/binary/windows_amd64/portmaster-kext.sys
|
RUN wget -O ./output/binary/windows_amd64/portmaster-kext.sys https://updates.safing.io/windows_amd64/kext/portmaster-kext_v2-0-4.sys
|
||||||
|
RUN touch ./output/binary/windows_amd64/portmaster-core.dll
|
||||||
|
|
||||||
# All platforms
|
# All platforms
|
||||||
COPY (+assets/assets.zip) ./output/binary/all/assets.zip
|
COPY (+assets/assets.zip) ./output/binary/all/assets.zip
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use log::LevelFilter;
|
use log::LevelFilter;
|
||||||
|
|
||||||
#[cfg(not(debug_assertions))]
|
// #[cfg(not(debug_assertions))]
|
||||||
const DEFAULT_LOG_LEVEL: log::LevelFilter = log::LevelFilter::Warn;
|
// const DEFAULT_LOG_LEVEL: log::LevelFilter = log::LevelFilter::Warn;
|
||||||
|
|
||||||
#[cfg(debug_assertions)]
|
// #[cfg(debug_assertions)]
|
||||||
const DEFAULT_LOG_LEVEL: log::LevelFilter = log::LevelFilter::Debug;
|
const DEFAULT_LOG_LEVEL: log::LevelFilter = log::LevelFilter::Debug;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -43,8 +43,8 @@ pub fn parse(raw: impl IntoIterator<Item = impl Into<std::ffi::OsString>>) -> Cl
|
||||||
data: None,
|
data: None,
|
||||||
log_level: DEFAULT_LOG_LEVEL,
|
log_level: DEFAULT_LOG_LEVEL,
|
||||||
background: false,
|
background: false,
|
||||||
with_prompts: false,
|
with_prompts: true,
|
||||||
with_notifications: false,
|
with_notifications: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
let raw = clap_lex::RawArgs::new(raw);
|
let raw = clap_lex::RawArgs::new(raw);
|
||||||
|
@ -67,11 +67,11 @@ pub fn parse(raw: impl IntoIterator<Item = impl Into<std::ffi::OsString>>) -> Cl
|
||||||
Ok("background") => {
|
Ok("background") => {
|
||||||
cli.background = true;
|
cli.background = true;
|
||||||
}
|
}
|
||||||
Ok("with_prompts") => {
|
Ok("no-prompts") => {
|
||||||
cli.with_prompts = true;
|
cli.with_prompts = false;
|
||||||
}
|
}
|
||||||
Ok("with_notifications") => {
|
Ok("no-notifications") => {
|
||||||
cli.with_notifications = true;
|
cli.with_notifications = false;
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
// Ignore unexpected flags
|
// Ignore unexpected flags
|
||||||
|
|
|
@ -127,14 +127,14 @@ fn main() {
|
||||||
let cli_args = cli::parse(std::env::args());
|
let cli_args = cli::parse(std::env::args());
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
let log_target = if let Some(data_dir) = cli_args.data {
|
let log_target = tauri_plugin_log::Target::new(tauri_plugin_log::TargetKind::Stdout);
|
||||||
tauri_plugin_log::Target::new(tauri_plugin_log::TargetKind::Folder {
|
// let log_target = if let Some(data_dir) = cli_args.data {
|
||||||
path: Path::new(&format!("{}/logs/app2", data_dir)).into(),
|
// tauri_plugin_log::Target::new(tauri_plugin_log::TargetKind::Folder {
|
||||||
file_name: None,
|
// path: Path::new(&format!("{}/logs/app2", data_dir)).into(),
|
||||||
})
|
// file_name: None,
|
||||||
} else {
|
// })
|
||||||
tauri_plugin_log::Target::new(tauri_plugin_log::TargetKind::Stdout)
|
// } else {
|
||||||
};
|
// };
|
||||||
|
|
||||||
// TODO(vladimir): Permission for logs/app2 folder are not guaranteed. Use the default location for now.
|
// TODO(vladimir): Permission for logs/app2 folder are not guaranteed. Use the default location for now.
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
|
|
|
@ -2,6 +2,7 @@ use crate::portapi::client::*;
|
||||||
use crate::portapi::message::*;
|
use crate::portapi::message::*;
|
||||||
use crate::portapi::models::notification::*;
|
use crate::portapi::models::notification::*;
|
||||||
use crate::portapi::types::*;
|
use crate::portapi::types::*;
|
||||||
|
use log::debug;
|
||||||
use log::error;
|
use log::error;
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use tauri::async_runtime;
|
use tauri::async_runtime;
|
||||||
|
@ -25,12 +26,12 @@ pub async fn notification_handler(cli: PortAPI) {
|
||||||
Ok(n) => {
|
Ok(n) => {
|
||||||
// Skip if this one should not be shown using the system notifications
|
// Skip if this one should not be shown using the system notifications
|
||||||
if !n.show_on_system {
|
if !n.show_on_system {
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip if this action has already been acted on
|
// Skip if this action has already been acted on
|
||||||
if n.selected_action_id.is_empty() {
|
if !n.selected_action_id.is_empty() {
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
show_notification(&cli, key, n).await;
|
show_notification(&cli, key, n).await;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,12 +28,12 @@
|
||||||
"takesValue": true
|
"takesValue": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "with-notifications",
|
"name": "no-notifications",
|
||||||
"description": "Enable experimental notifications via Tauri. Replaces the notifier app."
|
"description": "Disable notifications via Tauri."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "with-prompts",
|
"name": "no-prompts",
|
||||||
"description": "Enable experimental prompt support via Tauri. Replaces the notifier app."
|
"description": "Disable prompt support via Tauri."
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ func (i *OSIntegration) Initialize() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CleanUp releases any resourses allocated during initializaion.
|
// CleanUp releases any resources allocated during initialization.
|
||||||
func (i *OSIntegration) CleanUp() error {
|
func (i *OSIntegration) CleanUp() error {
|
||||||
if i.os.dll != nil {
|
if i.os.dll != nil {
|
||||||
return i.os.dll.Release()
|
return i.os.dll.Release()
|
||||||
|
|
|
@ -238,14 +238,14 @@ func updateListIndex() error {
|
||||||
func ResolveListIDs(ids []string) ([]string, error) {
|
func ResolveListIDs(ids []string) ([]string, error) {
|
||||||
index, err := getListIndexFromCache()
|
index, err := getListIndexFromCache()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, database.ErrNotFound) {
|
// if errors.Is(err, database.ErrNotFound) {
|
||||||
if err := updateListIndex(); err != nil {
|
// if err := updateListIndex(); err != nil {
|
||||||
return nil, err
|
// return nil, err
|
||||||
}
|
// }
|
||||||
|
|
||||||
// retry resolving IDs
|
// // retry resolving IDs
|
||||||
return ResolveListIDs(ids)
|
// return ResolveListIDs(ids)
|
||||||
}
|
// }
|
||||||
|
|
||||||
log.Errorf("failed to resolved ids %v: %s", ids, err)
|
log.Errorf("failed to resolved ids %v: %s", ids, err)
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Loading…
Add table
Reference in a new issue