diff options
-rw-r--r-- | src/QtUtils.cpp | 15 | ||||
-rw-r--r-- | src/QtUtils.h | 11 | ||||
-rw-r--r-- | src/mumble/UserInformation.cpp | 16 | ||||
-rw-r--r-- | src/mumble/ViewCert.cpp | 9 |
4 files changed, 30 insertions, 21 deletions
diff --git a/src/QtUtils.cpp b/src/QtUtils.cpp index 6f22fdfbf..4a71e0ff2 100644 --- a/src/QtUtils.cpp +++ b/src/QtUtils.cpp @@ -4,10 +4,25 @@ // Mumble source tree or at <https://www.mumble.info/LICENSE>. #include <QObject> +#include <QUrl> +#include <QStringList> namespace Mumble { namespace QtUtils { void deleteQObject(QObject *object) { object->deleteLater(); } + QString decode_utf8_qssl_string(const QString &input) { + QString i = input; + return QUrl::fromPercentEncoding(i.replace(QLatin1String("\\x"), QLatin1String("%")).toLatin1()); + } + + QString decode_first_utf8_qssl_string(const QStringList &list) { + if (list.count() > 0) { + return decode_utf8_qssl_string(list.at(0)); + } + return QString(); + } + + }; // namespace QtUtils }; // namespace Mumble diff --git a/src/QtUtils.h b/src/QtUtils.h index 7fc09246b..74a3808b4 100644 --- a/src/QtUtils.h +++ b/src/QtUtils.h @@ -6,7 +6,10 @@ #ifndef MUMBLE_QTUTILS_H_ #define MUMBLE_QTUTILS_H_ +#include <QString> + class QObject; +class QStringList; namespace Mumble { namespace QtUtils { @@ -20,6 +23,14 @@ namespace QtUtils { */ void deleteQObject(QObject *object); + QString decode_utf8_qssl_string(const QString &input); + + /** + * Applies decode_utf8_qssl_string on the first element in the + * given list. If the list is empty an empty String is returned. + */ + QString decode_first_utf8_qssl_string(const QStringList &list); + }; // namespace QtUtils }; // namespace Mumble diff --git a/src/mumble/UserInformation.cpp b/src/mumble/UserInformation.cpp index f234169c7..1ecc996e9 100644 --- a/src/mumble/UserInformation.cpp +++ b/src/mumble/UserInformation.cpp @@ -8,23 +8,11 @@ #include "Audio.h" #include "CELTCodec.h" #include "HostAddress.h" +#include "QtUtils.h" #include "ServerHandler.h" #include "ViewCert.h" #include "Global.h" -#include <QtCore/QUrl> - -static QString decode_utf8_qssl_string(const QString &input) { - QString i = input; - return QUrl::fromPercentEncoding(i.replace(QLatin1String("\\x"), QLatin1String("%")).toLatin1()); -} - -static QString decode_utf8_qssl_string(const QStringList &list) { - if (list.count() > 0) { - return decode_utf8_qssl_string(list.at(0)); - } - return QString(); -} UserInformation::UserInformation(const MumbleProto::UserStats &msg, QWidget *p) : QDialog(p) { setupUi(this); @@ -116,7 +104,7 @@ void UserInformation::update(const MumbleProto::UserStats &msg) { if (alts.contains(QSsl::EmailEntry)) qlCertificate->setText(QStringList(alts.values(QSsl::EmailEntry)).join(tr(", "))); else - qlCertificate->setText(decode_utf8_qssl_string(cert.subjectInfo(QSslCertificate::CommonName))); + qlCertificate->setText(Mumble::QtUtils::decode_first_utf8_qssl_string(cert.subjectInfo(QSslCertificate::CommonName))); if (msg.strong_certificate()) { QFont f = qfCertificateFont; diff --git a/src/mumble/ViewCert.cpp b/src/mumble/ViewCert.cpp index 19f4968f3..366987a1d 100644 --- a/src/mumble/ViewCert.cpp +++ b/src/mumble/ViewCert.cpp @@ -4,8 +4,8 @@ // Mumble source tree or at <https://www.mumble.info/LICENSE>. #include "ViewCert.h" +#include "QtUtils.h" -#include <QtCore/QUrl> #include <QtNetwork/QSslKey> #include <QtWidgets/QDialogButtonBox> #include <QtWidgets/QGroupBox> @@ -13,14 +13,9 @@ #include <QtWidgets/QListWidget> #include <QtWidgets/QVBoxLayout> -static QString decode_utf8_qssl_string(const QString &input) { - QString i = input; - return QUrl::fromPercentEncoding(i.replace(QLatin1String("\\x"), QLatin1String("%")).toLatin1()); -} - static QStringList processQSslCertificateInfo(QStringList in) { QStringList list; - foreach (QString str, in) { list << decode_utf8_qssl_string(str); } + foreach (QString str, in) { list << Mumble::QtUtils::decode_utf8_qssl_string(str); } return list; } |