diff options
51 files changed, 477 insertions, 100 deletions
diff --git a/plugins/manual/.qmake.cache b/plugins/manual/.qmake.cache index eb979e467..36951b2b4 100644 --- a/plugins/manual/.qmake.cache +++ b/plugins/manual/.qmake.cache @@ -1 +1 @@ -QMAKEFEATURES=features/ +QMAKEFEATURES=$$_PRO_FILE_PWD_/features/ diff --git a/plugins/manual/manual.cpp b/plugins/manual/manual.cpp index d57eaa23d..30b8a5ed5 100644 --- a/plugins/manual/manual.cpp +++ b/plugins/manual/manual.cpp @@ -32,7 +32,12 @@ #include <QtCore/QtCore> #include <QtGui/QtGui> +#if QT_VERSION >= 0x050000 +#include <QtWidgets/QMessageBox> +#else #include <QMessageBox> +#endif + #include <QPointer> #include <math.h> #include <float.h> diff --git a/plugins/manual/manual.h b/plugins/manual/manual.h index 5ad6916f9..ac727d431 100644 --- a/plugins/manual/manual.h +++ b/plugins/manual/manual.h @@ -1,9 +1,16 @@ #ifndef MUMBLE_MANUAL_H_ #define MUMBLE_MANUAL_H_ -#include <QDialog> -#include <QGraphicsItem> -#include <QGraphicsScene> +#if QT_VERSION >= 0x050000 +# include <QtWidgets/QDialog> +# include <QtWidgets/QGraphicsItem> +# include <QtWidgets/QGraphicsScene> +#else +# include <QDialog> +# include <QGraphicsItem> +# include <QGraphicsScene> +#endif + #include "ui_manual.h" class Manual : public QDialog, public Ui::Manual { diff --git a/plugins/manual/manual.pro b/plugins/manual/manual.pro index 191622efa..38f4a916d 100644 --- a/plugins/manual/manual.pro +++ b/plugins/manual/manual.pro @@ -1,7 +1,10 @@ include(../plugins.pri) TARGET = manual +CONFIG += qt +isEqual(QT_MAJOR_VERSION, 5) { + QT *= widgets +} HEADERS = manual.h SOURCES = manual.cpp -CONFIG += qt FORMS += manual.ui @@ -0,0 +1,2 @@ +QT_VERSION = $$[QT_VERSION] +QT_MAJOR_VERSION = $$section(QT_VERSION, ., 0, 0) diff --git a/src/Connection.h b/src/Connection.h index 69ad19907..53518ecb2 100644 --- a/src/Connection.h +++ b/src/Connection.h @@ -106,6 +106,8 @@ class Connection : public QObject { #endif }; +#if QT_VERSION < 0x050000 Q_DECLARE_METATYPE(QAbstractSocket::SocketError) +#endif #endif diff --git a/src/Group.cpp b/src/Group.cpp index 32468ceea..ec8962d82 100644 --- a/src/Group.cpp +++ b/src/Group.cpp @@ -139,24 +139,24 @@ bool Group::isMember(Channel *curChan, Channel *aclChan, QString name, ServerUse if (name.isEmpty()) return false; - if (name.startsWith(QChar::fromAscii('!'))) { + if (name.startsWith(QChar::fromLatin1('!'))) { invert = true; name = name.remove(0,1); continue; } - if (name.startsWith(QChar::fromAscii('~'))) { + if (name.startsWith(QChar::fromLatin1('~'))) { c = aclChan; name = name.remove(0,1); continue; } - if (name.startsWith(QChar::fromAscii('#'))) { + if (name.startsWith(QChar::fromLatin1('#'))) { token = true; name = name.remove(0,1); continue; } - if (name.startsWith(QChar::fromAscii('$'))) { + if (name.startsWith(QChar::fromLatin1('$'))) { hash = true; name = name.remove(0,1); continue; diff --git a/src/OSInfo.cpp b/src/OSInfo.cpp index b1cae4cf3..016b1b409 100644 --- a/src/OSInfo.cpp +++ b/src/OSInfo.cpp @@ -30,15 +30,15 @@ #include "murmur_pch.h" -#ifdef Q_WS_WIN +#if defined(Q_OS_WIN) #include <intrin.h> #endif -#ifdef Q_WS_X11 +#ifdef Q_OS_UNIX && !defined(Q_OS_MAC) #include <sys/utsname.h> #endif -#ifdef Q_WS_MAC +#if defined(Q_OS_MAC) #include <sys/types.h> #include <sys/sysctl.h> #include <mach-o/arch.h> @@ -57,7 +57,7 @@ QString OSInfo::getMacHash(const QList<QHostAddress> &qlBind) { if (qni.hardwareAddress().isEmpty()) continue; - QString hash = QString::fromAscii(QCryptographicHash::hash(qni.hardwareAddress().toAscii(), QCryptographicHash::Sha1).toHex()); + QString hash = QString::fromUtf8(QCryptographicHash::hash(qni.hardwareAddress().toUtf8(), QCryptographicHash::Sha1).toHex()); if (third.isEmpty() || third > hash) third = hash; @@ -86,9 +86,9 @@ QString OSInfo::getMacHash(const QList<QHostAddress> &qlBind) { } QString OSInfo::getOS() { -#if defined(Q_WS_WIN) +#if defined(Q_OS_WIN) return QLatin1String("Win"); -#elif defined(Q_WS_MAC) +#elif defined(Q_OS_MAC) return QLatin1String("OSX"); #else return QLatin1String("X11"); @@ -103,7 +103,7 @@ QString OSInfo::getOSVersion() { QString os; -#if defined(Q_WS_WIN) +#if defined(Q_OS_WIN) OSVERSIONINFOEXW ovi; memset(&ovi, 0, sizeof(ovi)); @@ -198,11 +198,11 @@ void OSInfo::fillXml(QDomDocument &doc, QDomElement &root, const QString &os, co t=doc.createTextNode(QString::fromLatin1(qVersion())); tag.appendChild(t); -#if defined(Q_WS_WIN) +#if defined(Q_OS_WIN) BOOL bIsWow64 = FALSE; IsWow64Process(GetCurrentProcess(), &bIsWow64); bIs64 = bIsWow64; -#elif defined(Q_WS_MAC) +#elif defined(Q_OS_MAC) size_t len = sizeof(bool); sysctlbyname("hw.cpu64bit_capable", &bIs64, &len, NULL, 0); #else @@ -213,7 +213,7 @@ void OSInfo::fillXml(QDomDocument &doc, QDomElement &root, const QString &os, co t=doc.createTextNode(QString::number(bIs64 ? 1 : 0)); tag.appendChild(t); -#if defined(Q_WS_WIN) +#if defined(Q_OS_WIN) #define regstr(x) QString::fromLatin1(reinterpret_cast<const char *>(& x), 4) int chop; int cpuinfo[4]; diff --git a/src/mumble.pri b/src/mumble.pri index e5f033378..d2f107fee 100644 --- a/src/mumble.pri +++ b/src/mumble.pri @@ -1,4 +1,5 @@ include(../compiler.pri) +include(../qt.pri) VERSION = 1.2.5 DIST = mumble.pri Message.h PacketDataStream.h CryptState.h Timer.h Version.h OSInfo.h SSL.h Mumble.proto diff --git a/src/mumble/About.h b/src/mumble/About.h index 8b2dfa07c..4f0c88c63 100644 --- a/src/mumble/About.h +++ b/src/mumble/About.h @@ -32,7 +32,12 @@ #define MUMBLE_MUMBLE_ABOUT_H_ #include <QtCore/QObject> -#include <QtGui/QDialog> + +#if QT_VERSION >= 0x050000 +# include <QtWidgets/QDialog> +#else +# include <QtGui/QDialog> +#endif class AboutDialog : public QDialog { private: diff --git a/src/mumble/AudioStats.h b/src/mumble/AudioStats.h index 02786cd9e..0221afaa5 100644 --- a/src/mumble/AudioStats.h +++ b/src/mumble/AudioStats.h @@ -33,7 +33,12 @@ #include <QtCore/QList> #include <QtCore/QTimer> -#include <QtGui/QWidget> + +#if QT_VERSION >= 0x050000 +# include <QtWidgets/QWidget> +#else +# include <QtGui/QWidget> +#endif class AudioBar : public QWidget { private: diff --git a/src/mumble/AudioWizard.h b/src/mumble/AudioWizard.h index 39109e8ac..13dbbb7b4 100644 --- a/src/mumble/AudioWizard.h +++ b/src/mumble/AudioWizard.h @@ -31,8 +31,13 @@ #ifndef MUMBLE_MUMBLE_AUDIOWIZARD_H_ #define MUMBLE_MUMBLE_AUDIOWIZARD_H_ -#include <QtGui/QWizard> -#include <QtGui/QWizardPage> +#if QT_VERSION >= 0x050000 +# include <QtWidgets/QWizard> +# include <QtWidgets/QWizardPage> +#else +# include <QtGui/QWizard> +# include <QtGui/QWizardPage> +#endif #include "AudioStats.h" #include "AudioOutput.h" diff --git a/src/mumble/Cert.cpp b/src/mumble/Cert.cpp index 20d376625..115651418 100644 --- a/src/mumble/Cert.cpp +++ b/src/mumble/Cert.cpp @@ -92,9 +92,18 @@ void CertView::setCert(const QList<QSslCertificate> &cert) { } else { QSslCertificate qscCert = qlCert.at(0); - QStringList emails(qscCert.alternateSubjectNames().values(QSsl::EmailEntry)); +#if QT_VERSION >= 0x050000 + const QStringList &names = qscCert.subjectInfo(QSslCertificate::CommonName); + QString name; + if (names.count() > 0) { + name = names.at(0); + } + QStringList emails = qscCert.subjectAlternativeNames().values(QSsl::EmailEntry); +#else const QString &name = qscCert.subjectInfo(QSslCertificate::CommonName); + QStringList emails(qscCert.alternateSubjectNames().values(QSsl::EmailEntry)); +#endif QString tmpName = name; tmpName = tmpName.replace(QLatin1String("\\x"), QLatin1String("%")); @@ -115,8 +124,16 @@ void CertView::setCert(const QList<QSslCertificate> &cert) { if (qlCert.count() > 1) qscCert = qlCert.last(); - const QString &issuer = qscCert.issuerInfo(QSslCertificate::CommonName); - qlIssuerName->setText((issuer == name) ? tr("Self-signed") : issuer); +#if QT_VERSION >= 0x050000 + const QStringList &issuerNames = qscCert.issuerInfo(QSslCertificate::CommonName); + QString issuerName; + if (issuerNames.count() > 0) { + issuerName = issuerName.at(0); + } +#else + const QString &issuerName = qscCert.issuerInfo(QSslCertificate::CommonName); +#endif + qlIssuerName->setText((issuerName == name) ? tr("Self-signed") : issuerName); } } diff --git a/src/mumble/Cert.h b/src/mumble/Cert.h index bc41d16ab..2933fa20f 100644 --- a/src/mumble/Cert.h +++ b/src/mumble/Cert.h @@ -32,7 +32,13 @@ #define MUMBLE_MUMBLE_CERT_H_ #include <QtCore/QString> -#include <QtGui/QGroupBox> + +#if QT_VERSION >= 0x050000 +# include <QtWidgets/QGroupBox> +#else +# include <QtGui/QGroupBox> +#endif + #include <QtNetwork/QHostInfo> #include <QtNetwork/QSslCertificate> diff --git a/src/mumble/ConfigWidget.h b/src/mumble/ConfigWidget.h index a86e3092f..167c041f2 100644 --- a/src/mumble/ConfigWidget.h +++ b/src/mumble/ConfigWidget.h @@ -33,7 +33,12 @@ #define MUMBLE_MUMBLE_CONFIGWIDGET_H_ #include <QtCore/QObject> -#include <QtGui/QWidget> + +#if QT_VERSION >= 0x050000 +# include <QtWidgets/QWidget> +#else +# include <QtGui/QWidget> +#endif struct Settings; class ConfigDialog; diff --git a/src/mumble/ConnectDialog.cpp b/src/mumble/ConnectDialog.cpp index a947ef3cb..1286b6078 100644 --- a/src/mumble/ConnectDialog.cpp +++ b/src/mumble/ConnectDialog.cpp @@ -362,6 +362,9 @@ ServerItem *ServerItem::fromMimeData(const QMimeData *mime, QWidget *p) { return NULL; QUrl url; +#if QT_VERSION >= 0x050000 + QUrlQuery query(url); +#endif if (mime->hasUrls() && ! mime->urls().isEmpty()) url = mime->urls().at(0); else if (mime->hasText()) @@ -401,6 +404,15 @@ ServerItem *ServerItem::fromMimeData(const QMimeData *mime, QWidget *p) { url.setUserName(g.s.qsUsername); } +#if QT_VERSION >= 0x050000 + if (! query.hasQueryItem(QLatin1String("title"))) + query.addQueryItem(QLatin1String("title"), url.host()); + + ServerItem *si = new ServerItem(query.queryItemValue(QLatin1String("title")), url.host(), static_cast<unsigned short>(url.port(DEFAULT_MUMBLE_PORT)), url.userName(), url.password()); + + if (query.hasQueryItem(QLatin1String("url"))) + si->qsUrl = query.queryItemValue(QLatin1String("url")); +#else if (! url.hasQueryItem(QLatin1String("title"))) url.addQueryItem(QLatin1String("title"), url.host()); @@ -408,6 +420,7 @@ ServerItem *ServerItem::fromMimeData(const QMimeData *mime, QWidget *p) { if (url.hasQueryItem(QLatin1String("url"))) si->qsUrl = url.queryItemValue(QLatin1String("url")); +#endif return si; } @@ -592,8 +605,16 @@ QMimeData *ServerItem::toMimeData(const QString &name, const QString &host, unsi if (port != DEFAULT_MUMBLE_PORT) url.setPort(port); url.setPath(channel); + +#if QT_VERSION >= 0x050000 + QUrlQuery query; + query.addQueryItem(QLatin1String("title"), name); + query.addQueryItem(QLatin1String("version"), QLatin1String("1.2.0")); + url.setQuery(query); +#else url.addQueryItem(QLatin1String("title"), name); url.addQueryItem(QLatin1String("version"), QLatin1String("1.2.0")); +#endif QString qs = QLatin1String(url.toEncoded()); @@ -782,9 +803,16 @@ ConnectDialog::ConnectDialog(QWidget *p, bool autoconnect) : QDialog(p), bAutoCo qdbbButtonBox->addButton(qpbEdit, QDialogButtonBox::ActionRole); qtwServers->sortItems(1, Qt::AscendingOrder); + +#if QT_VERSION >= 0x050000 + qtwServers->header()->setSectionResizeMode(0, QHeaderView::Stretch); + qtwServers->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents); + qtwServers->header()->setSectionResizeMode(2, QHeaderView::ResizeToContents); +#else qtwServers->header()->setResizeMode(0, QHeaderView::Stretch); qtwServers->header()->setResizeMode(1, QHeaderView::ResizeToContents); qtwServers->header()->setResizeMode(2, QHeaderView::ResizeToContents); +#endif connect(qtwServers->header(), SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)), this, SLOT(OnSortChanged(int, Qt::SortOrder))); @@ -1140,7 +1168,13 @@ void ConnectDialog::initList() { QUrl url; url.setPath(QLatin1String("/list2.cgi")); +#if QT_VERSION >= 0x050000 + QUrlQuery query; + query.addQueryItem(QLatin1String("version"), QLatin1String(MUMTEXT(MUMBLE_VERSION_STRING))); + url.setQuery(query); +#else url.addQueryItem(QLatin1String("version"), QLatin1String(MUMTEXT(MUMBLE_VERSION_STRING))); +#endif WebFetch::fetch(url, this, SLOT(fetched(QByteArray,QUrl,QMap<QString,QString>))); } diff --git a/src/mumble/ConnectDialog.h b/src/mumble/ConnectDialog.h index 31e83ddd0..60e7d70c4 100644 --- a/src/mumble/ConnectDialog.h +++ b/src/mumble/ConnectDialog.h @@ -36,7 +36,13 @@ #include <QtCore/QString> #include <QtCore/QUrl> -#include <QtGui/QTreeWidget> + +#if QT_VERSION >= 0x050000 +# include <QtWidgets/QTreeWidget> +#else +# include <QtGui/QTreeWidget> +#endif + #include <QtNetwork/QHostInfo> #ifdef USE_BONJOUR diff --git a/src/mumble/CrashReporter.h b/src/mumble/CrashReporter.h index abc30e2ba..57c9c29d2 100644 --- a/src/mumble/CrashReporter.h +++ b/src/mumble/CrashReporter.h @@ -34,10 +34,18 @@ #include <QtCore/QObject> #include <QtCore/QEventLoop> #include <QtNetwork/QNetworkReply> -#include <QtGui/QDialog> -#include <QtGui/QProgressDialog> -#include <QtGui/QLineEdit> -#include <QtGui/QTextEdit> + +#if QT_VERSION >= 0x050000 +# include <QtWidgets/QDialog> +# include <QtWidgets/QProgressDialog> +# include <QtWidgets/QLineEdit> +# include <QtWidgets/QTextEdit> +#else +# include <QtGui/QDialog> +# include <QtGui/QProgressDialog> +# include <QtGui/QLineEdit> +# include <QtGui/QTextEdit> +#endif class CrashReporter : QDialog { Q_OBJECT diff --git a/src/mumble/CustomElements.h b/src/mumble/CustomElements.h index 86b4a4050..0dbc5cc5f 100644 --- a/src/mumble/CustomElements.h +++ b/src/mumble/CustomElements.h @@ -33,9 +33,16 @@ #define MUMBLE_MUMBLE_CUSTOMELEMENTS_H_ #include <QtCore/QObject> -#include <QtGui/QLabel> -#include <QtGui/QTextBrowser> -#include <QtGui/QTextEdit> + +#if QT_VERSION >= 0x050000 +# include <QtWidgets/QLabel> +# include <QtWidgets/QTextBrowser> +# include <QtWidgets/QTextEdit> +#else +# include <QtGui/QLabel> +# include <QtGui/QTextBrowser> +# include <QtGui/QTextEdit> +#endif class LogTextBrowser : public QTextBrowser { private: diff --git a/src/mumble/DBus.cpp b/src/mumble/DBus.cpp index 1704395cf..24cd2cac9 100644 --- a/src/mumble/DBus.cpp +++ b/src/mumble/DBus.cpp @@ -67,7 +67,15 @@ void MumbleDBus::getCurrentUrl(const QDBusMessage &msg) { u.setHost(host); u.setPort(port); u.setUserName(user); + +#if QT_VERSION >= 0x050000 + QUrlQuery query; + query.addQueryItem(QLatin1String("version"), QLatin1String("1.2.0")); + u.setQuery(query); +#else u.addQueryItem(QLatin1String("version"), QLatin1String("1.2.0")); +#endif + QStringList path; Channel *c = ClientUser::get(g.uiSession)->cChannel; while (c->cParent) { diff --git a/src/mumble/Database.cpp b/src/mumble/Database.cpp index 954ebab2e..df212f6fd 100644 --- a/src/mumble/Database.cpp +++ b/src/mumble/Database.cpp @@ -68,7 +68,11 @@ Database::Database() { int i; datapaths << g.qdBasePath.absolutePath(); +#if QT_VERSION >= 0x050000 + datapaths << QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation); +#else datapaths << QDesktopServices::storageLocation(QDesktopServices::DataLocation); +#endif #if defined(Q_OS_UNIX) && ! defined(Q_OS_MAC) datapaths << QDir::homePath() + QLatin1String("/.config/Mumble"); #endif diff --git a/src/mumble/FileEngine.cpp b/src/mumble/FileEngine.cpp index f5355e9c9..4f7611b97 100644 --- a/src/mumble/FileEngine.cpp +++ b/src/mumble/FileEngine.cpp @@ -35,6 +35,8 @@ #include "ClientUser.h" #include "Global.h" +#if QT_VERSION < 0x050000 // QAbstractFileEngineHandler is private in Qt 5. + MumbleFileEngineHandler::MumbleFileEngineHandler() : QAbstractFileEngineHandler() { } @@ -94,3 +96,5 @@ QString MumbleImageFileEngine::fileName(QAbstractFileEngine::FileName fn) const return quUrl.toString(); } } + +#endif diff --git a/src/mumble/FileEngine.h b/src/mumble/FileEngine.h index 97ea89584..af2fa5aa5 100644 --- a/src/mumble/FileEngine.h +++ b/src/mumble/FileEngine.h @@ -31,6 +31,8 @@ #ifndef MUMBLE_MUMBLE_FILEENGINE_H_ #define MUMBLE_MUMBLE_FILEENGINE_H_ +#if QT_VERSION < 0x050000 // QAbstractFileEngineHandler is private in Qt 5. + class MumbleFileEngineHandler : public QAbstractFileEngineHandler { private: Q_DISABLE_COPY(MumbleFileEngineHandler) @@ -58,3 +60,5 @@ class MumbleImageFileEngine : public QAbstractFileEngine { }; #endif + +#endif diff --git a/src/mumble/Global.cpp b/src/mumble/Global.cpp index adc0ab524..c25725584 100644 --- a/src/mumble/Global.cpp +++ b/src/mumble/Global.cpp @@ -107,7 +107,11 @@ Global::Global() { QStringList qsl; qsl << QCoreApplication::instance()->applicationDirPath(); +#if QT_VERSION >= 0x050000 + qsl << QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation); +#else qsl << QDesktopServices::storageLocation(QDesktopServices::DataLocation); +#endif #if defined(Q_OS_WIN) QString appdata; wchar_t appData[MAX_PATH]; @@ -137,8 +141,12 @@ Global::Global() { qdBasePath.setPath(appdata); #else migrateDataDir(); +#if QT_VERSION >= 0x050000 + qdBasePath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation); +#else qdBasePath = QDesktopServices::storageLocation(QDesktopServices::DataLocation); #endif +#endif if (! qdBasePath.exists()) { QDir::root().mkpath(qdBasePath.absolutePath()); if (! qdBasePath.exists()) diff --git a/src/mumble/GlobalShortcut.cpp b/src/mumble/GlobalShortcut.cpp index d04ef341b..d9d143948 100644 --- a/src/mumble/GlobalShortcut.cpp +++ b/src/mumble/GlobalShortcut.cpp @@ -620,11 +620,21 @@ GlobalShortcutConfig::GlobalShortcutConfig(Settings &st) : ConfigWidget(st) { qtwShortcuts->setColumnCount(canSuppress ? 4 : 3); qtwShortcuts->setItemDelegate(new ShortcutDelegate(qtwShortcuts)); +#if QT_VERSION >= 0x050000 + qtwShortcuts->header()->setSectionResizeMode(0, QHeaderView::Fixed); + qtwShortcuts->header()->resizeSection(0, 150); + qtwShortcuts->header()->setSectionResizeMode(2, QHeaderView::Stretch); + if (canSuppress) + qtwShortcuts->header()->setSectionResizeMode(3, QHeaderView::ResizeToContents); +#else qtwShortcuts->header()->setResizeMode(0, QHeaderView::Fixed); qtwShortcuts->header()->resizeSection(0, 150); qtwShortcuts->header()->setResizeMode(2, QHeaderView::Stretch); if (canSuppress) qtwShortcuts->header()->setResizeMode(3, QHeaderView::ResizeToContents); +#endif + + qcbEnableGlobalShortcuts->setVisible(canDisable); } diff --git a/src/mumble/GlobalShortcut.h b/src/mumble/GlobalShortcut.h index 31b6d820d..4c176bec3 100644 --- a/src/mumble/GlobalShortcut.h +++ b/src/mumble/GlobalShortcut.h @@ -33,8 +33,14 @@ #define MUMBLE_MUMBLE_GLOBALSHORTCUT_H_ #include <QtCore/QThread> -#include <QtGui/QToolButton> -#include <QtGui/QStyledItemDelegate> + +#if QT_VERSION >= 0x050000 +# include <QtWidgets/QToolButton> +# include <QtWidgets/QStyledItemDelegate> +#else +# include <QtGui/QToolButton> +# include <QtGui/QStyledItemDelegate> +#endif #include "ConfigDialog.h" #include "Timer.h" diff --git a/src/mumble/GlobalShortcut_unix.cpp b/src/mumble/GlobalShortcut_unix.cpp index 08d28b6d1..8c53472e3 100644 --- a/src/mumble/GlobalShortcut_unix.cpp +++ b/src/mumble/GlobalShortcut_unix.cpp @@ -324,7 +324,7 @@ QString GlobalShortcutX::buttonName(const QVariant &v) { if (!ok) return QString(); if ((key < 0x118) || (key >= 0x128)) { - KeySym ks=XKeycodeToKeysym(QX11Info::display(), static_cast<KeyCode>(key), 0); + KeySym ks=XKeycodeToKeysym(display, static_cast<KeyCode>(key), 0); if (ks == NoSymbol) { return QLatin1String("0x")+QString::number(key,16); } else { diff --git a/src/mumble/GlobalShortcut_unix.h b/src/mumble/GlobalShortcut_unix.h index 4838bd76f..5ca140b74 100644 --- a/src/mumble/GlobalShortcut_unix.h +++ b/src/mumble/GlobalShortcut_unix.h @@ -35,7 +35,6 @@ #include "ConfigDialog.h" #include "Global.h" -#include <QX11Info> #include <X11/X.h> #include <X11/Xlib.h> #ifndef NO_XINPUT2 diff --git a/src/mumble/Log.cpp b/src/mumble/Log.cpp index 875d246dc..3903a7871 100644 --- a/src/mumble/Log.cpp +++ b/src/mumble/Log.cpp @@ -51,12 +51,19 @@ static ConfigRegistrar registrar(4000, LogConfigDialogNew); LogConfig::LogConfig(Settings &st) : ConfigWidget(st) { setupUi(this); - +#if QT_VERSION >= 0x050000 + qtwMessages->header()->setSectionResizeMode(ColMessage, QHeaderView::Stretch); + qtwMessages->header()->setSectionResizeMode(ColConsole, QHeaderView::ResizeToContents); + qtwMessages->header()->setSectionResizeMode(ColNotification, QHeaderView::ResizeToContents); + qtwMessages->header()->setSectionResizeMode(ColTTS, QHeaderView::ResizeToContents); + qtwMessages->header()->setSectionResizeMode(ColStaticSound, QHeaderView::ResizeToContents); +#else qtwMessages->header()->setResizeMode(ColMessage, QHeaderView::Stretch); qtwMessages->header()->setResizeMode(ColConsole, QHeaderView::ResizeToContents); qtwMessages->header()->setResizeMode(ColNotification, QHeaderView::ResizeToContents); qtwMessages->header()->setResizeMode(ColTTS, QHeaderView::ResizeToContents); qtwMessages->header()->setResizeMode(ColStaticSound, QHeaderView::ResizeToContents); +#endif QTreeWidgetItem *twi; for (int i = Log::firstMsgType; i <= Log::lastMsgType; ++i) { diff --git a/src/mumble/MainWindow.cpp b/src/mumble/MainWindow.cpp index 8dbe54ea7..6a6f2ba5e 100644 --- a/src/mumble/MainWindow.cpp +++ b/src/mumble/MainWindow.cpp @@ -190,8 +190,10 @@ MainWindow::MainWindow(QWidget *p) : QMainWindow(p) { qwPTTButtonWidget = NULL; +#if QT_VERSION < 0x050000 cuContextUser = QWeakPointer<ClientUser>(); cContextChannel = QWeakPointer<Channel>(); +#endif qtReconnect = new QTimer(this); qtReconnect->setInterval(10000); @@ -687,7 +689,12 @@ void MainWindow::openUrl(const QUrl &url) { minor = 2; patch = 0; +#if QT_VERSION >= 0x050000 + QUrlQuery query(url); + QString version = query.queryItemValue(QLatin1String("version")); +#else QString version = url.queryItemValue(QLatin1String("version")); +#endif MumbleVersion::get(&major, &minor, &patch, version); if ((major < 1) || // No pre 1.2.0 @@ -705,8 +712,14 @@ void MainWindow::openUrl(const QUrl &url) { QString pw = url.password(); qsDesiredChannel = url.path(); QString name; + +#if QT_VERSION >= 0x050000 + if (query.hasQueryItem(QLatin1String("title"))) + name = query.queryItemValue(QLatin1String("title")); +#else if (url.hasQueryItem(QLatin1String("title"))) name = url.queryItemValue(QLatin1String("title")); +#endif if (g.sh && g.sh->isRunning()) { QString oHost, oUser, oPw; @@ -1525,7 +1538,11 @@ void MainWindow::sendChatbarMessage(QString qsText) { ClientUser *p = pmModel->getUser(qtvUsers->currentIndex()); Channel *c = pmModel->getChannel(qtvUsers->currentIndex()); +#if QT_VERSION >= 0x050000 + qsText = qsText.toHtmlEscaped(); +#else qsText = Qt::escape(qsText); +#endif qsText = TextMessage::autoFormat(qsText); if (!g.s.bChatBarUseSelection || p == NULL || p->uiSession == g.uiSession) { @@ -2740,8 +2757,13 @@ void MainWindow::context_triggered() { QPair<QByteArray, QImage> MainWindow::openImageFile() { QPair<QByteArray, QImage> retval; - if (g.s.qsImagePath.isEmpty() || ! QDir::root().exists(g.s.qsImagePath)) + if (g.s.qsImagePath.isEmpty() || ! QDir::root().exists(g.s.qsImagePath)) { +#if QT_VERSION >= 0x050000 + g.s.qsImagePath = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation); +#else g.s.qsImagePath = QDesktopServices::storageLocation(QDesktopServices::PicturesLocation); +#endif + } QString fname = QFileDialog::getOpenFileName(this, tr("Choose image file"), g.s.qsImagePath, tr("Images (*.png *.jpg *.jpeg *.svg)")); diff --git a/src/mumble/MainWindow.h b/src/mumble/MainWindow.h index baa8f7f93..4e4be140b 100644 --- a/src/mumble/MainWindow.h +++ b/src/mumble/MainWindow.h @@ -32,8 +32,14 @@ #ifndef MUMBLE_MUMBLE_MAINWINDOW_H_ #define MUMBLE_MUMBLE_MAINWINDOW_H_ -#include <QtGui/QMainWindow> -#include <QtGui/QSystemTrayIcon> +#if QT_VERSION >= 0x050000 +# include <QtWidgets/QMainWindow> +# include <QtWidgets/QSystemTrayIcon> +#else +# include <QtGui/QMainWindow> +# include <QtGui/QSystemTrayIcon> +#endif + #include <QtNetwork/QAbstractSocket> #include "CustomElements.h" @@ -105,8 +111,14 @@ class MainWindow : public QMainWindow, public MessageHandler, public Ui::MainWin bool bSuppressAskOnQuit; bool bAutoUnmute; +#if QT_VERSION >= 0x050000 + QPointer<Channel> cContextChannel; + QPointer<ClientUser> cuContextUser; +#else QWeakPointer<Channel> cContextChannel; QWeakPointer<ClientUser> cuContextUser; +#endif + QPoint qpContextPosition; void recheckTTS(); diff --git a/src/mumble/Messages.cpp b/src/mumble/Messages.cpp index c8f808d99..f0105f54d 100644 --- a/src/mumble/Messages.cpp +++ b/src/mumble/Messages.cpp @@ -217,12 +217,12 @@ void MainWindow::msgPermissionDenied(const MumbleProto::PermissionDenied &msg) { g.s.bTTS = true; quint32 oflags = g.s.qmMessages.value(Log::PermissionDenied); g.s.qmMessages[Log::PermissionDenied] = (oflags | Settings::LogTTS) & (~Settings::LogSoundfile); - g.l->log(Log::PermissionDenied, QString::fromAscii(g.ccHappyEaster + 39).arg(u)); + g.l->log(Log::PermissionDenied, QString::fromUtf8(g.ccHappyEaster + 39).arg(u)); g.s.qmMessages[Log::PermissionDenied] = oflags; g.s.bDeaf = bold; g.s.bTTS = bold2; - g.mw->setWindowIcon(QIcon(QLatin1String(g.ccHappyEaster))); - g.mw->setStyleSheet(QString::fromAscii(g.ccHappyEaster + 82)); + g.mw->setWindowIcon(QIcon(QString::fromUtf8(g.ccHappyEaster))); + g.mw->setStyleSheet(QString::fromUtf8(g.ccHappyEaster + 82)); qWarning() << "Happy Easter"; } } diff --git a/src/mumble/Overlay.h b/src/mumble/Overlay.h index bd8141e42..a3fbdce5e 100644 --- a/src/mumble/Overlay.h +++ b/src/mumble/Overlay.h @@ -32,7 +32,14 @@ #define MUMBLE_MUMBLE_OVERLAY_H_ #include <QtCore/QUrl> -#include <QtGui/QGraphicsItem> + +#if QT_VERSION >= 0x050000 +# include <QtWidgets/QGraphicsItem> +#else +# include <QtGui/QGraphicsItem> +#endif + + #include <QtNetwork/QLocalSocket> #include "ConfigDialog.h" diff --git a/src/mumble/OverlayClient.cpp b/src/mumble/OverlayClient.cpp index 8f69a5efb..22b4fd308 100644 --- a/src/mumble/OverlayClient.cpp +++ b/src/mumble/OverlayClient.cpp @@ -174,7 +174,7 @@ void OverlayClient::updateMouse() { } #endif -#if defined(Q_WS_WIN) || defined(Q_WS_MAC) +#if defined(Q_OS_WIN) || defined(Q_OS_MAC) extern bool Q_GUI_EXPORT qt_use_native_dialogs; #endif @@ -183,7 +183,7 @@ extern bool Q_GUI_EXPORT qt_use_native_dialogs; // that we're about to reparent. void OverlayClient::showGui() { -#if defined(QT3_SUPPORT) || defined(Q_WS_WIN) +#if defined(QT3_SUPPORT) || defined(Q_OS_WIN) if (QCoreApplication::loopLevel() > 1) return; #else @@ -273,7 +273,7 @@ outer: setupScene(true); -#if defined(Q_WS_WIN) || defined(Q_WS_MAC) +#if defined(Q_OS_WIN) || defined(Q_OS_MAC) qt_use_native_dialogs = false; #endif @@ -288,7 +288,7 @@ outer: } void OverlayClient::hideGui() { -#if defined(QT3_SUPPORT) || defined(Q_WS_WIN) +#if defined(QT3_SUPPORT) || defined(Q_OS_WIN) if (QCoreApplication::loopLevel() > 1) { QCoreApplication::exit_loop(); QMetaObject::invokeMethod(this, "hideGui", Qt::QueuedConnection); @@ -353,7 +353,7 @@ void OverlayClient::hideGui() { setupScene(false); qgv.setAttribute(Qt::WA_WState_Hidden, true); -#if defined(Q_WS_WIN) || defined(Q_WS_MAC) +#if defined(Q_OS_WIN) || defined(Q_OS_MAC) qt_use_native_dialogs = true; #endif diff --git a/src/mumble/Plugins.cpp b/src/mumble/Plugins.cpp index 74a08d177..1c6720c48 100644 --- a/src/mumble/Plugins.cpp +++ b/src/mumble/Plugins.cpp @@ -68,8 +68,13 @@ PluginInfo::PluginInfo() { PluginConfig::PluginConfig(Settings &st) : ConfigWidget(st) { setupUi(this); +#if QT_VERSION >= 0x050000 + qtwPlugins->header()->setSectionResizeMode(0, QHeaderView::Stretch); + qtwPlugins->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents); +#else qtwPlugins->header()->setResizeMode(0, QHeaderView::Stretch); qtwPlugins->header()->setResizeMode(1, QHeaderView::ResizeToContents); +#endif refillPluginList(); } @@ -467,17 +472,29 @@ void Plugins::checkUpdates() { QUrl url; url.setPath(QLatin1String("/plugins.php")); - url.addQueryItem(QLatin1String("ver"), QLatin1String(QUrl::toPercentEncoding(QLatin1String(MUMBLE_RELEASE)))); + QList<QPair<QString, QString> > queryItems; + queryItems << qMakePair(QString::fromUtf8("ver"), QString::fromUtf8(QUrl::toPercentEncoding(QString::fromUtf8(MUMBLE_RELEASE)))); #if defined(Q_OS_WIN) - url.addQueryItem(QLatin1String("os"), QLatin1String("Win32")); - url.addQueryItem(QLatin1String("abi"), QLatin1String(MUMTEXT(_MSC_VER))); + queryItems << qMakePair(QString::fromUtf8("os"), QString::fromUtf8("Win32")); + queryItems << qMakePair(QString::fromUtf8("abi"), QString::fromUtf8(MUMTEXT(_MSC_VER))); #elif defined(Q_OS_MAC) - url.addQueryItem(QLatin1String("os"), QLatin1String("MacOSX")); + queryItems << qMakePair((QString::fromUtf8("os"), QString::fromUtf8("MacOSX")); #else - url.addQueryItem(QLatin1String("os"), QLatin1String("Unix")); + queryItems << qMakePair(QString::fromUtf8("os"), QString::fromUtf8("Unix")); #endif + #ifdef QT_NO_DEBUG +#if QT_VERSION >= 0x050000 + QUrlQuery query; + query.setQueryItems(queryItems); + url.setQuery(query); +#else + for (int i = 0; i < queryItems.size(); i++) { + const QPair<QString, QString> &queryPair = queryItems.at(i); + url.addQueryItem(queryPair.first, queryPair.second); + } +#endif WebFetch::fetch(url, this, SLOT(fetched(QByteArray,QUrl))); #else g.mw->msgBox(tr("Skipping plugin update in debug mode.")); diff --git a/src/mumble/RichTextEditor.cpp b/src/mumble/RichTextEditor.cpp index d333b800b..57b94dbcc 100644 --- a/src/mumble/RichTextEditor.cpp +++ b/src/mumble/RichTextEditor.cpp @@ -143,8 +143,13 @@ void RichTextHtmlEdit::insertFromMimeData(const QMimeData *source) { if (! uri.isEmpty()) { if (title.isEmpty()) title = uri; +#if QT_VERSION > 0x050000 + uri = uri.toHtmlEscaped(); + title = title.toHtmlEscaped(); +#else uri = Qt::escape(uri); title = Qt::escape(title); +#endif insertHtml(QString::fromLatin1("<a href=\"%1\">%2</a>").arg(uri, title)); return; @@ -171,8 +176,14 @@ QString RichTextEditorLink::text() const { QUrl url(qleUrl->text(), QUrl::StrictMode); QString txt = qleText->text(); +#if QT_VERSION >= 0x050000 + txt = txt.toHtmlEscaped(); +#else + txt = Qt::escape(txt); +#endif + if (url.isValid() && ! url.isRelative() && ! txt.isEmpty()) { - return QString::fromLatin1("<a href=\"%1\">%2</a>").arg(url.toString(), Qt::escape(txt)); + return QString::fromLatin1("<a href=\"%1\">%2</a>").arg(url.toString(), txt); } return QString(); diff --git a/src/mumble/RichTextEditor.h b/src/mumble/RichTextEditor.h index 854067447..245cc5b39 100644 --- a/src/mumble/RichTextEditor.h +++ b/src/mumble/RichTextEditor.h @@ -31,7 +31,11 @@ #ifndef MUMBLE_MUMBLE_RICHTEXTEDITOR_H_ #define MUMBLE_MUMBLE_RICHTEXTEDITOR_H_ -#include <QtGui/QTextEdit> +#if QT_VERSION >= 0x050000 +# include <QtWidgets/QTextEdit> +#else +# include <QtGui/QTextEdit> +#endif class RichTextHtmlEdit : public QTextEdit { private: diff --git a/src/mumble/ServerHandler.cpp b/src/mumble/ServerHandler.cpp index 2b5914b8a..3e708c8fe 100644 --- a/src/mumble/ServerHandler.cpp +++ b/src/mumble/ServerHandler.cpp @@ -292,7 +292,11 @@ void ServerHandler::run() { bUdp = false; +#if QT_VERSION >= 0x050000 + qtsSock->setProtocol(QSsl::TlsV1_0); +#else qtsSock->setProtocol(QSsl::TlsV1); +#endif qtsSock->connectToHostEncrypted(qsHostName, usPort); tTimestamp.restart(); @@ -763,7 +767,7 @@ void ServerHandler::sendChannelTextMessage(unsigned int channel, const QString & } else { mptm.add_channel_id(channel); - if (message_ == QString::fromAscii(g.ccHappyEaster + 10)) g.bHappyEaster = true; + if (message_ == QString::fromUtf8(g.ccHappyEaster + 10)) g.bHappyEaster = true; } mptm.set_message(u8(message_)); sendMessage(mptm); diff --git a/src/mumble/Settings.cpp b/src/mumble/Settings.cpp index b5f57d280..f498269c7 100644 --- a/src/mumble/Settings.cpp +++ b/src/mumble/Settings.cpp @@ -297,7 +297,11 @@ Settings::Settings() { bPluginCheck = true; #endif +#if QT_VERSION >= 0x050000 + qsImagePath = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation); +#else qsImagePath = QDesktopServices::storageLocation(QDesktopServices::PicturesLocation); +#endif ceExpand = ChannelsWithUsers; ceChannelDrag = Ask; @@ -365,7 +369,11 @@ Settings::Settings() { bHighContrast = false; // Recording +#if QT_VERSION >= 0x050000 + qsRecordingPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); +#else qsRecordingPath = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation); +#endif qsRecordingFile = QLatin1String("Mumble-%date-%time-%host-%user"); rmRecordingMode = RecordingMixdown; iRecordingFormat = 0; diff --git a/src/mumble/SocketRPC.cpp b/src/mumble/SocketRPC.cpp index d144643f4..60492d2d1 100644 --- a/src/mumble/SocketRPC.cpp +++ b/src/mumble/SocketRPC.cpp @@ -158,7 +158,15 @@ void SocketRPCClient::processXml() { u.setHost(host); u.setPort(port); u.setUserName(user); + +#if QT_VERSION >= 0x050000 + QUrlQuery query; + query.addQueryItem(QLatin1String("version"), QLatin1String("1.2.0")); + u.setQuery(query); +#else u.addQueryItem(QLatin1String("version"), QLatin1String("1.2.0")); +#endif + QStringList path; Channel *c = ClientUser::get(g.uiSession)->cChannel; while (c->cParent) { diff --git a/src/mumble/UserInformation.cpp b/src/mumble/UserInformation.cpp index 6da8b80ee..97f6a8ffa 100644 --- a/src/mumble/UserInformation.cpp +++ b/src/mumble/UserInformation.cpp @@ -44,6 +44,13 @@ static QString decode_utf8_qssl_string(const QString &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); @@ -129,8 +136,12 @@ void UserInformation::update(const MumbleProto::UserStats &msg) { qpbCertificate->setEnabled(true); const QSslCertificate &cert = qlCerts.last(); - const QMultiMap<QSsl::AlternateNameEntryType, QString> &alts = cert.alternateSubjectNames(); +#if QT_VERSION >= 0x050000 + const QMultiMap<QSsl::AlternativeNameEntryType, QString> &alts = cert.subjectAlternativeNames(); +#else + const QMultiMap<QSsl::AlternateNameEntryType, QString> &alts = cert.alternateSubjectNames(); +#endif if (alts.contains(QSsl::EmailEntry)) qlCertificate->setText(QStringList(alts.values(QSsl::EmailEntry)).join(tr(", "))); else diff --git a/src/mumble/UserView.h b/src/mumble/UserView.h index a8738e8b8..ebbaca88e 100644 --- a/src/mumble/UserView.h +++ b/src/mumble/UserView.h @@ -31,8 +31,13 @@ #ifndef MUMBLE_MUMBLE_USERVIEW_H_ #define MUMBLE_MUMBLE_USERVIEW_H_ -#include <QtGui/QStyledItemDelegate> -#include <QtGui/QTreeView> +#if QT_VERSION >= 0x050000 +# include <QtWidgets/QStyledItemDelegate> +# include <QtWidgets/QTreeView> +#else +# include <QtGui/QStyledItemDelegate> +# include <QtGui/QTreeView> +#endif #include "Timer.h" diff --git a/src/mumble/VersionCheck.cpp b/src/mumble/VersionCheck.cpp index 6623d102f..25c83c382 100644 --- a/src/mumble/VersionCheck.cpp +++ b/src/mumble/VersionCheck.cpp @@ -42,22 +42,23 @@ VersionCheck::VersionCheck(bool autocheck, QObject *p, bool focus) : QObject(p) QUrl url; url.setPath(focus ? QLatin1String("/focus.php") : QLatin1String("/ver.php")); - url.addQueryItem(QLatin1String("ver"), QLatin1String(QUrl::toPercentEncoding(QLatin1String(MUMBLE_RELEASE)))); - url.addQueryItem(QLatin1String("date"), QLatin1String(QUrl::toPercentEncoding(QLatin1String(__DATE__)))); - url.addQueryItem(QLatin1String("time"), QLatin1String(QUrl::toPercentEncoding(QLatin1String(__TIME__)))); + QList<QPair<QString, QString> > queryItems; + queryItems << qMakePair(QString::fromLatin1("ver"), QString::fromLatin1(QUrl::toPercentEncoding(QLatin1String(MUMBLE_RELEASE)))); + queryItems << qMakePair(QString::fromLatin1("date"), QString::fromLatin1(QUrl::toPercentEncoding(QLatin1String(__DATE__)))); + queryItems << qMakePair(QString::fromLatin1("time"), QString::fromLatin1(QUrl::toPercentEncoding(QLatin1String(__TIME__)))); #if defined(Q_OS_WIN) - url.addQueryItem(QLatin1String("os"), QLatin1String("Win32")); + queryItems << qMakePair(QString::fromLatin1("os"), QString::fromLatin1("Win32")); #elif defined(Q_OS_MAC) - url.addQueryItem(QLatin1String("os"), QLatin1String("MacOSX")); + queryItems << qMakePair(QString::fromLatin1("os"), QString::fromLatin1("MacOSX")); #else - url.addQueryItem(QLatin1String("os"), QLatin1String("Unix")); + queryItems << qMakePair(QString::fromLatin1("os"), QString::fromLatin1("Unix")); #endif if (! g.s.bUsage) - url.addQueryItem(QLatin1String("nousage"), QLatin1String("1")); + queryItems << qMakePair(QString::fromLatin1("nousage"), QString::fromLatin1("1")); if (autocheck) - url.addQueryItem(QLatin1String("auto"), QLatin1String("1")); + queryItems << qMakePair(QString::fromLatin1("auto"), QString::fromLatin1("1")); - url.addQueryItem(QLatin1String("locale"), g.s.qsLanguage.isEmpty() ? QLocale::system().name() : g.s.qsLanguage); + queryItems << qMakePair(QString::fromLatin1("locale"), g.s.qsLanguage.isEmpty() ? QLocale::system().name() : g.s.qsLanguage); QFile f(qApp->applicationFilePath()); if (! f.open(QIODevice::ReadOnly)) { @@ -69,10 +70,20 @@ VersionCheck::VersionCheck(bool autocheck, QObject *p, bool focus) : QObject(p) } else { QCryptographicHash qch(QCryptographicHash::Sha1); qch.addData(a); - url.addQueryItem(QLatin1String("sha1"), QLatin1String(qch.result().toHex())); + queryItems << qMakePair(QString::fromLatin1("sha1"), QString::fromLatin1(qch.result().toHex())); } } +#if QT_VERSION >= 0x050000 + QUrlQuery query; + query.setQueryItems(queryItems); + url.setQuery(query); +#else + for (int i = 0; i < queryItems.size(); i++) { + const QPair<QString, QString> &queryPair = queryItems.at(i); + url.addQueryItem(queryPair.first, queryPair.second); + } +#endif WebFetch::fetch(url, this, SLOT(fetched(QByteArray,QUrl))); } diff --git a/src/mumble/ViewCert.cpp b/src/mumble/ViewCert.cpp index 8afe205a2..dc08f5ecc 100644 --- a/src/mumble/ViewCert.cpp +++ b/src/mumble/ViewCert.cpp @@ -37,6 +37,13 @@ static QString decode_utf8_qssl_string(const QString &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(); +} + ViewCert::ViewCert(QList<QSslCertificate> cl, QWidget *p) : QDialog(p) { qlCerts = cl; @@ -80,8 +87,6 @@ void ViewCert::on_Chain_currentRowChanged(int idx) { QStringList l; const QSslCertificate &c=qlCerts.at(idx); - const QMultiMap<QSsl::AlternateNameEntryType, QString> &alts = c.alternateSubjectNames(); - QMultiMap<QSsl::AlternateNameEntryType, QString>::const_iterator i; l << tr("Common Name: %1").arg(decode_utf8_qssl_string(c.subjectInfo(QSslCertificate::CommonName))); l << tr("Organization: %1").arg(decode_utf8_qssl_string(c.subjectInfo(QSslCertificate::Organization))); @@ -94,6 +99,15 @@ void ViewCert::on_Chain_currentRowChanged(int idx) { l << tr("Serial: %1").arg(QString::fromLatin1(c.serialNumber().toHex())); l << tr("Public Key: %1 bits %2").arg(c.publicKey().length()).arg((c.publicKey().algorithm() == QSsl::Rsa) ? tr("RSA") : tr("DSA")); l << tr("Digest (SHA-1): %1").arg(QString::fromLatin1(c.digest(QCryptographicHash::Sha1).toHex())); + +#if QT_VERSION >= 0x050000 + const QMultiMap<QSsl::AlternativeNameEntryType, QString> &alts = c.subjectAlternativeNames(); + QMultiMap<QSsl::AlternativeNameEntryType, QString>::const_iterator i; +#else + const QMultiMap<QSsl::AlternateNameEntryType, QString> &alts = c.alternateSubjectNames(); + QMultiMap<QSsl::AlternateNameEntryType, QString>::const_iterator i; +#endif + for (i=alts.constBegin(); i != alts.constEnd(); ++i) { switch (i.key()) { case QSsl::EmailEntry: { diff --git a/src/mumble/ViewCert.h b/src/mumble/ViewCert.h index 97c504531..e029b384c 100644 --- a/src/mumble/ViewCert.h +++ b/src/mumble/ViewCert.h @@ -33,7 +33,13 @@ #include <QtCore/QObject> #include <QtCore/QList> -#include <QtGui/QDialog> + +#if QT_VERSION >= 0x050000 +# include <QtWidgets/QDialog> +#else +# include <QtGui/QDialog> +#endif + #include <QtNetwork/QSslCertificate> class QListWidget; diff --git a/src/mumble/main.cpp b/src/mumble/main.cpp index cc3037184..353acd3f1 100644 --- a/src/mumble/main.cpp +++ b/src/mumble/main.cpp @@ -397,7 +397,9 @@ int main(int argc, char **argv) { g.p = new Plugins(NULL); g.p->rescanPlugins(); +#if QT_VERSION < 0x050000 MumbleFileEngineHandler *mfeh = new MumbleFileEngineHandler(); +#endif Audio::start(); @@ -429,7 +431,12 @@ int main(int argc, char **argv) { g.s.uiUpdateCounter = 2; if (! CertWizard::validateCert(g.s.kpCertificate)) { +#if QT_VERSION >= 0x050000 + QDir qd(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)); +#else QDir qd(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)); +#endif + QFile qf(qd.absoluteFilePath(QLatin1String("MumbleAutomaticCertificateBackup.p12"))); if (qf.open(QIODevice::ReadOnly | QIODevice::Unbuffered)) { Settings::KeyPair kp = CertWizard::importCert(qf.readAll()); @@ -497,7 +504,9 @@ int main(int argc, char **argv) { if (sh) sh->disconnect(); +#if QT_VERSION < 0x050000 delete mfeh; +#endif delete srpc; diff --git a/src/mumble/mumble.pro b/src/mumble/mumble.pro index ff3c02f6f..d0cbfad0c 100644 --- a/src/mumble/mumble.pro +++ b/src/mumble/mumble.pro @@ -3,6 +3,10 @@ include(../mumble.pri) DEFINES *= MUMBLE TEMPLATE = app QT *= network sql xml svg +isEqual(QT_MAJOR_VERSION, 5) { + QT *= widgets +} + TARGET = mumble HEADERS *= BanEditor.h ACLEditor.h ConfigWidget.h Log.h AudioConfigDialog.h AudioStats.h AudioInput.h AudioOutput.h AudioOutputSample.h AudioOutputSpeech.h AudioOutputUser.h CELTCodec.h CustomElements.h MainWindow.h ServerHandler.h About.h ConnectDialog.h GlobalShortcut.h TextToSpeech.h Settings.h Database.h VersionCheck.h Global.h UserModel.h Audio.h ConfigDialog.h Plugins.h PTTButtonWidget.h LookConfig.h Overlay.h OverlayText.h SharedMemory.h AudioWizard.h ViewCert.h TextMessage.h NetworkConfig.h LCD.h Usage.h Cert.h ClientUser.h UserEdit.h Tokens.h UserView.h RichTextEditor.h UserInformation.h FileEngine.h SocketRPC.h VoiceRecorder.h VoiceRecorderDialog.h WebFetch.h ../SignalCurry.h SOURCES *= BanEditor.cpp ACLEditor.cpp ConfigWidget.cpp Log.cpp AudioConfigDialog.cpp AudioStats.cpp AudioInput.cpp AudioOutput.cpp AudioOutputSample.cpp AudioOutputSpeech.cpp AudioOutputUser.cpp main.cpp CELTCodec.cpp CustomElements.cpp MainWindow.cpp ServerHandler.cpp About.cpp ConnectDialog.cpp Settings.cpp Database.cpp VersionCheck.cpp Global.cpp UserModel.cpp Audio.cpp ConfigDialog.cpp Plugins.cpp PTTButtonWidget.cpp LookConfig.cpp OverlayClient.cpp OverlayConfig.cpp OverlayEditor.cpp OverlayEditorScene.cpp OverlayUser.cpp OverlayUserGroup.cpp Overlay.cpp OverlayText.cpp SharedMemory.cpp AudioWizard.cpp ViewCert.cpp Messages.cpp TextMessage.cpp GlobalShortcut.cpp NetworkConfig.cpp LCD.cpp Usage.cpp Cert.cpp ClientUser.cpp UserEdit.cpp Tokens.cpp UserView.cpp RichTextEditor.cpp UserInformation.cpp FileEngine.cpp SocketRPC.cpp VoiceRecorder.cpp VoiceRecorderDialog.cpp WebFetch.cpp diff --git a/src/mumble/mumble_pch.hpp b/src/mumble/mumble_pch.hpp index 74a6345cd..61506c091 100644 --- a/src/mumble/mumble_pch.hpp +++ b/src/mumble/mumble_pch.hpp @@ -2,7 +2,6 @@ #ifndef MUMBLE_MUMBLE_MUMBLE_PCH_H_ #define MUMBLE_MUMBLE_MUMBLE_PCH_H_ -#define QT_NO_DEBUG_STREAM #define QT_NO_CAST_TO_ASCII #define QT_NO_CAST_FROM_ASCII #define QT_USE_FAST_CONCATENATION @@ -29,6 +28,9 @@ #include <QtCore/QtCore> #include <QtGui/QtGui> +#if QT_VERSION >= 0x050000 +# include <QtWidgets/QtWidgets> +#endif #include <QtSvg/QtSvg> #ifdef USE_DBUS #include <QtDBus/QtDBus> diff --git a/src/murmur/Cert.cpp b/src/murmur/Cert.cpp index 49f8c8626..cf08ebfb1 100644 --- a/src/murmur/Cert.cpp +++ b/src/murmur/Cert.cpp @@ -116,13 +116,23 @@ void Server::initializeCert() { qlCA = ql; } - if (qscCert.issuerInfo(QSslCertificate::CommonName) == QLatin1String("Murmur Autogenerated Certificate")) { + QString issuer; +#if QT_VERSION >= 0x050000 + QStringList issuerNames = qscCert.issuerInfo(QSslCertificate::CommonName); + if (! issuerNames.isEmpty()) { + issuer = issuerNames.first(); + } +#else + issuer = qscCert.issuerInfo(QSslCertificate::CommonName); +#endif + + if (issuer == QString::fromUtf8("Murmur Autogenerated Certificate")) { log("Old autogenerated certificate is unusable for registration, invalidating it"); qscCert = QSslCertificate(); qskKey = QSslKey(); } - if (!qscCert.isNull() && (qscCert.issuerInfo(QSslCertificate::CommonName) == QLatin1String("Murmur Autogenerated Certificate v2")) && ! Meta::mp.qscCert.isNull() && ! Meta::mp.qskKey.isNull() && (Meta::mp.qlBind == qlBind)) { + if (!qscCert.isNull() && issuer == QString::fromUtf8("Murmur Autogenerated Certificate v2") && ! Meta::mp.qscCert.isNull() && ! Meta::mp.qskKey.isNull() && (Meta::mp.qlBind == qlBind)) { qscCert = Meta::mp.qscCert; qskKey = Meta::mp.qskKey; } diff --git a/src/murmur/Server.cpp b/src/murmur/Server.cpp index 92780f447..6009ac3f8 100644 --- a/src/murmur/Server.cpp +++ b/src/murmur/Server.cpp @@ -1144,7 +1144,11 @@ void Server::newClient() { u->setToS(); +#if QT_VERSION >= 0x050000 + sock->setProtocol(QSsl::TlsV1_0); +#else sock->setProtocol(QSsl::TlsV1); +#endif sock->startServerEncryption(); } } @@ -1168,10 +1172,31 @@ void Server::encrypted() { QList<QSslCertificate> certs = uSource->peerCertificateChain(); if (!certs.isEmpty()) { const QSslCertificate &cert = certs.last(); +#if QT_VERSION >= 0x050000 + uSource->qslEmail = cert.subjectAlternativeNames().values(QSsl::EmailEntry); +#else uSource->qslEmail = cert.alternateSubjectNames().values(QSsl::EmailEntry); +#endif uSource->qsHash = cert.digest(QCryptographicHash::Sha1).toHex(); if (! uSource->qslEmail.isEmpty() && uSource->bVerified) { - log(uSource, QString("Strong certificate for %1 <%2> (signed by %3)").arg(cert.subjectInfo(QSslCertificate::CommonName)).arg(uSource->qslEmail.join(", ")).arg(certs.first().issuerInfo(QSslCertificate::CommonName))); +#if QT_VERSION >= 0x050000 + QString subject; + QString issuer; + + QStringList subjectList = cert.subjectInfo(QSslCertificate::CommonName); + if (! subjectList.isEmpty()) { + subject = subjectList.first(); + } + + QStringList issuerList = certs.first().issuerInfo(QSslCertificate::CommonName); + if (! issuerList.isEmpty()) { + issuer = issuerList.first(); + } +#else + QString subject = cert.subjectInfo(QSslCertificate::CommonName); + QString issuer = certs.first().issuerInfo(QSslCertificate::CommonName); +#endif + log(uSource, QString::fromUtf8("Strong certificate for %1 <%2> (signed by %3)").arg(subject).arg(uSource->qslEmail.join(", ")).arg(issuer)); } foreach(const Ban &ban, qlBans) { diff --git a/src/murmur/main.cpp b/src/murmur/main.cpp index 1b5c30a6d..ac7be2e7f 100644 --- a/src/murmur/main.cpp +++ b/src/murmur/main.cpp @@ -60,7 +60,7 @@ static LogEmitter le; static QStringList qlErrors; -static void murmurMessageOutput(QtMsgType type, const char *msg) { +static void murmurMessageOutputQString(QtMsgType type, const QString &msg) { char c; switch (type) { case QtDebugMsg: @@ -111,7 +111,7 @@ static void murmurMessageOutput(QtMsgType type, const char *msg) { #ifdef Q_OS_UNIX if (detach) { if (qlErrors.isEmpty()) - qlErrors << QLatin1String(msg); + qlErrors << msg; qlErrors << QString(); m = qlErrors.join(QLatin1String("\n")); fprintf(stderr, "%s", qPrintable(m)); @@ -123,6 +123,17 @@ static void murmurMessageOutput(QtMsgType type, const char *msg) { } } +static void murmurMessageOutput(QtMsgType type, const char *msg) { + murmurMessageOutputQString(type, QString::fromUtf8(msg)); +} + +#if QT_VERSION >= 0x050000 +static void murmurMessageOutputWithContext(QtMsgType type, const QMessageLogContext &ctx, const QString &msg) { + Q_UNUSED(ctx); + murmurMessageOutputQString(type, msg); +} +#endif + #ifdef USE_ICE void IceParse(int &argc, char *argv[]); void IceStart(); @@ -171,7 +182,9 @@ int main(int argc, char **argv) { a.setOrganizationDomain("mumble.sourceforge.net"); QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8")); +#if QT_VERSION < 0x050000 QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); +#endif #ifdef Q_OS_WIN { @@ -188,9 +201,6 @@ int main(int argc, char **argv) { } #endif - argc = a.argc(); - argv = a.argv(); - QString inifile; QString supw; bool wipeSsl = false; @@ -201,23 +211,28 @@ int main(int argc, char **argv) { #endif qsrand(QDateTime::currentDateTime().toTime_t()); +#if QT_VERSION >= 0x050000 + qInstallMessageHandler(murmurMessageOutputWithContext); +#else qInstallMsgHandler(murmurMessageOutput); +#endif #ifdef Q_OS_WIN Tray tray(NULL, &le); #endif - for (int i=1;i<argc;i++) { + QStringList args = a.arguments(); + for (int i = 1; i < args.size(); i++) { bool bLast = false; - QString arg = QString(argv[i]).toLower(); + QString arg = args.at(i).toLower(); if ((arg == "-supw")) { detach = false; - if (i+1 < argc) { + if (i+1 < args.size()) { i++; - supw = argv[i]; - if (i+1 < argc) { + supw = args.at(i); + if (i+1 < args.size()) { i++; - sunum = QString::fromLatin1(argv[i]).toInt(); + sunum = args.at(i).toInt(); } bLast = true; } else { @@ -231,15 +246,15 @@ int main(int argc, char **argv) { } else if ((arg == "-readsupw")) { detach = false; readPw = true; - if (i+1 < argc) { + if (i+1 < args.size()) { i++; - sunum = QString::fromLatin1(argv[i]).toInt(); + sunum = args.at(i).toInt(); } bLast = true; #endif - } else if ((arg == "-ini") && (i+1 < argc)) { + } else if ((arg == "-ini") && (i+1 < args.size())) { i++; - inifile=argv[i]; + inifile = args.at(i); } else if ((arg == "-wipessl")) { wipeSsl = true; } else if ((arg == "-wipelogs")) { @@ -250,7 +265,7 @@ int main(int argc, char **argv) { bVerbose = true; } else if ((arg == "-version") || (arg == "--version")) { detach = false; - qFatal("%s -- %s", argv[0], MUMBLE_RELEASE); + qFatal("%s -- %s", qPrintable(args.at(0)), MUMBLE_RELEASE); } else if ((arg == "-h") || (arg == "-help") || (arg == "--help")) { detach = false; qFatal("Usage: %s [-ini <inifile>] [-supw <password>]\n" @@ -269,7 +284,7 @@ int main(int argc, char **argv) { " -wipelogs Remove all log entries from database.\n" " -version Show version information.\n" "If no inifile is provided, murmur will search for one in \n" - "default locations.", argv[0]); + "default locations.", qPrintable(args.at(0))); #ifdef Q_OS_UNIX } else if (arg == "-limits") { Meta::mp.read(inifile); @@ -279,9 +294,9 @@ int main(int argc, char **argv) { #endif } else { detach = false; - qFatal("Unknown argument %s", argv[i]); + qFatal("Unknown argument %s", qPrintable(args.at(i))); } - if (bLast && (i+1 != argc)) { + if (bLast && (i+1 != args.size())) { detach = false; qFatal("Password arguments must be last."); } @@ -477,7 +492,11 @@ int main(int argc, char **argv) { delete meta; +#if QT_VERSION >= 0x050000 + qInstallMessageHandler(NULL); +#else qInstallMsgHandler(NULL); +#endif #ifdef Q_OS_UNIX if (! Meta::mp.qsPid.isEmpty()) { |