1 // Copyright 2014 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_DBUS_LORGNETTE_MANAGER_CLIENT_H_ 6 #define CHROMEOS_DBUS_LORGNETTE_MANAGER_CLIENT_H_ 7 8 #include <map> 9 10 #include "base/callback.h" 11 #include "base/files/file.h" 12 #include "base/memory/ref_counted_memory.h" 13 #include "chromeos/chromeos_export.h" 14 #include "chromeos/dbus/dbus_client.h" 15 16 namespace chromeos { 17 18 // LorgnetteManagerClient is used to communicate with the lorgnette 19 // document scanning daemon. 20 class CHROMEOS_EXPORT LorgnetteManagerClient : public DBusClient { 21 public: 22 // The property information for each scanner retured by ListScanners. 23 typedef std::map<std::string, std::string> ScannerTableEntry; 24 typedef std::map<std::string, ScannerTableEntry> ScannerTable; 25 26 // Callback type for ListScanners(). Returns a map which contains 27 // a ScannerTableEntry for each available scanner. 28 typedef base::Callback<void( 29 bool succeeded, const ScannerTable&)> ListScannersCallback; 30 31 // Called once ScanImage() is complete. Takes one parameter: 32 // - succeeded: was the scan completed successfully. 33 typedef base::Callback<void(bool succeeded)> ScanImageCallback; 34 35 // Attributes provided to a scan request. 36 struct ScanProperties { ScanPropertiesScanProperties37 ScanProperties() : resolution_dpi(0) {} 38 std::string mode; // Can be "Color", "Gray", or "Lineart". 39 int resolution_dpi; 40 }; 41 42 virtual ~LorgnetteManagerClient(); 43 44 // Gets a list of scanners from the lorgnette manager. 45 virtual void ListScanners(const ListScannersCallback& callback) = 0; 46 47 // Request a scanned image and calls |callback| when completed. 48 // Image data will be stored in the .png format. 49 virtual void ScanImage(std::string device_name, 50 base::PlatformFile file, 51 const ScanProperties& properties, 52 const ScanImageCallback& callback) = 0; 53 54 // Factory function, creates a new instance and returns ownership. 55 // For normal usage, access the singleton via DBusThreadManager::Get(). 56 static LorgnetteManagerClient* Create(); 57 58 protected: 59 // Create() should be used instead. 60 LorgnetteManagerClient(); 61 62 private: 63 DISALLOW_COPY_AND_ASSIGN(LorgnetteManagerClient); 64 }; 65 66 } // namespace chromeos 67 68 #endif // CHROMEOS_DBUS_LORGNETTE_MANAGER_CLIENT_H_ 69