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

Generated by: LCOV version 1.11