How to use the dbus-next.interface function in dbus-next

To help you get started, we’ve selected a few dbus-next examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dbusjs / mpris-service / src / interfaces / mpris-interface.js View on Github external
const dbus = require('dbus-next');
const Variant = dbus.Variant;
const types = require('./types');
const deepEqual = require('deep-equal');
const constants = require('../constants');
const logging = require('../logging');

let {
  Interface, property, method, signal, DBusError,
  ACCESS_READ, ACCESS_WRITE, ACCESS_READWRITE
} = dbus.interface;

class MprisInterface extends Interface {
  constructor(name, player) {
    super(name);
    this.player = player;
  }

  _setPropertyInternal(property, valueDbus) {
    // nothing is currently settable internally that needs conversion to plain
    this.player.emit(property[0].toLowerCase() + property.substr(1), valueDbus);
  }

  setProperty(property, valuePlain) {
    // convert the plain value to a dbus value (default to the plain value)
    let valueDbus = valuePlain;
github dbusjs / mpris-service / src / interfaces / playlists.js View on Github external
// TODO proper import
let MprisInterface = require('./mpris-interface');
let dbus = require('dbus-next');
let Variant = dbus.Variant;
let types = require('./types');

let {
  property, method, signal, DBusError,
  ACCESS_READ, ACCESS_WRITE, ACCESS_READWRITE
} = dbus.interface;

class PlaylistsInterface extends MprisInterface {
  constructor(player) {
    super('org.mpris.MediaPlayer2.Playlists', player);
  }

  _ActivePlaylist = [ false, types.emptyPlaylist ];
  _PlaylistCount = 0;

  @property({signature: 'u', access: ACCESS_READ})
  get PlaylistCount() {
    return this._PlaylistCount;
  }

  @property({signature: 'as', access: ACCESS_READ})
  get Orderings() {
github dbusjs / mpris-service / src / interfaces / tracklist.js View on Github external
let MprisInterface = require('./mpris-interface');
let dbus = require('dbus-next');
let Variant = dbus.Variant;
let types = require('./types');

let {
  property, method, signal, DBusError,
  ACCESS_READ, ACCESS_WRITE, ACCESS_READWRITE
} = dbus.interface;

class TracklistInterface extends MprisInterface {
  constructor(player) {
    super('org.mpris.MediaPlayer2.TrackList', player);
  }

  _Tracks = [];
  _CanEditTracks = false;

  setTracks(tracksPlain) {
    this.setProperty('Tracks', tracksPlain);
  }

  @property({signature: 'ao', access: ACCESS_READ})
  get Tracks() {
    return this._Tracks;
github dbusjs / mpris-service / src / interfaces / player.js View on Github external
const dbus = require('dbus-next');
const MprisInterface = require('./mpris-interface');
const Variant = dbus.Variant;
const JSBI = require('jsbi');
const constants = require('../constants');

let {
  property, method, signal, DBusError,
  ACCESS_READ, ACCESS_WRITE, ACCESS_READWRITE
} = dbus.interface;

class PlayerInterface extends MprisInterface {
  constructor(player) {
    super('org.mpris.MediaPlayer2.Player', player);
  }

  _CanControl = true;
  _CanPause = true;
  _CanPlay = true;
  _CanSeek = true;
  _CanGoNext = true;
  _CanGoPrevious = true;
  _Metadata = {};
  _MaximumRate = 1;
  _MinimumRate = 1;
  _Rate = 1;
github dbusjs / mpris-service / src / interfaces / root.js View on Github external
let MprisInterface = require('./mpris-interface');
let dbus = require('dbus-next');
let Variant = dbus.Variant;

let {
  property, method, signal, DBusError,
  ACCESS_READ, ACCESS_WRITE, ACCESS_READWRITE
} = dbus.interface;

class RootInterface extends MprisInterface {
  constructor(player, opts={}) {
    super('org.mpris.MediaPlayer2', player);

    if (opts.hasOwnProperty('identity')) {
      this._Identity = opts.identity;
    }
    if (opts.hasOwnProperty('supportedUriSchemes')) {
      this._SupportedUriSchemes = opts.supportedUriSchemes;
    }
    if (opts.hasOwnProperty('supportedMimeTypes')) {
      this._SupportedMimeTypes = opts.supportedMimeTypes;
    }
    if (opts.hasOwnProperty('desktopEntry')) {
      this._DesktopEntry = opts.desktopEntry;