data/MutationJournal.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <QMetaType> | ||
| 4 | #include <QString> | ||
| 5 | |||
| 6 | #include "data/MailRequest.h" | ||
| 7 | |||
| 8 | // Durable operation taxonomy for Sprint 84. Desired-state operations may be | ||
| 9 | // replayed after authoritative verification; location-changing operations | ||
| 10 | // become ambiguous once dispatched and must be reconciled before retry. | ||
| 11 | enum class MutationKind { | ||
| 12 | Seen = 0, | ||
| 13 | Flagged, | ||
| 14 | Keyword, | ||
| 15 | Move, | ||
| 16 | Copy, | ||
| 17 | Append, | ||
| 18 | Undo, | ||
| 19 | }; | ||
| 20 | |||
| 21 | enum class MutationPhase { | ||
| 22 | Queued = 0, | ||
| 23 | Dispatched, | ||
| 24 | Confirmed, | ||
| 25 | AwaitingVerification, | ||
| 26 | Ambiguous, | ||
| 27 | Failed, | ||
| 28 | Quarantined, | ||
| 29 | }; | ||
| 30 | |||
| 31 | enum class MutationReplayClass { | ||
| 32 | DesiredState = 0, | ||
| 33 | AmbiguousOperation, | ||
| 34 | }; | ||
| 35 | |||
| 36 | struct MutationRecord { | ||
| 37 | qint64 token = 0; | ||
| 38 | MailId mailId; | ||
| 39 | QString folderPath; | ||
| 40 | MutationKind kind = MutationKind::Seen; | ||
| 41 | MutationReplayClass replayClass = MutationReplayClass::DesiredState; | ||
| 42 | MutationPhase phase = MutationPhase::Queued; | ||
| 43 | QString flag; | ||
| 44 | bool desiredState = false; | ||
| 45 | QString targetFolder; | ||
| 46 | QString messageId; | ||
| 47 | quint32 uidValidity = 0; | ||
| 48 | QString uidPlusEvidence; | ||
| 49 | QString error; | ||
| 50 | qint64 createdAt = 0; | ||
| 51 | qint64 updatedAt = 0; | ||
| 52 | |||
| 53 | 6758 | [[nodiscard]] bool isValid() const { | |
| 54 |
6/6✓ Branch 3 → 4 taken 6756 times.
✓ Branch 3 → 6 taken 2 times.
✓ Branch 5 → 6 taken 1 time.
✓ Branch 5 → 7 taken 6755 times.
✓ Branch 8 → 9 taken 3 times.
✓ Branch 8 → 10 taken 6755 times.
|
6758 | if (folderPath.isEmpty() || mailId.accountId.isEmpty()) |
| 55 | 3 | return false; | |
| 56 |
2/2✓ Branch 10 → 11 taken 33 times.
✓ Branch 10 → 21 taken 6722 times.
|
6755 | if (kind == MutationKind::Append) { |
| 57 | 65 | return replayClass == MutationReplayClass::AmbiguousOperation && | |
| 58 |
4/4✓ Branch 12 → 13 taken 31 times.
✓ Branch 12 → 19 taken 1 time.
✓ Branch 13 → 14 taken 30 times.
✓ Branch 13 → 19 taken 1 time.
|
32 | mailId.folderId == 0 && mailId.uid == 0 && |
| 59 |
6/6✓ Branch 11 → 12 taken 32 times.
✓ Branch 11 → 19 taken 1 time.
✓ Branch 15 → 16 taken 29 times.
✓ Branch 15 → 19 taken 1 time.
✓ Branch 17 → 18 taken 28 times.
✓ Branch 17 → 19 taken 1 time.
|
65 | !targetFolder.isEmpty() && !messageId.isEmpty(); |
| 60 | } | ||
| 61 |
2/2✓ Branch 22 → 23 taken 1 time.
✓ Branch 22 → 24 taken 6721 times.
|
6722 | if (!mailId.isValid()) |
| 62 | 1 | return false; | |
| 63 |
2/2✓ Branch 24 → 25 taken 875 times.
✓ Branch 24 → 27 taken 5846 times.
|
6721 | if (replayClass == MutationReplayClass::DesiredState) |
| 64 | 875 | return !flag.isEmpty(); | |
| 65 | 5846 | return !targetFolder.isEmpty(); | |
| 66 | } | ||
| 67 | }; | ||
| 68 | |||
| 69 | Q_DECLARE_METATYPE(MutationKind) | ||
| 70 | Q_DECLARE_METATYPE(MutationPhase) | ||
| 71 | Q_DECLARE_METATYPE(MutationReplayClass) | ||
| 72 | Q_DECLARE_METATYPE(MutationRecord) | ||
| 73 |