* @brief Core flooring over an explicit settings store and cipher (for testing). */
| 31 | * @brief Core flooring over an explicit settings store and cipher (for testing). |
| 32 | */ |
| 33 | QDateTime Licensing::MonotonicClock::nowFloored(QSettings& settings, SimpleCrypt& crypt) |
| 34 | { |
| 35 | auto effective = QDateTime::currentDateTime(); |
| 36 | |
| 37 | settings.beginGroup("licensing"); |
| 38 | const auto stored = settings.value("lastSeen", "").toString(); |
| 39 | settings.endGroup(); |
| 40 | |
| 41 | if (!stored.isEmpty()) { |
| 42 | const auto seen = QDateTime::fromString(crypt.decryptToString(stored), Qt::RFC2822Date); |
| 43 | if (seen.isValid() && seen > effective) |
| 44 | effective = seen; |
| 45 | } |
| 46 | |
| 47 | const auto encoded = crypt.encryptToString(effective.toString(Qt::RFC2822Date)); |
| 48 | settings.beginGroup("licensing"); |
| 49 | settings.setValue("lastSeen", encoded); |
| 50 | settings.endGroup(); |
| 51 | |
| 52 | return effective; |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * @brief Returns now floored at the highest wall-clock ever observed (anti clock-rewind). |
nothing calls this directly
no test coverage detected