Encapsulate socket state in AuthHandler, properly handle disconnects

The actual state of the socket used to connect to the core should be
kept internal to AuthHandler (and RemotePeer), in particular because
we want to handle the detection of legacy cores transparently later.
Also, it does not make sense to handle individual socket states outside
of the classes actually dealing with the socket; handling errors and
disconnection is sufficient. Both AuthHandler and Peer now emit
statusMessage() signals for displaying the socket state in the UI.
Because it was never used nor is it needed, this commits also removes
the AuthHandler::State enum.

While doing this, I also stumbled over the most likely reason for the
problem that the client would sometimes not reconnect to a core even
though it would claim to be disconnected:

QTcpSocket will only emit disconnected() when it had already reached
the Connected state, i.e. not if it was still connecting. While
CoreConnection would detect the socket go back to UnconnectedState,
and set its own state to Disconnected, it would never do its internal
clean-up which was tied to the socket's disconnected() signal, unless
the socket would also emit an error (which it apparently doesn't do
in all cases...). As a result, reconnecting was not possible in these
situations.

With these changes, CoreConnection relies solely on AuthHandler's
disconnected() signal, which is properly emitted even if establishing
the connection fails.
Fix header guard

Thanks Clang.
Remove unused

Thanks Clang.
Fix signedness

This should actually be unsigned.
Save Main ToolBar state when not built against KDE. Fixes #1116
Change ifdefs around Main ToolBar fix to target mac only.
Update AboutDlg
Handle the readyRead() signal in RemotePeer instead of LegacyPeer

That way, the RemotePeer subclasses don't all need to connect to the
signal themselves; also, we can make sure in a central place that
socket data is processed even the socket was handed over to the peer
with unhandled data still in its buffer.

Instead of handling the signal directly, RemotePeer subclasses need
to implement the onSocketDataAvailable() method.
Let RemotePeer(s) tell their protocol type and features

Knowing a peer's supported procotol type will come in handy once we
support more than one protocol. Also, peers may support specific
features which they can now report via the new accessor.
Add PeerFactory

This factory creates an instance of a RemotePeer subclass based on the
given protocol type and peer-specific features. If given a list, it will
select the preferred one (generally the first one that matches an available
peer which accepts the given peer-specific features).

For now, we just have the LegacyPeer (which does not have specific
features, so that value is ignored).
Allow overriding of socket handling methods

This is primarily needed for ClientAuthHandler, which does not want
to throw error messages to the outside during protocol detection.
Implement protocol detection

This introduces a new initial handshake for negotiating the supported
protocols and connection features on both sides. It is completely
backwards compatible with older releases, in which case we go into
fallback mode.

Arguably, we could've used a nice, verbose, text-based handshake, but
that would've introduced questions around string formats, parsing and so
on. Also I felt like doing some bitbanging, so now the probing only
exchanges a few bytes which are described in the wiki [1]. If we ever
plan to use a more verbose or different format, changing the magic that
starts the whole shebang will be sufficient to indicate a new format.

Immediately after probing, if both core and client support the new format
(and a protocol other than the legacy one),we'll enable SSL and compression [2]
as appropriate, instead of doing it somewhat later in the middle of the legacy
handshake.

To retain compatibility, the magic number sent by the client is designed such
that older cores will immediately close the connection; we'll then reconnect
in compatibility mode. The other way round, if an older client connects to
a new core, we'll figure out that there's no magic being sent and switch to
legacy mode as well.

The unchanged legacy protocol is also the last resort even if both ends speak
the new handshake as long as we don't have an alternative to offer. So for now,
we'll probe for protocol support, get back the legacy protocol as only choice,
and use that as before. This also disables early SSL and compression mentioned above.

This means that 3rd party clients could already implement the handshake in
preparation for the future without changing anything else. Note that they should
also implement the detection of older cores in order to stay compatible with them -
simply detect a disconnect after the first few bytes sent and reconnect again
in compat mode.

[1] http://bugs.quassel-irc.org/projects/quassel-irc/wiki/Doc_quassel_protocols
[2] Not implemented yet.
More typedef, less typing
Have the PeerFactory provide the list of supported protocols

... and make use of that in ClientAuthHandler, instead of hardcoding
the available protocols there.
Use PeerFactory instead of creating LegacyPeer directly

This means that legacypeer.h needs be included by peerfactory.cpp only,
and we can remove all references to it elsewhere.
Use milliseconds for CTCP PING
Make CTCP PING report the correct millisecond round-trip time

If we want to display latency in milliseconds, we should also make sure
our payload is set in milliseconds.

Unfortunately, millisecond resolution for QDateTime appeared only in
Qt 4.7, so it'll stay in seconds for cores built against older Qt versions.
There won't ever be a Qt 4.9...

... and this should actually have been a check for Qt 4.7+.