File indexing completed on 2024-12-22 05:01:05
0001 /* 0002 SPDX-FileCopyrightText: 2022 Sandro Knauß <sknauss@kde.org> 0003 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0004 */ 0005 0006 #pragma once 0007 #include "kmail_private_export.h" 0008 #include <QObject> 0009 0010 /** 0011 * @todo write docs 0012 */ 0013 class KMAILTESTS_TESTS_EXPORT EncryptionState : public QObject 0014 { 0015 Q_OBJECT 0016 Q_PROPERTY(bool override READ override WRITE setOverride NOTIFY overrideChanged) 0017 Q_PROPERTY(bool possibleEncrypt READ possibleEncrypt WRITE setPossibleEncrypt NOTIFY possibleEncryptChanged) 0018 Q_PROPERTY(bool autoEncrypt READ autoEncrypt WRITE setAutoEncrypt NOTIFY autoEncryptChanged) 0019 Q_PROPERTY(bool acceptedSolution READ acceptedSolution WRITE setAcceptedSolution NOTIFY acceptedSolutionChanged) 0020 Q_PROPERTY(bool encrypt READ encrypt NOTIFY encryptChanged) 0021 0022 public: 0023 /** 0024 * Default constructor 0025 */ 0026 EncryptionState(); 0027 0028 /** 0029 * @return the user set the encryption state no matter what 0030 */ 0031 [[nodiscard]] bool override() const; 0032 0033 /** 0034 * @return true when set an override 0035 */ 0036 [[nodiscard]] bool hasOverride() const; 0037 0038 /** 0039 * @return we have encryption keys for the user so in principal it is possible to encrypt 0040 */ 0041 [[nodiscard]] bool possibleEncrypt() const; 0042 0043 /** 0044 * @return the user wants auto encryption 0045 */ 0046 [[nodiscard]] bool autoEncrypt() const; 0047 0048 /** 0049 * @return we found a set of keys to encrypt to everyone 0050 */ 0051 [[nodiscard]] bool acceptedSolution() const; 0052 0053 /** 0054 * @return the encrypt 0055 */ 0056 [[nodiscard]] bool encrypt() const; 0057 0058 public Q_SLOTS: 0059 /** 0060 * Sets the override. 0061 * 0062 * @param override the new override 0063 */ 0064 void setOverride(bool override); 0065 0066 /** 0067 * Delete the override. 0068 */ 0069 void unsetOverride(); 0070 0071 /** 0072 * Toggles the override 0073 */ 0074 void toggleOverride(); 0075 0076 /** 0077 * Sets the acceptedSolution. 0078 * 0079 * @param acceptedSolution the new acceptedSolution 0080 */ 0081 void setAcceptedSolution(bool acceptedSolution); 0082 0083 /** 0084 * Sets the possibleEncrypt. 0085 * 0086 * @param possibleEncrypt the new possibleEncrypt 0087 */ 0088 void setPossibleEncrypt(bool possibleEncrypt); 0089 0090 /** 0091 * Sets the autoEncrypt. 0092 * 0093 * @param autoEncrypt the new autoEncrypt 0094 */ 0095 void setAutoEncrypt(bool autoEncrypt); 0096 0097 Q_SIGNALS: 0098 void overrideChanged(bool override); 0099 void hasOverrideChanged(bool hasOverride); 0100 0101 void acceptedSolutionChanged(bool acceptedSolution); 0102 0103 void possibleEncryptChanged(bool possibleEncrypt); 0104 0105 void autoEncryptChanged(bool autoEncrypt); 0106 0107 void encryptChanged(bool encrypt); 0108 0109 private: 0110 void setEncrypt(bool encrypt); 0111 void updateEncrypt(); 0112 0113 private: 0114 bool m_override = false; 0115 bool m_hasOverride = false; 0116 bool m_acceptedSolution = false; 0117 bool m_possibleEncrypt = false; 0118 bool m_autoEncrypt = false; 0119 bool m_encrypt = false; 0120 };