Mike Lockwood | 16864ba | 2010-05-11 17:16:59 -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_DATABASE_H |
| 18 | #define _MTP_DATABASE_H |
| 19 | |
Mike Lockwood | 335dd2b | 2010-05-19 10:33:39 -0400 | [diff] [blame] | 20 | #include "MtpTypes.h" |
Mike Lockwood | 16864ba | 2010-05-11 17:16:59 -0400 | [diff] [blame] | 21 | |
Mike Lockwood | 7850ef9 | 2010-05-14 10:10:36 -0400 | [diff] [blame] | 22 | namespace android { |
| 23 | |
Mike Lockwood | 16864ba | 2010-05-11 17:16:59 -0400 | [diff] [blame] | 24 | class MtpDataPacket; |
Mike Lockwood | 8277cec | 2010-08-10 15:20:35 -0400 | [diff] [blame] | 25 | class MtpProperty; |
Mike Lockwood | 16864ba | 2010-05-11 17:16:59 -0400 | [diff] [blame] | 26 | |
Mike Lockwood | 0250361 | 2010-07-02 14:03:31 -0400 | [diff] [blame] | 27 | class MtpDatabase { |
Mike Lockwood | 16864ba | 2010-05-11 17:16:59 -0400 | [diff] [blame] | 28 | public: |
Mike Lockwood | dda7e2b | 2010-07-03 14:40:05 -0400 | [diff] [blame] | 29 | virtual ~MtpDatabase() {} |
Mike Lockwood | fceef46 | 2010-05-14 15:35:17 -0400 | [diff] [blame] | 30 | |
Mike Lockwood | 4714b07 | 2010-07-12 08:49:01 -0400 | [diff] [blame] | 31 | // called from SendObjectInfo to reserve a database entry for the incoming file |
| 32 | virtual MtpObjectHandle beginSendObject(const char* path, |
Mike Lockwood | 0250361 | 2010-07-02 14:03:31 -0400 | [diff] [blame] | 33 | MtpObjectFormat format, |
| 34 | MtpObjectHandle parent, |
| 35 | MtpStorageID storage, |
| 36 | uint64_t size, |
| 37 | time_t modified) = 0; |
| 38 | |
Mike Lockwood | 4714b07 | 2010-07-12 08:49:01 -0400 | [diff] [blame] | 39 | // called to report success or failure of the SendObject file transfer |
| 40 | // success should signal a notification of the new object's creation, |
| 41 | // failure should remove the database entry created in beginSendObject |
| 42 | virtual void endSendObject(const char* path, |
| 43 | MtpObjectHandle handle, |
| 44 | MtpObjectFormat format, |
| 45 | bool succeeded) = 0; |
| 46 | |
Mike Lockwood | 0250361 | 2010-07-02 14:03:31 -0400 | [diff] [blame] | 47 | virtual MtpObjectHandleList* getObjectList(MtpStorageID storageID, |
Mike Lockwood | 4714b07 | 2010-07-12 08:49:01 -0400 | [diff] [blame] | 48 | MtpObjectFormat format, |
| 49 | MtpObjectHandle parent) = 0; |
Mike Lockwood | 16864ba | 2010-05-11 17:16:59 -0400 | [diff] [blame] | 50 | |
Mike Lockwood | 343af4e | 2010-08-02 10:52:20 -0400 | [diff] [blame] | 51 | virtual int getNumObjects(MtpStorageID storageID, |
| 52 | MtpObjectFormat format, |
| 53 | MtpObjectHandle parent) = 0; |
| 54 | |
Mike Lockwood | 782aef1 | 2010-08-10 07:37:50 -0400 | [diff] [blame] | 55 | // callee should delete[] the results from these |
| 56 | // results can be NULL |
| 57 | virtual MtpObjectFormatList* getSupportedPlaybackFormats() = 0; |
| 58 | virtual MtpObjectFormatList* getSupportedCaptureFormats() = 0; |
| 59 | virtual MtpObjectPropertyList* getSupportedObjectProperties(MtpObjectFormat format) = 0; |
| 60 | virtual MtpDevicePropertyList* getSupportedDeviceProperties() = 0; |
| 61 | |
Mike Lockwood | 8277cec | 2010-08-10 15:20:35 -0400 | [diff] [blame] | 62 | virtual MtpResponseCode getObjectPropertyValue(MtpObjectHandle handle, |
Mike Lockwood | 0250361 | 2010-07-02 14:03:31 -0400 | [diff] [blame] | 63 | MtpObjectProperty property, |
| 64 | MtpDataPacket& packet) = 0; |
Mike Lockwood | fceef46 | 2010-05-14 15:35:17 -0400 | [diff] [blame] | 65 | |
Mike Lockwood | 8277cec | 2010-08-10 15:20:35 -0400 | [diff] [blame] | 66 | virtual MtpResponseCode setObjectPropertyValue(MtpObjectHandle handle, |
| 67 | MtpObjectProperty property, |
| 68 | MtpDataPacket& packet) = 0; |
| 69 | |
| 70 | virtual MtpResponseCode getDevicePropertyValue(MtpDeviceProperty property, |
| 71 | MtpDataPacket& packet) = 0; |
| 72 | |
| 73 | virtual MtpResponseCode setDevicePropertyValue(MtpDeviceProperty property, |
| 74 | MtpDataPacket& packet) = 0; |
| 75 | |
| 76 | virtual MtpResponseCode resetDeviceProperty(MtpDeviceProperty property) = 0; |
| 77 | |
Mike Lockwood | 0250361 | 2010-07-02 14:03:31 -0400 | [diff] [blame] | 78 | virtual MtpResponseCode getObjectInfo(MtpObjectHandle handle, |
| 79 | MtpDataPacket& packet) = 0; |
Mike Lockwood | fceef46 | 2010-05-14 15:35:17 -0400 | [diff] [blame] | 80 | |
Mike Lockwood | 9c04c4c | 2010-08-02 10:37:41 -0400 | [diff] [blame] | 81 | virtual MtpResponseCode getObjectFilePath(MtpObjectHandle handle, |
Mike Lockwood | 0250361 | 2010-07-02 14:03:31 -0400 | [diff] [blame] | 82 | MtpString& filePath, |
| 83 | int64_t& fileLength) = 0; |
Mike Lockwood | 438344f | 2010-08-03 15:30:09 -0400 | [diff] [blame] | 84 | |
Mike Lockwood | 9c04c4c | 2010-08-02 10:37:41 -0400 | [diff] [blame] | 85 | virtual MtpResponseCode deleteFile(MtpObjectHandle handle) = 0; |
Mike Lockwood | 438344f | 2010-08-03 15:30:09 -0400 | [diff] [blame] | 86 | |
| 87 | virtual MtpObjectHandleList* getObjectReferences(MtpObjectHandle handle) = 0; |
| 88 | |
| 89 | virtual MtpResponseCode setObjectReferences(MtpObjectHandle handle, |
| 90 | MtpObjectHandleList* references) = 0; |
| 91 | |
Mike Lockwood | 8277cec | 2010-08-10 15:20:35 -0400 | [diff] [blame] | 92 | virtual MtpProperty* getObjectPropertyDesc(MtpObjectProperty property, |
| 93 | MtpObjectFormat format) = 0; |
| 94 | |
| 95 | virtual MtpProperty* getDevicePropertyDesc(MtpDeviceProperty property) = 0; |
Mike Lockwood | 6b3a9d1 | 2010-08-31 16:25:12 -0400 | [diff] [blame^] | 96 | |
| 97 | virtual void sessionStarted() = 0; |
| 98 | |
| 99 | virtual void sessionEnded() = 0; |
Mike Lockwood | 16864ba | 2010-05-11 17:16:59 -0400 | [diff] [blame] | 100 | }; |
| 101 | |
Mike Lockwood | 7850ef9 | 2010-05-14 10:10:36 -0400 | [diff] [blame] | 102 | }; // namespace android |
| 103 | |
Mike Lockwood | 16864ba | 2010-05-11 17:16:59 -0400 | [diff] [blame] | 104 | #endif // _MTP_DATABASE_H |