修改readme Signed-off-by:dongzhengkuan@huawei.com

Signed-off-by: dongzhengkuan <dongzhengkuan@huawei.com>
This commit is contained in:
dongzhengkuan 2023-07-20 09:55:22 +08:00
parent c2d37acfd6
commit bc29cf26a8
2 changed files with 83 additions and 24 deletions

View File

@ -1,20 +1,76 @@
## cups
### Introduction
# CUPS
## Introduction
OpenPrinting CUPS is the most current version of CUPS, a standards-based, open source printing system for Linux® and other Unix®-like operating systems. CUPS supports printing to:
- AirPrint™ and IPP Everywhere™ printers,
- Network and local (USB) printers with Printer Applications, and
- Network and local (USB) printers with (legacy) PPD-based printer drivers.
You can also learn more about the Cups project through [the official website](https://github.com/OpenPrinting/cups)
You can also learn more about the CUPS project through [the official website](https://github.com/OpenPrinting/cups)
### Background Brief
In the process of OpenHarmony's southward ecological development, it is necessary to be compatible with printers in the stock market. The use of cups printing system can directly connect with most printers in the market, which also reduces the difficulty for printer manufacturers to adapt to OpenHarmony.
## Background Brief
In the process of OpenHarmony's southward ecological development, it is necessary to be compatible with printers in the stock market. The use of CUPS printing system can directly connect with most printers in the market, which also reduces the difficulty for printer manufacturers to adapt to OpenHarmony.
## How to use
### 1、Header file import
```c
#include <cups/cups-private.h>
```
### 2、Add Compilation Dependency
Add in the bundle. json file
```json
"deps": {
"third_part": [
"cups"
]
}
```
Add dependencies where needed in BUILD.gn
```json
deps += [ "//third_party/cups:cups" ]
```
### 3、Example of interface usage
```c
// Example of using CUPS interface to query printer capabilities
ipp_t *request; /* IPP Request */
ipp_t *response; /* IPP response */
http_t *http = NULL;
char scheme[HTTP_MAX_URI]; // Protocol
char username[HTTP_MAX_URI];
char host[HTTP_MAX_URI];
int port;
// Declare which printer capabilities need to be queried, here are all
static const char * const pattrs[] = {
"all"
};
// Connect to printer
http = httpConnect2(host, port, NULL, AF_UNSPEC, HTTP_ENCRYPTION_IF_REQUESTED, 1, TIME_OUT, NULL);
if (http == nullptr) {
return;
}
request = ippNewRequest(IPP_OP_GET_PRINTER_ATTRIBUTES);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, printerUri.c_str());
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsUser());
ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "requested-attributes",
(int)(sizeof(pattrs) / sizeof(pattrs[0])), NULL, pattrs);
response = cupsDoRequest(http, request, "/");
// parse response
if (cupsLastError() > IPP_STATUS_OK_CONFLICTING) {
ippDelete(response);
return;
}
// close http
httpClose(http);
```
#### Repositories Involved
[third_party_cups-filters](https://gitee.com/openharmony/third_party_cups-filters)
[print_print_fwk](https://gitee.com/openharmony/print_print_fwk)
#### Contribution
[How to involve](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/contribute/参与贡献.md)
[Commit message spec](https://gitee.com/openharmony/device_qemu/wikis/Commit%20message%E8%A7%84%E8%8C%83)

View File

@ -1,15 +1,18 @@
## 三方开源软件cups
### cups简介
cupsCommon Unix Printing System是一种开源打印系统现在由OpenPrinting组织维护。cups主要功能包括打印队列管理、打印驱动程序管理、网络打印支持等。cups支持多种打印协议包括IPPInternet Printing Protocol、LPDLine Printer Daemon Protocol、AppSocket等。
# 三方开源软件CUPS
## CUPS简介
CUPSCommon Unix Printing System是一种开源打印系统现在由OpenPrinting组织维护。cups主要功能包括打印队列管理、打印驱动程序管理、网络打印支持等。CUPS支持多种打印协议包括IPPInternet Printing Protocol、LPDLine Printer Daemon Protocol、AppSocket等。
cups支持以下类型的打印机、AirPrint和IPP Everywhere认证的打印机、带打印机应用程序的网络和USB打印机、基于PPDPostScript Printer Definition打印驱动程序的网络和本地USB打印机。
CUPS支持以下类型的打印机
、AirPrint和IPP Everywhere认证的打印机
、带打印机应用程序的网络和USB打印机
、基于PPDPostScript Printer Definition打印驱动程序的网络和本地USB打印机。
您也可以通过[cups官网主页](https://github.com/OpenPrinting/cups)了解更多关于cups项目的信息。
您也可以通过[CUPS官网主页](https://github.com/OpenPrinting/cups)了解更多关于CUPS项目的信息。
### 引入背景简述
Openharmony南向生态发展过程中需要对存量市场的打印机进行兼容。使用cups打印系统能直接对接市场上大部分的打印机也减少了打印机驱动适配OpenHarmony系统的难度。
## 引入背景简述
OpenHarmony南向生态发展过程中需要对存量市场的打印机进行兼容。使用CUPS打印系统能直接对接市场上大部分的打印机也减少了打印机驱动适配OpenHarmony系统的难度。
### 目录结构
## 目录结构
```
- LICENSE 版权文件
- OAT.xml OAT.xml过滤配置文件
@ -24,18 +27,18 @@ Openharmony南向生态发展过程中需要对存量市场的打印机进行
- cups-xxx.patch 上游更新补丁列表
- cups.spec 上游更新记录说明
- cups.yaml 上游yaml文件
- cups_single_file.patch 适配OH编译补丁文件
- pthread_cancel.patch 适配OH编译补丁文件
- install.sh 适配OH编译sh脚本文件
- generate_mime_convs.py 适配OH编译python脚本文件
- cups_single_file.patch 适配OpenHarmony编译补丁文件
- pthread_cancel.patch 适配OpenHarmony编译补丁文件
- install.sh 适配OpenHarmony编译sh脚本文件
- generate_mime_convs.py 适配OpenHarmony编译python脚本文件
```
### 如何使用
#### 1、头文件引入
## 如何使用
### 1、头文件引入
```c
#include <cups/cups-private.h>
```
#### 2、添加编译依赖
### 2、添加编译依赖
在您的 bundle.json 文件 添加
```json
"deps": {
@ -48,15 +51,15 @@ Openharmony南向生态发展过程中需要对存量市场的打印机进行
```json
deps += [ "//third_party/cups:cups" ]
```
#### 3、接口使用示例
### 3、接口使用示例
```c
// 使用cups接口查询打印机能力示例
// 使用CUPS接口查询打印机能力示例
ipp_t *request; /* IPP Request */
ipp_t *response; /* IPP response */
http_t *http = NULL;
char scheme[HTTP_MAX_URI]; // 协议类型
char username[HTTP_MAX_URI]; // 请求用户名
char host[HTTP_MAX_URI]; // 打印机端口
char host[HTTP_MAX_URI]; // 打印机ip
int port; // 打印机端口
// 声明需要查询哪些打印机能力,此处为所有
static const char * const pattrs[] = {
@ -77,7 +80,7 @@ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", N
// 指定请求哪些打印机属性
ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "requested-attributes",
(int)(sizeof(pattrs) / sizeof(pattrs[0])), NULL, pattrs);
// 调用cups接口发送ipp请求
// 调用CUPS接口发送ipp请求
response = cupsDoRequest(http, request, "/");
// 处理请求结果
if (cupsLastError() > IPP_STATUS_OK_CONFLICTING) {