blob: fe4f1bdaa925a38155bc3323d80ddbd148d09045 [file] [log] [blame]
Mike Lockwood755fd612010-05-25 19:08:48 -04001/*
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_DEVICE_H
18#define _MTP_DEVICE_H
19
20#include "MtpRequestPacket.h"
21#include "MtpDataPacket.h"
22#include "MtpResponsePacket.h"
23#include "MtpTypes.h"
24
25namespace android {
26
27class MtpDeviceInfo;
28class MtpObjectInfo;
29class MtpStorageInfo;
30
31class MtpDevice {
32private:
33 struct usb_device* mDevice;
34 int mInterface;
35 struct usb_endpoint* mEndpointIn;
36 struct usb_endpoint* mEndpointOut;
37 struct usb_endpoint* mEndpointIntr;
38 MtpDeviceInfo* mDeviceInfo;
39
40 // a unique ID for the device
41 int mID;
42
43 // current session ID
44 MtpSessionID mSessionID;
45 // current transaction ID
46 MtpTransactionID mTransactionID;
47
48 MtpRequestPacket mRequest;
49 MtpDataPacket mData;
50 MtpResponsePacket mResponse;
51
52public:
53 MtpDevice(struct usb_device* device, int interface,
54 struct usb_endpoint *ep_in, struct usb_endpoint *ep_out,
55 struct usb_endpoint *ep_intr);
56 virtual ~MtpDevice();
57
58 inline int getID() const { return mID; }
59
60 void initialize();
61 void close();
62 const char* getDeviceName();
63
64 bool openSession();
65 bool closeSession();
66
67 MtpDeviceInfo* getDeviceInfo();
68 MtpStorageIDList* getStorageIDs();
69 MtpStorageInfo* getStorageInfo(MtpStorageID storageID);
70 MtpObjectHandleList* getObjectHandles(MtpStorageID storageID, MtpObjectFormat format, MtpObjectHandle parent);
71 MtpObjectInfo* getObjectInfo(MtpObjectHandle handle);
72
73private:
74 bool sendRequest(MtpOperationCode operation);
75 bool sendData(MtpOperationCode operation);
76 bool readData();
77 MtpResponseCode readResponse();
78
79};
80
81}; // namespace android
82
83#endif // _MTP_DEVICE_H