godock: github.com/sqp/godock/libs/srvdbus/dbuscommon Index | Files

package dbuscommon

import "github.com/sqp/godock/libs/srvdbus/dbuscommon"

Package dbuscommon provides a common dbus server and client base to extend.

Index

Package Files

dbuscommon.go

func EavesDrop Uses

func EavesDrop(match string) (chan *dbus.Message, error)

EavesDrop registers to receive Dbus events for custom parsing.

func NewError Uses

func NewError(msg string) *dbus.Error

NewError creates a dbus error.

func SessionBus Uses

func SessionBus() (*dbus.Conn, chan *dbus.Signal, error)

SessionBus creates a Dbus session with a listening chan.

func ToMapInterface Uses

func ToMapInterface(input map[string]dbus.Variant) map[string]interface{}

ToMapInterface recasts a map of dbus.Variant to a map of interface.

func ToMapVariant Uses

func ToMapVariant(input map[string]interface{}) map[string]dbus.Variant

ToMapVariant recasts a list of args to map[string]dbus.Variant as requested by the DBus API.

type Client Uses

type Client struct {
    dbus.BusObject
    // contains filtered or unexported fields
}

Client is a Dbus client to connect to the internal Dbus server.

func GetClient Uses

func GetClient(SrvObj, SrvPath string, InterfacePath ...string) (*Client, error)

GetClient return a connection to the active instance of the internal Dbus service if any. Return nil, nil if none found. InterfacePath is an optional string to provide if the object use an interface path different from SrvObj

func (*Client) Call Uses

func (cl *Client) Call(method string, args ...interface{}) error

Call calls a method on a Dbus object.

func (*Client) Get Uses

func (cl *Client) Get(method string, answers []interface{}, args ...interface{}) error

Get calls a method on a Dbus object with returned values. The list of answers has to be provided before the command arguments. The type of each field in answer must be a pointer to a value of the same type as expected to be returned by the Dbus method called (its go version).

func (*Client) Go Uses

func (cl *Client) Go(method string, args ...interface{}) error

Go calls a method on a Dbus object without waiting for an answer.

func (*Client) SetTestErr Uses

func (cl *Client) SetTestErr(testErr func(e error, method string))

SetTestErr sets a test error function.

type Server Uses

type Server struct {
    Conn   *dbus.Conn          // Dbus connection.
    Events <-chan *dbus.Signal // Dbus incoming signals channel.
    Log    cdtype.Logger
    // contains filtered or unexported fields
}

Server is a Dbus server with applets service management.

func NewServer Uses

func NewServer(srvObj, srvPath string, log cdtype.Logger) *Server

NewServer creates a Dbus service.

func (*Server) Introspect Uses

func (load *Server) Introspect(obj interface{}, propsSpec map[string]map[string]*prop.Prop) *introspect.Node

Introspect provides introspection data for the DBus service to start.

propsSpec example:

var propsSpec = map[string]map[string]*prop.Prop{
	SrvObj: {
		"Restart": {
			int32(0),
			true,
			prop.EmitTrue,
			func(c *prop.Change) *dbus.Error {
				fmt.Println(c.Name, "changed to", c.Value)
				return nil
			},
		},
	},
}

func (*Server) Start Uses

func (load *Server) Start(obj interface{}, propsSpec map[string]map[string]*prop.Prop) (bool, error)

Start starts the DBus service with the given object. Introspection will be managed and the provided properties exposed. Methods will also be auto discovered.

Package dbuscommon imports 7 packages (graph) and is imported by 6 packages. Updated 2017-09-29. Refresh now. Tools for package owners.