libkdenetwork Library API Documentation

keylistresult.cpp

00001 /* keylistresult.cpp - wraps a gpgme keylist 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/keylistresult.h>
00026 #include "shared.h"
00027 #include "result_p.h"
00028 
00029 #include <gpgme.h>
00030 
00031 #include <cstring>
00032 
00033 class GpgME::KeyListResult::Private : public GpgME::Shared {
00034 public:
00035   Private( const _gpgme_op_keylist_result & r ) : Shared(), res( r ) {}
00036   Private( const Private & other ) : Shared(), res( other.res ) {}
00037 
00038   _gpgme_op_keylist_result res;
00039 };
00040 
00041 GpgME::KeyListResult::KeyListResult( gpgme_ctx_t ctx, int error )
00042   : GpgME::Result( error ), d( 0 )
00043 {
00044   if ( error || !ctx )
00045     return;
00046   gpgme_keylist_result_t res = gpgme_op_keylist_result( ctx );
00047   if ( !res )
00048     return;
00049   d = new Private( *res );
00050   d->ref();
00051 }
00052 
00053 GpgME::KeyListResult::KeyListResult( const Error & error, const _gpgme_op_keylist_result & res )
00054   : GpgME::Result( error ), d( 0 )
00055 {
00056   d = new Private( res );
00057   d->ref();
00058 }
00059 
00060 make_standard_stuff(KeyListResult)
00061 
00062 void GpgME::KeyListResult::detach() {
00063   if ( isNull() || d->refCount() <= 1 )
00064     return;
00065   d->unref();
00066   d = new Private( *d );
00067 }
00068 
00069 void GpgME::KeyListResult::mergeWith( const KeyListResult & other ) {
00070   if ( other.isNull() )
00071     return;
00072   if ( isNull() ) { // just assign
00073     operator=( other );
00074     return;
00075   }
00076   // merge the truncated flag (try to keep detaching to a minimum):
00077   if ( other.d->res.truncated && !d->res.truncated ) {
00078     detach();
00079     d->res.truncated = true;
00080   }
00081   if ( !error() ) // only merge the error when there was none yet.
00082     Result::operator=( other );
00083 }
00084 
00085 bool GpgME::KeyListResult::isTruncated() const {
00086   return d && d->res.truncated;
00087 }
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 Mon Apr 4 04:44:05 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003