1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef VENDOR_BSUNI_DRIVER_H 17 #define VENDOR_BSUNI_DRIVER_H 18 19 #include "vendor_driver_base.h" 20 #include "operation_queue.h" 21 22 namespace OHOS { 23 namespace Print { 24 class VendorBsuniDriver : public VendorDriverBase { 25 public: 26 static void SetDriverWrapper(VendorBsuniDriver *driver); 27 static bool CheckVendorExtension(Print_VendorExtension *extension); 28 static int32_t AddPrinterToDiscovery(const Print_DiscoveryItem *discoveryItem); 29 static int32_t RemovePrinterFromDiscovery(const char *printerId); 30 static int32_t AddPrinterToCups(const Print_DiscoveryItem *printer, const Print_PrinterCapability *capability, 31 const Print_DefaultValue *defaultValue, const char *ppdData); 32 static int32_t RemovePrinterFromCups(const char *printerId); 33 static int32_t OnCapabilityQueried(const Print_DiscoveryItem *printer, const Print_PrinterCapability *capability, 34 const Print_DefaultValue *defaultValue); 35 static int32_t OnPropertiesQueried(const char *printerId, const Print_PropertyList *propertyList); 36 VendorBsuniDriver(); 37 ~VendorBsuniDriver(); 38 bool Init(IPrinterVendorManager *manager) override; 39 void UnInit() override; 40 void OnCreate() override; 41 void OnDestroy() override; 42 void OnStartDiscovery() override; 43 void OnStopDiscovery() override; 44 std::string GetVendorName() override; 45 bool OnQueryCapability(const std::string &printerId, int timeout) override; 46 bool OnQueryCapabilityByIp(const std::string &printerIp, const std::string &protocol) override; 47 bool OnQueryProperties(const std::string &printerId, const std::vector<std::string> &propertyKeys) override; 48 49 private: 50 bool LoadDriverExtension(); 51 void OnDiscoveredPrinterAdd(std::shared_ptr<PrinterInfo> printerInfo); 52 void OnDiscoveredPrinterRemove(std::shared_ptr<std::string> printerId); 53 void OnCupsPrinterAdd(std::shared_ptr<PrinterInfo> printerInfo, std::shared_ptr<std::string> ppdData); 54 void OnCupsPrinterRemove(std::shared_ptr<std::string> printerId); 55 void OnPpdQueried(std::shared_ptr<std::string> printerId, std::shared_ptr<std::string> ppdData); 56 void OnStateQueried(std::shared_ptr<std::string> printerId, std::shared_ptr<std::string> stateData); 57 void OnPrinterCapabilityQueried(std::shared_ptr<PrinterInfo> printerInfo); 58 private: 59 void *bsUniDriverHandler = nullptr; 60 Print_VendorExtension *vendorExtension = nullptr; 61 Print_ServiceAbility printServiceAbility = { 0 }; 62 OperationQueue opQueue; 63 }; 64 } // namespace Print 65 } // namespace OHOS 66 #endif // VENDOR_BSUNI_DRIVER_H 67