From a7c9d4c44216478ae7542d99feda16381ceb994c Mon Sep 17 00:00:00 2001 From: Konrad Rosenbaum Date: Sun, 21 Jul 2013 22:27:12 +0200 Subject: [PATCH] include GPG (not functional, just linking) --- aurora/aurora.pro | 8 +++-- aurora/build-gpg.sh | 11 +++++--- aurora/gpg.conf | 25 +++++++++++++++++ aurora/src/aurora.cpp | 70 ++++++++++++++++++++++++++++++++++++++++------- aurora/src/aurora.h | 10 +++++++ aurora/src/gpgwrap.cpp | 43 +++++++++++++++++++++++++++++ aurora/src/gpgwrap.h | 30 ++++++++++++++++++++ aurora/src/subtask.cpp | 2 +- aurora/src/subtask.h | 2 +- 9 files changed, 181 insertions(+), 20 deletions(-) create mode 100644 aurora/gpg.conf create mode 100644 aurora/src/gpgwrap.cpp create mode 100644 aurora/src/gpgwrap.h diff --git a/aurora/aurora.pro b/aurora/aurora.pro index d9de6bb..ba42436 100644 --- a/aurora/aurora.pro +++ b/aurora/aurora.pro @@ -13,13 +13,15 @@ VERSION = 0.2.0 SOURCES += \ src/aurora.cpp \ - src/subtask.cpp + src/subtask.cpp \ + src/gpgwrap.cpp HEADERS += \ src/aurora.h \ - src/subtask.h + src/subtask.h \ + src/gpgwrap.h -INCLUDEPATH += src +INCLUDEPATH += src gpg/include DEPENDPATH += $$INCLUDEPATH DEFINES += AURORA_LIBRARY_BUILD=1 diff --git a/aurora/build-gpg.sh b/aurora/build-gpg.sh index 5d939ee..e279f79 100755 --- a/aurora/build-gpg.sh +++ b/aurora/build-gpg.sh @@ -5,6 +5,9 @@ fmake(){ echo -e 'all:\n\techo ok\n\ninstall:\n\techo ok\n\n' >./$1/Makefile } +echo Cleaning up old binaries +rm -rf gpg + cd gnupg echo Building GnuPG git clean -dfx @@ -15,14 +18,14 @@ make make install cd .. -strip gpg/bin/gpg gpg/bin/gpg.exe || true +strip gpg/bin/* || true cd libgpg-error echo echo Building libgpg-error git clean -dfx ./autogen.sh -./configure --enable-static --disable-shared --disable-nls --disable-rpath --disable-languages --without-libiconv-prefix --without-libintl-prefix --prefix=`pwd`/../gpg +./configure --disable-static --enable-shared --disable-nls --disable-rpath --disable-languages --without-libiconv-prefix --without-libintl-prefix --prefix=`pwd`/../gpg fmake doc echo >po/LINGUAS make @@ -33,7 +36,7 @@ echo echo Building libassuan git clean -dfx ./autogen.sh -./configure --enable-static --disable-shared --with-libgpg-error-prefix=`pwd`/../gpg --prefix=`pwd`/../gpg +./configure --disable-static --enable-shared --with-libgpg-error-prefix=`pwd`/../gpg --prefix=`pwd`/../gpg fmake doc make make install @@ -43,7 +46,7 @@ echo echo Building GPGME git clean -dfx ./autogen.sh -./configure --enable-static --disable-shared --disable-glibtest --disable-gpgsm-test --disable-gpgconf-test --disable-g13-test --with-gpg=`pwd`/../gpg/bin/gpg --prefix=`pwd`/../gpg --with-libassuan-prefix=`pwd`/../gpg --with-libgpg-error-prefix=`pwd`/../gpg +./configure --disable-static --enable-shared --disable-glibtest --disable-gpgsm-test --disable-gpgconf-test --disable-g13-test --with-gpg=`pwd`/../gpg/bin/gpg --prefix=`pwd`/../gpg --with-libassuan-prefix=`pwd`/../gpg --with-libgpg-error-prefix=`pwd`/../gpg fmake doc fmake tests make diff --git a/aurora/gpg.conf b/aurora/gpg.conf new file mode 100644 index 0000000..ebea7cb --- /dev/null +++ b/aurora/gpg.conf @@ -0,0 +1,25 @@ +# Uncomment the following option to get rid of the copyright notice + +no-greeting + +# Because some mailers change lines starting with "From " to ">From " +# it is good to handle such lines in a special way when creating +# cleartext signatures; all other PGP versions do it this way too. + +#no-escape-from-lines + +# If you do not use the Latin-1 (ISO-8859-1) charset, you should tell +# GnuPG which is the native character set. Please check the man page +# for supported character sets. This character set is only used for +# metadata and not for the actual message which does not undergo any +# translation. Note that future version of GnuPG will change to UTF-8 +# as default character set. In most cases this option is not required +# as GnuPG is able to figure out the correct charset at runtime. + +charset utf-8 + +# Lock the file only once for the lifetime of a process. If you do +# not define this, the lock will be obtained and released every time +# it is needed, which is usually preferable. + +#lock-once diff --git a/aurora/src/aurora.cpp b/aurora/src/aurora.cpp index 4c964a0..248b4e7 100644 --- a/aurora/src/aurora.cpp +++ b/aurora/src/aurora.cpp @@ -5,8 +5,11 @@ #include "aurora.h" #include "subtask.h" +#include "gpgwrap.h" +#include #include +#include #include #include #include @@ -25,6 +28,10 @@ struct AuroraUpdater::AuroraPrivate QPointertask; bool isBlocking()const{return state!=Aurora::Initializing && state!=Aurora::Polling;} + +private: + void initFromSettings(); + void initFromXml(); }; @@ -43,24 +50,60 @@ Aurora::~Aurora() static const QString AuroraGroup("aurora_updater"); +static const QString AuroraBaseUrlAttr("baseurl"); +static const QString AuroraIndexFileAttr("indexfile"); +static const QString AuroraPollIntervalAttr("pollinterval"); +static const QString AuroraBaseUrlKey(AuroraGroup+"/"+AuroraBaseUrlAttr); +static const QString AuroraIndexFileKey(AuroraGroup+"/"+AuroraIndexFileAttr); +static const QString AuroraPollIntervalKey(AuroraGroup+"/"+AuroraPollIntervalAttr); AuroraPrivate::AuroraPrivate() { - QSettings cfg; - cfg.beginGroup(AuroraGroup); - url=cfg.value("baseurl").toUrl(); - indexfile=cfg.value("indexfile","auroraindex.xml").toString(); - pollint=cfg.value("pollinterval",0).toInt(); + //try to initialize from program settings + initFromSettings(); + //try to initialize from XML file + if(!url.isValid() || indexfile.isEmpty() || pollint<0){ + initFromXml(); + } qDebug()<<"Aurora: Initializing Auto-Updater. URL:"<applicationFilePath()+".aurora"); + if(!fd.exists())return; + if(!fd.open(QIODevice::ReadOnly))return; + if(!doc.setContent(&fd))return; + fd.close(); + qDebug()<<"Aurora: Initializing from"<indexfile; +} + void Aurora::setBaseUrl(QUrl u,QString idx) { d->url=u; d->indexfile=idx; - QSettings c;c.beginGroup(AuroraGroup); - c.setValue("baseurl",u); - c.setValue("indexfile",idx); + QSettings c; + c.setValue(AuroraBaseUrlKey,u); + c.setValue(AuroraIndexFileKey,idx); qDebug()<<"Aurora: Changing URL to"<=0){ d->pollint=intervalInSeconds; - QSettings cfg; - cfg.beginGroup(AuroraGroup); - cfg.setValue("pollintervall",d->pollint); + QSettings().setValue(AuroraPollIntervalKey,d->pollint); } if(d->polltmr){ delete d->polltmr; @@ -106,6 +149,10 @@ void Aurora::startPoll(int intervalInSeconds) qDebug()<<"Aurora: no valid URL and/or index file, cannot poll."; return; } + if(!GpgWrapper::instance()->foundGPG()){ + qDebug()<<"Aurora: there is no GPG, cannot verify so there is no point in polling."; + return; + } if(d->pollint>0){ d->polltmr=new QTimer(this); connect(d->polltmr,SIGNAL(timeout()), this,SLOT(pollnow())); @@ -156,6 +203,7 @@ void Aurora::checkMetaFile() return; } //TODO: verify signature + //extract info qDebug()<<"Aurora: got Meta Data, not doing anything about it yet"; d->task->deleteLater(); diff --git a/aurora/src/aurora.h b/aurora/src/aurora.h index 2ae0373..8e450c2 100644 --- a/aurora/src/aurora.h +++ b/aurora/src/aurora.h @@ -66,11 +66,18 @@ class AURORA_EXPORT Aurora:public QObject bool isReadyForDownload()const; bool isReadyForInstall()const; + ///returns the interval in seconds between update polls int pollInterVall()const; public slots: + ///sets the base URL at which new updates are requested + ///\param baseurl the base URL at which updates are found (the directory) + ///\param indexfile the index XML file that contains information about current versions void setBaseUrl(QUrl baseurl,QString indexfile); + ///starts polling for updates + ///\param intervalInSeconds if given: implicitly changes the poll interval void startPoll(int intervalInSeconds=-1); + ///changes the polling interval void setPollIntervall(int seconds); void startDownload(); void startInstallation(); @@ -84,8 +91,11 @@ class AURORA_EXPORT Aurora:public QObject void installationFailed(); private slots: + ///\internal starts an update check cycle void pollnow(); + ///\internal aborts the running update cycle void abortCycle(); + ///\internal when the intial index file was downloaded: check its signature void checkMetaFile(); private: AuroraPrivate *d; diff --git a/aurora/src/gpgwrap.cpp b/aurora/src/gpgwrap.cpp new file mode 100644 index 0000000..acc9f87 --- /dev/null +++ b/aurora/src/gpgwrap.cpp @@ -0,0 +1,43 @@ +// Copyright (C) 2013 by Konrad Rosenbaum +// protected under the GNU LGPL version 3 or at your option any newer. +// See COPYING.LGPL file that comes with this distribution. +// + +#include "gpgwrap.h" + +#include + +#include +#include +#include + +using namespace AuroraUpdater; + +GpgWrapper::GpgWrapper() +{ + //find executable + const QString exe = qApp->applicationDirPath()+ +#ifdef Q_OS_WIN + "/gpg.exe" +#else + "/gpg" +#endif + ; + if(QFile::exists(exe)){ + qDebug()<<"Aurora: found GPG in"< +// protected under the GNU LGPL version 3 or at your option any newer. +// See COPYING.LGPL file that comes with this distribution. +// + +#ifndef AURORA_GPGWRAP_H +#define AURORA_GPGWRAP_H + +#include + +namespace AuroraUpdater { + + +class GpgWrapper:public QObject +{ + public: + static GpgWrapper* instance(); + + bool foundGPG()const{return !mExe.isEmpty();} + + private: + GpgWrapper(); + QString mExe; +}; + +//end of namespace +} + + +#endif diff --git a/aurora/src/subtask.cpp b/aurora/src/subtask.cpp index 77e596a..c0976d7 100644 --- a/aurora/src/subtask.cpp +++ b/aurora/src/subtask.cpp @@ -46,7 +46,7 @@ void AuroraUpdater::SubTask::finishedReq() { // qDebug()<<"SubTask::finishedReq"< +// Copyright (C) 2013 by Konrad Rosenbaum // protected under the GNU LGPL version 3 or at your option any newer. // See COPYING.LGPL file that comes with this distribution. // -- 1.7.2.5