Mike Lockwood | 0250361 | 2010-07-02 14:03:31 -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_SQLITE_DATABASE_H |
| 18 | #define _MTP_SQLITE_DATABASE_H |
| 19 | |
| 20 | #include "MtpTypes.h" |
| 21 | #include "MtpDatabase.h" |
| 22 | |
| 23 | class SqliteDatabase; |
| 24 | |
| 25 | namespace android { |
| 26 | |
| 27 | class MtpDataPacket; |
| 28 | class SqliteStatement; |
| 29 | |
| 30 | class MtpSqliteDatabase : public MtpDatabase { |
| 31 | private: |
| 32 | SqliteDatabase* mDatabase; |
| 33 | SqliteStatement* mFileIdQuery; |
| 34 | SqliteStatement* mFilePathQuery; |
| 35 | SqliteStatement* mObjectInfoQuery; |
| 36 | SqliteStatement* mFileInserter; |
| 37 | SqliteStatement* mFileDeleter; |
Mike Lockwood | 0250361 | 2010-07-02 14:03:31 -0400 | [diff] [blame] | 38 | |
| 39 | public: |
| 40 | MtpSqliteDatabase(); |
| 41 | virtual ~MtpSqliteDatabase(); |
| 42 | |
| 43 | bool open(const char* path, bool create); |
| 44 | void close(); |
| 45 | |
| 46 | virtual MtpObjectHandle getObjectHandle(const char* path); |
| 47 | virtual MtpObjectHandle addFile(const char* path, |
| 48 | MtpObjectFormat format, |
| 49 | MtpObjectHandle parent, |
| 50 | MtpStorageID storage, |
| 51 | uint64_t size, |
| 52 | time_t modified); |
| 53 | |
Mike Lockwood | 0250361 | 2010-07-02 14:03:31 -0400 | [diff] [blame] | 54 | virtual MtpObjectHandleList* getObjectList(MtpStorageID storageID, |
| 55 | MtpObjectFormat format, |
| 56 | MtpObjectHandle parent); |
| 57 | |
| 58 | virtual MtpResponseCode getObjectProperty(MtpObjectHandle handle, |
| 59 | MtpObjectProperty property, |
| 60 | MtpDataPacket& packet); |
| 61 | |
| 62 | virtual MtpResponseCode getObjectInfo(MtpObjectHandle handle, |
| 63 | MtpDataPacket& packet); |
| 64 | |
| 65 | virtual bool getObjectFilePath(MtpObjectHandle handle, |
| 66 | MtpString& filePath, |
| 67 | int64_t& fileLength); |
| 68 | virtual bool deleteFile(MtpObjectHandle handle); |
| 69 | |
| 70 | // helper for media scanner |
| 71 | virtual MtpObjectHandle* getFileList(int& outCount); |
| 72 | |
| 73 | virtual void beginTransaction(); |
| 74 | virtual void commitTransaction(); |
| 75 | virtual void rollbackTransaction(); |
| 76 | }; |
| 77 | |
| 78 | }; // namespace android |
| 79 | |
| 80 | #endif // _MTP_SQLITE_DATABASE_H |