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 16 #include "payload_data/close_session_data.h" 17 #include "media_log.h" 18 #include "media_mtp_utils.h" 19 #include "mtp_constants.h" 20 #include "mtp_packet_tools.h" 21 22 using namespace std; 23 namespace OHOS { 24 namespace Media { CloseSessionData(shared_ptr<MtpOperationContext> & context)25CloseSessionData::CloseSessionData(shared_ptr<MtpOperationContext> &context) 26 :PayloadData(context) 27 { 28 } 29 ~CloseSessionData()30CloseSessionData::~CloseSessionData() 31 { 32 } 33 Parser(const vector<uint8_t> & buffer,int32_t readSize)34int CloseSessionData::Parser(const vector<uint8_t> &buffer, int32_t readSize) 35 { 36 if (!context_->sessionOpen) { 37 return MTP_SESSION_NOT_OPEN_CODE; 38 } 39 return MTP_OK_CODE; 40 } 41 Maker(vector<uint8_t> & outBuffer)42int CloseSessionData::Maker(vector<uint8_t> &outBuffer) 43 { 44 MtpPacketTool::PutUInt32(outBuffer, MTP_OK_CODE); 45 return MTP_OK_CODE; 46 } 47 CalculateSize()48uint32_t CloseSessionData::CalculateSize() 49 { 50 std::vector<uint8_t> tmpVar; 51 52 int res = Maker(tmpVar); 53 if (res != MTP_OK_CODE) { 54 return res; 55 } 56 uint32_t size = tmpVar.size(); 57 return size; 58 } 59 } // namespace Media 60 } // namespace OHOS