LCOV - code coverage report
Current view: top level - lang/cpp/src - global.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 2 0.0 %
Date: 2018-11-15 08:49:49 Functions: 0 1 0.0 %

          Line data    Source code
       1             : /*
       2             :   global.h - global gpgme functions and enums
       3             :   Copyright (C) 2003, 2007 Klarälvdalens Datakonsult AB
       4             :   2016 Bundesamt für Sicherheit in der Informationstechnik
       5             :   Software engineering by Intevation GmbH
       6             : 
       7             :   This file is part of GPGME++.
       8             : 
       9             :   GPGME++ is free software; you can redistribute it and/or
      10             :   modify it under the terms of the GNU Library General Public
      11             :   License as published by the Free Software Foundation; either
      12             :   version 2 of the License, or (at your option) any later version.
      13             : 
      14             :   GPGME++ is distributed in the hope that it will be useful,
      15             :   but WITHOUT ANY WARRANTY; without even the implied warranty of
      16             :   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      17             :   GNU Library General Public License for more details.
      18             : 
      19             :   You should have received a copy of the GNU Library General Public License
      20             :   along with GPGME++; see the file COPYING.LIB.  If not, write to the
      21             :   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
      22             :   Boston, MA 02110-1301, USA.
      23             : */
      24             : 
      25             : // -*- c++ -*-
      26             : #ifndef __GPGMEPP_GLOBAL_H__
      27             : #define __GPGMEPP_GLOBAL_H__
      28             : 
      29             : #include "gpgmefw.h"
      30             : #include "gpgmepp_export.h"
      31             : 
      32             : #include <iosfwd>
      33             : #include <cstring>
      34             : 
      35             : namespace GpgME
      36             : {
      37             : class Error;
      38             : class EngineInfo;
      39             : class Context;
      40             : }
      41             : 
      42             : struct _GIOChannel;
      43             : typedef struct _GIOChannel      GIOChannel;
      44             : class QIODevice;
      45             : 
      46             : namespace GpgME
      47             : {
      48             : 
      49             : GPGMEPP_EXPORT void initializeLibrary();
      50             : /*!
      51             :   Initializes the library, returns Error::code() ==
      52             :   GPG_ERR_USER_1 if underlying gpgme is too old.
      53             : */
      54             : GPGMEPP_EXPORT Error initializeLibrary(int);
      55             : 
      56             : enum Protocol { OpenPGP, CMS, UnknownProtocol };
      57             : 
      58             : enum Engine { GpgEngine, GpgSMEngine, GpgConfEngine, UnknownEngine, AssuanEngine, G13Engine, SpawnEngine };
      59             : 
      60             : enum KeyListMode {
      61             :     Local = 0x1,
      62             :     Extern = 0x2,
      63             :     Locate = 0x3,
      64             :     Signatures = 0x4,
      65             :     SignatureNotations = 0x8,
      66             :     Validate = 0x10,
      67             :     Ephemeral = 0x20,
      68             :     WithTofu = 0x40
      69             : };
      70             : 
      71             : enum SignatureMode { NormalSignatureMode, Detached, Clearsigned };
      72             : 
      73             : GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, Protocol proto);
      74             : GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, Engine eng);
      75             : GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, KeyListMode mode);
      76             : GPGMEPP_EXPORT std::ostream &operator<<(std::ostream &os, SignatureMode mode);
      77             : 
      78             : GPGMEPP_EXPORT Error setDefaultLocale(int category, const char *value);
      79             : 
      80             : GPGMEPP_EXPORT Context *wait(Error &e, bool hang = true);
      81             : typedef void (*IdleFunction)(void);
      82             : GPGMEPP_EXPORT IdleFunction registerIdleFunction(IdleFunction idleFunction);
      83             : 
      84             : typedef void (*IOCallback)(void *data, int fd);
      85             : 
      86             : GPGMEPP_EXPORT EngineInfo engineInfo(Protocol proto);
      87             : GPGMEPP_EXPORT EngineInfo engineInfo(Engine engine);
      88             : /** Wrapper around gpgme_get_dirinfo. What can be:
      89             : homedir, sysconfdir, bindir, libexecdir, libdir,
      90             : datadir, localedir, agent-socket, agent-ssh-socket,
      91             : dirmngr-socket, uiserver-socket, gpgconf-name, gpg-name,
      92             : gpgsm-name, g13-name
      93             : 
      94             : This may be extended in the future.
      95             : */
      96             : GPGMEPP_EXPORT const char *dirInfo(const char *what);
      97             : 
      98             : GPGMEPP_EXPORT Error checkEngine(Protocol proto);
      99             : GPGMEPP_EXPORT Error checkEngine(Engine engine);
     100             : 
     101             : GPGMEPP_EXPORT GIOChannel *getGIOChannel(int fd);
     102             : GPGMEPP_EXPORT QIODevice   *getQIODevice(int fd);
     103             : 
     104             : enum Feature {
     105             :     ValidatingKeylistModeFeature               = 0x00000001,
     106             :     CancelOperationFeature                     = 0x00000002,
     107             :     WrongKeyUsageFeature                       = 0x00000004,
     108             :     DefaultCertificateInclusionFeature         = 0x00000008,
     109             : 
     110             :     GetSetEngineInfoFeature                    = 0x00000010,
     111             :     EngineInfoHomeDirFeature                   = 0x00000020,
     112             :     NoEncryptToEncryptionFlagFeature           = 0x00000040,
     113             :     EphemeralKeylistModeFeature                = 0x00000080,
     114             : 
     115             :     SetDataFileNameFeeature                    = 0x00000100,
     116             :     VerificationResultFileNameFeature          = 0x00000200,
     117             :     DecryptionResultFileNameFeature            = 0x00000400,
     118             :     DecryptionResultRecipientsFeature          = 0x00000800,
     119             : 
     120             :     AuditLogFeature                            = 0x00001000,
     121             :     GpgConfEngineFeature                       = 0x00002000,
     122             :     CancelOperationAsyncFeature                = 0x00004000,
     123             :     AssuanEngineFeature                        = 0x00008000,
     124             : 
     125             :     ClearAddGetSignatureNotationsFeature       = 0x00010000,
     126             :     SignatureNotationsKeylistModeFeature       = 0x00020000,
     127             :     KeySignatureNotationsFeature               = 0x00040000,
     128             :     SignatureNotationsFlagsFeature             = 0x00080000,
     129             :     SignatureNotationsCriticalFlagFeature      = 0x00100000,
     130             :     SignatureNotationsHumanReadableFlagFeature = 0x00200000,
     131             :     CardKeyFeature                             = 0x00400000,
     132             :     ImportFromKeyserverFeature                 = 0x00800000,
     133             : 
     134             :     KeyIsQualifiedFeature                      = 0x01000200,
     135             :     SubkeyIsQualifiedFeature                   = 0x02000000,
     136             :     SignaturePkaFieldsFeature                  = 0x04000000,
     137             :     SignatureAlgorithmFieldsFeature            = 0x08000000,
     138             : 
     139             :     FdPointerFeature                           = 0x10000000,
     140             :     G13VFSFeature                              = 0x20000000,
     141             :     PasswdFeature                              = 0x40000000, // gpgme >= 1.3.0
     142             :     // unusable (max value)
     143             : 
     144             :     FeatureMaxValue                            = 0x80000000
     145             : };
     146             : enum Feature2 {
     147             :     BinaryAndFineGrainedIdentify               = 0x00000001, // gpgme >= 1.7.0
     148             :     Feature2MaxValue                           = 0x80000000
     149             : };
     150             : 
     151             : // use hasFeature( unsigned long, unsigned long ) instead
     152             : GPGMEPP_DEPRECATED_EXPORT bool hasFeature(unsigned long feature);
     153             : GPGMEPP_EXPORT bool hasFeature(unsigned long feature, unsigned long feature2);
     154             : 
     155             : } // namespace GpgME
     156             : 
     157             : # ifndef GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION
     158             : #  define GPGMEPP_MAKE_STD_SWAP_SPECIALIZATION( Class ) \
     159             :     namespace std { template <> inline void swap< GpgME::Class >( GpgME::Class & lhs, GpgME::Class & rhs ) { lhs.swap( rhs ); } }
     160             : # endif
     161             : 
     162             : # ifndef GPGMEPP_MAKE_SAFE_BOOL_OPERATOR
     163             : #  define GPGMEPP_MAKE_SAFE_BOOL_OPERATOR( Cond ) \
     164             :     private: \
     165             :     struct __safe_bool_dummy__ { void nonnull() {} }; \
     166             :     typedef void ( __safe_bool_dummy__::*unspecified_bool_type )(); \
     167             :     public: \
     168             :     operator unspecified_bool_type() const { return ( Cond ) ? &__safe_bool_dummy__::nonnull : 0 ; }
     169             : # endif
     170             : 
     171           0 : inline int _gpgmepp_strcmp(const char *s1, const char *s2)
     172             : {
     173           0 :     return s1 ? s2 ? std::strcmp(s1, s2) : 1 : s2 ? -1 : 0;
     174             : }
     175             : 
     176             : #define _GPGMEPP_MAKE_STRCMP( Name, expr, cmp )                     \
     177             :     template <template <typename U> class Op>                           \
     178             :     struct Name {                                                       \
     179             :         typedef bool result_type;                                       \
     180             :         \
     181             :         bool operator()( const char * lhs, const char * rhs ) const {   \
     182             :             return Op<int>()( cmp, 0 );                                 \
     183             :         }                                                               \
     184             :         \
     185             :         bool operator()( const std::string & lhs, const std::string & rhs ) const { \
     186             :             return operator()( lhs.c_str(), rhs.c_str() );              \
     187             :         }                                                               \
     188             :         bool operator()( const char * lhs, const std::string & rhs ) const { \
     189             :             return operator()( lhs, rhs.c_str() );                      \
     190             :         }                                                               \
     191             :         bool operator()( const std::string & lhs, const char * rhs ) const { \
     192             :             return operator()( lhs.c_str(), rhs );                      \
     193             :         }                                                               \
     194             :         \
     195             :         template <typename T>                                           \
     196             :         bool operator()( const T & lhs, const T & rhs ) const {         \
     197             :             return operator()( (lhs expr), (rhs expr) );                \
     198             :         }                                                               \
     199             :         template <typename T>                                           \
     200             :         bool operator()( const T & lhs, const char * rhs ) const {      \
     201             :             return operator()( (lhs expr), rhs );                       \
     202             :         }                                                               \
     203             :         template <typename T>                                           \
     204             :         bool operator()( const char * lhs, const T & rhs ) const {      \
     205             :             return operator()( lhs, (rhs expr) );                       \
     206             :         }                                                               \
     207             :         template <typename T>                                           \
     208             :         bool operator()( const T & lhs, const std::string & rhs ) const { \
     209             :             return operator()( (lhs expr), rhs );                       \
     210             :         }                                                               \
     211             :         template <typename T>                                           \
     212             :         bool operator()( const std::string & lhs, const T & rhs ) const {    \
     213             :             return operator()( lhs, (rhs expr) );                       \
     214             :         }                                                               \
     215             :     }
     216             : 
     217             : #define GPGMEPP_MAKE_STRCMP( Name, expr )                          \
     218             :     _GPGMEPP_MAKE_STRCMP( Name, expr, _gpgmepp_strcmp( lhs, rhs ) )
     219             : 
     220             : 
     221             : #endif // __GPGMEPP_GLOBAL_H__

Generated by: LCOV version 1.13