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 GetPayloadDataMore(std::shared_ptr<MtpOperationContext> &context, 39 std::shared_ptr<PayloadData> &data, uint16_t containerType, int &errorCode); 40 void ReceiveRequestPacket(int &errorCode); 41 void SendObjectData(int &errorCode); 42 void RecevieObjectData(int &errorCode); 43 void SendMakeResponsePacket(int &errorCode); 44 void ReceiveI2Rdata(int &errorCode); 45 void SendR2Idata(int &errorCode); 46 void AddStorage(std::shared_ptr<Storage> &storage); 47 void RemoveStorage(std::shared_ptr<Storage> &storage); 48 void DealRequest(uint16_t operationCode, int &errorCode); 49 50 private: 51 std::shared_ptr<MtpOperationContext> mtpContextPtr_; 52 std::shared_ptr<MtpPacket> requestPacketPtr_; 53 std::shared_ptr<MtpPacket> dataPacketPtr_; 54 std::shared_ptr<MtpPacket> responsePacketPtr_; 55 std::shared_ptr<MtpOperationUtils> operationUtils_; 56 std::shared_ptr<MtpDriver> mtpDriver_; 57 std::shared_ptr<PayloadData> dataPayloadData_; 58 uint16_t responseCode_; 59 }; 60 } // namespace Media 61 } // namespace OHOS 62 #endif // FRAMEWORKS_SERVICES_MEDIA_MTP_INCLUDE_MTP_OPERATION_H_ 63