equal
deleted
inserted
replaced
151 var _ xml.Marshaler = &Iq{} |
151 var _ xml.Marshaler = &Iq{} |
152 var _ Stanza = &Iq{} |
152 var _ Stanza = &Iq{} |
153 |
153 |
154 // Describes an XMPP stanza error. See RFC 3920, Section 9.3. |
154 // Describes an XMPP stanza error. See RFC 3920, Section 9.3. |
155 type Error struct { |
155 type Error struct { |
|
156 XMLName xml.Name `xml:"error"` |
156 // The error type attribute. |
157 // The error type attribute. |
157 Type string `xml:"attr"` |
158 Type string `xml:"attr"` |
158 // Any nested element, if present. |
159 // Any nested element, if present. |
159 Any *Generic |
160 Any *Generic |
160 } |
161 } |
161 var _ xml.Marshaler = &Error{} |
|
162 var _ os.Error = &Error{} |
162 var _ os.Error = &Error{} |
163 |
163 |
164 // Used for resource binding as a nested element inside <iq/>. |
164 // Used for resource binding as a nested element inside <iq/>. |
165 type bindIq struct { |
165 type bindIq struct { |
166 XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-bind bind"` |
166 XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-bind bind"` |
247 } |
247 } |
248 buf.WriteString("</stream:error>") |
248 buf.WriteString("</stream:error>") |
249 return buf.Bytes(), nil |
249 return buf.Bytes(), nil |
250 } |
250 } |
251 |
251 |
252 // BUG(cjyar) We can probably eliminate this if we use an |
|
253 // appropriately-tagged XMLName field. |
|
254 |
|
255 func (e *errText) MarshalXML() ([]byte, os.Error) { |
252 func (e *errText) MarshalXML() ([]byte, os.Error) { |
256 buf := bytes.NewBuffer(nil) |
253 buf := bytes.NewBuffer(nil) |
257 buf.WriteString("<text") |
254 buf.WriteString("<text") |
258 writeField(buf, "xmlns", NsStreams) |
255 writeField(buf, "xmlns", NsStreams) |
259 writeField(buf, "xml:lang", e.Lang) |
256 writeField(buf, "xml:lang", e.Lang) |
316 buf.WriteString(st.GetName()) |
313 buf.WriteString(st.GetName()) |
317 buf.WriteString(">") |
314 buf.WriteString(">") |
318 return buf.Bytes(), nil |
315 return buf.Bytes(), nil |
319 } |
316 } |
320 |
317 |
321 // BUG(cjyar) We can probably eliminate this if we add an XMLName |
318 func (er *Error) String() string { |
322 // field with an appropriate tag. |
|
323 func (er *Error) MarshalXML() ([]byte, os.Error) { |
|
324 buf := bytes.NewBuffer(nil) |
319 buf := bytes.NewBuffer(nil) |
325 buf.WriteString("<error") |
320 xml.Marshal(buf, er) |
326 writeField(buf, "type", er.Type) |
321 return buf.String() |
327 buf.WriteString(">") |
|
328 if er.Any != nil { |
|
329 xml.Marshal(buf, er.Any) |
|
330 } |
|
331 buf.WriteString("</error>") |
|
332 return buf.Bytes(), nil |
|
333 } |
|
334 |
|
335 func (er *Error) String() string { |
|
336 bytes, _ := er.MarshalXML() |
|
337 return string(bytes) |
|
338 } |
322 } |
339 |
323 |
340 func (m *Message) GetName() string { |
324 func (m *Message) GetName() string { |
341 return "message" |
325 return "message" |
342 } |
326 } |