mirror of
https://gitee.com/openharmony/third_party_cups
synced 2024-11-23 09:59:45 +00:00
修改readme Signed-off-by:dongzhengkuan@huawei.com
Signed-off-by: dongzhengkuan <dongzhengkuan@huawei.com>
This commit is contained in:
parent
c2d37acfd6
commit
bc29cf26a8
66
README.md
66
README.md
@ -1,20 +1,76 @@
|
|||||||
## cups
|
# CUPS
|
||||||
### Introduction
|
## 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:
|
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,
|
- AirPrint™ and IPP Everywhere™ printers,
|
||||||
- Network and local (USB) printers with Printer Applications, and
|
- Network and local (USB) printers with Printer Applications, and
|
||||||
- Network and local (USB) printers with (legacy) PPD-based printer drivers.
|
- 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
|
## 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.
|
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
|
#### Repositories Involved
|
||||||
[third_party_cups-filters](https://gitee.com/openharmony/third_party_cups-filters)
|
[third_party_cups-filters](https://gitee.com/openharmony/third_party_cups-filters)
|
||||||
|
|
||||||
[print_print_fwk](https://gitee.com/openharmony/print_print_fwk)
|
[print_print_fwk](https://gitee.com/openharmony/print_print_fwk)
|
||||||
|
|
||||||
#### Contribution
|
#### Contribution
|
||||||
[How to involve](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/contribute/参与贡献.md)
|
[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)
|
[Commit message spec](https://gitee.com/openharmony/device_qemu/wikis/Commit%20message%E8%A7%84%E8%8C%83)
|
||||||
|
|
||||||
|
41
README_zh.md
41
README_zh.md
@ -1,15 +1,18 @@
|
|||||||
## 三方开源软件cups
|
# 三方开源软件CUPS
|
||||||
### cups简介
|
## CUPS简介
|
||||||
cups(Common Unix Printing System)是一种开源打印系统,现在由OpenPrinting组织维护。cups主要功能包括打印队列管理、打印驱动程序管理、网络打印支持等。cups支持多种打印协议,包括IPP(Internet Printing Protocol)、LPD(Line Printer Daemon Protocol)、AppSocket等。
|
CUPS(Common Unix Printing System)是一种开源打印系统,现在由OpenPrinting组织维护。cups主要功能包括打印队列管理、打印驱动程序管理、网络打印支持等。CUPS支持多种打印协议,包括IPP(Internet Printing Protocol)、LPD(Line Printer Daemon Protocol)、AppSocket等。
|
||||||
|
|
||||||
cups支持以下类型的打印机:1、AirPrint和IPP Everywhere认证的打印机;2、带打印机应用程序的网络和USB打印机;3、基于PPD(PostScript Printer Definition)打印驱动程序的网络和本地(USB)打印机。
|
CUPS支持以下类型的打印机:
|
||||||
|
1、AirPrint和IPP Everywhere认证的打印机;
|
||||||
|
2、带打印机应用程序的网络和USB打印机;
|
||||||
|
3、基于PPD(PostScript Printer Definition)打印驱动程序的网络和本地(USB)打印机。
|
||||||
|
|
||||||
您也可以通过[cups官网主页](https://github.com/OpenPrinting/cups)了解更多关于cups项目的信息。
|
您也可以通过[CUPS官网主页](https://github.com/OpenPrinting/cups)了解更多关于CUPS项目的信息。
|
||||||
|
|
||||||
### 引入背景简述
|
## 引入背景简述
|
||||||
Openharmony南向生态发展过程中,需要对存量市场的打印机进行兼容。使用cups打印系统能直接对接市场上大部分的打印机,也减少了打印机驱动适配OpenHarmony系统的难度。
|
OpenHarmony南向生态发展过程中,需要对存量市场的打印机进行兼容。使用CUPS打印系统能直接对接市场上大部分的打印机,也减少了打印机驱动适配OpenHarmony系统的难度。
|
||||||
|
|
||||||
### 目录结构
|
## 目录结构
|
||||||
```
|
```
|
||||||
- LICENSE 版权文件
|
- LICENSE 版权文件
|
||||||
- OAT.xml OAT.xml过滤配置文件
|
- OAT.xml OAT.xml过滤配置文件
|
||||||
@ -24,18 +27,18 @@ Openharmony南向生态发展过程中,需要对存量市场的打印机进行
|
|||||||
- cups-xxx.patch 上游更新补丁列表
|
- cups-xxx.patch 上游更新补丁列表
|
||||||
- cups.spec 上游更新记录说明
|
- cups.spec 上游更新记录说明
|
||||||
- cups.yaml 上游yaml文件
|
- cups.yaml 上游yaml文件
|
||||||
- cups_single_file.patch 适配OH编译补丁文件
|
- cups_single_file.patch 适配OpenHarmony编译补丁文件
|
||||||
- pthread_cancel.patch 适配OH编译补丁文件
|
- pthread_cancel.patch 适配OpenHarmony编译补丁文件
|
||||||
- install.sh 适配OH编译sh脚本文件
|
- install.sh 适配OpenHarmony编译sh脚本文件
|
||||||
- generate_mime_convs.py 适配OH编译python脚本文件
|
- generate_mime_convs.py 适配OpenHarmony编译python脚本文件
|
||||||
```
|
```
|
||||||
|
|
||||||
### 如何使用
|
## 如何使用
|
||||||
#### 1、头文件引入
|
### 1、头文件引入
|
||||||
```c
|
```c
|
||||||
#include <cups/cups-private.h>
|
#include <cups/cups-private.h>
|
||||||
```
|
```
|
||||||
#### 2、添加编译依赖
|
### 2、添加编译依赖
|
||||||
在您的 bundle.json 文件 添加
|
在您的 bundle.json 文件 添加
|
||||||
```json
|
```json
|
||||||
"deps": {
|
"deps": {
|
||||||
@ -48,15 +51,15 @@ Openharmony南向生态发展过程中,需要对存量市场的打印机进行
|
|||||||
```json
|
```json
|
||||||
deps += [ "//third_party/cups:cups" ]
|
deps += [ "//third_party/cups:cups" ]
|
||||||
```
|
```
|
||||||
#### 3、接口使用示例
|
### 3、接口使用示例
|
||||||
```c
|
```c
|
||||||
// 使用cups接口查询打印机能力示例
|
// 使用CUPS接口查询打印机能力示例
|
||||||
ipp_t *request; /* IPP Request */
|
ipp_t *request; /* IPP Request */
|
||||||
ipp_t *response; /* IPP response */
|
ipp_t *response; /* IPP response */
|
||||||
http_t *http = NULL;
|
http_t *http = NULL;
|
||||||
char scheme[HTTP_MAX_URI]; // 协议类型
|
char scheme[HTTP_MAX_URI]; // 协议类型
|
||||||
char username[HTTP_MAX_URI]; // 请求用户名
|
char username[HTTP_MAX_URI]; // 请求用户名
|
||||||
char host[HTTP_MAX_URI]; // 打印机端口
|
char host[HTTP_MAX_URI]; // 打印机ip
|
||||||
int port; // 打印机端口
|
int port; // 打印机端口
|
||||||
// 声明需要查询哪些打印机能力,此处为所有
|
// 声明需要查询哪些打印机能力,此处为所有
|
||||||
static const char * const pattrs[] = {
|
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",
|
ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "requested-attributes",
|
||||||
(int)(sizeof(pattrs) / sizeof(pattrs[0])), NULL, pattrs);
|
(int)(sizeof(pattrs) / sizeof(pattrs[0])), NULL, pattrs);
|
||||||
// 调用cups接口发送ipp请求
|
// 调用CUPS接口发送ipp请求
|
||||||
response = cupsDoRequest(http, request, "/");
|
response = cupsDoRequest(http, request, "/");
|
||||||
// 处理请求结果
|
// 处理请求结果
|
||||||
if (cupsLastError() > IPP_STATUS_OK_CONFLICTING) {
|
if (cupsLastError() > IPP_STATUS_OK_CONFLICTING) {
|
||||||
|
Loading…
Reference in New Issue
Block a user