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; |
| 38 | SqliteStatement* mAudioInserter; |
| 39 | SqliteStatement* mAudioDeleter; |
| 40 | |
| 41 | public: |
| 42 | MtpSqliteDatabase(); |
| 43 | virtual ~MtpSqliteDatabase(); |
| 44 | |
| 45 | bool open(const char* path, bool create); |
| 46 | void close(); |
| 47 | |
| 48 | virtual MtpObjectHandle getObjectHandle(const char* path); |
| 49 | virtual MtpObjectHandle addFile(const char* path, |
| 50 | MtpObjectFormat format, |
| 51 | MtpObjectHandle parent, |
| 52 | MtpStorageID storage, |
| 53 | uint64_t size, |
| 54 | time_t modified); |
| 55 | |
| 56 | virtual MtpObjectHandle addAudioFile(MtpObjectHandle id); |
| 57 | |
| 58 | virtual MtpObjectHandle addAudioFile(MtpObjectHandle id, |
| 59 | const char* title, |
| 60 | const char* artist, |
| 61 | const char* album, |
| 62 | const char* albumArtist, |
| 63 | const char* genre, |
| 64 | const char* composer, |
| 65 | const char* mimeType, |
| 66 | int track, |
| 67 | int year, |
| 68 | int duration); |
| 69 | |
| 70 | virtual MtpObjectHandleList* getObjectList(MtpStorageID storageID, |
| 71 | MtpObjectFormat format, |
| 72 | MtpObjectHandle parent); |
| 73 | |
| 74 | virtual MtpResponseCode getObjectProperty(MtpObjectHandle handle, |
| 75 | MtpObjectProperty property, |
| 76 | MtpDataPacket& packet); |
| 77 | |
| 78 | virtual MtpResponseCode getObjectInfo(MtpObjectHandle handle, |
| 79 | MtpDataPacket& packet); |
| 80 | |
| 81 | virtual bool getObjectFilePath(MtpObjectHandle handle, |
| 82 | MtpString& filePath, |
| 83 | int64_t& fileLength); |
| 84 | virtual bool deleteFile(MtpObjectHandle handle); |
| 85 | |
| 86 | // helper for media scanner |
| 87 | virtual MtpObjectHandle* getFileList(int& outCount); |
| 88 | |
| 89 | virtual void beginTransaction(); |
| 90 | virtual void commitTransaction(); |
| 91 | virtual void rollbackTransaction(); |
| 92 | }; |
| 93 | |
| 94 | }; // namespace android |
| 95 | |
| 96 | #endif // _MTP_SQLITE_DATABASE_H |