Class DBus::Connection
In: lib/dbus/bus.rb
Parent: Object

D-Bus main connection class

Main class that maintains a connection to a bus and can handle incoming and outgoing messages.

Methods

Classes and Modules

Class DBus::Connection::NameRequestError

Constants

NAME_FLAG_ALLOW_REPLACEMENT = 0x1   FIXME: describe the following names, flags and constants. See DBus spec for definition
NAME_FLAG_REPLACE_EXISTING = 0x2
NAME_FLAG_DO_NOT_QUEUE = 0x4
REQUEST_NAME_REPLY_PRIMARY_OWNER = 0x1
REQUEST_NAME_REPLY_IN_QUEUE = 0x2
REQUEST_NAME_REPLY_EXISTS = 0x3
REQUEST_NAME_REPLY_ALREADY_OWNER = 0x4
DBUSXMLINTRO = '<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> <node> <interface name="org.freedesktop.DBus.Introspectable"> <method name="Introspect"> <arg name="data" direction="out" type="s"/> </method> </interface> <interface name="org.freedesktop.DBus"> <method name="RequestName"> <arg direction="in" type="s"/> <arg direction="in" type="u"/> <arg direction="out" type="u"/> </method> <method name="ReleaseName"> <arg direction="in" type="s"/> <arg direction="out" type="u"/> </method> <method name="StartServiceByName"> <arg direction="in" type="s"/> <arg direction="in" type="u"/> <arg direction="out" type="u"/> </method> <method name="Hello"> <arg direction="out" type="s"/> </method> <method name="NameHasOwner"> <arg direction="in" type="s"/> <arg direction="out" type="b"/> </method> <method name="ListNames"> <arg direction="out" type="as"/> </method> <method name="ListActivatableNames"> <arg direction="out" type="as"/> </method> <method name="AddMatch"> <arg direction="in" type="s"/> </method> <method name="RemoveMatch"> <arg direction="in" type="s"/> </method> <method name="GetNameOwner"> <arg direction="in" type="s"/> <arg direction="out" type="s"/> </method> <method name="ListQueuedOwners"> <arg direction="in" type="s"/> <arg direction="out" type="as"/> </method> <method name="GetConnectionUnixUser"> <arg direction="in" type="s"/> <arg direction="out" type="u"/> </method> <method name="GetConnectionUnixProcessID"> <arg direction="in" type="s"/> <arg direction="out" type="u"/> </method> <method name="GetConnectionSELinuxSecurityContext"> <arg direction="in" type="s"/> <arg direction="out" type="ay"/> </method> <method name="ReloadConfig"> </method> <signal name="NameOwnerChanged"> <arg type="s"/> <arg type="s"/> <arg type="s"/> </signal> <signal name="NameLost"> <arg type="s"/> </signal> <signal name="NameAcquired"> <arg type="s"/> </signal> </interface> </node> '
MSG_BUF_SIZE = 4096   The buffer size for messages.

Attributes

socket  [R]  The socket that is used to connect with the bus.
unique_name  [R]  The unique name (by specification) of the message.

Public Class methods

Create a new connection to the bus for a given connect path. path format is described in the D-Bus specification: dbus.freedesktop.org/doc/dbus-specification.html#addresses and is something like: "transport1:key1=value1,key2=value2;transport2:key1=value1,key2=value2" e.g. "unix:path=/tmp/dbus-test" or "tcp:host=localhost,port=2687"

Public Instance methods

[](name)

Alias for service

Asks bus to send us messages matching mr, and execute slot when received

Connect to the bus and initialize the connection.

Connect to a bus over tcp and initialize the connection.

Connect to an abstract unix bus and initialize the connection.

Emit a signal event for the given service, object obj, interface intf and signal sig with arguments args.

Tell a bus to register itself on the glib main loop

Issues a call to the org.freedesktop.DBus.Introspectable.Introspect method dest is the service and path the object path you want to introspect If a code block is given, the introspect call in asynchronous. If not data is returned

FIXME: link to ProxyObject data definition The returned object is a ProxyObject that has methods you can call to issue somme METHOD_CALL messages, and to setup to receive METHOD_RETURN

This apostroph is for syntax highlighting editors confused by above xml: "

Retrieve all the messages that are currently in the buffer.

Specify a code block that has to be executed when a reply for message m is received.

Update the buffer and retrieve all messages using Connection#messages. Return the messages.

Get one message from the bus and remove it from the buffer. Return the message.

Process a message m based on its type.

Set up a ProxyObject for the bus itself, since the bus is introspectable. Returns the object.

Attempt to request a service name.

FIXME, NameRequestError cannot really be rescued as it will be raised when dispatching a later call. Rework the API to better match the spec.

Send the buffer buf to the bus using Connection#writel.

Send a message m on to the bus. This is done synchronously, thus the call will block until a reply message arrives.

Retrieves the Service with the given name.

Fill (append) the buffer from data that might be available on the socket.

Wait for a message to arrive. Return it once it is available.

[Validate]