introspect.go 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // Package introspect provides some utilities for dealing with the DBus
  2. // introspection format.
  3. package introspect
  4. import "encoding/xml"
  5. // The introspection data for the org.freedesktop.DBus.Introspectable interface.
  6. var IntrospectData = Interface{
  7. Name: "org.freedesktop.DBus.Introspectable",
  8. Methods: []Method{
  9. {
  10. Name: "Introspect",
  11. Args: []Arg{
  12. {"out", "s", "out"},
  13. },
  14. },
  15. },
  16. }
  17. // XML document type declaration of the introspection format version 1.0
  18. const IntrospectDeclarationString = `
  19. <!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
  20. "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
  21. `
  22. // The introspection data for the org.freedesktop.DBus.Introspectable interface,
  23. // as a string.
  24. const IntrospectDataString = `
  25. <interface name="org.freedesktop.DBus.Introspectable">
  26. <method name="Introspect">
  27. <arg name="out" direction="out" type="s"/>
  28. </method>
  29. </interface>
  30. `
  31. // Node is the root element of an introspection.
  32. type Node struct {
  33. XMLName xml.Name `xml:"node"`
  34. Name string `xml:"name,attr,omitempty"`
  35. Interfaces []Interface `xml:"interface"`
  36. Children []Node `xml:"node,omitempty"`
  37. }
  38. // Interface describes a DBus interface that is available on the message bus.
  39. type Interface struct {
  40. Name string `xml:"name,attr"`
  41. Methods []Method `xml:"method"`
  42. Signals []Signal `xml:"signal"`
  43. Properties []Property `xml:"property"`
  44. Annotations []Annotation `xml:"annotation"`
  45. }
  46. // Method describes a Method on an Interface as returned by an introspection.
  47. type Method struct {
  48. Name string `xml:"name,attr"`
  49. Args []Arg `xml:"arg"`
  50. Annotations []Annotation `xml:"annotation"`
  51. }
  52. // Signal describes a Signal emitted on an Interface.
  53. type Signal struct {
  54. Name string `xml:"name,attr"`
  55. Args []Arg `xml:"arg"`
  56. Annotations []Annotation `xml:"annotation"`
  57. }
  58. // Property describes a property of an Interface.
  59. type Property struct {
  60. Name string `xml:"name,attr"`
  61. Type string `xml:"type,attr"`
  62. Access string `xml:"access,attr"`
  63. Annotations []Annotation `xml:"annotation"`
  64. }
  65. // Arg represents an argument of a method or a signal.
  66. type Arg struct {
  67. Name string `xml:"name,attr,omitempty"`
  68. Type string `xml:"type,attr"`
  69. Direction string `xml:"direction,attr,omitempty"`
  70. }
  71. // Annotation is an annotation in the introspection format.
  72. type Annotation struct {
  73. Name string `xml:"name,attr"`
  74. Value string `xml:"value,attr"`
  75. }