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_HELPER_H
17 #define VENDOR_HELPER_H
18 
19 #include <string>
20 #include "printer_info.h"
21 #include "vendor_extension.h"
22 
23 namespace OHOS {
24 namespace Print {
25 char *CopyString(const std::string &source);
26 bool ConvertStringToLong(const char *src, long &dst);
27 bool ConvertColorMode(const Print_ColorMode &code, uint32_t &dst);
28 bool ConvertDuplexMode(const Print_DuplexMode &code, uint32_t &dst);
29 bool ConvertQuality(const Print_Quality &code, uint32_t &dst);
30 bool ConvertStringToPrinterState(const std::string &stateData, Print_PrinterState &state);
31 void LogDiscoveryItem(const Print_DiscoveryItem *discoveryItem);
32 void LogPageCapability(const Print_PrinterCapability *capability);
33 void LogOtherCapability(const Print_PrinterCapability *capability);
34 void LogDefaultValue(const Print_DefaultValue *defaultValue);
35 void LogProperties(const Print_PropertyList *propertyList);
36 bool UpdateResolutionDefaultValue(PrinterCapability &printerCap, const Print_DefaultValue *defaultValue);
37 bool UpdateCopiesCapability(PrinterCapability &printerCap, const Print_PrinterCapability *capability,
38                             const Print_DefaultValue *defaultValue);
39 bool UpdateOrientationCapability(PrinterCapability &printerCap, const Print_PrinterCapability *capability,
40                                  const Print_DefaultValue *defaultValue);
41 bool UpdateMediaCapability(PrinterCapability &printerCap, const Print_PrinterCapability *capability,
42                            const Print_DefaultValue *defaultValue);
43 bool UpdateMarginCapability(PrinterCapability &printerCap, const Print_DefaultValue *defaultValue);
44 std::string FindPropertyFromPropertyList(const Print_PropertyList *propertyList, const std::string &keyName);
45 bool UpdatePrinterInfoWithDiscovery(PrinterInfo &info, const Print_DiscoveryItem *discoveryItem);
46 bool UpdatePrinterInfoWithCapability(PrinterInfo &info, const Print_DiscoveryItem *discoveryItem,
47                                      const Print_PrinterCapability *capability, const Print_DefaultValue *defaultValue);
48 std::shared_ptr<PrinterInfo> ConvertVendorCapabilityToPrinterInfo(const Print_DiscoveryItem *printer,
49                                                                   const Print_PrinterCapability *capability,
50                                                                   const Print_DefaultValue *defaultValue);
51 bool ConvertStringVectorToStringList(const std::vector<std::string> &stringVector, Print_StringList &stringList);
52 void ReleaseStringList(Print_StringList &stringList);
53 }  // namespace Print
54 }  // namespace OHOS
55 #endif  // VENDOR_HELPER_H
56