mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 06:35:14 +00:00
Minimal emoji sets support.
This commit is contained in:
@@ -84,6 +84,7 @@ enum { // Local Storage Keys
|
||||
lskBackgroundOld = 0x14, // no data
|
||||
lskSelfSerialized = 0x15, // serialized self
|
||||
lskMasksKeys = 0x16, // no data
|
||||
lskCustomEmojiKeys = 0x17, // no data
|
||||
};
|
||||
|
||||
auto EmptyMessageDraftSources()
|
||||
@@ -203,6 +204,9 @@ base::flat_set<QString> Account::collectGoodNames() const {
|
||||
_installedMasksKey,
|
||||
_recentMasksKey,
|
||||
_archivedMasksKey,
|
||||
_installedCustomEmojiKey,
|
||||
_recentCustomEmojiKey,
|
||||
_archivedCustomEmojiKey,
|
||||
};
|
||||
auto result = base::flat_set<QString>{
|
||||
"map0",
|
||||
@@ -284,6 +288,7 @@ Account::ReadMapResult Account::readMapWith(
|
||||
quint64 recentStickersKeyOld = 0;
|
||||
quint64 installedStickersKey = 0, featuredStickersKey = 0, recentStickersKey = 0, favedStickersKey = 0, archivedStickersKey = 0;
|
||||
quint64 installedMasksKey = 0, recentMasksKey = 0, archivedMasksKey = 0;
|
||||
quint64 installedCustomEmojiKey = 0, recentCustomEmojiKey = 0, archivedCustomEmojiKey = 0;
|
||||
quint64 savedGifsKey = 0;
|
||||
quint64 legacyBackgroundKeyDay = 0, legacyBackgroundKeyNight = 0;
|
||||
quint64 userSettingsKey = 0, recentHashtagsAndBotsKey = 0, exportSettingsKey = 0;
|
||||
@@ -386,6 +391,12 @@ Account::ReadMapResult Account::readMapWith(
|
||||
>> recentMasksKey
|
||||
>> archivedMasksKey;
|
||||
} break;
|
||||
case lskCustomEmojiKeys: {
|
||||
map.stream
|
||||
>> installedCustomEmojiKey
|
||||
>> recentCustomEmojiKey
|
||||
>> archivedCustomEmojiKey;
|
||||
} break;
|
||||
default:
|
||||
LOG(("App Error: unknown key type in encrypted map: %1").arg(keyType));
|
||||
return ReadMapResult::Failed;
|
||||
@@ -413,6 +424,9 @@ Account::ReadMapResult Account::readMapWith(
|
||||
_installedMasksKey = installedMasksKey;
|
||||
_recentMasksKey = recentMasksKey;
|
||||
_archivedMasksKey = archivedMasksKey;
|
||||
_installedCustomEmojiKey = installedCustomEmojiKey;
|
||||
_recentCustomEmojiKey = recentCustomEmojiKey;
|
||||
_archivedCustomEmojiKey = archivedCustomEmojiKey;
|
||||
_legacyBackgroundKeyDay = legacyBackgroundKeyDay;
|
||||
_legacyBackgroundKeyNight = legacyBackgroundKeyNight;
|
||||
_settingsKey = userSettingsKey;
|
||||
@@ -520,6 +534,9 @@ void Account::writeMap() {
|
||||
if (_installedMasksKey || _recentMasksKey || _archivedMasksKey) {
|
||||
mapSize += sizeof(quint32) + 3 * sizeof(quint64);
|
||||
}
|
||||
if (_installedCustomEmojiKey || _recentCustomEmojiKey || _archivedCustomEmojiKey) {
|
||||
mapSize += sizeof(quint32) + 3 * sizeof(quint64);
|
||||
}
|
||||
|
||||
EncryptedDescriptor mapData(mapSize);
|
||||
if (!self.isEmpty()) {
|
||||
@@ -572,6 +589,13 @@ void Account::writeMap() {
|
||||
<< quint64(_recentMasksKey)
|
||||
<< quint64(_archivedMasksKey);
|
||||
}
|
||||
if (_installedCustomEmojiKey || _recentCustomEmojiKey || _archivedCustomEmojiKey) {
|
||||
mapData.stream << quint32(lskCustomEmojiKeys);
|
||||
mapData.stream
|
||||
<< quint64(_installedCustomEmojiKey)
|
||||
<< quint64(_recentCustomEmojiKey)
|
||||
<< quint64(_archivedCustomEmojiKey);
|
||||
}
|
||||
map.writeEncrypted(mapData, _localKey);
|
||||
|
||||
_mapChanged = false;
|
||||
@@ -593,6 +617,9 @@ void Account::reset() {
|
||||
_installedMasksKey = 0;
|
||||
_recentMasksKey = 0;
|
||||
_archivedMasksKey = 0;
|
||||
_installedCustomEmojiKey = 0;
|
||||
_recentCustomEmojiKey = 0;
|
||||
_archivedCustomEmojiKey = 0;
|
||||
_legacyBackgroundKeyDay = _legacyBackgroundKeyNight = 0;
|
||||
_settingsKey = _recentHashtagsAndBotsKey = _exportSettingsKey = 0;
|
||||
_oldMapVersion = 0;
|
||||
@@ -2091,6 +2118,17 @@ void Account::writeRecentMasks() {
|
||||
}, Data::StickersSetsOrder());
|
||||
}
|
||||
|
||||
void Account::writeInstalledCustomEmoji() {
|
||||
using SetFlag = Data::StickersSetFlag;
|
||||
|
||||
writeStickerSets(_installedCustomEmojiKey, [](const Data::StickersSet &set) {
|
||||
if (!(set.flags & SetFlag::Emoji) || set.stickers.isEmpty()) {
|
||||
return StickerSetCheckResult::Skip;
|
||||
}
|
||||
return StickerSetCheckResult::Write;
|
||||
}, _owner->session().data().stickers().emojiSetsOrder());
|
||||
}
|
||||
|
||||
void Account::importOldRecentStickers() {
|
||||
using SetFlag = Data::StickersSetFlag;
|
||||
|
||||
@@ -2283,6 +2321,13 @@ void Account::readInstalledMasks() {
|
||||
Data::StickersSetFlag::Installed);
|
||||
}
|
||||
|
||||
void Account::readInstalledCustomEmoji() {
|
||||
readStickerSets(
|
||||
_installedCustomEmojiKey,
|
||||
&_owner->session().data().stickers().emojiSetsOrderRef(),
|
||||
Data::StickersSetFlag::Installed);
|
||||
}
|
||||
|
||||
void Account::writeSavedGifs() {
|
||||
const auto &saved = _owner->session().data().stickers().savedGifs();
|
||||
if (saved.isEmpty()) {
|
||||
|
Reference in New Issue
Block a user