2011-09-28 09:16:26 -04:00
|
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
2023-07-10 05:53:00 -04:00
|
|
|
|
|
|
|
|
|
import Clutter from 'gi://Clutter';
|
|
|
|
|
import Gio from 'gi://Gio';
|
|
|
|
|
import GLib from 'gi://GLib';
|
|
|
|
|
import GObject from 'gi://GObject';
|
|
|
|
|
import Pango from 'gi://Pango';
|
|
|
|
|
import Shell from 'gi://Shell';
|
|
|
|
|
import St from 'gi://St';
|
|
|
|
|
|
|
|
|
|
import * as Animation from './animation.js';
|
|
|
|
|
import * as CheckBox from './checkBox.js';
|
|
|
|
|
import * as Dialog from './dialog.js';
|
|
|
|
|
import * as Main from './main.js';
|
|
|
|
|
import * as MessageTray from './messageTray.js';
|
|
|
|
|
import * as ModalDialog from './modalDialog.js';
|
|
|
|
|
import * as Params from '../misc/params.js';
|
|
|
|
|
import * as ShellEntry from './shellEntry.js';
|
|
|
|
|
|
|
|
|
|
import {loadInterfaceXML} from '../misc/fileUtils.js';
|
|
|
|
|
import {wiggle} from '../misc/animationUtils.js';
|
|
|
|
|
|
|
|
|
|
const LIST_ITEM_ICON_SIZE = 48;
|
|
|
|
|
const WORK_SPINNER_ICON_SIZE = 16;
|
2011-06-22 16:43:16 -04:00
|
|
|
|
|
2012-11-15 15:57:15 -05:00
|
|
|
|
const REMEMBER_MOUNT_PASSWORD_KEY = 'remember-mount-password';
|
|
|
|
|
|
2011-07-12 11:44:08 -04:00
|
|
|
|
/* ------ Common Utils ------- */
|
2020-01-27 12:43:40 -05:00
|
|
|
|
function _setButtonsForChoices(dialog, oldChoices, choices) {
|
2011-07-12 11:44:08 -04:00
|
|
|
|
let buttons = [];
|
2020-01-27 12:43:40 -05:00
|
|
|
|
let buttonsChanged = oldChoices.length !== choices.length;
|
2011-07-12 11:44:08 -04:00
|
|
|
|
|
|
|
|
|
for (let idx = 0; idx < choices.length; idx++) {
|
|
|
|
|
let button = idx;
|
2020-01-27 12:43:40 -05:00
|
|
|
|
|
2022-01-18 15:02:04 -05:00
|
|
|
|
buttonsChanged ||= oldChoices[idx] !== choices[idx];
|
2020-01-27 12:43:40 -05:00
|
|
|
|
|
2019-02-12 09:02:09 -05:00
|
|
|
|
buttons.unshift({
|
|
|
|
|
label: choices[idx],
|
|
|
|
|
action: () => dialog.emit('response', button),
|
|
|
|
|
});
|
2011-07-12 11:44:08 -04:00
|
|
|
|
}
|
|
|
|
|
|
2020-01-27 12:43:40 -05:00
|
|
|
|
if (buttonsChanged)
|
|
|
|
|
dialog.setButtons(buttons);
|
2011-07-12 11:44:08 -04:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-15 00:03:55 -04:00
|
|
|
|
function _setLabelsForMessage(content, message) {
|
2011-07-12 11:44:08 -04:00
|
|
|
|
let labels = message.split('\n');
|
|
|
|
|
|
2017-07-15 00:03:55 -04:00
|
|
|
|
content.title = labels.shift();
|
2020-01-13 08:04:40 -05:00
|
|
|
|
content.description = labels.join('\n');
|
2011-07-12 11:44:08 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------- */
|
|
|
|
|
|
2023-07-10 05:53:00 -04:00
|
|
|
|
export class ShellMountOperation {
|
2017-10-30 21:19:44 -04:00
|
|
|
|
constructor(source, params) {
|
2023-08-06 18:40:20 -04:00
|
|
|
|
params = Params.parse(params, {existingDialog: null});
|
2011-07-12 11:29:49 -04:00
|
|
|
|
|
2011-07-12 11:44:08 -04:00
|
|
|
|
this._dialog = null;
|
2012-06-19 20:22:26 -04:00
|
|
|
|
this._existingDialog = params.existingDialog;
|
2011-06-22 16:43:16 -04:00
|
|
|
|
this._processesDialog = null;
|
|
|
|
|
|
|
|
|
|
this.mountOp = new Shell.MountOperation();
|
|
|
|
|
|
|
|
|
|
this.mountOp.connect('ask-question',
|
2023-08-06 19:45:22 -04:00
|
|
|
|
this._onAskQuestion.bind(this));
|
2011-06-22 16:43:16 -04:00
|
|
|
|
this.mountOp.connect('ask-password',
|
2023-08-06 19:45:22 -04:00
|
|
|
|
this._onAskPassword.bind(this));
|
2011-06-22 16:43:16 -04:00
|
|
|
|
this.mountOp.connect('show-processes-2',
|
2023-08-06 19:45:22 -04:00
|
|
|
|
this._onShowProcesses2.bind(this));
|
2011-06-22 16:43:16 -04:00
|
|
|
|
this.mountOp.connect('aborted',
|
2023-08-06 19:45:22 -04:00
|
|
|
|
this.close.bind(this));
|
2012-07-09 21:58:12 -04:00
|
|
|
|
this.mountOp.connect('show-unmount-progress',
|
2023-08-06 19:45:22 -04:00
|
|
|
|
this._onShowUnmountProgress.bind(this));
|
2017-10-30 21:19:44 -04:00
|
|
|
|
}
|
2011-06-22 16:43:16 -04:00
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
|
_closeExistingDialog() {
|
2012-06-19 20:22:26 -04:00
|
|
|
|
if (!this._existingDialog)
|
|
|
|
|
return;
|
|
|
|
|
|
2012-06-20 16:12:40 -04:00
|
|
|
|
this._existingDialog.close();
|
2012-06-19 20:22:26 -04:00
|
|
|
|
this._existingDialog = null;
|
2017-10-30 21:19:44 -04:00
|
|
|
|
}
|
2012-06-19 20:22:26 -04:00
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
|
_onAskQuestion(op, message, choices) {
|
2012-06-19 20:22:26 -04:00
|
|
|
|
this._closeExistingDialog();
|
2020-01-13 07:39:41 -05:00
|
|
|
|
this._dialog = new ShellMountQuestionDialog();
|
2011-07-12 11:44:08 -04:00
|
|
|
|
|
2021-08-15 18:36:59 -04:00
|
|
|
|
this._dialog.connectObject('response',
|
2017-10-30 20:38:18 -04:00
|
|
|
|
(object, choice) => {
|
2012-06-20 16:14:02 -04:00
|
|
|
|
this.mountOp.set_choice(choice);
|
|
|
|
|
this.mountOp.reply(Gio.MountOperationResult.HANDLED);
|
2011-07-12 11:44:08 -04:00
|
|
|
|
|
2012-06-20 16:14:02 -04:00
|
|
|
|
this.close();
|
2021-08-15 18:36:59 -04:00
|
|
|
|
}, this);
|
2011-07-12 11:44:08 -04:00
|
|
|
|
|
|
|
|
|
this._dialog.update(message, choices);
|
2012-06-20 16:12:40 -04:00
|
|
|
|
this._dialog.open();
|
2017-10-30 21:19:44 -04:00
|
|
|
|
}
|
2011-06-22 16:43:16 -04:00
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
|
_onAskPassword(op, message, defaultUser, defaultDomain, flags) {
|
2012-06-19 20:22:26 -04:00
|
|
|
|
if (this._existingDialog) {
|
|
|
|
|
this._dialog = this._existingDialog;
|
|
|
|
|
this._dialog.reaskPassword();
|
|
|
|
|
} else {
|
2020-01-13 07:39:41 -05:00
|
|
|
|
this._dialog = new ShellMountPasswordDialog(message, flags);
|
2012-06-19 20:22:26 -04:00
|
|
|
|
}
|
2012-06-19 18:12:11 -04:00
|
|
|
|
|
2021-08-15 18:36:59 -04:00
|
|
|
|
this._dialog.connectObject('response',
|
2019-04-07 17:35:07 -04:00
|
|
|
|
(object, choice, password, remember, hiddenVolume, systemVolume, pim) => {
|
2023-08-06 20:51:19 -04:00
|
|
|
|
if (choice === -1) {
|
2012-06-19 18:12:11 -04:00
|
|
|
|
this.mountOp.reply(Gio.MountOperationResult.ABORTED);
|
|
|
|
|
} else {
|
|
|
|
|
if (remember)
|
|
|
|
|
this.mountOp.set_password_save(Gio.PasswordSave.PERMANENTLY);
|
|
|
|
|
else
|
|
|
|
|
this.mountOp.set_password_save(Gio.PasswordSave.NEVER);
|
|
|
|
|
|
|
|
|
|
this.mountOp.set_password(password);
|
2019-04-07 17:35:07 -04:00
|
|
|
|
this.mountOp.set_is_tcrypt_hidden_volume(hiddenVolume);
|
|
|
|
|
this.mountOp.set_is_tcrypt_system_volume(systemVolume);
|
|
|
|
|
this.mountOp.set_pim(pim);
|
2012-06-19 18:12:11 -04:00
|
|
|
|
this.mountOp.reply(Gio.MountOperationResult.HANDLED);
|
|
|
|
|
}
|
2021-08-15 18:36:59 -04:00
|
|
|
|
}, this);
|
2012-06-20 16:12:40 -04:00
|
|
|
|
this._dialog.open();
|
2017-10-30 21:19:44 -04:00
|
|
|
|
}
|
2011-06-22 16:43:16 -04:00
|
|
|
|
|
2019-01-31 09:08:10 -05:00
|
|
|
|
close(_op) {
|
2012-06-19 20:22:26 -04:00
|
|
|
|
this._closeExistingDialog();
|
|
|
|
|
this._processesDialog = null;
|
2011-07-12 11:44:08 -04:00
|
|
|
|
|
2012-06-19 16:41:39 -04:00
|
|
|
|
if (this._dialog) {
|
2012-06-20 16:12:40 -04:00
|
|
|
|
this._dialog.close();
|
2012-06-19 16:41:39 -04:00
|
|
|
|
this._dialog = null;
|
|
|
|
|
}
|
2012-07-09 21:58:12 -04:00
|
|
|
|
|
|
|
|
|
if (this._notifier) {
|
|
|
|
|
this._notifier.done();
|
|
|
|
|
this._notifier = null;
|
|
|
|
|
}
|
2017-10-30 21:19:44 -04:00
|
|
|
|
}
|
2011-06-22 16:43:16 -04:00
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
|
_onShowProcesses2(op) {
|
2012-06-19 20:22:26 -04:00
|
|
|
|
this._closeExistingDialog();
|
|
|
|
|
|
2011-06-22 16:43:16 -04:00
|
|
|
|
let processes = op.get_show_processes_pids();
|
|
|
|
|
let choices = op.get_show_processes_choices();
|
|
|
|
|
let message = op.get_show_processes_message();
|
|
|
|
|
|
|
|
|
|
if (!this._processesDialog) {
|
2020-01-13 07:39:41 -05:00
|
|
|
|
this._processesDialog = new ShellProcessesDialog();
|
2011-07-12 11:44:08 -04:00
|
|
|
|
this._dialog = this._processesDialog;
|
|
|
|
|
|
2021-08-15 18:36:59 -04:00
|
|
|
|
this._processesDialog.connectObject('response',
|
2017-10-30 20:38:18 -04:00
|
|
|
|
(object, choice) => {
|
2023-08-06 20:51:19 -04:00
|
|
|
|
if (choice === -1) {
|
2012-06-20 16:14:02 -04:00
|
|
|
|
this.mountOp.reply(Gio.MountOperationResult.ABORTED);
|
|
|
|
|
} else {
|
|
|
|
|
this.mountOp.set_choice(choice);
|
|
|
|
|
this.mountOp.reply(Gio.MountOperationResult.HANDLED);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.close();
|
2021-08-15 18:36:59 -04:00
|
|
|
|
}, this);
|
2012-06-20 16:12:40 -04:00
|
|
|
|
this._processesDialog.open();
|
2011-06-22 16:43:16 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this._processesDialog.update(message, processes, choices);
|
2017-10-30 21:19:44 -04:00
|
|
|
|
}
|
2012-06-19 20:22:26 -04:00
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
|
_onShowUnmountProgress(op, message, timeLeft, bytesLeft) {
|
2012-07-09 21:58:12 -04:00
|
|
|
|
if (!this._notifier)
|
|
|
|
|
this._notifier = new ShellUnmountNotifier();
|
2019-09-12 11:26:08 -04:00
|
|
|
|
|
2023-08-06 20:51:19 -04:00
|
|
|
|
if (bytesLeft === 0)
|
2012-07-09 21:58:12 -04:00
|
|
|
|
this._notifier.done(message);
|
|
|
|
|
else
|
|
|
|
|
this._notifier.show(message);
|
2017-10-30 21:19:44 -04:00
|
|
|
|
}
|
2012-07-09 21:58:12 -04:00
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
|
borrowDialog() {
|
2021-08-15 18:36:59 -04:00
|
|
|
|
this._dialog?.disconnectObject(this);
|
2012-06-19 20:22:26 -04:00
|
|
|
|
return this._dialog;
|
|
|
|
|
}
|
2023-07-10 05:53:00 -04:00
|
|
|
|
}
|
2012-07-09 21:58:12 -04:00
|
|
|
|
|
2023-07-10 05:53:00 -04:00
|
|
|
|
const ShellUnmountNotifier = GObject.registerClass(
|
2019-05-13 17:32:31 -04:00
|
|
|
|
class ShellUnmountNotifier extends MessageTray.Source {
|
|
|
|
|
_init() {
|
|
|
|
|
super._init('', 'media-removable');
|
2012-07-09 21:58:12 -04:00
|
|
|
|
|
|
|
|
|
this._notification = null;
|
|
|
|
|
Main.messageTray.add(this);
|
2017-10-30 21:19:44 -04:00
|
|
|
|
}
|
2012-07-09 21:58:12 -04:00
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
|
show(message) {
|
2012-07-09 21:58:12 -04:00
|
|
|
|
let [header, text] = message.split('\n', 2);
|
|
|
|
|
|
|
|
|
|
if (!this._notification) {
|
|
|
|
|
this._notification = new MessageTray.Notification(this, header, text);
|
|
|
|
|
this._notification.setTransient(true);
|
|
|
|
|
this._notification.setUrgency(MessageTray.Urgency.CRITICAL);
|
|
|
|
|
} else {
|
|
|
|
|
this._notification.update(header, text);
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-13 17:32:31 -04:00
|
|
|
|
this.showNotification(this._notification);
|
2017-10-30 21:19:44 -04:00
|
|
|
|
}
|
2012-07-09 21:58:12 -04:00
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
|
done(message) {
|
2012-07-09 21:58:12 -04:00
|
|
|
|
if (this._notification) {
|
|
|
|
|
this._notification.destroy();
|
|
|
|
|
this._notification = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (message) {
|
|
|
|
|
let notification = new MessageTray.Notification(this, message, null);
|
|
|
|
|
notification.setTransient(true);
|
|
|
|
|
|
2019-05-13 17:32:31 -04:00
|
|
|
|
this.showNotification(notification);
|
2012-07-09 21:58:12 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-05-13 17:32:31 -04:00
|
|
|
|
});
|
2011-07-12 11:44:08 -04:00
|
|
|
|
|
2023-07-10 05:53:00 -04:00
|
|
|
|
const ShellMountQuestionDialog = GObject.registerClass({
|
2023-08-06 18:40:20 -04:00
|
|
|
|
Signals: {'response': {param_types: [GObject.TYPE_INT]}},
|
2019-05-23 16:45:44 -04:00
|
|
|
|
}, class ShellMountQuestionDialog extends ModalDialog.ModalDialog {
|
2020-01-13 07:39:41 -05:00
|
|
|
|
_init() {
|
2023-08-06 18:40:20 -04:00
|
|
|
|
super._init({styleClass: 'mount-question-dialog'});
|
2011-07-12 11:44:08 -04:00
|
|
|
|
|
2020-01-27 12:43:40 -05:00
|
|
|
|
this._oldChoices = [];
|
|
|
|
|
|
2020-01-13 07:39:41 -05:00
|
|
|
|
this._content = new Dialog.MessageDialogContent();
|
2019-10-21 14:44:00 -04:00
|
|
|
|
this.contentLayout.add_child(this._content);
|
2017-10-30 21:19:44 -04:00
|
|
|
|
}
|
2011-07-12 11:44:08 -04:00
|
|
|
|
|
2020-01-27 12:46:17 -05:00
|
|
|
|
vfunc_key_release_event(event) {
|
2023-08-08 12:14:04 -04:00
|
|
|
|
if (event.get_key_symbol() === Clutter.KEY_Escape) {
|
2020-01-27 12:46:17 -05:00
|
|
|
|
this.emit('response', -1);
|
|
|
|
|
return Clutter.EVENT_STOP;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Clutter.EVENT_PROPAGATE;
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
|
update(message, choices) {
|
2017-07-15 00:03:55 -04:00
|
|
|
|
_setLabelsForMessage(this._content, message);
|
2020-01-27 12:43:40 -05:00
|
|
|
|
_setButtonsForChoices(this, this._oldChoices, choices);
|
|
|
|
|
this._oldChoices = choices;
|
2011-07-12 11:44:08 -04:00
|
|
|
|
}
|
2019-05-23 16:45:44 -04:00
|
|
|
|
});
|
|
|
|
|
|
2023-07-10 05:53:00 -04:00
|
|
|
|
const ShellMountPasswordDialog = GObject.registerClass({
|
2020-03-27 09:18:34 -04:00
|
|
|
|
Signals: {
|
|
|
|
|
'response': {
|
|
|
|
|
param_types: [
|
|
|
|
|
GObject.TYPE_INT,
|
|
|
|
|
GObject.TYPE_STRING,
|
|
|
|
|
GObject.TYPE_BOOLEAN,
|
|
|
|
|
GObject.TYPE_BOOLEAN,
|
|
|
|
|
GObject.TYPE_BOOLEAN,
|
|
|
|
|
GObject.TYPE_UINT,
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
2019-05-23 16:45:44 -04:00
|
|
|
|
}, class ShellMountPasswordDialog extends ModalDialog.ModalDialog {
|
2020-01-13 07:39:41 -05:00
|
|
|
|
_init(message, flags) {
|
2011-07-12 11:29:49 -04:00
|
|
|
|
let strings = message.split('\n');
|
2017-07-15 00:03:55 -04:00
|
|
|
|
let title = strings.shift() || null;
|
2020-01-13 08:04:40 -05:00
|
|
|
|
let description = strings.shift() || null;
|
2023-08-06 18:40:20 -04:00
|
|
|
|
super._init({styleClass: 'prompt-dialog'});
|
2012-06-19 18:12:11 -04:00
|
|
|
|
|
2019-04-07 17:35:07 -04:00
|
|
|
|
let disksApp = Shell.AppSystem.get_default().lookup_app('org.gnome.DiskUtility.desktop');
|
|
|
|
|
|
2023-08-06 18:40:20 -04:00
|
|
|
|
let content = new Dialog.MessageDialogContent({title, description});
|
2011-07-12 11:29:49 -04:00
|
|
|
|
|
2023-08-06 18:40:20 -04:00
|
|
|
|
let passwordGridLayout = new Clutter.GridLayout({orientation: Clutter.Orientation.VERTICAL});
|
2019-12-08 07:08:13 -05:00
|
|
|
|
let passwordGrid = new St.Widget({
|
|
|
|
|
style_class: 'prompt-dialog-password-grid',
|
|
|
|
|
layout_manager: passwordGridLayout,
|
|
|
|
|
});
|
|
|
|
|
passwordGridLayout.hookup_style(passwordGrid);
|
2011-07-12 11:29:49 -04:00
|
|
|
|
|
2019-12-08 07:08:13 -05:00
|
|
|
|
let rtl = passwordGrid.get_text_direction() === Clutter.TextDirection.RTL;
|
|
|
|
|
let curGridRow = 0;
|
2019-04-07 17:35:07 -04:00
|
|
|
|
|
2019-12-08 07:08:13 -05:00
|
|
|
|
if (flags & Gio.AskPasswordFlags.TCRYPT) {
|
2023-06-08 00:53:07 -04:00
|
|
|
|
this._hiddenVolume = new CheckBox.CheckBox(_('Hidden Volume'));
|
2020-01-13 07:44:17 -05:00
|
|
|
|
content.add_child(this._hiddenVolume);
|
2019-04-07 17:35:07 -04:00
|
|
|
|
|
2023-06-08 00:53:07 -04:00
|
|
|
|
this._systemVolume = new CheckBox.CheckBox(_('Windows System Volume'));
|
2020-01-13 07:44:17 -05:00
|
|
|
|
content.add_child(this._systemVolume);
|
2019-04-07 17:35:07 -04:00
|
|
|
|
|
2023-06-08 00:53:07 -04:00
|
|
|
|
this._keyfilesCheckbox = new CheckBox.CheckBox(_('Uses Keyfiles'));
|
|
|
|
|
this._keyfilesCheckbox.connect('clicked', this._onKeyfilesCheckboxClicked.bind(this));
|
2020-01-13 07:44:17 -05:00
|
|
|
|
content.add_child(this._keyfilesCheckbox);
|
2019-04-07 17:35:07 -04:00
|
|
|
|
|
2023-06-08 00:53:07 -04:00
|
|
|
|
this._keyfilesLabel = new St.Label({visible: false});
|
2023-02-02 02:26:20 -05:00
|
|
|
|
if (disksApp) {
|
|
|
|
|
this._keyfilesLabel.clutter_text.set_markup(
|
|
|
|
|
/* Translators: %s is the Disks application */
|
|
|
|
|
_('To unlock a volume that uses keyfiles, use the <i>%s</i> utility instead.')
|
|
|
|
|
.format(disksApp.get_name()));
|
|
|
|
|
} else {
|
|
|
|
|
this._keyfilesLabel.clutter_text.set_markup(
|
|
|
|
|
_('You need an external utility like <i>Disks</i> to unlock a volume that uses keyfiles.'));
|
|
|
|
|
}
|
2019-04-07 17:35:07 -04:00
|
|
|
|
this._keyfilesLabel.clutter_text.ellipsize = Pango.EllipsizeMode.NONE;
|
|
|
|
|
this._keyfilesLabel.clutter_text.line_wrap = true;
|
2020-01-13 07:44:17 -05:00
|
|
|
|
content.add_child(this._keyfilesLabel);
|
2019-04-07 17:35:07 -04:00
|
|
|
|
|
2019-12-12 04:32:53 -05:00
|
|
|
|
this._pimEntry = new St.PasswordEntry({
|
|
|
|
|
style_class: 'prompt-dialog-password-entry',
|
2020-02-14 16:11:27 -05:00
|
|
|
|
hint_text: _('PIM Number'),
|
2019-12-12 04:32:53 -05:00
|
|
|
|
can_focus: true,
|
|
|
|
|
x_expand: true,
|
|
|
|
|
});
|
2019-04-07 17:35:07 -04:00
|
|
|
|
this._pimEntry.clutter_text.connect('activate', this._onEntryActivate.bind(this));
|
2019-12-12 04:32:53 -05:00
|
|
|
|
ShellEntry.addContextMenu(this._pimEntry);
|
2019-04-07 17:35:07 -04:00
|
|
|
|
|
2019-12-08 07:08:13 -05:00
|
|
|
|
if (rtl)
|
|
|
|
|
passwordGridLayout.attach(this._pimEntry, 1, curGridRow, 1, 1);
|
|
|
|
|
else
|
|
|
|
|
passwordGridLayout.attach(this._pimEntry, 0, curGridRow, 1, 1);
|
|
|
|
|
curGridRow += 1;
|
2019-04-07 17:35:07 -04:00
|
|
|
|
} else {
|
|
|
|
|
this._hiddenVolume = null;
|
|
|
|
|
this._systemVolume = null;
|
|
|
|
|
this._pimEntry = null;
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-12 04:32:53 -05:00
|
|
|
|
this._passwordEntry = new St.PasswordEntry({
|
|
|
|
|
style_class: 'prompt-dialog-password-entry',
|
2020-02-14 16:11:27 -05:00
|
|
|
|
hint_text: _('Password'),
|
2019-12-12 04:32:53 -05:00
|
|
|
|
can_focus: true,
|
|
|
|
|
x_expand: true,
|
|
|
|
|
});
|
2017-12-01 19:27:35 -05:00
|
|
|
|
this._passwordEntry.clutter_text.connect('activate', this._onEntryActivate.bind(this));
|
2012-06-19 18:12:11 -04:00
|
|
|
|
this.setInitialKeyFocus(this._passwordEntry);
|
2019-12-08 07:08:13 -05:00
|
|
|
|
ShellEntry.addContextMenu(this._passwordEntry);
|
|
|
|
|
|
2019-11-18 15:18:29 -05:00
|
|
|
|
this._workSpinner = new Animation.Spinner(WORK_SPINNER_ICON_SIZE, {
|
|
|
|
|
animate: true,
|
|
|
|
|
});
|
2011-07-12 11:29:49 -04:00
|
|
|
|
|
2019-04-07 17:33:34 -04:00
|
|
|
|
if (rtl) {
|
2019-12-08 07:08:13 -05:00
|
|
|
|
passwordGridLayout.attach(this._workSpinner, 0, curGridRow, 1, 1);
|
|
|
|
|
passwordGridLayout.attach(this._passwordEntry, 1, curGridRow, 1, 1);
|
2019-04-07 17:33:34 -04:00
|
|
|
|
} else {
|
2019-12-08 07:08:13 -05:00
|
|
|
|
passwordGridLayout.attach(this._passwordEntry, 0, curGridRow, 1, 1);
|
|
|
|
|
passwordGridLayout.attach(this._workSpinner, 1, curGridRow, 1, 1);
|
2019-04-07 17:33:34 -04:00
|
|
|
|
}
|
2019-12-08 07:08:13 -05:00
|
|
|
|
curGridRow += 1;
|
|
|
|
|
|
2023-08-06 18:40:20 -04:00
|
|
|
|
let warningBox = new St.BoxLayout({vertical: true});
|
2019-04-07 17:33:34 -04:00
|
|
|
|
|
2019-12-08 07:08:13 -05:00
|
|
|
|
let capsLockWarning = new ShellEntry.CapsLockWarning();
|
|
|
|
|
warningBox.add_child(capsLockWarning);
|
2019-04-07 17:33:34 -04:00
|
|
|
|
|
2019-12-08 07:08:13 -05:00
|
|
|
|
this._errorMessageLabel = new St.Label({
|
|
|
|
|
style_class: 'prompt-dialog-error-label',
|
|
|
|
|
opacity: 0,
|
|
|
|
|
});
|
2012-06-19 20:22:26 -04:00
|
|
|
|
this._errorMessageLabel.clutter_text.ellipsize = Pango.EllipsizeMode.NONE;
|
|
|
|
|
this._errorMessageLabel.clutter_text.line_wrap = true;
|
2019-12-08 07:08:13 -05:00
|
|
|
|
warningBox.add_child(this._errorMessageLabel);
|
|
|
|
|
|
|
|
|
|
passwordGridLayout.attach(warningBox, 0, curGridRow, 2, 1);
|
|
|
|
|
|
|
|
|
|
content.add_child(passwordGrid);
|
2011-07-12 11:29:49 -04:00
|
|
|
|
|
2012-06-20 17:23:34 -04:00
|
|
|
|
if (flags & Gio.AskPasswordFlags.SAVING_SUPPORTED) {
|
2023-06-08 00:53:07 -04:00
|
|
|
|
this._rememberChoice = new CheckBox.CheckBox(_('Remember Password'));
|
2019-07-16 05:24:13 -04:00
|
|
|
|
this._rememberChoice.checked =
|
2012-11-15 15:57:15 -05:00
|
|
|
|
global.settings.get_boolean(REMEMBER_MOUNT_PASSWORD_KEY);
|
2020-01-13 07:44:17 -05:00
|
|
|
|
content.add_child(this._rememberChoice);
|
2012-06-20 17:23:34 -04:00
|
|
|
|
} else {
|
|
|
|
|
this._rememberChoice = null;
|
|
|
|
|
}
|
2011-07-12 11:29:49 -04:00
|
|
|
|
|
2019-12-08 07:08:13 -05:00
|
|
|
|
this.contentLayout.add_child(content);
|
|
|
|
|
|
2019-02-12 09:02:09 -05:00
|
|
|
|
this._defaultButtons = [{
|
2023-06-08 00:53:07 -04:00
|
|
|
|
label: _('Cancel'),
|
2019-02-12 09:02:09 -05:00
|
|
|
|
action: this._onCancelButton.bind(this),
|
2019-11-05 14:37:28 -05:00
|
|
|
|
key: Clutter.KEY_Escape,
|
2019-02-12 09:02:09 -05:00
|
|
|
|
}, {
|
2023-06-08 00:53:07 -04:00
|
|
|
|
label: _('Unlock'),
|
2019-02-12 09:02:09 -05:00
|
|
|
|
action: this._onUnlockButton.bind(this),
|
|
|
|
|
default: true,
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
this._usesKeyfilesButtons = [{
|
2023-06-08 00:53:07 -04:00
|
|
|
|
label: _('Cancel'),
|
2019-02-12 09:02:09 -05:00
|
|
|
|
action: this._onCancelButton.bind(this),
|
2019-11-05 14:37:28 -05:00
|
|
|
|
key: Clutter.KEY_Escape,
|
2019-02-12 09:02:09 -05:00
|
|
|
|
}];
|
2019-04-07 17:35:07 -04:00
|
|
|
|
|
2023-02-02 02:26:20 -05:00
|
|
|
|
if (disksApp) {
|
|
|
|
|
this._usesKeyfilesButtons.push({
|
|
|
|
|
/* Translators: %s is the Disks application */
|
|
|
|
|
label: _('Open %s').format(disksApp.get_name()),
|
|
|
|
|
action: () => {
|
|
|
|
|
disksApp.activate();
|
|
|
|
|
this._onCancelButton();
|
|
|
|
|
},
|
|
|
|
|
default: true,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-07 17:35:07 -04:00
|
|
|
|
this.setButtons(this._defaultButtons);
|
2017-10-30 21:19:44 -04:00
|
|
|
|
}
|
2011-07-12 11:29:49 -04:00
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
|
reaskPassword() {
|
2019-04-06 11:39:29 -04:00
|
|
|
|
this._workSpinner.stop();
|
2019-12-08 07:08:13 -05:00
|
|
|
|
this._passwordEntry.set_text('');
|
|
|
|
|
this._errorMessageLabel.text = _('Sorry, that didn’t work. Please try again.');
|
|
|
|
|
this._errorMessageLabel.opacity = 255;
|
2020-01-21 04:39:33 -05:00
|
|
|
|
|
2023-07-10 00:58:21 -04:00
|
|
|
|
wiggle(this._passwordEntry);
|
2017-10-30 21:19:44 -04:00
|
|
|
|
}
|
2012-06-19 20:22:26 -04:00
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
|
_onCancelButton() {
|
2019-05-23 16:45:44 -04:00
|
|
|
|
this.emit('response', -1, '', false, false, false, 0);
|
2017-10-30 21:19:44 -04:00
|
|
|
|
}
|
2012-06-19 18:12:11 -04:00
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
|
_onUnlockButton() {
|
2012-06-19 18:12:11 -04:00
|
|
|
|
this._onEntryActivate();
|
2017-10-30 21:19:44 -04:00
|
|
|
|
}
|
2011-07-12 11:29:49 -04:00
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
|
_onEntryActivate() {
|
2019-04-07 17:35:07 -04:00
|
|
|
|
let pim = 0;
|
2019-12-08 07:08:13 -05:00
|
|
|
|
if (this._pimEntry !== null) {
|
2019-04-07 17:35:07 -04:00
|
|
|
|
pim = this._pimEntry.get_text();
|
2019-12-08 07:08:13 -05:00
|
|
|
|
|
|
|
|
|
if (isNaN(pim)) {
|
|
|
|
|
this._pimEntry.set_text('');
|
|
|
|
|
this._errorMessageLabel.text = _('The PIM must be a number or empty.');
|
|
|
|
|
this._errorMessageLabel.opacity = 255;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this._errorMessageLabel.opacity = 0;
|
2019-04-07 17:35:07 -04:00
|
|
|
|
}
|
|
|
|
|
|
2012-11-15 15:57:15 -05:00
|
|
|
|
global.settings.set_boolean(REMEMBER_MOUNT_PASSWORD_KEY,
|
2019-07-16 05:24:13 -04:00
|
|
|
|
this._rememberChoice && this._rememberChoice.checked);
|
2019-04-06 11:39:29 -04:00
|
|
|
|
|
|
|
|
|
this._workSpinner.play();
|
2012-06-19 18:12:11 -04:00
|
|
|
|
this.emit('response', 1,
|
|
|
|
|
this._passwordEntry.get_text(),
|
2012-06-20 17:23:34 -04:00
|
|
|
|
this._rememberChoice &&
|
2019-07-16 05:24:13 -04:00
|
|
|
|
this._rememberChoice.checked,
|
2019-04-07 17:35:07 -04:00
|
|
|
|
this._hiddenVolume &&
|
2019-07-16 05:24:13 -04:00
|
|
|
|
this._hiddenVolume.checked,
|
2019-04-07 17:35:07 -04:00
|
|
|
|
this._systemVolume &&
|
2019-07-16 05:24:13 -04:00
|
|
|
|
this._systemVolume.checked,
|
2019-05-23 16:45:44 -04:00
|
|
|
|
parseInt(pim));
|
2019-04-07 17:35:07 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_onKeyfilesCheckboxClicked() {
|
2019-07-16 05:24:13 -04:00
|
|
|
|
let useKeyfiles = this._keyfilesCheckbox.checked;
|
2019-04-07 17:35:07 -04:00
|
|
|
|
this._passwordEntry.reactive = !useKeyfiles;
|
|
|
|
|
this._passwordEntry.can_focus = !useKeyfiles;
|
|
|
|
|
this._pimEntry.reactive = !useKeyfiles;
|
|
|
|
|
this._pimEntry.can_focus = !useKeyfiles;
|
2019-07-16 05:24:13 -04:00
|
|
|
|
this._rememberChoice.reactive = !useKeyfiles;
|
|
|
|
|
this._rememberChoice.can_focus = !useKeyfiles;
|
2019-04-07 17:35:07 -04:00
|
|
|
|
this._keyfilesLabel.visible = useKeyfiles;
|
|
|
|
|
this.setButtons(useKeyfiles ? this._usesKeyfilesButtons : this._defaultButtons);
|
|
|
|
|
}
|
2019-05-23 16:45:44 -04:00
|
|
|
|
});
|
2011-06-22 16:43:16 -04:00
|
|
|
|
|
2023-07-10 05:53:00 -04:00
|
|
|
|
const ShellProcessesDialog = GObject.registerClass({
|
2023-08-06 18:40:20 -04:00
|
|
|
|
Signals: {'response': {param_types: [GObject.TYPE_INT]}},
|
2019-05-23 16:45:44 -04:00
|
|
|
|
}, class ShellProcessesDialog extends ModalDialog.ModalDialog {
|
2020-01-13 07:39:41 -05:00
|
|
|
|
_init() {
|
2023-08-06 18:40:20 -04:00
|
|
|
|
super._init({styleClass: 'processes-dialog'});
|
2011-06-22 16:43:16 -04:00
|
|
|
|
|
2020-01-27 12:43:40 -05:00
|
|
|
|
this._oldChoices = [];
|
|
|
|
|
|
2020-01-13 07:39:41 -05:00
|
|
|
|
this._content = new Dialog.MessageDialogContent();
|
2019-10-21 14:44:00 -04:00
|
|
|
|
this.contentLayout.add_child(this._content);
|
2011-06-22 16:43:16 -04:00
|
|
|
|
|
2020-01-27 12:50:26 -05:00
|
|
|
|
this._applicationSection = new Dialog.ListSection();
|
|
|
|
|
this._applicationSection.hide();
|
|
|
|
|
this.contentLayout.add_child(this._applicationSection);
|
|
|
|
|
}
|
2011-06-22 16:43:16 -04:00
|
|
|
|
|
2020-01-27 12:46:17 -05:00
|
|
|
|
vfunc_key_release_event(event) {
|
2023-08-08 12:14:04 -04:00
|
|
|
|
if (event.get_key_symbol() === Clutter.KEY_Escape) {
|
2020-01-27 12:46:17 -05:00
|
|
|
|
this.emit('response', -1);
|
|
|
|
|
return Clutter.EVENT_STOP;
|
|
|
|
|
}
|
2017-10-30 20:38:18 -04:00
|
|
|
|
|
2020-01-27 12:46:17 -05:00
|
|
|
|
return Clutter.EVENT_PROPAGATE;
|
2017-10-30 21:19:44 -04:00
|
|
|
|
}
|
2011-06-22 16:43:16 -04:00
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
|
_setAppsForPids(pids) {
|
2011-06-22 16:43:16 -04:00
|
|
|
|
// remove all the items
|
2020-01-27 12:50:26 -05:00
|
|
|
|
this._applicationSection.list.destroy_all_children();
|
2011-06-22 16:43:16 -04:00
|
|
|
|
|
2017-10-30 20:38:18 -04:00
|
|
|
|
pids.forEach(pid => {
|
2011-06-22 16:43:16 -04:00
|
|
|
|
let tracker = Shell.WindowTracker.get_default();
|
|
|
|
|
let app = tracker.get_app_from_pid(pid);
|
|
|
|
|
|
|
|
|
|
if (!app)
|
|
|
|
|
return;
|
|
|
|
|
|
2020-01-27 12:50:26 -05:00
|
|
|
|
let listItem = new Dialog.ListSectionItem({
|
|
|
|
|
icon_actor: app.create_icon_texture(LIST_ITEM_ICON_SIZE),
|
|
|
|
|
title: app.get_name(),
|
2017-10-30 20:38:18 -04:00
|
|
|
|
});
|
2020-01-27 12:50:26 -05:00
|
|
|
|
this._applicationSection.list.add_child(listItem);
|
2017-10-30 20:38:18 -04:00
|
|
|
|
});
|
2020-01-27 12:50:26 -05:00
|
|
|
|
|
|
|
|
|
this._applicationSection.visible =
|
|
|
|
|
this._applicationSection.list.get_n_children() > 0;
|
2017-10-30 21:19:44 -04:00
|
|
|
|
}
|
2011-06-22 16:43:16 -04:00
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
|
update(message, processes, choices) {
|
2011-06-22 16:43:16 -04:00
|
|
|
|
this._setAppsForPids(processes);
|
2017-07-15 00:03:55 -04:00
|
|
|
|
_setLabelsForMessage(this._content, message);
|
2020-01-27 12:43:40 -05:00
|
|
|
|
_setButtonsForChoices(this, this._oldChoices, choices);
|
|
|
|
|
this._oldChoices = choices;
|
2011-06-22 16:43:16 -04:00
|
|
|
|
}
|
2019-05-23 16:45:44 -04:00
|
|
|
|
});
|
2012-06-20 17:23:34 -04:00
|
|
|
|
|
2018-09-05 20:55:20 -04:00
|
|
|
|
const GnomeShellMountOpIface = loadInterfaceXML('org.Gtk.MountOperationHandler');
|
2012-06-20 17:23:34 -04:00
|
|
|
|
|
2023-07-30 08:56:59 -04:00
|
|
|
|
/** @enum {number} */
|
2023-07-10 05:53:00 -04:00
|
|
|
|
const ShellMountOperationType = {
|
2012-06-20 17:23:34 -04:00
|
|
|
|
NONE: 0,
|
|
|
|
|
ASK_PASSWORD: 1,
|
|
|
|
|
ASK_QUESTION: 2,
|
2019-08-20 17:43:54 -04:00
|
|
|
|
SHOW_PROCESSES: 3,
|
2012-06-20 17:23:34 -04:00
|
|
|
|
};
|
|
|
|
|
|
2023-07-10 05:53:00 -04:00
|
|
|
|
export class GnomeShellMountOpHandler {
|
2017-10-30 21:19:44 -04:00
|
|
|
|
constructor() {
|
2012-06-20 17:23:34 -04:00
|
|
|
|
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(GnomeShellMountOpIface, this);
|
|
|
|
|
this._dbusImpl.export(Gio.DBus.session, '/org/gtk/MountOperationHandler');
|
2023-08-06 19:45:22 -04:00
|
|
|
|
Gio.bus_own_name_on_connection(Gio.DBus.session,
|
|
|
|
|
'org.gtk.MountOperationHandler',
|
|
|
|
|
Gio.BusNameOwnerFlags.REPLACE, null, null);
|
2012-06-20 17:23:34 -04:00
|
|
|
|
|
|
|
|
|
this._dialog = null;
|
|
|
|
|
|
|
|
|
|
this._ensureEmptyRequest();
|
2017-10-30 21:19:44 -04:00
|
|
|
|
}
|
2012-06-20 17:23:34 -04:00
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
|
_ensureEmptyRequest() {
|
2012-06-20 17:23:34 -04:00
|
|
|
|
this._currentId = null;
|
|
|
|
|
this._currentInvocation = null;
|
|
|
|
|
this._currentType = ShellMountOperationType.NONE;
|
2017-10-30 21:19:44 -04:00
|
|
|
|
}
|
2012-06-20 17:23:34 -04:00
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
|
_clearCurrentRequest(response, details) {
|
2012-06-20 17:23:34 -04:00
|
|
|
|
if (this._currentInvocation) {
|
|
|
|
|
this._currentInvocation.return_value(
|
|
|
|
|
GLib.Variant.new('(ua{sv})', [response, details]));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this._ensureEmptyRequest();
|
2017-10-30 21:19:44 -04:00
|
|
|
|
}
|
2012-06-20 17:23:34 -04:00
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
|
_setCurrentRequest(invocation, id, type) {
|
2012-06-20 17:23:34 -04:00
|
|
|
|
let oldId = this._currentId;
|
|
|
|
|
let oldType = this._currentType;
|
2022-02-07 09:14:06 -05:00
|
|
|
|
let requestId = `${id}@${invocation.get_sender()}`;
|
2012-06-20 17:23:34 -04:00
|
|
|
|
|
|
|
|
|
this._clearCurrentRequest(Gio.MountOperationResult.UNHANDLED, {});
|
|
|
|
|
|
|
|
|
|
this._currentInvocation = invocation;
|
|
|
|
|
this._currentId = requestId;
|
|
|
|
|
this._currentType = type;
|
|
|
|
|
|
2023-08-06 20:51:19 -04:00
|
|
|
|
if (this._dialog && (oldId === requestId) && (oldType === type))
|
2012-06-20 17:23:34 -04:00
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
return false;
|
2017-10-30 21:19:44 -04:00
|
|
|
|
}
|
2012-06-20 17:23:34 -04:00
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
|
_closeDialog() {
|
2012-06-20 17:23:34 -04:00
|
|
|
|
if (this._dialog) {
|
|
|
|
|
this._dialog.close();
|
|
|
|
|
this._dialog = null;
|
|
|
|
|
}
|
2017-10-30 21:19:44 -04:00
|
|
|
|
}
|
2012-06-20 17:23:34 -04:00
|
|
|
|
|
|
|
|
|
/**
|
2023-08-06 21:15:51 -04:00
|
|
|
|
* The dialog will stay visible until clients call the Close() method, or
|
|
|
|
|
* another dialog becomes visible.
|
|
|
|
|
* Calling AskPassword again for the same id will have the effect to clear
|
|
|
|
|
* the existing dialog and update it with a message indicating the previous
|
|
|
|
|
* attempt went wrong.
|
|
|
|
|
*
|
2019-10-17 12:41:52 -04:00
|
|
|
|
* @param {Array} params
|
|
|
|
|
* {string} id: an opaque ID identifying the object for which
|
|
|
|
|
* the operation is requested
|
|
|
|
|
* {string} message: the message to display
|
|
|
|
|
* {string} icon_name: the name of an icon to display
|
|
|
|
|
* {string} default_user: the default username for display
|
|
|
|
|
* {string} default_domain: the default domain for display
|
|
|
|
|
* {Gio.AskPasswordFlags} flags: a set of GAskPasswordFlags
|
|
|
|
|
* {Gio.MountOperationResults} response: a GMountOperationResult
|
|
|
|
|
* {Object} response_details: a dictionary containing response details as
|
|
|
|
|
* entered by the user. The dictionary MAY contain the following
|
|
|
|
|
* properties:
|
2012-06-20 17:23:34 -04:00
|
|
|
|
* - "password" -> (s): a password to be used to complete the mount operation
|
|
|
|
|
* - "password_save" -> (u): a GPasswordSave
|
2019-10-17 12:41:52 -04:00
|
|
|
|
* @param {Gio.DBusMethodInvocation} invocation
|
|
|
|
|
* The ID must be unique in the context of the calling process.
|
2012-06-20 17:23:34 -04:00
|
|
|
|
*/
|
2017-10-30 20:03:21 -04:00
|
|
|
|
AskPasswordAsync(params, invocation) {
|
2020-01-13 07:39:41 -05:00
|
|
|
|
let [id, message, iconName_, defaultUser_, defaultDomain_, flags] = params;
|
2012-06-20 17:23:34 -04:00
|
|
|
|
|
|
|
|
|
if (this._setCurrentRequest(invocation, id, ShellMountOperationType.ASK_PASSWORD)) {
|
|
|
|
|
this._dialog.reaskPassword();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this._closeDialog();
|
|
|
|
|
|
2020-01-13 07:39:41 -05:00
|
|
|
|
this._dialog = new ShellMountPasswordDialog(message, flags);
|
2017-10-30 20:38:18 -04:00
|
|
|
|
this._dialog.connect('response',
|
2019-04-07 17:35:07 -04:00
|
|
|
|
(object, choice, password, remember, hiddenVolume, systemVolume, pim) => {
|
2012-06-20 17:23:34 -04:00
|
|
|
|
let details = {};
|
|
|
|
|
let response;
|
|
|
|
|
|
2023-08-06 20:51:19 -04:00
|
|
|
|
if (choice === -1) {
|
2012-06-20 17:23:34 -04:00
|
|
|
|
response = Gio.MountOperationResult.ABORTED;
|
|
|
|
|
} else {
|
|
|
|
|
response = Gio.MountOperationResult.HANDLED;
|
|
|
|
|
|
|
|
|
|
let passSave = remember ? Gio.PasswordSave.PERMANENTLY : Gio.PasswordSave.NEVER;
|
|
|
|
|
details['password_save'] = GLib.Variant.new('u', passSave);
|
|
|
|
|
details['password'] = GLib.Variant.new('s', password);
|
2019-04-07 17:35:07 -04:00
|
|
|
|
details['hidden_volume'] = GLib.Variant.new('b', hiddenVolume);
|
|
|
|
|
details['system_volume'] = GLib.Variant.new('b', systemVolume);
|
2019-05-23 16:45:44 -04:00
|
|
|
|
details['pim'] = GLib.Variant.new('u', pim);
|
2012-06-20 17:23:34 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this._clearCurrentRequest(response, details);
|
2017-10-30 20:38:18 -04:00
|
|
|
|
});
|
2012-06-20 17:23:34 -04:00
|
|
|
|
this._dialog.open();
|
2017-10-30 21:19:44 -04:00
|
|
|
|
}
|
2012-06-20 17:23:34 -04:00
|
|
|
|
|
|
|
|
|
/**
|
2023-08-06 21:15:51 -04:00
|
|
|
|
* The dialog will stay visible until clients call the Close() method, or
|
|
|
|
|
* another dialog becomes visible.
|
|
|
|
|
* Calling AskQuestion again for the same id will have the effect to clear
|
|
|
|
|
* update the dialog with the new question.
|
|
|
|
|
*
|
2019-10-17 12:41:52 -04:00
|
|
|
|
* @param {Array} params - params
|
|
|
|
|
* {string} id: an opaque ID identifying the object for which
|
|
|
|
|
* the operation is requested
|
2012-06-20 17:23:34 -04:00
|
|
|
|
* The ID must be unique in the context of the calling process.
|
2019-10-17 12:41:52 -04:00
|
|
|
|
* {string} message: the message to display
|
|
|
|
|
* {string} icon_name: the name of an icon to display
|
|
|
|
|
* {string[]} choices: an array of choice strings
|
|
|
|
|
* @param {Gio.DBusMethodInvocation} invocation - invocation
|
2012-06-20 17:23:34 -04:00
|
|
|
|
*/
|
2017-10-30 20:03:21 -04:00
|
|
|
|
AskQuestionAsync(params, invocation) {
|
2020-01-13 07:39:41 -05:00
|
|
|
|
let [id, message, iconName_, choices] = params;
|
2012-06-20 17:23:34 -04:00
|
|
|
|
|
|
|
|
|
if (this._setCurrentRequest(invocation, id, ShellMountOperationType.ASK_QUESTION)) {
|
|
|
|
|
this._dialog.update(message, choices);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this._closeDialog();
|
|
|
|
|
|
2020-01-13 07:39:41 -05:00
|
|
|
|
this._dialog = new ShellMountQuestionDialog(message);
|
2017-10-30 20:38:18 -04:00
|
|
|
|
this._dialog.connect('response', (object, choice) => {
|
2020-01-27 12:46:17 -05:00
|
|
|
|
let response;
|
|
|
|
|
let details = {};
|
|
|
|
|
|
2023-08-06 20:51:19 -04:00
|
|
|
|
if (choice === -1) {
|
2020-01-27 12:46:17 -05:00
|
|
|
|
response = Gio.MountOperationResult.ABORTED;
|
|
|
|
|
} else {
|
|
|
|
|
response = Gio.MountOperationResult.HANDLED;
|
|
|
|
|
details['choice'] = GLib.Variant.new('i', choice);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this._clearCurrentRequest(response, details);
|
2017-10-30 20:38:18 -04:00
|
|
|
|
});
|
2012-06-20 17:23:34 -04:00
|
|
|
|
|
|
|
|
|
this._dialog.update(message, choices);
|
|
|
|
|
this._dialog.open();
|
2017-10-30 21:19:44 -04:00
|
|
|
|
}
|
2012-06-20 17:23:34 -04:00
|
|
|
|
|
|
|
|
|
/**
|
2023-08-06 21:15:51 -04:00
|
|
|
|
* The dialog will stay visible until clients call the Close() method, or
|
|
|
|
|
* another dialog becomes visible.
|
|
|
|
|
* Calling ShowProcesses again for the same id will have the effect to clear
|
|
|
|
|
* the existing dialog and update it with the new message and the new list
|
|
|
|
|
* of processes.
|
|
|
|
|
*
|
2019-10-17 12:41:52 -04:00
|
|
|
|
* @param {Array} params - params
|
|
|
|
|
* {string} id: an opaque ID identifying the object for which
|
|
|
|
|
* the operation is requested
|
2012-06-20 17:23:34 -04:00
|
|
|
|
* The ID must be unique in the context of the calling process.
|
2019-10-17 12:41:52 -04:00
|
|
|
|
* {string} message: the message to display
|
|
|
|
|
* {string} icon_name: the name of an icon to display
|
|
|
|
|
* {number[]} application_pids: the PIDs of the applications to display
|
|
|
|
|
* {string[]} choices: an array of choice strings
|
|
|
|
|
* @param {Gio.DBusMethodInvocation} invocation - invocation
|
2012-06-20 17:23:34 -04:00
|
|
|
|
*/
|
2017-10-30 20:03:21 -04:00
|
|
|
|
ShowProcessesAsync(params, invocation) {
|
2020-01-13 07:39:41 -05:00
|
|
|
|
let [id, message, iconName_, applicationPids, choices] = params;
|
2012-06-20 17:23:34 -04:00
|
|
|
|
|
|
|
|
|
if (this._setCurrentRequest(invocation, id, ShellMountOperationType.SHOW_PROCESSES)) {
|
|
|
|
|
this._dialog.update(message, applicationPids, choices);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this._closeDialog();
|
|
|
|
|
|
2020-01-13 07:39:41 -05:00
|
|
|
|
this._dialog = new ShellProcessesDialog();
|
2017-10-30 20:38:18 -04:00
|
|
|
|
this._dialog.connect('response', (object, choice) => {
|
|
|
|
|
let response;
|
|
|
|
|
let details = {};
|
|
|
|
|
|
2023-08-06 20:51:19 -04:00
|
|
|
|
if (choice === -1) {
|
2017-10-30 20:38:18 -04:00
|
|
|
|
response = Gio.MountOperationResult.ABORTED;
|
|
|
|
|
} else {
|
|
|
|
|
response = Gio.MountOperationResult.HANDLED;
|
|
|
|
|
details['choice'] = GLib.Variant.new('i', choice);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this._clearCurrentRequest(response, details);
|
|
|
|
|
});
|
2012-06-20 17:23:34 -04:00
|
|
|
|
|
|
|
|
|
this._dialog.update(message, applicationPids, choices);
|
|
|
|
|
this._dialog.open();
|
2017-10-30 21:19:44 -04:00
|
|
|
|
}
|
2012-06-20 17:23:34 -04:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Closes a dialog previously opened by AskPassword, AskQuestion or ShowProcesses.
|
|
|
|
|
* If no dialog is open, does nothing.
|
2023-08-06 21:15:51 -04:00
|
|
|
|
*
|
|
|
|
|
* @param {Array} _params - params
|
|
|
|
|
* @param {Gio.DBusMethodInvocation} _invocation - invocation
|
2012-06-20 17:23:34 -04:00
|
|
|
|
*/
|
2019-01-31 09:08:10 -05:00
|
|
|
|
Close(_params, _invocation) {
|
2012-06-20 17:23:34 -04:00
|
|
|
|
this._clearCurrentRequest(Gio.MountOperationResult.UNHANDLED, {});
|
|
|
|
|
this._closeDialog();
|
|
|
|
|
}
|
2023-07-10 05:53:00 -04:00
|
|
|
|
}
|