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 #ifndef FRAMEWORKS_SERVICES_MEDIA_MTP_INCLUDE_MTP_OPERATION_H_ 16 #define FRAMEWORKS_SERVICES_MEDIA_MTP_INCLUDE_MTP_OPERATION_H_ 17 #include <memory> 18 #include <vector> 19 #include "mtp_driver.h" 20 #include "mtp_operation_context.h" 21 #include "mtp_operation_utils.h" 22 #include "mtp_packet.h" 23 #include "payload_data.h" 24 namespace OHOS { 25 namespace Media { 26 27 class MtpOperation { 28 public: 29 MtpOperation(); 30 ~MtpOperation() = default; 31 void Execute(); 32 33 private: 34 void Init(); 35 void ResetOperation(); 36 uint16_t GetPayloadData(std::shared_ptr<MtpOperationContext> &context, 37 std::shared_ptr<PayloadData> &data, uint16_t containerType, int &errorCode); 38 uint16_t GetPayloadDataSub(std::shared_ptr<MtpOperationContext> &context, 39 std::shared_ptr<PayloadData> &data, uint16_t containerType, int &errorCode); 40 uint16_t GetPayloadDataMore(std::shared_ptr<MtpOperationContext> &context, 41 std::shared_ptr<PayloadData> &data, uint16_t containerType, int &errorCode); 42 void ReceiveRequestPacket(int &errorCode); 43 void SendObjectData(int &errorCode); 44 void RecevieObjectData(int &errorCode); 45 void SendMakeResponsePacket(int &errorCode); 46 void ReceiveI2Rdata(int &errorCode); 47 void SendR2Idata(int &errorCode); 48 void AddStorage(std::shared_ptr<Storage> &storage); 49 void RemoveStorage(std::shared_ptr<Storage> &storage); 50 void DealRequest(uint16_t operationCode, int &errorCode); 51 52 private: 53 std::shared_ptr<MtpOperationContext> mtpContextPtr_; 54 std::shared_ptr<MtpPacket> requestPacketPtr_; 55 std::shared_ptr<MtpPacket> dataPacketPtr_; 56 std::shared_ptr<MtpPacket> responsePacketPtr_; 57 std::shared_ptr<MtpOperationUtils> operationUtils_; 58 std::shared_ptr<MtpDriver> mtpDriver_; 59 std::shared_ptr<PayloadData> dataPayloadData_; 60 uint16_t responseCode_; 61 }; 62 } // namespace Media 63 } // namespace OHOS 64 #endif // FRAMEWORKS_SERVICES_MEDIA_MTP_INCLUDE_MTP_OPERATION_H_ 65