1 /*
2  * Copyright (c) 2022 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 SCAN_SERVICE_INTERFACE_H
17 #define SCAN_SERVICE_INTERFACE_H
18 
19 #include <string>
20 #include <vector>
21 
22 #include "iscan_callback.h"
23 #include "iremote_broker.h"
24 #include "scanner_info.h"
25 #include "scan_option_descriptor.h"
26 #include "scan_option_value.h"
27 #include "scan_parameters.h"
28 #include "scanner_info.h"
29 #include "scan_progress.h"
30 
31 namespace OHOS::Scan {
32 class IScanService : public IRemoteBroker {
33 public:
34     DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.Scan.IScanService");
35     virtual int32_t InitScan(int32_t &scanVersion) = 0;
36     virtual int32_t ExitScan() = 0;
37     virtual int32_t GetScannerList() = 0;
38     virtual int32_t StopDiscover() = 0;
39     virtual int32_t OpenScanner(const std::string scannerId) = 0;
40     virtual int32_t CloseScanner(const std::string scannerId) = 0;
41     virtual int32_t GetScanOptionDesc(const std::string scannerId,
42     const int32_t optionIndex, ScanOptionDescriptor &desc) = 0;
43     virtual int32_t OpScanOptionValue(const std::string scannerId,
44     const int32_t optionIndex, const ScanOptionOpType op, ScanOptionValue &value, int32_t &info) =0;
45     virtual int32_t GetScanParameters(const std::string scannerId, ScanParameters &para) = 0;
46     virtual int32_t StartScan(const std::string scannerffId, const bool &batchMode) = 0;
47     virtual int32_t GetSingleFrameFD(const std::string scannerId, uint32_t &size, uint32_t fd) = 0;
48     virtual int32_t CancelScan(const std::string scannerId) = 0;
49     virtual int32_t SetScanIOMode(const std::string scannerId, const bool isNonBlocking) = 0;
50     virtual int32_t GetScanSelectFd(const std::string scannerId, int32_t &fd) = 0;
51     virtual int32_t GetScannerState(int32_t &scannerState)  = 0;
52     virtual int32_t GetScanProgress(const std::string scannerId, ScanProgress &prog) = 0;
53     virtual int32_t AddScanner(const std::string& serialNumber, const std::string& discoverMode) = 0;
54     virtual int32_t DeleteScanner(const std::string& serialNumber, const std::string& discoverMode) = 0;
55     virtual int32_t GetAddedScanner(std::vector<ScanDeviceInfo>& allAddedScanner) = 0;
56     virtual int32_t UpdateScannerName(const std::string& serialNumber,
57         const std::string& discoverMode, const std::string& deviceName) = 0;
58 
59     virtual int32_t On(const std::string taskId, const std::string &type, const sptr<IScanCallback> &listener) = 0;
60     virtual int32_t Off(const std::string taskId, const std::string &type) = 0;
61 };
62 
63 enum {
64     CMD_INIT_SCAN,
65     CMD_EXIT_SCAN,
66     CMD_GET_SCANNER_LIST,
67     CMD_STOP_DISCOVER,
68     CMD_OPEN_SCANNER,
69     CMD_CLOSE_SCANNER,
70     CMD_GET_SCAN_OPTION_DESC,
71     CMD_OP_SCAN_OPTION_VALUE,
72     CMD_GET_SCAN_PARAMETERS,
73     CMD_START_SCAN,
74     CMD_GET_SINGLE_FRAME,
75     CMD_GET_SINGLE_FRAME_FD,
76     CMD_CANCEL_SCAN,
77     CMD_SET_SCAN_IO_MODE,
78     CMD_GET_SCAN_SELECT_FD,
79     CMD_GET_SCANNER_STATE,
80     CMD_GET_SCAN_PROGRESS,
81     CMD_CONNECT_SCANNER,
82     CMD_DISCONNECT_SCANNER,
83     CMD_GET_CONNECTED_SCANNER,
84     CMD_UPDATE_SCANNER_NAME,
85     CMD_ADD_PRINTER,
86     CMD_ON,
87     CMD_OFF
88 };
89 } // namespace OHOS::Scan
90 #endif // SCAN_SERVICE_INTERFACE_H
91