# module DBus

dbus.rb - `Module` containing the low-level D-Bus implementation

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

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.

# D-Bus main module¶ ↑

`Module` containing all the D-Bus modules and classes.

This file is part of the ruby-dbus project Copyright © 2016 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.

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

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.

# D-Bus main module¶ ↑

`Module` containing all the D-Bus modules and classes.

This file is part of the ruby-dbus project Copyright © 2019 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.

This file is part of the ruby-dbus project Copyright © 2007 Arnaud Cornet and Paul van Tilburg Copyright © 2023 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.

This file is part of the ruby-dbus project Copyright © 2022 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.

This file is part of the ruby-dbus project Copyright © 2022 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.

error.rb

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

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.

dbus/introspection.rb - module containing a low-level D-Bus introspection implementation

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

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.

This file is part of the ruby-dbus project Copyright © 2007 Arnaud Cornet and Paul van Tilburg Copyright © 2023 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.

# D-Bus main module¶ ↑

`Module` containing all the D-Bus modules and classes.

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

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.

# D-Bus main module¶ ↑

`Module` containing all the D-Bus modules and classes.

This file is part of the ruby-dbus project Copyright © 2007 Arnaud Cornet and Paul van Tilburg Copyright © 2023 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.

This file is part of the ruby-dbus project Copyright © 2022 José Iván López González Copyright © 2022 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.

This file is part of the ruby-dbus project Copyright © 2019 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.

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.

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.

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.

This file is part of the ruby-dbus project Copyright © 2022 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.

dbus/type.rb - module containing low-level D-Bus data type information

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

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.

### Constants

BIG_END

  Protocol character signifying big endianness.

HOST_END

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

HOST_ENDIANNESS

  Comparing symbols is faster than strings @return [:little,:big]

INTERFACE_ELEMENT_RE

  Regular expressions that should match all interface names.

LIL_END

  Protocol character signifying little endianness.

METHOD_SIGNAL_RE

  Regular expressions that should match all method names.

PROPERTY_INTERFACE
SYSTEM_BUS_ADDRESS

  Default socket name for the system bus.

### Public Class Methods

error(name = "org.freedesktop.DBus.Error.Failed") click to toggle source

@example raise a generic error

    raise DBus.error, "message"

@example raise a specific error

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

       # File lib/dbus/error.rb
    43 def error(name = "org.freedesktop.DBus.Error.Failed")
    44   # message will be set by Kernel.raise
    45   DBus::Error.new(nil, name)
    46 end

logger() click to toggle source

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

       # File lib/dbus/logger.rb
    19 def logger
    20   if !defined?(@logger) || @logger.nil?
    21     debug = $DEBUG || ENV["RUBY_DBUS_DEBUG"]
    22     @logger = Logger.new($stderr)
    23     @logger.level = debug ? Logger::DEBUG : Logger::INFO
    24   end
    25   @logger
    26 end

logger=(logger) click to toggle source

Set the logger for the `DBus` module

       # File lib/dbus/logger.rb
    30 def logger=(logger)
    31   @logger = logger
    32 end

session_bus() click to toggle source

Shortcut for the {SessionBus} instance @return [BusConnection]

        # File lib/dbus/bus.rb
    310 def self.session_bus
    311   SessionBus.instance
    312 end

system_bus() click to toggle source

Shortcut for the {SystemBus} instance @return [BusConnection]

        # File lib/dbus/bus.rb
    304 def self.system_bus
    305   SystemBus.instance
    306 end

type(string_type) click to toggle source

Parse a String to a valid {DBus::Type}. This is prefered to {Type#initialize} which allows incomplete or invalid types. @param string_type [SingleCompleteType] @return [DBus::Type] (frozen) @raise SignatureException

        # File lib/dbus/type.rb
    401 def type(string_type)
    402   Type::Parser.new(string_type).parse1
    403 end

types(string_type) click to toggle source

Parse a String to zero or more {DBus::Type}s. @param string_type [Signature] @return [Array<DBus::Type>] (frozen) @raise SignatureException

        # File lib/dbus/type.rb
    410 def types(string_type)
    411   Type::Parser.new(string_type).parse
    412 end

variant(string_type, value) click to toggle source

Make an explicit [Type, value] pair @param string_type [SingleCompleteType] @param value [::Object] @return [Array(DBus::Type::Type,::Object)] @deprecated Use {Data::Variant#initialize} instead

        # File lib/dbus/type.rb
    420 def variant(string_type, value)
    421   Data::Variant.new(value, member_type: string_type)
    422 end

### Public Instance Methods

buffer_from_socket_nonblock() click to toggle source

Fill (append) the buffer from data that might be available on the socket. @return [void] @raise EOFError

        # File lib/dbus/message_queue.rb
    169 def buffer_from_socket_nonblock
    170   @buffer += @socket.read_nonblock(MSG_BUF_SIZE, @read_buffer)
    171 rescue EOFError
    172   raise # the caller expects it
    173 rescue Errno::EAGAIN
    174   # fine, would block
    175 rescue Exception => e
    176   puts "Oops:", e
    177   raise if @is_tcp # why?
    178
    179   puts "WARNING: read_nonblock failed, falling back to .recv"
    180   @buffer += @socket.recv(MSG_BUF_SIZE)
    181 end

### Private Instance Methods

error(name = "org.freedesktop.DBus.Error.Failed") click to toggle source

@example raise a generic error

    raise DBus.error, "message"

@example raise a specific error

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

       # File lib/dbus/error.rb
    43 def error(name = "org.freedesktop.DBus.Error.Failed")
    44   # message will be set by Kernel.raise
    45   DBus::Error.new(nil, name)
    46 end

logger() click to toggle source

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

       # File lib/dbus/logger.rb
    19 def logger
    20   if !defined?(@logger) || @logger.nil?
    21     debug = $DEBUG || ENV["RUBY_DBUS_DEBUG"]
    22     @logger = Logger.new($stderr)
    23     @logger.level = debug ? Logger::DEBUG : Logger::INFO
    24   end
    25   @logger
    26 end

logger=(logger) click to toggle source

Set the logger for the `DBus` module

       # File lib/dbus/logger.rb
    30 def logger=(logger)
    31   @logger = logger
    32 end

type(string_type) click to toggle source

Parse a String to a valid {DBus::Type}. This is prefered to {Type#initialize} which allows incomplete or invalid types. @param string_type [SingleCompleteType] @return [DBus::Type] (frozen) @raise SignatureException

        # File lib/dbus/type.rb
    401 def type(string_type)
    402   Type::Parser.new(string_type).parse1
    403 end

types(string_type) click to toggle source

Parse a String to zero or more {DBus::Type}s. @param string_type [Signature] @return [Array<DBus::Type>] (frozen) @raise SignatureException

        # File lib/dbus/type.rb
    410 def types(string_type)
    411   Type::Parser.new(string_type).parse
    412 end

variant(string_type, value) click to toggle source

Make an explicit [Type, value] pair @param string_type [SingleCompleteType] @param value [::Object] @return [Array(DBus::Type::Type,::Object)] @deprecated Use {Data::Variant#initialize} instead

        # File lib/dbus/type.rb
    420 def variant(string_type, value)
    421   Data::Variant.new(value, member_type: string_type)
    422 end