File indexing completed on 2024-06-16 04:56:16

0001 /*  view/pgpcardwiget.h
0002 
0003     This file is part of Kleopatra, the KDE keymanager
0004     SPDX-FileCopyrightText: 2017 Bundesamt für Sicherheit in der Informationstechnik
0005     SPDX-FileContributor: Intevation GmbH
0006     SPDX-FileCopyrightText: 2020, 2022 g10 Code GmbH
0007     SPDX-FileContributor: Ingo Klöcker <dev@ingo-kloecker.de>
0008 
0009     SPDX-License-Identifier: GPL-2.0-or-later
0010 */
0011 #pragma once
0012 
0013 #include "commands/changepincommand.h"
0014 
0015 #include <QWidget>
0016 
0017 #include <gpgme++/error.h>
0018 
0019 #include <string>
0020 
0021 class QLabel;
0022 class QPushButton;
0023 
0024 namespace Kleo
0025 {
0026 class GenCardKeyDialog;
0027 class OpenPGPKeyCardWidget;
0028 
0029 namespace SmartCard
0030 {
0031 struct KeyPairInfo;
0032 class OpenPGPCard;
0033 } // namespace SmartCard
0034 
0035 class PGPCardWidget : public QWidget
0036 {
0037     Q_OBJECT
0038 public:
0039     explicit PGPCardWidget(QWidget *parent = nullptr);
0040 
0041     void setCard(const SmartCard::OpenPGPCard *card);
0042     void doGenKey(GenCardKeyDialog *dlg);
0043     void genKeyDone(const GpgME::Error &err, const std::string &backup);
0044 
0045 public Q_SLOTS:
0046     void genkeyRequested();
0047     void changeNameRequested();
0048     void changeNameResult(const GpgME::Error &err);
0049     void changeUrlRequested();
0050     void changeUrlResult(const GpgME::Error &err);
0051     void createKeyFromCardKeys();
0052     void createCSR(const std::string &keyref);
0053     void generateKey(const std::string &keyref);
0054 
0055 private:
0056     void doChangePin(const std::string &keyRef, Commands::ChangePinCommand::ChangePinMode mode = Commands::ChangePinCommand::NormalMode);
0057 
0058 private:
0059     QLabel *mSerialNumber = nullptr;
0060     QLabel *mCardHolderLabel = nullptr;
0061     QLabel *mVersionLabel = nullptr;
0062     QLabel *mUrlLabel = nullptr;
0063     QPushButton *mKeyForCardKeysButton = nullptr;
0064     OpenPGPKeyCardWidget *mKeysWidget = nullptr;
0065     QString mUrl;
0066     bool mCardIsEmpty = false;
0067     bool mIs21 = false;
0068     std::string mRealSerial;
0069 };
0070 } // namespace Kleo