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 PRINT_CUPS_WRAPPER_H
17 #define PRINT_CUPS_WRAPPER_H
18 
19 #include <vector>
20 #include <string>
21 #include <functional>
22 #include <cups/cups-private.h>
23 #include <cups/ppd.h>
24 
25 namespace OHOS::Print {
26 typedef std::function<void()> CallbackFunc;
27 
28 class IPrintAbilityBase {
29 public:
~IPrintAbilityBase()30     virtual ~IPrintAbilityBase() {}
31     virtual cups_dest_t *GetNamedDest(http_t *http, const char *name, const char *instance) = 0;
32     virtual void FreeDests(int num, cups_dest_t *dests) = 0;
33     virtual ipp_t *DoRequest(http_t *http, ipp_t *request, const char *resource) = 0;
34     virtual cups_dinfo_t *CopyDestInfo(http_t *http, cups_dest_t *dest) = 0;
35     virtual void FreeDestInfo(cups_dinfo_t *dinfo) = 0;
36     virtual void FreeRequest(ipp_t *response) = 0;
37 };
38 
39 class PrintCupsWrapper : public IPrintAbilityBase {
40 public:
41     cups_dest_t* GetNamedDest(http_t *http, const char *name, const char *instance) override;
42     void FreeDests(int num, cups_dest_t *dests) override;
43     ipp_t *DoRequest(http_t *http, ipp_t *request, const char *resource) override;
44     cups_dinfo_t *CopyDestInfo(http_t *http, cups_dest_t *dest) override;
45     void FreeDestInfo(cups_dinfo_t *dinfo) override;
46     void FreeRequest(ipp_t *response) override;
47 };
48 } // namespace OHOS::Print
49 #endif // PRINT_CUPS_WRAPPER_H