| 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..692ee888b545ef52b90bb57fb26dc069c790c411
|
| --- /dev/null
|
| +++ b/printing/backend/cups_printer.h
|
| @@ -0,0 +1,109 @@
|
| +// 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 "printing/printing_export.h"
|
| +#include "url/gurl.h"
|
| +
|
| +namespace base {
|
| +class FilePath;
|
| +}
|
| +
|
| +namespace printing {
|
| +
|
| +struct PrinterBasicInfo;
|
| +
|
| +class DestinationDeleter {
|
| + 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(std::shared_ptr<http_t> http,
|
| + 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);
|
| +
|
| + bool FinishDocument();
|
| +
|
| + ipp_status_t CloseJob(int job_id);
|
| +
|
| + private:
|
| + bool InitializeDestInfo() const;
|
| +
|
| + std::shared_ptr<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_
|
|
|