2017-12-14 21:30:07 +01:00
|
|
|
package messages
|
|
|
|
|
2018-02-10 13:34:42 +01:00
|
|
|
import (
|
|
|
|
"encoding/xml"
|
|
|
|
|
|
|
|
"dev.sum7.eu/genofire/yaja/model"
|
|
|
|
)
|
|
|
|
|
|
|
|
type XMLElement struct {
|
|
|
|
XMLName xml.Name
|
|
|
|
InnerXML string `xml:",innerxml"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type Delay struct {
|
|
|
|
Stamp string `xml:"stamp,attr"`
|
|
|
|
}
|
2017-12-14 21:30:07 +01:00
|
|
|
|
|
|
|
type PresenceType string
|
|
|
|
|
|
|
|
const (
|
|
|
|
PresenceTypeUnavailable PresenceType = "unavailable"
|
|
|
|
PresenceTypeSubscribe PresenceType = "subscribe"
|
|
|
|
PresenceTypeSubscribed PresenceType = "subscribed"
|
|
|
|
PresenceTypeUnsubscribe PresenceType = "unsubscribe"
|
|
|
|
PresenceTypeUnsubscribed PresenceType = "unsubscribed"
|
|
|
|
PresenceTypeProbe PresenceType = "probe"
|
|
|
|
PresenceTypeError PresenceType = "error"
|
|
|
|
)
|
|
|
|
|
2018-02-07 19:32:11 +01:00
|
|
|
// PresenceClient element
|
|
|
|
type PresenceClient struct {
|
2018-02-10 13:34:42 +01:00
|
|
|
XMLName xml.Name `xml:"jabber:client presence"`
|
|
|
|
From *model.JID `xml:"from,attr,omitempty"`
|
|
|
|
ID string `xml:"id,attr,omitempty"`
|
|
|
|
To *model.JID `xml:"to,attr,omitempty"`
|
|
|
|
Type PresenceType `xml:"type,attr,omitempty"`
|
|
|
|
Lang string `xml:"lang,attr,omitempty"`
|
2017-12-14 21:30:07 +01:00
|
|
|
|
|
|
|
Show string `xml:"show,omitempty"` // away, chat, dnd, xa
|
|
|
|
Status string `xml:"status,omitempty"` // sb []clientText
|
|
|
|
Priority string `xml:"priority,omitempty"`
|
|
|
|
// Caps *ClientCaps `xml:"c"`
|
2018-02-10 13:34:42 +01:00
|
|
|
Delay *Delay `xml:"delay"`
|
|
|
|
|
|
|
|
Error *ErrorClient
|
2017-12-14 21:30:07 +01:00
|
|
|
}
|
2018-02-07 19:32:11 +01:00
|
|
|
|
2018-02-10 13:34:42 +01:00
|
|
|
type ChatType string
|
|
|
|
|
|
|
|
const (
|
|
|
|
ChatTypeChat ChatType = "chat"
|
|
|
|
ChatTypeGroupchat ChatType = "groupchat"
|
|
|
|
ChatTypeError ChatType = "error"
|
|
|
|
ChatTypeHeadline ChatType = "headline"
|
|
|
|
ChatTypeNormal ChatType = "normal"
|
|
|
|
)
|
|
|
|
|
2018-02-07 19:32:11 +01:00
|
|
|
// MessageClient element
|
|
|
|
type MessageClient struct {
|
2018-02-10 13:34:42 +01:00
|
|
|
XMLName xml.Name `xml:"jabber:client message"`
|
|
|
|
From *model.JID `xml:"from,attr,omitempty"`
|
|
|
|
ID string `xml:"id,attr,omitempty"`
|
|
|
|
To *model.JID `xml:"to,attr,omitempty"`
|
|
|
|
Type ChatType `xml:"type,attr,omitempty"`
|
|
|
|
Lang string `xml:"lang,attr,omitempty"`
|
|
|
|
Subject string `xml:"subject"`
|
|
|
|
Body string `xml:"body"`
|
|
|
|
Thread string `xml:"thread"`
|
|
|
|
// Any hasn't matched element
|
|
|
|
Other []XMLElement `xml:",any"`
|
|
|
|
|
|
|
|
Delay *Delay `xml:"delay"`
|
|
|
|
Error *ErrorClient
|
2018-02-07 19:32:11 +01:00
|
|
|
}
|