xmpp/stanza d---------
all: be more strict about stanza namespaces

Previously we were checking if something was a stanza based on faulty
assumptions (that there were only two valid stanza namespaces) and
without precision (we'd accept it if it were either namespace or none
instead of only accepting the actual namespace used by teh stream).
This PR fixes this to ensure that eg. a vulnerability that causes the
server to allow {jabber:server}message's sent over a jabber:client
stream without any of the normal security measures still won't affect
this library (hopefully).

This PR updates all locations to use the new APIs, but does not
necessarily perform the correct checks. A followup PR will be rquired to
upgrade some of the packages (eg. mux) to use the correct namespace.

Signed-off-by: Sam Whited <sam@samwhited.com>
stanza: return more detailed error text

Signed-off-by: Sam Whited <sam@samwhited.com>
stanza: add Error method to Presence and Message

Like IQs replying with an error involves switching the to/from
attributes and making sure the type is set to "error" so it makes sense
to have the Error method on both Presence and Message too.

While doing this I noticed that each stanza marshaled its attribute
order differently. While it doesn't matter and this is not a guaranteed
part of the API, it would be nice if they were consistent so I also
switched those around and fixed a few minor documentation issues.

Finally, since we were adding a Presence and Message Error method with a
test I also added a test belatedly for the IQ Error method.

Signed-off-by: Sam Whited <sam@samwhited.com>
stanza: add UnmarshalError function

Signed-off-by: Sam Whited <sam@samwhited.com>
stanza: add support for delayed delivery

Signed-off-by: Sam Whited <sam@samwhited.com>
stanza: fix error unmarshaling with other payloads

Previously if the error was not the first payload in the stanza it would
not be found by UnmarshalIQError. Now we iterate through all the child
payloads looking for it (and disregarding other payloads) until we can
unmarshal it.

Signed-off-by: Sam Whited <sam@samwhited.com>
stanza: add func to unmarshal IQ start or error IQ

Fixes #114

Signed-off-by: Sam Whited <sam@samwhited.com>
stanza: set default condition on errors

Previously if no condition was set on an error marshaling it to XML
would fail with the misleading error: "xml: start tag with no name".
Now marshaling will succeed and the condition will default to
undefined-condition per the RFC.

Fixes #127

Signed-off-by: Sam Whited <sam@samwhited.com>
stanza: rewrap test struct

Signed-off-by: Sam Whited <sam@samwhited.com>
stanza: add Wrap method to Errors

Signed-off-by: Sam Whited <sam@samwhited.com>
stanza: rename a file

With `Is' exported this now does more than handle IDs.
Rename the file for clarity.

Signed-off-by: Sam Whited <sam@samwhited.com>
all: add function stanza.Is()

Add exported function stanza.Is() which tests an xml.Name for its name
and space. If it is a proper stanza it returns true.
This function was repeatedly defined in several files and is now defined
one time and exported in stanza/stanza.go

Fixes #113
stanza: make errors comparable with errors.Is

Signed-off-by: Sam Whited <sam@samwhited.com>
stanza: move tests into stanza_test package

Signed-off-by: Sam Whited <sam@samwhited.com>
stanza: add missing documentation

Signed-off-by: Sam Whited <sam@samwhited.com>
stanza: support unique and stable stanza IDs

Fixes #111

Signed-off-by: Sam Whited <sam@samwhited.com>
stanza: add Error method on IQ

This provides an easy way to reply to IQs with an error, similar to

Signed-off-by: Sam Whited <sam@samwhited.com>
stanza: update documentation

Fix the stanza creation example to use the newer Wrap method and add an
ID argument to make it more obvious that you have to add IDs to the
stanzas yourself.

See #17

Signed-off-by: Sam Whited <sam@samwhited.com>
stanza: fix error on stanzas with empty to/from

Previously the "to" and "from" elements were always parsed as a JID,
even if they were empty. However, an empty to/from is valid even though
it is not a valid JID and would result in an error.

Signed-off-by: Sam Whited <sam@samwhited.com>
stanza: create stanzas from any start element

Previously stanzas were unmarshaled from the start element using an
xml.Decoder. This is slow and inefficient, and if the name of the stanza
differs an error will be returned. Implementing manual decoding of the
start element should make things faster (though this has not been
verified) and allows the name of the initial start element to be
disregarded. This will not change the name when the stanza typed value
is marshaled back into an XML stream.

Signed-off-by: Sam Whited <sam@samwhited.com>