X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcore%2Fcore.cpp;h=f9f8673cb3f69b4f3ce46a118459f4fe3b78fa00;hb=d07c7f8e2de851adefcee45049bb1bb19682d0c6;hp=8a1c777135038ffae1300fd891745fd78ecfa419;hpb=9a36f8e55bfa485467e093fba669841fdfacda2f;p=quassel.git diff --git a/src/core/core.cpp b/src/core/core.cpp index 8a1c7771..f9f8673c 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..."; @@ -207,6 +209,16 @@ void Core::syncStorage() { } /*** Storage Access ***/ +void Core::setUserSetting(UserId userId, const QString &settingName, const QVariant &data) { + QMutexLocker locker(&mutex); + instance()->storage->setUserSetting(userId, settingName, data); +} + +QVariant Core::getUserSetting(UserId userId, const QString &settingName, const QVariant &data) { + QMutexLocker locker(&mutex); + return instance()->storage->getUserSetting(userId, settingName, data); +} + bool Core::createNetwork(UserId user, NetworkInfo &info) { QMutexLocker locker(&mutex); NetworkId networkId = instance()->storage->createNetwork(user, info); @@ -292,9 +304,9 @@ QList Core::requestMsgRange(UserId user, BufferId buffer, int first, in return instance()->storage->requestMsgRange(user, buffer, first, last); } -QList Core::requestBuffers(UserId user, QDateTime since) { +QList Core::requestBuffers(UserId user) { QMutexLocker locker(&mutex); - return instance()->storage->requestBuffers(user, since); + return instance()->storage->requestBuffers(user); } bool Core::removeBuffer(const UserId &user, const BufferId &bufferId) { @@ -372,16 +384,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 @@ -391,22 +418,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; @@ -429,12 +453,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)) { @@ -468,7 +499,7 @@ void Core::processClientMessage(QTcpSocket *socket, const QVariantMap &msg) { } reply["MsgType"] = "ClientLoginAck"; SignalProxy::writeDataToDevice(socket, reply); - qDebug() << qPrintable(tr("Client %1 initialized and authentificated successfully as \"%2\".").arg(socket->peerAddress().toString(), msg["User"].toString())); + qDebug() << qPrintable(tr("Client %1 initialized and authenticated successfully as \"%2\" (UserId: %3).").arg(socket->peerAddress().toString(), msg["User"].toString()).arg(uid.toInt())); setupClientSession(socket, uid); } }