# HG changeset patch # User Jari Korhonen # Date 1274216180 -10800 # Node ID 465fbf9ad5a9059990a42b338ac02122db10629e # Parent 799cfade2cb3a1b5b11c26266d4a19cd06a6f5d2 Tries to show hg serve ipv6 address correctly (at least for browser, dont know about hg itself). diff -r 799cfade2cb3 -r 465fbf9ad5a9 mainwindow.cpp --- a/mainwindow.cpp Tue May 18 01:56:40 2010 +0300 +++ b/mainwindow.cpp Tue May 18 23:56:20 2010 +0300 @@ -546,20 +546,33 @@ } -QString MainWindow::findMyIps() +QString MainWindow::findMyIp(bool& isAddrIpV6) { QString ret; QHostInfo info = QHostInfo::fromName(QHostInfo::localHostName()); QList ipList = info.addresses(); + if (!ipList.isEmpty()) { QHostAddress addr = ipList.at(0); + + if (QAbstractSocket::IPv6Protocol == addr.protocol()) + { + isAddrIpV6 = true; + } + else + { + isAddrIpV6 = false; + } + ret = addr.toString(); } else { - ret = "unknown"; + //This won't help your teammate much, but is funny ;-) + ret = "127.0.0.1"; + isAddrIpV6 = false; } return ret; @@ -570,15 +583,24 @@ if (runningAction == ACT_NONE) { QStringList params; + QString msg; + bool isIpv6; - params << "serve"; + QString addr = findMyIp(isIpv6); + if (isIpv6) + { + QTextStream(&msg) << "Server running on http://[" << addr << "]:8000/"; + params << "serve" << "--ipv6"; + } + else + { + QTextStream(&msg) << "Server running on http://" << addr << ":8000/"; + params << "serve"; + } runner -> startProc(getHgBinaryName(), workFolderPath, params, false); runningAction = ACT_SERVE; - QString msg; - - QTextStream(&msg) << "Server running on http://" << findMyIps() << ":8000/"; QMessageBox::information(this, "Serve", msg, QMessageBox::Close); runner -> killProc(); }