# HG changeset patch # User Chris Jones # Date 1325102759 25200 # Node ID 8f6ae5cfc9b9e7ea9a5e4efcbf900fbfa4d2e89a # Parent e119444a111984347a278b9ba39d7fb03b47c247 Renamed Unrecognized to Generic. diff -r e119444a1119 -r 8f6ae5cfc9b9 stream.go --- a/stream.go Wed Dec 28 13:02:23 2011 -0700 +++ b/stream.go Wed Dec 28 13:05:59 2011 -0700 @@ -132,7 +132,7 @@ case "jabber:client presence": obj = &Presence{} default: - obj = &Unrecognized{} + obj = &Generic{} log.Printf("Ignoring unrecognized: %s %s\n", se.Name.Space, se.Name.Local) } @@ -145,7 +145,7 @@ } // BUG(cjyar) If it's a Stanza, use reflection to - // search for any Unrecognized elements and fill in + // search for any Generic elements and fill in // their attributes. // Put it on the channel. @@ -433,7 +433,7 @@ } else { clObj := &auth{XMLName: xml.Name{Space: nsSASL, Local: "failure"}, Any: - &Unrecognized{XMLName: xml.Name{Space: nsSASL, + &Generic{XMLName: xml.Name{Space: nsSASL, Local: "abort"}}} cl.xmlOut <- clObj } @@ -490,13 +490,13 @@ } // Send a request to bind a resource. RFC 3920, section 7. -func (cl *Client) bind(bind *Unrecognized) { +func (cl *Client) bind(bind *Generic) { res := cl.Jid.Resource msg := &Iq{Type: "set", Id: cl.NextId(), Any: - &Unrecognized{XMLName: xml.Name{Space: nsBind, Local: + &Generic{XMLName: xml.Name{Space: nsBind, Local: "bind"}}} if res != "" { - msg.Any.Any = &Unrecognized{XMLName: xml.Name{Local: + msg.Any.Any = &Generic{XMLName: xml.Name{Local: "resource"}, Chardata: res} } f := func(st Stanza) bool { diff -r e119444a1119 -r 8f6ae5cfc9b9 structs.go --- a/structs.go Wed Dec 28 13:02:23 2011 -0700 +++ b/structs.go Wed Dec 28 13:05:59 2011 -0700 @@ -66,7 +66,7 @@ type Features struct { Starttls *starttls Mechanisms mechs - Bind *Unrecognized + Bind *Generic } type starttls struct { @@ -82,7 +82,7 @@ XMLName xml.Name Chardata string `xml:"chardata"` Mechanism string `xml:"attr"` - Any *Unrecognized + Any *Generic } // One of the three core XMPP stanza types: iq, message, presence. See @@ -103,7 +103,7 @@ // A nested error element, if any. XError() *Error // A (non-error) nested element, if any. - XChild() *Unrecognized + XChild() *Generic } // message stanza @@ -114,7 +114,7 @@ Type string `xml:"attr"` Lang string `xml:"attr"` Error *Error - Any *Unrecognized + Any *Generic } var _ xml.Marshaler = &Message{} var _ Stanza = &Message{} @@ -127,7 +127,7 @@ Type string `xml:"attr"` Lang string `xml:"attr"` Error *Error - Any *Unrecognized + Any *Generic } var _ xml.Marshaler = &Presence{} var _ Stanza = &Presence{} @@ -140,7 +140,7 @@ Type string `xml:"attr"` Lang string `xml:"attr"` Error *Error - Any *Unrecognized + Any *Generic } var _ xml.Marshaler = &Iq{} var _ Stanza = &Iq{} @@ -150,18 +150,17 @@ // The error type attribute. Type string `xml:"attr"` // Any nested element, if present. - Any *Unrecognized + Any *Generic } var _ xml.Marshaler = &Error{} // Holds an XML element not described by the more specific types. -// BUG(cjyar) Rename this to something like Generic. -type Unrecognized struct { +type Generic struct { XMLName xml.Name - Any *Unrecognized + Any *Generic Chardata string `xml:"chardata"` } -var _ fmt.Stringer = &Unrecognized{} +var _ fmt.Stringer = &Generic{} func (jid *JID) String() string { result := jid.Domain @@ -261,7 +260,7 @@ } } -func (u *Unrecognized) String() string { +func (u *Generic) String() string { var sub string if u.Any != nil { sub = u.Any.String() @@ -344,7 +343,7 @@ return m.Error } -func (m *Message) XChild() *Unrecognized { +func (m *Message) XChild() *Generic { return m.Any } @@ -380,7 +379,7 @@ return p.Error } -func (p *Presence) XChild() *Unrecognized { +func (p *Presence) XChild() *Generic { return p.Any } @@ -416,7 +415,7 @@ return iq.Error } -func (iq *Iq) XChild() *Unrecognized { +func (iq *Iq) XChild() *Generic { return iq.Any } diff -r e119444a1119 -r 8f6ae5cfc9b9 structs_test.go --- a/structs_test.go Wed Dec 28 13:02:23 2011 -0700 +++ b/structs_test.go Wed Dec 28 13:05:59 2011 -0700 @@ -83,7 +83,7 @@ } func TestIqMarshal(t *testing.T) { - iq := &Iq{Type: "set", Id: "3", Any: &Unrecognized{XMLName: + iq := &Iq{Type: "set", Id: "3", Any: &Generic{XMLName: xml.Name{Space: nsBind, Local: "bind"}}} exp := ``