|
| 1 | +// Test helpers for mount operation dialogs. |
| 2 | +// Call from Looking Glass: |
| 3 | +// |
| 4 | +// imports.testing.testMountDialogs.askPassword() |
| 5 | +// imports.testing.testMountDialogs.askPassword("Unlock encrypted volume\nEnter password for 'My Drive'") |
| 6 | +// imports.testing.testMountDialogs.askPasswordTcrypt() |
| 7 | +// imports.testing.testMountDialogs.askQuestion() |
| 8 | +// imports.testing.testMountDialogs.askQuestion("Trust this certificate?\nThe identity of 'server.local' cannot be verified.", ["Cancel", "Trust", "Trust Always"]) |
| 9 | +// imports.testing.testMountDialogs.showProcesses() |
| 10 | + |
| 11 | +const Gio = imports.gi.Gio; |
| 12 | +const MountOp = imports.ui.cinnamonMountOperation; |
| 13 | + |
| 14 | +function askPassword(message, flags) { |
| 15 | + message = message || "Enter a password to unlock the volume\nThe password is needed to access encrypted data on My Encrypted Drive."; |
| 16 | + flags = flags || Gio.AskPasswordFlags.NEED_PASSWORD; |
| 17 | + |
| 18 | + let dialog = new MountOp.CinnamonMountPasswordDialog(message, flags); |
| 19 | + dialog.connect('response', (obj, choice, password, remember, hidden, system, pim) => { |
| 20 | + log(`[testMountDialogs] askPassword response: choice=${choice} password=${password}`); |
| 21 | + dialog.close(); |
| 22 | + }); |
| 23 | + dialog.open(); |
| 24 | + return dialog; |
| 25 | +} |
| 26 | + |
| 27 | +function askPasswordTcrypt(message) { |
| 28 | + message = message || "Enter a password to unlock the volume\nThe password is needed to access encrypted data on My VeraCrypt Drive."; |
| 29 | + let flags = Gio.AskPasswordFlags.NEED_PASSWORD | Gio.AskPasswordFlags.TCRYPT; |
| 30 | + |
| 31 | + return askPassword(message, flags); |
| 32 | +} |
| 33 | + |
| 34 | +function askQuestion(message, choices) { |
| 35 | + message = message || "Mount point is not empty\nThe mount point /mnt/data already contains files. Do you want to merge?"; |
| 36 | + choices = choices || ["Cancel", "Merge"]; |
| 37 | + |
| 38 | + let dialog = new MountOp.CinnamonMountQuestionDialog(); |
| 39 | + dialog.connect('response', (obj, choice) => { |
| 40 | + log(`[testMountDialogs] askQuestion response: choice=${choice}`); |
| 41 | + dialog.close(); |
| 42 | + }); |
| 43 | + dialog.update(message, choices); |
| 44 | + dialog.open(); |
| 45 | + return dialog; |
| 46 | +} |
| 47 | + |
| 48 | +function showProcesses(message, choices) { |
| 49 | + message = message || "Volume is busy\nOne or more applications are keeping the volume busy."; |
| 50 | + choices = choices || ["Cancel", "Unmount Anyway"]; |
| 51 | + |
| 52 | + let dialog = new MountOp.CinnamonProcessesDialog(); |
| 53 | + dialog.connect('response', (obj, choice) => { |
| 54 | + log(`[testMountDialogs] showProcesses response: choice=${choice}`); |
| 55 | + dialog.close(); |
| 56 | + }); |
| 57 | + |
| 58 | + // Use real PIDs of running apps if possible, otherwise empty |
| 59 | + let pids = []; |
| 60 | + dialog.update(message, pids, choices); |
| 61 | + dialog.open(); |
| 62 | + return dialog; |
| 63 | +} |
0 commit comments