You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
138 lines
6.3 KiB
138 lines
6.3 KiB
7 months ago
|
diff -up chromium-126.0.6478.26/printing/backend/cups_helper.cc.el7cups chromium-126.0.6478.26/printing/backend/cups_helper.cc
|
||
|
--- chromium-126.0.6478.26/printing/backend/cups_helper.cc.el7cups 2024-06-03 17:16:32.197509643 +0200
|
||
|
+++ chromium-126.0.6478.26/printing/backend/cups_helper.cc 2024-06-03 17:32:23.028376333 +0200
|
||
|
@@ -41,18 +41,6 @@ namespace printing {
|
||
3 years ago
|
// This section contains helper code for PPD parsing for semantic capabilities.
|
||
|
namespace {
|
||
|
|
||
|
-// Function availability can be tested by checking whether its address is not
|
||
|
-// nullptr. Weak symbols remove the need for platform specific build flags and
|
||
|
-// allow for appropriate CUPS usage on platforms with non-uniform version
|
||
|
-// support, namely Linux.
|
||
|
-#define WEAK_CUPS_FN(x) extern "C" __attribute__((weak)) decltype(x) x
|
||
|
-
|
||
|
-WEAK_CUPS_FN(httpConnect2);
|
||
|
-
|
||
|
-// Timeout for establishing a CUPS connection. It is expected that cupsd is
|
||
|
-// able to start and respond on all systems within this duration.
|
||
|
-constexpr base::TimeDelta kCupsTimeout = base::Seconds(5);
|
||
|
-
|
||
|
// CUPS default max copies value (parsed from kCupsMaxCopies PPD attribute).
|
||
|
constexpr int32_t kDefaultMaxCopies = 9999;
|
||
|
constexpr char kCupsMaxCopies[] = "cupsMaxCopies";
|
||
7 months ago
|
@@ -761,8 +749,7 @@ const int kDefaultIPPServerPort = 631;
|
||
3 years ago
|
// Helper wrapper around http_t structure, with connection and cleanup
|
||
|
// functionality.
|
||
|
HttpConnectionCUPS::HttpConnectionCUPS(const GURL& print_server_url,
|
||
|
- http_encryption_t encryption,
|
||
7 months ago
|
- bool blocking) {
|
||
|
+ http_encryption_t encryption) {
|
||
3 years ago
|
// If we have an empty url, use default print server.
|
||
|
if (print_server_url.is_empty())
|
||
7 months ago
|
return;
|
||
|
@@ -771,31 +758,22 @@ HttpConnectionCUPS::HttpConnectionCUPS(c
|
||
3 years ago
|
if (port == url::PORT_UNSPECIFIED)
|
||
|
port = kDefaultIPPServerPort;
|
||
|
|
||
|
- if (httpConnect2) {
|
||
7 months ago
|
- http_.reset(httpConnect2(print_server_url.host().c_str(), port,
|
||
|
- /*addrlist=*/nullptr, AF_UNSPEC, encryption,
|
||
|
- blocking ? 1 : 0, kCupsTimeout.InMilliseconds(),
|
||
|
- /*cancel=*/nullptr));
|
||
3 years ago
|
- } else {
|
||
|
- // Continue to use deprecated CUPS calls because because older Linux
|
||
|
- // distribution such as RHEL/CentOS 7 are shipped with CUPS 1.6.
|
||
7 months ago
|
- http_.reset(
|
||
|
+ http_.reset(
|
||
|
httpConnectEncrypt(print_server_url.host().c_str(), port, encryption));
|
||
3 years ago
|
- }
|
||
|
|
||
|
if (!http_) {
|
||
|
LOG(ERROR) << "CP_CUPS: Failed connecting to print server: "
|
||
7 months ago
|
<< print_server_url;
|
||
3 years ago
|
return;
|
||
|
}
|
||
7 months ago
|
-
|
||
|
- if (!httpConnect2) {
|
||
|
- httpBlocking(http(), blocking ? 1 : 0);
|
||
|
- }
|
||
3 years ago
|
}
|
||
|
|
||
7 months ago
|
HttpConnectionCUPS::~HttpConnectionCUPS() = default;
|
||
3 years ago
|
|
||
|
+void HttpConnectionCUPS::SetBlocking(bool blocking) {
|
||
7 months ago
|
+ httpBlocking(http(), blocking ? 1 : 0);
|
||
3 years ago
|
+}
|
||
|
+
|
||
|
http_t* HttpConnectionCUPS::http() {
|
||
7 months ago
|
return http_.get();
|
||
3 years ago
|
}
|
||
7 months ago
|
diff -up chromium-126.0.6478.26/printing/backend/cups_helper.h.el7cups chromium-126.0.6478.26/printing/backend/cups_helper.h
|
||
|
--- chromium-126.0.6478.26/printing/backend/cups_helper.h.el7cups 2024-06-03 17:23:35.923307842 +0200
|
||
|
+++ chromium-126.0.6478.26/printing/backend/cups_helper.h 2024-06-03 17:25:50.887855460 +0200
|
||
|
@@ -36,10 +36,11 @@ constexpr cups_ptype_t kDestinationsFilt
|
||
3 years ago
|
class COMPONENT_EXPORT(PRINT_BACKEND) HttpConnectionCUPS {
|
||
|
public:
|
||
|
HttpConnectionCUPS(const GURL& print_server_url,
|
||
|
- http_encryption_t encryption,
|
||
|
- bool blocking);
|
||
|
+ http_encryption_t encryption);
|
||
|
~HttpConnectionCUPS();
|
||
|
|
||
|
+ void SetBlocking(bool blocking);
|
||
|
+
|
||
|
http_t* http();
|
||
|
|
||
|
private:
|
||
7 months ago
|
diff -up chromium-126.0.6478.26/printing/backend/print_backend_cups.cc.el7cups chromium-126.0.6478.26/printing/backend/print_backend_cups.cc
|
||
|
--- chromium-126.0.6478.26/printing/backend/print_backend_cups.cc.el7cups 2024-06-03 17:26:44.607871149 +0200
|
||
|
+++ chromium-126.0.6478.26/printing/backend/print_backend_cups.cc 2024-06-03 17:29:15.889810651 +0200
|
||
|
@@ -149,7 +149,7 @@ mojom::ResultCode PrintBackendCUPS::Enum
|
||
3 years ago
|
// not showing as available. Using cupsEnumDests() allows us to do our own
|
||
|
// filtering should any duplicates occur.
|
||
|
CupsDestsData dests_data = {0, nullptr};
|
||
|
- ipp_status_t last_error = IPP_STATUS_OK;
|
||
|
+ ipp_status_t last_error = IPP_OK;
|
||
|
if (print_server_url_.is_empty()) {
|
||
|
VLOG(1) << "CUPS: using cupsEnumDests to enumerate printers";
|
||
|
if (!cupsEnumDests(CUPS_DEST_FLAGS_NONE, kCupsTimeoutMs,
|
||
7 months ago
|
@@ -176,7 +176,7 @@ mojom::ResultCode PrintBackendCUPS::Enum
|
||
3 years ago
|
// no printer drivers installed. Rely upon CUPS error code to distinguish
|
||
|
// between these.
|
||
|
DCHECK(!dests_data.dests);
|
||
|
- if (last_error != IPP_STATUS_ERROR_NOT_FOUND) {
|
||
|
+ if (last_error != IPP_NOT_FOUND) {
|
||
|
VLOG(1) << "CUPS: Error getting printers from CUPS server"
|
||
|
<< ", server: " << print_server_url_
|
||
|
<< ", error: " << static_cast<int>(last_error) << " - "
|
||
7 months ago
|
@@ -311,7 +311,8 @@ int PrintBackendCUPS::GetDests(cups_dest
|
||
3 years ago
|
if (print_server_url_.is_empty())
|
||
|
return cupsGetDests2(CUPS_HTTP_DEFAULT, dests);
|
||
|
|
||
|
- HttpConnectionCUPS http(print_server_url_, cups_encryption_, blocking_);
|
||
|
+ HttpConnectionCUPS http(print_server_url_, cups_encryption_);
|
||
|
+ http.SetBlocking(blocking_);
|
||
|
|
||
|
// This call must be made in the same scope as `http` because its destructor
|
||
|
// closes the connection.
|
||
7 months ago
|
@@ -337,7 +338,8 @@ base::FilePath PrintBackendCUPS::GetPPD(
|
||
3 years ago
|
// connection will timeout after 10 seconds of no data period. And it will
|
||
|
// return the same way as if data was completely and successfully
|
||
|
// downloaded.
|
||
|
- HttpConnectionCUPS http(print_server_url_, cups_encryption_, blocking_);
|
||
|
+ HttpConnectionCUPS http(print_server_url_, cups_encryption_);
|
||
|
+ http.SetBlocking(blocking_);
|
||
|
ppd_file_path = cupsGetPPD2(http.http(), name);
|
||
|
// Check if the get full PPD, since non-blocking call may simply return
|
||
|
// normally after timeout expired.
|
||
7 months ago
|
@@ -373,7 +375,8 @@ ScopedDestination PrintBackendCUPS::GetN
|
||
3 years ago
|
// Use default (local) print server.
|
||
|
dest = cupsGetNamedDest(CUPS_HTTP_DEFAULT, printer_name.c_str(), nullptr);
|
||
|
} else {
|
||
|
- HttpConnectionCUPS http(print_server_url_, cups_encryption_, blocking_);
|
||
|
+ HttpConnectionCUPS http(print_server_url_, cups_encryption_);
|
||
|
+ http.SetBlocking(blocking_);
|
||
|
dest = cupsGetNamedDest(http.http(), printer_name.c_str(), nullptr);
|
||
|
}
|
||
|
return ScopedDestination(dest);
|