libkdenetwork Library API Documentation

decryptionresult.cpp

00001 /* decryptionresult.cpp - wraps a gpgme keygen result
00002    Copyright (C) 2004 Klarälvdalens Datakonsult AB
00003 
00004    This file is part of GPGME++.
00005  
00006    GPGME++ is free software; you can redistribute it and/or modify it
00007    under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010  
00011    GPGME++ is distributed in the hope that it will be useful, but
00012    WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    General Public License for more details.
00015 
00016    You should have received a copy of the GNU General Public License
00017    along with GPGME++; if not, write to the Free Software Foundation,
00018    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA.
00019 */
00020 
00021 #ifdef HAVE_CONFIG_H
00022 #include <config.h>
00023 #endif
00024 
00025 #include <gpgmepp/decryptionresult.h>
00026 #include "shared.h"
00027 #include "result_p.h"
00028 
00029 #include <gpgme.h>
00030 
00031 #include <cstring>
00032 #include <cstdlib>
00033 
00034 class GpgME::DecryptionResult::Private : public GpgME::Shared {
00035 public:
00036   Private( const _gpgme_op_decrypt_result & r ) : Shared(), res( r ) {
00037     if ( res.unsupported_algorithm )
00038       res.unsupported_algorithm = strdup( res.unsupported_algorithm );
00039   }
00040   ~Private() {
00041     if ( res.unsupported_algorithm )
00042       std::free( res.unsupported_algorithm );
00043     res.unsupported_algorithm = 0;
00044   }
00045 
00046   _gpgme_op_decrypt_result res;
00047 };
00048 
00049 GpgME::DecryptionResult::DecryptionResult( gpgme_ctx_t ctx, int error )
00050   : GpgME::Result( error ), d( 0 )
00051 {
00052   if ( error || !ctx )
00053     return;
00054   gpgme_decrypt_result_t res = gpgme_op_decrypt_result( ctx );
00055   if ( !res )
00056     return;
00057   d = new Private( *res );
00058   d->ref();
00059 }
00060 
00061 make_standard_stuff(DecryptionResult)
00062 
00063 const char * GpgME::DecryptionResult::unsupportedAlgortihm() const {
00064   return d ? d->res.unsupported_algorithm : 0 ;
00065 }
00066 
00067 bool GpgME::DecryptionResult::wrongKeyUsage() const {
00068 #ifdef HAVE_GPGME_WRONG_KEY_USAGE
00069   if ( d )
00070     return d->res.wrong_key_usage;
00071 #endif
00072   return false;
00073 }
KDE Logo
This file is part of the documentation for libkdenetwork Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Oct 4 14:39:09 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003