1 /* 2 * Copyright (C) 2024 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_H 17 #define RINGTONE_RESTORE_H 18 19 #include "rdb_helper.h" 20 #include "result_set.h" 21 #include "ringtone_metadata.h" 22 #include "ringtone_restore_base.h" 23 24 namespace OHOS { 25 namespace Media { 26 class RingtoneRestore final : public RingtoneRestoreBase { 27 public: 28 RingtoneRestore() = default; 29 virtual ~RingtoneRestore() = default; 30 int32_t Init(const std::string &backupPath) override; 31 int32_t StartRestore() override; 32 protected: 33 virtual bool OnPrepare(FileInfo &info, const std::string &destPath) override; 34 virtual void OnFinished(std::vector<FileInfo> &infos) override; 35 private: 36 void CheckRestoreFileInfos(std::vector<FileInfo> &infos); 37 std::vector<FileInfo> QueryFileInfos(int32_t offset); 38 std::vector<FileInfo> ConvertToFileInfos(std::vector<std::shared_ptr<RingtoneMetadata>> &metaDatas); 39 void UpdateRestoreFileInfo(FileInfo &info); 40 private: 41 std::shared_ptr<NativeRdb::RdbStore> restoreRdb_ = nullptr; 42 std::string backupPath_ = {}; 43 std::string dbPath_ = {}; 44 }; 45 } // namespace Media 46 } // namespace OHOS 47 48 #endif // RINGTONE_RESTORE_H 49