Module: DBus

Defined in:
lib/dbus.rb,
lib/dbus.rb,
lib/dbus/bus.rb,
lib/dbus/xml.rb,
lib/dbus/auth.rb,
lib/dbus/data.rb,
lib/dbus/main.rb,
lib/dbus/type.rb,
lib/dbus/error.rb,
lib/dbus/logger.rb,
lib/dbus/object.rb,
lib/dbus/message.rb,
lib/dbus/bus_name.rb,
lib/dbus/marshall.rb,
lib/dbus/platform.rb,
lib/dbus/matchrule.rb,
lib/dbus/node_tree.rb,
lib/dbus/connection.rb,
lib/dbus/introspect.rb,
lib/dbus/api_options.rb,
lib/dbus/object_path.rb,
lib/dbus/raw_message.rb,
lib/dbus/proxy_object.rb,
lib/dbus/message_queue.rb,
lib/dbus/object_server.rb,
lib/dbus/proxy_service.rb,
lib/dbus/object_manager.rb,
lib/dbus/emits_changed_signal.rb,
lib/dbus/proxy_object_factory.rb,
lib/dbus/proxy_object_interface.rb

Overview

This file is part of the ruby-dbus project Copyright © 2007 Arnaud Cornet and Paul van Tilburg Copyright © 2009-2014 Martin Vidner

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1 as published by the Free Software Foundation. See the file “COPYING” for the exact licensing terms.

Defined Under Namespace

Modules: Authentication, Data, ObjectManager, Platform Classes: ASessionBus, ASystemBus, ApiOptions, AuthenticationFailed, BusConnection, BusName, Connection, EmitsChangedSignal, Error, ErrorMessage, FormalParameter, IncompleteBufferException, Interface, InterfaceElement, IntrospectXMLParser, InvalidClassDefinition, InvalidIntrospectionData, InvalidMethodName, InvalidPacketException, Main, MatchRule, MatchRuleException, Message, MessageQueue, Method, MethodReturnMessage, Node, NodeTree, Object, ObjectPath, ObjectServer, PacketMarshaller, PacketUnmarshaller, PeerConnection, Property, Prototype, ProxyObject, ProxyObjectFactory, ProxyObjectInterface, ProxyPeerService, ProxyService, RawMessage, RemoteBus, SessionBus, Signal, Signature, SingleCompleteType, SystemBus, Type, TypeException

Constant Summary collapse

BIG_END =

Protocol character signifying big endianness.

"B"
LIL_END =

Protocol character signifying little endianness.

"l"
HOST_END =

Protocol character signifying the host’s endianness. “S”: unpack as uint16, native endian

{ 1 => BIG_END, 256 => LIL_END }.fetch("\x00\x01".unpack1("S"))
HOST_ENDIANNESS =

Comparing symbols is faster than strings

Returns:

  • (:little, :big)
RawMessage.endianness(HOST_END)
SYSTEM_BUS_ADDRESS =

Default socket name for the system bus.

"unix:path=/var/run/dbus/system_bus_socket"
PROPERTY_INTERFACE =
"org.freedesktop.DBus.Properties"
METHOD_SIGNAL_RE =

Regular expressions that should match all method names.

/^[A-Za-z][A-Za-z0-9_]*$/.freeze
INTERFACE_ELEMENT_RE =

Regular expressions that should match all interface names.

/^[A-Za-z][A-Za-z0-9_]*$/.freeze

Class Method Summary collapse

Class Method Details

.error(name = "org.freedesktop.DBus.Error.Failed") ⇒ Object

Examples:

raise a generic error

raise DBus.error, "message"

raise a specific error

raise DBus.error("org.example.Error.SeatOccupied"), "Seat #{n} is occupied"


43
44
45
46
# File 'lib/dbus/error.rb', line 43

def error(name = "org.freedesktop.DBus.Error.Failed")
  # message will be set by Kernel.raise
  DBus::Error.new(nil, name)
end

.loggerObject

Get the logger for the DBus module. The default one logs to STDERR, with DEBUG if $DEBUG is set, otherwise INFO.



19
20
21
22
23
24
25
26
# File 'lib/dbus/logger.rb', line 19

def logger
  if @logger.nil?
    debug = $DEBUG || ENV["RUBY_DBUS_DEBUG"]
    @logger = Logger.new($stderr)
    @logger.level = debug ? Logger::DEBUG : Logger::INFO
  end
  @logger
end

.logger=(logger) ⇒ Object

Set the logger for the DBus module



30
31
32
# File 'lib/dbus/logger.rb', line 30

def logger=(logger)
  @logger = logger
end

.session_busBusConnection

Shortcut for the SessionBus instance

Returns:



310
311
312
# File 'lib/dbus/bus.rb', line 310

def self.session_bus
  SessionBus.instance
end

.system_busBusConnection

Shortcut for the SystemBus instance

Returns:



304
305
306
# File 'lib/dbus/bus.rb', line 304

def self.system_bus
  SystemBus.instance
end

.type(string_type) ⇒ DBus::Type

Parse a String to a valid Type. This is prefered to DBus::Type#initialize which allows incomplete or invalid types.

Parameters:

Returns:

Raises:

  • SignatureException



400
401
402
# File 'lib/dbus/type.rb', line 400

def type(string_type)
  Type::Parser.new(string_type).parse1
end

.types(string_type) ⇒ Array<DBus::Type>

Parse a String to zero or more Types.

Parameters:

Returns:

Raises:

  • SignatureException



409
410
411
# File 'lib/dbus/type.rb', line 409

def types(string_type)
  Type::Parser.new(string_type).parse
end

.variant(string_type, value) ⇒ Array(DBus::Type::Type,::Object)

Deprecated.

Make an explicit [Type, value] pair

Parameters:

Returns:



419
420
421
# File 'lib/dbus/type.rb', line 419

def variant(string_type, value)
  Data::Variant.new(value, member_type: string_type)
end