Mike Lockwood | 16864ba | 2010-05-11 17:16:59 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef _MTP_CLIENT_H |
| 18 | #define _MTP_CLIENT_H |
| 19 | |
| 20 | #include "MtpRequestPacket.h" |
| 21 | #include "MtpDataPacket.h" |
| 22 | #include "MtpResponsePacket.h" |
Mike Lockwood | 335dd2b | 2010-05-19 10:33:39 -0400 | [diff] [blame^] | 23 | #include "MtpTypes.h" |
Mike Lockwood | 16864ba | 2010-05-11 17:16:59 -0400 | [diff] [blame] | 24 | |
Mike Lockwood | 7850ef9 | 2010-05-14 10:10:36 -0400 | [diff] [blame] | 25 | namespace android { |
| 26 | |
Mike Lockwood | 335dd2b | 2010-05-19 10:33:39 -0400 | [diff] [blame^] | 27 | class MtpDeviceInfo; |
| 28 | class MtpStorageInfo; |
| 29 | |
Mike Lockwood | 16864ba | 2010-05-11 17:16:59 -0400 | [diff] [blame] | 30 | class MtpClient { |
| 31 | private: |
| 32 | struct usb_endpoint *mEndpointIn; |
| 33 | struct usb_endpoint *mEndpointOut; |
| 34 | struct usb_endpoint *mEndpointIntr; |
| 35 | |
| 36 | // current session ID |
| 37 | MtpSessionID mSessionID; |
| 38 | // current transaction ID |
| 39 | MtpTransactionID mTransactionID; |
| 40 | |
| 41 | MtpRequestPacket mRequest; |
| 42 | MtpDataPacket mData; |
| 43 | MtpResponsePacket mResponse; |
| 44 | |
| 45 | public: |
| 46 | MtpClient(struct usb_endpoint *ep_in, struct usb_endpoint *ep_out, |
| 47 | struct usb_endpoint *ep_intr); |
| 48 | virtual ~MtpClient(); |
| 49 | |
| 50 | bool openSession(); |
Mike Lockwood | 16864ba | 2010-05-11 17:16:59 -0400 | [diff] [blame] | 51 | bool closeSession(); |
| 52 | |
Mike Lockwood | 335dd2b | 2010-05-19 10:33:39 -0400 | [diff] [blame^] | 53 | MtpDeviceInfo* getDeviceInfo(); |
| 54 | MtpStorageIDList* getStorageIDs(); |
| 55 | MtpStorageInfo* getStorageInfo(MtpStorageID storageID); |
| 56 | |
Mike Lockwood | 16864ba | 2010-05-11 17:16:59 -0400 | [diff] [blame] | 57 | private: |
| 58 | bool sendRequest(MtpOperationCode operation); |
| 59 | bool sendData(MtpOperationCode operation); |
| 60 | bool readData(); |
| 61 | MtpResponseCode readResponse(); |
| 62 | |
| 63 | }; |
| 64 | |
Mike Lockwood | 7850ef9 | 2010-05-14 10:10:36 -0400 | [diff] [blame] | 65 | }; // namespace android |
| 66 | |
Mike Lockwood | 16864ba | 2010-05-11 17:16:59 -0400 | [diff] [blame] | 67 | #endif // _MTP_CLIENT_H |