• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeutils API Reference
  • KDE Home
  • Contact Us
 

kgpg

  • sources
  • kde-4.14
  • kdeutils
  • kgpg
  • core
KGpgUidNode.cpp
Go to the documentation of this file.
1 /* Copyright 2008,2009,2010 Rolf Eike Beer <kde@opensource.sf-tec.de>
2  *
3  * This program is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU General Public License as
5  * published by the Free Software Foundation; either version 2 of
6  * the License or (at your option) version 3 or any later version
7  * accepted by the membership of KDE e.V. (or its successor approved
8  * by the membership of KDE e.V.), which shall act as a proxy
9  * defined in Section 14 of version 3 of the license.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 #include "KGpgUidNode.h"
20 
21 #include "KGpgKeyNode.h"
22 #include "convert.h"
23 
24 class KGpgUidNodePrivate {
25 public:
26  KGpgUidNodePrivate(const unsigned int index, const QStringList &sl);
27 
28  const QString m_index;
29  QString m_email;
30  QString m_name;
31  QString m_comment;
32  KgpgCore::KgpgKeyTrust m_trust;
33  bool m_valid;
34 };
35 
36 KGpgUidNodePrivate::KGpgUidNodePrivate(const unsigned int index, const QStringList &sl)
37  : m_index(QString::number(index))
38 {
39  QString fullname(sl.at(9));
40  if (fullname.contains(QLatin1Char( '<' )) ) {
41  m_email = fullname;
42 
43  if (fullname.contains(QLatin1Char( ')' )) )
44  m_email = m_email.section(QLatin1Char( ')' ), 1);
45 
46  m_email = m_email.section(QLatin1Char( '<' ), 1);
47  m_email.truncate(m_email.length() - 1);
48 
49  if (m_email.contains(QLatin1Char( '<' ))) {
50  // several email addresses in the same key
51  m_email = m_email.replace(QLatin1Char( '>' ), QLatin1Char( ';' ));
52  m_email.remove(QLatin1Char( '<' ));
53  }
54  }
55 
56  m_name = fullname.section(QLatin1String( " <" ), 0, 0);
57  if (fullname.contains(QLatin1Char( '(' )) ) {
58  m_name = m_name.section(QLatin1String( " (" ), 0, 0);
59  m_comment = fullname.section(QLatin1Char( '(' ), 1, 1);
60  m_comment = m_comment.section(QLatin1Char( ')' ), 0, 0);
61  }
62 
63  m_trust = KgpgCore::Convert::toTrust(sl.at(1));
64  m_valid = ((sl.count() <= 11) || !sl.at(11).contains(QLatin1Char( 'D' )));
65 }
66 
67 
68 KGpgUidNode::KGpgUidNode(KGpgKeyNode *parent, const unsigned int index, const QStringList &sl)
69  : KGpgSignableNode(parent),
70  d_ptr(new KGpgUidNodePrivate(index, sl))
71 {
72 }
73 
74 KGpgUidNode::~KGpgUidNode()
75 {
76  delete d_ptr;
77 }
78 
79 QString
80 KGpgUidNode::getName() const
81 {
82  const Q_D(KGpgUidNode);
83 
84  return d->m_name;
85 }
86 
87 QString
88 KGpgUidNode::getEmail() const
89 {
90  const Q_D(KGpgUidNode);
91 
92  return d->m_email;
93 }
94 
95 QString
96 KGpgUidNode::getId() const
97 {
98  const Q_D(KGpgUidNode);
99 
100  return d->m_index;
101 }
102 
103 KGpgKeyNode *
104 KGpgUidNode::getKeyNode(void)
105 {
106  return getParentKeyNode()->toKeyNode();
107 }
108 
109 const KGpgKeyNode *
110 KGpgUidNode::getKeyNode(void) const
111 {
112  return getParentKeyNode()->toKeyNode();
113 }
114 
115 KGpgKeyNode *
116 KGpgUidNode::getParentKeyNode() const
117 {
118  return m_parent->toKeyNode();
119 }
120 
121 void
122 KGpgUidNode::readChildren()
123 {
124 }
125 
126 KgpgCore::KgpgItemType
127 KGpgUidNode::getType() const
128 {
129  return KgpgCore::ITYPE_UID;
130 }
131 
132 KgpgCore::KgpgKeyTrust
133 KGpgUidNode::getTrust() const
134 {
135  const Q_D(KGpgUidNode);
136 
137  return d->m_trust;
138 }
139 
140 QString
141 KGpgUidNode::getComment() const
142 {
143  const Q_D(KGpgUidNode);
144 
145  return d->m_comment;
146 }
KGpgUidNode.h
KGpgUidNode::KGpgUidNode
KGpgUidNode(KGpgKeyNode *parent, const unsigned int index, const QStringList &sl)
Definition: KGpgUidNode.cpp:68
QString::truncate
void truncate(int position)
KGpgUidNode::getEmail
virtual QString getEmail() const
Definition: KGpgUidNode.cpp:88
KGpgUidNode::getTrust
virtual KgpgCore::KgpgKeyTrust getTrust() const
Definition: KGpgUidNode.cpp:133
QList::at
const T & at(int i) const
KgpgCore::Convert::toTrust
KgpgKeyTrust toTrust(const QChar &c)
Definition: convert.cpp:138
KGpgUidNode::getId
virtual QString getId() const
Definition: KGpgUidNode.cpp:96
KGpgKeyNode
A public key with or without corresponding secret key.
Definition: KGpgKeyNode.h:33
KGpgUidNode::getName
virtual QString getName() const
Definition: KGpgUidNode.cpp:80
QList::count
int count(const T &value) const
QString
KGpgUidNode::getType
virtual KgpgCore::KgpgItemType getType() const
Returns the item type of this object.
Definition: KGpgUidNode.cpp:127
QStringList
QLatin1Char
KGpgUidNode::getComment
virtual QString getComment() const
Definition: KGpgUidNode.cpp:141
KGpgNode::toKeyNode
KGpgKeyNode * toKeyNode()
Definition: KGpgNode.cpp:94
KGpgUidNode::~KGpgUidNode
virtual ~KGpgUidNode()
Definition: KGpgUidNode.cpp:74
QLatin1String
KGpgNode::m_parent
KGpgExpandableNode * m_parent
Definition: KGpgNode.h:50
KGpgKeyNode.h
QString::section
QString section(QChar sep, int start, int end, QFlags< QString::SectionFlag > flags) const
KGpgUidNode::getParentKeyNode
virtual KGpgKeyNode * getParentKeyNode() const
Definition: KGpgUidNode.cpp:116
KGpgUidNode
A user id of a public key or key pair.
Definition: KGpgUidNode.h:33
KGpgUidNode::readChildren
virtual void readChildren()
reimplemented in every base class to read in the child data
Definition: KGpgUidNode.cpp:122
KgpgCore::ITYPE_UID
additional user id
Definition: kgpgkey.h:99
convert.h
KGpgUidNode::getKeyNode
virtual KGpgKeyNode * getKeyNode(void)
returns the key node this node belongs to
Definition: KGpgUidNode.cpp:104
KGpgSignableNode
An object that may have KGpgSignNode children.
Definition: KGpgSignableNode.h:31
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:42:08 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kgpg

Skip menu "kgpg"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeutils API Reference

Skip menu "kdeutils API Reference"
  • ark
  • filelight
  • kcalc
  • kcharselect
  • kdf
  • kfloppy
  • kgpg
  • ktimer
  • kwallet
  • sweeper

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal