diff options
author | Mikkel Krautz <mikkel@krautz.dk> | 2013-06-22 17:46:48 +0400 |
---|---|---|
committer | Mikkel Krautz <mikkel@krautz.dk> | 2013-06-29 18:56:41 +0400 |
commit | 5cb337049b42f5caa500328fe77724525ea4c6f7 (patch) | |
tree | 522afc0f9aa6402708f37fa3523138732cfa489d /src/murmur | |
parent | 29940483060a2dead35fe4cd9a7574dc9998eda9 (diff) |
mumble, murmur: Qt 5 support for Linux.
Diffstat (limited to 'src/murmur')
-rw-r--r-- | src/murmur/Cert.cpp | 14 | ||||
-rw-r--r-- | src/murmur/Server.cpp | 27 | ||||
-rw-r--r-- | src/murmur/main.cpp | 57 |
3 files changed, 76 insertions, 22 deletions
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()) { |