dbus

package
v0.0.0-...-1cbd0a6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2013 License: Apache-2.0, MIT Imports: 20 Imported by: 0

README

Documentation

Look at the API on GoPkgDoc.

Installation

go get launchpad.net/~jamesh/go-dbus/trunk

Usage

An example

// Issue OSD notifications according to the Desktop Notifications Specification 1.1
//      http://people.canonical.com/~agateau/notifications-1.1/spec/index.html
// See also
//      https://wiki.ubuntu.com/NotifyOSD#org.freedesktop.Notifications.Notify
package main

import "launchpad.net/~jamesh/go-dbus/trunk"
import "log"

func main() {
    var (
        err error
        conn *dbus.Connection
    )

    // Connect to Session or System buses.
    if conn, err = dbus.Connect(dbus.SessionBus); err != nil {
        log.Fatal("Connection error:", err)
    }
    if err = conn.Authenticate(); err != nil {
        log.Fatal("Authentication error:", err)
    }

    // Create an object proxy
    obj := conn.Object("org.freedesktop.Notifications", "/org/freedesktop/Notifications")

    // Call object methods.
    reply, err := obj.Call("org.freedesktop.Notifications", "Notify",
        "dbus-tutorial", uint32(0), "",
        "dbus-tutorial", "You've been notified!",
	[]string{}, map[string]dbus.Variant{}, int32(-1))
    if err != nil {
        log.Fatal("Notification error:", err)
    }

    // Parse the reply message
    var notification_id uint32
    if err := reply.GetArgs(&notification_id); err != nil {
        log.Fatal(err)
    }
    log.Print("Notification id:", notification_id)
}

Documentation

Index

Constants

View Source
const (
	BUS_DAEMON_NAME  = "org.freedesktop.DBus"
	BUS_DAEMON_PATH  = ObjectPath("/org/freedesktop/DBus")
	BUS_DAEMON_IFACE = "org.freedesktop.DBus"
)
View Source
const (
	NameFlagAllowReplacement = NameFlags(0x1)
	NameFlagReplaceExisting  = NameFlags(0x2)
	NameFlagDoNotQueue       = NameFlags(0x4)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthDbusCookieSha1

type AuthDbusCookieSha1 struct {
}

func (*AuthDbusCookieSha1) InitialResponse

func (p *AuthDbusCookieSha1) InitialResponse() []byte

func (*AuthDbusCookieSha1) Mechanism

func (p *AuthDbusCookieSha1) Mechanism() []byte

func (*AuthDbusCookieSha1) ProcessData

func (p *AuthDbusCookieSha1) ProcessData(mesg []byte) ([]byte, error)

type AuthExternal

type AuthExternal struct {
}

func (*AuthExternal) InitialResponse

func (p *AuthExternal) InitialResponse() []byte

func (*AuthExternal) Mechanism

func (p *AuthExternal) Mechanism() []byte

func (*AuthExternal) ProcessData

func (p *AuthExternal) ProcessData([]byte) ([]byte, error)

type Authenticator

type Authenticator interface {
	Mechanism() []byte
	InitialResponse() []byte
	ProcessData(challenge []byte) (response []byte, err error)
}

type BusDaemon

type BusDaemon struct {
	*ObjectProxy
}

func (*BusDaemon) AddMatch

func (o *BusDaemon) AddMatch(rule string) (err error)

func (*BusDaemon) GetConnectionUnixProcessID

func (o *BusDaemon) GetConnectionUnixProcessID(busName string) (process uint32, err error)

func (*BusDaemon) GetConnectionUnixUser

func (o *BusDaemon) GetConnectionUnixUser(busName string) (user uint32, err error)

func (*BusDaemon) GetId

func (o *BusDaemon) GetId() (busId string, err error)

func (*BusDaemon) GetNameOwner

func (o *BusDaemon) GetNameOwner(name string) (owner string, err error)

func (*BusDaemon) Hello

func (o *BusDaemon) Hello() (uniqueName string, err error)

func (*BusDaemon) ListActivatableNames

func (o *BusDaemon) ListActivatableNames() (names []string, err error)

func (*BusDaemon) ListNames

func (o *BusDaemon) ListNames() (names []string, err error)

func (*BusDaemon) ListQueuedOwners

func (o *BusDaemon) ListQueuedOwners(name string) (owners []string, err error)

func (*BusDaemon) NameHasOwner

func (o *BusDaemon) NameHasOwner(name string) (hasOwner bool, err error)

func (*BusDaemon) ReleaseName

func (o *BusDaemon) ReleaseName(name string) (result uint32, err error)

func (*BusDaemon) RemoveMatch

func (o *BusDaemon) RemoveMatch(rule string) (err error)

func (*BusDaemon) RequestName

func (o *BusDaemon) RequestName(name string, flags uint32) (result uint32, err error)

func (*BusDaemon) StartServiceByName

func (o *BusDaemon) StartServiceByName(name string, flags uint32) (result uint32, err error)

func (*BusDaemon) UpdateActivationEnvironment

func (o *BusDaemon) UpdateActivationEnvironment(env map[string]string) (err error)

type BusName

type BusName struct {
	Name  string
	Flags NameFlags
	// contains filtered or unexported fields
}

func (*BusName) Release

func (name *BusName) Release() error

type Connection

type Connection struct {
	UniqueName string
	// contains filtered or unexported fields
}

func Connect

func Connect(busType StandardBus) (*Connection, error)

func (*Connection) Authenticate

func (p *Connection) Authenticate() (err error)

func (*Connection) Close

func (p *Connection) Close() error

func (*Connection) Object

func (p *Connection) Object(dest string, path ObjectPath) *ObjectProxy

Retrieve a specified object.

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, nameAcquired func(*BusName), nameLost func(*BusName)) *BusName

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, handler func(newOwner string)) (watch *NameWatch, err error)

