Abstract away the protocol handshake code
authorManuel Nickschas <sputnick@quassel-irc.org>
Thu, 7 Nov 2013 19:35:55 +0000 (20:35 +0100)
committerManuel Nickschas <sputnick@quassel-irc.org>
Thu, 7 Nov 2013 22:43:01 +0000 (23:43 +0100)
commit64cf9f9b8a737dad5f29447805d4004cfd03c454
tree6605b6022709a0cf7e2f80cc34899638d43689fe
parent02bebb4c8f1c45397c55f1660176bfa0c303e703
Abstract away the protocol handshake code

This continues (and hopefully mostly concludes) the work begun
in 0e1b154 - abstracting away everything protocol-related from the
rest of the code, so we can later add another protocol. It's also
nice to not have all sorts of network- and protocol-related stuff
intertwined into central classes like Core and CoreConnection.

Note that nothing should change for end-users, modulo bugs. So new
and old client and core should work together in all combinations,
with and without SSL and/or compression. Please let me know if
something's wonky. That's also true for things like connection failure
handling and reconnects, as there have been many changes in those areas.

Turns out that abstracting the handshake stuff was much harder and
much more invasive than the previous work in SignalProxy. Turns also
out that the legacy handshake protocol is not the best ever. So
this touches lots of places in the code; sorry for a diff with over
3000 lines, but there was no way to sanely split the commits.

Anyway, here's the gist of it:

* Add auth handlers on both core and client side that process the
  handshake based on the generic message types in protocol.h - lots
  of code moved from CoreConnection and Core into the new classes.
  Note that "AuthHandler" is a stupid name for what it does, so we'll
  probably rename it to HandshakeHandler or something later.

* Extend LegacyPeer to translate the new message types to and from the
  legacy format, moving protocol-specific code out of the existing classes.
  Right now only "compat mode" is supported, i.e. the handshake we've
  been using for what feels like a decade. In the future, some of that
  should be done much nicer whilst keeping the same wire format. For now,
  there's several quirks in LegacyPeer to somehow map the insanities in
  the existing protocol to something that won't bite us in the future once
  we want to clean up that mess.

* Auth handlers will create the peer now - this is because later on the
  peer we need will be determined by protocol detection, which is part
  of the handshake.

* Use the generic protocol message types directly where it makes sense
  (in particular for things like SessionState) - instead of QVariantMaps.

* Lots of cleanups, API changes etc. were done in passing.

* Probably more that I choose to not remember right now.
32 files changed:
src/client/CMakeLists.txt
src/client/client.cpp
src/client/client.h
src/client/clientauthhandler.cpp [new file with mode: 0644]
src/client/clientauthhandler.h [new file with mode: 0644]
src/client/coreaccount.h
src/client/coreaccountmodel.h
src/client/coreconnection.cpp
src/client/coreconnection.h
src/common/CMakeLists.txt
src/common/authhandler.cpp [new file with mode: 0644]
src/common/authhandler.h [new file with mode: 0644]
src/common/internalpeer.cpp
src/common/internalpeer.h
src/common/peer.cpp
src/common/peer.h
src/common/protocols/legacy/legacypeer.cpp
src/common/protocols/legacy/legacypeer.h
src/common/remotepeer.cpp
src/common/remotepeer.h
src/common/signalproxy.h
src/core/CMakeLists.txt
src/core/core.cpp
src/core/core.h
src/core/coreauthhandler.cpp [new file with mode: 0644]
src/core/coreauthhandler.h [new file with mode: 0644]
src/core/coresession.cpp
src/core/coresession.h
src/core/sessionthread.cpp
src/core/sslserver.cpp
src/qtui/coreconfigwizard.cpp
src/qtui/monoapplication.cpp