1 /*
2  * Copyright (C) 2022-2023 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 #ifndef TELEPHONY_IMS_SMS_CALLBACK_STUB_H
17 #define TELEPHONY_IMS_SMS_CALLBACK_STUB_H
18 
19 #include <map>
20 
21 #include "ims_sms_callback_interface.h"
22 #include "ims_sms_callback_ipc_interface_code.h"
23 #include "iremote_stub.h"
24 #include "tel_event_handler.h"
25 
26 
27 namespace OHOS {
28 namespace Telephony {
29 class ImsSmsCallbackStub : public IRemoteStub<ImsSmsCallbackInterface> {
30 public:
31     ImsSmsCallbackStub();
32     virtual ~ImsSmsCallbackStub();
33     int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
34 
35     /****************** sms basic ******************/
36     int32_t ImsSendMessageResponse(int32_t slotId, const SendSmsResultInfo &result) override;
37     int32_t ImsSendMessageResponse(int32_t slotId, const RadioResponseInfo &info) override;
38     int32_t ImsSetSmsConfigResponse(int32_t slotId, const RadioResponseInfo &info) override;
39     int32_t ImsGetSmsConfigResponse(int32_t slotId, int32_t imsSmsConfig) override;
40     int32_t ImsGetSmsConfigResponse(int32_t slotId, const RadioResponseInfo &info) override;
41 
42 private:
43     void InitFuncMap();
44     void InitSmsBasicFuncMap();
45 
46     /****************** sms basic ******************/
47     int32_t OnImsSendMessageResponseInner(MessageParcel &data, MessageParcel &reply);
48     int32_t OnImsSetSmsConfigResponseInner(MessageParcel &data, MessageParcel &reply);
49     int32_t OnImsGetSmsConfigResponseInner(MessageParcel &data, MessageParcel &reply);
50 
51     int32_t SendHRilRadioResponseInfo(int32_t slotId, uint32_t eventId, const RadioResponseInfo &info);
52 
53 private:
54     using RequestFuncType = std::function<int32_t(MessageParcel &data, MessageParcel &reply)>;
55     std::map<uint32_t, RequestFuncType> requestFuncMap_;
56     std::shared_ptr<TelEventHandler> handler_[2];
57 };
58 } // namespace Telephony
59 } // namespace OHOS
60 
61 #endif // TELEPHONY_IMS_SMS_CALLBACK_STUB_H
62