Warning, file /utilities/kgpg/core/KGpgUidNode.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-FileCopyrightText: 2008, 2009, 2010 Rolf Eike Beer <kde@opensource.sf-tec.de> 0003 0004 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 #include "KGpgUidNode.h" 0007 0008 #include "KGpgKeyNode.h" 0009 #include "convert.h" 0010 0011 #include <QStringList> 0012 0013 class KGpgUidNodePrivate { 0014 public: 0015 KGpgUidNodePrivate(const unsigned int index, const QStringList &sl); 0016 0017 const QString m_index; 0018 QString m_email; 0019 QString m_name; 0020 QString m_comment; 0021 QDateTime m_creation; 0022 KgpgCore::KgpgKeyTrust m_trust; 0023 bool m_valid; 0024 }; 0025 0026 KGpgUidNodePrivate::KGpgUidNodePrivate(const unsigned int index, const QStringList &sl) 0027 : m_index(QString::number(index)) 0028 { 0029 QString fullname(sl.at(9)); 0030 if (fullname.contains(QLatin1Char( '<' )) ) { 0031 m_email = fullname; 0032 0033 if (fullname.contains(QLatin1Char( ')' )) ) 0034 m_email = m_email.section(QLatin1Char( ')' ), 1); 0035 0036 m_email = m_email.section(QLatin1Char( '<' ), 1); 0037 m_email.chop(1); 0038 0039 if (m_email.contains(QLatin1Char( '<' ))) { 0040 // several email addresses in the same key 0041 m_email.replace(QLatin1Char( '>' ), QLatin1Char( ';' )); 0042 m_email.remove(QLatin1Char( '<' )); 0043 } 0044 } 0045 0046 m_name = fullname.section(QLatin1String( " <" ), 0, 0); 0047 if (fullname.contains(QLatin1Char( '(' )) ) { 0048 m_name = m_name.section(QLatin1String( " (" ), 0, 0); 0049 m_comment = fullname.section(QLatin1Char( '(' ), 1, 1); 0050 m_comment = m_comment.section(QLatin1Char( ')' ), 0, 0); 0051 } 0052 0053 m_trust = KgpgCore::Convert::toTrust(sl.at(1)); 0054 m_valid = ((sl.count() <= 11) || !sl.at(11).contains(QLatin1Char( 'D' ))); 0055 m_creation = KgpgCore::Convert::toDateTime(sl.at(5)); 0056 } 0057 0058 0059 KGpgUidNode::KGpgUidNode(KGpgKeyNode *parent, const unsigned int index, const QStringList &sl) 0060 : KGpgSignableNode(parent), 0061 d_ptr(new KGpgUidNodePrivate(index, sl)) 0062 { 0063 } 0064 0065 KGpgUidNode::~KGpgUidNode() 0066 { 0067 delete d_ptr; 0068 } 0069 0070 QString 0071 KGpgUidNode::getName() const 0072 { 0073 const Q_D(KGpgUidNode); 0074 0075 return d->m_name; 0076 } 0077 0078 QString 0079 KGpgUidNode::getEmail() const 0080 { 0081 const Q_D(KGpgUidNode); 0082 0083 return d->m_email; 0084 } 0085 0086 QString 0087 KGpgUidNode::getId() const 0088 { 0089 const Q_D(KGpgUidNode); 0090 0091 return d->m_index; 0092 } 0093 0094 QDateTime 0095 KGpgUidNode::getCreation() const 0096 { 0097 const Q_D(KGpgUidNode); 0098 0099 return d->m_creation; 0100 } 0101 0102 KGpgKeyNode * 0103 KGpgUidNode::getKeyNode(void) 0104 { 0105 return getParentKeyNode()->toKeyNode(); 0106 } 0107 0108 const KGpgKeyNode * 0109 KGpgUidNode::getKeyNode(void) const 0110 { 0111 return getParentKeyNode()->toKeyNode(); 0112 } 0113 0114 KGpgKeyNode * 0115 KGpgUidNode::getParentKeyNode() const 0116 { 0117 return m_parent->toKeyNode(); 0118 } 0119 0120 void 0121 KGpgUidNode::readChildren() 0122 { 0123 } 0124 0125 KgpgCore::KgpgItemType 0126 KGpgUidNode::getType() const 0127 { 0128 return KgpgCore::ITYPE_UID; 0129 } 0130 0131 KgpgCore::KgpgKeyTrust 0132 KGpgUidNode::getTrust() const 0133 { 0134 const Q_D(KGpgUidNode); 0135 0136 return d->m_trust; 0137 } 0138 0139 QString 0140 KGpgUidNode::getComment() const 0141 { 0142 const Q_D(KGpgUidNode); 0143 0144 return d->m_comment; 0145 }