feat: update SDK and GUI versions, add debugger protection settings
- Updated SDK_DECODER_SEMVER to "1.3.0" and GUI_SEMVER to "1.2.4" in config.ini. - Updated MailViewer component to handle PDF already open error and improved iframe handling. - Removed deprecated useMsgConverter setting from settings page. - Added IsDebuggerRunning function to check for attached debuggers and quit the app if detected. - Enhanced PDF viewer to prevent infinite loading and improved error handling. Co-Authored-By: Laky-64 <iraci.matteo@gmail.com>
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
<script lang="ts">
|
||||
import { X, MailOpen, Image, FileText, File, ShieldCheck, Shield, Signature, FileUser, Loader2 } from "@lucide/svelte";
|
||||
import { X, MailOpen, Image, FileText, File, ShieldCheck, Shield, Signature, FileCode, Loader2 } from "@lucide/svelte";
|
||||
import { ShowOpenFileDialog, ReadEML, OpenPDF, OpenImageWindow, OpenPDFWindow, OpenImage, ReadMSG, ReadPEC, OpenEMLWindow } from "$lib/wailsjs/go/main/App";
|
||||
import type { internal } from "$lib/wailsjs/go/models";
|
||||
import { sidebarOpen } from "$lib/stores/app";
|
||||
import { onDestroy, onMount } from "svelte";
|
||||
import { toast } from "svelte-sonner";
|
||||
import { EventsOn, WindowShow, WindowUnminimise } from "$lib/wailsjs/runtime/runtime";
|
||||
import type { SupportedFileTypePreview } from "$lib/types";
|
||||
import { mailState } from "$lib/stores/mail-state.svelte";
|
||||
import { settingsStore } from "$lib/stores/settings.svelte";
|
||||
import * as m from "$lib/paraglide/messages";
|
||||
@@ -15,6 +14,9 @@
|
||||
let isLoading = $state(false);
|
||||
let loadingText = $state("");
|
||||
|
||||
|
||||
let iFrameUtilHTML = "<style>body{margin:0;padding:20px;font-family:sans-serif;} a{pointer-events:none!important;cursor:default!important;}</style><script>function handleWheel(event){if(event.ctrlKey){event.preventDefault();}}document.addEventListener('wheel',handleWheel,{passive:false});<\/script>";
|
||||
|
||||
function onClear() {
|
||||
mailState.clear();
|
||||
}
|
||||
@@ -22,7 +24,7 @@
|
||||
$effect(() => {
|
||||
console.log("Current email changed:", mailState.currentEmail);
|
||||
if(mailState.currentEmail !== null) {
|
||||
sidebarOpen.set(false);
|
||||
sidebarOpen.set(false);
|
||||
}
|
||||
console.log(mailState.currentEmail?.attachments)
|
||||
})
|
||||
@@ -47,21 +49,12 @@
|
||||
let emlContent;
|
||||
|
||||
if (lowerArg.endsWith(".msg")) {
|
||||
const useExt = settingsStore.settings.useMsgConverter ?? true;
|
||||
if (useExt) {
|
||||
loadingText = m.mail_loading_msg_conversion();
|
||||
}
|
||||
emlContent = await ReadMSG(arg, useExt);
|
||||
if(emlContent.isPec) {
|
||||
toast.warning(m.mail_pec_feature_warning());
|
||||
}
|
||||
loadingText = m.mail_loading_msg_conversion();
|
||||
emlContent = await ReadMSG(arg, true);
|
||||
} else {
|
||||
// EML handling
|
||||
try {
|
||||
emlContent = await ReadPEC(arg);
|
||||
if(emlContent.isPec) {
|
||||
toast.warning(m.mail_pec_feature_warning());
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn("ReadPEC failed, trying ReadEML:", e);
|
||||
emlContent = await ReadEML(arg);
|
||||
@@ -103,9 +96,13 @@
|
||||
} else {
|
||||
await OpenPDF(base64Data, filename);
|
||||
}
|
||||
} catch (error) {
|
||||
} catch (error: string | any) {
|
||||
if(error.includes(filename) && error.includes("already open")) {
|
||||
toast.error(m.mail_pdf_already_open());
|
||||
return;
|
||||
}
|
||||
console.error("Failed to open PDF:", error);
|
||||
toast.error(m.mail_error_pdf());
|
||||
toast.error(m.mail_error_pdf());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,17 +138,11 @@
|
||||
// If the file is .eml, otherwise if is .msg, read accordingly
|
||||
let email: internal.EmailData;
|
||||
if(result.toLowerCase().endsWith(".msg")) {
|
||||
const useExt = settingsStore.settings.useMsgConverter ?? true;
|
||||
if (useExt) {
|
||||
loadingText = m.mail_loading_msg_conversion();
|
||||
}
|
||||
email = await ReadMSG(result, useExt);
|
||||
loadingText = m.mail_loading_msg_conversion();
|
||||
email = await ReadMSG(result, true);
|
||||
} else {
|
||||
email = await ReadEML(result);
|
||||
}
|
||||
if(email.isPec) {
|
||||
toast.warning(m.mail_pec_feature_warning(), {duration: 10000});
|
||||
}
|
||||
mailState.setParams(email);
|
||||
sidebarOpen.set(false);
|
||||
|
||||
@@ -182,15 +173,10 @@
|
||||
return "";
|
||||
}
|
||||
|
||||
function getFileExtension(filename: string): string {
|
||||
return filename.slice((filename.lastIndexOf(".") - 1 >>> 0) + 2).toLowerCase();
|
||||
}
|
||||
|
||||
function shouldPreview(filename: string): boolean {
|
||||
if (!settingsStore.settings.useBuiltinPreview) return false;
|
||||
const ext = getFileExtension(filename);
|
||||
const supported = settingsStore.settings.previewFileSupportedTypes || [];
|
||||
return supported.includes(ext as SupportedFileTypePreview);
|
||||
function handleWheel(event: WheelEvent) {
|
||||
if (event.ctrlKey) {
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -290,7 +276,7 @@
|
||||
class="att-btn pdf"
|
||||
onclick={() => openPDFHandler(arrayBufferToBase64(att.data), att.filename)}
|
||||
>
|
||||
<FileText size="15" />
|
||||
<FileText />
|
||||
<span class="att-name">{att.filename}</span>
|
||||
</button>
|
||||
{:else if att.filename.toLowerCase().endsWith(".eml")}
|
||||
@@ -316,7 +302,7 @@
|
||||
href={`data:${att.contentType};base64,${arrayBufferToBase64(att.data)}`}
|
||||
download={att.filename}
|
||||
>
|
||||
<FileUser size="14" />
|
||||
<FileCode size="14" />
|
||||
<span class="att-name">{att.filename}</span>
|
||||
</a>
|
||||
{:else}
|
||||
@@ -342,11 +328,11 @@
|
||||
|
||||
<div class="email-body-wrapper">
|
||||
<iframe
|
||||
srcdoc={mailState.currentEmail.body +
|
||||
"<style>body{margin:0;padding:20px;font-family:sans-serif;} a{pointer-events:none!important;cursor:default!important;}</style>"}
|
||||
srcdoc={mailState.currentEmail.body + iFrameUtilHTML}
|
||||
title="Email Body"
|
||||
class="email-iframe"
|
||||
sandbox="allow-same-origin"
|
||||
sandbox="allow-same-origin allow-scripts"
|
||||
onwheel={handleWheel}
|
||||
></iframe>
|
||||
</div>
|
||||
</div>
|
||||
@@ -641,28 +627,6 @@
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.badged-row {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.signed-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
background: rgba(239, 68, 68, 0.15);
|
||||
color: #f87171;
|
||||
border: 1px solid rgba(239, 68, 68, 0.3);
|
||||
padding: 2px 6px;
|
||||
border-radius: 6px;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
vertical-align: middle;
|
||||
user-select: none;
|
||||
width: fit-content;
|
||||
}
|
||||
|
||||
.pec-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -5,9 +5,11 @@ import { getFromLocalStorage, saveToLocalStorage } from "$lib/utils/localStorage
|
||||
const STORAGE_KEY = "emly_gui_settings";
|
||||
|
||||
const defaults: EMLy_GUI_Settings = {
|
||||
selectedLanguage: "en",
|
||||
selectedLanguage: "it",
|
||||
useBuiltinPreview: true,
|
||||
useBuiltinPDFViewer: true,
|
||||
previewFileSupportedTypes: ["jpg", "jpeg", "png"],
|
||||
enableAttachedDebuggerProtection: true,
|
||||
};
|
||||
|
||||
class SettingsStore {
|
||||
|
||||
2
frontend/src/lib/types.d.ts
vendored
2
frontend/src/lib/types.d.ts
vendored
@@ -6,8 +6,8 @@ interface EMLy_GUI_Settings {
|
||||
selectedLanguage: SupportedLanguages = "en" | "it";
|
||||
useBuiltinPreview: boolean;
|
||||
useBuiltinPDFViewer?: boolean;
|
||||
useMsgConverter?: boolean;
|
||||
previewFileSupportedTypes?: SupportedFileTypePreview[];
|
||||
enableAttachedDebuggerProtection?: boolean;
|
||||
}
|
||||
|
||||
type SupportedLanguages = "en" | "it";
|
||||
|
||||
2
frontend/src/lib/wailsjs/go/main/App.d.ts
vendored
2
frontend/src/lib/wailsjs/go/main/App.d.ts
vendored
@@ -18,6 +18,8 @@ export function GetStartupFile():Promise<string>;
|
||||
|
||||
export function GetViewerData():Promise<main.ViewerData>;
|
||||
|
||||
export function IsDebuggerRunning():Promise<boolean>;
|
||||
|
||||
export function OpenDefaultAppsSettings():Promise<void>;
|
||||
|
||||
export function OpenEMLWindow(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
@@ -3,81 +3,85 @@
|
||||
// This file is automatically generated. DO NOT EDIT
|
||||
|
||||
export function CheckIsDefaultEMLHandler() {
|
||||
return window['go']['main']['App']['CheckIsDefaultEMLHandler']();
|
||||
return ObfuscatedCall(0, []);
|
||||
}
|
||||
|
||||
export function GetConfig() {
|
||||
return window['go']['main']['App']['GetConfig']();
|
||||
return ObfuscatedCall(1, []);
|
||||
}
|
||||
|
||||
export function GetImageViewerData() {
|
||||
return window['go']['main']['App']['GetImageViewerData']();
|
||||
return ObfuscatedCall(2, []);
|
||||
}
|
||||
|
||||
export function GetMachineData() {
|
||||
return window['go']['main']['App']['GetMachineData']();
|
||||
return ObfuscatedCall(3, []);
|
||||
}
|
||||
|
||||
export function GetPDFViewerData() {
|
||||
return window['go']['main']['App']['GetPDFViewerData']();
|
||||
return ObfuscatedCall(4, []);
|
||||
}
|
||||
|
||||
export function GetStartupFile() {
|
||||
return window['go']['main']['App']['GetStartupFile']();
|
||||
return ObfuscatedCall(5, []);
|
||||
}
|
||||
|
||||
export function GetViewerData() {
|
||||
return window['go']['main']['App']['GetViewerData']();
|
||||
return ObfuscatedCall(6, []);
|
||||
}
|
||||
|
||||
export function IsDebuggerRunning() {
|
||||
return ObfuscatedCall(7, []);
|
||||
}
|
||||
|
||||
export function OpenDefaultAppsSettings() {
|
||||
return window['go']['main']['App']['OpenDefaultAppsSettings']();
|
||||
return ObfuscatedCall(8, []);
|
||||
}
|
||||
|
||||
export function OpenEMLWindow(arg1, arg2) {
|
||||
return window['go']['main']['App']['OpenEMLWindow'](arg1, arg2);
|
||||
return ObfuscatedCall(9, [arg1, arg2]);
|
||||
}
|
||||
|
||||
export function OpenImage(arg1, arg2) {
|
||||
return window['go']['main']['App']['OpenImage'](arg1, arg2);
|
||||
return ObfuscatedCall(10, [arg1, arg2]);
|
||||
}
|
||||
|
||||
export function OpenImageWindow(arg1, arg2) {
|
||||
return window['go']['main']['App']['OpenImageWindow'](arg1, arg2);
|
||||
return ObfuscatedCall(11, [arg1, arg2]);
|
||||
}
|
||||
|
||||
export function OpenPDF(arg1, arg2) {
|
||||
return window['go']['main']['App']['OpenPDF'](arg1, arg2);
|
||||
return ObfuscatedCall(12, [arg1, arg2]);
|
||||
}
|
||||
|
||||
export function OpenPDFWindow(arg1, arg2) {
|
||||
return window['go']['main']['App']['OpenPDFWindow'](arg1, arg2);
|
||||
return ObfuscatedCall(13, [arg1, arg2]);
|
||||
}
|
||||
|
||||
export function QuitApp() {
|
||||
return window['go']['main']['App']['QuitApp']();
|
||||
return ObfuscatedCall(14, []);
|
||||
}
|
||||
|
||||
export function ReadEML(arg1) {
|
||||
return window['go']['main']['App']['ReadEML'](arg1);
|
||||
return ObfuscatedCall(15, [arg1]);
|
||||
}
|
||||
|
||||
export function ReadMSG(arg1, arg2) {
|
||||
return window['go']['main']['App']['ReadMSG'](arg1, arg2);
|
||||
return ObfuscatedCall(16, [arg1, arg2]);
|
||||
}
|
||||
|
||||
export function ReadMSGOSS(arg1) {
|
||||
return window['go']['main']['App']['ReadMSGOSS'](arg1);
|
||||
return ObfuscatedCall(17, [arg1]);
|
||||
}
|
||||
|
||||
export function ReadPEC(arg1) {
|
||||
return window['go']['main']['App']['ReadPEC'](arg1);
|
||||
return ObfuscatedCall(18, [arg1]);
|
||||
}
|
||||
|
||||
export function SaveConfig(arg1) {
|
||||
return window['go']['main']['App']['SaveConfig'](arg1);
|
||||
return ObfuscatedCall(19, [arg1]);
|
||||
}
|
||||
|
||||
export function ShowOpenFileDialog() {
|
||||
return window['go']['main']['App']['ShowOpenFileDialog']();
|
||||
return ObfuscatedCall(20, []);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user