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 CHROMEOS_PRINTING_PRINTER_DISCOVERER_H_ |
| 6 #define CHROMEOS_PRINTING_PRINTER_DISCOVERER_H_ |
| 7 |
| 8 #include <memory> |
| 9 #include <vector> |
| 10 |
| 11 #include "chromeos/printing/printer_configuration.h" |
| 12 |
| 13 namespace chromeos { |
| 14 |
| 15 // Interface for printer discovery. Constructs Printer objects from USB and |
| 16 // zeroconf (DNS-SD) printers. |
| 17 class PrinterDiscoverer { |
| 18 public: |
| 19 // Interface for objects interested in detected printers. |
| 20 class Observer { |
| 21 public: |
| 22 // Called after discovery has started. |
| 23 virtual void OnDiscoveryStarted() {} |
| 24 |
| 25 // Called when discovery is stopping. OnPrintersFound will not be |
| 26 // called after this occurs. |
| 27 virtual void OnDiscoveryStopping() {} |
| 28 |
| 29 // Called after all printers have been discovered and the observers |
| 30 // notified. |
| 31 virtual void OnDiscoveryDone() {} |
| 32 |
| 33 // Called with a collection of printers as they are discovered. Printer |
| 34 // objects must be copied if they are retained outside of the scope of this |
| 35 // function. |
| 36 virtual void OnPrintersFound(const std::vector<Printer>& printers) {} |
| 37 }; |
| 38 |
| 39 // Static factory |
| 40 static std::unique_ptr<PrinterDiscoverer> Create(); |
| 41 |
| 42 // Begin scanning for printers. Found printers will be reported to the |
| 43 // attached observer. |
| 44 virtual bool StartDiscovery() = 0; |
| 45 |
| 46 // Stop scanning for printers. Returns false if scanning could not be stopped |
| 47 // and new results will continue to be be sent to observers. Returns true if |
| 48 // scanning was stopped successfully. No calls to the attached observer will |
| 49 // be made after this returns if it returned true. |
| 50 virtual bool StopDiscovery() = 0; |
| 51 |
| 52 // Add an observer that will be notified of discovered printers. Ownership of |
| 53 // |observer| is not taken by the discoverer. It is an error to add an |
| 54 // oberserver more than once. |
| 55 virtual void AddObserver(PrinterDiscoverer::Observer* observer) = 0; |
| 56 |
| 57 // Remove an observer of printer discovery. |
| 58 virtual void RemoveObserver(PrinterDiscoverer::Observer* observer) = 0; |
| 59 }; |
| 60 |
| 61 } // namespace chromeos |
| 62 |
| 63 #endif // CHROMEOS_PRINTING_PRINTER_DISCOVERER_H_ |
OLD | NEW |