File indexing completed on 2022-10-04 17:28:19

0001 /*
0002     SPDX-FileCopyrightText: 2008, 2009, 2012 Rolf Eike Beer <kde@opensource.sf-tec.de>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #ifndef KGPGDELUID_H
0007 #define KGPGDELUID_H
0008 
0009 #include "kgpguidtransaction.h"
0010 
0011 #include "core/KGpgSignableNode.h"
0012 
0013 #include <QList>
0014 #include <QObject>
0015 
0016 class KGpgKeyNode;
0017 
0018 class KGpgDelUid: public KGpgUidTransaction {
0019     Q_OBJECT
0020 
0021     Q_DISABLE_COPY(KGpgDelUid)
0022     KGpgDelUid() = delete;
0023 public:
0024     enum ts_deluid {
0025         TS_NO_SUCH_UID = KGpgTransaction::TS_COMMON_END + 1 ///< user id does not exist
0026     };
0027 
0028     enum RemoveMode {
0029         RemoveAllOther = 0, ///< remove all other uids
0030         KeepUats = 1,       ///< remove all other uids, but keep uats
0031         RemoveWithEmail = 2 ///< remove only those other uids that have an email address
0032     };
0033 
0034     /**
0035      * @brief constructor
0036      * @param parent parent object
0037      * @param uid user id to delete
0038      */
0039     KGpgDelUid(QObject *parent, const KGpgSignableNode *uid);
0040     /**
0041      * @brief constructor
0042      * @param parent parent object
0043      * @param uids user ids to delete
0044      *
0045      * All entries in uids must be children of the same keynode. The keynode itself
0046      * may be part of the list, representing the primary user id. The nodes must be
0047      * either the keynode itself, user id nodes, or user attribute nodes.
0048      */
0049     KGpgDelUid(QObject *parent, const KGpgSignableNode::const_List &uids);
0050     /**
0051      * @brief constructor
0052      * @param parent parent object
0053      * @param keynode key to edit
0054      * @param uid uid to delete, negative to delete all others (see also removeMode)
0055      * @param removeMode control which other uids are removed in case uid is negative
0056      */
0057     KGpgDelUid(QObject *parent, const KGpgKeyNode *keynode, const int uid, const RemoveMode removeMode = RemoveAllOther);
0058     /**
0059      * @brief destructor
0060      */
0061     ~KGpgDelUid() override;
0062 
0063     /**
0064      * @brief set the user id to be deleted
0065      *
0066      * This removes all previously set user ids from the list.
0067      */
0068     void setUid(const KGpgSignableNode *uid);
0069     /**
0070      * @brief set the user id to be deleted
0071      *
0072      * @overload
0073      */
0074     void setUid(const KGpgKeyNode *keynode, const int uid, const RemoveMode removeMode = RemoveAllOther);
0075     /**
0076      * @brief set the user ids to be deleted
0077      *
0078      * This removes all previously set user ids from the list.
0079      */
0080     void setUids(const KGpgSignableNode::const_List &uids);
0081 
0082 protected:
0083     bool preStart() override;
0084     bool nextLine(const QString &line) override;
0085     ts_boolanswer boolQuestion(const QString &line) override;
0086     void finish() override;
0087 
0088 private:
0089     int m_fixargs;
0090     QList<const KGpgSignableNode *> m_uids;
0091 };
0092 
0093 #endif // KGPGDELUID_H