예제 #1
0
파일: event_data.go 프로젝트: oxpa/bullxmpp
func (elm *Delete) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	for _, x := range tag.Attr {
		switch {
		case x.Name.Space == "" && x.Name.Local == "node":
			elm.Node = xmlencoder.Copystring(x.Value)
		}
	}
	var t xml.Token
Loop:
	for {
		if t, err = d.Token(); err != nil {
			return err
		}
		switch t := t.(type) {
		case xml.EndElement:
			break Loop
		case xml.StartElement:
			switch {
			case t.Name.Space == NS && t.Name.Local == "redirect":
				for _, x := range tag.Attr {
					switch {
					case x.Name.Space == "" && x.Name.Local == "url":
						elm.Redirect.Url = xmlencoder.Copystring(x.Value)
					}
				}
			}
		}
	}
	return err
}
예제 #2
0
파일: sasl_data.go 프로젝트: oxpa/bullxmpp
func (elm *Failure) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	var t xml.Token
Loop:
	for {
		if t, err = d.Token(); err != nil {
			return err
		}
		switch t := t.(type) {
		case xml.EndElement:
			break Loop
		case xml.StartElement:
			switch {
			case t.Name.Space == NS && t.Name.Local == "text":
				if err = elm.Text.Decode(d, &t); err != nil {
					return err
				}
			default:
				if t.Name.Space == NS {
					*elm.Condition = FailureCondition(t.Name.Local)
					if err = d.Skip(); err != nil {
						return err
					}
				}
			}
		}
	}
	return err
}
예제 #3
0
파일: event_data.go 프로젝트: oxpa/bullxmpp
func (elm *Collection) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	for _, x := range tag.Attr {
		switch {
		case x.Name.Space == "" && x.Name.Local == "node":
			elm.Node = xmlencoder.Copystring(x.Value)
		}
	}
	var t xml.Token
Loop:
	for {
		if t, err = d.Token(); err != nil {
			return err
		}
		switch t := t.(type) {
		case xml.EndElement:
			break Loop
		case xml.StartElement:
			switch {
			default:
				if t.Name.Space == NS {
					for _, x := range tag.Attr {
						switch {
						case x.Name.Space == "" && x.Name.Local == "node":
							elm.Type.Node = xmlencoder.Copystring(x.Value)
						}
					}
				}
			}
		}
	}
	return err
}
예제 #4
0
파일: mood_data.go 프로젝트: oxpa/bullxmpp
func (elm *Mood) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	var t xml.Token
Loop:
	for {
		if t, err = d.Token(); err != nil {
			return err
		}
		switch t := t.(type) {
		case xml.EndElement:
			break Loop
		case xml.StartElement:
			switch {
			case t.Name.Space == NS && t.Name.Local == "text":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.Text = s
			default:
				if t.Name.Space == NS {
					*elm.Mood = MoodMood(t.Name.Local)
					if err = d.Skip(); err != nil {
						return err
					}
				}
			}
		}
	}
	return err
}
예제 #5
0
파일: event_data.go 프로젝트: oxpa/bullxmpp
func (elm *Configuration) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	for _, x := range tag.Attr {
		switch {
		case x.Name.Space == "" && x.Name.Local == "node":
			elm.Node = xmlencoder.Copystring(x.Value)
		}
	}
	var t xml.Token
