File indexing completed on 2025-03-16 08:32:47
0001 /* 0002 SPDX-FileCopyrightText: 2008, 2009 Rolf Eike Beer <kde@opensource.sf-tec.de> 0003 0004 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #ifndef KGPGREFNODE_H 0008 #define KGPGREFNODE_H 0009 0010 #include "KGpgNode.h" 0011 0012 class KGpgKeyNode; 0013 class KGpgRootNode; 0014 0015 /** 0016 * @brief Class for child objects that are only a reference to a primary key 0017 * 0018 * This is the base class for all type of objects that match these criteria: 0019 * -they can not have child objects 0020 * -they are only a reference to a primary key (which needs not to be in the 0021 * key ring) 0022 * 0023 * Do not create instances from this class. Use KGpgGroupMemberNode and 0024 * KGpgSignNode as those represent the existing objects. This class exists 0025 * only to get the hierarchy right. 0026 */ 0027 class KGpgRefNode : public KGpgNode 0028 { 0029 Q_OBJECT 0030 0031 private: 0032 const QString m_id; 0033 bool m_selfsig; ///< if this is a reference to it's own parent 0034 QMetaObject::Connection m_updateConnection; 0035 0036 protected: 0037 KGpgKeyNode *m_keynode; 0038 0039 explicit KGpgRefNode(KGpgExpandableNode *parent, KGpgKeyNode *key); 0040 explicit KGpgRefNode(KGpgExpandableNode *parent, const QString &keyid); 0041 0042 KGpgRootNode *getRootNode() const; 0043 0044 public: 0045 ~KGpgRefNode() override; 0046 0047 QString getId() const override; 0048 QString getName() const override; 0049 QString getEmail() const override; 0050 /** 0051 * Get the node of the primary key this node references to 0052 * 0053 * This will return the key node of the primary key this node 0054 * references. This may be %nullptr if the primary key is not in the key 0055 * ring, e.g. if this is a signature of an unknown key. 0056 * 0057 * @return the node of the primary key or %nullptr 0058 */ 0059 virtual KGpgKeyNode *getRefNode() const; 0060 0061 /** 0062 * Check if the referenced key exists 0063 * 0064 * @return if getRefNode() will return %nullptr or not 0065 */ 0066 bool isUnknown() const; 0067 0068 /** 0069 * Break the current reference 0070 * @param root root node 0071 * 0072 * This is called when the referenced node is going away. 0073 * 0074 * The root node is passed for two reasons: 0075 * @li it doesn't need to be searched again for every ref node which 0076 * can be many in case of an important key node get's deleted 0077 * @li the ref node may be a child of the deleted node, then we can 0078 * not call the parents functions to find the root anymore. This helps 0079 * simplifying the code 0080 */ 0081 void unRef(KGpgRootNode *root); 0082 0083 private Q_SLOTS: 0084 void keyUpdated(KGpgKeyNode *); 0085 }; 0086 0087 #endif /* KGPGREFNODE_H */