Fixed up marshaling of the extra fields in presence and message.
authorChris Jones <chris@cjones.org>
Mon, 02 Jan 2012 09:58:44 -0700
changeset 49 8e140810be02
parent 48 6b402eb552f5
child 50 08d2b9deb710
Fixed up marshaling of the extra fields in presence and message.
structs.go
--- a/structs.go	Mon Jan 02 09:58:17 2012 -0700
+++ b/structs.go	Mon Jan 02 09:58:44 2012 -0700
@@ -301,6 +301,34 @@
 	}
 	buf.WriteString(">")
 
+	if m, ok := st.(*Message) ; ok {
+		err := xml.Marshal(buf, m.Subject)
+		if err != nil {
+			return nil, err
+		}
+		err = xml.Marshal(buf, m.Body)
+		if err != nil {
+			return nil, err
+		}
+		err = xml.Marshal(buf, m.Thread)
+		if err != nil {
+			return nil, err
+		}
+	}
+	if p, ok := st.(*Presence) ; ok {
+		err := xml.Marshal(buf, p.Show)
+		if err != nil {
+			return nil, err
+		}
+		err = xml.Marshal(buf, p.Status)
+		if err != nil {
+			return nil, err
+		}
+		err = xml.Marshal(buf, p.Priority)
+		if err != nil {
+			return nil, err
+		}
+	}
 	if st.GetNested() != nil {
 		xml.Marshal(buf, st.GetNested())
 	} else if st.generic() != nil {
@@ -369,22 +397,6 @@
 	return marshalXML(m)
 }
 
-func (m *Message) InnerMarshal(w io.Writer) os.Error {
-	err := xml.Marshal(w, m.Subject)
-	if err != nil {
-		return err
-	}
-	err = xml.Marshal(w, m.Body)
-	if err != nil {
-		return err
-	}
-	err = xml.Marshal(w, m.Thread)
-	if err != nil {
-		return err
-	}
-	return nil
-}
-
 func (p *Presence) GetName() string {
 	return "presence"
 }
@@ -433,22 +445,6 @@
 	return marshalXML(p)
 }
 
-func (p *Presence) InnerMarshal(w io.Writer) os.Error {
-	err := xml.Marshal(w, p.Show)
-	if err != nil {
-		return err
-	}
-	err = xml.Marshal(w, p.Status)
-	if err != nil {
-		return err
-	}
-	err = xml.Marshal(w, p.Priority)
-	if err != nil {
-		return err
-	}
-	return nil
-}
-
 func (iq *Iq) GetName() string {
 	return "iq"
 }