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_WLAN_GROUP_H
17 #define VENDOR_WLAN_GROUP_H
18 
19 #include "vendor_manager.h"
20 #include "vendor_driver_group.h"
21 
22 namespace OHOS {
23 namespace Print {
24 
25 class VendorWlanGroup : public VendorDriverGroup {
26 public:
27     explicit VendorWlanGroup(VendorManager *vendorManager);
28     std::string GetVendorName() override;
29     bool OnQueryCapability(const std::string &printerId, int timeout) override;
30     bool OnQueryCapabilityByIp(const std::string &printerIp, const std::string &protocol) override;
31     int32_t OnPrinterDiscovered(const std::string &vendorName, const PrinterInfo &printerInfo) override;
32     int32_t OnPrinterRemoved(const std::string &vendorName, const std::string &printerId) override;
33     bool IsGroupDriver(const std::string &bothPrinterId) override;
34     bool ConvertGroupDriver(std::string &printerId, std::string &vendorName) override;
35     std::string ConvertGroupGlobalPrinterId(const std::string &bothPrinterId) override;
36     int32_t OnUpdatePrinterToDiscovery(const std::string &vendorName, const PrinterInfo &printerInfo) override;
37     bool IsConnectingPrinter(const std::string &globalPrinterIdOrIp, const std::string &uri) override;
38     void SetConnectingPrinter(ConnectMethod method, const std::string &globalPrinterIdOrIp) override;
39     bool OnPrinterPpdQueried(const std::string &vendorName, const std::string &printerId,
40                                      const std::string &ppdData) override;
41 
42 private:
43     bool IsBsunidriverSupport(const std::string &printerId);
44     void RemovePrinterVendorGroupById(const std::string &printerId);
45     std::string ExtractBsUniPrinterIdByPrinterInfo(const PrinterInfo &rinterInfo);
46     void QueryBsUniPrinterIdByUuidPrinterId(std::string &bsUniPrinterId);
47     void UpdateMappedPrinterId(const std::string &bsUniPrinterId, const std::string printerId);
48     PrinterInfo ConvertPrinterInfoId(const PrinterInfo &priterInfo);
49 
50 private:
51     VendorManager* parentVendorManager = nullptr;
52     std::map<std::string, std::string> printerVendorGroupList_;
53     std::map<std::string, std::string> printerIdToUuidMap_;
54     std::mutex uuidMapMutex;
55     bool hasGs = false;
56 };
57 }  // namespace Print
58 }  // namespace OHOS
59 #endif  // VENDOR_WLAN_GROUP_H