diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json index 8de15af..3af426d 100644 --- a/src-tauri/capabilities/default.json +++ b/src-tauri/capabilities/default.json @@ -24,6 +24,11 @@ "sql:allow-execute", "fs:allow-app-write", "fs:allow-app-write-recursive", + "fs:allow-config-read", + "fs:allow-config-read-recursive", + "fs:allow-config-write", + "fs:allow-config-write-recursive", + "fs:allow-write-text-file", "updater:default", "process:default", "clipboard-manager:allow-read-text", diff --git a/src-tauri/capabilities/shell.json b/src-tauri/capabilities/shell.json index 411f126..700908f 100644 --- a/src-tauri/capabilities/shell.json +++ b/src-tauri/capabilities/shell.json @@ -64,11 +64,6 @@ "name": "powershell", "cmd": "powershell", "args": true - }, - { - "name": "cp", - "cmd": "cp", - "args": true } ] }, @@ -119,11 +114,6 @@ "name": "deno", "cmd": "deno", "args": true - }, - { - "name": "cp", - "cmd": "cp", - "args": true } ] } diff --git a/src/helpers/use-linux-registerer.ts b/src/helpers/use-linux-registerer.ts index 3515a0b..9907f15 100644 --- a/src/helpers/use-linux-registerer.ts +++ b/src/helpers/use-linux-registerer.ts @@ -4,7 +4,6 @@ import { useKvPairs } from "@/helpers/use-kvpairs"; import { useSettingsPageStatesStore } from "@/services/store"; import { invoke } from "@tauri-apps/api/core"; import { useLogger } from "@/helpers/use-logger"; -import { Command } from "@tauri-apps/plugin-shell"; interface FileMap { source: string; @@ -34,38 +33,45 @@ export function useLinuxRegisterer() { const isFlatpak = await invoke('is_flatpak'); const resourceDirPath = isFlatpak ? '/app/lib/neodlp' : await resourceDir(); const homeDirPath = await homeDir(); + const flatpakChromeManifestContent = { + name: "com.neosubhamoy.neodlp", + description: "NeoDLP MsgHost", + path: `${homeDirPath}/.local/bin/neodlp-msghost`, + type: "stdio", + allowed_origins: ["chrome-extension://mehopeailfjmiloiiohgicphlcgpompf/"] + }; + const flatpakFirefoxManifestContent = { + name: "com.neosubhamoy.neodlp", + description: "NeoDLP MsgHost", + path: `${homeDirPath}/.local/bin/neodlp-msghost`, + type: "stdio", + allowed_extension: ["neodlp@neosubhamoy.com"] + }; LOG.info("LINUX REGISTERER", `Is Flatpak: ${isFlatpak}, Resource dir: ${resourceDirPath}, Home dir: ${homeDirPath}`); if (isFlatpak) { + await fs.writeTextFile('/app/lib/neodlp/chrome.json', JSON.stringify(flatpakChromeManifestContent, null, 2)); + await fs.writeTextFile('/app/lib/neodlp/firefox.json', JSON.stringify(flatpakFirefoxManifestContent, null, 2)); + for (const file of filesToCopyFlatpak) { const sourcePath = await join(resourceDirPath, file.source); - // const destinationDir = await join(homeDirPath, file.dir); + const destinationDir = await join(homeDirPath, file.dir); const destinationPath = await join(homeDirPath, file.destination); - const command = Command.create('cp', [sourcePath, destinationPath]); - const output = await command.execute(); - if (output.code === 0) { + const dirExists = await fs.exists(destinationDir); + if (dirExists) { + await fs.copyFile(sourcePath, destinationPath); console.log(`File ${file.source} copied successfully to ${destinationPath}`); LOG.info("LINUX REGISTERER", `File ${file.source} copied successfully to ${destinationPath}`); } else { - console.error(`Failed to copy file ${file.source} to ${destinationPath}:`, output.stderr); - LOG.error("LINUX REGISTERER", `Failed to copy file ${file.source} to ${destinationPath}: ${output.stderr}`); + await fs.mkdir(destinationDir, { recursive: true }) + console.log(`Created dir ${destinationDir}`); + LOG.info("LINUX REGISTERER", `Created dir ${destinationDir}`); + await fs.copyFile(sourcePath, destinationPath); + console.log(`File ${file.source} copied successfully to ${destinationPath}`); + LOG.info("LINUX REGISTERER", `File ${file.source} copied successfully to ${destinationPath}`); } - - // const dirExists = await fs.exists(destinationDir); - // if (dirExists) { - // await fs.copyFile(sourcePath, destinationPath); - // console.log(`File ${file.source} copied successfully to ${destinationPath}`); - // LOG.info("LINUX REGISTERER", `File ${file.source} copied successfully to ${destinationPath}`); - // } else { - // await fs.mkdir(destinationDir, { recursive: true }) - // console.log(`Created dir ${destinationDir}`); - // LOG.info("LINUX REGISTERER", `Created dir ${destinationDir}`); - // await fs.copyFile(sourcePath, destinationPath); - // console.log(`File ${file.source} copied successfully to ${destinationPath}`); - // LOG.info("LINUX REGISTERER", `File ${file.source} copied successfully to ${destinationPath}`); - // } } } else { for (const file of filesToCopy) {