1 /*
2 * Copyright (C) 2025 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 #define MLOG_TAG "Media_IPC"
16
17 #include "user_inner_ipc_client.h"
18
19 namespace OHOS::Media::IPC {
20 static const std::u16string DESCRIPTOR = u"OHOS.DataShare.IDataShare";
SetTraceId(const std::string & traceId)21 UserInnerIPCClient &UserInnerIPCClient::SetTraceId(const std::string &traceId)
22 {
23 this->traceId_ = traceId;
24 return *this;
25 }
26
GetTraceId() const27 std::string UserInnerIPCClient::GetTraceId() const
28 {
29 return this->traceId_;
30 }
31
SetUserId(const int32_t & userId)32 UserInnerIPCClient &UserInnerIPCClient::SetUserId(const int32_t &userId)
33 {
34 this->userId_ = userId;
35 return *this;
36 }
37
GetUserId() const38 int32_t UserInnerIPCClient::GetUserId() const
39 {
40 return this->userId_;
41 }
42
GetHeader() const43 std::unordered_map<std::string, std::string> UserInnerIPCClient::GetHeader() const
44 {
45 return this->header_;
46 }
47
SetHeader(const std::unordered_map<std::string,std::string> & header)48 UserInnerIPCClient &UserInnerIPCClient::SetHeader(const std::unordered_map<std::string, std::string> &header)
49 {
50 this->header_ = header;
51 return *this;
52 }
53
SetDataShareHelper(std::shared_ptr<DataShare::DataShareHelper> dataShareHelper)54 UserInnerIPCClient &UserInnerIPCClient::SetDataShareHelper(std::shared_ptr<DataShare::DataShareHelper> dataShareHelper)
55 {
56 this->dataShareHelper_ = dataShareHelper;
57 return *this;
58 }
59
HeaderMarshalling(MessageParcel & data)60 int32_t UserInnerIPCClient::HeaderMarshalling(MessageParcel &data)
61 {
62 bool errConn = !data.WriteInterfaceToken(DESCRIPTOR);
63 CHECK_AND_RETURN_RET_LOG(!errConn, E_FAIL, "WriteInterfaceToken failed");
64 return E_OK;
65 }
66
UserDefineFunc(MessageParcel & data,MessageParcel & reply,MessageOption & option)67 int32_t UserInnerIPCClient::UserDefineFunc(MessageParcel &data, MessageParcel &reply, MessageOption &option)
68 {
69 CHECK_AND_RETURN_RET_LOG(this->dataShareHelper_ != nullptr, E_ERR, "dataShareHelper_ is nullptr");
70 return this->dataShareHelper_->UserDefineFunc(data, reply, option);
71 }
72 } // namespace OHOS::Media::IPC