Page Menu
Home
GnuPG
Search
Configure Global Search
Log In
Files
F20320560
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Size
93 KB
Subscribers
None
View Options
diff --git a/lang/qt/src/qgpgmeadduseridjob.cpp b/lang/qt/src/qgpgmeadduseridjob.cpp
index 19127a82..03e8f20f 100644
--- a/lang/qt/src/qgpgmeadduseridjob.cpp
+++ b/lang/qt/src/qgpgmeadduseridjob.cpp
@@ -1,82 +1,83 @@
/*
qgpgmeadduseridjob.cpp
This file is part of qgpgme, the Qt API binding for gpgme
Copyright (c) 2008 Klarälvdalens Datakonsult AB
Copyright (c) 2016 Intevation GmbH
Libkleopatra is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
Libkleopatra is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
In addition, as a special exception, the copyright holders give
permission to link the code of this program with any edition of
the Qt library by Trolltech AS, Norway (or with modified versions
of Qt that use the same license as Qt), and distribute linked
combinations including the two. You must obey the GNU General
Public License in all respects for all of the code used other than
Qt. If you modify this file, you may extend this exception to
your version of the file, but you are not obligated to do so. If
you do not wish to do so, delete this exception statement from
your version.
*/
#include "qgpgmeadduseridjob.h"
#include "dataprovider.h"
#include "context.h"
#include "data.h"
#include "gpgadduserideditinteractor.h"
#include "key.h"
#include <cassert>
#include <memory>
using namespace QGpgME;
using namespace GpgME;
using namespace boost;
QGpgMEAddUserIDJob::QGpgMEAddUserIDJob(Context *context)
: mixin_type(context)
{
lateInitialization();
}
QGpgMEAddUserIDJob::~QGpgMEAddUserIDJob() {}
static QGpgMEAddUserIDJob::result_type add_user_id(Context *ctx, const Key &key, const QString &name, const QString &email, const QString &comment)
{
std::auto_ptr<GpgAddUserIDEditInteractor> gau(new GpgAddUserIDEditInteractor);
gau->setNameUtf8(name.toUtf8().constData());
gau->setEmailUtf8(email.toUtf8().constData());
gau->setCommentUtf8(comment.toUtf8().constData());
std::auto_ptr<EditInteractor> ei(gau);
QGpgME::QByteArrayDataProvider dp;
Data data(&dp);
assert(!data.isNull());
const Error err = ctx->edit(key, ei, data);
Error ae;
const QString log = _detail::audit_log_as_html(ctx, ae);
return make_tuple(err, log, ae);
}
Error QGpgMEAddUserIDJob::start(const Key &key, const QString &name, const QString &email, const QString &comment)
{
run(bind(&add_user_id, _1, key, name, email, comment));
return Error();
}
+#include "qgpgmeadduseridjob.moc"
diff --git a/lang/qt/src/qgpgmechangeexpiryjob.cpp b/lang/qt/src/qgpgmechangeexpiryjob.cpp
index ac06d8d7..41fe8c34 100644
--- a/lang/qt/src/qgpgmechangeexpiryjob.cpp
+++ b/lang/qt/src/qgpgmechangeexpiryjob.cpp
@@ -1,81 +1,82 @@
/*
qgpgmechangeexpiryjob.cpp
This file is part of qgpgme, the Qt API binding for gpgme
Copyright (c) 2008 Klarälvdalens Datakonsult AB
Copyright (c) 2016 Intevation GmbH
Libkleopatra is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
Libkleopatra is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
In addition, as a special exception, the copyright holders give
permission to link the code of this program with any edition of
the Qt library by Trolltech AS, Norway (or with modified versions
of Qt that use the same license as Qt), and distribute linked
combinations including the two. You must obey the GNU General
Public License in all respects for all of the code used other than
Qt. If you modify this file, you may extend this exception to
your version of the file, but you are not obligated to do so. If
you do not wish to do so, delete this exception statement from
your version.
*/
#include "qgpgmechangeexpiryjob.h"
#include "dataprovider.h"
#include "context.h"
#include "data.h"
#include "gpgsetexpirytimeeditinteractor.h"
#include "key.h"
#include <QDateTime>
#include <cassert>
#include <memory>
#include <string>
using namespace QGpgME;
using namespace GpgME;
using namespace boost;
QGpgMEChangeExpiryJob::QGpgMEChangeExpiryJob(Context *context)
: mixin_type(context)
{
lateInitialization();
}
QGpgMEChangeExpiryJob::~QGpgMEChangeExpiryJob() {}
static QGpgMEChangeExpiryJob::result_type change_expiry(Context *ctx, const Key &key, const QDateTime &expiry)
{
std::auto_ptr<EditInteractor>
ei(expiry.isValid()
? new GpgSetExpiryTimeEditInteractor(expiry.date().toString(Qt::ISODate).toStdString())
: new GpgSetExpiryTimeEditInteractor());
QGpgME::QByteArrayDataProvider dp;
Data data(&dp);
assert(!data.isNull());
const Error err = ctx->edit(key, ei, data);
Error ae;
const QString log = _detail::audit_log_as_html(ctx, ae);
return make_tuple(err, log, ae);
}
Error QGpgMEChangeExpiryJob::start(const Key &key, const QDateTime &expiry)
{
run(bind(&change_expiry, _1, key, expiry));
return Error();
}
+#include "qgpgmechangeexpiryjob.moc"
diff --git a/lang/qt/src/qgpgmechangeownertrustjob.cpp b/lang/qt/src/qgpgmechangeownertrustjob.cpp
index 3e4144d8..09b95394 100644
--- a/lang/qt/src/qgpgmechangeownertrustjob.cpp
+++ b/lang/qt/src/qgpgmechangeownertrustjob.cpp
@@ -1,77 +1,78 @@
/*
qgpgmechangeownertrustjob.cpp
This file is part of qgpgme, the Qt API binding for gpgme
Copyright (c) 2008 Klarälvdalens Datakonsult AB
Copyright (c) 2016 Intevation GmbH
Libkleopatra is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
Libkleopatra is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
In addition, as a special exception, the copyright holders give
permission to link the code of this program with any edition of
the Qt library by Trolltech AS, Norway (or with modified versions
of Qt that use the same license as Qt), and distribute linked
combinations including the two. You must obey the GNU General
Public License in all respects for all of the code used other than
Qt. If you modify this file, you may extend this exception to
your version of the file, but you are not obligated to do so. If
you do not wish to do so, delete this exception statement from
your version.
*/
#include "qgpgmechangeownertrustjob.h"
#include "dataprovider.h"
#include "context.h"
#include "data.h"
#include "gpgsetownertrusteditinteractor.h"
#include "key.h"
#include <cassert>
#include <memory>
using namespace QGpgME;
using namespace GpgME;
using namespace boost;
QGpgMEChangeOwnerTrustJob::QGpgMEChangeOwnerTrustJob(Context *context)
: mixin_type(context)
{
lateInitialization();
}
QGpgMEChangeOwnerTrustJob::~QGpgMEChangeOwnerTrustJob() {}
static QGpgMEChangeOwnerTrustJob::result_type change_ownertrust(Context *ctx, const Key &key, Key::OwnerTrust trust)
{
std::auto_ptr<EditInteractor>
ei(new GpgSetOwnerTrustEditInteractor(trust));
QGpgME::QByteArrayDataProvider dp;
Data data(&dp);
assert(!data.isNull());
const Error err = ctx->edit(key, ei, data);
Error ae;
const QString log = _detail::audit_log_as_html(ctx, ae);
return make_tuple(err, log, ae);
}
Error QGpgMEChangeOwnerTrustJob::start(const Key &key, Key::OwnerTrust trust)
{
run(bind(&change_ownertrust, _1, key, trust));
return Error();
}
+#include "qgpgmechangeownertrustjob.moc"
diff --git a/lang/qt/src/qgpgmechangepasswdjob.cpp b/lang/qt/src/qgpgmechangepasswdjob.cpp
index 4e5f6e36..a182214c 100644
--- a/lang/qt/src/qgpgmechangepasswdjob.cpp
+++ b/lang/qt/src/qgpgmechangepasswdjob.cpp
@@ -1,78 +1,80 @@
/*
qgpgmechangepasswdjob.cpp
This file is part of qgpgme, the Qt API binding for gpgme
Copyright (c) 2010 Klarälvdalens Datakonsult AB
Copyright (c) 2016 Intevation GmbH
Libkleopatra is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
Libkleopatra is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
In addition, as a special exception, the copyright holders give
permission to link the code of this program with any edition of
the Qt library by Trolltech AS, Norway (or with modified versions
of Qt that use the same license as Qt), and distribute linked
combinations including the two. You must obey the GNU General
Public License in all respects for all of the code used other than
Qt. If you modify this file, you may extend this exception to
your version of the file, but you are not obligated to do so. If
you do not wish to do so, delete this exception statement from
your version.
*/
#include "qgpgmechangepasswdjob.h"
#include "dataprovider.h"
#include "context.h"
#include "data.h"
#include "key.h"
#include <cassert>
#include <memory>
using namespace QGpgME;
using namespace GpgME;
using namespace boost;
QGpgMEChangePasswdJob::QGpgMEChangePasswdJob(Context *context)
: mixin_type(context)
{
lateInitialization();
}
QGpgMEChangePasswdJob::~QGpgMEChangePasswdJob() {}
static QGpgMEChangePasswdJob::result_type change_passwd(Context *ctx, const Key &key)
{
#if 0 // in case we want to fall back to edit interactor for gpg...
std::auto_ptr<EditInteractor> ei(new GpgChangePasswdEditInteractor);
QGpgME::QByteArrayDataProvider dp;
Data data(&dp);
assert(!data.isNull());
const Error err = ctx->edit(key, ei, data);
#else
const Error err = ctx->passwd(key);
#endif
Error ae;
const QString log = _detail::audit_log_as_html(ctx, ae);
return make_tuple(err, log, ae);
}
Error QGpgMEChangePasswdJob::start(const Key &key)
{
run(bind(&change_passwd, _1, key));
return Error();
}
+
+#include "qgpgmechangepasswdjob.moc"
diff --git a/lang/qt/src/qgpgmedecryptjob.cpp b/lang/qt/src/qgpgmedecryptjob.cpp
index f084e2a3..9ce41819 100644
--- a/lang/qt/src/qgpgmedecryptjob.cpp
+++ b/lang/qt/src/qgpgmedecryptjob.cpp
@@ -1,127 +1,129 @@
/*
qgpgmedecryptjob.cpp
This file is part of qgpgme, the Qt API binding for gpgme
Copyright (c) 2004,2008 Klarälvdalens Datakonsult AB
Copyright (c) 2016 Intevation GmbH
Libkleopatra is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
Libkleopatra is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
In addition, as a special exception, the copyright holders give
permission to link the code of this program with any edition of
the Qt library by Trolltech AS, Norway (or with modified versions
of Qt that use the same license as Qt), and distribute linked
combinations including the two. You must obey the GNU General
Public License in all respects for all of the code used other than
Qt. If you modify this file, you may extend this exception to
your version of the file, but you are not obligated to do so. If
you do not wish to do so, delete this exception statement from
your version.
*/
#include "qgpgmedecryptjob.h"
#include "dataprovider.h"
#include "context.h"
#include "decryptionresult.h"
#include "data.h"
#include <QBuffer>
#include <boost/weak_ptr.hpp>
#include <cassert>
using namespace QGpgME;
using namespace GpgME;
using namespace boost;
QGpgMEDecryptJob::QGpgMEDecryptJob(Context *context)
: mixin_type(context)
{
lateInitialization();
}
QGpgMEDecryptJob::~QGpgMEDecryptJob() {}
static QGpgMEDecryptJob::result_type decrypt(Context *ctx, QThread *thread, const weak_ptr<QIODevice> &cipherText_, const weak_ptr<QIODevice> &plainText_)
{
const shared_ptr<QIODevice> cipherText = cipherText_.lock();
const shared_ptr<QIODevice> plainText = plainText_.lock();
const _detail::ToThreadMover ctMover(cipherText, thread);
const _detail::ToThreadMover ptMover(plainText, thread);
QGpgME::QIODeviceDataProvider in(cipherText);
const Data indata(&in);
if (!plainText) {
QGpgME::QByteArrayDataProvider out;
Data outdata(&out);
const DecryptionResult res = ctx->decrypt(indata, outdata);
Error ae;
const QString log = _detail::audit_log_as_html(ctx, ae);
return make_tuple(res, out.data(), log, ae);
} else {
QGpgME::QIODeviceDataProvider out(plainText);
Data outdata(&out);
const DecryptionResult res = ctx->decrypt(indata, outdata);
Error ae;
const QString log = _detail::audit_log_as_html(ctx, ae);
return make_tuple(res, QByteArray(), log, ae);
}
}
static QGpgMEDecryptJob::result_type decrypt_qba(Context *ctx, const QByteArray &cipherText)
{
const shared_ptr<QBuffer> buffer(new QBuffer);
buffer->setData(cipherText);
if (!buffer->open(QIODevice::ReadOnly)) {
assert(!"This should never happen: QBuffer::open() failed");
}
return decrypt(ctx, 0, buffer, shared_ptr<QIODevice>());
}
Error QGpgMEDecryptJob::start(const QByteArray &cipherText)
{
run(bind(&decrypt_qba, _1, cipherText));
return Error();
}
void QGpgMEDecryptJob::start(const shared_ptr<QIODevice> &cipherText, const shared_ptr<QIODevice> &plainText)
{
run(bind(&decrypt, _1, _2, _3, _4), cipherText, plainText);
}
GpgME::DecryptionResult QGpgME::QGpgMEDecryptJob::exec(const QByteArray &cipherText,
QByteArray &plainText)
{
const result_type r = decrypt_qba(context(), cipherText);
plainText = get<1>(r);
resultHook(r);
return mResult;
}
//PENDING(marc) implement showErrorDialog()
void QGpgMEDecryptJob::resultHook(const result_type &tuple)
{
mResult = get<0>(tuple);
}
+
+#include "qgpgmedecryptjob.moc"
diff --git a/lang/qt/src/qgpgmedecryptverifyjob.cpp b/lang/qt/src/qgpgmedecryptverifyjob.cpp
index 635511ef..7e6c4b55 100644
--- a/lang/qt/src/qgpgmedecryptverifyjob.cpp
+++ b/lang/qt/src/qgpgmedecryptverifyjob.cpp
@@ -1,135 +1,136 @@
/*
qgpgmedecryptverifyjob.cpp
This file is part of qgpgme, the Qt API binding for gpgme
Copyright (c) 2004,2008 Klarälvdalens Datakonsult AB
Copyright (c) 2016 Intevation GmbH
Libkleopatra is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
Libkleopatra is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
In addition, as a special exception, the copyright holders give
permission to link the code of this program with any edition of
the Qt library by Trolltech AS, Norway (or with modified versions
of Qt that use the same license as Qt), and distribute linked
combinations including the two. You must obey the GNU General
Public License in all respects for all of the code used other than
Qt. If you modify this file, you may extend this exception to
your version of the file, but you are not obligated to do so. If
you do not wish to do so, delete this exception statement from
your version.
*/
#include "qgpgmedecryptverifyjob.h"
#include "dataprovider.h"
#include "context.h"
#include "decryptionresult.h"
#include "verificationresult.h"
#include "data.h"
#include <QDebug>
#include "gpgme_backend_debug.h"
#include <QBuffer>
#include <boost/weak_ptr.hpp>
#include <cassert>
using namespace QGpgME;
using namespace GpgME;
using namespace boost;
QGpgMEDecryptVerifyJob::QGpgMEDecryptVerifyJob(Context *context)
: mixin_type(context)
{
lateInitialization();
}
QGpgMEDecryptVerifyJob::~QGpgMEDecryptVerifyJob() {}
static QGpgMEDecryptVerifyJob::result_type decrypt_verify(Context *ctx, QThread *thread, const weak_ptr<QIODevice> &cipherText_, const weak_ptr<QIODevice> &plainText_)
{
qCDebug(GPGPME_BACKEND_LOG);
const shared_ptr<QIODevice> cipherText = cipherText_.lock();
const shared_ptr<QIODevice> plainText = plainText_.lock();
const _detail::ToThreadMover ctMover(cipherText, thread);
const _detail::ToThreadMover ptMover(plainText, thread);
QGpgME::QIODeviceDataProvider in(cipherText);
const Data indata(&in);
if (!plainText) {
QGpgME::QByteArrayDataProvider out;
Data outdata(&out);
const std::pair<DecryptionResult, VerificationResult> res = ctx->decryptAndVerify(indata, outdata);
Error ae;
const QString log = _detail::audit_log_as_html(ctx, ae);
qCDebug(GPGPME_BACKEND_LOG) << "End no plainText. Error: " << ae;
return make_tuple(res.first, res.second, out.data(), log, ae);
} else {
QGpgME::QIODeviceDataProvider out(plainText);
Data outdata(&out);
const std::pair<DecryptionResult, VerificationResult> res = ctx->decryptAndVerify(indata, outdata);
Error ae;
const QString log = _detail::audit_log_as_html(ctx, ae);
qCDebug(GPGPME_BACKEND_LOG) << "End plainText. Error: " << ae;
return make_tuple(res.first, res.second, QByteArray(), log, ae);
}
}
static QGpgMEDecryptVerifyJob::result_type decrypt_verify_qba(Context *ctx, const QByteArray &cipherText)
{
const shared_ptr<QBuffer> buffer(new QBuffer);
buffer->setData(cipherText);
if (!buffer->open(QIODevice::ReadOnly)) {
assert(!"This should never happen: QBuffer::open() failed");
}
return decrypt_verify(ctx, 0, buffer, shared_ptr<QIODevice>());
}
Error QGpgMEDecryptVerifyJob::start(const QByteArray &cipherText)
{
run(bind(&decrypt_verify_qba, _1, cipherText));
return Error();
}
void QGpgMEDecryptVerifyJob::start(const shared_ptr<QIODevice> &cipherText, const shared_ptr<QIODevice> &plainText)
{
run(bind(&decrypt_verify, _1, _2, _3, _4), cipherText, plainText);
}
std::pair<GpgME::DecryptionResult, GpgME::VerificationResult>
QGpgME::QGpgMEDecryptVerifyJob::exec(const QByteArray &cipherText, QByteArray &plainText)
{
const result_type r = decrypt_verify_qba(context(), cipherText);
plainText = get<2>(r);
resultHook(r);
return mResult;
}
//PENDING(marc) implement showErrorDialog()
void QGpgMEDecryptVerifyJob::resultHook(const result_type &tuple)
{
mResult = std::make_pair(get<0>(tuple), get<1>(tuple));
}
+#include "qgpgmedecryptverifyjob.moc"
diff --git a/lang/qt/src/qgpgmedeletejob.cpp b/lang/qt/src/qgpgmedeletejob.cpp
index c5f52535..8ec4f0a3 100644
--- a/lang/qt/src/qgpgmedeletejob.cpp
+++ b/lang/qt/src/qgpgmedeletejob.cpp
@@ -1,65 +1,66 @@
/*
qgpgmedeletejob.cpp
This file is part of qgpgme, the Qt API binding for gpgme
Copyright (c) 2004,2008 Klarälvdalens Datakonsult AB
Copyright (c) 2016 Intevation GmbH
Libkleopatra is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
Libkleopatra is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
In addition, as a special exception, the copyright holders give
permission to link the code of this program with any edition of
the Qt library by Trolltech AS, Norway (or with modified versions
of Qt that use the same license as Qt), and distribute linked
combinations including the two. You must obey the GNU General
Public License in all respects for all of the code used other than
Qt. If you modify this file, you may extend this exception to
your version of the file, but you are not obligated to do so. If
you do not wish to do so, delete this exception statement from
your version.
*/
#include "qgpgmedeletejob.h"
#include "context.h"
#include "key.h"
#include <cassert>
using namespace QGpgME;
using namespace GpgME;
using namespace boost;
QGpgMEDeleteJob::QGpgMEDeleteJob(Context *context)
: mixin_type(context)
{
lateInitialization();
}
QGpgMEDeleteJob::~QGpgMEDeleteJob() {}
static QGpgMEDeleteJob::result_type delete_key(Context *ctx, const Key &key, bool allowSecretKeyDeletion)
{
const Error err = ctx->deleteKey(key, allowSecretKeyDeletion);
Error ae;
const QString log = _detail::audit_log_as_html(ctx, ae);
return make_tuple(err, log, ae);
}
Error QGpgMEDeleteJob::start(const Key &key, bool allowSecretKeyDeletion)
{
run(bind(&delete_key, _1, key, allowSecretKeyDeletion));
return Error();
}
+#include "qgpgmedeletejob.moc"
diff --git a/lang/qt/src/qgpgmedownloadjob.cpp b/lang/qt/src/qgpgmedownloadjob.cpp
index 3baa6292..f46f4282 100644
--- a/lang/qt/src/qgpgmedownloadjob.cpp
+++ b/lang/qt/src/qgpgmedownloadjob.cpp
@@ -1,102 +1,103 @@
/*
qgpgmedownloadjob.cpp
This file is part of qgpgme, the Qt API binding for gpgme
Copyright (c) 2004,2008 Klarälvdalens Datakonsult AB
Copyright (c) 2016 Intevation GmbH
Libkleopatra is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
Libkleopatra is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
In addition, as a special exception, the copyright holders give
permission to link the code of this program with any edition of
the Qt library by Trolltech AS, Norway (or with modified versions
of Qt that use the same license as Qt), and distribute linked
combinations including the two. You must obey the GNU General
Public License in all respects for all of the code used other than
Qt. If you modify this file, you may extend this exception to
your version of the file, but you are not obligated to do so. If
you do not wish to do so, delete this exception statement from
your version.
*/
#include "qgpgmedownloadjob.h"
#include "dataprovider.h"
#include "context.h"
#include "data.h"
#include <QStringList>
#include <boost/weak_ptr.hpp>
#include <cassert>
using namespace QGpgME;
using namespace GpgME;
using namespace boost;
QGpgMEDownloadJob::QGpgMEDownloadJob(Context *context)
: mixin_type(context)
{
lateInitialization();
}
QGpgMEDownloadJob::~QGpgMEDownloadJob() {}
static QGpgMEDownloadJob::result_type download_qsl(Context *ctx, const QStringList &pats)
{
QGpgME::QByteArrayDataProvider dp;
Data data(&dp);
const _detail::PatternConverter pc(pats);
const Error err = ctx->exportPublicKeys(pc.patterns(), data);
Error ae;
const QString log = _detail::audit_log_as_html(ctx, ae);
return make_tuple(err, dp.data(), log, ae);
}
static QGpgMEDownloadJob::result_type download(Context *ctx, QThread *thread, const QByteArray &fpr, const weak_ptr<QIODevice> &keyData_)
{
const shared_ptr<QIODevice> keyData = keyData_.lock();
if (!keyData) {
return download_qsl(ctx, QStringList(QString::fromUtf8(fpr)));
}
const _detail::ToThreadMover kdMover(keyData, thread);
QGpgME::QIODeviceDataProvider dp(keyData);
Data data(&dp);
const _detail::PatternConverter pc(fpr);
const Error err = ctx->exportPublicKeys(pc.patterns(), data);
Error ae;
const QString log = _detail::audit_log_as_html(ctx, ae);
return make_tuple(err, QByteArray(), log, ae);
}
Error QGpgMEDownloadJob::start(const QStringList &pats)
{
run(bind(&download_qsl, _1, pats));
return Error();
}
Error QGpgMEDownloadJob::start(const QByteArray &fpr, const boost::shared_ptr<QIODevice> &keyData)
{
run(bind(&download, _1, _2, fpr, _3), keyData);
return Error();
}
+#include "qgpgmedownloadjob.moc"
diff --git a/lang/qt/src/qgpgmeencryptjob.cpp b/lang/qt/src/qgpgmeencryptjob.cpp
index 4618e4af..97406dd9 100644
--- a/lang/qt/src/qgpgmeencryptjob.cpp
+++ b/lang/qt/src/qgpgmeencryptjob.cpp
@@ -1,161 +1,162 @@
/*
qgpgmeencryptjob.cpp
This file is part of qgpgme, the Qt API binding for gpgme
Copyright (c) 2004,2007,2008 Klarälvdalens Datakonsult AB
Copyright (c) 2016 Intevation GmbH
Libkleopatra is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
Libkleopatra is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
In addition, as a special exception, the copyright holders give
permission to link the code of this program with any edition of
the Qt library by Trolltech AS, Norway (or with modified versions
of Qt that use the same license as Qt), and distribute linked
combinations including the two. You must obey the GNU General
Public License in all respects for all of the code used other than
Qt. If you modify this file, you may extend this exception to
your version of the file, but you are not obligated to do so. If
you do not wish to do so, delete this exception statement from
your version.
*/
#include "qgpgmeencryptjob.h"
#include "dataprovider.h"
#include "context.h"
#include "encryptionresult.h"
#include "data.h"
#include <QBuffer>
#include <boost/weak_ptr.hpp>
#include <cassert>
using namespace QGpgME;
using namespace GpgME;
using namespace boost;
QGpgMEEncryptJob::QGpgMEEncryptJob(Context *context)
: mixin_type(context),
mOutputIsBase64Encoded(false)
{
lateInitialization();
}
QGpgMEEncryptJob::~QGpgMEEncryptJob() {}
void QGpgMEEncryptJob::setOutputIsBase64Encoded(bool on)
{
mOutputIsBase64Encoded = on;
}
static QGpgMEEncryptJob::result_type encrypt(Context *ctx, QThread *thread,
const std::vector<Key> &recipients,
const weak_ptr<QIODevice> &plainText_,
const weak_ptr<QIODevice> &cipherText_,
bool alwaysTrust,
bool outputIsBsse64Encoded)
{
const shared_ptr<QIODevice> plainText = plainText_.lock();
const shared_ptr<QIODevice> cipherText = cipherText_.lock();
const _detail::ToThreadMover ctMover(cipherText, thread);
const _detail::ToThreadMover ptMover(plainText, thread);
QGpgME::QIODeviceDataProvider in(plainText);
const Data indata(&in);
const Context::EncryptionFlags eflags =
alwaysTrust ? Context::AlwaysTrust : Context::None;
if (!cipherText) {
QGpgME::QByteArrayDataProvider out;
Data outdata(&out);
if (outputIsBsse64Encoded) {
outdata.setEncoding(Data::Base64Encoding);
}
const EncryptionResult res = ctx->encrypt(recipients, indata, outdata, eflags);
Error ae;
const QString log = _detail::audit_log_as_html(ctx, ae);
return make_tuple(res, out.data(), log, ae);
} else {
QGpgME::QIODeviceDataProvider out(cipherText);
Data outdata(&out);
if (outputIsBsse64Encoded) {
outdata.setEncoding(Data::Base64Encoding);
}
const EncryptionResult res = ctx->encrypt(recipients, indata, outdata, eflags);
Error ae;
const QString log = _detail::audit_log_as_html(ctx, ae);
return make_tuple(res, QByteArray(), log, ae);
}
}
static QGpgMEEncryptJob::result_type encrypt_qba(Context *ctx, const std::vector<Key> &recipients, const QByteArray &plainText, bool alwaysTrust, bool outputIsBsse64Encoded)
{
const shared_ptr<QBuffer> buffer(new QBuffer);
buffer->setData(plainText);
if (!buffer->open(QIODevice::ReadOnly)) {
assert(!"This should never happen: QBuffer::open() failed");
}
return encrypt(ctx, 0, recipients, buffer, shared_ptr<QIODevice>(), alwaysTrust, outputIsBsse64Encoded);
}
Error QGpgMEEncryptJob::start(const std::vector<Key> &recipients, const QByteArray &plainText, bool alwaysTrust)
{
run(boost::bind(&encrypt_qba, _1, recipients, plainText, alwaysTrust, mOutputIsBase64Encoded));
return Error();
}
void QGpgMEEncryptJob::start(const std::vector<Key> &recipients, const shared_ptr<QIODevice> &plainText, const shared_ptr<QIODevice> &cipherText, bool alwaysTrust)
{
run(boost::bind(&encrypt,
_1, _2,
recipients,
_3, _4,
alwaysTrust,
mOutputIsBase64Encoded),
plainText, cipherText);
}
EncryptionResult QGpgMEEncryptJob::exec(const std::vector<Key> &recipients, const QByteArray &plainText, bool alwaysTrust, QByteArray &cipherText)
{
const result_type r = encrypt_qba(context(), recipients, plainText, alwaysTrust, mOutputIsBase64Encoded);
cipherText = get<1>(r);
resultHook(r);
return mResult;
}
void QGpgMEEncryptJob::resultHook(const result_type &tuple)
{
mResult = get<0>(tuple);
}
#if 0
void QGpgMEEncryptJob::showErrorDialog(QWidget *parent, const QString &caption) const
{
if (mResult.error() && !mResult.error().isCanceled()) {
MessageBox::error(parent, mResult, this, caption);
}
}
#endif
+#include "qgpgmeencryptjob.moc"
diff --git a/lang/qt/src/qgpgmeexportjob.cpp b/lang/qt/src/qgpgmeexportjob.cpp
index 12bbfd2b..d3a390e4 100644
--- a/lang/qt/src/qgpgmeexportjob.cpp
+++ b/lang/qt/src/qgpgmeexportjob.cpp
@@ -1,76 +1,77 @@
/*
qgpgmeexportjob.cpp
This file is part of qgpgme, the Qt API binding for gpgme
Copyright (c) 2004,2008 Klarälvdalens Datakonsult AB
Copyright (c) 2016 Intevation GmbH
Libkleopatra is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
Libkleopatra is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
In addition, as a special exception, the copyright holders give
permission to link the code of this program with any edition of
the Qt library by Trolltech AS, Norway (or with modified versions
of Qt that use the same license as Qt), and distribute linked
combinations including the two. You must obey the GNU General
Public License in all respects for all of the code used other than
Qt. If you modify this file, you may extend this exception to
your version of the file, but you are not obligated to do so. If
you do not wish to do so, delete this exception statement from
your version.
*/
#include "qgpgmeexportjob.h"
#include "dataprovider.h"
#include "context.h"
#include "data.h"
#include "key.h"
#include <QStringList>
#include <cassert>
using namespace QGpgME;
using namespace GpgME;
using namespace boost;
QGpgMEExportJob::QGpgMEExportJob(Context *context)
: mixin_type(context)
{
lateInitialization();
}
QGpgMEExportJob::~QGpgMEExportJob() {}
static QGpgMEExportJob::result_type export_qba(Context *ctx, const QStringList &patterns)
{
const _detail::PatternConverter pc(patterns);
QGpgME::QByteArrayDataProvider dp;
Data data(&dp);
const Error err = ctx->exportPublicKeys(pc.patterns(), data);
Error ae;
const QString log = _detail::audit_log_as_html(ctx, ae);
return make_tuple(err, dp.data(), log, ae);
}
Error QGpgMEExportJob::start(const QStringList &patterns)
{
run(bind(&export_qba, _1, patterns));
return Error();
}
+#include "qgpgmeexportjob.moc"
diff --git a/lang/qt/src/qgpgmeimportfromkeyserverjob.cpp b/lang/qt/src/qgpgmeimportfromkeyserverjob.cpp
index 846ebee7..ecf78797 100644
--- a/lang/qt/src/qgpgmeimportfromkeyserverjob.cpp
+++ b/lang/qt/src/qgpgmeimportfromkeyserverjob.cpp
@@ -1,82 +1,83 @@
/*
qgpgmeimportfromkeyserverjob.cpp
This file is part of qgpgme, the Qt API binding for gpgme
Copyright (c) 2004,2008 Klarälvdalens Datakonsult AB
Copyright (c) 2016 Intevation GmbH
Libkleopatra is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
Libkleopatra is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
In addition, as a special exception, the copyright holders give
permission to link the code of this program with any edition of
the Qt library by Trolltech AS, Norway (or with modified versions
of Qt that use the same license as Qt), and distribute linked
combinations including the two. You must obey the GNU General
Public License in all respects for all of the code used other than
Qt. If you modify this file, you may extend this exception to
your version of the file, but you are not obligated to do so. If
you do not wish to do so, delete this exception statement from
your version.
*/
#include "qgpgmeimportfromkeyserverjob.h"
#include "dataprovider.h"
#include "context.h"
#include "data.h"
#include "key.h"
#include <cassert>
using namespace QGpgME;
using namespace GpgME;
using namespace boost;
QGpgMEImportFromKeyserverJob::QGpgMEImportFromKeyserverJob(Context *context)
: mixin_type(context)
{
lateInitialization();
}
QGpgMEImportFromKeyserverJob::~QGpgMEImportFromKeyserverJob() {}
static QGpgMEImportFromKeyserverJob::result_type importfromkeyserver(Context *ctx, const std::vector<Key> &keys)
{
const ImportResult res = ctx->importKeys(keys);
Error ae;
const QString log = _detail::audit_log_as_html(ctx, ae);
return make_tuple(res, log, ae);
}
Error QGpgMEImportFromKeyserverJob::start(const std::vector<Key> &keys)
{
run(boost::bind(&importfromkeyserver, _1, keys));
return Error();
}
GpgME::ImportResult QGpgME::QGpgMEImportFromKeyserverJob::exec(const std::vector<Key> &keys)
{
const result_type r = importfromkeyserver(context(), keys);
resultHook(r);
return mResult;
}
// PENDING(marc) implement showErrorDialog()
void QGpgME::QGpgMEImportFromKeyserverJob::resultHook(const result_type &tuple)
{
mResult = get<0>(tuple);
}
+#include "qgpgmeimportfromkeyserverjob.moc"
diff --git a/lang/qt/src/qgpgmeimportjob.cpp b/lang/qt/src/qgpgmeimportjob.cpp
index 973a0bf0..0e44cbe8 100644
--- a/lang/qt/src/qgpgmeimportjob.cpp
+++ b/lang/qt/src/qgpgmeimportjob.cpp
@@ -1,85 +1,86 @@
/*
qgpgmeimportjob.cpp
This file is part of qgpgme, the Qt API binding for gpgme
Copyright (c) 2004,2008 Klarälvdalens Datakonsult AB
Copyright (c) 2016 Intevation GmbH
Libkleopatra is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
Libkleopatra is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
In addition, as a special exception, the copyright holders give
permission to link the code of this program with any edition of
the Qt library by Trolltech AS, Norway (or with modified versions
of Qt that use the same license as Qt), and distribute linked
combinations including the two. You must obey the GNU General
Public License in all respects for all of the code used other than
Qt. If you modify this file, you may extend this exception to
your version of the file, but you are not obligated to do so. If
you do not wish to do so, delete this exception statement from
your version.
*/
#include "qgpgmeimportjob.h"
#include "dataprovider.h"
#include "context.h"
#include "data.h"
#include "key.h"
#include <cassert>
using namespace QGpgME;
using namespace GpgME;
using namespace boost;
QGpgMEImportJob::QGpgMEImportJob(Context *context)
: mixin_type(context)
{
lateInitialization();
}
QGpgMEImportJob::~QGpgMEImportJob() {}
static QGpgMEImportJob::result_type import_qba(Context *ctx, const QByteArray &certData)
{
QGpgME::QByteArrayDataProvider dp(certData);
Data data(&dp);
const ImportResult res = ctx->importKeys(data);
Error ae;
const QString log = _detail::audit_log_as_html(ctx, ae);
return make_tuple(res, log, ae);
}
Error QGpgMEImportJob::start(const QByteArray &certData)
{
run(bind(&import_qba, _1, certData));
return Error();
}
GpgME::ImportResult QGpgME::QGpgMEImportJob::exec(const QByteArray &keyData)
{
const result_type r = import_qba(context(), keyData);
resultHook(r);
return mResult;
}
// PENDING(marc) implement showErrorDialog()
void QGpgME::QGpgMEImportJob::resultHook(const result_type &tuple)
{
mResult = get<0>(tuple);
}
+#include "qgpgmeimportjob.moc"
diff --git a/lang/qt/src/qgpgmekeygenerationjob.cpp b/lang/qt/src/qgpgmekeygenerationjob.cpp
index 56323c98..fc7cf159 100644
--- a/lang/qt/src/qgpgmekeygenerationjob.cpp
+++ b/lang/qt/src/qgpgmekeygenerationjob.cpp
@@ -1,71 +1,72 @@
/*
qgpgmekeygenerationjob.cpp
This file is part of qgpgme, the Qt API binding for gpgme
Copyright (c) 2004 Klarälvdalens Datakonsult AB
Copyright (c) 2016 Intevation GmbH
Libkleopatra is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
Libkleopatra is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
In addition, as a special exception, the copyright holders give
permission to link the code of this program with any edition of
the Qt library by Trolltech AS, Norway (or with modified versions
of Qt that use the same license as Qt), and distribute linked
combinations including the two. You must obey the GNU General
Public License in all respects for all of the code used other than
Qt. If you modify this file, you may extend this exception to
your version of the file, but you are not obligated to do so. If
you do not wish to do so, delete this exception statement from
your version.
*/
#include "qgpgmekeygenerationjob.h"
#include "dataprovider.h"
#include "context.h"
#include "data.h"
#include <cassert>
using namespace QGpgME;
using namespace GpgME;
using namespace boost;
QGpgMEKeyGenerationJob::QGpgMEKeyGenerationJob(Context *context)
: mixin_type(context)
{
lateInitialization();
}
QGpgMEKeyGenerationJob::~QGpgMEKeyGenerationJob() {}
static QGpgMEKeyGenerationJob::result_type generate_key(Context *ctx, const QString ¶meters)
{
QGpgME::QByteArrayDataProvider dp;
Data data = ctx->protocol() == CMS ? Data(&dp) : Data(Data::null);
assert(data.isNull() == (ctx->protocol() != CMS));
const KeyGenerationResult res = ctx->generateKey(parameters.toUtf8().constData(), data);
Error ae;
const QString log = _detail::audit_log_as_html(ctx, ae);
return make_tuple(res, dp.data(), log, ae);
}
Error QGpgMEKeyGenerationJob::start(const QString ¶meters)
{
run(bind(&generate_key, _1, parameters));
return Error();
}
+#include "qgpgmekeygenerationjob.moc"
diff --git a/lang/qt/src/qgpgmekeylistjob.cpp b/lang/qt/src/qgpgmekeylistjob.cpp
index 60599419..2af45fe7 100644
--- a/lang/qt/src/qgpgmekeylistjob.cpp
+++ b/lang/qt/src/qgpgmekeylistjob.cpp
@@ -1,167 +1,168 @@
/*
qgpgmekeylistjob.cpp
This file is part of qgpgme, the Qt API binding for gpgme
Copyright (c) 2004,2008 Klarälvdalens Datakonsult AB
Copyright (c) 2016 Intevation GmbH
Libkleopatra is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
Libkleopatra is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
In addition, as a special exception, the copyright holders give
permission to link the code of this program with any edition of
the Qt library by Trolltech AS, Norway (or with modified versions
of Qt that use the same license as Qt), and distribute linked
combinations including the two. You must obey the GNU General
Public License in all respects for all of the code used other than
Qt. If you modify this file, you may extend this exception to
your version of the file, but you are not obligated to do so. If
you do not wish to do so, delete this exception statement from
your version.
*/
#include "qgpgmekeylistjob.h"
#include "key.h"
#include "context.h"
#include "keylistresult.h"
#include <gpg-error.h>
#include <QStringList>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cassert>
using namespace QGpgME;
using namespace GpgME;
using namespace boost;
QGpgMEKeyListJob::QGpgMEKeyListJob(Context *context)
: mixin_type(context),
mResult(), mSecretOnly(false)
{
lateInitialization();
}
QGpgMEKeyListJob::~QGpgMEKeyListJob() {}
static KeyListResult do_list_keys(Context *ctx, const QStringList &pats, std::vector<Key> &keys, bool secretOnly)
{
const _detail::PatternConverter pc(pats);
if (const Error err = ctx->startKeyListing(pc.patterns(), secretOnly)) {
return KeyListResult(0, err);
}
Error err;
do {
keys.push_back(ctx->nextKey(err));
} while (!err);
keys.pop_back();
const KeyListResult result = ctx->endKeyListing();
ctx->cancelPendingOperation();
return result;
}
static QGpgMEKeyListJob::result_type list_keys(Context *ctx, QStringList pats, bool secretOnly)
{
if (pats.size() < 2) {
std::vector<Key> keys;
const KeyListResult r = do_list_keys(ctx, pats, keys, secretOnly);
return boost::make_tuple(r, keys, QString(), Error());
}
// The communication channel between gpgme and gpgsm is limited in
// the number of patterns that can be transported, but they won't
// say to how much, so we need to find out ourselves if we get a
// LINE_TOO_LONG error back...
// We could of course just feed them single patterns, and that would
// probably be easier, but the performance penalty would currently
// be noticeable.
unsigned int chunkSize = pats.size();
retry:
std::vector<Key> keys;
keys.reserve(pats.size());
KeyListResult result;
do {
const KeyListResult this_result = do_list_keys(ctx, pats.mid(0, chunkSize), keys, secretOnly);
if (this_result.error().code() == GPG_ERR_LINE_TOO_LONG) {
// got LINE_TOO_LONG, try a smaller chunksize:
chunkSize /= 2;
if (chunkSize < 1)
// chunks smaller than one can't be -> return the error.
{
return boost::make_tuple(this_result, keys, QString(), Error());
} else {
goto retry;
}
} else if (this_result.error().code() == GPG_ERR_EOF) {
// early end of keylisting (can happen when ~/.gnupg doesn't
// exist). Fakeing an empty result:
return boost::make_tuple(KeyListResult(), std::vector<Key>(), QString(), Error());
}
// ok, that seemed to work...
result.mergeWith(this_result);
if (result.error().code()) {
break;
}
pats = pats.mid(chunkSize);
} while (!pats.empty());
return boost::make_tuple(result, keys, QString(), Error());
}
Error QGpgMEKeyListJob::start(const QStringList &patterns, bool secretOnly)
{
mSecretOnly = secretOnly;
run(boost::bind(&list_keys, _1, patterns, secretOnly));
return Error();
}
KeyListResult QGpgMEKeyListJob::exec(const QStringList &patterns, bool secretOnly, std::vector<Key> &keys)
{
mSecretOnly = secretOnly;
const result_type r = list_keys(context(), patterns, secretOnly);
resultHook(r);
keys = get<1>(r);
return get<0>(r);
}
void QGpgMEKeyListJob::resultHook(const result_type &tuple)
{
mResult = get<0>(tuple);
Q_FOREACH (const Key &key, get<1>(tuple)) {
Q_EMIT nextKey(key);
}
}
#if 0
void QGpgMEKeyListJob::showErrorDialog(QWidget *parent, const QString &caption) const
{
if (!mResult.error() || mResult.error().isCanceled()) {
return;
}
const QString msg = i18n("<qt><p>An error occurred while fetching "
"the keys from the backend:</p>"
"<p><b>%1</b></p></qt>",
QString::fromLocal8Bit(mResult.error().asString()));
KMessageBox::error(parent, msg, caption);
}
#endif
+#include "qgpgmekeylistjob.moc"
diff --git a/lang/qt/src/qgpgmelistallkeysjob.cpp b/lang/qt/src/qgpgmelistallkeysjob.cpp
index a51231fc..4f98d34a 100644
--- a/lang/qt/src/qgpgmelistallkeysjob.cpp
+++ b/lang/qt/src/qgpgmelistallkeysjob.cpp
@@ -1,170 +1,171 @@
/*
qgpgmelistallkeysjob.cpp
This file is part of qgpgme, the Qt API binding for gpgme
Copyright (c) 2004,2008 Klarälvdalens Datakonsult AB
Copyright (c) 2016 Intevation GmbH
Libkleopatra is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
Libkleopatra is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
In addition, as a special exception, the copyright holders give
permission to link the code of this program with any edition of
the Qt library by Trolltech AS, Norway (or with modified versions
of Qt that use the same license as Qt), and distribute linked
combinations including the two. You must obey the GNU General
Public License in all respects for all of the code used other than
Qt. If you modify this file, you may extend this exception to
your version of the file, but you are not obligated to do so. If
you do not wish to do so, delete this exception statement from
your version.
*/
#include "qgpgmelistallkeysjob.h"
#include "predicates.h"
#include "key.h"
#include "context.h"
#include "keylistresult.h"
#include <gpg-error.h>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cassert>
using namespace QGpgME;
using namespace GpgME;
using namespace boost;
QGpgMEListAllKeysJob::QGpgMEListAllKeysJob(Context *context)
: mixin_type(context),
mResult()
{
lateInitialization();
}
QGpgMEListAllKeysJob::~QGpgMEListAllKeysJob() {}
static KeyListResult do_list_keys(Context *ctx, std::vector<Key> &keys, bool secretOnly)
{
const char **pat = 0;
if (const Error err = ctx->startKeyListing(pat, secretOnly)) {
return KeyListResult(0, err);
}
Error err;
do {
keys.push_back(ctx->nextKey(err));
} while (!err);
keys.pop_back();
const KeyListResult result = ctx->endKeyListing();
ctx->cancelPendingOperation();
return result;
}
namespace
{
template <typename ForwardIterator, typename BinaryPredicate>
ForwardIterator unique_by_merge(ForwardIterator first, ForwardIterator last, BinaryPredicate pred)
{
first = std::adjacent_find(first, last, pred);
if (first == last) {
return last;
}
ForwardIterator dest = first;
dest->mergeWith(*++first);
while (++first != last)
if (pred(*dest, *first)) {
dest->mergeWith(*first);
} else {
*++dest = *first;
}
return ++dest;
}
}
static void merge_keys(std::vector<Key> &merged, std::vector<Key> &pub, std::vector<Key> &sec)
{
merged.reserve(pub.size() + sec.size());
std::merge(pub.begin(), pub.end(),
sec.begin(), sec.end(),
std::back_inserter(merged),
_detail::ByFingerprint<std::less>());
merged.erase(unique_by_merge(merged.begin(), merged.end(), _detail::ByFingerprint<std::equal_to>()),
merged.end());
}
static QGpgMEListAllKeysJob::result_type list_keys(Context *ctx, bool mergeKeys)
{
std::vector<Key> pub, sec, merged;
KeyListResult r;
r.mergeWith(do_list_keys(ctx, pub, false));
std::sort(pub.begin(), pub.end(), _detail::ByFingerprint<std::less>());
r.mergeWith(do_list_keys(ctx, sec, true));
std::sort(sec.begin(), sec.end(), _detail::ByFingerprint<std::less>());
if (mergeKeys) {
merge_keys(merged, pub, sec);
} else {
merged.swap(pub);
}
return boost::make_tuple(r, merged, sec, QString(), Error());
}
Error QGpgMEListAllKeysJob::start(bool mergeKeys)
{
run(boost::bind(&list_keys, _1, mergeKeys));
return Error();
}
KeyListResult QGpgMEListAllKeysJob::exec(std::vector<Key> &pub, std::vector<Key> &sec, bool mergeKeys)
{
const result_type r = list_keys(context(), mergeKeys);
resultHook(r);
pub = get<1>(r);
sec = get<2>(r);
return get<0>(r);
}
void QGpgMEListAllKeysJob::resultHook(const result_type &tuple)
{
mResult = get<0>(tuple);
}
#if 0
void QGpgMEListAllKeysJob::showErrorDialog(QWidget *parent, const QString &caption) const
{
if (!mResult.error() || mResult.error().isCanceled()) {
return;
}
const QString msg = i18n("<qt><p>An error occurred while fetching "
"the keys from the backend:</p>"
"<p><b>%1</b></p></qt>",
QString::fromLocal8Bit(mResult.error().asString()));
KMessageBox::error(parent, msg, caption);
}
#endif
+#include "qgpgmelistallkeysjob.moc"
diff --git a/lang/qt/src/qgpgmerefreshkeysjob.cpp b/lang/qt/src/qgpgmerefreshkeysjob.cpp
index 2a35b235..67b0a147 100644
--- a/lang/qt/src/qgpgmerefreshkeysjob.cpp
+++ b/lang/qt/src/qgpgmerefreshkeysjob.cpp
@@ -1,224 +1,225 @@
/*
qgpgmerefreshkeysjob.cpp
This file is part of qgpgme, the Qt API binding for gpgme
Copyright (c) 2004 Klar�vdalens Datakonsult AB
Copyright (c) 2016 Intevation GmbH
Libkleopatra is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
Libkleopatra is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
In addition, as a special exception, the copyright holders give
permission to link the code of this program with any edition of
the Qt library by Trolltech AS, Norway (or with modified versions
of Qt that use the same license as Qt), and distribute linked
combinations including the two. You must obey the GNU General
Public License in all respects for all of the code used other than
Qt. If you modify this file, you may extend this exception to
your version of the file, but you are not obligated to do so. If
you do not wish to do so, delete this exception statement from
your version.
*/
#define MAX_CMD_LENGTH 32768
#include "qgpgmerefreshkeysjob.h"
#include <QDebug>
#include "gpgme_backend_debug.h"
#include "context.h"
#include <QByteArray>
#include <QStringList>
#include <gpg-error.h>
#include <assert.h>
QGpgME::QGpgMERefreshKeysJob::QGpgMERefreshKeysJob()
: RefreshKeysJob(0),
mProcess(0),
mError(0)
{
}
QGpgME::QGpgMERefreshKeysJob::~QGpgMERefreshKeysJob()
{
}
GpgME::Error QGpgME::QGpgMERefreshKeysJob::start(const QStringList &patterns)
{
assert(mPatternsToDo.empty());
mPatternsToDo = patterns;
if (mPatternsToDo.empty()) {
mPatternsToDo.push_back(QStringLiteral(" ")); // empty list means all -> mae
}
// sure to fail the first
// startAProcess() guard clause
return startAProcess();
}
#if MAX_CMD_LENGTH < 65 + 128
#error MAX_CMD_LENGTH is too low
#endif
GpgME::Error QGpgME::QGpgMERefreshKeysJob::startAProcess()
{
if (mPatternsToDo.empty()) {
return GpgME::Error();
}
// create and start gpgsm process:
mProcess = new QProcess(this);
mProcess->setObjectName(QStringLiteral("gpgsm -k --with-validation --force-crl-refresh --enable-crl-checks"));
// FIXME: obbtain the path to gpgsm from gpgme, so we use the same instance.
mProcess->setProgram(QStringLiteral("gpgsm"));
QStringList arguments;
arguments << QStringLiteral("-k")
<< QStringLiteral("--with-validation")
<< QStringLiteral("--force-crl-refresh")
<< QStringLiteral("--enable-crl-checks");
unsigned int commandLineLength = MAX_CMD_LENGTH;
commandLineLength -=
strlen("gpgsm") + 1 + strlen("-k") + 1 +
strlen("--with-validation") + 1 + strlen("--force-crl-refresh") + 1 +
strlen("--enable-crl-checks") + 1;
while (!mPatternsToDo.empty()) {
const QByteArray pat = mPatternsToDo.front().toUtf8().trimmed();
const unsigned int patLength = pat.length();
if (patLength >= commandLineLength) {
break;
}
mPatternsToDo.pop_front();
if (pat.isEmpty()) {
continue;
}
arguments << QLatin1String(pat);
commandLineLength -= patLength + 1;
}
mProcess->setArguments(arguments);
connect(mProcess, SIGNAL(finished(int,QProcess::ExitStatus)),
SLOT(slotProcessExited(int,QProcess::ExitStatus)));
connect(mProcess, SIGNAL(readyReadStandardOutput()),
SLOT(slotStdout()));
connect(mProcess, &QProcess::readyReadStandardError,
this, &QGpgMERefreshKeysJob::slotStderr);
mProcess->start();
if (!mProcess->waitForStarted()) {
mError = GpgME::Error::fromCode(GPG_ERR_ENOENT, GPG_ERR_SOURCE_GPGSM); // what else?
deleteLater();
return mError;
} else {
return GpgME::Error();
}
}
void QGpgME::QGpgMERefreshKeysJob::slotCancel()
{
if (mProcess) {
mProcess->kill();
}
mProcess = 0;
mError = GpgME::Error::fromCode(GPG_ERR_CANCELED, GPG_ERR_SOURCE_GPGSM);
}
void QGpgME::QGpgMERefreshKeysJob::slotStatus(QProcess *proc, const QString &type, const QStringList &args)
{
if (proc != mProcess) {
return;
}
QStringList::const_iterator it = args.begin();
bool ok = false;
if (type == QLatin1String("ERROR")) {
if (args.size() < 2) {
qCDebug(GPGPME_BACKEND_LOG) << "not recognising ERROR with < 2 args!";
return;
}
const int source = (*++it).toInt(&ok);
if (!ok) {
qCDebug(GPGPME_BACKEND_LOG) << "expected number for first ERROR arg, got something else";
return;
}
ok = false;
const int code = (*++it).toInt(&ok);
if (!ok) {
qCDebug(GPGPME_BACKEND_LOG) << "expected number for second ERROR arg, got something else";
return;
}
mError = GpgME::Error::fromCode(code, source);
} else if (type == QLatin1String("PROGRESS")) {
if (args.size() < 4) {
qCDebug(GPGPME_BACKEND_LOG) << "not recognising PROGRESS with < 4 args!";
return;
}
const QString what = *++it;
ok = false;
const int typ = (*++it).toInt(&ok);
if (!ok) {
qCDebug(GPGPME_BACKEND_LOG) << "expected number for \"type\", got something else";
return;
}
ok = false;
const int cur = (*++it).toInt(&ok);
if (!ok) {
qCDebug(GPGPME_BACKEND_LOG) << "expected number for \"cur\", got something else";
return;
}
ok = false;
const int total = (*++it).toInt(&ok);
if (!ok) {
qCDebug(GPGPME_BACKEND_LOG) << "expected number for \"total\", got something else";
return;
}
// TODO port
Q_EMIT progress(QString(), cur, total);
}
}
void QGpgME::QGpgMERefreshKeysJob::slotStderr()
{
// implement? or not?
}
void QGpgME::QGpgMERefreshKeysJob::slotProcessExited(int exitCode, QProcess::ExitStatus exitStatus)
{
if (!mError && !mPatternsToDo.empty()) {
if (const GpgME::Error err = startAProcess()) {
mError = err;
} else {
return;
}
}
Q_EMIT done();
if (!mError &&
(exitStatus != QProcess::NormalExit || exitCode != 0)) {
mError = GpgME::Error::fromCode(GPG_ERR_GENERAL, GPG_ERR_SOURCE_GPGSM);
}
Q_EMIT result(mError);
deleteLater();
}
+#include "qgpgmerefreshkeysjob.moc"
diff --git a/lang/qt/src/qgpgmesecretkeyexportjob.cpp b/lang/qt/src/qgpgmesecretkeyexportjob.cpp
index 9fd3ffec..3c330b00 100644
--- a/lang/qt/src/qgpgmesecretkeyexportjob.cpp
+++ b/lang/qt/src/qgpgmesecretkeyexportjob.cpp
@@ -1,141 +1,142 @@
/*
qgpgmesecretexportjob.cpp
This file is part of qgpgme, the Qt API binding for gpgme
Copyright (c) 2004 Klar�vdalens Datakonsult AB
Copyright (c) 2016 Intevation GmbH
Libkleopatra is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
Libkleopatra is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
In addition, as a special exception, the copyright holders give
permission to link the code of this program with any edition of
the Qt library by Trolltech AS, Norway (or with modified versions
of Qt that use the same license as Qt), and distribute linked
combinations including the two. You must obey the GNU General
Public License in all respects for all of the code used other than
Qt. If you modify this file, you may extend this exception to
your version of the file, but you are not obligated to do so. If
you do not wish to do so, delete this exception statement from
your version.
*/
#include "qgpgmesecretkeyexportjob.h"
#include <QDebug>
#include "gpgme_backend_debug.h"
#include "context.h"
#include "data.h"
#include <QStringList>
#include <gpg-error.h>
#include <string.h>
#include <assert.h>
QGpgME::QGpgMESecretKeyExportJob::QGpgMESecretKeyExportJob(bool armour, const QString &charset)
: ExportJob(0),
mProcess(0),
mError(0),
mArmour(armour),
mCharset(charset)
{
}
QGpgME::QGpgMESecretKeyExportJob::~QGpgMESecretKeyExportJob()
{
}
GpgME::Error QGpgME::QGpgMESecretKeyExportJob::start(const QStringList &patterns)
{
assert(mKeyData.isEmpty());
if (patterns.size() != 1 || patterns.front().isEmpty()) {
deleteLater();
return mError = GpgME::Error::fromCode(GPG_ERR_INV_VALUE, GPG_ERR_SOURCE_GPGSM);
}
// create and start gpgsm process:
mProcess = new QProcess(this);
mProcess->setObjectName(QStringLiteral("gpgsm --export-secret-key-p12"));
// FIXME: obtain the path to gpgsm from gpgme, so we use the same instance.
mProcess->setProgram("gpgsm");
QStringList arguments;
arguments << QStringLiteral("--export-secret-key-p12");
if (mArmour) {
arguments << QStringLiteral("--armor");
}
if (!mCharset.isEmpty()) {
arguments << QStringLiteral("--p12-charset") << mCharset;
}
arguments << QLatin1String(patterns.front().toUtf8());
mProcess->setArguments(arguments);
connect(mProcess, SIGNAL(finished(int,QProcess::ExitStatus)),
SLOT(slotProcessExited(int,QProcess::ExitStatus)));
connect(mProcess, &QProcess::readyReadStandardOutput,
this, &QGpgMESecretKeyExportJob::slotStdout);
connect(mProcess, &QProcess::readyReadStandardError,
this, &QGpgMESecretKeyExportJob::slotStderr);
mProcess->start();
if (!mProcess->waitForStarted()) {
mError = GpgME::Error::fromCode(GPG_ERR_ENOENT, GPG_ERR_SOURCE_GPGSM); // what else?
deleteLater();
return mError;
} else {
return GpgME::Error();
}
}
void QGpgME::QGpgMESecretKeyExportJob::slotCancel()
{
if (mProcess) {
mProcess->kill();
}
mProcess = 0;
mError = GpgME::Error::fromCode(GPG_ERR_CANCELED, GPG_ERR_SOURCE_GPGSM);
}
void QGpgME::QGpgMESecretKeyExportJob::slotStdout()
{
QString line = QString::fromLocal8Bit(mProcess->readLine());
if (!line.isEmpty()) {
return;
}
const unsigned int oldlen = mKeyData.size();
mKeyData.resize(oldlen + line.length());
memcpy(mKeyData.data() + oldlen, line.toLatin1(), line.length());
}
void QGpgME::QGpgMESecretKeyExportJob::slotStderr()
{
// implement? or not?
}
void QGpgME::QGpgMESecretKeyExportJob::slotProcessExited(int exitCode, QProcess::ExitStatus exitStatus)
{
Q_EMIT done();
if (!mError &&
(exitStatus != QProcess::NormalExit || exitCode != 0)) {
mError = GpgME::Error::fromCode(GPG_ERR_GENERAL, GPG_ERR_SOURCE_GPGSM);
}
Q_EMIT result(mError, mKeyData);
deleteLater();
}
+#include "qgpgmesecretkeyexportjob.moc"
diff --git a/lang/qt/src/qgpgmesignencryptjob.cpp b/lang/qt/src/qgpgmesignencryptjob.cpp
index 1712b389..7c184c6c 100644
--- a/lang/qt/src/qgpgmesignencryptjob.cpp
+++ b/lang/qt/src/qgpgmesignencryptjob.cpp
@@ -1,160 +1,161 @@
/*
qgpgmesignencryptjob.cpp
This file is part of qgpgme, the Qt API binding for gpgme
Copyright (c) 2004, 2007 Klarälvdalens Datakonsult AB
Copyright (c) 2016 Intevation GmbH
Libkleopatra is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
Libkleopatra is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
In addition, as a special exception, the copyright holders give
permission to link the code of this program with any edition of
the Qt library by Trolltech AS, Norway (or with modified versions
of Qt that use the same license as Qt), and distribute linked
combinations including the two. You must obey the GNU General
Public License in all respects for all of the code used other than
Qt. If you modify this file, you may extend this exception to
your version of the file, but you are not obligated to do so. If
you do not wish to do so, delete this exception statement from
your version.
*/
#include "qgpgmesignencryptjob.h"
#include "dataprovider.h"
#include "context.h"
#include "data.h"
#include "key.h"
#include "exception.h"
#include <QBuffer>
#include <boost/weak_ptr.hpp>
#include <cassert>
using namespace QGpgME;
using namespace GpgME;
using namespace boost;
QGpgMESignEncryptJob::QGpgMESignEncryptJob(Context *context)
: mixin_type(context),
mOutputIsBase64Encoded(false)
{
lateInitialization();
}
QGpgMESignEncryptJob::~QGpgMESignEncryptJob() {}
void QGpgMESignEncryptJob::setOutputIsBase64Encoded(bool on)
{
mOutputIsBase64Encoded = on;
}
static QGpgMESignEncryptJob::result_type sign_encrypt(Context *ctx, QThread *thread, const std::vector<Key> &signers, const std::vector<Key> &recipients, const weak_ptr<QIODevice> &plainText_, const weak_ptr<QIODevice> &cipherText_, bool alwaysTrust, bool outputIsBsse64Encoded)
{
const shared_ptr<QIODevice> &plainText = plainText_.lock();
const shared_ptr<QIODevice> &cipherText = cipherText_.lock();
const _detail::ToThreadMover ctMover(cipherText, thread);
const _detail::ToThreadMover ptMover(plainText, thread);
QGpgME::QIODeviceDataProvider in(plainText);
const Data indata(&in);
const Context::EncryptionFlags eflags =
alwaysTrust ? Context::AlwaysTrust : Context::None;
ctx->clearSigningKeys();
Q_FOREACH (const Key &signer, signers)
if (!signer.isNull())
if (const Error err = ctx->addSigningKey(signer)) {
return make_tuple(SigningResult(err), EncryptionResult(), QByteArray(), QString(), Error());
}
if (!cipherText) {
QGpgME::QByteArrayDataProvider out;
Data outdata(&out);
if (outputIsBsse64Encoded) {
outdata.setEncoding(Data::Base64Encoding);
}
const std::pair<SigningResult, EncryptionResult> res = ctx->signAndEncrypt(recipients, indata, outdata, eflags);
Error ae;
const QString log = _detail::audit_log_as_html(ctx, ae);
return make_tuple(res.first, res.second, out.data(), log, ae);
} else {
QGpgME::QIODeviceDataProvider out(cipherText);
Data outdata(&out);
if (outputIsBsse64Encoded) {
outdata.setEncoding(Data::Base64Encoding);
}
const std::pair<SigningResult, EncryptionResult> res = ctx->signAndEncrypt(recipients, indata, outdata, eflags);
Error ae;
const QString log = _detail::audit_log_as_html(ctx, ae);
return make_tuple(res.first, res.second, QByteArray(), log, ae);
}
}
static QGpgMESignEncryptJob::result_type sign_encrypt_qba(Context *ctx, const std::vector<Key> &signers, const std::vector<Key> &recipients, const QByteArray &plainText, bool alwaysTrust, bool outputIsBsse64Encoded)
{
const shared_ptr<QBuffer> buffer(new QBuffer);
buffer->setData(plainText);
if (!buffer->open(QIODevice::ReadOnly)) {
assert(!"This should never happen: QBuffer::open() failed");
}
return sign_encrypt(ctx, 0, signers, recipients, buffer, shared_ptr<QIODevice>(), alwaysTrust, outputIsBsse64Encoded);
}
Error QGpgMESignEncryptJob::start(const std::vector<Key> &signers, const std::vector<Key> &recipients, const QByteArray &plainText, bool alwaysTrust)
{
run(boost::bind(&sign_encrypt_qba, _1, signers, recipients, plainText, alwaysTrust, mOutputIsBase64Encoded));
return Error();
}
void QGpgMESignEncryptJob::start(const std::vector<Key> &signers, const std::vector<Key> &recipients, const shared_ptr<QIODevice> &plainText, const shared_ptr<QIODevice> &cipherText, bool alwaysTrust)
{
run(boost::bind(&sign_encrypt, _1, _2, signers, recipients, _3, _4, alwaysTrust, mOutputIsBase64Encoded), plainText, cipherText);
}
std::pair<SigningResult, EncryptionResult> QGpgMESignEncryptJob::exec(const std::vector<Key> &signers, const std::vector<Key> &recipients, const QByteArray &plainText, bool alwaysTrust, QByteArray &cipherText)
{
const result_type r = sign_encrypt_qba(context(), signers, recipients, plainText, alwaysTrust, mOutputIsBase64Encoded);
cipherText = get<2>(r);
resultHook(r);
return mResult;
}
#if 0
TODO port?
void QGpgMESignEncryptJob::showErrorDialog(QWidget *parent, const QString &caption) const
{
if ((mResult.first.error() && !mResult.first.error().isCanceled()) ||
(mResult.second.error() && !mResult.second.error().isCanceled())) {
MessageBox::error(parent, mResult.first, mResult.second, this, caption);
}
}
#endif
void QGpgMESignEncryptJob::resultHook(const result_type &tuple)
{
mResult = std::make_pair(get<0>(tuple), get<1>(tuple));
}
+#include "qgpgmesignencryptjob.moc"
diff --git a/lang/qt/src/qgpgmesignjob.cpp b/lang/qt/src/qgpgmesignjob.cpp
index 5d8ae858..3fdf3e61 100644
--- a/lang/qt/src/qgpgmesignjob.cpp
+++ b/lang/qt/src/qgpgmesignjob.cpp
@@ -1,164 +1,165 @@
/*
qgpgmesignjob.cpp
This file is part of qgpgme, the Qt API binding for gpgme
Copyright (c) 2004,2007,2008 Klarälvdalens Datakonsult AB
Copyright (c) 2016 Intevation GmbH
Libkleopatra is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
Libkleopatra is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
In addition, as a special exception, the copyright holders give
permission to link the code of this program with any edition of
the Qt library by Trolltech AS, Norway (or with modified versions
of Qt that use the same license as Qt), and distribute linked
combinations including the two. You must obey the GNU General
Public License in all respects for all of the code used other than
Qt. If you modify this file, you may extend this exception to
your version of the file, but you are not obligated to do so. If
you do not wish to do so, delete this exception statement from
your version.
*/
#include "qgpgmesignjob.h"
#include "dataprovider.h"
#include "context.h"
#include "signingresult.h"
#include "data.h"
#include <QBuffer>
#include <boost/weak_ptr.hpp>
#include <cassert>
using namespace QGpgME;
using namespace GpgME;
using namespace boost;
QGpgMESignJob::QGpgMESignJob(Context *context)
: mixin_type(context),
mOutputIsBase64Encoded(false)
{
lateInitialization();
}
QGpgMESignJob::~QGpgMESignJob() {}
void QGpgMESignJob::setOutputIsBase64Encoded(bool on)
{
mOutputIsBase64Encoded = on;
}
static QGpgMESignJob::result_type sign(Context *ctx, QThread *thread,
const std::vector<Key> &signers,
const weak_ptr<QIODevice> &plainText_,
const weak_ptr<QIODevice> &signature_,
SignatureMode mode,
bool outputIsBsse64Encoded)
{
const shared_ptr<QIODevice> plainText = plainText_.lock();
const shared_ptr<QIODevice> signature = signature_.lock();
const _detail::ToThreadMover ptMover(plainText, thread);
const _detail::ToThreadMover sgMover(signature, thread);
QGpgME::QIODeviceDataProvider in(plainText);
const Data indata(&in);
ctx->clearSigningKeys();
Q_FOREACH (const Key &signer, signers)
if (!signer.isNull())
if (const Error err = ctx->addSigningKey(signer)) {
return make_tuple(SigningResult(err), QByteArray(), QString(), Error());
}
if (!signature) {
QGpgME::QByteArrayDataProvider out;
Data outdata(&out);
if (outputIsBsse64Encoded) {
outdata.setEncoding(Data::Base64Encoding);
}
const SigningResult res = ctx->sign(indata, outdata, mode);
Error ae;
const QString log = _detail::audit_log_as_html(ctx, ae);
return make_tuple(res, out.data(), log, ae);
} else {
QGpgME::QIODeviceDataProvider out(signature);
Data outdata(&out);
if (outputIsBsse64Encoded) {
outdata.setEncoding(Data::Base64Encoding);
}
const SigningResult res = ctx->sign(indata, outdata, mode);
Error ae;
const QString log = _detail::audit_log_as_html(ctx, ae);
return make_tuple(res, QByteArray(), log, ae);
}
}
static QGpgMESignJob::result_type sign_qba(Context *ctx,
const std::vector<Key> &signers,
const QByteArray &plainText,
SignatureMode mode,
bool outputIsBsse64Encoded)
{
const shared_ptr<QBuffer> buffer(new QBuffer);
buffer->setData(plainText);
if (!buffer->open(QIODevice::ReadOnly)) {
assert(!"This should never happen: QBuffer::open() failed");
}
return sign(ctx, 0, signers, buffer, shared_ptr<QIODevice>(), mode, outputIsBsse64Encoded);
}
Error QGpgMESignJob::start(const std::vector<Key> &signers, const QByteArray &plainText, SignatureMode mode)
{
run(boost::bind(&sign_qba, _1, signers, plainText, mode, mOutputIsBase64Encoded));
return Error();
}
void QGpgMESignJob::start(const std::vector<Key> &signers, const shared_ptr<QIODevice> &plainText, const shared_ptr<QIODevice> &signature, SignatureMode mode)
{
run(boost::bind(&sign, _1, _2, signers, _3, _4, mode, mOutputIsBase64Encoded), plainText, signature);
}
SigningResult QGpgMESignJob::exec(const std::vector<Key> &signers, const QByteArray &plainText, SignatureMode mode, QByteArray &signature)
{
const result_type r = sign_qba(context(), signers, plainText, mode, mOutputIsBase64Encoded);
signature = get<1>(r);
resultHook(r);
return mResult;
}
void QGpgMESignJob::resultHook(const result_type &tuple)
{
mResult = get<0>(tuple);
}
#if 0
TODO port
void QGpgMESignJob::showErrorDialog(QWidget *parent, const QString &caption) const
{
if (mResult.error() && !mResult.error().isCanceled()) {
MessageBox::error(parent, mResult, this, caption);
}
}
#endif
+#include "qgpgmesignjob.moc"
diff --git a/lang/qt/src/qgpgmesignkeyjob.cpp b/lang/qt/src/qgpgmesignkeyjob.cpp
index c6bbe2c8..d683e53c 100644
--- a/lang/qt/src/qgpgmesignkeyjob.cpp
+++ b/lang/qt/src/qgpgmesignkeyjob.cpp
@@ -1,127 +1,128 @@
/*
qgpgmesignkeyjob.cpp
This file is part of qgpgme, the Qt API binding for gpgme
Copyright (c) 2008 Klarälvdalens Datakonsult AB
Copyright (c) 2016 Intevation GmbH
Libkleopatra is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
Libkleopatra is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
In addition, as a special exception, the copyright holders give
permission to link the code of this program with any edition of
the Qt library by Trolltech AS, Norway (or with modified versions
of Qt that use the same license as Qt), and distribute linked
combinations including the two. You must obey the GNU General
Public License in all respects for all of the code used other than
Qt. If you modify this file, you may extend this exception to
your version of the file, but you are not obligated to do so. If
you do not wish to do so, delete this exception statement from
your version.
*/
#include "qgpgmesignkeyjob.h"
#include "dataprovider.h"
#include "context.h"
#include "data.h"
#include "gpgsignkeyeditinteractor.h"
#include <cassert>
#include <memory>
using namespace QGpgME;
using namespace GpgME;
using namespace boost;
QGpgMESignKeyJob::QGpgMESignKeyJob(Context *context)
: mixin_type(context),
m_userIDsToSign(),
m_signingKey(),
m_checkLevel(0),
m_exportable(false),
m_nonRevocable(false),
m_started(false)
{
lateInitialization();
}
QGpgMESignKeyJob::~QGpgMESignKeyJob() {}
static QGpgMESignKeyJob::result_type sign_key(Context *ctx, const Key &key, const std::vector<unsigned int> &uids, unsigned int checkLevel, const Key &signer, unsigned int opts)
{
QGpgME::QByteArrayDataProvider dp;
Data data(&dp);
std::auto_ptr<GpgSignKeyEditInteractor> skei(new GpgSignKeyEditInteractor);
skei->setUserIDsToSign(uids);
skei->setCheckLevel(checkLevel);
skei->setSigningOptions(opts);
std::auto_ptr<EditInteractor> ei(skei);
if (!signer.isNull())
if (const Error err = ctx->addSigningKey(signer)) {
return make_tuple(err, QString(), Error());
}
const Error err = ctx->edit(key, ei, data);
Error ae;
const QString log = _detail::audit_log_as_html(ctx, ae);
return make_tuple(err, log, ae);
}
Error QGpgMESignKeyJob::start(const Key &key)
{
unsigned int opts = 0;
if (m_nonRevocable) {
opts |= GpgSignKeyEditInteractor::NonRevocable;
}
if (m_exportable) {
opts |= GpgSignKeyEditInteractor::Exportable;
}
run(boost::bind(&sign_key, _1, key, m_userIDsToSign, m_checkLevel, m_signingKey, opts));
m_started = true;
return Error();
}
void QGpgMESignKeyJob::setUserIDsToSign(const std::vector<unsigned int> &idsToSign)
{
assert(!m_started);
m_userIDsToSign = idsToSign;
}
void QGpgMESignKeyJob::setCheckLevel(unsigned int checkLevel)
{
assert(!m_started);
m_checkLevel = checkLevel;
}
void QGpgMESignKeyJob::setExportable(bool exportable)
{
assert(!m_started);
m_exportable = exportable;
}
void QGpgMESignKeyJob::setSigningKey(const Key &key)
{
assert(!m_started);
m_signingKey = key;
}
void QGpgMESignKeyJob::setNonRevocable(bool nonRevocable)
{
assert(!m_started);
m_nonRevocable = nonRevocable;
}
+#include "qgpgmesignkeyjob.moc"
diff --git a/lang/qt/src/qgpgmeverifydetachedjob.cpp b/lang/qt/src/qgpgmeverifydetachedjob.cpp
index 5122835e..3d652425 100644
--- a/lang/qt/src/qgpgmeverifydetachedjob.cpp
+++ b/lang/qt/src/qgpgmeverifydetachedjob.cpp
@@ -1,119 +1,120 @@
/*
qgpgmeverifydetachedjob.cpp
This file is part of qgpgme, the Qt API binding for gpgme
Copyright (c) 2004,2007,2008 Klarälvdalens Datakonsult AB
Copyright (c) 2016 Intevation GmbH
Libkleopatra is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
Libkleopatra is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
In addition, as a special exception, the copyright holders give
permission to link the code of this program with any edition of
the Qt library by Trolltech AS, Norway (or with modified versions
of Qt that use the same license as Qt), and distribute linked
combinations including the two. You must obey the GNU General
Public License in all respects for all of the code used other than
Qt. If you modify this file, you may extend this exception to
your version of the file, but you are not obligated to do so. If
you do not wish to do so, delete this exception statement from
your version.
*/
#include "qgpgmeverifydetachedjob.h"
#include "dataprovider.h"
#include "context.h"
#include "verificationresult.h"
#include "data.h"
#include <cassert>
#include <boost/weak_ptr.hpp>
using namespace QGpgME;
using namespace GpgME;
using namespace boost;
QGpgMEVerifyDetachedJob::QGpgMEVerifyDetachedJob(Context *context)
: mixin_type(context)
{
lateInitialization();
}
QGpgMEVerifyDetachedJob::~QGpgMEVerifyDetachedJob() {}
static QGpgMEVerifyDetachedJob::result_type verify_detached(Context *ctx, QThread *thread, const weak_ptr<QIODevice> &signature_, const weak_ptr<QIODevice> &signedData_)
{
const shared_ptr<QIODevice> signature = signature_.lock();
const shared_ptr<QIODevice> signedData = signedData_.lock();
const _detail::ToThreadMover sgMover(signature, thread);
const _detail::ToThreadMover sdMover(signedData, thread);
QGpgME::QIODeviceDataProvider sigDP(signature);
Data sig(&sigDP);
QGpgME::QIODeviceDataProvider dataDP(signedData);
Data data(&dataDP);
const VerificationResult res = ctx->verifyDetachedSignature(sig, data);
Error ae;
const QString log = _detail::audit_log_as_html(ctx, ae);
return make_tuple(res, log, ae);
}
static QGpgMEVerifyDetachedJob::result_type verify_detached_qba(Context *ctx, const QByteArray &signature, const QByteArray &signedData)
{
QGpgME::QByteArrayDataProvider sigDP(signature);
Data sig(&sigDP);
QGpgME::QByteArrayDataProvider dataDP(signedData);
Data data(&dataDP);
const VerificationResult res = ctx->verifyDetachedSignature(sig, data);
Error ae;
const QString log = _detail::audit_log_as_html(ctx, ae);
return make_tuple(res, log, ae);
}
Error QGpgMEVerifyDetachedJob::start(const QByteArray &signature, const QByteArray &signedData)
{
run(bind(&verify_detached_qba, _1, signature, signedData));
return Error();
}
void QGpgMEVerifyDetachedJob::start(const shared_ptr<QIODevice> &signature, const shared_ptr<QIODevice> &signedData)
{
run(bind(&verify_detached, _1, _2, _3, _4), signature, signedData);
}
GpgME::VerificationResult QGpgME::QGpgMEVerifyDetachedJob::exec(const QByteArray &signature,
const QByteArray &signedData)
{
const result_type r = verify_detached_qba(context(), signature, signedData);
resultHook(r);
return mResult;
}
//PENDING(marc) implement showErrorDialog()
void QGpgME::QGpgMEVerifyDetachedJob::resultHook(const result_type &tuple)
{
mResult = get<0>(tuple);
}
+#include "qgpgmeverifydetachedjob.moc"
diff --git a/lang/qt/src/qgpgmeverifyopaquejob.cpp b/lang/qt/src/qgpgmeverifyopaquejob.cpp
index fd5b7088..fc5c1f2e 100644
--- a/lang/qt/src/qgpgmeverifyopaquejob.cpp
+++ b/lang/qt/src/qgpgmeverifyopaquejob.cpp
@@ -1,126 +1,127 @@
/*
qgpgmeverifyopaquejob.cpp
This file is part of qgpgme, the Qt API binding for gpgme
Copyright (c) 2004,2007,2008 Klarälvdalens Datakonsult AB
Copyright (c) 2016 Intevation GmbH
Libkleopatra is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
Libkleopatra is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
In addition, as a special exception, the copyright holders give
permission to link the code of this program with any edition of
the Qt library by Trolltech AS, Norway (or with modified versions
of Qt that use the same license as Qt), and distribute linked
combinations including the two. You must obey the GNU General
Public License in all respects for all of the code used other than
Qt. If you modify this file, you may extend this exception to
your version of the file, but you are not obligated to do so. If
you do not wish to do so, delete this exception statement from
your version.
*/
#include "qgpgmeverifyopaquejob.h"
#include "dataprovider.h"
#include "context.h"
#include "verificationresult.h"
#include "data.h"
#include <QBuffer>
#include <boost/weak_ptr.hpp>
#include <cassert>
using namespace QGpgME;
using namespace GpgME;
using namespace boost;
QGpgMEVerifyOpaqueJob::QGpgMEVerifyOpaqueJob(Context *context)
: mixin_type(context)
{
lateInitialization();
}
QGpgMEVerifyOpaqueJob::~QGpgMEVerifyOpaqueJob() {}
static QGpgMEVerifyOpaqueJob::result_type verify_opaque(Context *ctx, QThread *thread, const weak_ptr<QIODevice> &signedData_, const weak_ptr<QIODevice> &plainText_)
{
const shared_ptr<QIODevice> plainText = plainText_.lock();
const shared_ptr<QIODevice> signedData = signedData_.lock();
const _detail::ToThreadMover ptMover(plainText, thread);
const _detail::ToThreadMover sdMover(signedData, thread);
QGpgME::QIODeviceDataProvider in(signedData);
const Data indata(&in);
if (!plainText) {
QGpgME::QByteArrayDataProvider out;
Data outdata(&out);
const VerificationResult res = ctx->verifyOpaqueSignature(indata, outdata);
Error ae;
const QString log = _detail::audit_log_as_html(ctx, ae);
return make_tuple(res, out.data(), log, ae);
} else {
QGpgME::QIODeviceDataProvider out(plainText);
Data outdata(&out);
const VerificationResult res = ctx->verifyOpaqueSignature(indata, outdata);
Error ae;
const QString log = _detail::audit_log_as_html(ctx, ae);
return make_tuple(res, QByteArray(), log, ae);
}
}
static QGpgMEVerifyOpaqueJob::result_type verify_opaque_qba(Context *ctx, const QByteArray &signedData)
{
const shared_ptr<QBuffer> buffer(new QBuffer);
buffer->setData(signedData);
if (!buffer->open(QIODevice::ReadOnly)) {
assert(!"This should never happen: QBuffer::open() failed");
}
return verify_opaque(ctx, 0, buffer, shared_ptr<QIODevice>());
}
Error QGpgMEVerifyOpaqueJob::start(const QByteArray &signedData)
{
run(bind(&verify_opaque_qba, _1, signedData));
return Error();
}
void QGpgMEVerifyOpaqueJob::start(const shared_ptr<QIODevice> &signedData, const shared_ptr<QIODevice> &plainText)
{
run(bind(&verify_opaque, _1, _2, _3, _4), signedData, plainText);
}
GpgME::VerificationResult QGpgME::QGpgMEVerifyOpaqueJob::exec(const QByteArray &signedData, QByteArray &plainText)
{
const result_type r = verify_opaque_qba(context(), signedData);
plainText = get<1>(r);
resultHook(r);
return mResult;
}
//PENDING(marc) implement showErrorDialog()
void QGpgME::QGpgMEVerifyOpaqueJob::resultHook(const result_type &tuple)
{
mResult = get<0>(tuple);
}
+#include "qgpgmeverifyopaquejob.moc"
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Fri, Mar 14, 4:06 AM (1 d, 6 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
2b/a4/c9ce4c3d265ac0e020fe889340a2
Attached To
rM GPGME
Event Timeline
Log In to Comment