desc

package
Version: v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2020 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package desc implements data types to map to the content from description XML files

Index

Constants

View Source
const (
	// UPNPRootDeviceType is the UPnP root device indicator
	UPNPRootDeviceType = "upnp:rootdevice"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	Name      string     `xml:"name"`
	Arguments []Argument `xml:"argumentList>argument"`
}

Action represents an action from a service description

func (*Action) Trim

func (me *Action) Trim()

Trim removes leading and trailing spaces for some attributes

func (*Action) Validate

func (me *Action) Validate(res *[]string) (ok bool)

Validate checks whether the attribute values are OK. Problem messages are added to res.

type AllowedValueRange

type AllowedValueRange struct {
	Minimum string `xml:"minimum"`
	Maximum string `xml:"maximum"`
	Step    string `xml:"step"`
}

AllowedValueRange represents the allowed value range of aa state variable

func (*AllowedValueRange) IsZero

func (me *AllowedValueRange) IsZero() bool

IsZero returns true if the allowed value range is empty, otherwise false

type Argument

type Argument struct {
	Name                 string `xml:"name"`
	Direction            string `xml:"direction"`
	RelatedStateVariable string `xml:"relatedStateVariable"`
}

Argument represents an argument from a service description

func (*Argument) Trim

func (me *Argument) Trim()

Trim removes leading and trailing spaces for some attributes

func (*Argument) Validate

func (me *Argument) Validate(res *[]string) (ok bool)

Validate checks whether the attribute values are OK. Problem messages are added to res.

type Device

type Device struct {
	DeviceType       string             `xml:"deviceType"`
	FriendlyName     string             `xml:"friendlyName"`
	Manufacturer     string             `xml:"manufacturer"`
	ManufacturerURL  string             `xml:"manufacturerURL"`
	ModelDescription string             `xml:"modelDescription"`
	ModelName        string             `xml:"modelName"`
	ModelNumber      string             `xml:"modelNumber"`
	ModelURL         string             `xml:"modelURL"`
	SerialNumber     string             `xml:"serialNumber"`
	UDN              string             `xml:"UDN"`
	UPC              string             `xml:"UPC,omitempty"`
	Icons            []Icon             `xml:"iconList>icon,omitempty"`
	Services         []ServiceReference `xml:"serviceList>service,omitempty"`
	Devices          []Device           `xml:"deviceList>device,omitempty"`
	PresentationURL  string             `xml:"presentationURL"`
}

Device represents a device description

func (*Device) Trim

func (me *Device) Trim()

Trim removes leading and trailing spaces for some attributes

func (Device) Validate

func (me Device) Validate(res *[]string) (ok bool)

Validate checks whether the attribute values are OK. Problem messages are added to res.

type Icon

type Icon struct {
	Mimetype string `xml:"mimetype"`
	Width    uint32 `xml:"width"`
	Height   uint32 `xml:"height"`
	Depth    uint32 `xml:"depth"`
	URL      string `xml:"url"`
}

Icon represents the icon part of a device description

type RootDevice

type RootDevice struct {
	XMLName     xml.Name    `xml:"urn:schemas-upnp-org:device-1-0 root"`
	ConfigID    uint32      `xml:"configId,attr"`
	SpecVersion SpecVersion `xml:"specVersion"`
	Device      Device      `xml:"device"`
}

RootDevice represents a device description as described in https://openconnectivity.org/upnp-specs/UPnP-arch-DeviceArchitecture-v2.0-20200417.pdf

func LoadRootDevice

func LoadRootDevice(filepath string) (dvc *RootDevice, err error)

LoadRootDevice reads a root device description file and creates a root device object from it

func (*RootDevice) Hash

func (me *RootDevice) Hash() (hash []byte, err error)

Hash calculates the md5 hash of the XML representation of a root device description

func (*RootDevice) Validate

func (me *RootDevice) Validate() (ok bool, res []string)

Validate checks whether the attribute values are OK. Problem messages are stored in res.

type Service

type Service struct {
	XMLName           xml.Name        `xml:"urn:schemas-upnp-org:service-1-0 scpd"`
	ConfigID          uint32          `xml:"configId,attr"`
	SpecVersion       SpecVersion     `xml:"specVersion"`
	Actions           []Action        `xml:"actionList>action"`
	ServiceStateTable []StateVariable `xml:"serviceStateTable>stateVariable"`
}

Service represents a service description as described in https://openconnectivity.org/upnp-specs/UPnP-arch-DeviceArchitecture-v2.0-20200417.pdf

func LoadService

func LoadService(filepath string) (svc *Service, err error)

LoadService reads a service description file and creates a service object from it

func (*Service) Hash

func (me *Service) Hash() (hash []byte, err error)

Hash calculates the md5 hash of the XML representation of a service description

func (*Service) Validate

func (me *Service) Validate() (ok bool, res []string)

Validate checks whether the attribute values are OK. Problem messages are added to res.

type ServiceMap

type ServiceMap map[string]*Service

ServiceMap maps a service id to the correspondingh service description

type ServiceReference

type ServiceReference struct {
	ServiceType string `xml:"serviceType"`
	ServiceID   string `xml:"serviceId"`
	SCPDURL     string `xml:"SCPDURL"`
	ControlURL  string `xml:"controlURL"`
	EventSubURL string `xml:"eventSubURL"`
}

ServiceReference represents the service information that is contained in a device description

func (*ServiceReference) Trim

func (me *ServiceReference) Trim()

Trim removes leading and trailing spaces for some attributes

func (*ServiceReference) Validate

func (me *ServiceReference) Validate(res *[]string) (ok bool)

Validate executes a trim and checks whether the attribute values are OK. Problem messages are added to res.

type SpecVersion

type SpecVersion struct {
	Major int32 `xml:"major"`
	Minor int32 `xml:"minor"`
}

SpecVersion is part of a RootDevice, describes the version of the specification that the data adheres to.

type StateVariable

type StateVariable struct {
	Name              string            `xml:"name"`
	SendEvents        string            `xml:"sendEvents,attr,omitempty"`
	Multicast         string            `xml:"multicast,attr,omitempty"`
	DataType          string            `xml:"dataType"`
	DefaultValue      string            `xml:"defaultValue"`
	AllowedValueList  []string          `xml:"allowedValueList>allowedValue,omitempty"`
	AllowedValueRange AllowedValueRange `xml:"allowedValueRange,omitempty"`
}

StateVariable represents a state variable from a service description

func (*StateVariable) Trim

func (me *StateVariable) Trim()

Trim removes leading and trailing spaces for some attributes

func (*StateVariable) Validate

func (me *StateVariable) Validate(res *[]string) (ok bool)

Validate checks whether the attribute values are OK. Problem messages are added to res.

Jump to

Keyboard shortcuts

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