libkdenetwork Library API Documentation

engineinfo.cpp

00001 /* engineinfo.h
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 "engineinfo.h"
00026 #include "shared.h"
00027 
00028 #include <gpgme.h>
00029 
00030 struct GpgME::EngineInfo::Private : public GpgME::Shared {
00031   Private( gpgme_engine_info_t engine=0 ) : Shared(), info( engine ) {}
00032   ~Private() { info = 0; }
00033 
00034   gpgme_engine_info_t info;
00035 };
00036 
00037 
00038 GpgME::EngineInfo::EngineInfo() : d(0) {}
00039 
00040 GpgME::EngineInfo::EngineInfo( gpgme_engine_info_t engine )
00041   : d(0)
00042 {
00043   d = new Private( engine );
00044   d->ref();
00045 }
00046 
00047 GpgME::EngineInfo::EngineInfo( const EngineInfo & other )
00048   : d( other.d )
00049 {
00050   if ( d )
00051     d->ref();
00052 }
00053 
00054 
00055 GpgME::EngineInfo::~EngineInfo() {
00056   if ( d )
00057     d->deref();
00058 }
00059 
00060 const GpgME::EngineInfo & GpgME::EngineInfo::operator=( const GpgME::EngineInfo & other ) {
00061   if ( this->d == other.d )
00062     return *this;
00063 
00064   if ( other.d )
00065     other.d->ref();
00066   if ( this->d )
00067     this->d->unref();
00068 
00069   this->d = other.d;
00070   return *this;
00071 }
00072 
00073 bool GpgME::EngineInfo::isNull() const {
00074   return !d || !d->info;
00075 }
00076 
00077 GpgME::Context::Protocol GpgME::EngineInfo::protocol() const {
00078   if ( isNull() )
00079     return Context::Unknown;
00080   switch( d->info->protocol ) {
00081   case GPGME_PROTOCOL_OpenPGP: return Context::OpenPGP;
00082   case GPGME_PROTOCOL_CMS:     return Context::CMS;
00083   default:
00084     return Context::Unknown;
00085   }
00086 }
00087 
00088 const char * GpgME::EngineInfo::fileName() const {
00089   return isNull() ? 0 : d->info->file_name;
00090 }
00091 
00092 const char * GpgME::EngineInfo::version() const {
00093   return isNull() ? 0 : d->info->version;
00094 }
00095 
00096 const char * GpgME::EngineInfo::requiredVersion() const {
00097   return isNull() ? 0 : d->info->req_version;
00098 }
00099 
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 Wed Oct 17 09:52:20 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003