1 /* 2 * Copyright (c) 2022 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 #ifndef OHOS_ACE_DIALOG_CALLBACK_STUB_H 16 #define OHOS_ACE_DIALOG_CALLBACK_STUB_H 17 18 #include <memory> 19 #include <map> 20 21 #include "dialog_callback_interface.h" 22 #include "nocopyable.h" 23 24 #include <iremote_object.h> 25 #include <iremote_stub.h> 26 27 namespace OHOS { 28 namespace Ace { 29 class DialogCallbackStub : public IRemoteStub<IDialogCallback> { 30 public: 31 DialogCallbackStub(DialogCallback callback); 32 virtual ~DialogCallbackStub(); 33 34 int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; 35 void OnDialogCallback(int32_t id, const std::string& event, const std::string& params) override; 36 37 private: 38 int OnDialogCallBackInner(MessageParcel &data, MessageParcel &reply); 39 40 DialogCallback callback_; 41 42 DISALLOW_COPY_AND_MOVE(DialogCallbackStub); 43 }; 44 45 /** 46 * @class DialogCallbackRecipient 47 * DialogCallbackRecipient notices IRemoteBroker died. 48 */ 49 class DialogCallbackRecipient : public IRemoteObject::DeathRecipient { 50 public: 51 using RemoteDiedHandler = std::function<void(const wptr<IRemoteObject> &)>; 52 DialogCallbackRecipient(RemoteDiedHandler handler); 53 virtual ~DialogCallbackRecipient(); 54 virtual void OnRemoteDied(const wptr<IRemoteObject> &remote); 55 56 private: 57 RemoteDiedHandler handler_; 58 }; 59 } // namespace Ace 60 } // namespace OHOS 61 #endif // OHOS_ACE_DIALOG_CALLBACK_STUB_H