Loop:
	for {
		if t, err = d.Token(); err != nil {
			return err
		}
		switch t := t.(type) {
		case xml.EndElement:
			break Loop
		case xml.StartElement:
			switch {
			case t.Name.Space == "jabber:x:data" && t.Name.Local == "x":
				newel := &xdata.X{}
				if err = newel.Decode(d, &t); err != nil {
					return err
				}
				elm.Xdata = newel
			}
		}
	}
	return err
}
예제 #6
0
func (elm *Error) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	var t xml.Token
Loop:
	for {
		if t, err = d.Token(); err != nil {
			return err
		}
		switch t := t.(type) {
		case xml.EndElement:
			break Loop
		case xml.StartElement:
			switch {
			case t.Name.Space == NS && t.Name.Local == "text":
				if err = elm.Text.Decode(d, &t); err != nil {
					return err
				}
			default:
				if t.Name.Space == NS {
					var s string
					if s, err = d.Text(); err != nil {
						return err
					}
					*elm.Condition.Extra = s
				}
			}
		}
	}
	return err
}
예제 #7
0
파일: vcard_data.go 프로젝트: oxpa/bullxmpp
func (elm *ORG) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	var t xml.Token
Loop:
	for {
		if t, err = d.Token(); err != nil {
			return err
		}
		switch t := t.(type) {
		case xml.EndElement:
			break Loop
		case xml.StartElement:
			switch {
			case t.Name.Space == NS && t.Name.Local == "ORGNAME":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.ORGNAME = s
			case t.Name.Space == NS && t.Name.Local == "ORGUNIT":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				elm.ORGUNIT = append(elm.ORGUNIT, s)
			}
		}
	}
	return err
}
예제 #8
0
파일: vcard_data.go 프로젝트: oxpa/bullxmpp
func (elm *CLASS) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	var t xml.Token
Loop:
	for {
		if t, err = d.Token(); err != nil {
			return err
		}
		switch t := t.(type) {
		case xml.EndElement:
			break Loop
		case xml.StartElement:
			switch {
			default:
				if t.Name.Space == NS {
					*elm.Type = CLASSType(t.Name.Local)
					if err = d.Skip(); err != nil {
						return err
					}
				}
			}
		}
	}
	return err
}
예제 #9
0
func (elm *Features) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	var t xml.Token
Loop:
	for {
		if t, err = d.Token(); err != nil {
			return err
		}
		switch t := t.(type) {
		case xml.StartElement:
			if newel, ok := xmlencoder.GetExtension(t.Name); ok {
				if err = newel.(xmlencoder.Extension).Decode(d, &t); err != nil {
					return err
				}
				*elm = append(*elm, newel)
			} else {
				if err = d.Skip(); err != nil {
					return err
				}
			}
		case xml.EndElement:
			break Loop
		}
	}
	return err
}
예제 #10
0
파일: user_data.go 프로젝트: oxpa/bullxmpp
func (elm *Invite) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
var err error
for _, x := range tag.Attr {
switch {
case x.Name.Space == "" && x.Name.Local == "from":
var j *jid.JID
if j, err = jid.New(x.Value); err != nil { return err }
elm.From = j
case x.Name.Space == "" && x.Name.Local == "to":
var j *jid.JID
if j, err = jid.New(x.Value); err != nil { return err }
elm.To = j
}
}
var t xml.Token
Loop:
for {
if t, err = d.Token(); err != nil { return err }
switch t := t.(type) {
case xml.EndElement:
break Loop
case xml.StartElement:
switch {
case t.Name.Space == NS && t.Name.Local == "reason":
var s string
if s, err = d.Text(); err != nil { return err }
*elm.Reason = s
}
}
}
return err
}
예제 #11
0
func (elm *Item) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	for _, x := range tag.Attr {
		switch {
		case x.Name.Space == "" && x.Name.Local == "action":
			value := ItemAction(x.Value)
			elm.Action = &value
		case x.Name.Space == "" && x.Name.Local == "order":
			var i uint64
			i, err = strconv.ParseUint(x.Value, 10, 0)
			if err == nil {
				*elm.Order = uint(i)
			}
		case x.Name.Space == "" && x.Name.Local == "type":
			value := ItemType(x.Value)
			elm.Type = &value
		case x.Name.Space == "" && x.Name.Local == "value":
			elm.Value = xmlencoder.Copystring(x.Value)
		}
	}
	var t xml.Token
