blob: e41a8725c5ddb19bededc0ca087b5b21209bafe1 [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
Mike Lockwoodb14e5882010-06-29 18:11:52 -040025struct usb_device;
26
Mike Lockwood5ed68d22010-05-25 19:08:48 -040027namespace android {
28
29class MtpDeviceInfo;
30class MtpObjectInfo;
31class MtpStorageInfo;
32
33class MtpDevice {
34private:
35 struct usb_device* mDevice;
36 int mInterface;
37 struct usb_endpoint* mEndpointIn;
38 struct usb_endpoint* mEndpointOut;
39 struct usb_endpoint* mEndpointIntr;
40 MtpDeviceInfo* mDeviceInfo;
Mike Lockwooda6c490b2010-06-05 22:45:01 -040041 MtpPropertyList mDeviceProperties;
Mike Lockwood5ed68d22010-05-25 19:08:48 -040042
43 // a unique ID for the device
44 int mID;
45
46 // current session ID
47 MtpSessionID mSessionID;
48 // current transaction ID
49 MtpTransactionID mTransactionID;
50
51 MtpRequestPacket mRequest;
52 MtpDataPacket mData;
53 MtpResponsePacket mResponse;
54
55public:
56 MtpDevice(struct usb_device* device, int interface,
57 struct usb_endpoint *ep_in, struct usb_endpoint *ep_out,
58 struct usb_endpoint *ep_intr);
59 virtual ~MtpDevice();
60
61 inline int getID() const { return mID; }
62
63 void initialize();
64 void close();
65 const char* getDeviceName();
66
67 bool openSession();
68 bool closeSession();
69
70 MtpDeviceInfo* getDeviceInfo();
71 MtpStorageIDList* getStorageIDs();
72 MtpStorageInfo* getStorageInfo(MtpStorageID storageID);
73 MtpObjectHandleList* getObjectHandles(MtpStorageID storageID, MtpObjectFormat format, MtpObjectHandle parent);
74 MtpObjectInfo* getObjectInfo(MtpObjectHandle handle);
Mike Lockwood3e072b32010-06-10 16:34:20 -040075 void* getThumbnail(MtpObjectHandle handle, int& outLength);
Mike Lockwood6afc41d2010-06-11 16:34:52 -040076 bool deleteObject(MtpObjectHandle handle);
77 MtpObjectHandle getParent(MtpObjectHandle handle);
78 MtpObjectHandle getStorageID(MtpObjectHandle handle);
Mike Lockwood5ed68d22010-05-25 19:08:48 -040079
Mike Lockwooda6c490b2010-06-05 22:45:01 -040080 MtpProperty* getDevicePropDesc(MtpDeviceProperty code);
81
Mike Lockwood5ed68d22010-05-25 19:08:48 -040082private:
83 bool sendRequest(MtpOperationCode operation);
84 bool sendData(MtpOperationCode operation);
85 bool readData();
86 MtpResponseCode readResponse();
87
88};
89
90}; // namespace android
91
92#endif // _MTP_DEVICE_H