- qobject_cast<RemotePeer *>(_peer)->writeSocketData(clientInit);
-}
-
-
-void CoreConnection::clientInitAck(const QVariantMap &msg)
-{
- // Core has accepted our version info and sent its own. Let's see if we accept it as well...
- uint ver = msg["ProtocolVersion"].toUInt();
- if (ver < Quassel::buildInfo().clientNeedsProtocol) {
- emit connectionErrorPopup(tr("<b>The Quassel Core you are trying to connect to is too old!</b><br>"
- "Need at least core/client protocol v%1 to connect.").arg(Quassel::buildInfo().clientNeedsProtocol));
- disconnectFromCore(QString(), false);
- return;
- }
-
- Client::setCoreFeatures((Quassel::Features)msg["CoreFeatures"].toUInt());
-
-#ifndef QT_NO_COMPRESS
- if (msg["SupportsCompression"].toBool()) {
- _socket->setProperty("UseCompression", true);
- }
-#endif
-
- _coreMsgBuffer = msg;
-
-#ifdef HAVE_SSL
- CoreAccountSettings s;
- if (currentAccount().useSsl()) {
- if (msg["SupportSsl"].toBool()) {
- // Make sure the warning is shown next time we don't have SSL in the core
- s.setAccountValue("ShowNoCoreSslWarning", true);
-
- QSslSocket *sslSocket = qobject_cast<QSslSocket *>(_socket);
- Q_ASSERT(sslSocket);
- connect(sslSocket, SIGNAL(encrypted()), SLOT(sslSocketEncrypted()));
- connect(sslSocket, SIGNAL(sslErrors(const QList<QSslError> &)), SLOT(sslErrors()));
- sslSocket->startClientEncryption();
- }
- else {
- if (s.accountValue("ShowNoCoreSslWarning", true).toBool()) {
- bool accepted = false;
- emit handleNoSslInCore(&accepted);
- if (!accepted) {
- disconnectFromCore(tr("Unencrypted connection canceled"), false);
- return;
- }
- s.setAccountValue("ShowNoCoreSslWarning", false);
- s.setAccountValue("SslCert", QString());
- }
- connectionReady();
- }
- return;
- }
-#endif
- // if we use SSL we wait for the next step until every SSL warning has been cleared
- connectionReady();
-}
-
-
-#ifdef HAVE_SSL
-
-void CoreConnection::sslSocketEncrypted()
-{
- QSslSocket *socket = qobject_cast<QSslSocket *>(sender());
- Q_ASSERT(socket);
-
- if (!socket->sslErrors().count()) {
- // Cert is valid, so we don't want to store it as known
- // That way, a warning will appear in case it becomes invalid at some point
- CoreAccountSettings s;
- s.setAccountValue("SSLCert", QString());
- }
-
- emit encrypted(true);
- connectionReady();
-}
-
-
-void CoreConnection::sslErrors()
-{
- QSslSocket *socket = qobject_cast<QSslSocket *>(sender());
- Q_ASSERT(socket);
-
- CoreAccountSettings s;
- QByteArray knownDigest = s.accountValue("SslCert").toByteArray();
-
- if (knownDigest != socket->peerCertificate().digest()) {
- bool accepted = false;
- bool permanently = false;
- emit handleSslErrors(socket, &accepted, &permanently);