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 #include "print_innerkit_modal_ui_callback.h"
17 #include "napi_print_utils.h"
18 #include "print_log.h"
19 
20 #include "ui_content.h"
21 
22 using namespace OHOS::Ace;
23 
24 namespace OHOS {
25 namespace Print {
26 
PrintInnerkitModalUICallback(OHOS::Ace::UIContent * uiContent)27 PrintInnerkitModalUICallback::PrintInnerkitModalUICallback(OHOS::Ace::UIContent *uiContent)
28 {
29     this->uiContent = uiContent;
30     PRINT_HILOGD("constructor ModalUICallback");
31 }
32 
SetSessionId(int32_t sessionId)33 void PrintInnerkitModalUICallback::SetSessionId(int32_t sessionId)
34 {
35     this->sessionId_ = sessionId;
36 }
37 
OnRelease(int32_t releaseCode)38 void PrintInnerkitModalUICallback::OnRelease(int32_t releaseCode)
39 {
40     PRINT_HILOGD("OnRelease enter. release code is %{public}d", releaseCode);
41     if (this->uiContent == nullptr) {
42         PRINT_HILOGE("OnRelease uiContent is null");
43         return;
44     }
45 
46     PRINT_HILOGI("CloseModalUIExtension");
47     this->uiContent->CloseModalUIExtension(this->sessionId_);
48     return;
49 }
50 
OnReceive(const OHOS::AAFwk::WantParams & request)51 void PrintInnerkitModalUICallback::OnReceive(const OHOS::AAFwk::WantParams& request)
52 {
53     PRINT_HILOGD("OnReceive enter.");
54 }
55 
OnError(int32_t code,const std::string & name,const std::string & message)56 void PrintInnerkitModalUICallback::OnError(int32_t code, const std::string& name, const std::string& message)
57 {
58     PRINT_HILOGE("OnError enter. errorCode=%{public}d, name=%{public}s, message=%{public}s",
59         code, name.c_str(), message.c_str());
60     if (this->uiContent == nullptr) {
61         PRINT_HILOGE("OnError uiContent is null");
62         return;
63     }
64 
65     PRINT_HILOGI("CloseModalUIExtension");
66     this->uiContent->CloseModalUIExtension(this->sessionId_);
67     return;
68 }
69 
OnResultForModal(int32_t resultCode,const OHOS::AAFwk::Want & result)70 void PrintInnerkitModalUICallback::OnResultForModal(int32_t resultCode, const OHOS::AAFwk::Want& result)
71 {
72     PRINT_HILOGD("OnResultForModal enter.");
73 }
74 } // namespace Print
75 } // namespace OHOS