• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021-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 SMS_INTERFACE_STUB_H
17 #define SMS_INTERFACE_STUB_H
18 
19 #include <list>
20 #include <memory>
21 #include <mutex>
22 #include <string>
23 
24 #include "iremote_stub.h"
25 
26 #include "i_sms_service_interface.h"
27 #include "sms_interface_manager.h"
28 #include "sms_receive_manager.h"
29 #include "sms_send_manager.h"
30 #include "sms_service_ipc_interface_code.h"
31 
32 namespace OHOS {
33 namespace Telephony {
34 class SmsInterfaceStub : public IRemoteStub<ISmsServiceInterface> {
35 public:
36     SmsInterfaceStub();
37     ~SmsInterfaceStub();
38     virtual int OnRemoteRequest(
39         uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
40     std::shared_ptr<SmsInterfaceManager> GetSmsInterfaceManager(int32_t slotId);
41     std::shared_ptr<SmsInterfaceManager> GetSmsInterfaceManager();
42 
43 protected:
44     void InitModule();
45 
46 private:
47     void OnSendSmsTextRequest(MessageParcel &data, MessageParcel &reply, MessageOption &option);
48     void OnSendSmsDataRequest(MessageParcel &data, MessageParcel &reply, MessageOption &option);
49     void OnSetSmscAddr(MessageParcel &data, MessageParcel &reply, MessageOption &option);
50     void OnGetSmscAddr(MessageParcel &data, MessageParcel &reply, MessageOption &option);
51     void OnAddSimMessage(MessageParcel &data, MessageParcel &reply, MessageOption &option);
52     void OnDelSimMessage(MessageParcel &data, MessageParcel &reply, MessageOption &option);
53     void OnUpdateSimMessage(MessageParcel &data, MessageParcel &reply, MessageOption &option);
54     void OnGetAllSimMessages(MessageParcel &data, MessageParcel &reply, MessageOption &option);
55     void OnSetCBRangeConfig(MessageParcel &data, MessageParcel &reply, MessageOption &option);
56     void OnSetCBConfig(MessageParcel &data, MessageParcel &reply, MessageOption &option);
57     void OnSetImsSmsConfig(MessageParcel &data, MessageParcel &reply, MessageOption &option);
58     void OnSetDefaultSmsSlotId(MessageParcel &data, MessageParcel &reply, MessageOption &option);
59     void OnGetDefaultSmsSlotId(MessageParcel &data, MessageParcel &reply, MessageOption &option);
60     void OnGetDefaultSmsSimId(MessageParcel &data, MessageParcel &reply, MessageOption &option);
61     void OnSplitMessage(MessageParcel &data, MessageParcel &reply, MessageOption &option);
62     void OnGetSmsSegmentsInfo(MessageParcel &data, MessageParcel &reply, MessageOption &option);
63     void OnIsImsSmsSupported(MessageParcel &data, MessageParcel &reply, MessageOption &option);
64     void OnGetImsShortMessageFormat(MessageParcel &data, MessageParcel &reply, MessageOption &option);
65     void OnHasSmsCapability(MessageParcel &data, MessageParcel &reply, MessageOption &option);
66     void OnCreateMessage(MessageParcel &data, MessageParcel &reply, MessageOption &option);
67     void OnGetBase64Encode(MessageParcel &data, MessageParcel &reply, MessageOption &option);
68     void OnGetBase64Decode(MessageParcel &data, MessageParcel &reply, MessageOption &option);
69     void OnGetEncodeStringFunc(MessageParcel &data, MessageParcel &reply, MessageOption &option);
70     void RemoveSpacesInDesAddr(std::u16string &desAddr);
71 
72     void OnSendMms(MessageParcel &data, MessageParcel &reply, MessageOption &option);
73     void OnDownloadMms(MessageParcel &data, MessageParcel &reply, MessageOption &option);
74 
75     std::map<uint32_t, std::shared_ptr<SmsInterfaceManager>> slotSmsInterfaceManagerMap_;
76     using SmsServiceFunc = void (SmsInterfaceStub::*)(MessageParcel &data, MessageParcel &reply, MessageOption &option);
77     std::map<uint32_t, SmsServiceFunc> memberFuncMap_;
78     std::mutex mutex_;
79     const std::string MMS_APP = "com.ohos.mms";
80 };
81 } // namespace Telephony
82 } // namespace OHOS
83 #endif