dbus

package module
v0.0.0-...-1ef31ba Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2012 License: MIT Imports: 11 Imported by: 0

README

Documentation

Look at the API on GoPkgDoc.

Installation

goinstall github.com/norisatir/go-dbus

Usage

// 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 "github.com/norisatir/go-dbus"
import "log"

func main() {
    var (
        err error
        conn *dbus.Connection
        out []interface{}
    )

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

    // Get objects.
    obj := conn.GetObject("org.freedesktop.Notifications", "/org/freedesktop/Notifications")

    // Introspect objects.
    out, err = conn.CallMethod(
        conn.Interface(obj, "org.freedesktop.DBus.Introspectable"), "Introspect")
    if err != nil {
        log.Fatal("Introspect error:", err)
    }
    var intro dbus.Introspect
    intro, err = dbus.NewIntrospect(out[0].(string))
    method := intro.GetInterfaceData("org.freedesktop.Notifications").GetMethodData("Notify")
    log.Printf("%s in:%s out:%s", method.GetName(), method.GetInSignature(), method.GetOutSignature())

    // Call object methods.
    out, err = conn.CallMethod(
        conn.Interface(
            conn.GetObject("org.freedesktop.Notifications", "/org/freedesktop/Notifications"),
            "org.freedesktop.Notifications"),
        "Notify",
		"dbus-tutorial", uint32(0), "",
        "dbus-tutorial", "You've been notified!",
		[]interface{}{}, map[string]interface{}{}, int32(-1))
    if err != nil {
        log.Fatal("Notification error:", err)
    }
    log.Print("Notification id:", out[0])
}

Documentation

Index

Constants

View Source
const (
	STARTING = iota
	WAITING_FOR_DATA
	WAITING_FOR_OK
	WAITING_FOR_REJECT
	AUTH_CONTINUE
	AUTH_OK
	AUTH_ERROR
	AUTHENTICATED
	AUTH_NEXT
)
View Source
const (
	INVALID       = 0
	METHOD_CALL   = 1
	METHOD_RETURN = 2
	ERROR         = 3
	SIGNAL        = 4
)
View Source
const (
	NO_REPLY_EXPECTED = 0x1
	NO_AUTO_START     = 0x2
)

Variables

View Source
var (
	ErrAuthUnknownCommand = errors.New("UnknowAuthCommand")
	ErrAuthFailed         = errors.New("AuthenticationFailed")
)

Functions

func Parse

func Parse(buff []byte, sig string, index int) (slice []interface{}, bufIdx int, err error)

Types

type AuthExternal

type AuthExternal struct {
}

func (*AuthExternal) Authenticate

func (p *AuthExternal) Authenticate() string

func (*AuthExternal) Mechanism

func (p *AuthExternal) Mechanism() string

type Authenticator

type Authenticator interface {
	Mechanism() string
	Authenticate() string
}

type Connection

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

func Connect

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

func (*Connection) AddSignalHandler

func (p *Connection) AddSignalHandler(mr *MatchRule, proc func(*Message))

func (*Connection) CallMethod

func (p *Connection) CallMethod(iface *Interface, name string, args ...interface{}) ([]interface{}, error)

func (*Connection) EmitSignal

func (p *Connection) EmitSignal(iface *Interface, name string, args ...interface{}) error

func (*Connection) GetObject

func (p *Connection) GetObject(dest string, path string) *Object

func (*Connection) Initialize

func (p *Connection) Initialize() error

func (*Connection) Interface

func (p *Connection) Interface(obj *Object, name string) *Interface

type Interface

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

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 MatchRule

type MatchRule struct {
	Type      string
	Interface string
	Member    string
	Path      string
}

type Message

type Message struct {
	Type     MessageType
	Flags    MessageFlag
	Protocol int

	Path   string
	Dest   string
	Iface  string
	Member string
	Sig    string
	Params []interface{}

	ErrorName string
	// contains filtered or unexported fields
}

func NewMessage

func NewMessage() *Message

type MessageFlag

type MessageFlag int

type MessageType

type MessageType int

type MethodData

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

type Object

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

type SignalData

type SignalData interface {
	GetSignature() string
}

type StandardBus

type StandardBus int
const (
	SessionBus StandardBus = iota
	SystemBus
)

Jump to

Keyboard shortcuts

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