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 /**
17  * @addtogroup OH_Print
18  * @{
19  *
20  * @brief Provides the definition of the C interface for the print vendor extension.
21  *
22  * @syscap SystemCapability.Print.PrintFramework
23  *
24  * @since 12
25  * @version 1.0
26  */
27 
28 /**
29  * @file vendor_extension.h
30  *
31  * @brief Declares the APIs to discover and manage vendor owned printers.
32  *
33  * @syscap SystemCapability.Print.PrintFramework
34  * @since 12
35  * @version 1.0
36  */
37 
38 #ifndef VENDOR_EXTENSION_H
39 #define VENDOR_EXTENSION_H
40 
41 #include "ohprint.h"
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 typedef enum {
48     EXTENSION_ERROR_NONE = 0,
49     EXTENSION_INVALID_PARAMETER = 401,
50     EXTENSION_ERROR_CALLBACK_NULL = 24300100,
51     EXTENSION_ERROR_CALLBACK_FAIL,
52     EXTENSION_ERROR_INVALID_PRINTER,
53 } Print_ExtensionError;
54 
55 /**
56  * @brief Indicates printer information.
57  *
58  * @since 12
59  */
60 typedef struct {
61     /** Printer id. */
62     char *printerId;
63     /** Printer name. */
64     char *printerName;
65     /** Printer description. */
66     char *description;
67     /** Printer location. */
68     char *location;
69     /** Printer make and model information. */
70     char *makeAndModel;
71     /** Printer Uri. */
72     char *printerUri;
73     /** Printer UUID. */
74     char *printerUuid;
75     /** Detail information in json format. */
76     char *detailInfo;
77 } Print_DiscoveryItem;
78 
79 #define PRINTER_PROPERTY_KEY_DEVICE_STATE "printer_device_state" // 非IPP机器需要,无法查打印任务状态
80 #define PRINTER_PROPERTY_KEY_DEVICE_VENDOR "printer_device_vendor" // json字符串,支持传多个字符串。厂商名称 型号等
81 #define PRINTER_PROPERTY_KEY_DEVICE_CAPABILITY "printer_device_capability" // json字符串 打印机能力
82 #define PRINTER_PROPERTY_KEY_DEVICE_DEFAULT_VALUE "printer_device_default_value" // json字符串 打印机默认值
83 #define PRINTER_PROPERTY_KEY_DEVICE_SUPPLIES "printer_device_supplies" // json字符串 耗材信息,支持多个墨盒
84 #define PRINTER_PROPERTY_KEY_CUPS_PPD_FILE "printer_cups_ppd_file" // 跟设备相关的PPD全文
85 
86 typedef struct {
87     int32_t (*addPrinterToDiscovery)(const Print_DiscoveryItem *discoveryItem);
88     int32_t (*removePrinterFromDiscovery)(const char *printerId);
89     int32_t (*addPrinterToCups)(const Print_DiscoveryItem *printer, const Print_PrinterCapability *capability,
90         const Print_DefaultValue *defaultValue, const char *ppdData);
91     int32_t (*removePrinterFromCups)(const char *printerId);
92     int32_t (*onCapabilityQueried)(const Print_DiscoveryItem *printer,
93         const Print_PrinterCapability *capability, const Print_DefaultValue *defaultValue);
94     int32_t (*onPropertiesQueried)(const char *printerId, const Print_PropertyList *propertyList);
95 } Print_ServiceAbility;
96 
97 typedef struct {
98     int32_t (*onCreate)(const Print_ServiceAbility *context);
99     int32_t (*onDestroy)();
100     int32_t (*onStartDiscovery)();
101     int32_t (*onStopDiscovery)();
102     int32_t (*onConnectPrinter)(const char *printerId);
103     int32_t (*onDisconnectPrinter)(const char *printerId);
104     int32_t (*onQueryCapability)(const char *printerId);
105     int32_t (*onQueryCapabilityByIp)(const char *printerIp, const char *protocol);
106     int32_t (*onQueryProperties)(const char *printerId, const Print_StringList *propertyKeyList);
107 } Print_VendorExtension;
108 
109 Print_VendorExtension* GetPrintVendorExtension(void);
110 
111 #ifdef __cplusplus
112 }
113 #endif
114 
115 #endif // VENDOR_EXTENSION_H
116 /** @} */