Add preliminary support for IoT control (XEP-0325)

disco_info_form
Mickael Remond 8 years ago
parent adcd2bd467
commit 3a516a43d3

@ -0,0 +1,23 @@
package iot
import "encoding/xml"
type Control struct {
ControlSet ControlSet `xml:",omitempty"`
ControlGetForm ControlGetForm `xml:",omitempty"`
}
type ControlSet struct {
XMLName xml.Name `xml:"urn:xmpp:iot:control set"`
Fields []ControlField `xml:",any"`
}
type ControlGetForm struct {
XMLName xml.Name `xml:"urn:xmpp:iot:control getForm"`
}
type ControlField struct {
XMLName xml.Name
Name string `xml:"name,attr,omitempty"`
Value string `xml:"value,attr,omitempty"`
}

@ -1,11 +1,18 @@
package xmpp
import "encoding/xml"
import (
"encoding/xml"
type clientIQ struct { // info/query
"github.com/processone/gox/xmpp/iot"
)
// info/query
type ClientIQ struct {
XMLName xml.Name `xml:"jabber:client iq"`
Packet
Bind bindBind
Bind bindBind `xml:",omitempty"`
iot.Control
RawXML string `xml:",innerxml"`
// TODO We need to support detecting the IQ namespace / Query packet
// Error clientError
}

@ -1,5 +1,6 @@
package xmpp
// Packet represents the root default structure for an XMPP packet.
type Packet struct {
Id string `xml:"id,attr,omitempty"`
From string `xml:"from,attr,omitempty"`

@ -82,7 +82,7 @@ func next(p *xml.Decoder) (xml.Name, interface{}, error) {
case nsClient + " presence":
nv = &clientPresence{}
case nsClient + " iq":
nv = &clientIQ{}
nv = &ClientIQ{}
default:
return xml.Name{}, nil, errors.New("unexpected XMPP message " +
se.Name.Space + " <" + se.Name.Local + "/>")

@ -153,7 +153,7 @@ func (s *Session) bind(o Options) {
fmt.Fprintf(s.socketProxy, "<iq type='set' id='%s'><bind xmlns='%s'/></iq>", s.PacketId(), nsBind)
}
var iq clientIQ
var iq ClientIQ
if s.err = s.decoder.Decode(&iq); s.err != nil || &iq.Bind == nil {
s.err = errors.New("iq bind result missing: " + s.err.Error())
return
@ -169,7 +169,7 @@ func (s *Session) rfc3921Session(o Options) {
return
}
var iq clientIQ
var iq ClientIQ
// TODO: Do no send unconditionally, check if session is optional and omit it
fmt.Fprintf(s.socketProxy, "<iq type='set' id='%s'><session xmlns='%s'/></iq>", s.PacketId(), nsSession)

Loading…
Cancel
Save