~ubuntu-branches/ubuntu/raring/quassel/raring-proposed

« back to all changes in this revision

Viewing changes to src/core/core.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Harald Sitter
  • Date: 2008-06-27 19:21:30 UTC
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20080627192130-kjsrutd8w40x5okn
Tags: upstream-0.2.0~rc1
ImportĀ upstreamĀ versionĀ 0.2.0~rc1

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
 
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"
 
60
                                "to work."));
58
61
    exit(1); // TODO make this less brutal (especially for mono client -> popup)
59
62
  }
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);
106
109
}
115
118
    return;
116
119
  }
117
120
  CoreSettings s;
118
 
  uint build = s.coreState().toMap()["CoreBuild"].toUInt();
119
 
  if(build < 362) {
 
121
  /* We don't check, since we are at the first version since switching to Git
 
122
  uint statever = s.coreState().toMap()["CoreStateVersion"].toUInt();
 
123
  if(statever < 1) {
120
124
    qWarning() << qPrintable(tr("Core state too old, ignoring..."));
121
125
    return;
122
126
  }
 
127
  */
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);
308
313
}
309
314
 
 
315
QList<BufferId> Core::requestBufferIdsForNetwork(UserId user, NetworkId networkId) {
 
316
  QMutexLocker locker(&mutex);
 
317
  return instance()->storage->requestBufferIdsForNetwork(user, networkId);
 
318
}
 
319
 
310
320
bool Core::removeBuffer(const UserId &user, const BufferId &bufferId) {
311
321
  QMutexLocker locker(&mutex);
312
322
  return instance()->storage->removeBuffer(user, bufferId);
331
341
 
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())));
335
345
    return false;
336
346
  }
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;
 
395
 
 
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;
 
406
    }
 
407
 
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 &ge; %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>"
 
418
                            "Built: %2<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));
396
421
 
397
422
#ifndef QT_NO_OPENSSL
407
432
 
408
433
    reply["LoginEnabled"] = true;
409
434
 
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;
419
 
    }
420
435
    // check if we are configured, start wizard otherwise
421
436
    if(!configured) {
422
437
      reply["Configured"] = false;