equal
deleted
inserted
replaced
91 GetType() string |
91 GetType() string |
92 // The xml:lang attribute. |
92 // The xml:lang attribute. |
93 GetLang() string |
93 GetLang() string |
94 // A nested error element, if any. |
94 // A nested error element, if any. |
95 GetError() *Error |
95 GetError() *Error |
96 // A (non-error) nested element, if any. |
96 // Zero or more (non-error) nested elements. These will be in |
97 // BUG(cjyar) This should return a slice. |
97 // namespaces managed by extensions. |
98 GetNested() interface{} |
98 GetNested() []interface{} |
99 setNested(interface{}) |
99 addNested(interface{}) |
100 generic() *Generic |
|
101 innerxml() string |
100 innerxml() string |
102 } |
101 } |
103 |
102 |
104 // message stanza |
103 // message stanza |
105 type Message struct { |
104 type Message struct { |
111 Innerxml string `xml:"innerxml"` |
110 Innerxml string `xml:"innerxml"` |
112 Error *Error |
111 Error *Error |
113 Subject *Generic |
112 Subject *Generic |
114 Body *Generic |
113 Body *Generic |
115 Thread *Generic |
114 Thread *Generic |
116 Any *Generic |
115 Nested []interface{} |
117 Nested interface{} |
|
118 } |
116 } |
119 var _ xml.Marshaler = &Message{} |
117 var _ xml.Marshaler = &Message{} |
120 var _ Stanza = &Message{} |
118 var _ Stanza = &Message{} |
121 |
119 |
122 // presence stanza |
120 // presence stanza |
129 Innerxml string `xml:"innerxml"` |
127 Innerxml string `xml:"innerxml"` |
130 Error *Error |
128 Error *Error |
131 Show *Generic |
129 Show *Generic |
132 Status *Generic |
130 Status *Generic |
133 Priority *Generic |
131 Priority *Generic |
134 Any *Generic |
132 Nested []interface{} |
135 Nested interface{} |
|
136 } |
133 } |
137 var _ xml.Marshaler = &Presence{} |
134 var _ xml.Marshaler = &Presence{} |
138 var _ Stanza = &Presence{} |
135 var _ Stanza = &Presence{} |
139 |
136 |
140 // iq stanza |
137 // iq stanza |
144 Id string `xml:"attr"` |
141 Id string `xml:"attr"` |
145 Type string `xml:"attr"` |
142 Type string `xml:"attr"` |
146 Lang string `xml:"attr"` |
143 Lang string `xml:"attr"` |
147 Innerxml string `xml:"innerxml"` |
144 Innerxml string `xml:"innerxml"` |
148 Error *Error |
145 Error *Error |
149 Any *Generic |
146 Nested []interface{} |
150 Nested interface{} |
|
151 } |
147 } |
152 var _ xml.Marshaler = &Iq{} |
148 var _ xml.Marshaler = &Iq{} |
153 var _ Stanza = &Iq{} |
149 var _ Stanza = &Iq{} |
154 |
150 |
155 // Describes an XMPP stanza error. See RFC 3920, Section 9.3. |
151 // Describes an XMPP stanza error. See RFC 3920, Section 9.3. |
333 err = xml.Marshal(buf, p.Priority) |
329 err = xml.Marshal(buf, p.Priority) |
334 if err != nil { |
330 if err != nil { |
335 return nil, err |
331 return nil, err |
336 } |
332 } |
337 } |
333 } |
338 if st.GetNested() != nil { |
334 if nested := st.GetNested() ; nested != nil { |
339 xml.Marshal(buf, st.GetNested()) |
335 for _, n := range(nested) { |
340 } else if st.generic() != nil { |
336 xml.Marshal(buf, n) |
341 xml.Marshal(buf, st.generic()) |
337 } |
342 } else if st.innerxml() != "" { |
338 } else if st.innerxml() != "" { |
343 buf.WriteString(st.innerxml()) |
339 buf.WriteString(st.innerxml()) |
344 } |
340 } |
345 |
341 |
346 buf.WriteString("</") |
342 buf.WriteString("</") |
381 |
377 |
382 func (m *Message) GetError() *Error { |
378 func (m *Message) GetError() *Error { |
383 return m.Error |
379 return m.Error |
384 } |
380 } |
385 |
381 |
386 func (m *Message) GetNested() interface{} { |
382 func (m *Message) GetNested() []interface{} { |
387 return m.Nested |
383 return m.Nested |
388 } |
384 } |
389 |
385 |
390 func (m *Message) setNested(n interface{}) { |
386 func (m *Message) addNested(n interface{}) { |
391 m.Nested = n |
387 m.Nested = append(m.Nested, n) |
392 } |
|
393 |
|
394 func (m *Message) generic() *Generic { |
|
395 return m.Any |
|
396 } |
388 } |
397 |
389 |
398 func (m *Message) innerxml() string { |
390 func (m *Message) innerxml() string { |
399 return m.Innerxml |
391 return m.Innerxml |
400 } |
392 } |
429 |
421 |
430 func (p *Presence) GetError() *Error { |
422 func (p *Presence) GetError() *Error { |
431 return p.Error |
423 return p.Error |
432 } |
424 } |
433 |
425 |
434 func (p *Presence) GetNested() interface{} { |
426 func (p *Presence) GetNested() []interface{} { |
435 return p.Nested |
427 return p.Nested |
436 } |
428 } |
437 |
429 |
438 func (p *Presence) setNested(n interface{}) { |
430 func (p *Presence) addNested(n interface{}) { |
439 p.Nested = n |
431 p.Nested = append(p.Nested, n) |
440 } |
|
441 |
|
442 func (p *Presence) generic() *Generic { |
|
443 return p.Any |
|
444 } |
432 } |
445 |
433 |
446 func (p *Presence) innerxml() string { |
434 func (p *Presence) innerxml() string { |
447 return p.Innerxml |
435 return p.Innerxml |
448 } |
436 } |
477 |
465 |
478 func (iq *Iq) GetError() *Error { |
466 func (iq *Iq) GetError() *Error { |
479 return iq.Error |
467 return iq.Error |
480 } |
468 } |
481 |
469 |
482 func (iq *Iq) GetNested() interface{} { |
470 func (iq *Iq) GetNested() []interface{} { |
483 return iq.Nested |
471 return iq.Nested |
484 } |
472 } |
485 |
473 |
486 func (iq *Iq) setNested(n interface{}) { |
474 func (iq *Iq) addNested(n interface{}) { |
487 iq.Nested = n |
475 iq.Nested = append(iq.Nested, n) |
488 } |
|
489 |
|
490 func (iq *Iq) generic() *Generic { |
|
491 return iq.Any |
|
492 } |
476 } |
493 |
477 |
494 func (iq *Iq) innerxml() string { |
478 func (iq *Iq) innerxml() string { |
495 return iq.Innerxml |
479 return iq.Innerxml |
496 } |
480 } |