fix parsing xml.

This commit is contained in:
mattn 2012-04-04 01:46:01 +09:00
parent f482858a52
commit f8ce0ead60

38
xmpp.go
View File

@ -119,7 +119,7 @@ func (c *Client) Close() error {
func (c *Client) init(user, passwd string) error {
// For debugging: the following causes the plaintext of the connection to be duplicated to stdout.
// c.p = xml.NewParser(tee{c.tls, os.Stdout});
//c.p = xml.NewDecoder(tee{c.tls, os.Stdout});
c.p = xml.NewDecoder(c.tls)
a := strings.SplitN(user, "@", 2)
@ -279,12 +279,12 @@ type tlsFailure struct {
type saslMechanisms struct {
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-sasl mechanisms"`
Mechanism []string
Mechanism []string `xml:"mechanism"`
}
type saslAuth struct {
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-sasl auth"`
Mechanism string `xml:"attr"`
Mechanism string `xml:",attr"`
}
type saslChallenge string
@ -316,10 +316,10 @@ type bindBind struct {
type clientMessage struct {
XMLName xml.Name `xml:"jabber:client message"`
From string `xml:"attr"`
Id string `xml:"attr"`
To string `xml:"attr"`
Type string `xml:"attr"` // chat, error, groupchat, headline, or normal
From string `xml:",attr"`
Id string `xml:",attr"`
To string `xml:",attr"`
Type string `xml:",attr"` // chat, error, groupchat, headline, or normal
// These should technically be []clientText,
// but string is much more convenient.
@ -329,17 +329,17 @@ type clientMessage struct {
}
type clientText struct {
Lang string `xml:"attr"`
Lang string `xml:",attr"`
Body string `xml:"chardata"`
}
type clientPresence struct {
XMLName xml.Name `xml:"jabber:client presence"`
From string `xml:"attr"`
Id string `xml:"attr"`
To string `xml:"attr"`
Type string `xml:"attr"` // error, probe, subscribe, subscribed, unavailable, unsubscribe, unsubscribed
Lang string `xml:"attr"`
From string `xml:",attr"`
Id string `xml:",attr"`
To string `xml:",attr"`
Type string `xml:",attr"` // error, probe, subscribe, subscribed, unavailable, unsubscribe, unsubscribed
Lang string `xml:",attr"`
Show string // away, chat, dnd, xa
Status string // sb []clientText
@ -349,18 +349,18 @@ type clientPresence struct {
type clientIQ struct { // info/query
XMLName xml.Name `xml:"jabber:client iq"`
From string `xml:"attr"`
Id string `xml:"attr"`
To string `xml:"attr"`
Type string `xml:"attr"` // error, get, result, set
From string `xml:",attr"`
Id string `xml:",attr"`
To string `xml:",attr"`
Type string `xml:",attr"` // error, get, result, set
Error clientError
Bind bindBind
}
type clientError struct {
XMLName xml.Name `xml:"jabber:client error"`
Code string `xml:"attr"`
Type string `xml:"attr"`
Code string `xml:",attr"`
Type string `xml:",attr"`
Any xml.Name
Text string
}