Blame lang/cpp/README

Packit d7e8d0
GpgMEpp - C++ bindings/wrapper for GPGME
Packit d7e8d0
----------------------------------------
Packit d7e8d0
Based on KF5gpgmepp
Packit d7e8d0
Packit d7e8d0
Overview
Packit d7e8d0
--------
Packit d7e8d0
Packit d7e8d0
GpgMEpp is a C++ wrapper (or C++ bindings) for the GnuPG project's
Packit d7e8d0
gpgme (GnuPG Made Easy) library, version 0.4.4 and later.
Packit d7e8d0
Packit d7e8d0
It is fairly complete, with some minor things still missing (in
Packit d7e8d0
particular, the key edit interface).
Packit d7e8d0
Packit d7e8d0
The design principles of this library are as follows:
Packit d7e8d0
Packit d7e8d0
1. A value-based interface (most clases are implicitly shared)
Packit d7e8d0
2. Callbacks are replaced by C++ interfaces (classes with only
Packit d7e8d0
   abstract methods).
Packit d7e8d0
3. No exceptions are thrown
Packit d7e8d0
4. There is (as yet) no explicit support for multi-threaded use
Packit d7e8d0
   (other than what gpgme itself provides; most notably the
Packit d7e8d0
   refcounting for implicit sharing is not thread-safe)
Packit d7e8d0
5. To avoid binary incompatible interface changes, we make
Packit d7e8d0
   extensive use of the d-pointer pattern and avoid virtual
Packit d7e8d0
   methods; any polymorphism present is already provided by gpgme
Packit d7e8d0
   itself, anyway (see e.g. Data). A notable exception of the
Packit d7e8d0
   no-virtuals rule is the use of abstract classes to cover
Packit d7e8d0
   C-callbacks.
Packit d7e8d0
6. Use of STL containers for improved memory management and
Packit d7e8d0
   dealing with lists.
Packit d7e8d0
7. Complete abstraction of the C-API so "gpgme.h" should not
Packit d7e8d0
   be needed in your project using GpgME++.
Packit d7e8d0
8. Abstraction of GnuPG's edit-key interface by prepared
Packit d7e8d0
   Editinteractor classes.
Packit d7e8d0
Packit d7e8d0
GpgMEpp was originally developed as part of the KDEPIM community.
Packit d7e8d0
Packit d7e8d0
Usage
Packit d7e8d0
-----
Packit d7e8d0
Packit d7e8d0
The usage pattern of GpgMEpp closely follows GPGMEs core usage
Packit d7e8d0
pattern so the documentation for GPGME itself provides a good
Packit d7e8d0
way to start.
Packit d7e8d0
Packit d7e8d0
The context structure in GPGME is mapped to a Context object in
Packit d7e8d0
GpgMEpp. Additional convienience code provides Data objects and
Packit d7e8d0
a Dataprovider interface that can be used to implement GPGME's
Packit d7e8d0
data with any subclass by implementing the right callbacks.
Packit d7e8d0
Packit d7e8d0
EditInteractor subclasses provide ready to use classes for
Packit d7e8d0
common --edit-key tasks. You can implement your own editinteractor
Packit d7e8d0
classes by implementing the EditInteractor interface and using
Packit d7e8d0
your subclass as an interactor in the edit function.
Packit d7e8d0
Packit d7e8d0
Example to set the ownertrust of a key:
Packit d7e8d0
Packit d7e8d0
    /* Create an edit interactor */
Packit d7e8d0
    EditInteractor *ei = new GpgSetOwnerTrustEditInteractor(Key::Ultimate);
Packit d7e8d0
    /* Obtain a Context */
Packit d7e8d0
    Context *ctx = Context::createForProtocol(Protocol::OpenPGP);
Packit d7e8d0
    /* Create an in memory data object */
Packit d7e8d0
    Data data;
Packit d7e8d0
    /* Start the edit on some key previously obtained. */
Packit d7e8d0
    Error e = ctx->edit(key, std::unique_ptr<EditInteractor>(ei), data);
Packit d7e8d0
    /* Errors provide boolean comparison */
Packit d7e8d0
    if (!e)
Packit d7e8d0
        ...
Packit d7e8d0
    /* Delete the context */
Packit d7e8d0
    delete ctx;
Packit d7e8d0
Packit d7e8d0
Examples / Tests
Packit d7e8d0
----------------
Packit d7e8d0
Packit d7e8d0
GpgMEpp is tested through the Qt API. You can refer to the
Packit d7e8d0
tests in qt/tests for examples of usage or refer to
Packit d7e8d0
the actual QGpgME*Job.cpp implementations which rely
Packit d7e8d0
on GpgMEpp and should cover most use cases.
Packit d7e8d0
Packit d7e8d0
Hacking
Packit d7e8d0
-------
Packit d7e8d0
Packit d7e8d0
GpgMEpp follows KDE Coding styles. See:
Packit d7e8d0
https://techbase.kde.org/Policies/Frameworks_Coding_Style
Packit d7e8d0
for more info.
Packit d7e8d0
Packit d7e8d0
License
Packit d7e8d0
-------
Packit d7e8d0
GPGMEpp is free software; you can redistribute it and/or
Packit d7e8d0
modify it under the terms of the GNU Library General Public
Packit d7e8d0
License as published by the Free Software Foundation; either
Packit d7e8d0
version 2 of the License, or (at your option) any later version.
Packit d7e8d0
Packit d7e8d0
GPGMEpp is distributed in the hope that it will be useful,
Packit d7e8d0
but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit d7e8d0
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit d7e8d0
GNU Library General Public License for more details.
Packit d7e8d0
Packit d7e8d0
You should have received a copy of the GNU Library General Public License
Packit d7e8d0
along with GPGME++; see the file COPYING.LIB.  If not, write to the
Packit d7e8d0
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Packit d7e8d0
Boston, MA 02110-1301, USA.