Made the stream type non-public.
authorChris Jones <chris@cjones.org>
Wed, 28 Dec 2011 13:14:46 -0700
changeset 22 d6b7b4cbf50d
parent 21 8f6ae5cfc9b9
child 23 b5de44679389
Made the stream type non-public.
stream.go
structs.go
structs_test.go
xmpp.go
xmpp_test.go
--- a/stream.go	Wed Dec 28 13:05:59 2011 -0700
+++ b/stream.go	Wed Dec 28 13:14:46 2011 -0700
@@ -202,7 +202,7 @@
 		case x := <- srvIn:
 			send := false
 			switch obj := x.(type) {
-			case *Stream:
+			case *stream:
 				handleStream(obj)
 			case *Features:
 				cl.handleFeatures(obj)
@@ -237,7 +237,7 @@
 	}
 }
 
-func handleStream(ss *Stream) {
+func handleStream(ss *stream) {
 }
 
 func (cl *Client) handleFeatures(fe *Features) {
@@ -288,7 +288,7 @@
 
 	// Now re-send the initial handshake message to start the new
 	// session.
-	hsOut := &Stream{To: cl.Jid.Domain, Version: Version}
+	hsOut := &stream{To: cl.Jid.Domain, Version: Version}
 	cl.xmlOut <- hsOut
 }
 
@@ -345,7 +345,7 @@
 		log.Println("SASL authentication failed")
 	case "success":
 		log.Println("SASL authentication succeeded")
-		ss := &Stream{To: cl.Jid.Domain, Version: Version}
+		ss := &stream{To: cl.Jid.Domain, Version: Version}
 		cl.xmlOut <- ss
 	}
 }
--- a/structs.go	Wed Dec 28 13:05:59 2011 -0700
+++ b/structs.go	Wed Dec 28 13:14:46 2011 -0700
@@ -30,16 +30,15 @@
 var _ flag.Value = &JID{}
 
 // XMPP's <stream:stream> XML element
-// BUG(cjyar) Hide this.
-type Stream struct {
+type stream struct {
 	To string `xml:"attr"`
 	From string `xml:"attr"`
 	Id string `xml:"attr"`
 	Lang string `xml:"attr"`
 	Version string `xml:"attr"`
 }
-var _ xml.Marshaler = &Stream{}
-var _ fmt.Stringer = &Stream{}
+var _ xml.Marshaler = &stream{}
+var _ fmt.Stringer = &stream{}
 
 // <stream:error>
 // BUG(cjyar) Can this be consolidated with Error? Hide it if not.
@@ -49,7 +48,7 @@
 }
 var _ xml.Marshaler = &StreamError{}
 
-// BUG(cjyar) Replace this with Unrecognized.
+// BUG(cjyar) Replace this with Generic.
 type definedCondition struct {
 	// Must always be in namespace nsStreams
 	XMLName xml.Name
@@ -189,7 +188,7 @@
 	return true
 }
 
-func (s *Stream) MarshalXML() ([]byte, os.Error) {
+func (s *stream) MarshalXML() ([]byte, os.Error) {
 	buf := bytes.NewBuffer(nil)
 	buf.WriteString("<stream:stream")
 	writeField(buf, "xmlns", "jabber:client")
@@ -204,13 +203,13 @@
 	return buf.Bytes(), nil
 }
 
-func (s *Stream) String() string {
+func (s *stream) String() string {
 	result, _ := s.MarshalXML()
 	return string(result)
 }
 
-func parseStream(se xml.StartElement) (*Stream, os.Error) {
-	s := &Stream{}
+func parseStream(se xml.StartElement) (*stream, os.Error) {
+	s := &stream{}
 	for _, attr := range se.Attr {
 		switch strings.ToLower(attr.Name.Local) {
 		case "to":
--- a/structs_test.go	Wed Dec 28 13:05:59 2011 -0700
+++ b/structs_test.go	Wed Dec 28 13:14:46 2011 -0700
@@ -50,18 +50,18 @@
 }
 
 func TestStreamMarshal(t *testing.T) {
-	s := &Stream{To: "bob"}
+	s := &stream{To: "bob"}
 	exp := `<stream:stream xmlns="jabber:client"` +
 		` xmlns:stream="` + nsStream + `" to="bob">`
 	assertMarshal(t, exp, s)
 
-	s = &Stream{To: "bob", From: "alice", Id: "#3", Version: "5.3"}
+	s = &stream{To: "bob", From: "alice", Id: "#3", Version: "5.3"}
 	exp = `<stream:stream xmlns="jabber:client"` +
 		` xmlns:stream="` + nsStream + `" to="bob" from="alice"` +
 		` id="#3" version="5.3">`
 	assertMarshal(t, exp, s)
 
-	s = &Stream{Lang: "en_US"}
+	s = &stream{Lang: "en_US"}
 	exp = `<stream:stream xmlns="jabber:client"` +
 		` xmlns:stream="` + nsStream + `" xml:lang="en_US">`
 	assertMarshal(t, exp, s)
--- a/xmpp.go	Wed Dec 28 13:05:59 2011 -0700
+++ b/xmpp.go	Wed Dec 28 13:14:46 2011 -0700
@@ -123,7 +123,7 @@
 	clOut := startStreamWriter(cl.xmlOut)
 
 	// Initial handshake.
-	hsOut := &Stream{To: jid.Domain, Version: Version}
+	hsOut := &stream{To: jid.Domain, Version: Version}
 	cl.xmlOut <- hsOut
 
 	cl.In = clIn
--- a/xmpp_test.go	Wed Dec 28 13:05:59 2011 -0700
+++ b/xmpp_test.go	Wed Dec 28 13:14:46 2011 -0700
@@ -52,9 +52,9 @@
 	ch := make(chan interface{})
 	go readXml(r, ch)
 	x := <- ch
-	ss, ok := x.(*Stream)
+	ss, ok := x.(*stream)
 	if !ok {
-		t.Fatalf("not Stream: %v", reflect.TypeOf(x))
+		t.Fatalf("not stream: %v", reflect.TypeOf(x))
 	}
 	assertEquals(t, "foo.com", ss.To)
 	assertEquals(t, "bar.org", ss.From)
@@ -95,7 +95,7 @@
 }
 
 func TestWriteStream(t *testing.T) {
-	ss := &Stream{To: "foo.org", From: "bar.com", Id: "42", Lang:
+	ss := &stream{To: "foo.org", From: "bar.com", Id: "42", Lang:
 		"en", Version: "1.0"}
 	str := testWrite(ss)
 	exp := `<stream:stream xmlns="jabber:client"` +