blob: 2e03c29cfd96ad6ca99199bffc414d31035acc77 [file] [log] [blame]
Mike Lockwood755fd612010-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_CURSOR_H
18#define _MTP_CURSOR_H
19
20#include "MtpTypes.h"
21
22namespace android {
23
24class CursorWindow;
25
26class MtpCursor {
27private:
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 Lockwoodba765542010-09-23 14:01:11 -040039 MtpClient* mClient;
40 int mQueryType;
41 int mDeviceID;
42 MtpStorageID mStorageID;
43 MtpObjectHandle mQbjectID;
44 int mColumnCount;
45 int* mColumns;
Mike Lockwood755fd612010-05-25 19:08:48 -040046
47public:
48 MtpCursor(MtpClient* client, int queryType, int deviceID,
Mike Lockwoodba765542010-09-23 14:01:11 -040049 MtpStorageID storageID, MtpObjectHandle objectID,
50 int columnCount, int* columns);
Mike Lockwood755fd612010-05-25 19:08:48 -040051 virtual ~MtpCursor();
52
53 int fillWindow(CursorWindow* window, int startPos);
54
55private:
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 Lockwoode11eba32010-09-28 09:14:50 -040070 bool putLong(CursorWindow* window, int64_t value, int row, int column);
Mike Lockwood755fd612010-05-25 19:08:48 -040071 bool putString(CursorWindow* window, const char* text, int row, int column);
Mike Lockwoodba765542010-09-23 14:01:11 -040072 bool putThumbnail(CursorWindow* window, MtpObjectHandle objectID,
73 MtpObjectFormat format, int row, int column);
Mike Lockwood755fd612010-05-25 19:08:48 -040074};
75
76}; // namespace android
77
78#endif // _MTP_CURSOR_H