mirror of
https://github.com/kfattic/cupsadmin.git
synced 2026-11-13 19:06:43 -05:00
Canon and HP driver profiles for quick actions
Canon: CNColorMode color/mono, CNDuplex, PageSize=Letter. HP: HPColorAsGray or HPColorMode; duplex and Letter from the generic profile. Profiles can mark an action unavailable with a reason (Canon department IDs, HP accounting codes). Use Letter Paper only says Fit to Nearest Size when the profile sets a fit option. Offline tests sweep every Canon and HP PPD found in CUPSKIT_PPD_DIRS or /Library/Printers/PPDs. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -52,8 +52,10 @@ public struct DriverProfile: Decodable, Identifiable {
|
||||
public let match: Match
|
||||
/// Action id -> alternatives, each a list of `keyword=value` pairs applied together.
|
||||
public let actions: [String: [[String]]]
|
||||
/// Action id -> why this driver can't do it (e.g. accounting codes set outside the PPD).
|
||||
public let unavailable: [String: String]
|
||||
|
||||
enum CodingKeys: String, CodingKey { case id, name, match, actions }
|
||||
enum CodingKeys: String, CodingKey { case id, name, match, actions, unavailable }
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
let c = try decoder.container(keyedBy: CodingKeys.self)
|
||||
@@ -65,6 +67,7 @@ public struct DriverProfile: Decodable, Identifiable {
|
||||
let raw = try c.decode([String: FlexiblePairs].self, forKey: .actions)
|
||||
for (action, pairs) in raw { actions[action] = pairs.alternatives }
|
||||
self.actions = actions
|
||||
unavailable = try c.decodeIfPresent([String: String].self, forKey: .unavailable) ?? [:]
|
||||
}
|
||||
|
||||
private struct FlexiblePairs: Decodable {
|
||||
|
||||
Reference in New Issue
Block a user