File indexing completed on 2024-06-23 05:13:38
0001 /* -*- mode: c++; c-basic-offset:4 -*- 0002 commands/changeroottrustcommand.h 0003 0004 This file is part of Kleopatra, the KDE keymanager 0005 SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 0010 #pragma once 0011 0012 #include <commands/command.h> 0013 0014 #include <gpgme++/key.h> 0015 0016 namespace Kleo 0017 { 0018 namespace Commands 0019 { 0020 0021 class ChangeRootTrustCommand : public Command 0022 { 0023 Q_OBJECT 0024 public: 0025 explicit ChangeRootTrustCommand(KeyListController *parent); 0026 explicit ChangeRootTrustCommand(QAbstractItemView *view, KeyListController *parent); 0027 explicit ChangeRootTrustCommand(const GpgME::Key &key, KeyListController *parent); 0028 explicit ChangeRootTrustCommand(const GpgME::Key &key, QAbstractItemView *view, KeyListController *parent); 0029 ~ChangeRootTrustCommand() override; 0030 0031 void setTrust(GpgME::Key::OwnerTrust trust); 0032 GpgME::Key::OwnerTrust trust() const; 0033 0034 void setTrustListFile(const QString &file); 0035 QString trustListFile() const; 0036 0037 /* reimp */ static Restrictions restrictions() 0038 { 0039 return OnlyOneKey | MustBeCMS | MustBeRoot; 0040 } 0041 0042 private: 0043 void doStart() override; 0044 void doCancel() override; 0045 0046 private: 0047 class Private; 0048 inline Private *d_func(); 0049 inline const Private *d_func() const; 0050 }; 0051 0052 class TrustRootCommand : public ChangeRootTrustCommand 0053 { 0054 public: 0055 explicit TrustRootCommand(KeyListController *parent) 0056 : ChangeRootTrustCommand(parent) 0057 { 0058 setTrust(GpgME::Key::Ultimate); 0059 } 0060 explicit TrustRootCommand(QAbstractItemView *view, KeyListController *parent) 0061 : ChangeRootTrustCommand(view, parent) 0062 { 0063 setTrust(GpgME::Key::Ultimate); 0064 } 0065 explicit TrustRootCommand(const GpgME::Key &key, KeyListController *parent) 0066 : ChangeRootTrustCommand(key, parent) 0067 { 0068 setTrust(GpgME::Key::Ultimate); 0069 } 0070 explicit TrustRootCommand(const GpgME::Key &key, QAbstractItemView *view, KeyListController *parent) 0071 : ChangeRootTrustCommand(key, view, parent) 0072 { 0073 setTrust(GpgME::Key::Ultimate); 0074 } 0075 0076 /* reimp */ static Restrictions restrictions() 0077 { 0078 return ChangeRootTrustCommand::restrictions() | MustBeUntrustedRoot; 0079 } 0080 }; 0081 0082 class DistrustRootCommand : public ChangeRootTrustCommand 0083 { 0084 public: 0085 explicit DistrustRootCommand(KeyListController *parent) 0086 : ChangeRootTrustCommand(parent) 0087 { 0088 setTrust(GpgME::Key::Never); 0089 } 0090 explicit DistrustRootCommand(QAbstractItemView *view, KeyListController *parent) 0091 : ChangeRootTrustCommand(view, parent) 0092 { 0093 setTrust(GpgME::Key::Never); 0094 } 0095 explicit DistrustRootCommand(const GpgME::Key &key, KeyListController *parent) 0096 : ChangeRootTrustCommand(key, parent) 0097 { 0098 setTrust(GpgME::Key::Never); 0099 } 0100 explicit DistrustRootCommand(const GpgME::Key &key, QAbstractItemView *view, KeyListController *parent) 0101 : ChangeRootTrustCommand(key, view, parent) 0102 { 0103 setTrust(GpgME::Key::Never); 0104 } 0105 0106 /* reimp */ static Restrictions restrictions() 0107 { 0108 return ChangeRootTrustCommand::restrictions() | MustBeTrustedRoot; 0109 } 0110 }; 0111 0112 } 0113 }