1/*
2 * Copyright (C) 2003-2008 Justin Karneges <justin@affinix.com>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19#include "mykeystoreentry.h"
20#include "utils.h"
21
22using namespace QCA;
23
24namespace gpgQCAPlugin {
25
26MyKeyStoreEntry::MyKeyStoreEntry(const PGPKey &_pub, const PGPKey &_sec, Provider *p)
27 : KeyStoreEntryContext(p)
28{
29 pub = _pub;
30 sec = _sec;
31 if (!sec.isNull())
32 item_type = KeyStoreEntry::TypePGPSecretKey;
33 else
34 item_type = KeyStoreEntry::TypePGPPublicKey;
35}
36
37MyKeyStoreEntry::MyKeyStoreEntry(const MyKeyStoreEntry &from)
38 : KeyStoreEntryContext(from)
39{
40}
41
42MyKeyStoreEntry::~MyKeyStoreEntry()
43{
44}
45
46Provider::Context *MyKeyStoreEntry::clone() const
47{
48 return new MyKeyStoreEntry(*this);
49}
50
51KeyStoreEntry::Type MyKeyStoreEntry::type() const
52{
53 return item_type;
54}
55
56QString MyKeyStoreEntry::name() const
57{
58 return pub.primaryUserId();
59}
60
61QString MyKeyStoreEntry::id() const
62{
63 return pub.keyId();
64}
65
66QString MyKeyStoreEntry::storeId() const
67{
68 return _storeId;
69}
70
71QString MyKeyStoreEntry::storeName() const
72{
73 return _storeName;
74}
75
76PGPKey MyKeyStoreEntry::pgpSecretKey() const
77{
78 return sec;
79}
80
81PGPKey MyKeyStoreEntry::pgpPublicKey() const
82{
83 return pub;
84}
85
86QString MyKeyStoreEntry::serialize() const
87{
88 // we only serialize the key id. this means the keyring
89 // must be available to restore the data
90 QStringList out;
91 out += escape_string(QStringLiteral("qca-gnupg-1"));
92 out += escape_string(in: pub.keyId());
93 return out.join(QStringLiteral(":"));
94}
95
96} // end namespace gpgQCAPlugin
97

source code of qca/plugins/qca-gnupg/mykeystoreentry.cpp