blob: 76d9648358f2f901a91df1c7fb1cd7177415d638 [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;
Mike Lockwoode13401b2010-05-19 15:12:14 -040028class MtpObjectInfo;
Mike Lockwood335dd2b2010-05-19 10:33:39 -040029class MtpStorageInfo;
30
Mike Lockwood16864ba2010-05-11 17:16:59 -040031class MtpClient {
32private:
Mike Lockwoode13401b2010-05-19 15:12:14 -040033 struct usb_endpoint* mEndpointIn;
34 struct usb_endpoint* mEndpointOut;
35 struct usb_endpoint* mEndpointIntr;
Mike Lockwood16864ba2010-05-11 17:16:59 -040036
37 // current session ID
Mike Lockwoode13401b2010-05-19 15:12:14 -040038 MtpSessionID mSessionID;
Mike Lockwood16864ba2010-05-11 17:16:59 -040039 // current transaction ID
Mike Lockwoode13401b2010-05-19 15:12:14 -040040 MtpTransactionID mTransactionID;
Mike Lockwood16864ba2010-05-11 17:16:59 -040041
Mike Lockwoode13401b2010-05-19 15:12:14 -040042 MtpRequestPacket mRequest;
43 MtpDataPacket mData;
44 MtpResponsePacket mResponse;
Mike Lockwood16864ba2010-05-11 17:16:59 -040045
46public:
Mike Lockwoode13401b2010-05-19 15:12:14 -040047 MtpClient(struct usb_endpoint *ep_in, struct usb_endpoint *ep_out,
Mike Lockwood16864ba2010-05-11 17:16:59 -040048 struct usb_endpoint *ep_intr);
Mike Lockwoode13401b2010-05-19 15:12:14 -040049 virtual ~MtpClient();
Mike Lockwood16864ba2010-05-11 17:16:59 -040050
Mike Lockwoode13401b2010-05-19 15:12:14 -040051 bool openSession();
52 bool closeSession();
Mike Lockwood16864ba2010-05-11 17:16:59 -040053
Mike Lockwoode13401b2010-05-19 15:12:14 -040054 MtpDeviceInfo* getDeviceInfo();
55 MtpStorageIDList* getStorageIDs();
56 MtpStorageInfo* getStorageInfo(MtpStorageID storageID);
57 MtpObjectHandleList* getObjectHandles(MtpStorageID storageID, MtpObjectFormat format, MtpObjectHandle parent);
58 MtpObjectInfo* getObjectInfo(MtpObjectHandle handle);
Mike Lockwood335dd2b2010-05-19 10:33:39 -040059
Mike Lockwood16864ba2010-05-11 17:16:59 -040060private:
Mike Lockwoode13401b2010-05-19 15:12:14 -040061 bool sendRequest(MtpOperationCode operation);
62 bool sendData(MtpOperationCode operation);
63 bool readData();
64 MtpResponseCode readResponse();
Mike Lockwood16864ba2010-05-11 17:16:59 -040065
66};
67
Mike Lockwood7850ef92010-05-14 10:10:36 -040068}; // namespace android
69
Mike Lockwood16864ba2010-05-11 17:16:59 -040070#endif // _MTP_CLIENT_H