56
56
if(!_storageBackends.count()) {
57
57
qWarning() << qPrintable(tr("Could not initialize any storage backend! Exiting..."));
58
qWarning() << qPrintable(tr("Currently, Quassel only supports SQLite3. You need to build your\n"
59
"Qt library with the sqlite plugin enabled in order for quasselcore\n"
58
61
exit(1); // TODO make this less brutal (especially for mono client -> popup)
60
63
connect(&_storageSyncTimer, SIGNAL(timeout()), this, SLOT(syncStorage()));
100
103
QVariantMap state;
101
104
QVariantList activeSessions;
102
105
foreach(UserId user, instance()->sessions.keys()) activeSessions << QVariant::fromValue<UserId>(user);
103
state["CoreBuild"] = Global::quasselBuild;
106
state["CoreStateVersion"] = 1;
104
107
state["ActiveSessions"] = activeSessions;
105
108
s.setCoreState(state);
118
uint build = s.coreState().toMap()["CoreBuild"].toUInt();
121
/* We don't check, since we are at the first version since switching to Git
122
uint statever = s.coreState().toMap()["CoreStateVersion"].toUInt();
120
124
qWarning() << qPrintable(tr("Core state too old, ignoring..."));
123
128
QVariantList activeSessions = s.coreState().toMap()["ActiveSessions"].toList();
124
129
if(activeSessions.count() > 0) {
125
130
qDebug() << "Restoring previous core state...";
307
312
return instance()->storage->requestBuffers(user);
315
QList<BufferId> Core::requestBufferIdsForNetwork(UserId user, NetworkId networkId) {
316
QMutexLocker locker(&mutex);
317
return instance()->storage->requestBufferIdsForNetwork(user, networkId);
310
320
bool Core::removeBuffer(const UserId &user, const BufferId &bufferId) {
311
321
QMutexLocker locker(&mutex);
312
322
return instance()->storage->removeBuffer(user, bufferId);
332
342
bool Core::startListening(uint port) {
333
343
if(!server.listen(QHostAddress::Any, port)) {
334
qWarning(qPrintable(QString("Could not open GUI client port %1: %2").arg(port).arg(server.errorString())));
344
qWarning("%s", qPrintable(QString("Could not open GUI client port %1: %2").arg(port).arg(server.errorString())));
337
347
qDebug() << "Listening for GUI clients on port" << server.serverPort();
382
392
// OK, so we have at least an init message format we can understand
383
393
if(msg["MsgType"] == "ClientInit") {
384
394
QVariantMap reply;
396
// Just version information -- check it!
397
if((msg.contains("ClientBuild") && msg["ClientBuild"].toUInt() < 732)
398
|| (!msg.contains("ClientBuild") && msg["ProtocolVersion"].toUInt() < Global::coreNeedsProtocol)) {
399
reply["MsgType"] = "ClientInitReject";
400
reply["Error"] = tr("<b>Your Quassel Client is too old!</b><br>"
401
"This core needs at least client/core protocol version %1.<br>"
402
"Please consider upgrading your client.").arg(Global::coreNeedsProtocol);
403
SignalProxy::writeDataToDevice(socket, reply);
404
qWarning() << qPrintable(tr("Client %1 too old, rejecting.").arg(socket->peerAddress().toString()));
405
socket->close(); return;
385
408
reply["CoreVersion"] = Global::quasselVersion;
386
reply["CoreDate"] = Global::quasselDate;
387
reply["CoreBuild"] = Global::quasselBuild;
409
reply["CoreDate"] = Global::quasselBuildDate;
410
reply["CoreBuild"] = 860; // FIXME legacy
411
reply["ProtocolVersion"] = Global::protocolVersion;
388
412
// TODO: Make the core info configurable
389
413
int uptime = startTime.secsTo(QDateTime::currentDateTime());
390
414
int updays = uptime / 86400; uptime %= 86400;
391
415
int uphours = uptime / 3600; uptime %= 3600;
392
416
int upmins = uptime / 60;
393
reply["CoreInfo"] = tr("<b>Quassel Core Version %1 (Build ≥ %2)</b><br>"
394
"Up %3d%4h%5m (since %6)").arg(Global::quasselVersion).arg(Global::quasselBuild)
417
reply["CoreInfo"] = tr("<b>Quassel Core Version %1</b><br>"
419
"Up %3d%4h%5m (since %6)").arg(Global::quasselVersion).arg(Global::quasselBuildDate)
395
420
.arg(updays).arg(uphours,2,10,QChar('0')).arg(upmins,2,10,QChar('0')).arg(startTime.toString(Qt::TextDate));
397
422
#ifndef QT_NO_OPENSSL
408
433
reply["LoginEnabled"] = true;
410
// Just version information -- check it!
411
if(msg["ClientBuild"].toUInt() < Global::clientBuildNeeded) {
412
reply["MsgType"] = "ClientInitReject";
413
reply["Error"] = tr("<b>Your Quassel Client is too old!</b><br>"
414
"This core needs at least client version %1 (Build >= %2).<br>"
415
"Please consider upgrading your client.").arg(Global::quasselVersion).arg(Global::quasselBuild);
416
SignalProxy::writeDataToDevice(socket, reply);
417
qWarning() << qPrintable(tr("Client %1 too old, rejecting.").arg(socket->peerAddress().toString()));
418
socket->close(); return;
420
435
// check if we are configured, start wizard otherwise
421
436
if(!configured) {
422
437
reply["Configured"] = false;