[go: nahoru, domu]

Directly construct IPP requests for print job management

Instead of relying on libcups functions to do it for us. This allows us
to bypass the awkward abstraction of cups_option_t, where all attributes
had to be encoded as strings, and send collection-type attributes like
"client-info" without relying on the undocumented internal format used
by libcups.

Bug: b:267349303
Test: send print jobs with various options to ippeveprinter
Test: print something using an actual printer
Change-Id: I7ec030c28e33dbf9a68cfbb14185c585b3a797b9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4209858
Reviewed-by: Benjamin Gordon <bmgordon@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Sparik Hayrapetyan <ust@google.com>
Auto-Submit: Bryan Cain <bryancain@chromium.org>
Commit-Queue: Bryan Cain <bryancain@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1103416}
diff --git a/printing/client_info_helpers.h b/printing/client_info_helpers.h
index 3c306ade..df96eea 100644
--- a/printing/client_info_helpers.h
+++ b/printing/client_info_helpers.h
@@ -5,11 +5,9 @@
 #ifndef PRINTING_CLIENT_INFO_HELPERS_H_
 #define PRINTING_CLIENT_INFO_HELPERS_H_
 
-#include <string>
-
+#include <cstddef>
 #include "base/component_export.h"
 #include "printing/mojom/print.mojom-forward.h"
-#include "third_party/abseil-cpp/absl/types/optional.h"
 
 namespace printing {
 
@@ -19,15 +17,13 @@
 inline constexpr size_t kClientInfoMaxStringVersionLength = 127;
 inline constexpr size_t kClientInfoMaxVersionLength = 64;
 
-// Returns the string representation of `client_info` in a format suitable for
-// use as a `cups_option_t` value, or absl::nullopt if `client_info` is invalid.
-// `client_info` represents one value of the 'client-info' multi-valued IPP
-// attribute. `client_info` is considered valid if all string members match the
-// regex [a-zA-Z0-9_.-]* and do not exceed the maximum length specified for the
-// respective IPP member attribute.
+// Returns true if all members of `client_info` are valid.
+// String members are considered valid if they match the regex [a-zA-Z0-9_.-]*
+// and do not exceed the maximum length specified for the respective IPP member
+// attribute. The `client_type` member is valid if it is equal to one of the
+// enum values defined for the `client-type` IPP attribute.
 COMPONENT_EXPORT(PRINTING)
-absl::optional<std::string> ClientInfoCollectionToCupsOptionValue(
-    const mojom::IppClientInfo& client_info);
+bool ValidateClientInfoItem(const mojom::IppClientInfo& client_info);
 
 }  // namespace printing