...

Package introspect

import "github.com/godbus/dbus/v5/introspect"
Overview
Index

Overview ▾

Package introspect provides some utilities for dealing with the DBus introspection format.

Constants

The introspection data for the org.freedesktop.DBus.Introspectable interface, as a string.

const IntrospectDataString = `
    <interface name="org.freedesktop.DBus.Introspectable">
        <method name="Introspect">
            <arg name="out" direction="out" type="s"/>
        </method>
    </interface>
`

XML document type declaration of the introspection format version 1.0

const IntrospectDeclarationString = `
    <!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
     "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
`

Variables

The introspection data for the org.freedesktop.DBus.Introspectable interface.

var IntrospectData = Interface{
    Name: "org.freedesktop.DBus.Introspectable",
    Methods: []Method{
        {
            Name: "Introspect",
            Args: []Arg{
                {"out", "s", "out"},
            },
        },
    },
}

type Annotation

Annotation is an annotation in the introspection format.

type Annotation struct {
    Name  string `xml:"name,attr"`
    Value string `xml:"value,attr"`
}

type Arg

Arg represents an argument of a method or a signal.

type Arg struct {
    Name      string `xml:"name,attr,omitempty"`
    Type      string `xml:"type,attr"`
    Direction string `xml:"direction,attr,omitempty"`
}

type Interface

Interface describes a DBus interface that is available on the message bus.

type Interface struct {
    Name        string       `xml:"name,attr"`
    Methods     []Method     `xml:"method"`
    Signals     []Signal     `xml:"signal"`
    Properties  []Property   `xml:"property"`
    Annotations []Annotation `xml:"annotation"`
}

type Introspectable

Introspectable implements org.freedesktop.Introspectable.

You can create it by converting the XML-formatted introspection data from a string to an Introspectable or call NewIntrospectable with a Node. Then, export it as org.freedesktop.Introspectable on you object.

type Introspectable string

func NewIntrospectable

func NewIntrospectable(n *Node) Introspectable

NewIntrospectable returns an Introspectable that returns the introspection data that corresponds to the given Node. If n.Interfaces doesn't contain the data for org.freedesktop.DBus.Introspectable, it is added automatically.

func (Introspectable) Introspect

func (i Introspectable) Introspect() (string, *dbus.Error)

Introspect implements org.freedesktop.Introspectable.Introspect.

type Method

Method describes a Method on an Interface as returned by an introspection.

type Method struct {
    Name        string       `xml:"name,attr"`
    Args        []Arg        `xml:"arg"`
    Annotations []Annotation `xml:"annotation"`
}

func Methods

func Methods(v interface{}) []Method

Methods returns the description of the methods of v. This can be used to create a Node which can be passed to NewIntrospectable.

type Node

Node is the root element of an introspection.

type Node struct {
    XMLName    xml.Name    `xml:"node"`
    Name       string      `xml:"name,attr,omitempty"`
    Interfaces []Interface `xml:"interface"`
    Children   []Node      `xml:"node,omitempty"`
}

func Call

func Call(o dbus.BusObject) (*Node, error)

Call calls org.freedesktop.Introspectable.Introspect on a remote object and returns the introspection data.

type Property

Property describes a property of an Interface.

type Property struct {
    Name        string       `xml:"name,attr"`
    Type        string       `xml:"type,attr"`
    Access      string       `xml:"access,attr"`
    Annotations []Annotation `xml:"annotation"`
}

type Signal

Signal describes a Signal emitted on an Interface.

type Signal struct {
    Name        string       `xml:"name,attr"`
    Args        []Arg        `xml:"arg"`
    Annotations []Annotation `xml:"annotation"`
}