~ubuntu-branches/ubuntu/jaunty/quassel/jaunty

« back to all changes in this revision

Viewing changes to src/core/core.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2009-01-19 23:45:13 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20090119234513-81rdu99b9ro36px8
Tags: 0.4.0~git090119-0ubuntu1
* New upstream git snapshot
  - Fixes KDE logout problem
  - Other bug fixes
  - SSL cert handling improvements

Show diffs side-by-side

added added

removed removed

Lines of Context:
244
244
  bool success = false;
245
245
  uint port = Quassel::optionValue("port").toUInt();
246
246
 
247
 
  if(_server.listen(QHostAddress::Any, port)) {
248
 
    quInfo() << "Listening for GUI clients on IPv4 port" << _server.serverPort()
249
 
             << "using protocol version" << Quassel::buildInfo().protocolVersion;
250
 
    success = true;
251
 
  }
252
 
  if(_v6server.listen(QHostAddress::AnyIPv6, port)) {
253
 
    quInfo() << "Listening for GUI clients on IPv6 port" << _v6server.serverPort()
254
 
             << "using protocol version" << Quassel::buildInfo().protocolVersion;
255
 
    success = true;
256
 
  }
257
 
 
258
 
  if(!success) {
259
 
    qCritical() << qPrintable(QString("Could not open GUI client port %1: %2").arg(port).arg(_server.errorString()));
260
 
  }
 
247
  const QString listen = Quassel::optionValue("listen");
 
248
  const QStringList listen_list = listen.split(",", QString::SkipEmptyParts);
 
249
  if(listen_list.size() > 0) {
 
250
    foreach (const QString listen_term, listen_list) {  // TODO: handle multiple interfaces for same TCP version gracefully
 
251
      QHostAddress addr;
 
252
      if(!addr.setAddress(listen_term)) {
 
253
        qCritical() << qPrintable(
 
254
          tr("Invalid listen address %1")
 
255
            .arg(listen_term)
 
256
        );
 
257
      } else {
 
258
        switch(addr.protocol()) {
 
259
          case QAbstractSocket::IPv4Protocol:
 
260
            if(_server.listen(addr, port)) {
 
261
              quInfo() << qPrintable(
 
262
                tr("Listening for GUI clients on IPv4 %1 port %2 using protocol version %3")
 
263
                  .arg(addr.toString())
 
264
                  .arg(_server.serverPort())
 
265
                  .arg(Quassel::buildInfo().protocolVersion)
 
266
              );
 
267
              success = true;
 
268
            } else
 
269
              quWarning() << qPrintable(
 
270
                tr("Could not open IPv4 interface %1:%2: %3")
 
271
                  .arg(addr.toString())
 
272
                  .arg(port)
 
273
                  .arg(_server.errorString()));
 
274
            break;
 
275
          case QAbstractSocket::IPv6Protocol:
 
276
            if(_v6server.listen(addr, port)) {
 
277
              quInfo() << qPrintable(
 
278
                tr("Listening for GUI clients on IPv6 %1 port %2 using protocol version %3")
 
279
                  .arg(addr.toString())
 
280
                  .arg(_v6server.serverPort())
 
281
                  .arg(Quassel::buildInfo().protocolVersion)
 
282
              );
 
283
              success = true;
 
284
            } else {
 
285
              // if v4 succeeded on Any, the port will be already in use - don't display the error then
 
286
              // FIXME: handle this more sanely, make sure we can listen to both v4 and v6 by default!
 
287
              if(!success || _v6server.serverError() != QAbstractSocket::AddressInUseError)
 
288
                quWarning() << qPrintable(
 
289
                  tr("Could not open IPv6 interface %1:%2: %3")
 
290
                  .arg(addr.toString())
 
291
                  .arg(port)
 
292
                  .arg(_v6server.errorString()));
 
293
            }
 
294
            break;
 
295
          default:
 
296
            qCritical() << qPrintable(
 
297
              tr("Invalid listen address %1, unknown network protocol")
 
298
                  .arg(listen_term)
 
299
            );
 
300
            break;
 
301
        }
 
302
      }
 
303
    }
 
304
  }
 
305
  if(!success)
 
306
    quError() << qPrintable(tr("Could not open any network interfaces to listen on!"));
261
307
 
262
308
  return success;
263
309
}
350
396
#ifdef HAVE_SSL
351
397
    SslServer *sslServer = qobject_cast<SslServer *>(&_server);
352
398
    QSslSocket *sslSocket = qobject_cast<QSslSocket *>(socket);
353
 
    bool supportSsl = (bool)sslServer && (bool)sslSocket && sslServer->certIsValid();
 
399
    bool supportSsl = (bool)sslServer && (bool)sslSocket && sslServer->isCertValid();
354
400
#else
355
401
    bool supportSsl = false;
356
402
#endif