Blame lang/qt/README

Packit Service 672cf4
Qt API bindings/wrapper for GPGME
Packit Service 672cf4
---------------------------------
Packit Service 672cf4
Based on KF5gpgmepp QGpgME and libkleo/backends/qgpgme
Packit Service 672cf4
Packit Service 672cf4
Please note that QGpgME has a different license (GPL only)
Packit Service 6c01f9
then GPGME itself. See the License secion in this
Packit Service 672cf4
document for more information.
Packit Service 672cf4
Packit Service 672cf4
Overview
Packit Service 672cf4
--------
Packit Service 672cf4
QGpgme provides a very high level Qt API around GpgMEpp.
Packit Service 672cf4
As such it depends on GpgMEpp additionally to GpgME.
Packit Service 672cf4
Packit Service 672cf4
There are two general concepts in QGpgME. Data abstraction
Packit Service 672cf4
through GpgMEpp's Dataprovider interface and the Job pattern.
Packit Service 672cf4
Packit Service 672cf4
Data can be provided with QByteArrayDataProvider or
Packit Service 672cf4
QIODeviceDataProvider which can be constructed from their
Packit Service 672cf4
respective types. This means you can pass a QFile, QProcess,
Packit Service 672cf4
QString, etc.. directly to GPGME.
Packit Service 672cf4
Packit Service 672cf4
To provide a stable API / ABI and because of historic reasons
Packit Service 672cf4
in libkleo (Where QGpgME was originally developed as an abstract
Packit Service 672cf4
crypto backend) QGpgME only provides abstract interfaces as
Packit Service 672cf4
public API while the actual implementation happens in the
Packit Service 672cf4
private QGpgME prefixed classes.
Packit Service 672cf4
Packit Service 672cf4
Usage
Packit Service 672cf4
-----
Packit Service 672cf4
Packit Service 672cf4
To use QGpgME first you need to obtain a Protocol class
Packit Service 672cf4
either for CMS (S/MIME) or OpenPGP. This Protocol class
Packit Service 672cf4
can then be used to create a Job.
Packit Service 672cf4
Packit Service 672cf4
Each Job can be started asynchronusly and emits a result
Packit Service 672cf4
signal when done. The jobs are deleted automatically
Packit Service 672cf4
with QObject::deleteLater so they can be started without
Packit Service 672cf4
result handlers.
Packit Service 672cf4
Packit Service 672cf4
The result signal provides a tuple of objects with the
Packit Service 672cf4
appropriate result information for this job. For historic
Packit Service 672cf4
reasons each result signal also includes an AuditLog
Packit Service 672cf4
and an AuditLog Error. These are only useful for
Packit Service 672cf4
S/MIME signature validation but are part of other jobs
Packit Service 672cf4
for API stability reasons.
Packit Service 672cf4
Packit Service 672cf4
Some jobs like the verification or decryption jobs have
Packit Service 672cf4
dedicated result classes. Each result class at least
Packit Service 672cf4
has the member function error() that can be used
Packit Service 6c01f9
to check if a job failed. Additionally errors are emited
Packit Service 672cf4
in the result signal.
Packit Service 672cf4
Packit Service 672cf4
Jobs also provide progress signal whenever GnuPG emits
Packit Service 672cf4
a progress status line.
Packit Service 672cf4
Packit Service 672cf4
Most jobs also provide a way synchronusly execute them.
Packit Service 6c01f9
Please not that synchronus use does not cause the autodeletion
Packit Service 672cf4
to take place so you have to manually delete them.
Packit Service 672cf4
Packit Service 672cf4
Async usage:
Packit Service 672cf4
Packit Service 672cf4
    /* Create a job */
Packit Service 672cf4
    EncryptJob *job = openpgp()->encryptJob(/*ASCII Armor */false, /* Textmode */ false);
Packit Service 672cf4
    /* Connect something to the result signal */
