OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef PRINTING_BACKEND_CUPS_PRINTER_H_ | |
6 #define PRINTING_BACKEND_CUPS_PRINTER_H_ | |
7 | |
8 #include <cups/cups.h> | |
9 | |
10 #include <memory> | |
11 #include <string> | |
12 #include <vector> | |
13 | |
14 #include "base/memory/weak_ptr.h" | |
15 #include "printing/printing_export.h" | |
16 #include "url/gurl.h" | |
17 | |
18 namespace base { | |
19 class FilePath; | |
20 } | |
21 | |
22 namespace printing { | |
23 | |
24 struct PrinterBasicInfo; | |
25 | |
26 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
| |
27 public: | |
28 void operator()(cups_dest_t* dest) const; | |
29 }; | |
30 | |
31 class DestInfoDeleter { | |
32 public: | |
33 void operator()(cups_dinfo_t* info) const; | |
34 }; | |
35 | |
36 // Represents a CUPS printer. | |
37 // Retrieves information from CUPS printer objects as requested. | |
38 class PRINTING_EXPORT CupsPrinter { | |
39 public: | |
40 // This object now owns |dest| and |info|. | |
41 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.
| |
42 cups_dest_t* dest, | |
43 cups_dinfo_t* info); | |
44 | |
45 CupsPrinter(CupsPrinter&& printer); | |
46 | |
47 ~CupsPrinter(); | |
48 | |
49 // Returns true if this is the default printer | |
50 bool is_default() const; | |
51 | |
52 // Returns the supported ipp attributes for the given |option_name|. | |
53 // ipp_attribute_t* is owned by CupsPrinter. | |
54 ipp_attribute_t* GetSupportedOptionValues( | |
55 base::StringPiece option_name) const; | |
56 | |
57 // Returns supported attribute values for |option_name| where the value can be | |
58 // convered to a string. | |
59 std::vector<base::StringPiece> GetSupportedOptionValueStrings( | |
60 base::StringPiece option_name) const; | |
61 | |
62 // Returns the default ipp attributes for the given |option_name|. | |
63 // ipp_attribute_t* is owned by CupsPrinter. | |
64 ipp_attribute_t* GetDefaultOptionValue(base::StringPiece option_name) const; | |
65 | |
66 bool CheckOptionSupported(base::StringPiece name, | |
67 base::StringPiece value) const; | |
68 | |
69 // Returns the file name for the PPD retrieved from the print server. | |
70 base::FilePath GetPPD() const; | |
71 | |
72 // Returns the name of the printer as configured in CUPS | |
73 const std::string GetName() const; | |
74 | |
75 const std::string GetMakeAndModel() const; | |
76 | |
77 // Returns true if the printer is currently reachable and working. | |
78 bool IsAvailable() const; | |
79 | |
80 // Populates |basic_info| with the relevant information about the printer | |
81 bool ToPrinterInfo(PrinterBasicInfo* basic_info) const; | |
82 | |
83 ipp_status_t CreateJob(int* job_id, | |
84 base::StringPiece job_title, | |
85 const std::vector<cups_option_t>& options); | |
86 | |
87 bool StartDocument(int job_id, | |
88 base::StringPiece document_name, | |
89 bool last_doc, | |
90 const std::vector<cups_option_t>& options); | |
91 | |
92 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.
| |
93 | |
94 bool FinishDocument(); | |
95 | |
96 ipp_status_t CloseJob(int job_id); | |
97 | |
98 private: | |
99 bool InitializeDestInfo() const; | |
100 | |
101 base::WeakPtr<http_t> cups_http_; | |
102 std::unique_ptr<cups_dest_t, DestinationDeleter> destination_; | |
103 mutable std::unique_ptr<cups_dinfo_t, DestInfoDeleter> dest_info_; | |
104 | |
105 DISALLOW_COPY_AND_ASSIGN(CupsPrinter); | |
106 }; | |
107 | |
108 } // namespace printing | |
109 | |
110 #endif // PRINTING_BACKEND_CUPS_PRINTER_H_ | |
OLD | NEW |