libkdenetwork Library API Documentation

trustitem.cpp

00001 /* trustitem.cpp - wraps a gpgme trust item
00002    Copyright (C) 2003 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 #ifdef HAVE_CONFIG_H
00021 #include <config.h>
00022 #endif
00023 
00024 #include <gpgmepp/trustitem.h>
00025 
00026 #include <gpgme.h>
00027 
00028 #include <cassert>
00029 
00030 namespace GpgME {
00031 
00032   struct TrustItem::Private  {
00033     Private( gpgme_trust_item_t aItem )
00034       : item( aItem )
00035     {
00036     }
00037 
00038     gpgme_trust_item_t item;
00039   };
00040 
00041   TrustItem::TrustItem( gpgme_trust_item_t item ) {
00042     d = new Private( item );
00043     if ( d->item )
00044       gpgme_trust_item_ref( d->item );
00045   }
00046 
00047   TrustItem::TrustItem( const TrustItem & other ) {
00048     d = new Private( other.d->item );
00049     if ( d->item )
00050       gpgme_trust_item_ref( d->item );
00051   }
00052 
00053   const TrustItem & TrustItem::operator=( const TrustItem & other ) {
00054     if ( &other == this ) return *this;
00055 
00056     if ( other.d->item )
00057       gpgme_trust_item_ref( other.d->item );
00058     if ( d->item )
00059       gpgme_trust_item_unref( d->item );
00060     *d = *other.d;
00061     return *this;
00062   }
00063 
00064   TrustItem::~TrustItem() {
00065     if ( d->item )
00066       gpgme_trust_item_unref( d->item );
00067     delete d; d = 0;
00068   }
00069 
00070   bool TrustItem::isNull() const {
00071     return !d || !d->item;
00072   }
00073 
00074   gpgme_trust_item_t TrustItem::impl() const {
00075     return d->item;
00076   }
00077 
00078 
00079   const char * TrustItem::keyID() const {
00080     return d->item ? d->item->keyid : 0 ;
00081   }
00082 
00083   const char * TrustItem::userID() const {
00084     return d->item ? d->item->name : 0 ;
00085   }
00086 
00087   const char * TrustItem::ownerTrustAsString() const {
00088     return d->item ? d->item->owner_trust : 0 ;
00089   }
00090 
00091   const char * TrustItem::validityAsString() const {
00092     return d->item ? d->item->validity : 0 ;
00093   }
00094 
00095   int TrustItem::trustLevel() const {
00096     return d->item ? d->item->level : 0 ;
00097   }
00098 
00099   TrustItem::Type TrustItem::type() const {
00100     if ( !d->item )
00101       return Unknown;
00102     else 
00103       return
00104     d->item->type == 1 ? Key :
00105     d->item->type == 2 ? UserID :
00106     Unknown ;
00107   }
00108 
00109 } // namespace GpgME
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 Fri Dec 21 14:21:41 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003