Loop:
	for {
		if t, err = d.Token(); err != nil {
			return err
		}
		switch t := t.(type) {
		case xml.EndElement:
			break Loop
		case xml.StartElement:
			switch {
			case t.Name.Space == NS && t.Name.Local == "iq":
				elm.Iq = true
				if err = d.Skip(); err != nil {
					return err
				}
				continue
			case t.Name.Space == NS && t.Name.Local == "message":
				elm.Message = true
				if err = d.Skip(); err != nil {
					return err
				}
				continue
			case t.Name.Space == NS && t.Name.Local == "presence-in":
				elm.PresenceIn = true
				if err = d.Skip(); err != nil {
					return err
				}
				continue
			case t.Name.Space == NS && t.Name.Local == "presence-out":
				elm.PresenceOut = true
				if err = d.Skip(); err != nil {
					return err
				}
				continue
			}
		}
	}
	return err
}
예제 #12
0
파일: bind_data.go 프로젝트: oxpa/bullxmpp
func (elm *Bind) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	var t xml.Token
Loop:
	for {
		if t, err = d.Token(); err != nil {
			return err
		}
		switch t := t.(type) {
		case xml.EndElement:
			break Loop
		case xml.StartElement:
			switch {
			case t.Name.Space == NS && t.Name.Local == "resource":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.Resource = s
			case t.Name.Space == NS && t.Name.Local == "jid":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				var j *jid.JID
				if j, err = jid.New(s); err != nil {
					return err
				}
				elm.Jid = j
			}
		}
	}
	return err
}
예제 #13
0
파일: owner_data.go 프로젝트: oxpa/bullxmpp
func (elm *Configure) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	var t xml.Token
Loop:
	for {
		if t, err = d.Token(); err != nil {
			return err
		}
		switch t := t.(type) {
		case xml.StartElement:
			if t.Name.Space == "jabber:x:data" && t.Name.Local == "x" {
				newel := &xdata.X{}
				if err = newel.Decode(d, &t); err != nil {
					return err
				}
				*elm = Configure(*newel)
			} else {
				if err = d.Skip(); err != nil {
					return err
				}
			}
		case xml.EndElement:
			break Loop
		}
	}
	return err
}
예제 #14
0
func (elm *List) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	for _, x := range tag.Attr {
		switch {
		case x.Name.Space == "" && x.Name.Local == "name":
			elm.Name = xmlencoder.Copystring(x.Value)
		}
	}
	var t xml.Token
Loop:
	for {
		if t, err = d.Token(); err != nil {
			return err
		}
		switch t := t.(type) {
		case xml.EndElement:
			break Loop
		case xml.StartElement:
			switch {
			case t.Name.Space == NS && t.Name.Local == "item":
				newel := &Item{}
				if err = newel.Decode(d, &t); err != nil {
					return err
				}
				elm.Items = append(elm.Items, newel)
			}
		}
	}
	return err
}
예제 #15
0
파일: xdata_data.go 프로젝트: oxpa/bullxmpp
func (elm *Option) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	for _, x := range tag.Attr {
		switch {
		case x.Name.Space == "" && x.Name.Local == "label":
			elm.Label = xmlencoder.Copystring(x.Value)
		}
	}
	var t xml.Token
