Mike Lockwood | 755fd61 | 2010-05-25 19:08:48 -0400 | [diff] [blame] | 1 | /* |
| 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_CURSOR_H |
| 18 | #define _MTP_CURSOR_H |
| 19 | |
| 20 | #include "MtpTypes.h" |
| 21 | |
| 22 | namespace android { |
| 23 | |
| 24 | class CursorWindow; |
| 25 | |
| 26 | class MtpCursor { |
| 27 | private: |
| 28 | enum { |
| 29 | DEVICE = 1, |
| 30 | DEVICE_ID = 2, |
| 31 | STORAGE = 3, |
| 32 | STORAGE_ID = 4, |
| 33 | OBJECT = 5, |
| 34 | OBJECT_ID = 6, |
| 35 | STORAGE_CHILDREN = 7, |
| 36 | OBJECT_CHILDREN = 8, |
| 37 | }; |
| 38 | |
Mike Lockwood | ba76554 | 2010-09-23 14:01:11 -0400 | [diff] [blame] | 39 | MtpClient* mClient; |
| 40 | int mQueryType; |
| 41 | int mDeviceID; |
| 42 | MtpStorageID mStorageID; |
| 43 | MtpObjectHandle mQbjectID; |
| 44 | int mColumnCount; |
| 45 | int* mColumns; |
Mike Lockwood | 755fd61 | 2010-05-25 19:08:48 -0400 | [diff] [blame] | 46 | |
| 47 | public: |
| 48 | MtpCursor(MtpClient* client, int queryType, int deviceID, |
Mike Lockwood | ba76554 | 2010-09-23 14:01:11 -0400 | [diff] [blame] | 49 | MtpStorageID storageID, MtpObjectHandle objectID, |
| 50 | int columnCount, int* columns); |
Mike Lockwood | 755fd61 | 2010-05-25 19:08:48 -0400 | [diff] [blame] | 51 | virtual ~MtpCursor(); |
| 52 | |
| 53 | int fillWindow(CursorWindow* window, int startPos); |
| 54 | |
| 55 | private: |
| 56 | int fillDevices(CursorWindow* window, int startPos); |
| 57 | int fillDevice(CursorWindow* window, int startPos); |
| 58 | int fillStorages(CursorWindow* window, int startPos); |
| 59 | int fillStorage(CursorWindow* window, int startPos); |
| 60 | int fillObjects(CursorWindow* window, int parent, int startPos); |
| 61 | int fillObject(CursorWindow* window, int startPos); |
| 62 | |
| 63 | bool fillDevice(CursorWindow* window, MtpDevice* device, int startPos); |
| 64 | bool fillStorage(CursorWindow* window, MtpDevice* device, |
| 65 | MtpStorageID storageID, int row); |
| 66 | bool fillObject(CursorWindow* window, MtpDevice* device, |
| 67 | MtpObjectHandle objectID, int row); |
| 68 | |
| 69 | bool prepareRow(CursorWindow* window); |
Mike Lockwood | e11eba3 | 2010-09-28 09:14:50 -0400 | [diff] [blame] | 70 | bool putLong(CursorWindow* window, int64_t value, int row, int column); |
Mike Lockwood | 755fd61 | 2010-05-25 19:08:48 -0400 | [diff] [blame] | 71 | bool putString(CursorWindow* window, const char* text, int row, int column); |
Mike Lockwood | ba76554 | 2010-09-23 14:01:11 -0400 | [diff] [blame] | 72 | bool putThumbnail(CursorWindow* window, MtpObjectHandle objectID, |
| 73 | MtpObjectFormat format, int row, int column); |
Mike Lockwood | 755fd61 | 2010-05-25 19:08:48 -0400 | [diff] [blame] | 74 | }; |
| 75 | |
| 76 | }; // namespace android |
| 77 | |
| 78 | #endif // _MTP_CURSOR_H |