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 "modal_ui_callback.h"
17 #include "picker_n_exporter.h"
18 
19 namespace OHOS {
20 namespace Picker {
21 using namespace OHOS::Ace;
22 using namespace std;
ModalUICallback(Ace::UIContent * uiContent,std::shared_ptr<PickerCallBack> pickerCallBack)23 ModalUICallback::ModalUICallback(Ace::UIContent* uiContent, std::shared_ptr<PickerCallBack> pickerCallBack)
24 {
25     this->uiContent = uiContent;
26     this->pickerCallBack_ = pickerCallBack;
27 }
28 
SetSessionId(int32_t sessionId)29 void ModalUICallback::SetSessionId(int32_t sessionId)
30 {
31     this->sessionId_ = sessionId;
32 }
33 
OnRelease(int32_t releaseCode)34 void ModalUICallback::OnRelease(int32_t releaseCode)
35 {
36     HILOG_INFO("[picker] OnRelease enter. release code is %{public}d", releaseCode);
37     this->uiContent->CloseModalUIExtension(this->sessionId_);
38     pickerCallBack_->ready = true;
39 }
40 
OnError(int32_t code,const std::string & name,const std::string & message)41 void ModalUICallback::OnError(int32_t code, const std::string& name, const std::string& message)
42 {
43     HILOG_ERROR("[picker] OnError enter. errorCode=%{public}d, name=%{public}s, message=%{public}s",
44         code, name.c_str(), message.c_str());
45     this->uiContent->CloseModalUIExtension(this->sessionId_);
46 }
47 
OnResultForModal(int32_t resultCode,const OHOS::AAFwk::Want & result)48 void ModalUICallback::OnResultForModal(int32_t resultCode, const OHOS::AAFwk::Want &result)
49 {
50     HILOG_INFO("[picker] OnResultForModal enter. resultCode is %{public}d,", resultCode);
51     pickerCallBack_->resultCode = resultCode;
52     pickerCallBack_->want = result;
53 }
54 
OnReceive(const OHOS::AAFwk::WantParams & request)55 void ModalUICallback::OnReceive(const OHOS::AAFwk::WantParams &request)
56 {
57     HILOG_INFO("[picker] OnReceive enter.");
58 }
59 
OnDestroy()60 void ModalUICallback::OnDestroy()
61 {
62     HILOG_INFO("[picker] OnDestroy enter.");
63 }
64 } // namespace Picker
65 } // namespace OHOS