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_ASSET_H
17 #define RINGTONE_ASSET_H
18 
19 #include <mutex>
20 #include <string>
21 
22 namespace OHOS {
23 namespace Media {
24 #define EXPORT __attribute__ ((visibility ("default")))
25 
26 class RingtoneAsset {
27 public:
28     EXPORT RingtoneAsset();
29     EXPORT virtual ~RingtoneAsset() = default;
30 
31     EXPORT int32_t GetId() const;
32     EXPORT void SetId(int32_t id);
33 
34     EXPORT int64_t GetSize() const;
35     EXPORT void SetSize(int64_t size);
36 
37     EXPORT const std::string &GetPath() const;
38     EXPORT void SetPath(const std::string &path);
39 
40     EXPORT const std::string &GetDisplayName() const;
41     EXPORT void SetDisplayName(const std::string &displayName);
42 
43     EXPORT const std::string &GetTitle() const;
44     EXPORT void SetTitle(const std::string &title);
45 
46     EXPORT const std::string &GetMimeType() const;
47     EXPORT void SetMimeType(const std::string &mimeType);
48 
49     EXPORT int32_t GetToneType() const;
50     EXPORT void SetToneType(int32_t toneType);
51 
52     EXPORT int32_t GetSourceType() const;
53     EXPORT void SetSourceType(int32_t type);
54 
55     EXPORT int64_t GetDateAdded() const;
56     EXPORT void SetDateAdded(int64_t dateAdded);
57 
58     EXPORT int64_t GetDateModified() const;
59     EXPORT void SetDateModified(int64_t dateModified);
60 
61     EXPORT int64_t GetDateTaken() const;
62     EXPORT void SetDateTaken(int64_t dateTaken);
63 
64     EXPORT int32_t GetDuration() const;
65     EXPORT void SetDuration(int32_t duration);
66 
67     EXPORT int32_t GetShottoneType() const;
68     EXPORT void SetShottoneType(int32_t type);
69 
70     EXPORT int32_t GetShottoneSourceType() const;
71     EXPORT void SetShottoneSourceType(int32_t type);
72 
73     EXPORT int32_t GetNotificationtoneType() const;
74     EXPORT void SetNotificationtoneType(int32_t type);
75 
76     EXPORT int32_t GetNotificationtoneSourceType() const;
77     EXPORT void SetNotificationtoneSourceType(int32_t type);
78 
79     EXPORT int32_t GetRingtoneType() const;
80     EXPORT void SetRingtoneType(int32_t type);
81 
82     EXPORT int32_t GetRingtoneSourceType() const;
83     EXPORT void SetRingtoneSourceType(int32_t type);
84 
85     EXPORT int32_t GetAlarmtoneType() const;
86     EXPORT void SetAlarmtoneType(int32_t type);
87 
88     EXPORT int32_t GetAlarmtoneSourceType() const;
89     EXPORT void SetAlarmtoneSourceType(int32_t type);
90 
91     EXPORT void SetOpenStatus(int32_t fd, int32_t openStatus);
92     EXPORT void RemoveOpenStatus(int32_t fd);
93     EXPORT int32_t GetOpenStatus(int32_t fd);
94 
95     EXPORT std::unordered_map<std::string, std::variant<int32_t, int64_t, std::string, double>> &GetMemberMap();
96     EXPORT std::variant<int32_t, int64_t, std::string, double> &GetMemberValue(const std::string &name);
97 
98 private:
99     const std::string &GetStrMember(const std::string &name) const;
100     int32_t GetInt32Member(const std::string &name) const;
101     int64_t GetInt64Member(const std::string &name) const;
102 
103     std::unordered_map<std::string, std::variant<int32_t, int64_t, std::string, double>> member_;
104     std::mutex openStatusMapMutex_;
105     std::shared_ptr<std::unordered_map<int32_t, int32_t>> openStatusMap_;
106 };
107 } // namespace Media
108 } // namespace OHOS
109 
110 #endif  // RINGTONE_ASSET_H
111