Skip to content

Instantly share code, notes, and snippets.

@shadeslayer
Created July 27, 2018 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shadeslayer/ae2a234979136d6b3c0131f0c8366fa3 to your computer and use it in GitHub Desktop.
Save shadeslayer/ae2a234979136d6b3c0131f0c8366fa3 to your computer and use it in GitHub Desktop.
/*
* This file is part of Cockpit.
*
* Copyright (C) 2015 Red Hat, Inc.
* Copyright (C) 2018 Rohan Garg <rohan@garg.io>
*
* Cockpit is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* Cockpit is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Cockpit; If not, see <http://www.gnu.org/licenses/>.
*/
(function() {
"use strict";
var cockpit = require('cockpit');
var client = { };
client.storaged_client = undefined;
cockpit.event_target(client);
var UDISKS_SERVICE;
var UDISKS_OPATH_PFX;
var UDISKS_IFACE_PFX;
function init_manager() {
UDISKS_SERVICE = "org.freedesktop.UDisks2";
UDISKS_OPATH_PFX = "/org/freedesktop/UDisks2";
UDISKS_IFACE_PFX = "org.freedesktop.DBus.ObjectManager";
var udisks = cockpit.dbus(UDISKS_SERVICE);
var udisks_manager = udisks.proxy(UDISKS_IFACE_PFX,
UDISKS_OPATH_PFX, { watch: true });
return udisks_manager.wait().then(function () {
return udisks_manager;
});
}
client.init = function init_storaged() {
init_manager().then(function(manager) {
client.storaged_client = manager.client;
client.manager = manager;
});
};
module.exports = client;
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment