mirror of
https://github.com/Ylianst/MeshAgent
synced 2025-12-21 02:33:24 +00:00
Updated support for KDE/PLasma
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -110,7 +110,7 @@ limitations under the License.
|
|||||||
{
|
{
|
||||||
if (s)
|
if (s)
|
||||||
{
|
{
|
||||||
if (process.platform == 'darwin')
|
if (process.platform == 'darwin' || require('message-box').kdialog)
|
||||||
{
|
{
|
||||||
buttons.unshift('Setup');
|
buttons.unshift('Setup');
|
||||||
}
|
}
|
||||||
@@ -128,7 +128,7 @@ limitations under the License.
|
|||||||
|
|
||||||
if (process.platform != 'darwin')
|
if (process.platform != 'darwin')
|
||||||
{
|
{
|
||||||
if ((require('message-box').zenity == null) || (!require('message-box').zenity.extra))
|
if (!require('message-box').kdialog && (require('message-box').zenity == null || (!require('message-box').zenity.extra)))
|
||||||
{
|
{
|
||||||
console.log('\n' + "This installer cannot run on this system.");
|
console.log('\n' + "This installer cannot run on this system.");
|
||||||
console.log("Try installing/updating Zenity, and run again." + '\n');
|
console.log("Try installing/updating Zenity, and run again." + '\n');
|
||||||
@@ -143,6 +143,7 @@ limitations under the License.
|
|||||||
{
|
{
|
||||||
msg = "Agent: " + (s.isRunning() ? "RUNNING" : "NOT RUNNING") + '\n';
|
msg = "Agent: " + (s.isRunning() ? "RUNNING" : "NOT RUNNING") + '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
msg += ("Device Group: " + msh.MeshName + '\n');
|
msg += ("Device Group: " + msh.MeshName + '\n');
|
||||||
msg += ("Server URL: " + msh.MeshServer + '\n');
|
msg += ("Server URL: " + msh.MeshServer + '\n');
|
||||||
|
|
||||||
@@ -189,7 +190,15 @@ limitations under the License.
|
|||||||
msg = ("Device Group: " + msh.MeshName + '\n');
|
msg = ("Device Group: " + msh.MeshName + '\n');
|
||||||
msg += ("Server URL: " + msh.MeshServer + '\n');
|
msg += ("Server URL: " + msh.MeshServer + '\n');
|
||||||
|
|
||||||
var d = require('message-box').create("MeshCentral Agent", msg, 99999, ["Disconnect"]);
|
if (process.platform != 'darwin')
|
||||||
|
{
|
||||||
|
if(!require('message-box').zenity && require('message-box').kdialog)
|
||||||
|
{
|
||||||
|
msg += ('\nPress OK to Disconnect');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var d = require('message-box').create("MeshCentral Agent", msg, 99999, ['Disconnect']);
|
||||||
d.then(function (v) { process.exit(); }).catch(function (v) { process.exit(); });
|
d.then(function (v) { process.exit(); }).catch(function (v) { process.exit(); });
|
||||||
break;
|
break;
|
||||||
case "Uninstall":
|
case "Uninstall":
|
||||||
|
|||||||
@@ -365,13 +365,13 @@ function linux_messageBox()
|
|||||||
ret._rej('This system cannot display a user dialog box when a user is not logged in');
|
ret._rej('This system cannot display a user dialog box when a user is not logged in');
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
if (Array.isArray(layout) && (!this.zenity || !this.zenity.extra))
|
if (this.zenity)
|
||||||
|
{
|
||||||
|
if (!this.zenity.extra && layout.length > 1)
|
||||||
{
|
{
|
||||||
ret._rej('This system does not support custom button layouts');
|
ret._rej('This system does not support custom button layouts');
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
if (this.zenity)
|
|
||||||
{
|
|
||||||
// GNOME/ZENITY
|
// GNOME/ZENITY
|
||||||
ret._options = { title: title.trim(), caption: caption.trim(), timeout: timeout, layout: layout, zenity: this.zenity };
|
ret._options = { title: title.trim(), caption: caption.trim(), timeout: timeout, layout: layout, zenity: this.zenity };
|
||||||
var parms = ['zenity'];
|
var parms = ['zenity'];
|
||||||
@@ -493,16 +493,58 @@ function linux_messageBox()
|
|||||||
}
|
}
|
||||||
else if(this.kdialog)
|
else if(this.kdialog)
|
||||||
{
|
{
|
||||||
|
var msgparms = ['kdialog', '--title', title];
|
||||||
|
if (Array.isArray(layout))
|
||||||
|
{
|
||||||
|
if (layout.length > 3) { ret._rej('KDialog only supports up to 3 button layouts'); return (ret); }
|
||||||
|
ret.user = true;
|
||||||
|
switch(layout.length)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
case 1:
|
||||||
|
msgparms.push('--msgbox');
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
msgparms.push('--yesno');
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
msgparms.push('--yesnocancel');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
msgparms.push(caption);
|
||||||
|
|
||||||
|
for (var i = 0; i < layout.length; ++i)
|
||||||
|
{
|
||||||
|
switch(i)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
msgparms.push('--yes-label=' + layout[i]);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
msgparms.push('--no-label=' + layout[i]);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
msgparms.push('--cancel-label=' + layout[i]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msgparms.push(layout == null ? '--yesno' : '--msgbox');
|
||||||
|
msgparms.push(caption);
|
||||||
|
}
|
||||||
|
|
||||||
if (process.platform != 'freebsd' && process.env['DISPLAY'])
|
if (process.platform != 'freebsd' && process.env['DISPLAY'])
|
||||||
{
|
{
|
||||||
ret.child = require('child_process').execFile(this.kdialog.path, ['kdialog', '--title', title, layout==null?'--yesno':'--msgbox', caption]);
|
ret.child = require('child_process').execFile(this.kdialog.path, msgparms);
|
||||||
ret.child.promise = ret;
|
ret.child.promise = ret;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var xdg = require('user-sessions').findEnv(uid, 'XDG_RUNTIME_DIR'); if (xdg == null) { xdg = ''; }
|
var xdg = require('user-sessions').findEnv(uid, 'XDG_RUNTIME_DIR'); if (xdg == null) { xdg = ''; }
|
||||||
if (!xinfo || !xinfo.display || !xinfo.xauthority) { ret._rej('Interal Error, could not determine X11/XDG env'); return (ret); }
|
if (!xinfo || !xinfo.display || !xinfo.xauthority) { ret._rej('Interal Error, could not determine X11/XDG env'); return (ret); }
|
||||||
ret.child = require('child_process').execFile(this.kdialog.path, ['kdialog', '--title', title, layout == null ? '--yesno' : '--msgbox', caption], { uid: uid, env: { DISPLAY: xinfo.display, XAUTHORITY: xinfo.xauthority, XDG_RUNTIME_DIR: xdg } });
|
ret.child = require('child_process').execFile(this.kdialog.path, msgparms, { uid: uid, env: { DISPLAY: xinfo.display, XAUTHORITY: xinfo.xauthority, XDG_RUNTIME_DIR: xdg } });
|
||||||
ret.child.promise = ret;
|
ret.child.promise = ret;
|
||||||
}
|
}
|
||||||
ret.child.descriptorMetadata = 'kdialog, message-box'
|
ret.child.descriptorMetadata = 'kdialog, message-box'
|
||||||
@@ -513,11 +555,18 @@ function linux_messageBox()
|
|||||||
}, timeout * 1000, ret.child);
|
}, timeout * 1000, ret.child);
|
||||||
ret.child.stdout.on('data', function (chunk) { });
|
ret.child.stdout.on('data', function (chunk) { });
|
||||||
ret.child.stderr.on('data', function (chunk) { });
|
ret.child.stderr.on('data', function (chunk) { });
|
||||||
|
ret.child.buttons = layout;
|
||||||
ret.child.on('exit', function (code)
|
ret.child.on('exit', function (code)
|
||||||
{
|
{
|
||||||
if (this.timeout)
|
if (this.timeout)
|
||||||
{
|
{
|
||||||
clearTimeout(this.timeout);
|
clearTimeout(this.timeout);
|
||||||
|
if (this.promise.user)
|
||||||
|
{
|
||||||
|
this.promise._res(this.buttons[code]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
switch (code)
|
switch (code)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
@@ -531,6 +580,7 @@ function linux_messageBox()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.promise._rej('timeout');
|
this.promise._rej('timeout');
|
||||||
|
|||||||
Reference in New Issue
Block a user