diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e290245cb9d4c7b6a208dbe245aab3105f4fd0a..ffaeaf43d6d8da08084dabe9a649827427946537 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,7 +50,8 @@ if(QT6) else() message(STATUS "Building Qt 5 version") set(Qt5_NO_LINK_QTMAIN ON) - find_package(Qt5 5.14 REQUIRED Core) + # Support down to Qt 5.3.2 (aka OS X 10.6) + find_package(Qt5 5.3.2 REQUIRED Core) endif() set(CMAKE_AUTOMOC ON) diff --git a/plugins/qca-gnupg/gpgaction.cpp b/plugins/qca-gnupg/gpgaction.cpp index c739dd1a7f63c18fe68f256ac91622299460215e..314659dec708a5367a28ac69bec520ec000136e2 100644 --- a/plugins/qca-gnupg/gpgaction.cpp +++ b/plugins/qca-gnupg/gpgaction.cpp @@ -35,7 +35,13 @@ static QDateTime getTimestamp(const QString &s) if (s.contains(QLatin1Char('T'))) { return QDateTime::fromString(s, Qt::ISODate); } else { +#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) return QDateTime::fromSecsSinceEpoch(s.toInt()); +#else + QDateTime dt; + dt.setTime_t(s.toInt()); + return dt; +#endif } } @@ -586,6 +592,12 @@ void GpgAction::processStatusLine(const QString &line) QString s, rest; s = nextArg(line, &rest); +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) + const auto splitPars = Qt::SkipEmptyParts; +#else + const auto splitPars = QString::SkipEmptyParts; +#endif + if (s == QLatin1String("NODATA")) { // only set this if it'll make it better if (curError == GpgOp::ErrorUnknown) @@ -665,12 +677,12 @@ void GpgAction::processStatusLine(const QString &line) output.verifyResult = GpgOp::VerifyBad; } else if (s == QLatin1String("ERRSIG")) { output.wasSigned = true; - const QStringList list = rest.split(QLatin1Char(' '), Qt::SkipEmptyParts); + const QStringList list = rest.split(QLatin1Char(' '), splitPars); output.signerId = list[0]; output.timestamp = getTimestamp(list[4]); output.verifyResult = GpgOp::VerifyNoKey; } else if (s == QLatin1String("VALIDSIG")) { - const QStringList list = rest.split(QLatin1Char(' '), Qt::SkipEmptyParts); + const QStringList list = rest.split(QLatin1Char(' '), splitPars); output.timestamp = getTimestamp(list[2]); } } diff --git a/plugins/qca-gnupg/utils.cpp b/plugins/qca-gnupg/utils.cpp index f4ecffa013e51d505938b9393a8196edff252583..8ee4fc3fb987b3dea78f910ef995c16487b65158 100644 --- a/plugins/qca-gnupg/utils.cpp +++ b/plugins/qca-gnupg/utils.cpp @@ -130,7 +130,12 @@ QString find_bin() const QString pathSep = QStringLiteral(":"); #endif - QStringList paths = QString::fromLocal8Bit(qgetenv("PATH")).split(pathSep, Qt::SkipEmptyParts); +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) + const auto splitPars = Qt::SkipEmptyParts; +#else + const auto splitPars = QString::SkipEmptyParts; +#endif + QStringList paths = QString::fromLocal8Bit(qgetenv("PATH")).split(pathSep, splitPars); #ifdef Q_OS_MAC // On Mac OS bundled always uses system default PATH diff --git a/plugins/qca-logger/qca-logger.cpp b/plugins/qca-logger/qca-logger.cpp index a80cc365e268f5d88a8eed988ee8cfc61008a6b6..e77afdf9a4fd3c5160224e8facb422815c872fdd 100644 --- a/plugins/qca-logger/qca-logger.cpp +++ b/plugins/qca-logger/qca-logger.cpp @@ -25,6 +25,12 @@ #include +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) +# define ENDL Qt::endl +#else +# define ENDL endl +#endif + using namespace QCA; namespace loggerQCAPlugin { @@ -47,14 +53,14 @@ public: void logTextMessage(const QString &message, enum QCA::Logger::Severity severity) override { - _stream << now() << " " << severityName(severity) << " " << message << Qt::endl; + _stream << now() << " " << severityName(severity) << " " << message << ENDL; } void logBinaryMessage(const QByteArray &blob, enum QCA::Logger::Severity severity) override { Q_UNUSED(blob); _stream << now() << " " << severityName(severity) << " " - << "Binary blob not implemented yet" << Qt::endl; + << "Binary blob not implemented yet" << ENDL; } private: diff --git a/src/qca_cert.cpp b/src/qca_cert.cpp index 610cd1f1a66c9b793274678786b64f480b48516a..12b4663c1a113865923001d5bc851471c826405c 100644 --- a/src/qca_cert.cpp +++ b/src/qca_cert.cpp @@ -32,6 +32,12 @@ #include +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) +# define SPLITPARS Qt::KeepEmptyParts +#else +# define SPLITPARS QString::KeepEmptyParts +#endif + namespace QCA { Provider::Context *getContext(const QString &type, const QString &provider); @@ -1250,7 +1256,7 @@ static QByteArray ipaddr_str2bin(const QString &str) { // ipv6 if (str.contains(QLatin1Char(':'))) { - const QStringList parts = str.split(QLatin1Char(':'), Qt::KeepEmptyParts); + const QStringList parts = str.split(QLatin1Char(':'), SPLITPARS); if (parts.count() < 3 || parts.count() > 8) return QByteArray(); @@ -1307,7 +1313,7 @@ static QByteArray ipaddr_str2bin(const QString &str) return ipv6; } else if (str.contains(QLatin1Char('.'))) { - const QStringList parts = str.split(QLatin1Char('.'), Qt::KeepEmptyParts); + const QStringList parts = str.split(QLatin1Char('.'), SPLITPARS); if (parts.count() != 4) return QByteArray(); @@ -1349,7 +1355,7 @@ static bool cert_match_domain(const QString &certname, const QString &acedomain) return false; // hack into parts, and require at least 1 part - const QStringList parts_name = name.split(QLatin1Char('.'), Qt::KeepEmptyParts); + const QStringList parts_name = name.split(QLatin1Char('.'), SPLITPARS); if (parts_name.isEmpty()) return false; @@ -1361,7 +1367,7 @@ static bool cert_match_domain(const QString &certname, const QString &acedomain) if (parts_name.count() >= 2 && parts_name[parts_name.count() - 2].contains(QLatin1Char('*'))) return false; - const QStringList parts_compare = acedomain.split(QLatin1Char('.'), Qt::KeepEmptyParts); + const QStringList parts_compare = acedomain.split(QLatin1Char('.'), SPLITPARS); if (parts_compare.isEmpty()) return false; diff --git a/src/qca_core.cpp b/src/qca_core.cpp index 19cbff9afcd89b6e99a60f17786a3f9102c63a42..1be2cb895ef6d844b4130a36342743335ec9654c 100644 --- a/src/qca_core.cpp +++ b/src/qca_core.cpp @@ -353,7 +353,12 @@ bool isSupported(const QStringList &features, const QString &provider) bool isSupported(const char *features, const QString &provider) { - return isSupported(QString::fromLatin1(features).split(QLatin1Char(','), Qt::SkipEmptyParts), provider); +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) + const auto splitPars = Qt::SkipEmptyParts; +#else + const auto splitPars = QString::SkipEmptyParts; +#endif + return isSupported(QString::fromLatin1(features).split(QLatin1Char(','), splitPars), provider); } QStringList supportedFeatures() diff --git a/tools/qcatool/main.cpp b/tools/qcatool/main.cpp index b9ad99742df241d95745d362898b52675a22e3d6..adf5275b50735bde4ac0b19e68b38bcbe0caaa19 100644 --- a/tools/qcatool/main.cpp +++ b/tools/qcatool/main.cpp @@ -31,6 +31,19 @@ #include "import_plugins.h" #endif +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) +# define ENDL Qt::endl +# define SPLITPARS Qt::KeepEmptyParts +#else +# define ENDL endl +# define SPLITPARS QString::KeepEmptyParts +#endif +#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) +# define QASPRINTF QString::asprintf +#else +# define QASPRINTF QString().sprintf +#endif + const char *const APPNAME = "qcatool"; const char *const EXENAME = "qcatool"; const char *const VERSION = QCA_VERSION_STR; @@ -85,14 +98,14 @@ public: void logTextMessage(const QString &message, enum QCA::Logger::Severity severity) override { - _stream << now() << " " << severityName(severity) << " " << message << Qt::endl; + _stream << now() << " " << severityName(severity) << " " << message << endl; } void logBinaryMessage(const QByteArray &blob, enum QCA::Logger::Severity severity) override { Q_UNUSED(blob); _stream << now() << " " << severityName(severity) << " " - << "Binary blob not implemented yet" << Qt::endl; + << "Binary blob not implemented yet" << endl; } private: @@ -124,7 +137,7 @@ static void output_plugin_diagnostic_text() QCA::clearPluginDiagnosticText(); if (str[str.length() - 1] == QLatin1Char('\n')) str.truncate(str.length() - 1); - const QStringList lines = str.split(QLatin1Char('\n'), Qt::KeepEmptyParts); + const QStringList lines = str.split(QLatin1Char('\n'), SPLITPARS); for (int n = 0; n < lines.count(); ++n) fprintf(stderr, "plugin: %s\n", qPrintable(lines[n])); } @@ -135,7 +148,7 @@ static void output_keystore_diagnostic_text() QCA::KeyStoreManager::clearDiagnosticText(); if (str[str.length() - 1] == QLatin1Char('\n')) str.truncate(str.length() - 1); - const QStringList lines = str.split(QLatin1Char('\n'), Qt::KeepEmptyParts); + const QStringList lines = str.split(QLatin1Char('\n'), SPLITPARS); for (int n = 0; n < lines.count(); ++n) fprintf(stderr, "keystore: %s\n", qPrintable(lines[n])); } @@ -145,7 +158,7 @@ static void output_message_diagnostic_text(QCA::SecureMessage *msg) QString str = msg->diagnosticText(); if (str[str.length() - 1] == QLatin1Char('\n')) str.truncate(str.length() - 1); - const QStringList lines = str.split(QLatin1Char('\n'), Qt::KeepEmptyParts); + const QStringList lines = str.split(QLatin1Char('\n'), SPLITPARS); for (int n = 0; n < lines.count(); ++n) fprintf(stderr, "message: %s\n", qPrintable(lines[n])); } @@ -162,7 +175,11 @@ public: kg.set = set; QEventLoop eventLoop; kg.eventLoop = &eventLoop; +#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) QTimer::singleShot(0, &kg, &AnimatedKeyGen::start); +#else + QTimer::singleShot(0, &kg, SLOT(start())); +#endif eventLoop.exec(); QCA::PrivateKey key = kg.key; return key; @@ -251,7 +268,11 @@ public: KeyStoreMonitor monitor; QEventLoop eventLoop; monitor.eventLoop = &eventLoop; +#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) QTimer::singleShot(0, &monitor, &KeyStoreMonitor::start); +#else + QTimer::singleShot(0, &monitor, SLOT(start())); +#endif eventLoop.exec(); } @@ -1525,7 +1546,7 @@ public: // provider settings (always write at least 10 providers) for (int n = 0; n < 10 || n < providers.count(); ++n) { - QString prefix = QString::asprintf("provider_%02d_", n); + QString prefix = QASPRINTF("provider_%02d_", n); Pkcs11ProviderConfig provider; if (n < providers.count()) @@ -1553,7 +1574,7 @@ public: pin_cache = in[QStringLiteral("pin_cache")].toInt(); for (int n = 0;; ++n) { - QString prefix = QString::asprintf("provider_%02d_", n); + QString prefix = QASPRINTF("provider_%02d_", n); // collect all key/values with this prefix into a // a separate container, leaving out the prefix diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt index f882ecde17bfb889fc01bd00e18f6772caded172..42cf15e429ca14790fdfa2f200cec7888ca07f3b 100644 --- a/unittest/CMakeLists.txt +++ b/unittest/CMakeLists.txt @@ -27,7 +27,12 @@ add_subdirectory(logger) add_subdirectory(macunittest) add_subdirectory(metatype) add_subdirectory(pgpunittest) -add_subdirectory(pipeunittest) +if (Qt5Test_FOUND AND Qt5Test_VERSION VERSION_GREATER_EQUAL 5.4.0) + add_subdirectory(pipeunittest) +else() + # RJVB being lazy; too many point changes in the pipeunittest + message(STATUS "Skipping pipeunittest; Qt ${Qt5Test_VERSION} too old") +endif() add_subdirectory(pkits) add_subdirectory(rsaunittest) add_subdirectory(securearrayunittest) diff --git a/unittest/bigintunittest/bigintunittest.cpp b/unittest/bigintunittest/bigintunittest.cpp index a94d15cc4db598d42b6d6d884be9a6186d27e76c..c4b6812034f50e6206d83e3d292df60cf315b5b6 100644 --- a/unittest/bigintunittest/bigintunittest.cpp +++ b/unittest/bigintunittest/bigintunittest.cpp @@ -30,6 +30,12 @@ #include "import_plugins.h" #endif +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) +# define ENDL Qt::endl +#else +# define ENDL endl +#endif + class BigIntUnitTest : public QObject { Q_OBJECT @@ -87,7 +93,7 @@ void BigIntUnitTest::allTests() // Check if the stream operator is any good QString testString; QTextStream ts(&testString, QIODevice::WriteOnly); - ts << a << b << c << Qt::endl; + ts << a << b << c << ENDL; QCOMPARE(testString, QStringLiteral("4000000000000-40000000000002000000000000\n")); // Botan's addition tests diff --git a/unittest/filewatchunittest/filewatchunittest.cpp b/unittest/filewatchunittest/filewatchunittest.cpp index d1bc117cb6f6bd2c135d7a404010c114779c23ec..ad238877c3f69ce8b68e112a7614ddb5a40acc68 100644 --- a/unittest/filewatchunittest/filewatchunittest.cpp +++ b/unittest/filewatchunittest/filewatchunittest.cpp @@ -45,7 +45,11 @@ void FileWatchUnitTest::filewatchTest() QCA::FileWatch watcher; QCOMPARE(watcher.fileName(), QString()); +#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) QSignalSpy spy(&watcher, &QCA::FileWatch::changed); +#else + QSignalSpy spy(&watcher, SIGNAL(changed())); +#endif QVERIFY(spy.isValid()); QCOMPARE(spy.count(), 0); diff --git a/src/qca_default.cpp b/src/qca_default.cpp index 294b90565e50c493da36eb6a5ba998fe2cb48645..5c8b7c3e113f7f2f7cb9151f5b4b8464e388b8f0 100644 --- a/src/qca_default.cpp +++ b/src/qca_default.cpp @@ -1250,7 +1250,12 @@ public: { const QDateTime now = QDateTime::currentDateTime(); +#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) uint t = now.toSecsSinceEpoch(); +#else + // implementation from v2.2.1: + uint t = now.toTime_t(); +#endif if (now.time().msec() > 0) t /= now.time().msec(); std::srand(t); diff --git a/src/qca_keystore.cpp b/src/qca_keystore.cpp index 2284a10d201c700ca2f66d28f173b098b793f8b4..292075b5d481230e05fa800274a38df0dfa04080 100644 --- a/src/qca_keystore.cpp +++ b/src/qca_keystore.cpp @@ -1516,7 +1516,11 @@ public: public Q_SLOTS: void tracker_updated() { +#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) QCA_logTextMessage(QString::asprintf("keystore: %p: tracker_updated start", q), Logger::Information); +#else + QCA_logTextMessage(QString().sprintf("keystore: %p: tracker_updated start", q), Logger::Information); +#endif QMutexLocker locker(&m); if (!pending) { @@ -1529,7 +1533,11 @@ public Q_SLOTS: w.wakeOne(); } +#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) QCA_logTextMessage(QString::asprintf("keystore: %p: tracker_updated end", q), Logger::Information); +#else + QCA_logTextMessage(QString().sprintf("keystore: %p: tracker_updated end", q), Logger::Information); +#endif } void update() diff --git a/src/qca_plugin.cpp b/src/qca_plugin.cpp index f00467845bdfda800af7ef7b46e36acd6ecd05ca..7078f6a8015039f3ac25e28aa7b4472c36d0926a 100644 --- a/src/qca_plugin.cpp +++ b/src/qca_plugin.cpp @@ -336,7 +336,11 @@ void ProviderManager::scan() const int ver = i->p->qcaVersion(); if (!validVersion(ver)) { +#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) errstr = QString::asprintf("plugin version 0x%06x is in the future", ver); +#else + errstr.sprintf("plugin version 0x%06x is in the future", ver); +#endif logDebug(QStringLiteral(" %1: (as %2) %3").arg(className, providerName, errstr)); delete i; continue; @@ -418,7 +422,11 @@ void ProviderManager::scan() const int ver = i->p->qcaVersion(); if (!validVersion(ver)) { +#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) errstr = QString::asprintf("plugin version 0x%06x is in the future", ver); +#else + errstr.sprintf("plugin version 0x%06x is in the future", ver); +#endif logDebug(QStringLiteral(" %1: (class: %2, as %3) %4").arg(fileName, className, providerName, errstr)); delete i; continue; @@ -451,7 +459,12 @@ bool ProviderManager::add(Provider *p, int priority) const int ver = p->qcaVersion(); if (!validVersion(ver)) { +#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) QString errstr = QString::asprintf("plugin version 0x%06x is in the future", ver); +#else + QString errstr; + errstr.sprintf("plugin version 0x%06x is in the future", ver); +#endif logDebug(QStringLiteral("Directly adding: %1: %2").arg(providerName, errstr)); return false; } @@ -491,7 +504,11 @@ void ProviderManager::unloadAll() while (!providerItemList.isEmpty()) { ProviderItem *i = providerItemList.first(); +#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 3) const QString name = i->p->name(); +#else + const QString name = i->fname; +#endif delete i; providerItemList.removeFirst(); providerList.removeFirst(); diff --git a/src/support/logger.cpp b/src/support/logger.cpp index cda4ee46b8a83c2a341135320c7ea7437c6eba82..bdd22d008664102a2ea0946563572d141e44aa26 100644 --- a/src/support/logger.cpp +++ b/src/support/logger.cpp @@ -20,6 +20,19 @@ #include "qca_support.h" +#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) +namespace QtPrivate { +template struct QAddConst { typedef const T Type; }; +} + +// this adds const to non-const objects (like std::as_const) +template +Q_DECL_CONSTEXPR typename QtPrivate::QAddConst::Type &qAsConst(T &t) Q_DECL_NOTHROW { return t; } +// prevent rvalue arguments: +template +void qAsConst(const T &&) Q_DECL_EQ_DELETE; +#endif + namespace QCA { AbstractLogDevice::AbstractLogDevice(const QString &name, QObject *parent) diff --git a/plugins/qca-botan/qca-botan.cpp b/plugins/qca-botan/qca-botan.cpp index e335edbff3c4b620885cb0e8a745c98f84c4de73..51187b9b44fb868098c6d7ca9111cf89277b2e1a 100644 --- a/plugins/qca-botan/qca-botan.cpp +++ b/plugins/qca-botan/qca-botan.cpp @@ -36,6 +36,19 @@ #include #include +#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) +namespace QtPrivate { +template struct QAddConst { typedef const T Type; }; +} + +// this adds const to non-const objects (like std::as_const) +template +Q_DECL_CONSTEXPR typename QtPrivate::QAddConst::Type &qAsConst(T &t) Q_DECL_NOTHROW { return t; } +// prevent rvalue arguments: +template +void qAsConst(const T &&) Q_DECL_EQ_DELETE; +#endif + //----------------------------------------------------------- class botanRandomContext : public QCA::RandomContext { diff --git a/plugins/qca-gnupg/gpgproc/gpgproc_p.h b/plugins/qca-gnupg/gpgproc/gpgproc_p.h index 7c21f251b49b7bdcd141f62608501dcc502d93ff..8a53524f7408c3c6cce9dea02099402e5276e874 100644 --- a/plugins/qca-gnupg/gpgproc/gpgproc_p.h +++ b/plugins/qca-gnupg/gpgproc/gpgproc_p.h @@ -46,12 +46,20 @@ public: &QProcessSignalRelay::proc_readyReadStandardError, Qt::QueuedConnection); connect(proc, &QProcess::bytesWritten, this, &QProcessSignalRelay::proc_bytesWritten, Qt::QueuedConnection); +#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) connect(proc, QOverload::of(&QProcess::finished), this, &QProcessSignalRelay::proc_finished, Qt::QueuedConnection); +#else + connect(proc, SIGNAL(finished(int)), SLOT(proc_finished(int)), Qt::QueuedConnection); +#endif +#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) connect(proc, &QProcess::errorOccurred, this, &QProcessSignalRelay::proc_error, Qt::QueuedConnection); +#else + connect(proc, SIGNAL(error(QProcess::ProcessError)), SLOT(proc_error(QProcess::ProcessError)), Qt::QueuedConnection); +#endif } Q_SIGNALS: diff --git a/plugins/qca-ossl/qca-ossl.cpp b/plugins/qca-ossl/qca-ossl.cpp index 9c81746844f9d8543f7e9eff8603662f495d7a1e..74c5f49c6754b0350a3367ac90d404e4e756b2b2 100644 --- a/plugins/qca-ossl/qca-ossl.cpp +++ b/plugins/qca-ossl/qca-ossl.cpp @@ -3474,8 +3475,13 @@ public: BN_free(bn); // validity period +#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) ASN1_TIME_set(X509_get_notBefore(x), opts.notValidBefore().toSecsSinceEpoch()); ASN1_TIME_set(X509_get_notAfter(x), opts.notValidAfter().toSecsSinceEpoch()); +#else + ASN1_TIME_set(X509_get_notBefore(x), opts.notValidBefore().toTime_t()); + ASN1_TIME_set(X509_get_notAfter(x), opts.notValidAfter().toTime_t()); +#endif // public key X509_set_pubkey(x, pk); @@ -3878,8 +3884,13 @@ public: BN_free(bn); // validity period +#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) ASN1_TIME_set(X509_get_notBefore(x), QDateTime::currentDateTimeUtc().toSecsSinceEpoch()); ASN1_TIME_set(X509_get_notAfter(x), notValidAfter.toSecsSinceEpoch()); +#else + ASN1_TIME_set(X509_get_notBefore(x), QDateTime::currentDateTimeUtc().toTime_t()); + ASN1_TIME_set(X509_get_notAfter(x), notValidAfter.toTime_t()); +#endif X509_set_pubkey(x, static_cast(req.subjectPublicKey())->get_pkey()); X509_set_subject_name(x, subjectName); diff --git a/plugins/qca-pkcs11/qca-pkcs11.cpp b/plugins/qca-pkcs11/qca-pkcs11.cpp index ae13bf0a3c34f87614f446ecebd32fa43976e611..8ee1d881b6c64a32b618ffae0ae25fd38bb18fb2 100644 --- a/plugins/qca-pkcs11/qca-pkcs11.cpp +++ b/plugins/qca-pkcs11/qca-pkcs11.cpp @@ -29,6 +29,12 @@ #include #include +#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) +# define QASPRINTF QString::asprintf +#else +# define QASPRINTF QString().sprintf +#endif + using namespace QCA; // qPrintable is ASCII only!!! @@ -443,7 +449,7 @@ public: bool ret = false; QCA_logTextMessage( - QString::asprintf("pkcs11RSAContext::decrypt - decrypt in.size()=%d, alg=%d", in.size(), (int)alg), + QASPRINTF("pkcs11RSAContext::decrypt - decrypt in.size()=%d, alg=%d", in.size(), (int)alg), Logger::Debug); try { @@ -506,11 +512,11 @@ public: if (s_keyStoreList != nullptr) { s_keyStoreList->_emit_diagnosticText( - QString::asprintf("PKCS#11: Cannot decrypt: %lu-'%s'.\n", e.rv(), myPrintable(e.message()))); + QASPRINTF("PKCS#11: Cannot decrypt: %lu-'%s'.\n", e.rv(), myPrintable(e.message()))); } } - QCA_logTextMessage(QString::asprintf("pkcs11RSAContext::decrypt - decrypt out->size()=%d", out->size()), + QCA_logTextMessage(QASPRINTF("pkcs11RSAContext::decrypt - decrypt out->size()=%d", out->size()), Logger::Debug); return ret; @@ -538,7 +544,7 @@ public: case EMSA1_SHA1: case EMSA3_RIPEMD160: default: - QCA_logTextMessage(QString::asprintf("PKCS#11: Invalid hash algorithm %d", _sign_data.alg), + QCA_logTextMessage(QASPRINTF("PKCS#11: Invalid hash algorithm %d", _sign_data.alg), Logger::Warning); break; } @@ -632,14 +638,14 @@ public: if (s_keyStoreList != nullptr) { s_keyStoreList->_emit_diagnosticText( - QString::asprintf("PKCS#11: Cannot sign: %lu-'%s'.\n", e.rv(), myPrintable(e.message()))); + QASPRINTF("PKCS#11: Cannot sign: %lu-'%s'.\n", e.rv(), myPrintable(e.message()))); } } _clearSign(); QCA_logTextMessage( - QString::asprintf("pkcs11RSAContext::endSign - return result.size ()=%d", int(result.size())), + QASPRINTF("pkcs11RSAContext::endSign - return result.size ()=%d", int(result.size())), Logger::Debug); return result; @@ -715,7 +721,7 @@ public: ret = pkcs11h_token_ensureAccess(_pkcs11h_certificate_id->token_id, nullptr, 0) == CKR_OK; - QCA_logTextMessage(QString::asprintf("pkcs11RSAContext::_ensureTokenAvailable - return ret=%d", ret ? 1 : 0), + QCA_logTextMessage(QASPRINTF("pkcs11RSAContext::_ensureTokenAvailable - return ret=%d", ret ? 1 : 0), Logger::Debug); return ret; @@ -730,7 +736,7 @@ public: ret = pkcs11h_token_ensureAccess(_pkcs11h_certificate_id->token_id, nullptr, PKCS11H_PROMPT_MASK_ALLOW_ALL) == CKR_OK; - QCA_logTextMessage(QString::asprintf("pkcs11RSAContext::_ensureTokenAccess - return ret=%d", ret ? 1 : 0), + QCA_logTextMessage(QASPRINTF("pkcs11RSAContext::_ensureTokenAccess - return ret=%d", ret ? 1 : 0), Logger::Debug); return ret; @@ -1048,8 +1054,11 @@ private: Certificate cert = Certificate::fromDER(QByteArray((char *)blob, blob_size)); +#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) *expiration = cert.notValidAfter().toSecsSinceEpoch(); - +#else + *expiration = cert.notValidAfter().toTime_t(); +#endif return TRUE; // krazy:exclude=captruefalse } @@ -1105,7 +1114,7 @@ pkcs11KeyStoreListContext::pkcs11KeyStoreListContext(Provider *p) : KeyStoreListContext(p) { QCA_logTextMessage( - QString::asprintf("pkcs11KeyStoreListContext::pkcs11KeyStoreListContext - entry Provider=%p", (void *)p), + QASPRINTF("pkcs11KeyStoreListContext::pkcs11KeyStoreListContext - entry Provider=%p", (void *)p), Logger::Debug); _last_id = 0; @@ -1142,7 +1151,7 @@ void pkcs11KeyStoreListContext::start() void pkcs11KeyStoreListContext::setUpdatesEnabled(bool enabled) { QCA_logTextMessage( - QString::asprintf("pkcs11KeyStoreListContext::setUpdatesEnabled - entry enabled=%d", enabled ? 1 : 0), + QASPRINTF("pkcs11KeyStoreListContext::setUpdatesEnabled - entry enabled=%d", enabled ? 1 : 0), Logger::Debug); try { @@ -1154,7 +1163,7 @@ void pkcs11KeyStoreListContext::setUpdatesEnabled(bool enabled) } } catch (const pkcs11Exception &e) { s_keyStoreList->_emit_diagnosticText( - QString::asprintf("PKCS#11: Start event failed %lu-'%s'.\n", e.rv(), myPrintable(e.message()))); + QASPRINTF("PKCS#11: Start event failed %lu-'%s'.\n", e.rv(), myPrintable(e.message()))); } QCA_logTextMessage(QStringLiteral("pkcs11KeyStoreListContext::setUpdatesEnabled - return"), Logger::Debug); @@ -1162,7 +1171,7 @@ void pkcs11KeyStoreListContext::setUpdatesEnabled(bool enabled) KeyStoreEntryContext *pkcs11KeyStoreListContext::entry(int id, const QString &entryId) { - QCA_logTextMessage(QString::asprintf("pkcs11KeyStoreListContext::entry - entry/return id=%d entryId='%s'", + QCA_logTextMessage(QASPRINTF("pkcs11KeyStoreListContext::entry - entry/return id=%d entryId='%s'", id, myPrintable(entryId)), Logger::Debug); @@ -1178,7 +1187,7 @@ KeyStoreEntryContext *pkcs11KeyStoreListContext::entryPassive(const QString &ser pkcs11h_certificate_id_t certificate_id = nullptr; QCA_logTextMessage( - QString::asprintf("pkcs11KeyStoreListContext::entryPassive - entry serialized='%s'", myPrintable(serialized)), + QASPRINTF("pkcs11KeyStoreListContext::entryPassive - entry serialized='%s'", myPrintable(serialized)), Logger::Debug); try { @@ -1196,7 +1205,7 @@ KeyStoreEntryContext *pkcs11KeyStoreListContext::entryPassive(const QString &ser } } catch (const pkcs11Exception &e) { s_keyStoreList->_emit_diagnosticText( - QString::asprintf("PKCS#11: Add key store entry %lu-'%s'.\n", e.rv(), myPrintable(e.message()))); + QASPRINTF("PKCS#11: Add key store entry %lu-'%s'.\n", e.rv(), myPrintable(e.message()))); } if (certificate_id != nullptr) { @@ -1204,7 +1213,7 @@ KeyStoreEntryContext *pkcs11KeyStoreListContext::entryPassive(const QString &ser certificate_id = nullptr; } - QCA_logTextMessage(QString::asprintf("pkcs11KeyStoreListContext::entryPassive - return entry=%p", (void *)entry), + QCA_logTextMessage(QASPRINTF("pkcs11KeyStoreListContext::entryPassive - return entry=%p", (void *)entry), Logger::Debug); return entry; @@ -1214,7 +1223,7 @@ KeyStore::Type pkcs11KeyStoreListContext::type(int id) const { Q_UNUSED(id); - QCA_logTextMessage(QString::asprintf("pkcs11KeyStoreListContext::type - entry/return id=%d", id), Logger::Debug); + QCA_logTextMessage(QASPRINTF("pkcs11KeyStoreListContext::type - entry/return id=%d", id), Logger::Debug); return KeyStore::SmartCard; } @@ -1223,13 +1232,13 @@ QString pkcs11KeyStoreListContext::storeId(int id) const { QString ret; - QCA_logTextMessage(QString::asprintf("pkcs11KeyStoreListContext::storeId - entry id=%d", id), Logger::Debug); + QCA_logTextMessage(QASPRINTF("pkcs11KeyStoreListContext::storeId - entry id=%d", id), Logger::Debug); if (_storesById.contains(id)) { ret = _tokenId2storeId(_storesById[id]->tokenId()); } - QCA_logTextMessage(QString::asprintf("pkcs11KeyStoreListContext::storeId - return ret=%s", myPrintable(ret)), + QCA_logTextMessage(QASPRINTF("pkcs11KeyStoreListContext::storeId - return ret=%s", myPrintable(ret)), Logger::Debug); return ret; @@ -1239,13 +1248,13 @@ QString pkcs11KeyStoreListContext::name(int id) const { QString ret; - QCA_logTextMessage(QString::asprintf("pkcs11KeyStoreListContext::name - entry id=%d", id), Logger::Debug); + QCA_logTextMessage(QASPRINTF("pkcs11KeyStoreListContext::name - entry id=%d", id), Logger::Debug); if (_storesById.contains(id)) { ret = QString::fromLatin1(_storesById[id]->tokenId()->label); } - QCA_logTextMessage(QString::asprintf("pkcs11KeyStoreListContext::name - return ret=%s", myPrintable(ret)), + QCA_logTextMessage(QASPRINTF("pkcs11KeyStoreListContext::name - return ret=%s", myPrintable(ret)), Logger::Debug); return ret; @@ -1255,7 +1264,7 @@ QList pkcs11KeyStoreListContext::entryTypes(int id) const { Q_UNUSED(id); - QCA_logTextMessage(QString::asprintf("pkcs11KeyStoreListContext::entryTypes - entry/return id=%d", id), + QCA_logTextMessage(QASPRINTF("pkcs11KeyStoreListContext::entryTypes - entry/return id=%d", id), Logger::Debug); QList list; @@ -1311,7 +1320,7 @@ QList pkcs11KeyStoreListContext::keyStores() } } catch (const pkcs11Exception &e) { s_keyStoreList->_emit_diagnosticText( - QString::asprintf("PKCS#11: Cannot get key stores: %lu-'%s'.\n", e.rv(), myPrintable(e.message()))); + QASPRINTF("PKCS#11: Cannot get key stores: %lu-'%s'.\n", e.rv(), myPrintable(e.message()))); } if (tokens != nullptr) { @@ -1319,7 +1328,7 @@ QList pkcs11KeyStoreListContext::keyStores() } QCA_logTextMessage( - QString::asprintf("pkcs11KeyStoreListContext::keyStores - return out.size()=%d", int(out.size())), + QASPRINTF("pkcs11KeyStoreListContext::keyStores - return out.size()=%d", int(out.size())), Logger::Debug); return out; @@ -1330,7 +1339,7 @@ QList pkcs11KeyStoreListContext::entryList(int id) pkcs11h_certificate_id_list_t certs = nullptr; QList out; - QCA_logTextMessage(QString::asprintf("pkcs11KeyStoreListContext::entryList - entry id=%d", id), Logger::Debug); + QCA_logTextMessage(QASPRINTF("pkcs11KeyStoreListContext::entryList - entry id=%d", id), Logger::Debug); try { CK_RV rv; @@ -1393,7 +1402,7 @@ QList pkcs11KeyStoreListContext::entryList(int id) current->certificate_id, false, chain, friendlyNames[certificateHash(chain.primary())]); } } catch (const pkcs11Exception &e) { - s_keyStoreList->_emit_diagnosticText(QString::asprintf( + s_keyStoreList->_emit_diagnosticText(QASPRINTF( "PKCS#11: Add key store entry %lu-'%s'.\n", e.rv(), myPrintable(e.message()))); } } @@ -1408,14 +1417,14 @@ QList pkcs11KeyStoreListContext::entryList(int id) out += _keyStoreEntryByCertificateId( current->certificate_id, true, chain, friendlyNames[certificateHash(chain.primary())]); } catch (const pkcs11Exception &e) { - s_keyStoreList->_emit_diagnosticText(QString::asprintf( + s_keyStoreList->_emit_diagnosticText(QASPRINTF( "PKCS#11: Add key store entry %lu-'%s'.\n", e.rv(), myPrintable(e.message()))); } } } } catch (const pkcs11Exception &e) { s_keyStoreList->_emit_diagnosticText( - QString::asprintf("PKCS#11: Enumerating store failed %lu-'%s'.\n", e.rv(), myPrintable(e.message()))); + QASPRINTF("PKCS#11: Enumerating store failed %lu-'%s'.\n", e.rv(), myPrintable(e.message()))); } if (certs != nullptr) { @@ -1423,7 +1432,7 @@ QList pkcs11KeyStoreListContext::entryList(int id) } QCA_logTextMessage( - QString::asprintf("pkcs11KeyStoreListContext::entryList - return out.size()=%d", int(out.size())), + QASPRINTF("pkcs11KeyStoreListContext::entryList - return out.size()=%d", int(out.size())), Logger::Debug); return out; @@ -1436,7 +1445,7 @@ bool pkcs11KeyStoreListContext::_tokenPrompt(void *const user_data, const pkcs11 QString storeId, storeName; bool ret = false; - QCA_logTextMessage(QString::asprintf("pkcs11KeyStoreListContext::_tokenPrompt - entry user_data=%p, token_id=%p", + QCA_logTextMessage(QASPRINTF("pkcs11KeyStoreListContext::_tokenPrompt - entry user_data=%p, token_id=%p", user_data, (void *)token_id), Logger::Debug); @@ -1460,7 +1469,7 @@ bool pkcs11KeyStoreListContext::_tokenPrompt(void *const user_data, const pkcs11 ret = true; } - QCA_logTextMessage(QString::asprintf("pkcs11KeyStoreListContext::_tokenPrompt - return ret=%d", ret ? 1 : 0), + QCA_logTextMessage(QASPRINTF("pkcs11KeyStoreListContext::_tokenPrompt - return ret=%d", ret ? 1 : 0), Logger::Debug); return ret; @@ -1473,7 +1482,7 @@ bool pkcs11KeyStoreListContext::_pinPrompt(void *const user_data, const pkcs11h_ QString storeId, storeName; bool ret = false; - QCA_logTextMessage(QString::asprintf("pkcs11KeyStoreListContext::_pinPrompt - entry user_data=%p, token_id=%p", + QCA_logTextMessage(QASPRINTF("pkcs11KeyStoreListContext::_pinPrompt - entry user_data=%p, token_id=%p", user_data, (void *)token_id), Logger::Debug); @@ -1500,7 +1509,7 @@ bool pkcs11KeyStoreListContext::_pinPrompt(void *const user_data, const pkcs11h_ pin = asker.password(); } - QCA_logTextMessage(QString::asprintf("pkcs11KeyStoreListContext::_pinPrompt - return ret=%d", ret ? 1 : 0), + QCA_logTextMessage(QASPRINTF("pkcs11KeyStoreListContext::_pinPrompt - return ret=%d", ret ? 1 : 0), Logger::Debug); return ret; @@ -1509,7 +1518,7 @@ bool pkcs11KeyStoreListContext::_pinPrompt(void *const user_data, const pkcs11h_ void pkcs11KeyStoreListContext::_emit_diagnosticText(const QString &t) { QCA_logTextMessage( - QString::asprintf("pkcs11KeyStoreListContext::_emit_diagnosticText - entry t='%s'", myPrintable(t)), + QASPRINTF("pkcs11KeyStoreListContext::_emit_diagnosticText - entry t='%s'", myPrintable(t)), Logger::Debug); QCA_logTextMessage(t, Logger::Warning); @@ -1541,7 +1550,7 @@ pkcs11KeyStoreListContext::pkcs11KeyStoreItem * pkcs11KeyStoreListContext::_registerTokenId(const pkcs11h_token_id_t token_id) { QCA_logTextMessage( - QString::asprintf("pkcs11KeyStoreListContext::_registerTokenId - entry token_id=%p", (void *)token_id), + QASPRINTF("pkcs11KeyStoreListContext::_registerTokenId - entry token_id=%p", (void *)token_id), Logger::Debug); QMutexLocker l(&_mutexStores); @@ -1570,7 +1579,7 @@ pkcs11KeyStoreListContext::_registerTokenId(const pkcs11h_token_id_t token_id) } QCA_logTextMessage( - QString::asprintf("pkcs11KeyStoreListContext::_registerTokenId - return entry=%p", (void *)token_id), + QASPRINTF("pkcs11KeyStoreListContext::_registerTokenId - return entry=%p", (void *)token_id), Logger::Debug); return entry; @@ -1600,7 +1609,7 @@ pkcs11KeyStoreListContext::_keyStoreEntryByCertificateId(const pkcs11h_certifica { pkcs11KeyStoreEntryContext *entry = nullptr; - QCA_logTextMessage(QString::asprintf("pkcs11KeyStoreListContext::_keyStoreEntryByCertificateId - entry " + QCA_logTextMessage(QASPRINTF("pkcs11KeyStoreListContext::_keyStoreEntryByCertificateId - entry " "certificate_id=%p, has_private=%d, chain.size()=%d", (void *)certificate_id, has_private ? 1 : 0, @@ -1647,7 +1656,7 @@ pkcs11KeyStoreListContext::_keyStoreEntryByCertificateId(const pkcs11h_certifica } QCA_logTextMessage( - QString::asprintf("pkcs11KeyStoreListContext::_keyStoreEntryByCertificateId - return entry=%p", (void *)entry), + QASPRINTF("pkcs11KeyStoreListContext::_keyStoreEntryByCertificateId - return entry=%p", (void *)entry), Logger::Debug); return entry; @@ -1659,7 +1668,7 @@ QString pkcs11KeyStoreListContext::_tokenId2storeId(const pkcs11h_token_id_t tok size_t len; QCA_logTextMessage( - QString::asprintf("pkcs11KeyStoreListContext::_tokenId2storeId - entry token_id=%p", (void *)token_id), + QASPRINTF("pkcs11KeyStoreListContext::_tokenId2storeId - entry token_id=%p", (void *)token_id), Logger::Debug); if (pkcs11h_token_serializeTokenId(nullptr, &len, token_id) != CKR_OK) { @@ -1678,7 +1687,7 @@ QString pkcs11KeyStoreListContext::_tokenId2storeId(const pkcs11h_token_id_t tok storeId = QStringLiteral("qca-pkcs11/") + _escapeString(QString::fromUtf8(buf)); QCA_logTextMessage( - QString::asprintf("pkcs11KeyStoreListContext::_tokenId2storeId - return storeId='%s'", myPrintable(storeId)), + QASPRINTF("pkcs11KeyStoreListContext::_tokenId2storeId - return storeId='%s'", myPrintable(storeId)), Logger::Debug); return storeId; @@ -1692,7 +1701,7 @@ QString pkcs11KeyStoreListContext::_serializeCertificate(const pkcs11h_certifica size_t len; QCA_logTextMessage( - QString::asprintf( + QASPRINTF( "pkcs11KeyStoreListContext::_serializeCertificate - entry certificate_id=%p, xx, has_private=%d", (void *)certificate_id, has_private ? 1 : 0), @@ -1711,7 +1720,7 @@ QString pkcs11KeyStoreListContext::_serializeCertificate(const pkcs11h_certifica buf.resize((int)len); - serialized = QString::asprintf( + serialized = QASPRINTF( "qca-pkcs11/0/%s/%d/", myPrintable(_escapeString(QString::fromUtf8(buf))), has_private ? 1 : 0); QStringList list; @@ -1721,7 +1730,7 @@ QString pkcs11KeyStoreListContext::_serializeCertificate(const pkcs11h_certifica serialized.append(list.join(QStringLiteral("/"))); - QCA_logTextMessage(QString::asprintf("pkcs11KeyStoreListContext::_serializeCertificate - return serialized='%s'", + QCA_logTextMessage(QASPRINTF("pkcs11KeyStoreListContext::_serializeCertificate - return serialized='%s'", myPrintable(serialized)), Logger::Debug); @@ -1736,7 +1745,7 @@ void pkcs11KeyStoreListContext::_deserializeCertificate(const QString & pkcs11h_certificate_id_t certificate_id = nullptr; chain.clear(); - QCA_logTextMessage(QString::asprintf("pkcs11KeyStoreListContext::_deserializeCertificate - entry from='%s', " + QCA_logTextMessage(QASPRINTF("pkcs11KeyStoreListContext::_deserializeCertificate - entry from='%s', " "p_certificate_id=%p, p_has_private=%p", myPrintable(from), (void *)p_certificate_id, @@ -1804,7 +1813,7 @@ void pkcs11KeyStoreListContext::_deserializeCertificate(const QString & } QCA_logTextMessage( - QString::asprintf( + QASPRINTF( "pkcs11KeyStoreListContext::_deserializeCertificate - return *p_certificate_id=%p, chain.size()=%d", (void *)*p_certificate_id, int(chain.size())), @@ -1817,7 +1826,7 @@ QString pkcs11KeyStoreListContext::_escapeString(const QString &from) const foreach (QChar c, from) { if (c == QLatin1Char('/') || c == QLatin1Char('\\')) { - to += QString::asprintf("\\x%04x", c.unicode()); + to += QASPRINTF("\\x%04x", c.unicode()); } else { to += c; } @@ -1914,7 +1923,7 @@ void pkcs11Provider::init() } catch (const pkcs11Exception &e) { QCA_logTextMessage(e.message(), Logger::Error); appendPluginDiagnosticText( - QString::asprintf("An error %s during initialization of qca-pkcs11 plugin\n", myPrintable(e.message()))); + QASPRINTF("An error %s during initialization of qca-pkcs11 plugin\n", myPrintable(e.message()))); } catch (...) { QCA_logTextMessage(QStringLiteral("PKCS#11: Unknown error during provider initialization"), Logger::Error); appendPluginDiagnosticText(QStringLiteral("Unknown error during initialization of qca-pkcs11 plugin\n")); @@ -1957,7 +1966,7 @@ Provider::Context *pkcs11Provider::createContext(const QString &type) { Provider::Context *context = nullptr; - QCA_logTextMessage(QString::asprintf("pkcs11Provider::createContext - entry type='%s'", myPrintable(type)), + QCA_logTextMessage(QASPRINTF("pkcs11Provider::createContext - entry type='%s'", myPrintable(type)), Logger::Debug); if (_lowLevelInitialized) { @@ -1969,7 +1978,7 @@ Provider::Context *pkcs11Provider::createContext(const QString &type) } } - QCA_logTextMessage(QString::asprintf("pkcs11Provider::createContext - return context=%p", (void *)context), + QCA_logTextMessage(QASPRINTF("pkcs11Provider::createContext - return context=%p", (void *)context), Logger::Debug); return context; @@ -2015,14 +2024,14 @@ QVariantMap pkcs11Provider::defaultConfig() const mytemplate[QStringLiteral("pin_cache")] = PKCS11H_PIN_CACHE_INFINITE; mytemplate[QStringLiteral("log_level")] = 0; for (int i = 0; i < _CONFIG_MAX_PROVIDERS; i++) { - mytemplate[QString::asprintf("provider_%02d_enabled", i)] = false; - mytemplate[QString::asprintf("provider_%02d_name", i)] = QLatin1String(""); - mytemplate[QString::asprintf("provider_%02d_library", i)] = QLatin1String(""); - mytemplate[QString::asprintf("provider_%02d_allow_protected_authentication", i)] = true; - mytemplate[QString::asprintf("provider_%02d_cert_private", i)] = false; - mytemplate[QString::asprintf("provider_%02d_private_mask", i)] = PKCS11H_PRIVATEMODE_MASK_AUTO; - mytemplate[QString::asprintf("provider_%02d_slotevent_method", i)] = QStringLiteral("auto"); - mytemplate[QString::asprintf("provider_%02d_slotevent_timeout", i)] = 0; + mytemplate[QASPRINTF("provider_%02d_enabled", i)] = false; + mytemplate[QASPRINTF("provider_%02d_name", i)] = QLatin1String(""); + mytemplate[QASPRINTF("provider_%02d_library", i)] = QLatin1String(""); + mytemplate[QASPRINTF("provider_%02d_allow_protected_authentication", i)] = true; + mytemplate[QASPRINTF("provider_%02d_cert_private", i)] = false; + mytemplate[QASPRINTF("provider_%02d_private_mask", i)] = PKCS11H_PRIVATEMODE_MASK_AUTO; + mytemplate[QASPRINTF("provider_%02d_slotevent_method", i)] = QStringLiteral("auto"); + mytemplate[QASPRINTF("provider_%02d_slotevent_timeout", i)] = 0; } return mytemplate; @@ -2060,10 +2069,10 @@ void pkcs11Provider::configChanged(const QVariantMap &config) * Add new providers */ for (int i = 0; i < _CONFIG_MAX_PROVIDERS; i++) { - bool enabled = config[QString::asprintf("provider_%02d_enabled", i)].toBool(); - QString provider = config[QString::asprintf("provider_%02d_library", i)].toString(); - QString name = config[QString::asprintf("provider_%02d_name", i)].toString(); - QString qslotevent = config[QString::asprintf("provider_%02d_slotevent_method", i)].toString(); + bool enabled = config[QASPRINTF("provider_%02d_enabled", i)].toBool(); + QString provider = config[QASPRINTF("provider_%02d_library", i)].toString(); + QString name = config[QASPRINTF("provider_%02d_name", i)].toString(); + QString qslotevent = config[QASPRINTF("provider_%02d_slotevent_method", i)].toString(); unsigned slotevent = PKCS11H_SLOTEVENT_METHOD_AUTO; if (qslotevent == QLatin1String("trigger")) { slotevent = PKCS11H_SLOTEVENT_METHOD_TRIGGER; @@ -2077,29 +2086,29 @@ void pkcs11Provider::configChanged(const QVariantMap &config) if (enabled && !provider.isEmpty()) { QCA_logTextMessage( - QString::asprintf("Loading PKCS#11 provider '%s' (%s)", myPrintable(name), myPrintable(provider)), + QASPRINTF("Loading PKCS#11 provider '%s' (%s)", myPrintable(name), myPrintable(provider)), Logger::Information); if ((rv = pkcs11h_addProvider( myPrintable(name), myPrintable(provider), - config[QString::asprintf("provider_%02d_allow_protected_authentication", i)].toBool() != false + config[QASPRINTF("provider_%02d_allow_protected_authentication", i)].toBool() != false ? TRUE : FALSE, // krazy:exclude=captruefalse - (unsigned)config[QString::asprintf("provider_%02d_private_mask", i)].toInt(), + (unsigned)config[QASPRINTF("provider_%02d_private_mask", i)].toInt(), slotevent, - (unsigned)config[QString::asprintf("provider_%02d_slotevent_timeout", i)].toInt(), - config[QString::asprintf("provider_%02d_cert_private", i)].toBool() != false + (unsigned)config[QASPRINTF("provider_%02d_slotevent_timeout", i)].toInt(), + config[QASPRINTF("provider_%02d_cert_private", i)].toBool() != false ? TRUE : FALSE // krazy:exclude=captruefalse )) != CKR_OK) { - QCA_logTextMessage(QString::asprintf("PKCS#11: Cannot log provider '%s'-'%s' %lu-'%s'.\n", + QCA_logTextMessage(QASPRINTF("PKCS#11: Cannot log provider '%s'-'%s' %lu-'%s'.\n", myPrintable(name), myPrintable(provider), rv, pkcs11h_getMessage(rv)), Logger::Error); - appendPluginDiagnosticText(QString::asprintf("Cannot load PKCS#11 provider '%s'\n", myPrintable(name))); + appendPluginDiagnosticText(QASPRINTF("Cannot load PKCS#11 provider '%s'\n", myPrintable(name))); } else { _providers += provider; } diff --git a/plugins/qca-softstore/qca-softstore.cpp b/plugins/qca-softstore/qca-softstore.cpp index 13b6df7c94a927c32dc3de3e00decaa8e52e3002..2f2d3562df70ed3c11a09f1013b30d6695ecbfba 100644 --- a/plugins/qca-softstore/qca-softstore.cpp +++ b/plugins/qca-softstore/qca-softstore.cpp @@ -22,6 +22,12 @@ #include #include +#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) +# define QASPRINTF QString::asprintf +#else +# define QASPRINTF QString().sprintf +#endif + using namespace QCA; // qPrintable is ASCII only!!! @@ -368,7 +374,7 @@ public: cleanup1:; } - QCA_logTextMessage(QString::asprintf("softstorePKeyBase::_ensureAccess - return ret=%d", ret ? 1 : 0), + QCA_logTextMessage(QASPRINTF("softstorePKeyBase::_ensureAccess - return ret=%d", ret ? 1 : 0), Logger::Debug); return ret; @@ -569,7 +575,7 @@ public: QString storeId() const override { - return QString::asprintf("%s/%s", "qca-softstore", myPrintable(_entry.name)); + return QASPRINTF("%s/%s", "qca-softstore", myPrintable(_entry.name)); } QString storeName() const override @@ -602,7 +608,7 @@ public: : KeyStoreListContext(p) { QCA_logTextMessage( - QString::asprintf("softstoreKeyStoreListContext::softstoreKeyStoreListContext - entry Provider=%p", + QASPRINTF("softstoreKeyStoreListContext::softstoreKeyStoreListContext - entry Provider=%p", (void *)p), Logger::Debug); @@ -642,14 +648,14 @@ public: void setUpdatesEnabled(bool enabled) override { QCA_logTextMessage( - QString::asprintf("softstoreKeyStoreListContext::setUpdatesEnabled - entry/return enabled=%d", + QASPRINTF("softstoreKeyStoreListContext::setUpdatesEnabled - entry/return enabled=%d", enabled ? 1 : 0), Logger::Debug); } KeyStoreEntryContext *entry(int id, const QString &entryId) override { - QCA_logTextMessage(QString::asprintf("softstoreKeyStoreListContext::entry - entry/return id=%d entryId='%s'", + QCA_logTextMessage(QASPRINTF("softstoreKeyStoreListContext::entry - entry/return id=%d entryId='%s'", id, myPrintable(entryId)), Logger::Debug); @@ -663,7 +669,7 @@ public: { KeyStoreEntryContext *entry = nullptr; - QCA_logTextMessage(QString::asprintf("softstoreKeyStoreListContext::entryPassive - entry serialized='%s'", + QCA_logTextMessage(QASPRINTF("softstoreKeyStoreListContext::entryPassive - entry serialized='%s'", myPrintable(serialized)), Logger::Debug); @@ -676,7 +682,7 @@ public: } QCA_logTextMessage( - QString::asprintf("softstoreKeyStoreListContext::entryPassive - return entry=%p", (void *)entry), + QASPRINTF("softstoreKeyStoreListContext::entryPassive - return entry=%p", (void *)entry), Logger::Debug); return entry; @@ -686,7 +692,7 @@ public: { Q_UNUSED(id); - QCA_logTextMessage(QString::asprintf("softstoreKeyStoreListContext::type - entry/return id=%d", id), + QCA_logTextMessage(QASPRINTF("softstoreKeyStoreListContext::type - entry/return id=%d", id), Logger::Debug); return KeyStore::User; @@ -696,11 +702,11 @@ public: { QString ret; - QCA_logTextMessage(QString::asprintf("softstoreKeyStoreListContext::storeId - entry id=%d", id), Logger::Debug); + QCA_logTextMessage(QASPRINTF("softstoreKeyStoreListContext::storeId - entry id=%d", id), Logger::Debug); ret = QStringLiteral("qca-softstore"); - QCA_logTextMessage(QString::asprintf("softstoreKeyStoreListContext::storeId - return ret=%s", myPrintable(ret)), + QCA_logTextMessage(QASPRINTF("softstoreKeyStoreListContext::storeId - return ret=%s", myPrintable(ret)), Logger::Debug); return ret; @@ -710,11 +716,11 @@ public: { QString ret; - QCA_logTextMessage(QString::asprintf("softstoreKeyStoreListContext::name - entry id=%d", id), Logger::Debug); + QCA_logTextMessage(QASPRINTF("softstoreKeyStoreListContext::name - entry id=%d", id), Logger::Debug); ret = QStringLiteral("User Software Store"); - QCA_logTextMessage(QString::asprintf("softstoreKeyStoreListContext::name - return ret=%s", myPrintable(ret)), + QCA_logTextMessage(QASPRINTF("softstoreKeyStoreListContext::name - return ret=%s", myPrintable(ret)), Logger::Debug); return ret; @@ -724,7 +730,7 @@ public: { Q_UNUSED(id); - QCA_logTextMessage(QString::asprintf("softstoreKeyStoreListContext::entryTypes - entry/return id=%d", id), + QCA_logTextMessage(QASPRINTF("softstoreKeyStoreListContext::entryTypes - entry/return id=%d", id), Logger::Debug); QList list; @@ -742,7 +748,7 @@ public: list += _last_id; QCA_logTextMessage( - QString::asprintf("softstoreKeyStoreListContext::keyStores - return out.size()=%d", int(list.size())), + QASPRINTF("softstoreKeyStoreListContext::keyStores - return out.size()=%d", int(list.size())), Logger::Debug); return list; @@ -752,7 +758,7 @@ public: { QList list; - QCA_logTextMessage(QString::asprintf("softstoreKeyStoreListContext::entryList - entry id=%d", id), + QCA_logTextMessage(QASPRINTF("softstoreKeyStoreListContext::entryList - entry id=%d", id), Logger::Debug); foreach (const SoftStoreEntry &e, _entries) { @@ -760,7 +766,7 @@ public: } QCA_logTextMessage( - QString::asprintf("softstoreKeyStoreListContext::entryList - return out.size()=%d", int(list.size())), + QASPRINTF("softstoreKeyStoreListContext::entryList - return out.size()=%d", int(list.size())), Logger::Debug); return list; @@ -769,7 +775,7 @@ public: void _emit_diagnosticText(const QString &t) { QCA_logTextMessage( - QString::asprintf("softstoreKeyStoreListContext::_emit_diagnosticText - entry t='%s'", myPrintable(t)), + QASPRINTF("softstoreKeyStoreListContext::_emit_diagnosticText - entry t='%s'", myPrintable(t)), Logger::Debug); QCA_logTextMessage(t, Logger::Warning); @@ -817,21 +823,21 @@ public: _entries.clear(); for (int i = 0; i < maxEntries; i++) { - if (config[QString::asprintf("entry_%02d_enabled", i)].toBool()) { + if (config[QASPRINTF("entry_%02d_enabled", i)].toBool()) { ConvertResult cresult; SoftStoreEntry entry; PublicType publicType = publicTypeInvalid; - entry.name = config[QString::asprintf("entry_%02d_name", i)].toString(); - const QString stringReferenceType = config[QString::asprintf("entry_%02d_private_type", i)].toString(); - const QString stringPublicType = config[QString::asprintf("entry_%02d_public_type", i)].toString(); - entry.noPassphrase = config[QString::asprintf("entry_%02d_no_passphrase", i)].toBool(); - entry.unlockTimeout = config[QString::asprintf("entry_%02d_unlock_timeout", i)].toInt(); + entry.name = config[QASPRINTF("entry_%02d_name", i)].toString(); + const QString stringReferenceType = config[QASPRINTF("entry_%02d_private_type", i)].toString(); + const QString stringPublicType = config[QASPRINTF("entry_%02d_public_type", i)].toString(); + entry.noPassphrase = config[QASPRINTF("entry_%02d_no_passphrase", i)].toBool(); + entry.unlockTimeout = config[QASPRINTF("entry_%02d_unlock_timeout", i)].toInt(); if (publicTypeMap.contains(stringPublicType)) { publicType = publicTypeMap[stringPublicType]; } else { - _emit_diagnosticText(QString::asprintf("Software Store: Bad public key type of '%s' entry.\n", + _emit_diagnosticText(QASPRINTF("Software Store: Bad public key type of '%s' entry.\n", myPrintable(entry.name))); goto cleanup1; } @@ -839,12 +845,12 @@ public: if (keyTypeMap.contains(stringReferenceType)) { entry.keyReferenceType = keyTypeMap[stringReferenceType]; } else { - _emit_diagnosticText(QString::asprintf("Software Store: Bad private key type of '%s' entry.\n", + _emit_diagnosticText(QASPRINTF("Software Store: Bad private key type of '%s' entry.\n", myPrintable(entry.name))); goto cleanup1; } - entry.keyReference = config[QString::asprintf("entry_%02d_private", i)].toString(); + entry.keyReference = config[QASPRINTF("entry_%02d_private", i)].toString(); switch (publicType) { case publicTypeInvalid: @@ -852,14 +858,14 @@ public: break; case publicTypeX509Chain: const QStringList base64certs = - config[QString::asprintf("entry_%02d_public", i)].toString().split(QStringLiteral("!")); + config[QASPRINTF("entry_%02d_public", i)].toString().split(QStringLiteral("!")); foreach (const QString &s, base64certs) { entry.chain += Certificate::fromDER(Base64().stringToArray(s).toByteArray(), &cresult); } if (cresult != ConvertGood) { - _emit_diagnosticText(QString::asprintf( + _emit_diagnosticText(QASPRINTF( "Software Store: Cannot load certificate of '%s' entry.\n", myPrintable(entry.name))); goto cleanup1; } @@ -882,11 +888,11 @@ private: { QString serialized; - QCA_logTextMessage(QString::asprintf("softstoreKeyStoreListContext::_serializeSoftStoreEntry - entry name=%s", + QCA_logTextMessage(QASPRINTF("softstoreKeyStoreListContext::_serializeSoftStoreEntry - entry name=%s", myPrintable(entry.name)), Logger::Debug); - serialized = QString::asprintf("qca-softstore/0/%s/%d/%s/%d/%d/x509chain/", + serialized = QASPRINTF("qca-softstore/0/%s/%d/%s/%d/%d/x509chain/", myPrintable(_escapeString(entry.name)), entry.keyReferenceType, myPrintable(_escapeString(entry.keyReference)), @@ -901,7 +907,7 @@ private: serialized.append(list.join(QStringLiteral("/"))); QCA_logTextMessage( - QString::asprintf("softstoreKeyStoreListContext::_serializeSoftStoreEntry - return serialized='%s'", + QASPRINTF("softstoreKeyStoreListContext::_serializeSoftStoreEntry - return serialized='%s'", myPrintable(serialized)), Logger::Debug); @@ -913,7 +919,7 @@ private: bool ret = false; QCA_logTextMessage( - QString::asprintf("softstoreKeyStoreListContext::_deserializeSoftStoreEntry - entry from='%s'", + QASPRINTF("softstoreKeyStoreListContext::_deserializeSoftStoreEntry - entry from='%s'", myPrintable(serialized)), Logger::Debug); @@ -954,7 +960,7 @@ private: cleanup: QCA_logTextMessage( - QString::asprintf( + QASPRINTF( "softstoreKeyStoreListContext::_deserializeSoftStoreEntry - return ret=%d chain.size()=%d", ret ? 1 : 0, int(entry.chain.size())), @@ -968,7 +974,7 @@ private: softstoreKeyStoreEntryContext *entry = nullptr; QCA_logTextMessage( - QString::asprintf("softstoreKeyStoreListContext::_keyStoreEntryBySoftStoreEntry - entry name=%s", + QASPRINTF("softstoreKeyStoreListContext::_keyStoreEntryBySoftStoreEntry - entry name=%s", myPrintable(sentry.name)), Logger::Debug); @@ -986,7 +992,7 @@ private: entry = new softstoreKeyStoreEntryContext(key, sentry, serialized, provider()); QCA_logTextMessage( - QString::asprintf("softstoreKeyStoreListContext::_keyStoreEntryBySoftStoreEntry - return entry=%p", + QASPRINTF("softstoreKeyStoreListContext::_keyStoreEntryBySoftStoreEntry - return entry=%p", (void *)entry), Logger::Debug); @@ -999,7 +1005,7 @@ private: foreach (const QChar &c, from) { if (c == QLatin1Char('/') || c == QLatin1Char('\\')) { - to += QString::asprintf("\\x%04x", c.unicode()); + to += QASPRINTF("\\x%04x", c.unicode()); } else { to += c; } @@ -1080,7 +1086,7 @@ public: { Provider::Context *context = nullptr; - QCA_logTextMessage(QString::asprintf("softstoreProvider::createContext - entry type='%s'", myPrintable(type)), + QCA_logTextMessage(QASPRINTF("softstoreProvider::createContext - entry type='%s'", myPrintable(type)), Logger::Debug); if (type == QLatin1String("keystorelist")) { @@ -1091,7 +1097,7 @@ public: context = s_keyStoreList; } - QCA_logTextMessage(QString::asprintf("softstoreProvider::createContext - return context=%p", (void *)context), + QCA_logTextMessage(QASPRINTF("softstoreProvider::createContext - return context=%p", (void *)context), Logger::Debug); return context; @@ -1105,14 +1111,14 @@ public: mytemplate[QStringLiteral("formtype")] = QStringLiteral("http://affinix.com/qca/forms/qca-softstore#1.0"); for (int i = 0; i < _CONFIG_MAX_ENTRIES; i++) { - mytemplate[QString::asprintf("entry_%02d_enabled", i)] = false; - mytemplate[QString::asprintf("entry_%02d_name", i)] = QLatin1String(""); - mytemplate[QString::asprintf("entry_%02d_public_type", i)] = QLatin1String(""); - mytemplate[QString::asprintf("entry_%02d_private_type", i)] = QLatin1String(""); - mytemplate[QString::asprintf("entry_%02d_public", i)] = QLatin1String(""); - mytemplate[QString::asprintf("entry_%02d_private", i)] = QLatin1String(""); - mytemplate[QString::asprintf("entry_%02d_unlock_timeout", i)] = -1; - mytemplate[QString::asprintf("entry_%02d_no_passphrase", i)] = false; + mytemplate[QASPRINTF("entry_%02d_enabled", i)] = false; + mytemplate[QASPRINTF("entry_%02d_name", i)] = QLatin1String(""); + mytemplate[QASPRINTF("entry_%02d_public_type", i)] = QLatin1String(""); + mytemplate[QASPRINTF("entry_%02d_private_type", i)] = QLatin1String(""); + mytemplate[QASPRINTF("entry_%02d_public", i)] = QLatin1String(""); + mytemplate[QASPRINTF("entry_%02d_private", i)] = QLatin1String(""); + mytemplate[QASPRINTF("entry_%02d_unlock_timeout", i)] = -1; + mytemplate[QASPRINTF("entry_%02d_no_passphrase", i)] = false; } return mytemplate; diff --git a/examples/keyloader/keyloader.cpp b/examples/keyloader/keyloader.cpp index 335678f02db9fefb4065e82326da2f5c6838e4c4..8d5a31e38781ad3b14933a25400f6d184d513ffc 100644 --- a/examples/keyloader/keyloader.cpp +++ b/examples/keyloader/keyloader.cpp @@ -108,7 +108,11 @@ int main(int argc, char **argv) App app; app.str = QFile::decodeName(argv[1]); QObject::connect(&app, &App::quit, &qapp, QCoreApplication::quit); +#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) QTimer::singleShot(0, &app, &App::start); +#else + QTimer::singleShot(0, &app, SLOT(start())); +#endif qapp.exec(); return 0; } diff --git a/examples/saslclient/saslclient.cpp b/examples/saslclient/saslclient.cpp index 99db413c63bdbecc185e468e6357458a614c4eed..03fccee48918aca64842d122f92449ca161e87d8 100644 --- a/examples/saslclient/saslclient.cpp +++ b/examples/saslclient/saslclient.cpp @@ -152,8 +152,10 @@ public: connect(sock, &QTcpSocket::readyRead, this, &ClientTest::sock_readyRead); #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) connect(sock, &QTcpSocket::errorOccurred, this, &ClientTest::sock_error); -#else +#elif QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) connect(sock, QOverload::of(&QTcpSocket::error), this, &ClientTest::sock_error); +#else + connect(sock, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(sock_error(QAbstractSocket::SocketError))); #endif sasl = new QCA::SASL(this); @@ -552,7 +554,11 @@ int main(int argc, char **argv) ClientTest client(host, port, proto, authzid, realm, user, pass, no_authzid, no_realm); QObject::connect(&client, &ClientTest::quit, &qapp, &QCoreApplication::quit); +#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) QTimer::singleShot(0, &client, &ClientTest::start); +#else + QTimer::singleShot(0, &client, SLOT(start())); +#endif qapp.exec(); return 0; diff --git a/examples/saslserver/saslserver.cpp b/examples/saslserver/saslserver.cpp index 0983dc7e82e8b48769a68a9ff9db3c3721dbd26a..9c235bc43a5f95fd12d54ebc22e02865efd51ba6 100644 --- a/examples/saslserver/saslserver.cpp +++ b/examples/saslserver/saslserver.cpp @@ -183,11 +183,13 @@ public: connect(sock, &QTcpSocket::readyRead, this, &ServerTestHandler::sock_readyRead); #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) connect(sock, &QTcpSocket::errorOccurred, this, &ServerTestHandler::sock_error); -#else +#elif QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) connect(sock, QOverload::of(&QTcpSocket::error), this, &ServerTestHandler::sock_error); +#else + connect(sock, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(sock_error(QAbstractSocket::SocketError))); #endif connect(sock, &QTcpSocket::bytesWritten, this, &ServerTestHandler::sock_bytesWritten); @@ -515,7 +517,11 @@ int main(int argc, char **argv) ServerTest server(host, port, proto, realm, str); QObject::connect(&server, &ServerTest::quit, &qapp, &QCoreApplication::quit); +#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) QTimer::singleShot(0, &server, &ServerTest::start); +#else + QTimer::singleShot(0, &server, SLOT(start())); +#endif qapp.exec(); return 0; diff --git a/examples/sslservtest/sslservtest.cpp b/examples/sslservtest/sslservtest.cpp index 4e4cfd4d3b4bd7c877c442cb5a3f0f759c194823..690c5d981f01bfa468ea23650bdeb46f23b84b1f 100644 --- a/examples/sslservtest/sslservtest.cpp +++ b/examples/sslservtest/sslservtest.cpp @@ -33,6 +33,14 @@ #include "import_plugins.h" #endif +#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) +# define SSQUIT &SecureServer::quit +# define QAQUIT &QCoreApplication::quit +#else +# define SSQUIT SLOT(quit()) +# define QAQUIT SLOT(quit()) +#endif + char pemdata_cert[] = "-----BEGIN CERTIFICATE-----\n" "MIICeTCCAeKgAwIBAgIRAKKKnOj6Aarmwf0phApitVAwDQYJKoZIhvcNAQEFBQAw\n" @@ -111,17 +119,17 @@ public: { if (cert.isNull()) { qDebug() << "Error loading cert!"; - QTimer::singleShot(0, this, &SecureServer::quit); + QTimer::singleShot(0, this, SSQUIT); return; } if (privkey.isNull()) { qDebug() << "Error loading private key!"; - QTimer::singleShot(0, this, &SecureServer::quit); + QTimer::singleShot(0, this, SSQUIT); return; } if (false == server->listen(QHostAddress::Any, port)) { qDebug() << "Error binding to port " << port; - QTimer::singleShot(0, this, &SecureServer::quit); + QTimer::singleShot(0, this, SSQUIT); return; } qDebug() << "Listening on port" << port; @@ -162,8 +170,10 @@ private Q_SLOTS: connect(sock, &QTcpSocket::disconnected, this, &SecureServer::sock_disconnected); #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) connect(sock, &QTcpSocket::errorOccurred, this, &SecureServer::sock_error); -#else +#elif QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) connect(sock, QOverload::of(&QTcpSocket::error), this, &SecureServer::sock_error); +#else + connect(sock, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(sock_error(QAbstractSocket::SocketError))); #endif connect(sock, &QTcpSocket::bytesWritten, this, &SecureServer::sock_bytesWritten); @@ -273,7 +283,7 @@ int main(int argc, char **argv) } SecureServer *server = new SecureServer(port); - QObject::connect(server, &SecureServer::quit, &app, &QCoreApplication::quit); + QObject::connect(server, SSQUIT, &app, QAQUIT); server->start(); app.exec(); delete server; diff --git a/examples/ssltest/ssltest.cpp b/examples/ssltest/ssltest.cpp index 471bd119e1fcd14aff8a1dc20a0d49ee54df770f..166faf6bbe52a515187f9f3cbc676763e9b28588 100644 --- a/examples/ssltest/ssltest.cpp +++ b/examples/ssltest/ssltest.cpp @@ -114,8 +114,10 @@ public: connect(sock, &QTcpSocket::readyRead, this, &SecureTest::sock_readyRead); #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) connect(sock, &QTcpSocket::errorOccurred, this, &SecureTest::sock_error); -#else +#elif QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) connect(sock, QOverload::of(&QTcpSocket::error), this, &SecureTest::sock_error); +#else + connect(sock, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(sock_error(QAbstractSocket::SocketError))); #endif ssl = new QCA::TLS; diff --git a/examples/tlssocket/tlssocket.cpp b/examples/tlssocket/tlssocket.cpp index 9264d8939b00ab82765dae4015108c3ee2f3ee94..e711ba4c34097cce5aab57f4134b759657ebff73 100644 --- a/examples/tlssocket/tlssocket.cpp +++ b/examples/tlssocket/tlssocket.cpp @@ -50,11 +50,13 @@ public: connect(sock, &QTcpSocket::bytesWritten, this, &TLSSocket::Private::sock_bytesWritten); #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) connect(sock, &QTcpSocket::errorOccurred, this, &TLSSocket::Private::sock_error); -#else +#elif QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) connect(sock, QOverload::of(&QTcpSocket::error), this, &TLSSocket::Private::sock_error); +#else + connect(sock, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(sock_error(QAbstractSocket::SocketError))); #endif tls = new QCA::TLS(this);