Packit Service 672cf4
    connect(job, &EncryptJob::result, this, [] (const GpgME::EncryptionResult &result,
Packit Service 672cf4
                                                const QByteArray &cipherText,
Packit Service 672cf4
                                                const QString,
Packit Service 672cf4
                                                const GpgME::Error) {
Packit Service 672cf4
        /* Handle the result / do something with the ciphertext */
Packit Service 672cf4
     });
Packit Service 672cf4
    /* Start the job */
Packit Service 672cf4
    job->start(keys, inptr, outptr, Context::AlwaysTrust);
Packit Service 672cf4
    /* Do not delete the job as it is autodeleted. */
Packit Service 672cf4
Packit Service 672cf4
Synchronous usage:
Packit Service 672cf4
Packit Service 672cf4
    /* Create a job */
Packit Service 672cf4
    KeyListJob *listjob = openpgp()->keyListJob(false, false, false);
Packit Service 672cf4
    /* Prepare result vector */
Packit Service 672cf4
    std::vector<Key> keys;
Packit Service 672cf4
    /* Execute it synchronusly */
Packit Service 672cf4
    KeyListResult result = listjob->exec(QStringList() << QStringLiteral("alfa@example.net"),
Packit Service 672cf4
                                         false, keys);
Packit Service 672cf4
    /* Delete the job */
Packit Service 672cf4
    delete listjob;
Packit Service 672cf4
    /* Work with the result */
Packit Service 672cf4
Packit Service 672cf4
See the generated documentation for more info on the classes
Packit Service 672cf4
in QGpgME. (Subdir doc)
Packit Service 672cf4
Packit Service 672cf4
Examples / Tests
Packit Service 672cf4
----------------
Packit Service 672cf4
Packit Service 672cf4
The tests in the tests subdir can be used to get a better
Packit Service 672cf4
idea of QGpgME's usage. They also serve to test the C++
Packit Service 672cf4
API. Kleopatra and KMails Messagelib also make extensive
Packit Service 672cf4
use of QGpgME and can be used as further examples.
Packit Service 672cf4
Packit Service 672cf4
Hacking
Packit Service 672cf4
-------
Packit Service 672cf4
QGpgME comes from a KDE background. As such it does not use
Packit Service 672cf4
GNU Coding styles but KDE Coding styles. See:
Packit Service 672cf4
https://techbase.kde.org/Policies/Frameworks_Coding_Style
Packit Service 672cf4
Packit Service 672cf4
License
Packit Service 672cf4
-------
Packit Service 672cf4
QGpgME is free software; you can redistribute it and/or
Packit Service 672cf4
modify it under the terms of the GNU General Public License as
Packit Service 672cf4
published by the Free Software Foundation; either version 2 of the
Packit Service 672cf4
License, or (at your option) any later version.
Packit Service 672cf4
Packit Service 672cf4
QGpgME is distributed in the hope that it will be useful,
Packit Service 672cf4
but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 672cf4
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 672cf4
General Public License for more details.
Packit Service 672cf4
Packit Service 672cf4
You should have received a copy of the GNU General Public License
Packit Service 672cf4
along with this program; if not, write to the Free Software
Packit Service 672cf4
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
Packit Service 672cf4
Packit Service 672cf4
In addition, as a special exception, the copyright holders give
Packit Service 672cf4
permission to link the code of this program with any edition of
Packit Service 672cf4
the Qt library by Trolltech AS, Norway (or with modified versions
Packit Service 672cf4
of Qt that use the same license as Qt), and distribute linked
Packit Service 672cf4
combinations including the two.  You must obey the GNU General
Packit Service 672cf4
Public License in all respects for all of the code used other than
Packit Service 672cf4
Qt.  If you modify this file, you may extend this exception to
Packit Service 672cf4
your version of the file, but you are not obligated to do so.  If
Packit Service 672cf4
you do not wish to do so, delete this exception statement from
Packit Service 672cf4
your version.