structs.go
changeset 20 e119444a1119
parent 17 d269d9c0fc8e
child 21 8f6ae5cfc9b9
equal deleted inserted replaced
19:e923f28d65aa 20:e119444a1119
    19 
    19 
    20 // JID represents an entity that can communicate with other
    20 // JID represents an entity that can communicate with other
    21 // entities. It looks like node@domain/resource. Node and resource are
    21 // entities. It looks like node@domain/resource. Node and resource are
    22 // sometimes optional.
    22 // sometimes optional.
    23 type JID struct {
    23 type JID struct {
    24 	// TODO Make this not a pointer.
    24 	// BUG(cjyar) Make this not a pointer.
    25 	Node *string
    25 	Node *string
    26 	Domain string
    26 	Domain string
    27 	Resource string
    27 	Resource string
    28 }
    28 }
    29 var _ fmt.Stringer = &JID{}
    29 var _ fmt.Stringer = &JID{}
    30 var _ flag.Value = &JID{}
    30 var _ flag.Value = &JID{}
    31 
    31 
    32 // XMPP's <stream:stream> XML element
    32 // XMPP's <stream:stream> XML element
    33 // TODO Hide this.
    33 // BUG(cjyar) Hide this.
    34 type Stream struct {
    34 type Stream struct {
    35 	To string `xml:"attr"`
    35 	To string `xml:"attr"`
    36 	From string `xml:"attr"`
    36 	From string `xml:"attr"`
    37 	Id string `xml:"attr"`
    37 	Id string `xml:"attr"`
    38 	Lang string `xml:"attr"`
    38 	Lang string `xml:"attr"`
    40 }
    40 }
    41 var _ xml.Marshaler = &Stream{}
    41 var _ xml.Marshaler = &Stream{}
    42 var _ fmt.Stringer = &Stream{}
    42 var _ fmt.Stringer = &Stream{}
    43 
    43 
    44 // <stream:error>
    44 // <stream:error>
    45 // TODO Can this be consolidated with Error?
    45 // BUG(cjyar) Can this be consolidated with Error? Hide it if not.
    46 type StreamError struct {
    46 type StreamError struct {
    47 	Any definedCondition
    47 	Any definedCondition
    48 	Text *errText
    48 	Text *errText
    49 }
    49 }
    50 var _ xml.Marshaler = &StreamError{}
    50 var _ xml.Marshaler = &StreamError{}
    51 
    51 
    52 // TODO Replace this with Unrecognized.
    52 // BUG(cjyar) Replace this with Unrecognized.
    53 type definedCondition struct {
    53 type definedCondition struct {
    54 	// Must always be in namespace nsStreams
    54 	// Must always be in namespace nsStreams
    55 	XMLName xml.Name
    55 	XMLName xml.Name
    56 	Chardata string `xml:"chardata"`
    56 	Chardata string `xml:"chardata"`
    57 }
    57 }
    60 	Lang string `xml:"attr"`
    60 	Lang string `xml:"attr"`
    61 	Text string `xml:"chardata"`
    61 	Text string `xml:"chardata"`
    62 }
    62 }
    63 var _ xml.Marshaler = &errText{}
    63 var _ xml.Marshaler = &errText{}
    64 
    64 
    65 // TODO Store this in Client and make it available to the app.
    65 // BUG(cjyar) Store this in Client and make it available to the app.
    66 type Features struct {
    66 type Features struct {
    67 	Starttls *starttls
    67 	Starttls *starttls
    68 	Mechanisms mechs
    68 	Mechanisms mechs
    69 	Bind *Unrecognized
    69 	Bind *Unrecognized
    70 }
    70 }
   153 	Any *Unrecognized
   153 	Any *Unrecognized
   154 }
   154 }
   155 var _ xml.Marshaler = &Error{}
   155 var _ xml.Marshaler = &Error{}
   156 
   156 
   157 // Holds an XML element not described by the more specific types.
   157 // Holds an XML element not described by the more specific types.
   158 // TODO Rename this to something like Generic.
   158 // BUG(cjyar) Rename this to something like Generic.
   159 type Unrecognized struct {
   159 type Unrecognized struct {
   160 	XMLName xml.Name
   160 	XMLName xml.Name
   161 	Any *Unrecognized
   161 	Any *Unrecognized
   162 	Chardata string `xml:"chardata"`
   162 	Chardata string `xml:"chardata"`
   163 }
   163 }