X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fcore.cpp;h=c92c4f157f70a9a3a7d6c57c2273a101f5feb8a7;hp=1af89261d2ea4973dd846d16f95d5dff51fc0c57;hb=52a7b4d0f289f075aa386445a47d876743bcb6d0;hpb=1e626e57b97756088052bcd88a29305dd7412f58 diff --git a/src/core/core.cpp b/src/core/core.cpp index 1af89261..c92c4f15 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -100,7 +100,7 @@ void Core::saveState() { QVariantMap state; QVariantList activeSessions; foreach(UserId user, instance()->sessions.keys()) activeSessions << QVariant::fromValue(user); - state["CoreBuild"] = Global::quasselBuild; + state["CoreStateVersion"] = 1; state["ActiveSessions"] = activeSessions; s.setCoreState(state); } @@ -115,11 +115,13 @@ void Core::restoreState() { return; } CoreSettings s; - uint build = s.coreState().toMap()["CoreBuild"].toUInt(); - if(build < 362) { + /* We don't check, since we are at the first version since switching to Git + uint statever = s.coreState().toMap()["CoreStateVersion"].toUInt(); + if(statever < 1) { qWarning() << qPrintable(tr("Core state too old, ignoring...")); return; } + */ QVariantList activeSessions = s.coreState().toMap()["ActiveSessions"].toList(); if(activeSessions.count() > 0) { qDebug() << "Restoring previous core state..."; @@ -307,6 +309,11 @@ QList Core::requestBuffers(UserId user) { return instance()->storage->requestBuffers(user); } +QList Core::requestBufferIdsForNetwork(UserId user, NetworkId networkId) { + QMutexLocker locker(&mutex); + return instance()->storage->requestBufferIdsForNetwork(user, networkId); +} + bool Core::removeBuffer(const UserId &user, const BufferId &bufferId) { QMutexLocker locker(&mutex); return instance()->storage->removeBuffer(user, bufferId); @@ -331,7 +338,7 @@ QHash Core::bufferLastSeenMsgIds(UserId user) { bool Core::startListening(uint port) { if(!server.listen(QHostAddress::Any, port)) { - qWarning(qPrintable(QString("Could not open GUI client port %1: %2").arg(port).arg(server.errorString()))); + qWarning("%s", qPrintable(QString("Could not open GUI client port %1: %2").arg(port).arg(server.errorString()))); return false; } qDebug() << "Listening for GUI clients on port" << server.serverPort(); @@ -382,16 +389,31 @@ void Core::processClientMessage(QTcpSocket *socket, const QVariantMap &msg) { // OK, so we have at least an init message format we can understand if(msg["MsgType"] == "ClientInit") { QVariantMap reply; + + // Just version information -- check it! + if((msg.contains("ClientBuild") && msg["ClientBuild"].toUInt() < 732) + || (!msg.contains("ClientBuild") && msg["ProtocolVersion"].toUInt() < Global::coreNeedsProtocol)) { + reply["MsgType"] = "ClientInitReject"; + reply["Error"] = tr("Your Quassel Client is too old!
" + "This core needs at least client/core protocol version %1.
" + "Please consider upgrading your client.").arg(Global::coreNeedsProtocol); + SignalProxy::writeDataToDevice(socket, reply); + qWarning() << qPrintable(tr("Client %1 too old, rejecting.").arg(socket->peerAddress().toString())); + socket->close(); return; + } + reply["CoreVersion"] = Global::quasselVersion; - reply["CoreDate"] = Global::quasselDate; - reply["CoreBuild"] = Global::quasselBuild; + reply["CoreDate"] = Global::quasselBuildDate; + reply["CoreBuild"] = 860; // FIXME legacy + reply["ProtocolVersion"] = Global::protocolVersion; // TODO: Make the core info configurable int uptime = startTime.secsTo(QDateTime::currentDateTime()); int updays = uptime / 86400; uptime %= 86400; int uphours = uptime / 3600; uptime %= 3600; int upmins = uptime / 60; - reply["CoreInfo"] = tr("Quassel Core Version %1 (Build ≥ %2)
" - "Up %3d%4h%5m (since %6)").arg(Global::quasselVersion).arg(Global::quasselBuild) + reply["CoreInfo"] = tr("Quassel Core Version %1
" + "Built: %2
" + "Up %3d%4h%5m (since %6)").arg(Global::quasselVersion).arg(Global::quasselBuildDate) .arg(updays).arg(uphours,2,10,QChar('0')).arg(upmins,2,10,QChar('0')).arg(startTime.toString(Qt::TextDate)); #ifndef QT_NO_OPENSSL @@ -401,22 +423,19 @@ void Core::processClientMessage(QTcpSocket *socket, const QVariantMap &msg) { #else bool supportSsl = false; #endif - + +#ifndef QT_NO_COMPRESS + bool supportsCompression = true; +#else + bool supportsCompression = false; +#endif + reply["SupportSsl"] = supportSsl; - // switch to ssl after client has been informed about our capabilities (see below) + reply["SupportsCompression"] = supportsCompression; + // switch to ssl/compression after client has been informed about our capabilities (see below) reply["LoginEnabled"] = true; - // Just version information -- check it! - if(msg["ClientBuild"].toUInt() < Global::clientBuildNeeded) { - reply["MsgType"] = "ClientInitReject"; - reply["Error"] = tr("Your Quassel Client is too old!
" - "This core needs at least client version %1 (Build >= %2).
" - "Please consider upgrading your client.").arg(Global::quasselVersion).arg(Global::quasselBuild); - SignalProxy::writeDataToDevice(socket, reply); - qWarning() << qPrintable(tr("Client %1 too old, rejecting.").arg(socket->peerAddress().toString())); - socket->close(); return; - } // check if we are configured, start wizard otherwise if(!configured) { reply["Configured"] = false; @@ -439,12 +458,19 @@ void Core::processClientMessage(QTcpSocket *socket, const QVariantMap &msg) { #ifndef QT_NO_OPENSSL // after we told the client that we are ssl capable we switch to ssl mode if(supportSsl && msg["UseSsl"].toBool()) { - qDebug() << "Starting TLS for Client:" << qPrintable(socket->peerAddress().toString()); + qDebug() << "Starting TLS for Client:" << qPrintable(socket->peerAddress().toString()); connect(sslSocket, SIGNAL(sslErrors(const QList &)), this, SLOT(sslErrors(const QList &))); sslSocket->startServerEncryption(); } #endif +#ifndef QT_NO_COMPRESS + if(supportsCompression && msg["UseCompression"].toBool()) { + socket->setProperty("UseCompression", true); + qDebug() << "Using compression for Client:" << qPrintable(socket->peerAddress().toString()); + } +#endif + } else { // for the rest, we need an initialized connection if(!clientInfo.contains(socket)) {