MtpDatabase.h revision 0250361b110267a139cc0865ff7d2f13b4d63bdf
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_DATABASE_H
18#define _MTP_DATABASE_H
19
20#include "MtpTypes.h"
21#include "SqliteDatabase.h"
22
23namespace android {
24
25class MtpDataPacket;
26
27class MtpDatabase {
28public:
29    virtual ~MtpDatabase();
30
31    static uint32_t                 getTableForFile(MtpObjectFormat format);
32
33    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,
56                                    MtpObjectFormat format,
57                                    MtpObjectHandle parent) = 0;
58
59    virtual MtpResponseCode         getObjectProperty(MtpObjectHandle handle,
60                                            MtpObjectProperty property,
61                                            MtpDataPacket& packet) = 0;
62
63    virtual MtpResponseCode         getObjectInfo(MtpObjectHandle handle,
64                                            MtpDataPacket& packet) = 0;
65
66    virtual bool                    getObjectFilePath(MtpObjectHandle handle,
67                                            MtpString& filePath,
68                                            int64_t& fileLength) = 0;
69    virtual bool                    deleteFile(MtpObjectHandle handle) = 0;
70
71    // helper for media scanner
72    virtual MtpObjectHandle*        getFileList(int& outCount) = 0;
73
74    virtual void                    beginTransaction() = 0;
75    virtual void                    commitTransaction() = 0;
76    virtual void                    rollbackTransaction() = 0;
77};
78
79}; // namespace android
80
81#endif // _MTP_DATABASE_H
82