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_CONST_H
17 #define RINGTONE_RESTORE_CONST_H
18 
19 #include <string>
20 #include <unordered_set>
21 #include <variant>
22 #include <vector>
23 
24 #include "ringtone_db_const.h"
25 #include "ringtone_type.h"
26 #include "ringtone_metadata.h"
27 
28 namespace OHOS {
29 namespace Media {
30 
31 const std::string RINGTONE_BACKUP_SUFFIX_DIR = "/storage/media/local/files/Ringtone";
32 const std::string RINGTONE_RESTORE_DIR = "/storage/media/local/files/Ringtone";
33 
34 enum RestoreSceneType : int32_t {
35     RESTORE_SCENE_TYPE_INVILID = -1,
36     RESTORE_SCENE_TYPE_DUAL_UPGRADE,
37     RESTORE_SCENE_TYPE_SINGLE_CLONE,
38     RESTORE_SCENE_TYPE_DUAL_CLONE,
39     RESTORE_SCENE_TYPE_MAX,
40 };
41 
42 struct FileInfo {
43     int32_t toneId {0};
44     std::string data;
45     int64_t size {0};
46     std::string displayName {};
47     std::string title {};
48     int32_t mediaType {0};
49     int32_t toneType {0};
50     std::string mimeType {};
51     int32_t sourceType {0};
52     int64_t dateAdded {0};
53     int64_t dateModified {0};
54     int64_t dateTaken {0};
55     int32_t duration {0};
56     int32_t shotToneType {0};
57     int32_t shotToneSourceType {0};
58     int32_t notificationToneType {0};
59     int32_t notificationToneSourceType {0};
60     int32_t ringToneType {0};
61     int32_t ringToneSourceType {0};
62     int32_t alarmToneType {0};
63     int32_t alarmToneSourceType {0};
64     std::string restorePath {};
65     bool doInsert {true};
66 
67     FileInfo() = default;
FileInfoFileInfo68     FileInfo(const RingtoneMetadata &meta): toneId(meta.GetToneId()),
69         data(meta.GetData()),
70         size(meta.GetSize()),
71         displayName(meta.GetDisplayName()),
72         title(meta.GetTitle()),
73         mediaType(meta.GetMediaType()),
74         toneType(meta.GetToneType()),
75         mimeType(meta.GetMimeType()),
76         sourceType(meta.GetSourceType()),
77         dateAdded(meta.GetDateAdded()),
78         dateModified(meta.GetDateModified()),
79         dateTaken(meta.GetDateTaken()),
80         duration(meta.GetDuration()),
81         shotToneType(meta.GetShotToneType()),
82         shotToneSourceType(meta.GetShotToneSourceType()),
83         notificationToneType(meta.GetNotificationToneType()),
84         notificationToneSourceType(meta.GetNotificationToneSourceType()),
85         ringToneType(meta.GetRingToneType()),
86         ringToneSourceType(meta.GetRingToneSourceType()),
87         alarmToneType(meta.GetAlarmToneType()),
88         alarmToneSourceType(meta.GetAlarmToneSourceType()) {}
89 
toStringFileInfo90     std::string toString() const
91     {
92         return data + "|" + displayName + "|" + title + "|size=" + std::to_string(size) +
93             "|sourceType=" + std::to_string(sourceType) +
94             "|shotToneType=" + std::to_string(shotToneType) +
95             "|shotToneSourceType=" + std::to_string(shotToneSourceType) +
96             "|notificationToneType=" + std::to_string(notificationToneType) +
97             "|notificationToneSourceType=" + std::to_string(notificationToneSourceType) +
98             "|ringToneType=" + std::to_string(ringToneType) +
99             "|ringToneSourceType=" + std::to_string(ringToneSourceType) +
100             "|doInsert=" + std::to_string(doInsert) +
101             "|restorePath=" + restorePath;
102     }
103 };
104 } // namespace Media
105 } // namespace OHOS
106 
107 #endif  // RINGTONE_RESTORE_CONST_H
108