QtPass Developer documentation
QtPass test coverage
Current view: top level - src/userinfo.h (source / functions) Coverage Total Hit
Test: QtPass Lines: 100.0 % 2 2
Test Date: 2026-12-03 23:34:20 Functions: 100.0 % 1 1
Branches: 100.0 % 8 8

             Branch data     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                 :             : #include <QStringList>
      14                 :             : 
      15                 :             : /**
      16                 :             :  * @struct UserInfo
      17                 :             :  * @ingroup keys
      18                 :             :  * @brief Stores GPG key info including validity, creation date, and more.
      19                 :             :  */
      20                 :             : struct UserInfo {
      21                 :             :   /**
      22                 :             :    * @brief Construct a UserInfo with default (invalid/disabled) state.
      23                 :             :    */
      24                 :        6636 :   UserInfo() = default;
      25                 :             : 
      26                 :             :   /**
      27                 :             :    * @brief Check full validity per GnuPG validity codes.
      28                 :             :    * @return true when validity is 'f' or 'u'.
      29                 :             :    * http://git.gnupg.org/cgi-bin/gitweb.cgi?p=gnupg.git;a=blob_plain;f=doc/DETAILS
      30                 :             :    */
      31                 :             :   auto fullyValid() const -> bool {
      32   [ +  +  +  +  :        6369 :     return (validity == 'f') || (validity == 'u');
           +  + ][ +  + ]
      33                 :             :   }
      34                 :             :   /**
      35                 :             :    * @brief Check marginal validity per GnuPG validity codes.
      36                 :             :    * @return true when validity is 'm'.
      37                 :             :    * http://git.gnupg.org/cgi-bin/gitweb.cgi?p=gnupg.git;a=blob_plain;f=doc/DETAILS
      38                 :             :    */
      39                 :             :   auto marginallyValid() const -> bool { return validity == 'm'; }
      40                 :             :   /**
      41                 :             :    * @brief Check whether the key has any usable validity level.
      42                 :             :    * @return true when fullyValid() or marginallyValid() is true.
      43                 :             :    */
      44                 :             :   auto isValid() const -> bool { return fullyValid() || marginallyValid(); }
      45                 :             : 
      46                 :             :   /**
      47                 :             :    * @brief GPG user ID / full name.
      48                 :             :    */
      49                 :             :   QString name;
      50                 :             :   /**
      51                 :             :    * @brief Hexadecimal representation of the GnuPG key identifier.
      52                 :             :    */
      53                 :             :   QString key_id;
      54                 :             :   /**
      55                 :             :    * @brief Every user ID on the key, revoked ones included, with gpg's colon
      56                 :             :    * escapes (such as `\x3a`) decoded: the names a recipient list may use.
      57                 :             :    */
      58                 :             :   QStringList uids;
      59                 :             :   /**
      60                 :             :    * @brief Key IDs and fingerprints of the key's subkeys, by which a
      61                 :             :    * recipient list may name the key as well.
      62                 :             :    */
      63                 :             :   QStringList subkeys;
      64                 :             :   /**
      65                 :             :    * @brief GnuPG representation of validity.
      66                 :             :    * http://git.gnupg.org/cgi-bin/gitweb.cgi?p=gnupg.git;a=blob_plain;f=doc/DETAILS
      67                 :             :    */
      68                 :             :   char validity{'-'};
      69                 :             :   /**
      70                 :             :    * @brief Whether secret key is available (can decrypt with this key).
      71                 :             :    */
      72                 :             :   bool have_secret{false};
      73                 :             :   /**
      74                 :             :    * @brief Whether this user/key is enabled for normal use.
      75                 :             :    */
      76                 :             :   bool enabled{false};
      77                 :             :   /**
      78                 :             :    * @brief Date/time when key expires.
      79                 :             :    */
      80                 :             :   QDateTime expiry;
      81                 :             :   /**
      82                 :             :    * @brief Date/time when key was created.
      83                 :             :    */
      84                 :             :   QDateTime created;
      85                 :             : };
      86                 :             : 
      87                 :             : #endif // SRC_USERINFO_H_
        

Generated by: LCOV version 2.0-1