diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2011-11-16 16:06:07 -0600 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2011-11-16 16:06:07 -0600 |
commit | be0ca741fd12897337408d1d7a7d8f5f18e1fac9 (patch) | |
tree | b9fa3458193a17180d8773a0204ee05ae206cd99 /libkdenetwork/gpgmepp/importresult.cpp | |
parent | bbb7afdb6da2969535e7f05715e2cb95cfdc917c (diff) | |
download | tdepim-be0ca741fd12897337408d1d7a7d8f5f18e1fac9.tar.gz tdepim-be0ca741fd12897337408d1d7a7d8f5f18e1fac9.zip |
Finish rename from prior commit
Diffstat (limited to 'libkdenetwork/gpgmepp/importresult.cpp')
-rw-r--r-- | libkdenetwork/gpgmepp/importresult.cpp | 204 |
1 files changed, 0 insertions, 204 deletions
diff --git a/libkdenetwork/gpgmepp/importresult.cpp b/libkdenetwork/gpgmepp/importresult.cpp deleted file mode 100644 index 3b4b713c7..000000000 --- a/libkdenetwork/gpgmepp/importresult.cpp +++ /dev/null @@ -1,204 +0,0 @@ -/* importresult.cpp - wraps a gpgme import result - Copyright (C) 2004 Klarälvdalens Datakonsult AB - - This file is part of GPGME++. - - GPGME++ is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - GPGME++ is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GPGME++; if not, write to the Free Software Foundation, - Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gpgmepp/importresult.h> -#include "shared.h" -#include "result_p.h" - -#include <gpgme.h> -#include <cstring> -#include <cstdlib> -#include <cstdlib> - -class GpgME::ImportResult::Private : public GpgME::Shared { -public: - Private( const _gpgme_op_import_result & r ) : Shared(), res( r ) { - // copy recursively, using compiler-generated copy ctor. - // We just need to handle the pointers in the structs: - for ( gpgme_import_status_t is = r.imports ; is ; is = is->next ) { - gpgme_import_status_t copy = new _gpgme_import_status( *is ); - copy->fpr = strdup( is->fpr ); - copy->next = 0; - imports.push_back( copy ); - } - res.imports = 0; - } - ~Private() { - for ( std::vector<gpgme_import_status_t>::iterator it = imports.begin() ; it != imports.end() ; ++it ) { - std::free( (*it)->fpr ); - delete *it; *it = 0; - } - } - - _gpgme_op_import_result res; - std::vector<gpgme_import_status_t> imports; -}; - -GpgME::ImportResult::ImportResult( gpgme_ctx_t ctx, int error ) - : GpgME::Result( error ), d( 0 ) -{ - if ( error || !ctx ) - return; - gpgme_import_result_t res = gpgme_op_import_result( ctx ); - if ( !res ) - return; - d = new Private( *res ); - d->ref(); -} - -make_standard_stuff(ImportResult) - -int GpgME::ImportResult::numConsidered() const { - return d ? d->res.considered : 0 ; -} - -int GpgME::ImportResult::numKeysWithoutUserID() const { - return d ? d->res.no_user_id : 0 ; -} - -int GpgME::ImportResult::numImported() const { - return d ? d->res.imported : 0 ; -} - -int GpgME::ImportResult::numRSAImported() const { - return d ? d->res.imported_rsa : 0 ; -} - -int GpgME::ImportResult::numUnchanged() const { - return d ? d->res.unchanged : 0 ; -} - -int GpgME::ImportResult::newUserIDs() const { - return d ? d->res.new_user_ids : 0 ; -} - -int GpgME::ImportResult::newSubkeys() const { - return d ? d->res.new_sub_keys : 0 ; -} - -int GpgME::ImportResult::newSignatures() const { - return d ? d->res.new_signatures : 0 ; -} - -int GpgME::ImportResult::newRevocations() const { - return d ? d->res.new_revocations : 0 ; -} - -int GpgME::ImportResult::numSecretKeysConsidered() const { - return d ? d->res.secret_read : 0 ; -} - -int GpgME::ImportResult::numSecretKeysImported() const { - return d ? d->res.secret_imported : 0 ; -} - -int GpgME::ImportResult::numSecretKeysUnchanged() const { - return d ? d->res.secret_unchanged : 0 ; -} - -int GpgME::ImportResult::notImported() const { - return d ? d->res.not_imported : 0 ; -} - -GpgME::Import GpgME::ImportResult::import( unsigned int idx ) const { - return Import( d, idx ); -} - -std::vector<GpgME::Import> GpgME::ImportResult::imports() const { - if ( !d ) - return std::vector<Import>(); - std::vector<Import> result; - result.reserve( d->imports.size() ); - for ( unsigned int i = 0 ; i < d->imports.size() ; ++i ) - result.push_back( Import( d, i ) ); - return result; -} - - - - - - -GpgME::Import::Import( ImportResult::Private * parent, unsigned int i ) - : d( parent ), idx( i ) -{ - if ( d ) - d->ref(); -} - -GpgME::Import::Import() : d( 0 ), idx( 0 ) {} - -GpgME::Import::Import( const Import & other ) - : d( other.d ), idx( other.idx ) -{ - if ( d ) - d->ref(); -} - -GpgME::Import::~Import() { - if ( d ) - d->unref(); -} - -const GpgME::Import & GpgME::Import::operator=( const Import & other ) { - if ( this->d != other.d ) { - if ( other.d ) - other.d->ref(); - if ( this->d ) - this->d->unref(); - this->d = other.d; - } - - this->idx = other.idx; - return *this; -} - - -bool GpgME::Import::isNull() const { - return !d || idx >= d->imports.size() ; -} - - - - -const char * GpgME::Import::fingerprint() const { - return isNull() ? 0 : d->imports[idx]->fpr ; -} - -GpgME::Error GpgME::Import::error() const { - return isNull() ? 0 : d->imports[idx]->result ; -} - -GpgME::Import::tqStatus GpgME::Import::status() const { - if ( isNull() ) - return Unknown; - unsigned int s = d->imports[idx]->status; - unsigned int result = Unknown; - if ( s & GPGME_IMPORT_NEW ) result |= NewKey; - if ( s & GPGME_IMPORT_UID ) result |= NewUserIDs; - if ( s & GPGME_IMPORT_SIG ) result |= NewSignatures; - if ( s & GPGME_IMPORT_SUBKEY ) result |= NewSubkeys; - if ( s & GPGME_IMPORT_SECRET ) result |= ContainedSecretKey; - return static_cast<tqStatus>( result ); -} |