Skip to content

Commit

Permalink
finish about info gui - start on fuse integration
Browse files Browse the repository at this point in the history
  • Loading branch information
lilyannehall committed Dec 26, 2024
1 parent dd73d36 commit 5546963
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 13 deletions.
32 changes: 24 additions & 8 deletions bin/fuse.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
'use strict';

const Fuse = require('fuse-native');
const { execSync } = require('node:child_process');
const path = require('node:path');

function _init(mnt) {
return new Promise(async (resolve, reject) => {
Expand All @@ -10,8 +12,8 @@ function _init(mnt) {
return cb(Fuse.ENOENT)
},
getattr: function (path, cb) {
if (path === '/') return cb(null, stat({ mode: 'dir', size: 4096 }))
if (path === '/test') return cb(null, stat({ mode: 'file', size: 11 }))
if (path === '/') return cb(null, { mode: 'dir', size: 4096 })
if (path === '/test') return cb(null, { mode: 'file', size: 11 })
return cb(Fuse.ENOENT)
},
open: function (path, flags, cb) {
Expand All @@ -28,16 +30,30 @@ function _init(mnt) {
}
};

// TODO Fuse.isConfigured? pkexec

const fuse = new Fuse(mnt, ops, { debug: true });
const fuseconfigpath = path.join(__dirname, '../node_modules/.bin/fuse-native');

fuse.mount(function(err) {
Fuse.isConfigured((err, isConfigured) => {
if (err) {
return reject(err);
}
resolve();
})

if (!isConfigured) {
try {
execSync(`pkexec ${fuseconfigpath} configure`);
} catch (err) {
return reject(err);
}
}

const fuse = new Fuse(mnt, ops, { debug: true });

fuse.mount(function(err) {
if (err) {
return reject(err);
}
resolve();
});
})
});
}

Expand Down
47 changes: 42 additions & 5 deletions bin/tray.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ const { spawn, fork } = require('node:child_process');
const path = require('node:path');
const Dialog = require('../lib/zenity');
const fs = require('node:fs');
const fuse = require('./fuse.js');
const mkdirp = require('mkdirp');

const shoesTitle = '🝰 dusk / SHOES '
const duskTitle = '🝰 dusk'
Expand Down Expand Up @@ -78,7 +80,7 @@ function _init(rpc, program, config, exitGracefully) {
items: [
NET_STATUS_CONNECTING.item,
{
title: '🔍 Show network info',
title: 'ℹ️ Show about info',
enabled: true,
checked: false
},
Expand Down Expand Up @@ -124,13 +126,14 @@ function _init(rpc, program, config, exitGracefully) {
case 0: // Status indicator
break;
case 1: // Show network info
showNetworkInfo(action);
showAboutInfo(action);
break;
case 2: // Link peer device
manageDeviceLinks(action);
break;
case 3: // Mount virtual folders
toggleMountVirtualFolders(action);
break;
case 4: // Encryption tools dialogs
encryptionUtilities(action);
break;
Expand All @@ -151,8 +154,31 @@ function _init(rpc, program, config, exitGracefully) {
}
});

function showNetworkInfo(action) {
function showAboutInfo(action) {
rpc.invoke('getinfo', [], (err, info) => {
if (err) {
Dialog.info(err, 'Sorry', 'error');
} else {
_showInfo(info);
}
});

function _showInfo(info) {
const dialogOptions = {
width: 300,
};
const dialogTitle = `${duskTitle}`;
const version = `${info.versions.software}:${info.versions.protocol}`

const dialogText = `Version: ${version}
Peers: ${info.peers.length}
anti-©opyright, 2024 tactical chihuahua
licensed under the agpl 3
`;

Dialog.info(dialogText, dialogTitle, 'info', dialogOptions);
}
}

function manageDeviceLinks(actions) {
Expand Down Expand Up @@ -181,8 +207,14 @@ function _init(rpc, program, config, exitGracefully) {
}
}

function toggleMountVirtualFolders(action) {

async function toggleMountVirtualFolders(action) {
try {
mkdirp.sync('/tmp/dusk.vfs');
await fuse('/tmp/dusk.vfs');
} catch (e) {
return Dialog.info(e, 'Sorry', 'error');
}
Dialog.notify('Virtual filesystem mounted.\n/tmp/dusk.vfs');
}

function encryptionUtilities(action) {
Expand Down Expand Up @@ -273,6 +305,11 @@ function _init(rpc, program, config, exitGracefully) {
printColumn: 'ALL'
}
);

if (!newConfig) {
return;
}

let writeOut = '';
let splitConfig = newConfig.split('|');
if (splitConfig.length >= 2) {
Expand Down

0 comments on commit 5546963

Please sign in to comment.