summaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorTopi Reinio <topi.reinio@digia.com>2014-01-31 11:06:52 +0100
committerTopi Reiniƶ <topi.reinio@digia.com>2014-02-03 11:13:34 +0200
commit711bfedc706f609cce586406647cfb4ef4547f15 (patch)
tree14245ddcdce10d72443620384ec2f0f922ae1645 /src/utils
parentca32a427ba15ddcf410e84069416757d366612f4 (diff)
Improve QDroidUtils IP address retrieval
Instead of returning the first IP address from eth0, return a comma-separated list. This ensures that the IPv4 address is shown in Launcher Settings demo, important as it's required for setting up the connection to Raspberry Pi in Qt Creator (sometimes, IPv6 address is shown as first entry). Also, cleans up the garbage (trailing %eth0) returned for IPv6 addresses. Change-Id: Ibced367ba443ac76c2ad2a4f2589c9edcbc74b7f Reviewed-by: Eirik Aavitsland <eirik.aavitsland@digia.com>
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/qdroidutils.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/utils/qdroidutils.cpp b/src/utils/qdroidutils.cpp
index 67d8d29..0952345 100644
--- a/src/utils/qdroidutils.cpp
+++ b/src/utils/qdroidutils.cpp
@@ -229,22 +229,22 @@ bool QDroidUtils::setDisplayBrightness(quint8 value)
/*!
- * Gets the current IP address of the device
+ * Gets the current IP address(es) of the device
*/
QString QDroidUtils::getIPAddress()
{
- QString address;
+ QStringList addresses;
#ifdef Q_OS_ANDROID_NO_SDK
qDebug("QDroidUtils::getIPAddress()");
#else
QNetworkInterface interface = QNetworkInterface::interfaceFromName("eth0");
QList<QNetworkAddressEntry> entries;
entries = interface.addressEntries();
- if ( !entries.empty() ) {
- address = entries.first().ip().toString();
+ foreach (const QNetworkAddressEntry &entry, entries) {
+ addresses.append(entry.ip().toString().split('%').first());
}
#endif
- return address;
+ return addresses.join(QStringLiteral(", "));
}
/*!