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 21 namespace OHOS { 22 namespace Print { 23 class VendorBsuniDriver : public VendorDriverBase { 24 public: 25 static void SetDriverWrapper(VendorBsuniDriver *driver); 26 static bool CheckVendorExtension(Print_VendorExtension *extension); 27 static int32_t AddPrinterToDiscovery(const Print_DiscoveryItem *discoveryItem); 28 static int32_t RemovePrinterFromDiscovery(const char *printerId); 29 static int32_t AddPrinterToCups(const Print_DiscoveryItem *printer, const Print_PrinterCapability *capability, 30 const Print_DefaultValue *defaultValue, const char *ppdData); 31 static int32_t RemovePrinterFromCups(const char *printerId); 32 static int32_t OnCapabilityQueried(const Print_DiscoveryItem *printer, const Print_PrinterCapability *capability, 33 const Print_DefaultValue *defaultValue); 34 static int32_t OnPropertiesQueried(const char *printerId, const Print_PropertyList *propertyList); 35 VendorBsuniDriver(); 36 ~VendorBsuniDriver(); 37 bool Init(IPrinterVendorManager *manager) override; 38 void UnInit() override; 39 void OnCreate() override; 40 void OnDestroy() override; 41 void OnStartDiscovery() override; 42 void OnStopDiscovery() override; 43 std::string GetVendorName() override; 44 bool OnQueryCapability(const std::string &printerId, int timeout) override; 45 bool OnQueryCapabilityByIp(const std::string &printerIp, const std::string &protocol) override; 46 bool OnQueryProperties(const std::string &printerId, const std::vector<std::string> &propertyKeys) override; 47 48 private: 49 bool LoadDriverExtension(); 50 int32_t OnPrinterPropertiesQueried(const std::string &printerId, const Print_PropertyList *propertyList); 51 int32_t OnPrinterCapabilityQueried(const Print_DiscoveryItem *printer, const Print_PrinterCapability *capability, 52 const Print_DefaultValue *defaultValue); 53 bool ConvertBsUri(std::string &uri); 54 55 private: 56 void *bsUniDriverHandler = nullptr; 57 Print_VendorExtension *vendorExtension = nullptr; 58 Print_ServiceAbility printServiceAbility = { 0 }; 59 }; 60 } // namespace Print 61 } // namespace OHOS 62 #endif // VENDOR_BSUNI_DRIVER_H 63