Loop:
	for {
		if t, err = d.Token(); err != nil {
			return err
		}
		switch t := t.(type) {
		case xml.EndElement:
			break Loop
		case xml.StartElement:
			switch {
			case t.Name.Space == NS && t.Name.Local == "value":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.Value = s
			}
		}
	}
	return err
}
예제 #16
0
파일: user_data.go 프로젝트: oxpa/bullxmpp
func (elm *Action) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
var err error
var t xml.Token
Loop:
for {
if t, err = d.Token(); err != nil { return err }
switch t := t.(type) {
case xml.EndElement:
break Loop
case xml.StartElement:
switch {
case t.Name.Space == NS && t.Name.Local == "invite":
newel := &Invite{}
if err = newel.Decode(d, &t); err != nil { return err}
elm.Invite = append(elm.Invite, newel)
case t.Name.Space == NS && t.Name.Local == "password":
var s string
if s, err = d.Text(); err != nil { return err }
*elm.Password = s
case t.Name.Space == NS && t.Name.Local == "status":
newel := &Status{}
if err = newel.Decode(d, &t); err != nil { return err}
elm.Status = append(elm.Status, newel)
}
}
}
return err
}
예제 #17
0
파일: vcard_data.go 프로젝트: oxpa/bullxmpp
func (elm *Vcard) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	var t xml.Token
Loop:
	for {
		if t, err = d.Token(); err != nil {
			return err
		}
		switch t := t.(type) {
		case xml.EndElement:
			break Loop
		case xml.StartElement:
			switch {
			case t.Name.Space == NS && t.Name.Local == "VERSION":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.VERSION = s
			case t.Name.Space == NS && t.Name.Local == "FN":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.FN = s
			}
		}
	}
	return err
}
예제 #18
0
파일: vcard_data.go 프로젝트: oxpa/bullxmpp
func (elm *AGENT) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	var t xml.Token
Loop:
	for {
		if t, err = d.Token(); err != nil {
			return err
		}
		switch t := t.(type) {
		case xml.EndElement:
			break Loop
		case xml.StartElement:
			switch {
			case t.Name.Space == NS && t.Name.Local == "vCard":
				newel := &Vcard{}
				if err = newel.Decode(d, &t); err != nil {
					return err
				}
				elm.Payload = newel
			case t.Name.Space == NS && t.Name.Local == "EXTVAL":
				newel := &EXTVAL{}
				if err = newel.Decode(d, &t); err != nil {
					return err
				}
				elm.Payload = newel
			}
		}
	}
	return err
}
예제 #19
0
func (elm *Iq) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	for _, x := range tag.Attr {
		switch {
		case x.Name.Space == "" && x.Name.Local == "from":
			var j *jid.JID
			if j, err = jid.New(x.Value); err != nil {
				return err
			}
			elm.From = j
		case x.Name.Space == "" && x.Name.Local == "to":
			var j *jid.JID
			if j, err = jid.New(x.Value); err != nil {
				return err
			}
			elm.To = j
		case x.Name.Space == "" && x.Name.Local == "id":
			elm.Id = xmlencoder.Copystring(x.Value)
		case x.Name.Space == "" && x.Name.Local == "type":
			value := IqType(x.Value)
			elm.Type = &value
		case x.Name.Space == "http://www.w3.org/XML/1998/namespace" && x.Name.Local == "lang":
			elm.Lang = &x.Value
		}
	}
	var t xml.Token
