Documentation ¶
Overview ¶
Package dbus provides a client interface to the D-Bus IPC system. It can be used to talk to system services (via the "system bus") or services within the user's session (via the "session bus").
Index ¶
- Constants
- Variables
- type BusDaemon
- func (o *BusDaemon) AddMatch(rule string) (err error)
- func (o *BusDaemon) GetConnectionUnixProcessID(busName string) (process uint32, err error)
- func (o *BusDaemon) GetConnectionUnixUser(busName string) (user uint32, err error)
- func (o *BusDaemon) GetId() (busId string, err error)
- func (o *BusDaemon) GetNameOwner(name string) (owner string, err error)
- func (o *BusDaemon) Hello() (uniqueName string, err error)
- func (o *BusDaemon) ListActivatableNames() (names []string, err error)
- func (o *BusDaemon) ListNames() (names []string, err error)
- func (o *BusDaemon) ListQueuedOwners(name string) (owners []string, err error)
- func (o *BusDaemon) NameHasOwner(name string) (hasOwner bool, err error)
- func (o *BusDaemon) ReleaseName(name string) (result uint32, err error)
- func (o *BusDaemon) RemoveMatch(rule string) (err error)
- func (o *BusDaemon) RequestName(name string, flags uint32) (result uint32, err error)
- func (o *BusDaemon) StartServiceByName(name string, flags uint32) (result uint32, err error)
- func (o *BusDaemon) UpdateActivationEnvironment(env map[string]string) (err error)
- type BusName
- type Connection
- func (p *Connection) Authenticate() error
- func (p *Connection) Close() error
- func (p *Connection) Object(dest string, path ObjectPath) *ObjectProxy
- func (p *Connection) RegisterMessageFilter(filter func(*Message) *Message) *MessageFilter
- func (p *Connection) RegisterObjectPath(path ObjectPath, handler chan<- *Message)
- func (p *Connection) RequestName(busName string, flags NameFlags) *BusName
- func (p *Connection) Send(msg *Message) error
- func (p *Connection) SendWithReply(msg *Message) (*Message, error)
- func (p *Connection) UnregisterMessageFilter(filter *MessageFilter)
- func (p *Connection) UnregisterObjectPath(path ObjectPath)
- func (p *Connection) WatchName(busName string) (watch *NameWatch, err error)
- func (p *Connection) WatchSignal(rule *MatchRule) (*SignalWatch, error)
- type Error
- type Introspectable
- type MatchRule
- type Message
- func NewErrorMessage(methodCall *Message, errorName string, message string) *Message
- func NewMethodCallMessage(destination string, path ObjectPath, iface string, member string) *Message
- func NewMethodReturnMessage(methodCall *Message) *Message
- func NewSignalMessage(path ObjectPath, iface string, member string) *Message
- type MessageFilter
- type MessageFlag
- type MessageType
- type NameFlags
- type NameWatch
- type ObjectPath
- type ObjectPather
- type ObjectProxy
- type Properties
- type SignalWatch
- type Signature
- type StandardBus
- type Variant
Constants ¶
const ( BUS_DAEMON_NAME = "org.freedesktop.DBus" BUS_DAEMON_PATH = ObjectPath("/org/freedesktop/DBus") BUS_DAEMON_IFACE = "org.freedesktop.DBus" )
Variables ¶
Functions ¶
This section is empty.
Types ¶
type BusDaemon ¶
type BusDaemon struct {
*ObjectProxy
}
func (*BusDaemon) GetConnectionUnixProcessID ¶
func (*BusDaemon) GetConnectionUnixUser ¶
func (*BusDaemon) GetNameOwner ¶
func (*BusDaemon) ListActivatableNames ¶
func (*BusDaemon) ListQueuedOwners ¶
func (*BusDaemon) NameHasOwner ¶
func (*BusDaemon) ReleaseName ¶
func (*BusDaemon) RemoveMatch ¶
func (*BusDaemon) RequestName ¶
func (*BusDaemon) StartServiceByName ¶
type BusName ¶
type BusName struct { Name string Flags NameFlags C chan error // contains filtered or unexported fields }
BusName acts as a handle for a well known bus name owned by this client.
type Connection ¶
type Connection struct { // The unique name of this connection on the message bus. UniqueName string // contains filtered or unexported fields }
Connection represents a connection to a message bus.
func Connect ¶
func Connect(busType StandardBus) (*Connection, error)
Connect returns a connection to the message bus identified by busType.
func (*Connection) Authenticate ¶
func (p *Connection) Authenticate() error
func (*Connection) Close ¶
func (p *Connection) Close() error
func (*Connection) Object ¶
func (p *Connection) Object(dest string, path ObjectPath) *ObjectProxy
Object returns a proxy for the object identified by the given destination address and path
func (*Connection) RegisterMessageFilter ¶
func (p *Connection) RegisterMessageFilter(filter func(*Message) *Message) *MessageFilter
func (*Connection) RegisterObjectPath ¶
func (p *Connection) RegisterObjectPath(path ObjectPath, handler chan<- *Message)
func (*Connection) RequestName ¶
func (p *Connection) RequestName(busName string, flags NameFlags) *BusName
RequestName requests ownership of a well known bus name.
Name ownership is communicated over the the BusName's channel: a nil value indicates that the name was successfully acquired, and a non-nil value indicates that the name was lost or could not be acquired.
func (*Connection) Send ¶
func (p *Connection) Send(msg *Message) error
func (*Connection) SendWithReply ¶
func (p *Connection) SendWithReply(msg *Message) (*Message, error)
func (*Connection) UnregisterMessageFilter ¶
func (p *Connection) UnregisterMessageFilter(filter *MessageFilter)
func (*Connection) UnregisterObjectPath ¶
func (p *Connection) UnregisterObjectPath(path ObjectPath)
func (*Connection) WatchName ¶
func (p *Connection) WatchName(busName string) (watch *NameWatch, err error)
func (*Connection) WatchSignal ¶
func (p *Connection) WatchSignal(rule *MatchRule) (*SignalWatch, error)
Handle received signals.
type Introspectable ¶
type Introspectable struct {
*ObjectProxy
}
func (*Introspectable) Introspect ¶
func (o *Introspectable) Introspect() (data string, err error)
type MatchRule ¶
type MatchRule struct { Type MessageType Sender string Path ObjectPath Interface string Member string Arg0 string // contains filtered or unexported fields }
Matches all messages with equal type, interface, member, or path. Any missing/invalid fields are not matched against.
type Message ¶
type Message struct { Type MessageType Flags MessageFlag Protocol uint8 // header fields Path ObjectPath Interface string Member string ErrorName string Dest string Sender string // contains filtered or unexported fields }
Message represents a D-Bus message.
It is used to both construct messages for sending on the bus, and to represent messages received from the bus.
There type does not use locks to protect its internal members. Instead, it is expected that users either (a) only modify a message from a single thread (usually the case when constructing a message to send), or (b) treat the message as read only (usually the case when processing a received message).
func NewErrorMessage ¶
NewErrorMessage creates an error message.
This message type should be sent in response to a method call message in the case of a failure.
func NewMethodCallMessage ¶
func NewMethodCallMessage(destination string, path ObjectPath, iface string, member string) *Message
NewMethodCallMessage creates a method call message.
Method arguments can be appended to the message via AppendArgs.
func NewMethodReturnMessage ¶
NewMethodReturnMessage creates a method return message.
This message type represents a successful reply to the method call message passed as an argument.
Return arguments should be appended to the message via AppendArgs.
func NewSignalMessage ¶
func NewSignalMessage(path ObjectPath, iface string, member string) *Message
NewSignalMessage creates a signal message.
Signal messages are used to broadcast messages to interested listeners.
Arguments can be appended to the signal with AppendArgs.
func (*Message) AllArgs ¶
func (p *Message) AllArgs() []interface{}
AllArgs returns all arguments in the message.
This method is equivalent to calling Args and passing pointers to blank interface values for each message argument.
func (*Message) AppendArgs ¶
AppendArgs appends arguments to a message.
Native Go types are converted to equivalent D-Bus types:
- uint8 represents a byte.
- bool represents a boolean value.
- int16, uint16, int32, uint32, int64 and uint64 represent the equivalent integer types.
- string represents a string.
- The dbus.ObjectPath type or any type conforming to the dbus.ObjectPather interface represents an object path.
- arrays and slices represent arrays of the element type.
- maps represent equivalent D-Bus dictionaries.
- structures represent a structure comprising the public members.
- the dbus.Variant type represents a variant.
If an argument can not be serialised in the message, an error is returned. When multiple arguments are being appended, it is possible for some arguments to be successfully appended before the error is generated.
func (*Message) Args ¶
Args decodes one or more arguments from the message.
The arguments should be pointers to variables used to hold the arguments. If the type of the argument does not match the corresponding argument in the message, then an error will be raised.
As a special case, arguments may be decoded into a blank interface value. This may result in a less useful decoded version though (e.g. an "ai" message argument would be decoded as []interface{} instead of []int32).
type MessageFilter ¶
type MessageFilter struct {
// contains filtered or unexported fields
}
type MessageFlag ¶
type MessageFlag uint8
const ( // When applied to method call messages, indicates that no // method return or error message is expected. FlagNoReplyExpected MessageFlag = 1 << iota // Indicates that the message should not autostart the service // if the destination service is not currently running. FlagNoAutoStart )
type MessageType ¶
type MessageType uint8
See the D-Bus tutorial for information about message types.
http://dbus.freedesktop.org/doc/dbus-tutorial.html#messages
const ( TypeInvalid MessageType = iota TypeMethodCall TypeMethodReturn TypeError TypeSignal )
func (MessageType) String ¶
func (t MessageType) String() string
type ObjectPath ¶
type ObjectPath string
func (ObjectPath) ObjectPath ¶
func (o ObjectPath) ObjectPath() ObjectPath
type ObjectPather ¶
type ObjectPather interface {
ObjectPath() ObjectPath
}
type ObjectProxy ¶
type ObjectProxy struct {
// contains filtered or unexported fields
}
ObjectProxy represents a remote object on the bus. It can be used to simplify constructing method calls, and acts as a basis for D-Bus interface client stubs.
func (*ObjectProxy) Call ¶
func (o *ObjectProxy) Call(iface, method string, args ...interface{}) (*Message, error)
Call the given method on the remote object.
On success, the reply message will be returned, whose arguments can be unpacked with its Args() method.
On failure (both network failures and D-Bus level errors), an error will be returned.
func (*ObjectProxy) ObjectPath ¶
func (o *ObjectProxy) ObjectPath() ObjectPath
func (*ObjectProxy) WatchSignal ¶
func (o *ObjectProxy) WatchSignal(iface, member string) (*SignalWatch, error)
type Properties ¶
type Properties struct {
*ObjectProxy
}
func (*Properties) Get ¶
func (o *Properties) Get(interfaceName string, propertyName string) (value interface{}, err error)
type SignalWatch ¶
type SignalWatch struct { C chan *Message // contains filtered or unexported fields }
func (*SignalWatch) Cancel ¶
func (watch *SignalWatch) Cancel() error