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_METADATA_H 17 #define RINGTONE_METADATA_H 18 19 #include "ringtone_db_const.h" 20 #include "ringtone_type.h" 21 22 23 namespace OHOS { 24 namespace Media { 25 #define EXPORT __attribute__ ((visibility ("default"))) 26 27 class RingtoneMetadata { 28 public: 29 EXPORT RingtoneMetadata(); 30 EXPORT ~RingtoneMetadata() = default; 31 using VariantData = std::variant<int32_t, std::string, int64_t, double>; 32 33 EXPORT void SetToneId(const VariantData &toneId); 34 EXPORT int32_t GetToneId() const; 35 36 EXPORT void SetData(const VariantData &data); 37 EXPORT const std::string &GetData() const; 38 39 EXPORT void SetSize(const VariantData &size); 40 EXPORT int64_t GetSize() const; 41 42 EXPORT void SetDisplayName(const VariantData &displayName); 43 EXPORT const std::string &GetDisplayName() const; 44 45 EXPORT void SetTitle(const VariantData &title); 46 EXPORT const std::string &GetTitle() const; 47 48 EXPORT void SetMediaType(const VariantData &mediaType); 49 EXPORT int32_t GetMediaType() const; 50 51 EXPORT void SetToneType(const VariantData &toneType); 52 EXPORT int32_t GetToneType() const; 53 54 EXPORT void SetMimeType(const VariantData &mimeType); 55 EXPORT const std::string &GetMimeType() const; 56 57 EXPORT void SetSourceType(const VariantData &toneType); 58 EXPORT int32_t GetSourceType() const; 59 60 EXPORT void SetDateAdded(const VariantData &dateAdded); 61 EXPORT int64_t GetDateAdded() const; 62 63 EXPORT void SetDateModified(const VariantData &dateModified); 64 EXPORT int64_t GetDateModified() const; 65 66 EXPORT void SetDateTaken(const VariantData &dateTaken); 67 EXPORT int64_t GetDateTaken() const; 68 69 EXPORT void SetDuration(const VariantData &duration); 70 EXPORT int32_t GetDuration() const; 71 72 EXPORT void SetShotToneType(const VariantData &shotToneType); 73 EXPORT int32_t GetShotToneType() const; 74 75 EXPORT void SetShotToneSourceType(const VariantData &shotToneSourceType); 76 EXPORT int32_t GetShotToneSourceType() const; 77 78 EXPORT void SetNotificationToneType(const VariantData ¬ificationToneType); 79 EXPORT int32_t GetNotificationToneType() const; 80 81 EXPORT void SetNotificationToneSourceType(const VariantData ¬ificationToneSourceType); 82 EXPORT int32_t GetNotificationToneSourceType() const; 83 84 EXPORT void SetRingToneType(const VariantData &ringToneType); 85 EXPORT int32_t GetRingToneType() const; 86 87 EXPORT void SetRingToneSourceType(const VariantData &ringToneSourceType); 88 EXPORT int32_t GetRingToneSourceType() const; 89 90 EXPORT void SetAlarmToneType(const VariantData &alarmToneType); 91 EXPORT int32_t GetAlarmToneType() const; 92 93 EXPORT void SetAlarmToneSourceType(const VariantData &alarmToneSourceType); 94 EXPORT int32_t GetAlarmToneSourceType() const; 95 96 EXPORT void Init(); 97 98 using RingtoneMetadataFnPtr = void (RingtoneMetadata::*)(const VariantData &); 99 std::unordered_map<std::string, std::pair<RingtoneResultSetDataType, RingtoneMetadataFnPtr>> memberFuncMap_; 100 101 EXPORT std::string ToString() const; 102 private: 103 int32_t toneId_; 104 std::string data_; 105 int64_t size_; 106 std::string displayName_; 107 std::string title_; 108 int32_t mediaType_; 109 int32_t toneType_; 110 std::string mimeType_; 111 int32_t sourceType_; 112 int64_t dateAdded_; 113 int64_t dateModified_; 114 int64_t dateTaken_; 115 int32_t duration_; 116 int32_t shotToneType_; 117 int32_t shotToneSourceType_; 118 int32_t notificationToneType_; 119 int32_t notificationToneSourceType_; 120 int32_t ringToneType_; 121 int32_t ringToneSourceType_; 122 int32_t alarmToneType_; 123 int32_t alarmToneSourceType_; 124 }; 125 } // namespace Media 126 } // namespace OHOS 127 128 #endif // RINGTONE_METADATA_H 129