Loop:
	for {
		if t, err = d.Token(); err != nil {
			return err
		}
		switch t := t.(type) {
		case xml.EndElement:
			break Loop
		case xml.StartElement:
			switch {
			default:
				if newel, ok := xmlencoder.GetExtension(t.Name); ok {
					if err = newel.(xmlencoder.Extension).Decode(d, &t); err != nil {
						return err
					}
					elm.Payload = newel
				} else {
					if err = d.Skip(); err != nil {
						return err
					}
				}
			case t.Name.Space == "urn:ietf:params:xml:ns:xmpp-stanzas" && t.Name.Local == "error":
				newel := &stanza.Error{}
				if err = newel.Decode(d, &t); err != nil {
					return err
				}
				elm.Error = newel
			}
		}
	}
	return err
}
예제 #20
0
파일: event_data.go 프로젝트: oxpa/bullxmpp
func (elm *Event) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	var t xml.Token
Loop:
	for {
		if t, err = d.Token(); err != nil {
			return err
		}
		switch t := t.(type) {
		case xml.EndElement:
			break Loop
		case xml.StartElement:
			switch {
			case t.Name.Space == NS && t.Name.Local == "collection":
				newel := &Collection{}
				if err = newel.Decode(d, &t); err != nil {
					return err
				}
				elm.Payload = newel
			case t.Name.Space == NS && t.Name.Local == "configuration":
				newel := &Configuration{}
				if err = newel.Decode(d, &t); err != nil {
					return err
				}
				elm.Payload = newel
			case t.Name.Space == NS && t.Name.Local == "delete":
				newel := &Delete{}
				if err = newel.Decode(d, &t); err != nil {
					return err
				}
				elm.Payload = newel
			case t.Name.Space == NS && t.Name.Local == "items":
				newel := &Items{}
				if err = newel.Decode(d, &t); err != nil {
					return err
				}
				elm.Payload = newel
			case t.Name.Space == NS && t.Name.Local == "purge":
				newel := &Purge{}
				if err = newel.Decode(d, &t); err != nil {
					return err
				}
				elm.Payload = newel
			case t.Name.Space == NS && t.Name.Local == "subscription":
				newel := &Subscription{}
				if err = newel.Decode(d, &t); err != nil {
					return err
				}
				elm.Payload = newel
			}
		}
	}
	return err
}
예제 #21
0
파일: vcard_data.go 프로젝트: oxpa/bullxmpp
func (elm *EMAIL) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	var t xml.Token
Loop:
	for {
		if t, err = d.Token(); err != nil {
			return err
		}
		switch t := t.(type) {
		case xml.EndElement:
			break Loop
		case xml.StartElement:
			switch {
			case t.Name.Space == NS && t.Name.Local == "HOME":
				elm.HOME = true
				if err = d.Skip(); err != nil {
					return err
				}
				continue
			case t.Name.Space == NS && t.Name.Local == "WORK":
				elm.WORK = true
				if err = d.Skip(); err != nil {
					return err
				}
				continue
			case t.Name.Space == NS && t.Name.Local == "INTERNET":
				elm.INTERNET = true
				if err = d.Skip(); err != nil {
					return err
				}
				continue
			case t.Name.Space == NS && t.Name.Local == "PREF":
				elm.PREF = true
				if err = d.Skip(); err != nil {
					return err
				}
				continue
			case t.Name.Space == NS && t.Name.Local == "X400":
				elm.X400 = true
				if err = d.Skip(); err != nil {
					return err
				}
				continue
			case t.Name.Space == NS && t.Name.Local == "USERID":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.USERID = s
			}
		}
	}
	return err
}
예제 #22
0
파일: xdata_data.go 프로젝트: oxpa/bullxmpp
func (elm *Field) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	for _, x := range tag.Attr {
		switch {
		case x.Name.Space == "" && x.Name.Local == "label":
			elm.Label = xmlencoder.Copystring(x.Value)
		case x.Name.Space == "" && x.Name.Local == "type":
			value := FieldType(x.Value)
			elm.Type = &value
		case x.Name.Space == "" && x.Name.Local == "var":
			elm.Var = xmlencoder.Copystring(x.Value)
		}
	}
	var t xml.Token
Loop:
	for {
		if t, err = d.Token(); err != nil {
			return err
		}
		switch t := t.(type) {
		case xml.EndElement:
			break Loop
		case xml.StartElement:
			switch {
			case t.Name.Space == NS && t.Name.Local == "desc":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.Desc = s
			case t.Name.Space == NS && t.Name.Local == "required":
				elm.Required = true
				if err = d.Skip(); err != nil {
					return err
				}
				continue
			case t.Name.Space == NS && t.Name.Local == "value":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.Value = s
			case t.Name.Space == NS && t.Name.Local == "option":
				newel := &Option{}
				if err = newel.Decode(d, &t); err != nil {
					return err
				}
				elm.Option = append(elm.Option, newel)
			}
		}
	}
	return err
}
예제 #23
0
파일: admin_data.go 프로젝트: oxpa/bullxmpp
func (elm *Item) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	for _, x := range tag.Attr {
		switch {
		case x.Name.Space == "" && x.Name.Local == "affiliation":
			value := ItemAffiliation(x.Value)
			elm.Affiliation = &value
		case x.Name.Space == "" && x.Name.Local == "jid":
			var j *jid.JID
			if j, err = jid.New(x.Value); err != nil {
				return err
			}
			elm.Jid = j
		case x.Name.Space == "" && x.Name.Local == "nick":
			elm.Nick = xmlencoder.Copystring(x.Value)
		case x.Name.Space == "" && x.Name.Local == "role":
			value := ItemRole(x.Value)
			elm.Role = &value
		}
	}
	var t xml.Token
