File indexing completed on 2024-06-09 05:17:18
0001 /* -*- c++ -*- 0002 kleo/keyresolvercore.h 0003 0004 This file is part of libkleopatra, the KDE keymanagement library 0005 SPDX-FileCopyrightText: 2018 Intevation GmbH 0006 SPDX-FileCopyrightText: 2021 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 0012 #pragma once 0013 0014 #include "kleo_export.h" 0015 0016 #include <Libkleo/KeyResolver> 0017 0018 #include <QMap> 0019 #include <QStringList> 0020 0021 #include <gpgme++/global.h> 0022 0023 #include <memory> 0024 #include <vector> 0025 0026 class QString; 0027 0028 namespace GpgME 0029 { 0030 class Key; 0031 } 0032 0033 namespace Kleo 0034 { 0035 0036 class KLEO_EXPORT KeyResolverCore 0037 { 0038 public: 0039 enum SolutionFlags { 0040 // clang-format off 0041 SomeUnresolved = 0, 0042 AllResolved = 1, 0043 0044 OpenPGPOnly = 2, 0045 CMSOnly = 4, 0046 MixedProtocols = OpenPGPOnly | CMSOnly, 0047 0048 Error = 0x1000, 0049 0050 ResolvedMask = AllResolved | Error, 0051 ProtocolsMask = OpenPGPOnly | CMSOnly | Error, 0052 // clang-format on 0053 }; 0054 struct Result { 0055 SolutionFlags flags; 0056 KeyResolver::Solution solution; 0057 KeyResolver::Solution alternative; 0058 }; 0059 0060 explicit KeyResolverCore(bool encrypt, bool sign, GpgME::Protocol format = GpgME::UnknownProtocol); 0061 ~KeyResolverCore(); 0062 0063 void setSender(const QString &sender); 0064 QString normalizedSender() const; 0065 0066 void setRecipients(const QStringList &addresses); 0067 0068 void setSigningKeys(const QStringList &fingerprints); 0069 0070 void setOverrideKeys(const QMap<GpgME::Protocol, QMap<QString, QStringList>> &overrides); 0071 0072 void setAllowMixedProtocols(bool allowMixed); 0073 0074 void setPreferredProtocol(GpgME::Protocol proto); 0075 0076 void setMinimumValidity(int validity); 0077 0078 Result resolve(); 0079 0080 private: 0081 class Private; 0082 std::unique_ptr<Private> d; 0083 }; 0084 0085 } // namespace Kleo