blob: 14ed281a5d028bec94c7ea7535f87344d9643fbc [file] [log] [blame]
Mike Lockwood02503612010-07-02 14:03:31 -04001/*
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
23class SqliteDatabase;
24
25namespace android {
26
27class MtpDataPacket;
28class SqliteStatement;
29
30class MtpSqliteDatabase : public MtpDatabase {
31private:
32 SqliteDatabase* mDatabase;
33 SqliteStatement* mFileIdQuery;
34 SqliteStatement* mFilePathQuery;
35 SqliteStatement* mObjectInfoQuery;
36 SqliteStatement* mFileInserter;
37 SqliteStatement* mFileDeleter;
Mike Lockwood02503612010-07-02 14:03:31 -040038
39public:
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 Lockwood02503612010-07-02 14:03:31 -040054 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