# module DBus

# D-Bus main module¶ ↑

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

This file is part of the ruby-dbus project Copyright (C) 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.

# D-Bus main module¶ ↑

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

This file is part of the ruby-dbus project Copyright (C) 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.

error.rb

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

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

This file is part of the ruby-dbus project Copyright (C) 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

  Byte signifying big endianness.

HOST_END

  Byte signifying the host's endianness.

INTERFACE_ELEMENT_RE

  Regular expressions that should match all interface names.

LIL_END

  Byte signifying little endianness.

METHOD_SIGNAL_RE

  Regular expressions that should match all method names.

MSG_BUF_SIZE

  The buffer size for messages.

SystemSocketName

  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
    41 def error(name = "org.freedesktop.DBus.Error.Failed")
    42   # message will be set by Kernel.raise
    43   DBus::Error.new(nil, name)
    44 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
    17 def logger
    18   unless defined? @logger
    19     @logger = Logger.new(STDERR)
    20     @logger.level = $DEBUG ? Logger::DEBUG : Logger::INFO
    21   end
    22   @logger
    23 end

logger=(logger) click to toggle source

Set the logger for the `DBus` module

       # File lib/dbus/logger.rb
    27 def logger=(logger)
    28   @logger = logger
    29 end

session_bus() click to toggle source

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

        # File lib/dbus/bus.rb
    693 def self.session_bus
    694   SessionBus.instance
    695 end

system_bus() click to toggle source

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

        # File lib/dbus/bus.rb
    687 def self.system_bus
    688   SystemBus.instance
    689 end

type(string_type) click to toggle source

Parse a String to a `DBus::Type::Type`

        # File lib/dbus/type.rb
    181 def type(string_type)
    182   Type::Parser.new(string_type).parse[0]
    183 end

variant(string_type, value) click to toggle source

Make an explicit [Type, value] pair

        # File lib/dbus/type.rb
    187 def variant(string_type, value)
    188   [type(string_type), value]
    189 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
    155 def buffer_from_socket_nonblock
    156   @buffer += @socket.read_nonblock(MSG_BUF_SIZE)
    157 rescue EOFError
    158   raise # the caller expects it
    159 rescue Errno::EAGAIN
    160   # fine, would block
    161 rescue Exception => e
    162   puts "Oops:", e
    163   raise if @is_tcp # why?
    164   puts "WARNING: read_nonblock failed, falling back to .recv"
    165   @buffer += @socket.recv(MSG_BUF_SIZE)
    166 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
    41 def error(name = "org.freedesktop.DBus.Error.Failed")
    42   # message will be set by Kernel.raise
    43   DBus::Error.new(nil, name)
    44 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
    17 def logger
    18   unless defined? @logger
    19     @logger = Logger.new(STDERR)
    20     @logger.level = $DEBUG ? Logger::DEBUG : Logger::INFO
    21   end
    22   @logger
    23 end

logger=(logger) click to toggle source

Set the logger for the `DBus` module

       # File lib/dbus/logger.rb
    27 def logger=(logger)
    28   @logger = logger
    29 end

type(string_type) click to toggle source

Parse a String to a `DBus::Type::Type`

        # File lib/dbus/type.rb
    181 def type(string_type)
    182   Type::Parser.new(string_type).parse[0]
    183 end

variant(string_type, value) click to toggle source

Make an explicit [Type, value] pair

        # File lib/dbus/type.rb
    187 def variant(string_type, value)
    188   [type(string_type), value]
    189 end