KIdentityManagement

cryptographyeditorbackend.cpp
1// SPDX-FileCopyrightText: 2023 Claudio Cambra <claudio.cambra@kde.org>
2// SPDX-License-Identifier: LGPL-2.0-or-later
3
4#include "cryptographyeditorbackend.h"
5
6#include "cryptographybackendinterface.h"
7#include "identity.h"
8
9namespace KIdentityManagementQuick
10{
11
12CryptographyEditorBackend::CryptographyEditorBackend(QObject *parent, const CryptographyBackendInterfacePtr &cryptoBackend)
13 : QObject{parent}
14 , mCryptoBackend(cryptoBackend)
15{
16 connect(this, &CryptographyEditorBackend::cryptographyBackendChanged, this, &CryptographyEditorBackend::openPgpKeyListModelChanged);
17 connect(this, &CryptographyEditorBackend::cryptographyBackendChanged, this, &CryptographyEditorBackend::smimeKeyListModelChanged);
18}
19
20CryptographyBackendInterfacePtr CryptographyEditorBackend::cryptographyBackend() const
21{
22 return mCryptoBackend;
23}
24
25void CryptographyEditorBackend::setCryptographyBackend(const CryptographyBackendInterfacePtr &cryptoBackend)
26{
27 if (cryptoBackend.get() == mCryptoBackend.get()) {
28 return;
29 }
30
31 mCryptoBackend = cryptoBackend;
32 Q_EMIT cryptographyBackendChanged();
33}
34
35QAbstractItemModel *CryptographyEditorBackend::openPgpKeyListModel() const
36{
37 if (!mCryptoBackend) {
38 return nullptr;
39 }
40 return mCryptoBackend->openPgpKeyListModel();
41}
42
43QAbstractItemModel *CryptographyEditorBackend::smimeKeyListModel() const
44{
45 if (!mCryptoBackend) {
46 return nullptr;
47 }
48 return mCryptoBackend->smimeKeyListModel();
49}
50
51KIdentityManagementCore::Identity CryptographyEditorBackend::identity() const
52{
53 return mCryptoBackend->identity();
54}
55
56void CryptographyEditorBackend::setIdentity(const KIdentityManagementCore::Identity &identity)
57{
58 mCryptoBackend->setIdentity(identity);
59 Q_EMIT identityChanged();
60}
61
63CryptographyEditorBackend::indexForIdentity(QAbstractItemModel *model, const KIdentityManagementCore::Identity &identity, const KeyUseTypes::KeyUse keyUse)
64{
65 Q_ASSERT(model);
66 const auto klmInterface = dynamic_cast<const KeyListModelInterface *>(model);
67 Q_ASSERT(klmInterface);
68 return klmInterface->indexForIdentity(identity, keyUse);
69}
70
71QString CryptographyEditorBackend::stringFromKeyByteArray(const QByteArray &key)
72{
73 return QString::fromUtf8(key);
74}
75}
76
77#include "moc_cryptographyeditorbackend.cpp"
User identity information.
Definition identity.h:73
QString fromUtf8(QByteArrayView str)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Apr 27 2024 22:14:39 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.