1 /*
2  * Copyright (C) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef RINGTONE_RESTORE_DATABASE_UTILS_H
17 #define RINGTONE_RESTORE_DATABASE_UTILS_H
18 
19 #include <string>
20 
21 #include "rdb_helper.h"
22 #include "result_set.h"
23 
24 namespace OHOS {
25 namespace Media {
26 class RingtoneRestoreDbUtils {
27 public:
28     static int32_t InitDb(std::shared_ptr<NativeRdb::RdbStore> &rdbStore, const std::string &dbName,
29         const std::string &dbPath, const std::string &bundleName, bool isMediaLibary);
30     static int32_t QueryInt(std::shared_ptr<NativeRdb::RdbStore> rdbStore, const std::string &sql,
31         const std::string &column);
32     static int32_t Update(std::shared_ptr<NativeRdb::RdbStore> &rdbStore, int32_t &changeRows,
33         NativeRdb::ValuesBucket &valuesBucket, std::unique_ptr<NativeRdb::AbsRdbPredicates> &predicates);
34     static int32_t QueryRingtoneCount(std::shared_ptr<NativeRdb::RdbStore> rdbStore);
35     static std::shared_ptr<NativeRdb::ResultSet> GetQueryResultSet(const std::shared_ptr<NativeRdb::RdbStore> &rdbStore,
36         const std::string &querySql);
37     static std::unordered_map<std::string, std::string> GetColumnInfoMap(
38         const std::shared_ptr<NativeRdb::RdbStore> &rdbStore, const std::string &tableName);
39     static bool GetUserID(int &userId);
40 };
41 
42 } // namespace Media
43 } // namespace OHOS
44 
45 #endif  // RINGTONE_RESTORE_DATABASE_UTILS_H
46