Guest User

Untitled

a guest
Oct 12th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. 'use strict';
  2.  
  3. const Gio = imports.gi.Gio;
  4. const GLib = imports.gi.GLib;
  5.  
  6.  
  7. async function mount() {
  8. try {
  9. // This comes from a 'kdeconnect.sftp' packet
  10. let file = Gio.File.new_for_uri('sftp://192.168.1.68:1748//storage/emulated/0');
  11.  
  12. let mount = new Gio.MountOperation({
  13. // This is always 'kdeconnect'
  14. username: 'kdeconnect',
  15. // This comes from a 'kdeconnect.sftp' packet
  16. password: '0DLBswxkjjY4bTxpNUvNXGB1X3c9',
  17. // Save password for session and accept new connections
  18. password_save: Gio.PasswordSave.FOR_SESSION,
  19. choice: 0
  20. });
  21.  
  22. // We already know the host, so just accept
  23. mount.connect('ask-question', (op, message, choices) => {
  24. op.reply(Gio.MountOperationResult.HANDLED);
  25. });
  26.  
  27. // We set the password, so just accept
  28. mount.connect('ask-password', (op, message, user, domain, flags) => {
  29. op.reply(Gio.MountOperationResult.HANDLED);
  30. });
  31.  
  32. // This is the actual call to mount the device
  33. await new Promise((resolve, reject) => {
  34. file.mount_enclosing_volume(0, mount, null, (file, res) => {
  35. try {
  36. file.mount_enclosing_volume_finish(res);
  37. } catch (e) {
  38. logError(e);
  39. }
  40. });
  41. });
  42. } catch (e) {
  43. logError(e);
  44. }
  45. }
  46.  
  47. mount();
  48.  
  49. let loop = GLib.MainLoop.new(null, false);
  50. loop.run();
Add Comment
Please, Sign In to add comment