func (*Connection) WatchSignal

func (p *Connection) WatchSignal(rule *MatchRule, handler func(*Message)) (*SignalWatch, error)

Handle received signals.

type Error

type Error struct {
	Name    string
	Message string
}

func (*Error) Error

func (e *Error) Error() string

type HasObjectPath

type HasObjectPath interface {
	GetObjectPath() ObjectPath
}

type InterfaceData

type InterfaceData interface {
	GetMethodData(name string) MethodData
	GetSignalData(name string) SignalData
	GetName() string
}

type Introspect

type Introspect interface {
	GetInterfaceData(name string) InterfaceData
}

func NewIntrospect

func NewIntrospect(xmlIntro string) (Introspect, error)

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.

func (*MatchRule) String

func (p *MatchRule) String() string

A string representation af the MatchRule (D-Bus variant map).

type Message

type Message struct {
	Type     MessageType
	Flags    MessageFlag
	Protocol uint8

	// header fields
	Path      ObjectPath
	Iface     string
	Member    string
	ErrorName string

	Dest   string
	Sender string
	// contains filtered or unexported fields
}

func NewErrorMessage

func NewErrorMessage(methodCall *Message, errorName string, message string) *Message

func NewMethodCallMessage

func NewMethodCallMessage(destination string, path ObjectPath, iface string, member string) *Message

func NewMethodReturnMessage

func NewMethodReturnMessage(methodCall *Message) *Message

func NewSignalMessage

func NewSignalMessage(path ObjectPath, iface string, member string) *Message

func (*Message) AppendArgs

func (p *Message) AppendArgs(args ...interface{}) error

func (*Message) AsError

func (p *Message) AsError() error

func (*Message) GetAllArgs

func (p *Message) GetAllArgs() []interface{}

func (*Message) GetArgs

func (p *Message) GetArgs(args ...interface{}) error

func (*Message) WriteTo

func (p *Message) WriteTo(w io.Writer) (int64, error)

type MessageFilter

type MessageFilter struct {
	// contains filtered or unexported fields
}

type MessageFlag

type MessageFlag uint8
const (
	FlagNoReplyExpected MessageFlag = 1 << iota
	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 MethodData

type MethodData interface {
	GetName() string
	GetInSignature() Signature
	GetOutSignature() Signature
}

type NameFlags

type NameFlags uint32

type NameWatch

type NameWatch struct {
	// contains filtered or unexported fields
}

func (*NameWatch) Cancel

func (watch *NameWatch) Cancel() error

type ObjectPath

type ObjectPath string

func (ObjectPath) GetObjectPath

func (o ObjectPath) GetObjectPath() ObjectPath

type ObjectProxy

type ObjectProxy struct {
	// contains filtered or unexported fields
}

func (*ObjectProxy) Call

func (o *ObjectProxy) Call(iface, method string, args ...interface{}) (*Message, error)

func (*ObjectProxy) GetObjectPath

func (o *ObjectProxy) GetObjectPath() ObjectPath

func (*ObjectProxy) WatchSignal

func (o *ObjectProxy) WatchSignal(iface, member string, handler func(*Message)) (*SignalWatch, error)

type Properties

type Properties struct {
	*ObjectProxy
}

func (*Properties) Get

func (o *Properties) Get(interfaceName string, propertyName string) (value interface{}, err error)

func (*Properties) GetAll

func (o *Properties) GetAll(interfaceName string) (props map[string]Variant, err error)

func (*Properties) Set

func (o *Properties) Set(interfaceName string, propertyName string, value interface{}) (err error)

type SignalData

type SignalData interface {
	GetName() string
	GetSignature() Signature
}

type SignalWatch

type SignalWatch struct {
	// contains filtered or unexported fields
}

func (*SignalWatch) Cancel

func (watch *SignalWatch) Cancel() error

type Signature

type Signature string

func SignatureOf

func SignatureOf(t reflect.Type) (Signature, error)

func (Signature) NextType

func (sig Signature) NextType(offset int) (next int, err error)

func (Signature) Validate

func (sig Signature) Validate() (err error)

Validate that the signature is a valid string of type codes

type StandardBus

type StandardBus int
const (
	SessionBus StandardBus = iota
	SystemBus
)

type Variant

type Variant struct {
	Value interface{}
}

func (*Variant) GetVariantSignature

func (v *Variant) GetVariantSignature() (Signature, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL