Chromium Code Reviews| Index: printing/backend/cups_printer.h |
| diff --git a/printing/backend/cups_printer.h b/printing/backend/cups_printer.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..134f20933dfdb21ac69701a37e82d1dc245719e0 |
| --- /dev/null |
| +++ b/printing/backend/cups_printer.h |
| @@ -0,0 +1,110 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef PRINTING_BACKEND_CUPS_PRINTER_H_ |
| +#define PRINTING_BACKEND_CUPS_PRINTER_H_ |
| + |
| +#include <cups/cups.h> |
| + |
| +#include <memory> |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "base/memory/weak_ptr.h" |
| +#include "printing/printing_export.h" |
| +#include "url/gurl.h" |
| + |
| +namespace base { |
| +class FilePath; |
| +} |
| + |
| +namespace printing { |
| + |
| +struct PrinterBasicInfo; |
| + |
| +class DestinationDeleter { |
|
Lei Zhang
2016/07/13 01:08:42
Could some of these be shared for use with print_b
skau
2016/07/14 20:43:06
I've moved them to a separate file. It's probably
|
| + public: |
| + void operator()(cups_dest_t* dest) const; |
| +}; |
| + |
| +class DestInfoDeleter { |
| + public: |
| + void operator()(cups_dinfo_t* info) const; |
| +}; |
| + |
| +// Represents a CUPS printer. |
| +// Retrieves information from CUPS printer objects as requested. |
| +class PRINTING_EXPORT CupsPrinter { |
| + public: |
| + // This object now owns |dest| and |info|. |
| + explicit CupsPrinter(base::WeakPtr<http_t> http, |
|
Lei Zhang
2016/07/13 01:08:42
Not explicit.
skau
2016/07/14 20:43:06
Done.
|
| + cups_dest_t* dest, |
| + cups_dinfo_t* info); |
| + |
| + CupsPrinter(CupsPrinter&& printer); |
| + |
| + ~CupsPrinter(); |
| + |
| + // Returns true if this is the default printer |
| + bool is_default() const; |
| + |
| + // Returns the supported ipp attributes for the given |option_name|. |
| + // ipp_attribute_t* is owned by CupsPrinter. |
| + ipp_attribute_t* GetSupportedOptionValues( |
| + base::StringPiece option_name) const; |
| + |
| + // Returns supported attribute values for |option_name| where the value can be |
| + // convered to a string. |
| + std::vector<base::StringPiece> GetSupportedOptionValueStrings( |
| + base::StringPiece option_name) const; |
| + |
| + // Returns the default ipp attributes for the given |option_name|. |
| + // ipp_attribute_t* is owned by CupsPrinter. |
| + ipp_attribute_t* GetDefaultOptionValue(base::StringPiece option_name) const; |
| + |
| + bool CheckOptionSupported(base::StringPiece name, |
| + base::StringPiece value) const; |
| + |
| + // Returns the file name for the PPD retrieved from the print server. |
| + base::FilePath GetPPD() const; |
| + |
| + // Returns the name of the printer as configured in CUPS |
| + const std::string GetName() const; |
| + |
| + const std::string GetMakeAndModel() const; |
| + |
| + // Returns true if the printer is currently reachable and working. |
| + bool IsAvailable() const; |
| + |
| + // Populates |basic_info| with the relevant information about the printer |
| + bool ToPrinterInfo(PrinterBasicInfo* basic_info) const; |
| + |
| + ipp_status_t CreateJob(int* job_id, |
| + base::StringPiece job_title, |
| + const std::vector<cups_option_t>& options); |
| + |
| + bool StartDocument(int job_id, |
| + base::StringPiece document_name, |
| + bool last_doc, |
| + const std::vector<cups_option_t>& options); |
| + |
| + bool StreamData(char* buffer, int len); |
|
Lei Zhang
2016/07/13 01:32:04
Can this take a const std::vector<char>& - use ST
skau
2016/07/14 20:43:06
Done.
|
| + |
| + bool FinishDocument(); |
| + |
| + ipp_status_t CloseJob(int job_id); |
| + |
| + private: |
| + bool InitializeDestInfo() const; |
| + |
| + base::WeakPtr<http_t> cups_http_; |
| + std::unique_ptr<cups_dest_t, DestinationDeleter> destination_; |
| + mutable std::unique_ptr<cups_dinfo_t, DestInfoDeleter> dest_info_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(CupsPrinter); |
| +}; |
| + |
| +} // namespace printing |
| + |
| +#endif // PRINTING_BACKEND_CUPS_PRINTER_H_ |