1 /*
2 * Copyright (c) 2023 Shenzhen Kaihong Digital Industry Development 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 "ipc_msg_decoder.h"
17 #include "common/sharing_log.h"
18
19 namespace OHOS {
20 namespace Sharing {
21
MsgDecode(std::shared_ptr<BaseMsg> & sharingMsg,MessageParcel & ipcMsg)22 int32_t IpcMsgDecoder::MsgDecode(std::shared_ptr<BaseMsg> &sharingMsg, MessageParcel &ipcMsg)
23 {
24 SHARING_LOGD("trace.");
25 int32_t nMsgType = ipcMsg.ReadInt32();
26 return this->OnIpcMessage(nMsgType, sharingMsg, ipcMsg);
27 }
28
DomainMsgDecode(std::shared_ptr<BaseDomainMsg> & sharingMsg,MessageParcel & ipcMsg)29 int32_t IpcMsgDecoder::DomainMsgDecode(std::shared_ptr<BaseDomainMsg> &sharingMsg, MessageParcel &ipcMsg)
30 {
31 SHARING_LOGD("trace.");
32 std::shared_ptr<BaseMsg> reply = nullptr;
33 int32_t ret = MsgDecode(reply, ipcMsg);
34 if (ret != 0) {
35 SHARING_LOGE("decode domain msg failed.");
36 return ret;
37 }
38
39 sharingMsg = std::static_pointer_cast<BaseDomainMsg>(reply);
40 return 0;
41 }
42
43 } // namespace Sharing
44 } // namespace OHOS