blob: f7f33ffb5d5ade105565320f1595734af5d00f3a [file] [log] [blame]
bigbiff bigbiffaf32bb92018-12-18 18:39:53 -05001/*
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 * Copyright (C) 2014 TeamWin - bigbiff and Dees_Troy mtp database conversion to c++
17 */
18
19#ifndef _MTP_DATABASE_H
20#define _MTP_DATABASE_H
21
22#include "MtpTypes.h"
23
24class MtpDataPacket;
25class MtpProperty;
26class MtpObjectInfo;
27
28class MtpDatabase {
29public:
30 virtual ~MtpDatabase() {}
31
32 // called from SendObjectInfo to reserve a database entry for the incoming file
33 virtual MtpObjectHandle beginSendObject(const char* path,
34 MtpObjectFormat format,
35 MtpObjectHandle parent,
36 MtpStorageID storage,
37 uint64_t size,
38 time_t modified) = 0;
39
40 // called to report success or failure of the SendObject file transfer
41 // success should signal a notification of the new object's creation,
42 // failure should remove the database entry created in beginSendObject
43 virtual void endSendObject(const char* path,
44 MtpObjectHandle handle,
45 MtpObjectFormat format,
46 bool succeeded) = 0;
47
48 virtual MtpObjectHandleList* getObjectList(MtpStorageID storageID,
49 MtpObjectFormat format,
50 MtpObjectHandle parent) = 0;
51
52 virtual int getNumObjects(MtpStorageID storageID,
53 MtpObjectFormat format,
54 MtpObjectHandle parent) = 0;
55
56 // callee should delete[] the results from these
57 // results can be NULL
58 virtual MtpObjectFormatList* getSupportedPlaybackFormats() = 0;
59 virtual MtpObjectFormatList* getSupportedCaptureFormats() = 0;
60 virtual MtpObjectPropertyList* getSupportedObjectProperties(MtpObjectFormat format) = 0;
61 virtual MtpDevicePropertyList* getSupportedDeviceProperties() = 0;
62
63 virtual void createDB(MtpStorage* storage, MtpStorageID storageID) = 0;
64 virtual void destroyDB(MtpStorageID storageID) = 0;
65
66 virtual MtpResponseCode getObjectPropertyValue(MtpObjectHandle handle,
67 MtpObjectProperty property,
68 MtpDataPacket& packet) = 0;
69
70 virtual MtpResponseCode setObjectPropertyValue(MtpObjectHandle handle,
71 MtpObjectProperty property,
72 MtpDataPacket& packet) = 0;
73
74 virtual MtpResponseCode getDevicePropertyValue(MtpDeviceProperty property,
75 MtpDataPacket& packet) = 0;
76
77 virtual MtpResponseCode setDevicePropertyValue(MtpDeviceProperty property,
78 MtpDataPacket& packet) = 0;
79
80 virtual MtpResponseCode resetDeviceProperty(MtpDeviceProperty property) = 0;
81
82 virtual MtpResponseCode getObjectPropertyList(MtpObjectHandle handle,
83 uint32_t format, uint32_t property,
84 int groupCode, int depth,
85 MtpDataPacket& packet) = 0;
86
87 virtual MtpResponseCode getObjectInfo(MtpObjectHandle handle,
88 MtpObjectInfo& info) = 0;
89
90 virtual void* getThumbnail(MtpObjectHandle handle, size_t& outThumbSize) = 0;
91
92 virtual MtpResponseCode getObjectFilePath(MtpObjectHandle handle,
93 MtpString& outFilePath,
94 int64_t& outFileLength,
95 MtpObjectFormat& outFormat) = 0;
96
97 virtual MtpResponseCode deleteFile(MtpObjectHandle handle) = 0;
98
99 virtual MtpObjectHandleList* getObjectReferences(MtpObjectHandle handle) = 0;
100
101 virtual MtpResponseCode setObjectReferences(MtpObjectHandle handle,
102 MtpObjectHandleList* references) = 0;
103
104 virtual MtpProperty* getObjectPropertyDesc(MtpObjectProperty property,
105 MtpObjectFormat format) = 0;
106
107 virtual MtpProperty* getDevicePropertyDesc(MtpDeviceProperty property) = 0;
108
109 virtual void sessionStarted() = 0;
110
111 virtual void sessionEnded() = 0;
112 virtual void lockMutex() = 0;
113 virtual void unlockMutex() = 0;
114};
115
116#endif // _MTP_DATABASE_H