trustitem.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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 }
This file is part of the documentation for libkdenetwork Library Version 3.3.0.