Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Neugebauer <jan.neugebauer@stud.uni-hannover.de>2022-06-02 19:04:44 +0300
committerJan Neugebauer <jan.neugebauer@stud.uni-hannover.de>2022-06-05 21:03:35 +0300
commit1a0e048865027e29339d2db8ec67b86c85f60c00 (patch)
tree6e0bfb22fbe5615dd4bc1579fb370b1538e2c7f9
parentdd5df45313a937359285327f556557159bab758e (diff)
FEAT(client, ui): separate ipv4 and ipv6 in ServerItem tooltip
The "Addresses" field in the ServerItem tooltip shows both ipv4 and ipv6 addresses. The order of addresses in this field is not determined. In the wild it is randomized. As discussed in #5696 it is better to implement a concrete ordering to prevent user confusion. To further improve the readability of the addresses we split the addresses field in two fields called "IPv4 address" and "IPv6 address". The ipv4 address is now always shown above the ipv6 address. Implements #5696 Co-Authored-By: Thomas Pawelek <thomas.pawelek@stud.uni-hannover.de>
-rw-r--r--src/HostAddress.cpp25
-rw-r--r--src/HostAddress.h2
-rw-r--r--src/mumble/ConnectDialog.cpp24
3 files changed, 36 insertions, 15 deletions
diff --git a/src/HostAddress.cpp b/src/HostAddress.cpp
index 8c6a68f8c..a726be164 100644
--- a/src/HostAddress.cpp
+++ b/src/HostAddress.cpp
@@ -135,22 +135,29 @@ quint32 qHash(const HostAddress &ha) {
return (ha.hash[0] ^ ha.hash[1] ^ ha.hash[2] ^ ha.hash[3]);
}
-QString HostAddress::toString() const {
+QString HostAddress::toString(bool bracketEnclosed) const {
if (isV6()) {
if (isValid()) {
- QString qs;
+ QString str;
+ const char *squareBracketOpen = "";
+ const char *squareBracketClose = "";
+ if (bracketEnclosed) {
+ squareBracketOpen = "[";
+ squareBracketClose = "]";
+ }
#if QT_VERSION >= 0x050500
- qs = QString::asprintf("[%x:%x:%x:%x:%x:%x:%x:%x]", ntohs(shorts[0]), ntohs(shorts[1]), ntohs(shorts[2]),
- ntohs(shorts[3]), ntohs(shorts[4]), ntohs(shorts[5]), ntohs(shorts[6]),
- ntohs(shorts[7]));
+ str = QString::asprintf("%s%x:%x:%x:%x:%x:%x:%x:%x%s", squareBracketOpen, ntohs(shorts[0]),
+ ntohs(shorts[1]), ntohs(shorts[2]), ntohs(shorts[3]), ntohs(shorts[4]),
+ ntohs(shorts[5]), ntohs(shorts[6]), ntohs(shorts[7]), squareBracketClose);
#else
// sprintf() has been deprecated in Qt 5.5 in favor for the static QString::asprintf()
- qs.sprintf("[%x:%x:%x:%x:%x:%x:%x:%x]", ntohs(shorts[0]), ntohs(shorts[1]), ntohs(shorts[2]),
- ntohs(shorts[3]), ntohs(shorts[4]), ntohs(shorts[5]), ntohs(shorts[6]), ntohs(shorts[7]));
+ str.sprintf("%s%x:%x:%x:%x:%x:%x:%x:%x%s", squareBracketOpen, ntohs(shorts[0]), ntohs(shorts[1]),
+ ntohs(shorts[2]), ntohs(shorts[3]), ntohs(shorts[4]), ntohs(shorts[5]), ntohs(shorts[6]),
+ ntohs(shorts[7]), squareBracketClose);
#endif
- return qs.replace(QRegExp(QLatin1String("(:0)+")), QLatin1String(":"));
+ return str.replace(QRegExp(QLatin1String("(:0)+")), QLatin1String(":"));
} else {
- return QLatin1String("[::]");
+ return bracketEnclosed ? QLatin1String("[::]") : QLatin1String("::");
}
} else {
return QHostAddress(ntohl(hash[3])).toString();
diff --git a/src/HostAddress.h b/src/HostAddress.h
index 761cf945d..d0b65a608 100644
--- a/src/HostAddress.h
+++ b/src/HostAddress.h
@@ -35,7 +35,7 @@ struct HostAddress {
bool match(const HostAddress &, int bits) const;
- QString toString() const;
+ QString toString(bool bracketEnclosed = true) const;
std::string toStdString() const;
QHostAddress toAddress() const;
diff --git a/src/mumble/ConnectDialog.cpp b/src/mumble/ConnectDialog.cpp
index d3655d826..f53e6ea85 100644
--- a/src/mumble/ConnectDialog.cpp
+++ b/src/mumble/ConnectDialog.cpp
@@ -473,11 +473,23 @@ QVariant ServerItem::data(int column, int role) const {
return uiUsers ? QString::fromLatin1("%1/%2 ").arg(uiUsers).arg(uiMaxUsers) : QVariant();
}
} else if (role == Qt::ToolTipRole) {
- QStringList qsl;
+ QStringList ipv4List;
+ QStringList ipv6List;
foreach (const ServerAddress &addr, qlAddresses) {
- const QString qsAddress = addr.host.toString() + QLatin1String(":")
- + QString::number(static_cast< unsigned long >(addr.port));
- qsl << qsAddress.toHtmlEscaped();
+ const QString address = addr.host.toString(false).toHtmlEscaped();
+ if (addr.host.isV6()) {
+ ipv6List << address;
+ } else {
+ ipv4List << address;
+ }
+ }
+ QString ipv4 = "-";
+ QString ipv6 = "-";
+ if (!ipv4List.isEmpty()) {
+ ipv4 = ipv4List.join(QLatin1String(", "));
+ }
+ if (!ipv6List.isEmpty()) {
+ ipv6 = ipv6List.join(QLatin1String(", "));
}
double ploss = 100.0;
@@ -500,7 +512,9 @@ QVariant ServerItem::data(int column, int role) const {
.arg(ConnectDialog::tr("Port"))
.arg(usPort)
+ QString::fromLatin1("<tr><th align=left>%1</th><td>%2</td></tr>")
- .arg(ConnectDialog::tr("Addresses"), qsl.join(QLatin1String(", ")));
+ .arg(ConnectDialog::tr("IPv4 address"), ipv4)
+ + QString::fromLatin1("<tr><th align=left>%1</th><td>%2</td></tr>")
+ .arg(ConnectDialog::tr("IPv6 address"), ipv6);
if (!qsUrl.isEmpty())
qs += QString::fromLatin1("<tr><th align=left>%1</th><td>%2</td></tr>")