blob: 51d5fb136d251aab6d7d0419f7aae7f6608f56eb [file] [log] [blame]
Mike Lockwood56118b52010-05-11 17:16:59 -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_DATABASE_H
18#define _MTP_DATABASE_H
19
Mike Lockwood5bae7f62010-05-19 10:33:39 -040020#include "MtpTypes.h"
Mike Lockwood56118b52010-05-11 17:16:59 -040021#include "SqliteDatabase.h"
Mike Lockwood56118b52010-05-11 17:16:59 -040022
Mike Lockwood8d3257a2010-05-14 10:10:36 -040023namespace android {
24
Mike Lockwood56118b52010-05-11 17:16:59 -040025class MtpDataPacket;
26class SqliteStatement;
27
28class MtpDatabase : public SqliteDatabase {
29private:
30 SqliteStatement* mFileIdQuery;
31 SqliteStatement* mFilePathQuery;
32 SqliteStatement* mObjectInfoQuery;
33 SqliteStatement* mFileInserter;
34 SqliteStatement* mFileDeleter;
Mike Lockwoodd0782672010-05-14 15:35:17 -040035 SqliteStatement* mAudioInserter;
36 SqliteStatement* mAudioDeleter;
Mike Lockwood56118b52010-05-11 17:16:59 -040037
38public:
39 MtpDatabase();
40 virtual ~MtpDatabase();
41
Mike Lockwoodd0782672010-05-14 15:35:17 -040042 static uint32_t getTableForFile(MtpObjectFormat format);
43
Mike Lockwood56118b52010-05-11 17:16:59 -040044 bool open(const char* path, bool create);
Mike Lockwoodd0782672010-05-14 15:35:17 -040045 MtpObjectHandle getObjectHandle(const char* path);
Mike Lockwood56118b52010-05-11 17:16:59 -040046 MtpObjectHandle addFile(const char* path,
47 MtpObjectFormat format,
48 MtpObjectHandle parent,
49 MtpStorageID storage,
50 uint64_t size,
Mike Lockwood56118b52010-05-11 17:16:59 -040051 time_t modified);
52
Mike Lockwoodd0782672010-05-14 15:35:17 -040053 MtpObjectHandle addAudioFile(MtpObjectHandle id);
54
55 MtpObjectHandle addAudioFile(MtpObjectHandle id,
56 const char* title,
57 const char* artist,
58 const char* album,
59 const char* albumArtist,
60 const char* genre,
61 const char* composer,
62 const char* mimeType,
63 int track,
64 int year,
65 int duration);
66
Mike Lockwood56118b52010-05-11 17:16:59 -040067 MtpObjectHandleList* getObjectList(MtpStorageID storageID,
68 MtpObjectFormat format,
69 MtpObjectHandle parent);
70
71 MtpResponseCode getObjectProperty(MtpObjectHandle handle,
72 MtpObjectProperty property,
73 MtpDataPacket& packet);
74
75 MtpResponseCode getObjectInfo(MtpObjectHandle handle,
76 MtpDataPacket& packet);
77
78 bool getObjectFilePath(MtpObjectHandle handle,
79 MtpString& filePath,
80 int64_t& fileLength);
81 bool deleteFile(MtpObjectHandle handle);
Mike Lockwoodd0782672010-05-14 15:35:17 -040082
83 // helper for media scanner
84 MtpObjectHandle* getFileList(int& outCount);
Mike Lockwood56118b52010-05-11 17:16:59 -040085};
86
Mike Lockwood8d3257a2010-05-14 10:10:36 -040087}; // namespace android
88
Mike Lockwood56118b52010-05-11 17:16:59 -040089#endif // _MTP_DATABASE_H