Skip to content
This repository was archived by the owner on Mar 7, 2026. It is now read-only.

Commit 7f85a4c

Browse files
authored
Enhance CertStatus with raw status numbers
Updated CertStatus to include raw status numbers and modified related logic in CertificateView and AddCertificateView.
1 parent aa97d7c commit 7f85a4c

1 file changed

Lines changed: 27 additions & 12 deletions

File tree

Sources/prosign/views/CertificateView.swift

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import SwiftUI
22
import UniformTypeIdentifiers
33
import ProStoreTools
4+
45
// Centralized types to avoid conflicts
56
struct CertificateFileItem {
67
var name: String = ""
@@ -12,24 +13,25 @@ struct CustomCertificate: Identifiable {
1213
let folderName: String
1314
}
1415

16+
// CertStatus stores the optional expiration Date and the raw numeric status returned from checkRevokage
1517
enum CertStatus {
1618
case loading
17-
case signed(Date?)
18-
case revoked(Date?)
19-
case unknown
19+
case signed(Date?, Int) // e.g. (expirationDate, rawStatusNumber)
20+
case revoked(Date?, Int) // e.g. (expirationDate, rawStatusNumber)
21+
case unknown(Int) // rawStatusNumber for unknown (-1, etc.)
2022
}
2123

2224
extension CertStatus {
2325
var description: String {
2426
switch self {
2527
case .loading:
2628
return "Status: Loading"
27-
case .signed:
28-
return "Status: Signed"
29-
case .revoked:
30-
return "Status: Revoked"
31-
case .unknown:
32-
return "Status: Unknown"
29+
case .signed(_, let raw):
30+
return "Status: Signed (\(raw))"
31+
case .revoked(_, let raw):
32+
return "Status: Revoked (\(raw))"
33+
case .unknown(let raw):
34+
return "Status: Unknown (\(raw))"
3335
}
3436
}
3537

@@ -45,7 +47,20 @@ extension CertStatus {
4547
return .yellow
4648
}
4749
}
50+
51+
// Optional: expose expiration date if needed elsewhere
52+
var expirationDate: Date? {
53+
switch self {
54+
case .signed(let date, _):
55+
return date
56+
case .revoked(let date, _):
57+
return date
58+
default:
59+
return nil
60+
}
61+
}
4862
}
63+
4964
// MARK: - CertificateView (List + Add/Edit launchers)
5065
struct CertificateView: View {
5166
@State private var customCertificates: [CustomCertificate] = []
@@ -211,11 +226,11 @@ struct CertificateView: View {
211226
let newStatus: CertStatus
212227
switch status {
213228
case 0:
214-
newStatus = .signed(expirationDate)
229+
newStatus = .signed(expirationDate, status)
215230
case 1, 2:
216-
newStatus = .revoked(expirationDate)
231+
newStatus = .revoked(expirationDate, status)
217232
default:
218-
newStatus = .unknown
233+
newStatus = .unknown(status)
219234
}
220235
self.certStatuses[folderName] = newStatus
221236
}

0 commit comments

Comments
 (0)