MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / nowFloored

Method nowFloored

app/src/Licensing/MonotonicClock.cpp:33–53  ·  view source on GitHub ↗

* @brief Core flooring over an explicit settings store and cipher (for testing). */

Source from the content-addressed store, hash-verified

31 * @brief Core flooring over an explicit settings store and cipher (for testing).
32 */
33QDateTime 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).

Callers

nothing calls this directly

Calls 5

isEmptyMethod · 0.80
decryptToStringMethod · 0.80
encryptToStringMethod · 0.80
valueMethod · 0.45
isValidMethod · 0.45

Tested by

no test coverage detected