Add initial XEP-0198 support (EJAB-532)

Implement partial support for XEP-0198: Stream Management.  After
successful negotiation of this feature, the server requests an ACK for
each stanza transmitted to the client and responds to ACK requests
issued by the client.  On session termination, the server re-routes any
unacknowledged stanzas.  The length of the pending queue can be limited
by setting the "max_ack_queue" option to some integer value (default:
500).  XEP-0198 support can be disabled entirely by setting the
"stream_management" option to false (default: true).

So far, stream management is implemented only for c2s connections, and
the optional stream resumption feature also described in XEP-0198 is not
(yet) supported.

This addition was originally based on a patch provided by Magnus Henoch
and updated by Grzegorz Grasza.  Their code implements an early draft of
XEP-0198 for some previous version of ejabberd.  It has since been
rewritten almost entirely.
Remove some commented out code

The code that had been commented out at some earlier point in time would
now break XEP-0198.
Support XEP-0198 session resumption

Implement the optional session resumption feature described in XEP-0198.
A client that supports this feature may now resume the previous session
(within a configurable number of seconds) if the connection was lost.
During resumption, ejabberd will retransmit any stanzas that hadn't been
acknowledged by the client.
Remove "fun" element from c2s #state

Memory consumption wise, local "fun" references are quite expensive.
XEP-0198: Bounce unacked stanzas by default

If the new "resend_on_timeout" option is set to false (which it is by
default), bounce any unacknowledged stanzas instead of re-routing them.
XEP-0198: Don't bounce/resend forwarded messages

On connection timeout, drop any messages that were forwarded by some
encapsulating protocol, such as XEP-0280 carbon copies or XEP-0313
archive messages.  Bouncing or resending them could easily lead to
unexpected results.
XEP-0198: Turn some warnings into info messages

Don't log warnings on events that will happen during normal operation.
Assume tcp_init/2 and udp_init/2 now return new options
Assume udp_recv/5 now returns new options
Do not crash on version downgrade
test/README: Create MySQL test user on 'localhost'

Suggest specifying 'localhost' as host name part of the MySQL test
account name.  Otherwise, the anonymous user that is usually created by
default for 'localhost' would take precedence for local connections due
to the more specific host name.
Merge pull request #194 from weiss/mysql-user-at-localhost

test/README: Create MySQL test user on localhost
Make it possible to get/set vCards for MUC rooms
XEP-0198: Log message when waiting for resumption

Log an informational message when a session goes into the pending state
(waiting for resumption) after the connection was lost.  Administrators
may well be interested in this state change when looking into issues.
XEP-0198: Accept stream elements in pending state

Due to timing issues, ejabberd_c2s might receive stream elements from
the client while the session is waiting for stream resumption.  Those
elements are now accepted.
XEP-0198: Don't log protocol issues

There are corner cases where certain clients acknowledge more stanzas
than they received.  Nothing really bad will happen in those cases, and
server administrators can't do anything about such issues anyway.
extauth_cache can have value 0
Temporary room not destroyed when the last participant is expulsed (EJAB-520)
Fix small bug in presence_based_delivery implementation
Merge pull request #195 from Iperity/master

Fix small bug in presence_based_delivery implementation