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_DATABASE_H 18 #define _MTP_DATABASE_H 19 20 #include "MtpTypes.h" 21 22 namespace android { 23 24 class MtpDataPacket; 25 class MtpProperty; 26 class MtpObjectInfo; 27 28 class MtpDatabase { 29 public: ~MtpDatabase()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 MtpResponseCode getObjectPropertyValue(MtpObjectHandle handle, 64 MtpObjectProperty property, 65 MtpDataPacket& packet) = 0; 66 67 virtual MtpResponseCode setObjectPropertyValue(MtpObjectHandle handle, 68 MtpObjectProperty property, 69 MtpDataPacket& packet) = 0; 70 71 virtual MtpResponseCode getDevicePropertyValue(MtpDeviceProperty property, 72 MtpDataPacket& packet) = 0; 73 74 virtual MtpResponseCode setDevicePropertyValue(MtpDeviceProperty property, 75 MtpDataPacket& packet) = 0; 76 77 virtual MtpResponseCode resetDeviceProperty(MtpDeviceProperty property) = 0; 78 79 virtual MtpResponseCode getObjectPropertyList(MtpObjectHandle handle, 80 uint32_t format, uint32_t property, 81 int groupCode, int depth, 82 MtpDataPacket& packet) = 0; 83 84 virtual MtpResponseCode getObjectInfo(MtpObjectHandle handle, 85 MtpObjectInfo& info) = 0; 86 87 virtual void* getThumbnail(MtpObjectHandle handle, size_t& outThumbSize) = 0; 88 89 virtual MtpResponseCode getObjectFilePath(MtpObjectHandle handle, 90 MtpString& outFilePath, 91 int64_t& outFileLength, 92 MtpObjectFormat& outFormat) = 0; 93 94 virtual MtpResponseCode deleteFile(MtpObjectHandle handle) = 0; 95 96 virtual MtpObjectHandleList* getObjectReferences(MtpObjectHandle handle) = 0; 97 98 virtual MtpResponseCode setObjectReferences(MtpObjectHandle handle, 99 MtpObjectHandleList* references) = 0; 100 101 virtual MtpProperty* getObjectPropertyDesc(MtpObjectProperty property, 102 MtpObjectFormat format) = 0; 103 104 virtual MtpProperty* getDevicePropertyDesc(MtpDeviceProperty property) = 0; 105 106 virtual void sessionStarted() = 0; 107 108 virtual void sessionEnded() = 0; 109 }; 110 111 }; // namespace android 112 113 #endif // _MTP_DATABASE_H 114