blob: 0c70d9fe6b7903d0360db9266723546d65ab0aa8 [file] [log] [blame]
Mike Lockwood16864ba2010-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 Lockwood335dd2b2010-05-19 10:33:39 -040020#include "MtpTypes.h"
Mike Lockwood16864ba2010-05-11 17:16:59 -040021#include "SqliteDatabase.h"
Mike Lockwood16864ba2010-05-11 17:16:59 -040022
Mike Lockwood7850ef92010-05-14 10:10:36 -040023namespace android {
24
Mike Lockwood16864ba2010-05-11 17:16:59 -040025class MtpDataPacket;
Mike Lockwood16864ba2010-05-11 17:16:59 -040026
Mike Lockwood02503612010-07-02 14:03:31 -040027class MtpDatabase {
Mike Lockwood16864ba2010-05-11 17:16:59 -040028public:
Mike Lockwood02503612010-07-02 14:03:31 -040029 virtual ~MtpDatabase();
Mike Lockwood16864ba2010-05-11 17:16:59 -040030
Mike Lockwood02503612010-07-02 14:03:31 -040031 static uint32_t getTableForFile(MtpObjectFormat format);
Mike Lockwoodfceef462010-05-14 15:35:17 -040032
Mike Lockwood02503612010-07-02 14:03:31 -040033 virtual MtpObjectHandle getObjectHandle(const char* path) = 0;
34 virtual MtpObjectHandle addFile(const char* path,
35 MtpObjectFormat format,
36 MtpObjectHandle parent,
37 MtpStorageID storage,
38 uint64_t size,
39 time_t modified) = 0;
40
41 virtual MtpObjectHandle addAudioFile(MtpObjectHandle id) = 0;
42
43 virtual MtpObjectHandle addAudioFile(MtpObjectHandle id,
44 const char* title,
45 const char* artist,
46 const char* album,
47 const char* albumArtist,
48 const char* genre,
49 const char* composer,
50 const char* mimeType,
51 int track,
52 int year,
53 int duration) = 0;
54
55 virtual MtpObjectHandleList* getObjectList(MtpStorageID storageID,
Mike Lockwood16864ba2010-05-11 17:16:59 -040056 MtpObjectFormat format,
Mike Lockwood02503612010-07-02 14:03:31 -040057 MtpObjectHandle parent) = 0;
Mike Lockwood16864ba2010-05-11 17:16:59 -040058
Mike Lockwood02503612010-07-02 14:03:31 -040059 virtual MtpResponseCode getObjectProperty(MtpObjectHandle handle,
60 MtpObjectProperty property,
61 MtpDataPacket& packet) = 0;
Mike Lockwoodfceef462010-05-14 15:35:17 -040062
Mike Lockwood02503612010-07-02 14:03:31 -040063 virtual MtpResponseCode getObjectInfo(MtpObjectHandle handle,
64 MtpDataPacket& packet) = 0;
Mike Lockwoodfceef462010-05-14 15:35:17 -040065
Mike Lockwood02503612010-07-02 14:03:31 -040066 virtual bool getObjectFilePath(MtpObjectHandle handle,
67 MtpString& filePath,
68 int64_t& fileLength) = 0;
69 virtual bool deleteFile(MtpObjectHandle handle) = 0;
Mike Lockwoodfceef462010-05-14 15:35:17 -040070
71 // helper for media scanner
Mike Lockwood02503612010-07-02 14:03:31 -040072 virtual MtpObjectHandle* getFileList(int& outCount) = 0;
73
74 virtual void beginTransaction() = 0;
75 virtual void commitTransaction() = 0;
76 virtual void rollbackTransaction() = 0;
Mike Lockwood16864ba2010-05-11 17:16:59 -040077};
78
Mike Lockwood7850ef92010-05-14 10:10:36 -040079}; // namespace android
80
Mike Lockwood16864ba2010-05-11 17:16:59 -040081#endif // _MTP_DATABASE_H