gpgmepp/util.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __GPGMEPP_UTIL_H__
00022 #define __GPGMEPP_UTIL_H__
00023
00024 #include <gpgme.h>
00025 #include <context.h>
00026
00027 #ifndef NDEBUG
00028 #include <iostream>
00029 #endif
00030
00031 static inline gpgme_keylist_mode_t add_to_gpgme_keylist_mode_t( unsigned int oldmode, unsigned int newmodes ) {
00032 if ( newmodes & GpgME::Context::Local ) oldmode |= GPGME_KEYLIST_MODE_LOCAL;
00033 if ( newmodes & GpgME::Context::Extern ) oldmode |= GPGME_KEYLIST_MODE_EXTERN;
00034 if ( newmodes & GpgME::Context::Signatures ) oldmode |= GPGME_KEYLIST_MODE_SIGS;
00035 if ( newmodes & GpgME::Context::Validate ) {
00036 #ifdef HAVE_GPGME_KEYLIST_MODE_VALIDATE
00037 oldmode |= GPGME_KEYLIST_MODE_VALIDATE;
00038 #elif !defined(NDEBUG)
00039 std::cerr << "GpgME::Context: ignoring Valdidate keylist flag (gpgme too old)." << std::endl;
00040 #endif
00041 }
00042 #ifndef NDEBUG
00043 if ( newmodes & ~(GpgME::Context::Local|GpgME::Context::Extern|GpgME::Context::Signatures|GpgME::Context::Validate) )
00044 std::cerr << "GpgME::Context: keylist mode must be one of Local, "
00045 "Extern, Signatures, or Validate, or a combination thereof!" << std::endl;
00046 #endif
00047 return static_cast<gpgme_keylist_mode_t>( oldmode );
00048 }
00049
00050 static inline unsigned int convert_from_gpgme_keylist_mode_t( unsigned int mode ) {
00051 unsigned int result = 0;
00052 if ( mode & GPGME_KEYLIST_MODE_LOCAL ) result |= GpgME::Context::Local;
00053 if ( mode & GPGME_KEYLIST_MODE_EXTERN ) result |= GpgME::Context::Extern;
00054 if ( mode & GPGME_KEYLIST_MODE_SIGS ) result |= GpgME::Context::Signatures;
00055 #ifdef HAVE_GPGME_KEYLIST_MODE_VALIDATE
00056 if ( mode & GPGME_KEYLIST_MODE_VALIDATE ) result |= GpgME::Context::Validate;
00057 #endif
00058 #ifndef NDEBUG
00059 if ( mode & ~(GPGME_KEYLIST_MODE_LOCAL|
00060 GPGME_KEYLIST_MODE_EXTERN|
00061 #ifdef HAVE_GPGME_KEYLIST_MODE_VALIDATE
00062 GPGME_KEYLIST_MODE_VALIDATE|
00063 #endif
00064 GPGME_KEYLIST_MODE_SIGS) )
00065 std::cerr << "GpgME::Context: WARNING: gpgme_get_keylist_mode() returned an unknown flag!" << std::endl;
00066 #endif // NDEBUG
00067 return result;
00068 }
00069
00070
00071 #endif // __GPGMEPP_UTIL_H__
This file is part of the documentation for libkdenetwork Library Version 3.3.2.