Loop:
	for {
		if t, err = d.Token(); err != nil {
			return err
		}
		switch t := t.(type) {
		case xml.EndElement:
			break Loop
		case xml.StartElement:
			switch {
			case t.Name.Space == NS && t.Name.Local == "actor":
				for _, x := range tag.Attr {
					switch {
					case x.Name.Space == "" && x.Name.Local == "jid":
						var j *jid.JID
						if j, err = jid.New(x.Value); err != nil {
							return err
						}
						elm.Actor.Jid = j
					}
				}
			case t.Name.Space == NS && t.Name.Local == "reason":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.Reason = s
			}
		}
	}
	return err
}
예제 #24
0
파일: muc_data.go 프로젝트: oxpa/bullxmpp
func (elm *Enter) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	var t xml.Token
Loop:
	for {
		if t, err = d.Token(); err != nil {
			return err
		}
		switch t := t.(type) {
		case xml.EndElement:
			break Loop
		case xml.StartElement:
			switch {
			case t.Name.Space == NS && t.Name.Local == "history":
				for _, x := range tag.Attr {
					switch {
					case x.Name.Space == "" && x.Name.Local == "maxchars":
						var i int64
						i, err = strconv.ParseInt(x.Value, 10, 0)
						if err == nil {
							*elm.History.Maxchars = int(i)
						}
					case x.Name.Space == "" && x.Name.Local == "maxstanzas":
						var i int64
						i, err = strconv.ParseInt(x.Value, 10, 0)
						if err == nil {
							*elm.History.Maxstanzas = int(i)
						}
					case x.Name.Space == "" && x.Name.Local == "seconds":
						var i int64
						i, err = strconv.ParseInt(x.Value, 10, 0)
						if err == nil {
							*elm.History.Seconds = int(i)
						}
					case x.Name.Space == "" && x.Name.Local == "since":
						*elm.History.Since, err = time.Parse(time.RFC3339, x.Value)
						if err != nil {
							return err
						}
					}
				}
			case t.Name.Space == NS && t.Name.Local == "password":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.Password = s
			}
		}
	}
	return err
}
예제 #25
0
파일: xdata_data.go 프로젝트: oxpa/bullxmpp
func (elm *X) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	for _, x := range tag.Attr {
		switch {
		case x.Name.Space == "" && x.Name.Local == "type":
			value := XType(x.Value)
			elm.Type = &value
		}
	}
	var t xml.Token
Loop:
	for {
		if t, err = d.Token(); err != nil {
			return err
		}
		switch t := t.(type) {
		case xml.EndElement:
			break Loop
		case xml.StartElement:
			switch {
			case t.Name.Space == NS && t.Name.Local == "title":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.Title = s
			case t.Name.Space == NS && t.Name.Local == "reported":
				var t xml.Token
			InLoop:
				for {
					if t, err = d.Token(); err != nil {
						return err
					}
					switch t := t.(type) {
					case xml.StartElement:
						if t.Name.Space == NS && t.Name.Local == "field" {
							newel := &Field{}
							if err = newel.Decode(d, &t); err != nil {
								return err
							}
							elm.Reported = append(elm.Reported, newel)
						}
					case xml.EndElement:
						break InLoop
					}
				}
			}
		}
	}
	return err
}
예제 #26
0
func (elm *Item) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	for _, x := range tag.Attr {
		switch {
		case x.Name.Space == "" && x.Name.Local == "approved":
			var b bool
			b, err = strconv.ParseBool(x.Value)
			if err == nil {
				elm.Approved = b
			}
		case x.Name.Space == "" && x.Name.Local == "ask":
			value := ItemAsk(x.Value)
			elm.Ask = &value
		case x.Name.Space == "" && x.Name.Local == "jid":
			var j *jid.JID
			if j, err = jid.New(x.Value); err != nil {
				return err
			}
			elm.Jid = j
		case x.Name.Space == "" && x.Name.Local == "name":
			elm.Name = xmlencoder.Copystring(x.Value)
		case x.Name.Space == "" && x.Name.Local == "subscription":
			value := ItemSubscription(x.Value)
			elm.Subscription = &value
		}
	}
	var t xml.Token
