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
18 #include "ui_content.h"
19
20
21 using namespace OHOS::Ace;
22 using namespace std;
23
24 namespace OHOS {
25 namespace Media {
ModalUICallback(Ace::UIContent * uiContent,PickerCallBack * pickerCallBack)26 ModalUICallback::ModalUICallback(Ace::UIContent* uiContent, PickerCallBack* pickerCallBack)
27 {
28 this->uiContent = uiContent;
29 this->pickerCallBack_ = pickerCallBack;
30 }
31
SetSessionId(int32_t sessionId)32 void ModalUICallback::SetSessionId(int32_t sessionId)
33 {
34 this->sessionId_=sessionId;
35 }
36
OnRelease(int32_t releaseCode)37 void ModalUICallback::OnRelease(int32_t releaseCode)
38 {
39 LOGI("OnRelease enter. release code is %{public}d", releaseCode);
40 this->uiContent->CloseModalUIExtension(this->sessionId_);
41 pickerCallBack_->ready = true;
42 }
43
OnError(int32_t code,const std::string & name,const std::string & message)44 void ModalUICallback::OnError(int32_t code, const std::string& name, const std::string& message)
45 {
46 LOGE("OnError enter. errorCode=%{public}d, name=%{public}s, message=%{public}s",
47 code, name.c_str(), message.c_str());
48 if (!pickerCallBack_->ready) {
49 this->uiContent->CloseModalUIExtension(this->sessionId_);
50 pickerCallBack_->ready = true;
51 }
52 }
53
OnResultForModal(int32_t resultCode,const OHOS::AAFwk::Want & result)54 void ModalUICallback::OnResultForModal(int32_t resultCode, const OHOS::AAFwk::Want &result)
55 {
56 LOGI("OnResultForModal enter. resultCode is %{public}d", resultCode);
57 pickerCallBack_->uris = result.GetStringArrayParam("select-item-list");
58 pickerCallBack_->isOrigin = result.GetBoolParam("isOriginal", false);
59 pickerCallBack_->resultCode = resultCode;
60 }
61
OnReceive(const OHOS::AAFwk::WantParams & request)62 void ModalUICallback::OnReceive(const OHOS::AAFwk::WantParams &request)
63 {
64 LOGI("OnReceive enter.");
65 }
66
OnDestroy()67 void ModalUICallback::OnDestroy()
68 {
69 LOGI("OnDestroy enter.");
70 }
71 } // namespace Media
72 } // namespace OHOS