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; |
Mike Lockwood | e13401b | 2010-05-19 15:12:14 -0400 | [diff] [blame^] | 28 | class MtpObjectInfo; |
Mike Lockwood | 335dd2b | 2010-05-19 10:33:39 -0400 | [diff] [blame] | 29 | class MtpStorageInfo; |
| 30 | |
Mike Lockwood | 16864ba | 2010-05-11 17:16:59 -0400 | [diff] [blame] | 31 | class MtpClient { |
| 32 | private: |
Mike Lockwood | e13401b | 2010-05-19 15:12:14 -0400 | [diff] [blame^] | 33 | struct usb_endpoint* mEndpointIn; |
| 34 | struct usb_endpoint* mEndpointOut; |
| 35 | struct usb_endpoint* mEndpointIntr; |
Mike Lockwood | 16864ba | 2010-05-11 17:16:59 -0400 | [diff] [blame] | 36 | |
| 37 | // current session ID |
Mike Lockwood | e13401b | 2010-05-19 15:12:14 -0400 | [diff] [blame^] | 38 | MtpSessionID mSessionID; |
Mike Lockwood | 16864ba | 2010-05-11 17:16:59 -0400 | [diff] [blame] | 39 | // current transaction ID |
Mike Lockwood | e13401b | 2010-05-19 15:12:14 -0400 | [diff] [blame^] | 40 | MtpTransactionID mTransactionID; |
Mike Lockwood | 16864ba | 2010-05-11 17:16:59 -0400 | [diff] [blame] | 41 | |
Mike Lockwood | e13401b | 2010-05-19 15:12:14 -0400 | [diff] [blame^] | 42 | MtpRequestPacket mRequest; |
| 43 | MtpDataPacket mData; |
| 44 | MtpResponsePacket mResponse; |
Mike Lockwood | 16864ba | 2010-05-11 17:16:59 -0400 | [diff] [blame] | 45 | |
| 46 | public: |
Mike Lockwood | e13401b | 2010-05-19 15:12:14 -0400 | [diff] [blame^] | 47 | MtpClient(struct usb_endpoint *ep_in, struct usb_endpoint *ep_out, |
Mike Lockwood | 16864ba | 2010-05-11 17:16:59 -0400 | [diff] [blame] | 48 | struct usb_endpoint *ep_intr); |
Mike Lockwood | e13401b | 2010-05-19 15:12:14 -0400 | [diff] [blame^] | 49 | virtual ~MtpClient(); |
Mike Lockwood | 16864ba | 2010-05-11 17:16:59 -0400 | [diff] [blame] | 50 | |
Mike Lockwood | e13401b | 2010-05-19 15:12:14 -0400 | [diff] [blame^] | 51 | bool openSession(); |
| 52 | bool closeSession(); |
Mike Lockwood | 16864ba | 2010-05-11 17:16:59 -0400 | [diff] [blame] | 53 | |
Mike Lockwood | e13401b | 2010-05-19 15:12:14 -0400 | [diff] [blame^] | 54 | MtpDeviceInfo* getDeviceInfo(); |
| 55 | MtpStorageIDList* getStorageIDs(); |
| 56 | MtpStorageInfo* getStorageInfo(MtpStorageID storageID); |
| 57 | MtpObjectHandleList* getObjectHandles(MtpStorageID storageID, MtpObjectFormat format, MtpObjectHandle parent); |
| 58 | MtpObjectInfo* getObjectInfo(MtpObjectHandle handle); |
Mike Lockwood | 335dd2b | 2010-05-19 10:33:39 -0400 | [diff] [blame] | 59 | |
Mike Lockwood | 16864ba | 2010-05-11 17:16:59 -0400 | [diff] [blame] | 60 | private: |
Mike Lockwood | e13401b | 2010-05-19 15:12:14 -0400 | [diff] [blame^] | 61 | bool sendRequest(MtpOperationCode operation); |
| 62 | bool sendData(MtpOperationCode operation); |
| 63 | bool readData(); |
| 64 | MtpResponseCode readResponse(); |
Mike Lockwood | 16864ba | 2010-05-11 17:16:59 -0400 | [diff] [blame] | 65 | |
| 66 | }; |
| 67 | |
Mike Lockwood | 7850ef9 | 2010-05-14 10:10:36 -0400 | [diff] [blame] | 68 | }; // namespace android |
| 69 | |
Mike Lockwood | 16864ba | 2010-05-11 17:16:59 -0400 | [diff] [blame] | 70 | #endif // _MTP_CLIENT_H |