Use sockets and GnuTLS for networking and TLS

When networking was implemented we used Gio since it was part of GLib
which we already used heavily, so it didn't add a lot of extra
dependencies. As a bonus it also included support for TLS.

There have however been some interest in using GnuTLS instead of Glib's
TLS implementation. While switching to GnuTLS the rest of Gio was also
replaced with traditional sockets due to difficulties in integrating it
with the existing code. In the process the code was also cleaned up
where appropriate.

The networking code should probably be moved into a separate networking
layer which all clients can share. This is not strictly necessary right
now since we only have an IMAP client, but it's something which more
thought should be given to.

Signed-off-by: Marcus Karlsson <mk@acc.umu.se>