mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fix ringtones downloaded to disk.
This commit is contained in:
parent
6adb3e7200
commit
7d678e5fa7
1 changed files with 29 additions and 8 deletions
|
@ -88,6 +88,25 @@ constexpr auto kSystemAlertDuration = crl::time(0);
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] QByteArray ReadRingtoneBytes(
|
||||||
|
const std::shared_ptr<Data::DocumentMedia> &media) {
|
||||||
|
const auto result = media->bytes();
|
||||||
|
if (!result.isEmpty()) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
const auto &location = media->owner()->location();
|
||||||
|
if (!location.isEmpty() && location.accessEnable()) {
|
||||||
|
const auto guard = gsl::finally([&] {
|
||||||
|
location.accessDisable();
|
||||||
|
});
|
||||||
|
auto f = QFile(location.name());
|
||||||
|
if (f.open(QIODevice::ReadOnly)) {
|
||||||
|
return f.readAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
const char kOptionGNotification[] = "gnotification";
|
const char kOptionGNotification[] = "gnotification";
|
||||||
|
@ -801,14 +820,16 @@ not_null<Media::Audio::Track*> System::lookupSound(
|
||||||
return i->second.get();
|
return i->second.get();
|
||||||
}
|
}
|
||||||
const auto ¬ifySettings = owner->notifySettings();
|
const auto ¬ifySettings = owner->notifySettings();
|
||||||
const auto custom = notifySettings.lookupRingtone(id);
|
if (const auto custom = notifySettings.lookupRingtone(id)) {
|
||||||
if (custom && !custom->bytes().isEmpty()) {
|
const auto bytes = ReadRingtoneBytes(custom);
|
||||||
const auto j = _customSoundTracks.emplace(
|
if (!bytes.isEmpty()) {
|
||||||
id,
|
const auto j = _customSoundTracks.emplace(
|
||||||
Media::Audio::Current().createTrack()
|
id,
|
||||||
).first;
|
Media::Audio::Current().createTrack()
|
||||||
j->second->fillFromData(bytes::make_vector(custom->bytes()));
|
).first;
|
||||||
return j->second.get();
|
j->second->fillFromData(bytes::make_vector(bytes));
|
||||||
|
return j->second.get();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ensureSoundCreated();
|
ensureSoundCreated();
|
||||||
return _soundTrack.get();
|
return _soundTrack.get();
|
||||||
|
|
Loading…
Add table
Reference in a new issue