MtpDatabase.h revision 16864bae0f51c32c456da2c43adf7a057c0c4882
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 "MtpUtils.h"
21#include "SqliteDatabase.h"
22#include "mtp.h"
23
24class MtpDataPacket;
25class SqliteStatement;
26
27class MtpDatabase : public SqliteDatabase {
28private:
29    SqliteStatement*        mFileIdQuery;
30    SqliteStatement*        mFilePathQuery;
31    SqliteStatement*        mObjectInfoQuery;
32    SqliteStatement*        mFileInserter;
33    SqliteStatement*        mFileDeleter;
34
35public:
36                            MtpDatabase();
37    virtual                 ~MtpDatabase();
38
39    bool                    open(const char* path, bool create);
40    MtpObjectHandle         addFile(const char* path,
41                                    MtpObjectFormat format,
42                                    MtpObjectHandle parent,
43                                    MtpStorageID storage,
44                                    uint64_t size,
45                                    time_t created,
46                                    time_t modified);
47
48    MtpObjectHandleList*    getObjectList(MtpStorageID storageID,
49                                    MtpObjectFormat format,
50                                    MtpObjectHandle parent);
51
52    MtpResponseCode         getObjectProperty(MtpObjectHandle handle,
53                                    MtpObjectProperty property,
54                                    MtpDataPacket& packet);
55
56    MtpResponseCode         getObjectInfo(MtpObjectHandle handle,
57                                    MtpDataPacket& packet);
58
59    bool                    getObjectFilePath(MtpObjectHandle handle,
60                                    MtpString& filePath,
61                                    int64_t& fileLength);
62    bool                    deleteFile(MtpObjectHandle handle);
63};
64
65#endif // _MTP_DATABASE_H
66