blob: b43a9e043102625b10123f84462f5807bcb89059 [file] [log] [blame]
Mike Lockwood16864ba2010-05-11 17:16:59 -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_CLIENT_H
18#define _MTP_CLIENT_H
19
20#include "MtpRequestPacket.h"
21#include "MtpDataPacket.h"
22#include "MtpResponsePacket.h"
Mike Lockwood335dd2b2010-05-19 10:33:39 -040023#include "MtpTypes.h"
Mike Lockwood16864ba2010-05-11 17:16:59 -040024
Mike Lockwood7850ef92010-05-14 10:10:36 -040025namespace android {
26
Mike Lockwood335dd2b2010-05-19 10:33:39 -040027class MtpDeviceInfo;
28class MtpStorageInfo;
29
Mike Lockwood16864ba2010-05-11 17:16:59 -040030class MtpClient {
31private:
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
45public:
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 Lockwood16864ba2010-05-11 17:16:59 -040051 bool closeSession();
52
Mike Lockwood335dd2b2010-05-19 10:33:39 -040053 MtpDeviceInfo* getDeviceInfo();
54 MtpStorageIDList* getStorageIDs();
55 MtpStorageInfo* getStorageInfo(MtpStorageID storageID);
56
Mike Lockwood16864ba2010-05-11 17:16:59 -040057private:
58 bool sendRequest(MtpOperationCode operation);
59 bool sendData(MtpOperationCode operation);
60 bool readData();
61 MtpResponseCode readResponse();
62
63};
64
Mike Lockwood7850ef92010-05-14 10:10:36 -040065}; // namespace android
66
Mike Lockwood16864ba2010-05-11 17:16:59 -040067#endif // _MTP_CLIENT_H