Line data Source code
1 : // SPDX-FileCopyrightText: 2015 Anne Jan Brouwer
2 : // SPDX-License-Identifier: GPL-3.0-or-later
3 : /**
4 : * @file
5 : * @brief UserInfo, one GPG key as listed by gpg, with the selection flag the
6 : * recipient dialogs use.
7 : */
8 : #ifndef SRC_USERINFO_H_
9 : #define SRC_USERINFO_H_
10 :
11 : #include <QDateTime>
12 : #include <QString>
13 :
14 : /**
15 : * @struct UserInfo
16 : * @ingroup keys
17 : * @brief Stores GPG key info including validity, creation date, and more.
18 : */
19 : struct UserInfo {
20 : /**
21 : * @brief Construct a UserInfo with default (invalid/disabled) state.
22 : */
23 347 : UserInfo() {}
24 :
25 : /**
26 : * @brief Check full validity per GnuPG validity codes.
27 : * @return true when validity is 'f' or 'u'.
28 : * http://git.gnupg.org/cgi-bin/gitweb.cgi?p=gnupg.git;a=blob_plain;f=doc/DETAILS
29 : */
30 : auto fullyValid() const -> bool {
31 218 : return (validity == 'f') || (validity == 'u');
32 : }
33 : /**
34 : * @brief Check marginal validity per GnuPG validity codes.
35 : * @return true when validity is 'm'.
36 : * http://git.gnupg.org/cgi-bin/gitweb.cgi?p=gnupg.git;a=blob_plain;f=doc/DETAILS
37 : */
38 : auto marginallyValid() const -> bool { return validity == 'm'; }
39 : /**
40 : * @brief Check whether the key has any usable validity level.
41 : * @return true when fullyValid() or marginallyValid() is true.
42 : */
43 : auto isValid() const -> bool { return fullyValid() || marginallyValid(); }
44 :
45 : /**
46 : * @brief GPG user ID / full name.
47 : */
48 : QString name;
49 : /**
50 : * @brief Hexadecimal representation of the GnuPG key identifier.
51 : */
52 : QString key_id;
53 : /**
54 : * @brief GnuPG representation of validity.
55 : * http://git.gnupg.org/cgi-bin/gitweb.cgi?p=gnupg.git;a=blob_plain;f=doc/DETAILS
56 : */
57 : char validity{'-'};
58 : /**
59 : * @brief Whether secret key is available (can decrypt with this key).
60 : */
61 : bool have_secret{false};
62 : /**
63 : * @brief Whether this user/key is enabled for normal use.
64 : */
65 : bool enabled{false};
66 : /**
67 : * @brief Date/time when key expires.
68 : */
69 : QDateTime expiry;
70 : /**
71 : * @brief Date/time when key was created.
72 : */
73 : QDateTime created;
74 : };
75 :
76 : #endif // SRC_USERINFO_H_
|