• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     ConnectMethod GetConnectingMethod(const std::string &globalPrinterIdOrIp) override;
39     void SetConnectingPrinter(ConnectMethod method, const std::string &globalPrinterIdOrIp) override;
40     bool OnPrinterPpdQueried(const std::string &vendorName, const std::string &printerId,
41                              const std::string &ppdName, const std::string &ppdData) override;
42     bool MonitorPrinterStatus(const std::string &groupPrinterId, bool on) override;
43     bool OnPrinterStatusChanged(const std::string &vendorName, const std::string &printerId,
44                                 const PrinterVendorStatus &status) override;
45     bool OnPrinterCapabilityQueried(const std::string &vendorName, const PrinterInfo &printerInfo) override;
46 
47 private:
48     bool IsBsunidriverSupport(const std::string &groupPrinterId);
49     void RemoveGroupPrinterFromVendorGroupList(const std::string &groupPrinterId);
50     std::string ExtractPrinterIdByPrinterInfo(const PrinterInfo &printerInfo);
51     std::string GetGroupPrinterId(const std::string &printerId);
52     void UpdateGroupPrinter(const std::string &printerId, const std::string &groupPrinterId);
53     bool HasGroupPrinter(const std::string &printerId);
54     void RemovedGroupPrinter(const std::string &printerId);
55     PrinterInfo ConvertPrinterInfoId(const PrinterInfo &priterInfo);
56     bool CheckPrinterAddedByIp(const std::string &printerId);
57     PrinterInfo ConvertIpPrinterName(const PrinterInfo &printerInfo);
58     std::string QueryVendorDriverByGroupPrinterId(const std::string &groupPrinterId);
59     bool TryConnectByPpdDriver(const PrinterInfo &printerInfo);
60     bool MonitorStatusByBsuniDriver(const std::string &groupPrinterId, bool on);
61 
62 private:
63     VendorManager* parentVendorManager = nullptr;
64     std::map<std::string, std::string> printerVendorGroupList_;
65     std::map<std::string, std::string> groupPrinterIdMap_;
66     std::mutex groupPrinterIdMapMutex;
67     bool hasGs = false;
68 };
69 }  // namespace Print
70 }  // namespace OHOS
71 #endif  // VENDOR_WLAN_GROUP_H