blob: 8e2d979df4ac1088cb14c23aab3c24bf53d3b503 [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"
23#include "mtp.h"
24
25#include "MtpUtils.h"
26
Mike Lockwood7850ef92010-05-14 10:10:36 -040027namespace android {
28
Mike Lockwood16864ba2010-05-11 17:16:59 -040029class MtpClient {
30private:
31 struct usb_endpoint *mEndpointIn;
32 struct usb_endpoint *mEndpointOut;
33 struct usb_endpoint *mEndpointIntr;
34
35 // current session ID
36 MtpSessionID mSessionID;
37 // current transaction ID
38 MtpTransactionID mTransactionID;
39
40 MtpRequestPacket mRequest;
41 MtpDataPacket mData;
42 MtpResponsePacket mResponse;
43
44public:
45 MtpClient(struct usb_endpoint *ep_in, struct usb_endpoint *ep_out,
46 struct usb_endpoint *ep_intr);
47 virtual ~MtpClient();
48
49 bool openSession();
50 bool getDeviceInfo();
51 bool closeSession();
52
53private:
54 bool sendRequest(MtpOperationCode operation);
55 bool sendData(MtpOperationCode operation);
56 bool readData();
57 MtpResponseCode readResponse();
58
59};
60
Mike Lockwood7850ef92010-05-14 10:10:36 -040061}; // namespace android
62
Mike Lockwood16864ba2010-05-11 17:16:59 -040063#endif // _MTP_CLIENT_H