blob: 0ee930f7dd5b43dd1a91e86f73751c2c61a133ec [file] [log] [blame]
Mike Lockwood5ed68d22010-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;
Mike Lockwooda6c490b2010-06-05 22:45:01 -040039 MtpPropertyList mDeviceProperties;
Mike Lockwood5ed68d22010-05-25 19:08:48 -040040
41 // a unique ID for the device
42 int mID;
43
44 // current session ID
45 MtpSessionID mSessionID;
46 // current transaction ID
47 MtpTransactionID mTransactionID;
48
49 MtpRequestPacket mRequest;
50 MtpDataPacket mData;
51 MtpResponsePacket mResponse;
52
53public:
54 MtpDevice(struct usb_device* device, int interface,
55 struct usb_endpoint *ep_in, struct usb_endpoint *ep_out,
56 struct usb_endpoint *ep_intr);
57 virtual ~MtpDevice();
58
59 inline int getID() const { return mID; }
60
61 void initialize();
62 void close();
63 const char* getDeviceName();
64
65 bool openSession();
66 bool closeSession();
67
68 MtpDeviceInfo* getDeviceInfo();
69 MtpStorageIDList* getStorageIDs();
70 MtpStorageInfo* getStorageInfo(MtpStorageID storageID);
71 MtpObjectHandleList* getObjectHandles(MtpStorageID storageID, MtpObjectFormat format, MtpObjectHandle parent);
72 MtpObjectInfo* getObjectInfo(MtpObjectHandle handle);
Mike Lockwood3e072b32010-06-10 16:34:20 -040073 void* getThumbnail(MtpObjectHandle handle, int& outLength);
Mike Lockwood5ed68d22010-05-25 19:08:48 -040074
Mike Lockwooda6c490b2010-06-05 22:45:01 -040075 MtpProperty* getDevicePropDesc(MtpDeviceProperty code);
76
Mike Lockwood5ed68d22010-05-25 19:08:48 -040077private:
78 bool sendRequest(MtpOperationCode operation);
79 bool sendData(MtpOperationCode operation);
80 bool readData();
81 MtpResponseCode readResponse();
82
83};
84
85}; // namespace android
86
87#endif // _MTP_DEVICE_H