40 lines
898 B
Go
40 lines
898 B
Go
package main
|
|
|
|
// Implementation of XEP-0054
|
|
// https://xmpp.org/extensions/xep-0054.html
|
|
|
|
import (
|
|
"encoding/xml"
|
|
"gosrc.io/xmpp/stanza"
|
|
)
|
|
|
|
type VCard struct {
|
|
XMLName xml.Name `xml:"vcard-temp vCard"`
|
|
Photo Photo `xml:"PHOTO"`
|
|
ResultSet *stanza.ResultSet `xml:"set,omitempty"`
|
|
}
|
|
|
|
type VCardUpdate struct {
|
|
stanza.PresExtension
|
|
XMLName xml.Name `xml:"vcard-temp:x:update x"`
|
|
Photo string `xml:"photo"`
|
|
}
|
|
|
|
func (v *VCard) Namespace() string {
|
|
return v.XMLName.Space
|
|
}
|
|
|
|
func (v *VCard) GetSet() *stanza.ResultSet {
|
|
return v.ResultSet
|
|
}
|
|
|
|
type Photo struct {
|
|
Type string `xml:"TYPE"`
|
|
Binval string `xml:"BINVAL"`
|
|
}
|
|
|
|
func init() {
|
|
stanza.TypeRegistry.MapExtension(stanza.PKTIQ, xml.Name{Space: "vcard-temp", Local: "vCard"}, VCard{})
|
|
stanza.TypeRegistry.MapExtension(stanza.PKTPresence, xml.Name{Space: "vcard-temp:x:update", Local: "x"}, VCardUpdate{})
|
|
}
|