• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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_ANI_CALLBACK_H
17 #define PRINT_ANI_CALLBACK_H
18 
19 #include <mutex>
20 #include <uv.h>
21 #include <ani.h>
22 #include <functional>
23 #include "print_callback_stub.h"
24 #include "iprint_adapter.h"
25 #include "print_manager_client.h"
26 
27 namespace OHOS::Print {
28 class PrintAniCallback : public PrintCallbackStub {
29 public:
30     PrintAniCallback(ani_env *env, ani_object callback);
PrintAniCallback()31     PrintAniCallback(){};
32     ~PrintAniCallback();
33     bool OnCallback() override;
34     bool OnCallback(uint32_t state, const PrinterInfo &info) override;
35     bool OnCallback(uint32_t state, const PrintJob &info) override;
36     bool OnCallback(const std::string &extensionId, const std::string &info) override;
37     bool OnCallbackAdapterLayout(const std::string &jobId, const PrintAttributes &oldAttrs,
38         const PrintAttributes &newAttrs, uint32_t fd) override;
39     bool onCallbackAdapterJobStateChanged(const std::string jobId,
40         const uint32_t state, const uint32_t subState) override;
41 
42     bool OnCallbackAdapterGetFile(uint32_t state) override;
43 
44 private:
45     std::mutex mutex_;
46     ani_vm *aniVm_ = nullptr;
47     ani_ref aniCallback_ = nullptr;
48 };
49 }  // namespace OHOS::Print
50 #endif  // PRINT_ANI_CALLBACK_H
51