Loop:
	for {
		if t, err = d.Token(); err != nil {
			return err
		}
		switch t := t.(type) {
		case xml.EndElement:
			break Loop
		case xml.StartElement:
			switch {
			case t.Name.Space == NS && t.Name.Local == "group":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				elm.Group = append(elm.Group, s)
			}
		}
	}
	return err
}
예제 #27
0
파일: vcard_data.go 프로젝트: oxpa/bullxmpp
func (elm *N) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	var t xml.Token
Loop:
	for {
		if t, err = d.Token(); err != nil {
			return err
		}
		switch t := t.(type) {
		case xml.EndElement:
			break Loop
		case xml.StartElement:
			switch {
			case t.Name.Space == NS && t.Name.Local == "FAMILY":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.FAMILY = s
			case t.Name.Space == NS && t.Name.Local == "GIVEN":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.GIVEN = s
			case t.Name.Space == NS && t.Name.Local == "NIDDLE":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.NIDDLE = s
			case t.Name.Space == NS && t.Name.Local == "PREFIX":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.PREFIX = s
			case t.Name.Space == NS && t.Name.Local == "SUFFIX":
				var s string
				if s, err = d.Text(); err != nil {
					return err
				}
				*elm.SUFFIX = s
			}
		}
	}
	return err
}
예제 #28
0
파일: event_data.go 프로젝트: oxpa/bullxmpp
func (elm *Item) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	for _, x := range tag.Attr {
		switch {
		case x.Name.Space == "" && x.Name.Local == "id":
			elm.Id = xmlencoder.Copystring(x.Value)
		case x.Name.Space == "" && x.Name.Local == "node":
			elm.Node = xmlencoder.Copystring(x.Value)
		case x.Name.Space == "" && x.Name.Local == "publisher":
			elm.Publisher = xmlencoder.Copystring(x.Value)
		}
	}
	var t xml.Token
Loop:
	for {
		if t, err = d.Token(); err != nil {
			return err
		}
		switch t := t.(type) {
		case xml.EndElement:
			break Loop
		case xml.StartElement:
			switch {
			default:
				if newel, ok := xmlencoder.GetExtension(t.Name); ok {
					if err = newel.(xmlencoder.Extension).Decode(d, &t); err != nil {
						return err
					}
					elm.Event = newel
				} else {
					if err = d.Skip(); err != nil {
						return err
					}
				}
			}
		}
	}
	return err
}
예제 #29
0
파일: stats_data.go 프로젝트: oxpa/bullxmpp
func (elm *Stats) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	var t xml.Token
Loop:
	for {
		if t, err = d.Token(); err != nil {
			return err
		}
		switch t := t.(type) {
		case xml.StartElement:
			if t.Name.Space == NS && t.Name.Local == "stat" {
				newel := &Stat{}
				if err = newel.Decode(d, &t); err != nil {
					return err
				}
				elm = append(elm, newel)
			}
		case xml.EndElement:
			break Loop
		}
	}
	return err
}
예제 #30
0
func (elm *Starttls) Decode(d *xmlencoder.Decoder, tag *xml.StartElement) error {
	var err error
	var t xml.Token
Loop:
	for {
		if t, err = d.Token(); err != nil {
			return err
		}
		switch t := t.(type) {
		case xml.EndElement:
			break Loop
		case xml.StartElement:
			switch {
			case t.Name.Space == NS && t.Name.Local == "required":
				elm.Required = true
				if err = d.Skip(); err != nil {
					return err
				}
				continue
			}
		}
	}
	return err
}