OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef CHROME_SERVICE_CLOUD_PRINT_PRINT_SYSTEM_H_ | 5 #ifndef CHROME_SERVICE_CLOUD_PRINT_PRINT_SYSTEM_H_ |
6 #define CHROME_SERVICE_CLOUD_PRINT_PRINT_SYSTEM_H_ | 6 #define CHROME_SERVICE_CLOUD_PRINT_PRINT_SYSTEM_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 | 74 |
75 // PrintSystem class will provide interface for different printing systems | 75 // PrintSystem class will provide interface for different printing systems |
76 // (Windows, CUPS) to implement. User will call CreateInstance() to | 76 // (Windows, CUPS) to implement. User will call CreateInstance() to |
77 // obtain available printing system. | 77 // obtain available printing system. |
78 // Please note, that PrintSystem is not platform specific, but rather | 78 // Please note, that PrintSystem is not platform specific, but rather |
79 // print system specific. For example, CUPS is available on both Linux and Mac, | 79 // print system specific. For example, CUPS is available on both Linux and Mac, |
80 // but not avaialble on ChromeOS, etc. This design allows us to add more | 80 // but not avaialble on ChromeOS, etc. This design allows us to add more |
81 // functionality on some platforms, while reusing core (CUPS) functions. | 81 // functionality on some platforms, while reusing core (CUPS) functions. |
82 class PrintSystem : public base::RefCountedThreadSafe<PrintSystem> { | 82 class PrintSystem : public base::RefCountedThreadSafe<PrintSystem> { |
83 public: | 83 public: |
84 virtual ~PrintSystem() {} | |
85 | |
86 // Enumerates the list of installed local and network printers. | |
87 virtual void EnumeratePrinters(PrinterList* printer_list) = 0; | |
88 | |
89 // Gets the capabilities and defaults for a specific printer. | |
90 virtual bool GetPrinterCapsAndDefaults(const std::string& printer_name, | |
91 PrinterCapsAndDefaults* printer_info) = 0; | |
92 | |
93 // Returns true if ticket is valid. | |
94 virtual bool ValidatePrintTicket(const std::string& printer_name, | |
95 const std::string& print_ticket_data) = 0; | |
96 | |
97 // Send job to the printer. | |
98 virtual bool SpoolPrintJob(const std::string& print_ticket, | |
99 const FilePath& print_data_file_path, | |
100 const std::string& print_data_mime_type, | |
101 const std::string& printer_name, | |
102 const std::string& job_title, | |
103 PlatformJobId* job_id_ret) = 0; | |
104 | |
105 // Get details for already spooled job. | |
106 virtual bool GetJobDetails(const std::string& printer_name, | |
107 PlatformJobId job_id, | |
108 PrintJobDetails *job_details) = 0; | |
109 | |
110 // Returns true if printer_name points to a valid printer. | |
111 virtual bool IsValidPrinter(const std::string& printer_name) = 0; | |
112 | |
113 class PrintServerWatcher | 84 class PrintServerWatcher |
114 : public base::RefCountedThreadSafe<PrintServerWatcher> { | 85 : public base::RefCountedThreadSafe<PrintServerWatcher> { |
115 public: | 86 public: |
116 // Callback interface for new printer notifications. | 87 // Callback interface for new printer notifications. |
117 class Delegate { | 88 class Delegate { |
118 public: | 89 public: |
119 virtual void OnPrinterAdded() = 0; | 90 virtual void OnPrinterAdded() = 0; |
120 // TODO(gene): Do we need OnPrinterDeleted notification here? | 91 // TODO(gene): Do we need OnPrinterDeleted notification here? |
121 }; | 92 }; |
122 | 93 |
(...skipping 11 matching lines...) Expand all Loading... |
134 virtual void OnPrinterChanged() = 0; | 105 virtual void OnPrinterChanged() = 0; |
135 virtual void OnJobChanged() = 0; | 106 virtual void OnJobChanged() = 0; |
136 }; | 107 }; |
137 | 108 |
138 virtual ~PrinterWatcher() {} | 109 virtual ~PrinterWatcher() {} |
139 virtual bool StartWatching(PrinterWatcher::Delegate* delegate) = 0; | 110 virtual bool StartWatching(PrinterWatcher::Delegate* delegate) = 0; |
140 virtual bool StopWatching() = 0; | 111 virtual bool StopWatching() = 0; |
141 virtual bool GetCurrentPrinterInfo(PrinterBasicInfo* printer_info) = 0; | 112 virtual bool GetCurrentPrinterInfo(PrinterBasicInfo* printer_info) = 0; |
142 }; | 113 }; |
143 | 114 |
| 115 class JobSpooler : public base::RefCountedThreadSafe<JobSpooler> { |
| 116 public: |
| 117 // Callback interface for JobSpooler notifications. |
| 118 class Delegate { |
| 119 public: |
| 120 virtual ~Delegate() { } |
| 121 virtual void OnJobSpoolSucceeded(const PlatformJobId& job_id) = 0; |
| 122 virtual void OnJobSpoolFailed() = 0; |
| 123 }; |
| 124 |
| 125 virtual ~JobSpooler() {} |
| 126 // Spool job to the printer asynchronously. Caller will be notified via |
| 127 // |delegate|. Note that only one print job can be in progress at any given |
| 128 // time. Subsequent calls to Spool (before the Delegate::OnJobSpoolSucceeded |
| 129 // or Delegate::OnJobSpoolFailed methods are called) can fail. |
| 130 virtual bool Spool(const std::string& print_ticket, |
| 131 const FilePath& print_data_file_path, |
| 132 const std::string& print_data_mime_type, |
| 133 const std::string& printer_name, |
| 134 const std::string& job_title, |
| 135 JobSpooler::Delegate* delegate) = 0; |
| 136 }; |
| 137 |
| 138 virtual ~PrintSystem() {} |
| 139 |
| 140 // Enumerates the list of installed local and network printers. |
| 141 virtual void EnumeratePrinters(PrinterList* printer_list) = 0; |
| 142 |
| 143 // Gets the capabilities and defaults for a specific printer. |
| 144 virtual bool GetPrinterCapsAndDefaults(const std::string& printer_name, |
| 145 PrinterCapsAndDefaults* printer_info) = 0; |
| 146 |
| 147 // Returns true if ticket is valid. |
| 148 virtual bool ValidatePrintTicket(const std::string& printer_name, |
| 149 const std::string& print_ticket_data) = 0; |
| 150 |
| 151 // Get details for already spooled job. |
| 152 virtual bool GetJobDetails(const std::string& printer_name, |
| 153 PlatformJobId job_id, |
| 154 PrintJobDetails *job_details) = 0; |
| 155 |
| 156 // Returns true if printer_name points to a valid printer. |
| 157 virtual bool IsValidPrinter(const std::string& printer_name) = 0; |
| 158 |
144 // Factory methods to create corresponding watcher. Callee is responsible | 159 // Factory methods to create corresponding watcher. Callee is responsible |
145 // for deleting objects. Return NULL if failed. | 160 // for deleting objects. Return NULL if failed. |
146 virtual PrintServerWatcher* CreatePrintServerWatcher() = 0; | 161 virtual PrintServerWatcher* CreatePrintServerWatcher() = 0; |
147 virtual PrinterWatcher* CreatePrinterWatcher( | 162 virtual PrinterWatcher* CreatePrinterWatcher( |
148 const std::string& printer_name) = 0; | 163 const std::string& printer_name) = 0; |
| 164 virtual JobSpooler* CreateJobSpooler() = 0; |
149 | 165 |
150 // Generate unique for proxy. | 166 // Generate unique for proxy. |
151 static std::string GenerateProxyId(); | 167 static std::string GenerateProxyId(); |
152 | 168 |
153 // Call this function to obtain printing system for specified print server. | 169 // Call this function to obtain printing system for specified print server. |
154 // If print settings are NULL, default settings will be used. | 170 // If print settings are NULL, default settings will be used. |
155 // Return NULL if no print system available. | 171 // Return NULL if no print system available. |
156 static scoped_refptr<PrintSystem> CreateInstance( | 172 static scoped_refptr<PrintSystem> CreateInstance( |
157 const DictionaryValue* print_system_settings); | 173 const DictionaryValue* print_system_settings); |
158 }; | 174 }; |
159 | 175 |
160 | 176 |
161 // This typedef is to workaround the issue with certain versions of | 177 // This typedef is to workaround the issue with certain versions of |
162 // Visual Studio where it gets confused between multiple Delegate | 178 // Visual Studio where it gets confused between multiple Delegate |
163 // classes and gives a C2500 error. (I saw this error on the try bots - | 179 // classes and gives a C2500 error. (I saw this error on the try bots - |
164 // the workaround was not needed for my machine). | 180 // the workaround was not needed for my machine). |
165 typedef PrintSystem::PrintServerWatcher::Delegate PrintServerWatcherDelegate; | 181 typedef PrintSystem::PrintServerWatcher::Delegate PrintServerWatcherDelegate; |
166 typedef PrintSystem::PrinterWatcher::Delegate PrinterWatcherDelegate; | 182 typedef PrintSystem::PrinterWatcher::Delegate PrinterWatcherDelegate; |
| 183 typedef PrintSystem::JobSpooler::Delegate JobSpoolerDelegate; |
167 | 184 |
168 } // namespace cloud_print | 185 } // namespace cloud_print |
169 | 186 |
170 #endif // CHROME_SERVICE_CLOUD_PRINT_PRINT_SYSTEM_H_ | 187 #endif // CHROME_SERVICE_CLOUD_PRINT_PRINT_SYSTEM_H_ |
OLD | NEW |