diff --git a/TODO b/TODO index 329afbd0..d5106a90 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,6 @@ * Additional unit tests * Update to latest Botan, and remake the botantools patch as appropriate +* create .prf for auto-discovery by qmake-based projects * API documentation clean up Algorithm @@ -18,16 +19,6 @@ add more "getters" to the library? give all classes non-default ctors/dtors/copy/op=, and dpointers? -* finish API: - finish qcaprovider.h - -* build system: - get qt 4 support into qconf - on non-win/mac, allow specifying of flatfile store, else install/use built-in - certstore.qcm: QCA_NO_SYSTEMSTORE - make sure it installs properly - create qt4 qmake .prf for auto-discovery by applications - * finish code for APIs: core: properties cert: rfc 2818 hostname validation diff --git a/certstore.qcm b/certstore.qcm index de22d9f2..ea6ad831 100644 --- a/certstore.qcm +++ b/certstore.qcm @@ -1,9 +1,7 @@ -#include -#include /* -----BEGIN QCMOD----- name: certstore -arg: certstore-path=[path],Path to the SSL Certificate store +arg: certstore-path=[path],Path to the SSL/X509 Certificate store -----END QCMOD----- */ @@ -16,9 +14,21 @@ public: bool exec() { + bundled = false; + +#if defined(Q_OS_WIN) || defined(Q_OS_MAC) + // use built-in + return true; +#else QStringList pathsToTry; - pathsToTry.append(conf->getenv("QC_CERTSTORE_PATH")); + path = conf->getenv("QC_CERTSTORE_PATH"); + if(!path.isEmpty()) + { + if(QFile::exists(path)) + return true; + return false; + } // This is from Debian pathsToTry.append( QString("/etc/ssl/certs/ca-certificates.crt") ); @@ -27,27 +37,54 @@ public: pathsToTry.append( QString("/usr/share/ssl/cert.pem") ); pathsToTry.append( QString("/usr/share/ssl/certs/ca-bundle.crt") ); - for ( QStringList::Iterator path = pathsToTry.begin(); path != pathsToTry.end(); ++path ) { - if ( QFile::exists( *path ) ) { - m_firstGoodPath = *path; + for(int n = 0; n < pathsToTry.count(); ++n) + { + if(QFile::exists(pathsToTry[n])) + { + path = pathsToTry[n]; break; } } - QString certPathString = "QCA_SYSTEMSTORE_PATH='\"" + m_firstGoodPath + "\"'"; + // fall back to bundled + if(path.isEmpty()) + { + path = "$$DATADIR/qca/certs/rootcerts.pem"; + QString extra = + "sharedfiles.path = $$DATADIR/qca\n" + "sharedfiles.files = certs\n" + "INSTALLS += sharedfiles\n"; + conf->addExtra(extra); + bundled = true; + } + + QString certPathString = "QCA_SYSTEMSTORE_PATH='\"" + path + "\"'"; conf->addDefine(certPathString); - if ( m_firstGoodPath.isEmpty() ) - return false; - else - return true; + return true; +#endif } QString resultString() const { - return m_firstGoodPath; +#if defined(Q_OS_WIN) + return "using Windows built-in" +#elif defined(Q_OS_MAC) + return "using Mac built-in" +#else + if(success) + { + if(bundled) + return "using bundled"; + else + return path; + } + else + return ConfObj::resultString(); +#endif } private: - QString m_firstGoodPath; + QString path; + bool bundled; }; diff --git a/extra.qcm b/extra.qcm new file mode 100644 index 00000000..c24ec08e --- /dev/null +++ b/extra.qcm @@ -0,0 +1,40 @@ +/* +-----BEGIN QCMOD----- +name: extra +-----END QCMOD----- +*/ + +class qc_extra : public ConfObj +{ +public: + qc_extra(Conf *c) : ConfObj(c) {} + QString name() const { return "extra"; } + QString shortname() const { return "extra"; } + + // no output + QString checkString() const { return QString(); } + + bool exec() + { + QString prefix = conf->getenv("PREFIX"); + QString str = QString( + "prefix=%1\n" + "exec_prefix=${prefix}\n" + "libdir=${prefix}/lib\n" + "includedir=${prefix}/include/QtCrypto\n" + "\n" + "Name: QCA\n" + "Description: Qt Cryptographic Architecture library\n" + "Version: 2.0.0 #maybe this shouldn't be literal...\n" + "Requires: qt-mt\n" + "Libs: -L${libdir} -lqca\n" + "Cflags: -I${includedir}\n" + "\n" + ).arg(prefix); + + QFile f("qca.pc"); + if(f.open(QFile::WriteOnly | QFile::Truncate)) + f.write(str.toLatin1()); + return true; + } +}; diff --git a/plugins/qca-gcrypt/libgcrypt.qcm b/plugins/qca-gcrypt/libgcrypt.qcm index c0ff3597..2c2027f0 100644 --- a/plugins/qca-gcrypt/libgcrypt.qcm +++ b/plugins/qca-gcrypt/libgcrypt.qcm @@ -16,50 +16,21 @@ public: bool exec() { - proc = new QProcess( 0 ); QString path = conf->getenv("QC_GCRYPT_CONFIG"); - proc->addArgument( path + "libgcrypt-config" ); - proc->addArgument( "--libs" ); + if(path.isEmpty()) + path = "libgcrypt-config"; - if(! proc->start() ) - // this often indicates that it wasn't found in the path. + QStringList incs; + QString ver, libs, other; + if(!conf->findFooConfig(path, &ver, &incs, &libs, &other)) return false; - do { - usleep(100000); - } while (proc->isRunning()); - - QString libs = proc->readStdout(); - if (!libs.isEmpty()) + for(int n = 0; n < incs.count(); ++n) + conf->addIncludePath(incs[n]); + if(!libs.isEmpty()) conf->addLib(libs); - - proc->clearArguments(); - proc->addArgument( path + "libgcrypt-config" ); - proc->addArgument( "--cflags" ); - - if(! proc->start() ) - return false; - - do { - usleep(100000); - } while (proc->isRunning()); - - QString cflags = proc->readStdout(); - if (!cflags.isEmpty()) { - QStringList cflagsList = QStringList::split(" ", cflags); - for ( QStringList::Iterator it = cflagsList.begin(); it != cflagsList.end(); ++it ) { - if ( (*it).startsWith("-I") ){ - // we want everything except the leading "-I" - QString includePath = (*it).remove(0,2); - conf->addIncludePath(includePath); - } else { - // we want whatever is left. - conf->addExtra(QString("QMAKE_CFLAGS += ") + (*it) ); - } - } - } + if(!other.isEmpty()) + conf->addExtra(QString("QMAKE_CFLAGS += %1\n").arg(other)); return true; } -private: - QProcess* proc; }; diff --git a/plugins/qca-gcrypt/qca-gcrypt.pro b/plugins/qca-gcrypt/qca-gcrypt.pro index edeb3824..959c720f 100644 --- a/plugins/qca-gcrypt/qca-gcrypt.pro +++ b/plugins/qca-gcrypt/qca-gcrypt.pro @@ -9,8 +9,9 @@ DEFINES += QCA_PLUGIN INCLUDEPATH += ../../include/QtCrypto SOURCES = qca-gcrypt.cpp -# temp hack until the build system works again -LIBS += -lgcrypt -lgpg-error +include(conf.pri) + +# install +target.path += $$[QT_INSTALL_PLUGINS]/crypto +INSTALLS += target -#include(conf.pri) -#include(extra.pri) diff --git a/plugins/qca-gcrypt/qcextra b/plugins/qca-gcrypt/qcextra deleted file mode 100755 index fef4f18b..00000000 --- a/plugins/qca-gcrypt/qcextra +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -cat >extra.pri < Qt Cryptographic Architecture (QCA) qca.pro - + + + . + + + + diff --git a/qcextra b/qcextra deleted file mode 100755 index 712d4ef8..00000000 --- a/qcextra +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh - -cat >extra.pri <qca.pc <