• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     if (!pickerCallBack_) {
38         HILOG_ERROR("[picker] OnRelease error");
39         return;
40     }
41     this->uiContent->CloseModalUIExtension(this->sessionId_);
42     pickerCallBack_->ready = true;
43 }
44 
OnError(int32_t code,const std::string & name,const std::string & message)45 void ModalUICallback::OnError(int32_t code, const std::string& name, const std::string& message)
46 {
47     HILOG_ERROR("[picker] OnError enter. errorCode=%{public}d, name=%{public}s, message=%{public}s",
48         code, name.c_str(), message.c_str());
49     this->uiContent->CloseModalUIExtension(this->sessionId_);
50 }
51 
OnResultForModal(int32_t resultCode,const OHOS::AAFwk::Want & result)52 void ModalUICallback::OnResultForModal(int32_t resultCode, const OHOS::AAFwk::Want &result)
53 {
54     HILOG_INFO("[picker] OnResultForModal enter. resultCode is %{public}d,", resultCode);
55     if (!pickerCallBack_) {
56         HILOG_ERROR("[picker] OnResultForModal error.");
57         return;
58     }
59     pickerCallBack_->resultCode = resultCode;
60     pickerCallBack_->want = result;
61 }
62 
OnReceive(const OHOS::AAFwk::WantParams & request)63 void ModalUICallback::OnReceive(const OHOS::AAFwk::WantParams &request)
64 {
65     HILOG_INFO("[picker] OnReceive enter.");
66 }
67 
OnDestroy()68 void ModalUICallback::OnDestroy()
69 {
70     HILOG_INFO("[picker] OnDestroy enter.");
71 }
72 } // namespace Picker
73 } // namespace OHOS