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.
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.
XEP-0198: Use "mgmt_" prefix for all #state fields

Prefix all ejabberd_c2s #state fields that are used for stream
management with "mgmt_".
Merge remote-tracking branch 'processone/master' into xep-0198

Conflicts:
	doc/guide.tex
	src/ejabberd_c2s.erl
Merge pull request #166 from weiss/xep-0198

Add support for XEP-0198: Stream Management