# HG changeset patch # User Jari Korhonen # Date 1275075284 -10800 # Node ID 90ffef5f049483daa3902cc5c76f94aeea3b322f # Parent 6e8cd5ffa4dff91ce082ad5e96383201dfa28ee0 Another attempt to list hg serve ip addresses ;-) diff -r 6e8cd5ffa4df -r 90ffef5f0494 common.h --- a/common.h Thu May 20 23:03:49 2010 +0300 +++ b/common.h Fri May 28 22:34:44 2010 +0300 @@ -6,7 +6,7 @@ #include #define APPNAME "HgExplorer" -#define APPVERSION "0.4.4" +#define APPVERSION "0.4.5" #define MY_ICON_SIZE 32 #define REPOMENU_TITLE "Repository actions" #define WORKFOLDERMENU_TITLE "Workfolder actions" diff -r 6e8cd5ffa4df -r 90ffef5f0494 mainwindow.cpp --- a/mainwindow.cpp Thu May 20 23:03:49 2010 +0300 +++ b/mainwindow.cpp Fri May 28 22:34:44 2010 +0300 @@ -548,57 +548,34 @@ -void MainWindow::listAllUpAddresses() +QString MainWindow::listAllUpIpV4Addresses() { + QString ret; QList ifaces = QNetworkInterface::allInterfaces(); for (int i = 0; i < ifaces.count(); i++) { QNetworkInterface iface = ifaces.at(i); - QString msg; - - QTextStream(&msg) << "name: " << iface.name() << endl << "mac: " << iface.hardwareAddress() << endl; - QMessageBox::information(this, "interface", msg); - if (iface.flags().testFlag(QNetworkInterface::IsUp) && !iface.flags().testFlag(QNetworkInterface::IsLoopBack)) { - // this loop is important for (int j=0; j ipList = QNetworkInterface::allAddresses(); - - - if (!ipList.isEmpty()) - { - for(int i = 0; i < ipList.size(); i++) - { - QHostAddress addr = ipList.at(i); - - if (QAbstractSocket::IPv4Protocol == addr.protocol()) - { - if (addr != QHostAddress::LocalHost) + QHostAddress tmp = iface.addressEntries().at(j).ip(); + if (QAbstractSocket::IPv4Protocol == tmp.protocol()) { - return addr.toString(); + if (!ret.isEmpty()) + { + ret += " "; + } + ret += tmp.toString(); } } } } + return ret; +} - //This won't help your teammate much but is funny ;-) - return "127.0.0.1"; -} void MainWindow::hgServe() { @@ -607,9 +584,9 @@ QStringList params; QString msg; - QString addr = findMyIp(); - QTextStream(&msg) << "Server running on http://" << addr << ":8000/"; - params << "serve" << "--address" << addr << "--port" << "8000"; + QString addrs = listAllUpIpV4Addresses(); + QTextStream(&msg) << "Server running on address(es) (" << addrs << "), port 8000"; + params << "serve"; runner -> startProc(getHgBinaryName(), workFolderPath, params, false); runningAction = ACT_SERVE; diff -r 6e8cd5ffa4df -r 90ffef5f0494 mainwindow.h --- a/mainwindow.h Thu May 20 23:03:49 2010 +0300 +++ b/mainwindow.h Fri May 28 22:34:44 2010 +0300 @@ -152,8 +152,7 @@ bool areAllSelectedUntracked(QListWidget *workList); bool isSelectedDeletable(QListWidget *workList); bool areAllSelectedCommitable(QListWidget *workList); - QString findMyIp(); - void listAllUpAddresses(); + QString listAllUpIpV4Addresses(); //Actions enabled flags