Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "printing/backend/cups_jobs.h" | 5 #include "printing/backend/cups_jobs.h" |
| 6 | 6 |
| 7 #include <cups/ipp.h> | 7 #include <cups/ipp.h> |
| 8 | 8 |
| 9 #include <array> | 9 #include <array> |
| 10 #include <map> | 10 #include <map> |
| 11 #include <memory> | 11 #include <memory> |
| 12 | 12 |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/stl_util.h" | |
| 14 #include "base/strings/string_piece.h" | 15 #include "base/strings/string_piece.h" |
| 15 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 17 #include "base/threading/thread_restrictions.h" | |
| 18 #include "base/version.h" | |
| 19 #include "printing/backend/cups_deleters.h" | |
| 16 | 20 |
| 17 namespace printing { | 21 namespace printing { |
| 18 namespace { | 22 namespace { |
| 19 | 23 |
| 20 using PReason = PrinterStatus::PrinterReason::Reason; | 24 using PReason = PrinterStatus::PrinterReason::Reason; |
| 21 using PSeverity = PrinterStatus::PrinterReason::Severity; | 25 using PSeverity = PrinterStatus::PrinterReason::Severity; |
| 22 | 26 |
| 23 // printer attributes | 27 // printer attributes |
| 24 const char kPrinterUri[] = "printer-uri"; | 28 const char kPrinterUri[] = "printer-uri"; |
| 25 const char kPrinterState[] = "printer-state"; | 29 const char kPrinterState[] = "printer-state"; |
| 26 const char kPrinterStateReasons[] = "printer-state-reasons"; | 30 const char kPrinterStateReasons[] = "printer-state-reasons"; |
| 27 const char kPrinterStateMessage[] = "printer-state-message"; | 31 const char kPrinterStateMessage[] = "printer-state-message"; |
| 28 | 32 |
| 33 const char kPrinterMakeAndModel[] = "printer-make-and-model"; | |
| 34 const char kIppVersionsSupported[] = "ipp-versions-supported"; | |
| 35 const char kIppFeaturesSupported[] = "ipp-features-supported"; | |
| 36 const char kDocumentFormatSupported[] = "document-format-supported"; | |
| 37 | |
| 29 // job attributes | 38 // job attributes |
| 30 const char kJobUri[] = "job-uri"; | 39 const char kJobUri[] = "job-uri"; |
| 31 const char kJobId[] = "job-id"; | 40 const char kJobId[] = "job-id"; |
| 32 const char kJobState[] = "job-state"; | 41 const char kJobState[] = "job-state"; |
| 33 const char kJobStateReasons[] = "job-state-reasons"; | 42 const char kJobStateReasons[] = "job-state-reasons"; |
| 34 const char kJobStateMessage[] = "job-state-message"; | 43 const char kJobStateMessage[] = "job-state-message"; |
| 35 const char kJobImpressionsCompleted[] = "job-impressions-completed"; | 44 const char kJobImpressionsCompleted[] = "job-impressions-completed"; |
| 36 const char kTimeAtProcessing[] = "time-at-processing"; | 45 const char kTimeAtProcessing[] = "time-at-processing"; |
| 37 | 46 |
| 38 // request parameters | 47 // request parameters |
| 39 const char kRequestedAttributes[] = "requested-attributes"; | 48 const char kRequestedAttributes[] = "requested-attributes"; |
| 40 const char kWhichJobs[] = "which-jobs"; | 49 const char kWhichJobs[] = "which-jobs"; |
| 41 const char kLimit[] = "limit"; | 50 const char kLimit[] = "limit"; |
| 42 | 51 |
| 43 // request values | 52 // request values |
| 44 const char kCompleted[] = "completed"; | 53 const char kCompleted[] = "completed"; |
| 45 const char kNotCompleted[] = "not-completed"; | 54 const char kNotCompleted[] = "not-completed"; |
| 46 | 55 |
| 56 // ipp features | |
| 57 const char kIppEverywhere[] = "ipp-everywhere"; | |
| 58 | |
| 47 // printer state severities | 59 // printer state severities |
| 48 const char kSeverityReport[] = "report"; | 60 const char kSeverityReport[] = "report"; |
| 49 const char kSeverityWarn[] = "warning"; | 61 const char kSeverityWarn[] = "warning"; |
| 50 const char kSeverityError[] = "error"; | 62 const char kSeverityError[] = "error"; |
| 51 | 63 |
| 52 // printer state reason values | 64 // printer state reason values |
| 53 const char kNone[] = "none"; | 65 const char kNone[] = "none"; |
| 54 const char kMediaNeeded[] = "media-needed"; | 66 const char kMediaNeeded[] = "media-needed"; |
| 55 const char kMediaJam[] = "media-jam"; | 67 const char kMediaJam[] = "media-jam"; |
| 56 const char kMovingToPaused[] = "moving-to-paused"; | 68 const char kMovingToPaused[] = "moving-to-paused"; |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 81 const char kOpcNearEol[] = "opc-near-eol"; | 93 const char kOpcNearEol[] = "opc-near-eol"; |
| 82 const char kOpcLifeOver[] = "opc-life-over"; | 94 const char kOpcLifeOver[] = "opc-life-over"; |
| 83 const char kDeveloperLow[] = "developer-low"; | 95 const char kDeveloperLow[] = "developer-low"; |
| 84 const char kDeveloperEmpty[] = "developer-empty"; | 96 const char kDeveloperEmpty[] = "developer-empty"; |
| 85 const char kInterpreterResourceUnavailable[] = | 97 const char kInterpreterResourceUnavailable[] = |
| 86 "interpreter-resource-unavailable"; | 98 "interpreter-resource-unavailable"; |
| 87 | 99 |
| 88 constexpr std::array<const char* const, 3> kPrinterAttributes{ | 100 constexpr std::array<const char* const, 3> kPrinterAttributes{ |
| 89 {kPrinterState, kPrinterStateReasons, kPrinterStateMessage}}; | 101 {kPrinterState, kPrinterStateReasons, kPrinterStateMessage}}; |
| 90 | 102 |
| 91 std::unique_ptr<ipp_t, void (*)(ipp_t*)> WrapIpp(ipp_t* ipp) { | 103 constexpr std::array<const char* const, 4> kPrinterInfo{ |
| 92 return std::unique_ptr<ipp_t, void (*)(ipp_t*)>(ipp, &ippDelete); | 104 {kPrinterMakeAndModel, kIppVersionsSupported, kIppFeaturesSupported, |
| 105 kDocumentFormatSupported}}; | |
| 106 | |
| 107 using ScopedIppPtr = std::unique_ptr<ipp_t, void (*)(ipp_t*)>; | |
| 108 | |
| 109 ScopedIppPtr WrapIpp(ipp_t* ipp) { | |
| 110 return ScopedIppPtr(ipp, &ippDelete); | |
| 93 } | 111 } |
| 94 | 112 |
| 113 using ScopedHttpPtr = std::unique_ptr<http_t, HttpDeleter>; | |
| 114 | |
| 95 // Converts an IPP attribute |attr| to the appropriate JobState enum. | 115 // Converts an IPP attribute |attr| to the appropriate JobState enum. |
| 96 CupsJob::JobState ToJobState(ipp_attribute_t* attr) { | 116 CupsJob::JobState ToJobState(ipp_attribute_t* attr) { |
| 97 DCHECK_EQ(IPP_TAG_ENUM, ippGetValueTag(attr)); | 117 DCHECK_EQ(IPP_TAG_ENUM, ippGetValueTag(attr)); |
| 98 int state = ippGetInteger(attr, 0); | 118 int state = ippGetInteger(attr, 0); |
| 99 switch (state) { | 119 switch (state) { |
| 100 case IPP_JOB_ABORTED: | 120 case IPP_JOB_ABORTED: |
| 101 return CupsJob::ABORTED; | 121 return CupsJob::ABORTED; |
| 102 case IPP_JOB_CANCELLED: | 122 case IPP_JOB_CANCELLED: |
| 103 return CupsJob::CANCELED; | 123 return CupsJob::CANCELED; |
| 104 case IPP_JOB_COMPLETED: | 124 case IPP_JOB_COMPLETED: |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 274 ParseField(attr, attribute_name, current_job); | 294 ParseField(attr, attribute_name, current_job); |
| 275 } | 295 } |
| 276 } | 296 } |
| 277 | 297 |
| 278 // Returns the uri for printer with |id| as served by CUPS. Assumes that |id| | 298 // Returns the uri for printer with |id| as served by CUPS. Assumes that |id| |
| 279 // is a valid CUPS printer name and performs no error checking or escaping. | 299 // is a valid CUPS printer name and performs no error checking or escaping. |
| 280 std::string PrinterUriFromName(const std::string& id) { | 300 std::string PrinterUriFromName(const std::string& id) { |
| 281 return base::StringPrintf("ipp://localhost/printers/%s", id.c_str()); | 301 return base::StringPrintf("ipp://localhost/printers/%s", id.c_str()); |
| 282 } | 302 } |
| 283 | 303 |
| 304 // Extracts PrinterInfo fields from |response| and populates |printer_info|. | |
| 305 // Returns true if at least printer-make-and-model and ipp-versions-supported | |
| 306 // were read. | |
| 307 bool ParsePrinterInfo(ipp_t* response, PrinterInfo* printer_info) { | |
| 308 for (ipp_attribute_t* attr = ippFirstAttribute(response); attr != nullptr; | |
| 309 attr = ippNextAttribute(response)) { | |
| 310 base::StringPiece name = ippGetName(attr); | |
| 311 | |
| 312 if (name == base::StringPiece(kPrinterMakeAndModel)) { | |
| 313 DCHECK_EQ(IPP_TAG_TEXT, ippGetValueTag(attr)); | |
| 314 printer_info->make_and_model = ippGetString(attr, 0, nullptr); | |
| 315 } else if (name == base::StringPiece(kIppVersionsSupported)) { | |
| 316 std::vector<std::string> ipp_versions; | |
| 317 ParseCollection(attr, &ipp_versions); | |
| 318 for (const std::string& version : ipp_versions) { | |
| 319 base::Version major_minor(version); | |
| 320 if (major_minor.IsValid()) { | |
| 321 printer_info->ipp_versions.push_back(major_minor); | |
| 322 } | |
| 323 } | |
| 324 } else if (name == base::StringPiece(kIppFeaturesSupported)) { | |
| 325 std::vector<std::string> features; | |
| 326 ParseCollection(attr, &features); | |
| 327 printer_info->ipp_everywhere = | |
| 328 base::ContainsValue(features, kIppEverywhere); | |
| 329 } else if (name == base::StringPiece(kDocumentFormatSupported)) { | |
| 330 ParseCollection(attr, &printer_info->document_formats); | |
| 331 } | |
| 332 } | |
| 333 | |
| 334 return !printer_info->make_and_model.empty() && | |
| 335 !printer_info->ipp_versions.empty(); | |
| 336 } | |
| 337 | |
| 284 } // namespace | 338 } // namespace |
| 285 | 339 |
| 286 CupsJob::CupsJob() = default; | 340 CupsJob::CupsJob() = default; |
| 287 | 341 |
| 288 CupsJob::CupsJob(const CupsJob& other) = default; | 342 CupsJob::CupsJob(const CupsJob& other) = default; |
| 289 | 343 |
| 290 CupsJob::~CupsJob() = default; | 344 CupsJob::~CupsJob() = default; |
| 291 | 345 |
| 292 PrinterStatus::PrinterStatus() = default; | 346 PrinterStatus::PrinterStatus() = default; |
| 293 | 347 |
| 294 PrinterStatus::PrinterStatus(const PrinterStatus& other) = default; | 348 PrinterStatus::PrinterStatus(const PrinterStatus& other) = default; |
| 295 | 349 |
| 296 PrinterStatus::~PrinterStatus() = default; | 350 PrinterStatus::~PrinterStatus() = default; |
| 297 | 351 |
| 352 PrinterInfo::PrinterInfo() = default; | |
| 353 | |
| 354 PrinterInfo::~PrinterInfo() = default; | |
| 355 | |
| 298 void ParseJobsResponse(ipp_t* response, | 356 void ParseJobsResponse(ipp_t* response, |
| 299 const std::string& printer_id, | 357 const std::string& printer_id, |
| 300 std::vector<CupsJob>* jobs) { | 358 std::vector<CupsJob>* jobs) { |
| 301 // Advance the position in the response to the jobs section. | 359 // Advance the position in the response to the jobs section. |
| 302 ipp_attribute_t* attr = ippFirstAttribute(response); | 360 ipp_attribute_t* attr = ippFirstAttribute(response); |
| 303 while (attr != nullptr && ippGetGroupTag(attr) != IPP_TAG_JOB) { | 361 while (attr != nullptr && ippGetGroupTag(attr) != IPP_TAG_JOB) { |
| 304 attr = ippNextAttribute(response); | 362 attr = ippNextAttribute(response); |
| 305 } | 363 } |
| 306 | 364 |
| 307 if (attr != nullptr) { | 365 if (attr != nullptr) { |
| 308 ParseJobs(response, printer_id, attr, jobs); | 366 ParseJobs(response, printer_id, attr, jobs); |
| 309 } | 367 } |
| 310 } | 368 } |
| 311 | 369 |
| 370 // Returns an IPP response for a Get-Printer-Attributes request to |http|. For | |
| 371 // print servers, |printer_uri| is used as the printer-uri value. | |
| 372 // |resource_path| specifies the path portion of the server URI. | |
| 373 // |num_attributes| is the number of attributes in |attributes| which should be | |
| 374 // a list of IPP attributes. |status| is updated with status code for the | |
| 375 // request. A successful request will have the |status| IPP_STATUS_OK. | |
| 376 ScopedIppPtr GetPrinterAttributes(http_t* http, | |
| 377 const std::string& printer_uri, | |
| 378 const std::string& resource_path, | |
| 379 int num_attributes, | |
| 380 const char* const* attributes, | |
| 381 ipp_status_t* status) { | |
| 382 base::ThreadRestrictions::AssertIOAllowed(); | |
| 383 DCHECK(http); | |
| 384 | |
| 385 // CUPS expects a leading slash for resource names. Add one if it's missing. | |
| 386 std::string rp = | |
| 387 resource_path.front() == '/' ? resource_path : "/" + resource_path; | |
|
Lei Zhang
2017/06/07 22:29:28
Does front() work if |resource_path| is an empty s
skau
2017/06/07 22:41:34
No. front() is undefined for an empty string. :(
| |
| 388 | |
| 389 auto request = WrapIpp(ippNewRequest(IPP_OP_GET_PRINTER_ATTRIBUTES)); | |
| 390 | |
| 391 ippAddString(request.get(), IPP_TAG_OPERATION, IPP_TAG_URI, kPrinterUri, | |
| 392 nullptr, printer_uri.data()); | |
| 393 | |
| 394 ippAddStrings(request.get(), IPP_TAG_OPERATION, IPP_TAG_KEYWORD, | |
| 395 kRequestedAttributes, num_attributes, nullptr, attributes); | |
| 396 | |
| 397 auto response = WrapIpp(cupsDoRequest(http, request.release(), rp.c_str())); | |
| 398 *status = ippGetStatusCode(response.get()); | |
| 399 | |
| 400 return response; | |
| 401 } | |
| 402 | |
| 312 void ParsePrinterStatus(ipp_t* response, PrinterStatus* printer_status) { | 403 void ParsePrinterStatus(ipp_t* response, PrinterStatus* printer_status) { |
| 313 for (ipp_attribute_t* attr = ippFirstAttribute(response); attr != nullptr; | 404 for (ipp_attribute_t* attr = ippFirstAttribute(response); attr != nullptr; |
| 314 attr = ippNextAttribute(response)) { | 405 attr = ippNextAttribute(response)) { |
| 315 base::StringPiece name = ippGetName(attr); | 406 base::StringPiece name = ippGetName(attr); |
| 316 if (name.empty()) { | 407 if (name.empty()) { |
| 317 continue; | 408 continue; |
| 318 } | 409 } |
| 319 | 410 |
| 320 if (name == kPrinterState) { | 411 if (name == kPrinterState) { |
| 321 DCHECK_EQ(IPP_TAG_ENUM, ippGetValueTag(attr)); | 412 DCHECK_EQ(IPP_TAG_ENUM, ippGetValueTag(attr)); |
| 322 printer_status->state = static_cast<ipp_pstate_t>(ippGetInteger(attr, 0)); | 413 printer_status->state = static_cast<ipp_pstate_t>(ippGetInteger(attr, 0)); |
| 323 } else if (name == kPrinterStateReasons) { | 414 } else if (name == kPrinterStateReasons) { |
| 324 std::vector<std::string> reason_strings; | 415 std::vector<std::string> reason_strings; |
| 325 ParseCollection(attr, &reason_strings); | 416 ParseCollection(attr, &reason_strings); |
| 326 for (const std::string& reason : reason_strings) { | 417 for (const std::string& reason : reason_strings) { |
| 327 printer_status->reasons.push_back(ToPrinterReason(reason)); | 418 printer_status->reasons.push_back(ToPrinterReason(reason)); |
| 328 } | 419 } |
| 329 } else if (name == kPrinterStateMessage) { | 420 } else if (name == kPrinterStateMessage) { |
| 330 printer_status->message = ippGetString(attr, 0, nullptr); | 421 printer_status->message = ippGetString(attr, 0, nullptr); |
| 331 } | 422 } |
| 332 } | 423 } |
| 333 } | 424 } |
| 334 | 425 |
| 426 bool GetPrinterInfo(const std::string& address, | |
| 427 const int port, | |
| 428 const std::string& resource, | |
| 429 PrinterInfo* printer_info) { | |
| 430 base::ThreadRestrictions::AssertIOAllowed(); | |
| 431 | |
| 432 ScopedHttpPtr http = ScopedHttpPtr( | |
| 433 httpConnect2(address.data(), port, nullptr, AF_INET, | |
| 434 HTTP_ENCRYPTION_IF_REQUESTED, 0, 200, nullptr)); | |
| 435 if (!http) { | |
| 436 LOG(WARNING) << "Could not connect to host"; | |
| 437 return false; | |
| 438 } | |
| 439 | |
| 440 ipp_status_t status; | |
| 441 ScopedIppPtr response = | |
| 442 GetPrinterAttributes(http.get(), resource, resource, kPrinterInfo.size(), | |
| 443 kPrinterInfo.data(), &status); | |
| 444 if (status != IPP_STATUS_OK || response.get() == nullptr) { | |
| 445 LOG(WARNING) << "Get attributes failure: " << status; | |
| 446 return false; | |
| 447 } | |
| 448 | |
| 449 return ParsePrinterInfo(response.get(), printer_info); | |
| 450 } | |
| 451 | |
| 335 bool GetPrinterStatus(http_t* http, | 452 bool GetPrinterStatus(http_t* http, |
| 336 const std::string& printer_id, | 453 const std::string& printer_id, |
| 337 PrinterStatus* printer_status) { | 454 PrinterStatus* printer_status) { |
| 338 DCHECK(http); | 455 base::ThreadRestrictions::AssertIOAllowed(); |
| 339 | 456 |
| 340 auto request = WrapIpp(ippNewRequest(IPP_OP_GET_PRINTER_ATTRIBUTES)); | 457 ipp_status_t status; |
| 458 const std::string printer_uri = PrinterUriFromName(printer_id); | |
| 341 | 459 |
| 342 const std::string printer_uri = PrinterUriFromName(printer_id); | 460 ScopedIppPtr response = |
| 343 ippAddString(request.get(), IPP_TAG_OPERATION, IPP_TAG_URI, kPrinterUri, | 461 GetPrinterAttributes(http, printer_uri, "/", kPrinterAttributes.size(), |
| 344 nullptr, printer_uri.data()); | 462 kPrinterAttributes.data(), &status); |
| 345 | 463 |
| 346 ippAddStrings(request.get(), IPP_TAG_OPERATION, IPP_TAG_KEYWORD, | 464 if (status != IPP_STATUS_OK) |
| 347 kRequestedAttributes, kPrinterAttributes.size(), nullptr, | |
| 348 kPrinterAttributes.data()); | |
| 349 | |
| 350 auto response = | |
| 351 WrapIpp(cupsDoRequest(http, request.release(), printer_uri.c_str())); | |
| 352 | |
| 353 if (ippGetStatusCode(response.get()) != IPP_STATUS_OK) | |
| 354 return false; | 465 return false; |
| 355 | 466 |
| 356 ParsePrinterStatus(response.get(), printer_status); | 467 ParsePrinterStatus(response.get(), printer_status); |
| 357 | 468 |
| 358 return true; | 469 return true; |
| 359 } | 470 } |
| 360 | 471 |
| 361 bool GetCupsJobs(http_t* http, | 472 bool GetCupsJobs(http_t* http, |
| 362 const std::string& printer_id, | 473 const std::string& printer_id, |
| 363 int limit, | 474 int limit, |
| 364 JobCompletionState which, | 475 JobCompletionState which, |
| 365 std::vector<CupsJob>* jobs) { | 476 std::vector<CupsJob>* jobs) { |
| 477 base::ThreadRestrictions::AssertIOAllowed(); | |
| 366 DCHECK(http); | 478 DCHECK(http); |
| 367 | 479 |
| 368 auto request = WrapIpp(ippNewRequest(IPP_OP_GET_JOBS)); | 480 auto request = WrapIpp(ippNewRequest(IPP_OP_GET_JOBS)); |
| 369 const std::string printer_uri = PrinterUriFromName(printer_id); | 481 const std::string printer_uri = PrinterUriFromName(printer_id); |
| 370 ippAddString(request.get(), IPP_TAG_OPERATION, IPP_TAG_URI, kPrinterUri, | 482 ippAddString(request.get(), IPP_TAG_OPERATION, IPP_TAG_URI, kPrinterUri, |
| 371 nullptr, printer_uri.data()); | 483 nullptr, printer_uri.data()); |
| 372 ippAddInteger(request.get(), IPP_TAG_OPERATION, IPP_TAG_INTEGER, kLimit, | 484 ippAddInteger(request.get(), IPP_TAG_OPERATION, IPP_TAG_INTEGER, kLimit, |
| 373 limit); | 485 limit); |
| 374 | 486 |
| 375 std::vector<const char*> job_attributes = { | 487 std::vector<const char*> job_attributes = { |
| 376 kJobUri, kJobId, kJobState, | 488 kJobUri, kJobId, kJobState, |
| 377 kJobStateReasons, kJobStateMessage, kJobImpressionsCompleted, | 489 kJobStateReasons, kJobStateMessage, kJobImpressionsCompleted, |
| 378 kTimeAtProcessing}; | 490 kTimeAtProcessing}; |
| 379 | 491 |
| 380 ippAddStrings(request.get(), IPP_TAG_OPERATION, IPP_TAG_KEYWORD, | 492 ippAddStrings(request.get(), IPP_TAG_OPERATION, IPP_TAG_KEYWORD, |
| 381 kRequestedAttributes, job_attributes.size(), nullptr, | 493 kRequestedAttributes, job_attributes.size(), nullptr, |
| 382 job_attributes.data()); | 494 job_attributes.data()); |
| 383 | 495 |
| 384 ippAddString(request.get(), IPP_TAG_OPERATION, IPP_TAG_KEYWORD, kWhichJobs, | 496 ippAddString(request.get(), IPP_TAG_OPERATION, IPP_TAG_KEYWORD, kWhichJobs, |
| 385 nullptr, which == COMPLETED ? kCompleted : kNotCompleted); | 497 nullptr, which == COMPLETED ? kCompleted : kNotCompleted); |
| 386 | 498 |
| 387 if (ippValidateAttributes(request.get()) != 1) { | 499 if (ippValidateAttributes(request.get()) != 1) { |
| 388 LOG(WARNING) << "Could not validate ipp request: " << cupsLastErrorString(); | 500 LOG(WARNING) << "Could not validate ipp request: " << cupsLastErrorString(); |
| 389 return false; | 501 return false; |
| 390 } | 502 } |
| 391 | 503 |
| 392 // cupsDoRequest will delete the request. | 504 // cupsDoRequest will delete the request. |
| 393 auto response = | 505 auto response = WrapIpp(cupsDoRequest(http, request.release(), "/")); |
| 394 WrapIpp(cupsDoRequest(http, request.release(), printer_uri.c_str())); | |
| 395 | 506 |
| 396 ipp_status_t status = ippGetStatusCode(response.get()); | 507 ipp_status_t status = ippGetStatusCode(response.get()); |
| 397 | 508 |
| 398 if (status != IPP_OK) { | 509 if (status != IPP_STATUS_OK) { |
| 399 LOG(WARNING) << "IPP Error: " << cupsLastErrorString(); | 510 LOG(WARNING) << "IPP Error: " << cupsLastErrorString(); |
| 400 return false; | 511 return false; |
| 401 } | 512 } |
| 402 | 513 |
| 403 ParseJobsResponse(response.get(), printer_id, jobs); | 514 ParseJobsResponse(response.get(), printer_id, jobs); |
| 404 | 515 |
| 405 return true; | 516 return true; |
| 406 } | 517 } |
| 407 | 518 |
| 408 } // namespace printing | 519 } // namespace printing |
| OLD | NEW |