blob: a6be6a66f14f8b3011c61d9d79be7d4824fd017d [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
20#include "MtpUtils.h"
21#include "SqliteDatabase.h"
22#include "mtp.h"
23
Mike Lockwood8d3257a2010-05-14 10:10:36 -040024namespace android {
25
Mike Lockwood56118b52010-05-11 17:16:59 -040026class MtpDataPacket;
27class SqliteStatement;
28
29class MtpDatabase : public SqliteDatabase {
30private:
31 SqliteStatement* mFileIdQuery;
32 SqliteStatement* mFilePathQuery;
33 SqliteStatement* mObjectInfoQuery;
34 SqliteStatement* mFileInserter;
35 SqliteStatement* mFileDeleter;
Mike Lockwoodd0782672010-05-14 15:35:17 -040036 SqliteStatement* mAudioInserter;
37 SqliteStatement* mAudioDeleter;
Mike Lockwood56118b52010-05-11 17:16:59 -040038
39public:
40 MtpDatabase();
41 virtual ~MtpDatabase();
42
Mike Lockwoodd0782672010-05-14 15:35:17 -040043 static uint32_t getTableForFile(MtpObjectFormat format);
44
Mike Lockwood56118b52010-05-11 17:16:59 -040045 bool open(const char* path, bool create);
Mike Lockwoodd0782672010-05-14 15:35:17 -040046 MtpObjectHandle getObjectHandle(const char* path);
Mike Lockwood56118b52010-05-11 17:16:59 -040047 MtpObjectHandle addFile(const char* path,
48 MtpObjectFormat format,
49 MtpObjectHandle parent,
50 MtpStorageID storage,
51 uint64_t size,
Mike Lockwood56118b52010-05-11 17:16:59 -040052 time_t modified);
53
Mike Lockwoodd0782672010-05-14 15:35:17 -040054 MtpObjectHandle addAudioFile(MtpObjectHandle id);
55
56 MtpObjectHandle addAudioFile(MtpObjectHandle id,
57 const char* title,
58 const char* artist,
59 const char* album,
60 const char* albumArtist,
61 const char* genre,
62 const char* composer,
63 const char* mimeType,
64 int track,
65 int year,
66 int duration);
67
Mike Lockwood56118b52010-05-11 17:16:59 -040068 MtpObjectHandleList* getObjectList(MtpStorageID storageID,
69 MtpObjectFormat format,
70 MtpObjectHandle parent);
71
72 MtpResponseCode getObjectProperty(MtpObjectHandle handle,
73 MtpObjectProperty property,
74 MtpDataPacket& packet);
75
76 MtpResponseCode getObjectInfo(MtpObjectHandle handle,
77 MtpDataPacket& packet);
78
79 bool getObjectFilePath(MtpObjectHandle handle,
80 MtpString& filePath,
81 int64_t& fileLength);
82 bool deleteFile(MtpObjectHandle handle);
Mike Lockwoodd0782672010-05-14 15:35:17 -040083
84 // helper for media scanner
85 MtpObjectHandle* getFileList(int& outCount);
Mike Lockwood56118b52010-05-11 17:16:59 -040086};
87
Mike Lockwood8d3257a2010-05-14 10:10:36 -040088}; // namespace android
89
Mike Lockwood56118b52010-05-11 17:16:59 -040090#endif // _MTP_DATABASE_H