2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

ReportSpamPanel -> HistoryView::ContactStatus.

This commit is contained in:
John Preston
2019-06-07 14:32:58 +03:00
parent 30dea3a2e7
commit 5e3734d7bf
21 changed files with 438 additions and 501 deletions

View File

@@ -518,7 +518,7 @@ enum { // Local Storage Keys
lskRecentHashtagsAndBots = 0x0a, // no data
lskStickersOld = 0x0b, // no data
lskSavedPeersOld = 0x0c, // no data
lskReportSpamStatuses = 0x0d, // no data
lskReportSpamStatusesOld = 0x0d, // no data
lskSavedGifsOld = 0x0e, // no data
lskSavedGifs = 0x0f, // no data
lskStickersKeys = 0x10, // no data
@@ -645,7 +645,7 @@ typedef QMap<QString, FileLocationPair> FileLocationPairs;
FileLocationPairs _fileLocationPairs;
typedef QMap<MediaKey, MediaKey> FileLocationAliases;
FileLocationAliases _fileLocationAliases;
FileKey _locationsKey = 0, _reportSpamStatusesKey = 0, _trustedBotsKey = 0;
FileKey _locationsKey = 0, _trustedBotsKey = 0;
using TrustedBots = OrderedSet<uint64>;
TrustedBots _trustedBots;
@@ -838,63 +838,6 @@ void _readLocations() {
}
}
void _writeReportSpamStatuses() {
if (!_working()) return;
if (cReportSpamStatuses().isEmpty()) {
if (_reportSpamStatusesKey) {
clearKey(_reportSpamStatusesKey);
_reportSpamStatusesKey = 0;
_mapChanged = true;
_writeMap();
}
} else {
if (!_reportSpamStatusesKey) {
_reportSpamStatusesKey = genKey();
_mapChanged = true;
_writeMap(WriteMapWhen::Fast);
}
const ReportSpamStatuses &statuses(cReportSpamStatuses());
quint32 size = sizeof(qint32);
for (ReportSpamStatuses::const_iterator i = statuses.cbegin(), e = statuses.cend(); i != e; ++i) {
// peer + status
size += sizeof(quint64) + sizeof(qint32);
}
EncryptedDescriptor data(size);
data.stream << qint32(statuses.size());
for (ReportSpamStatuses::const_iterator i = statuses.cbegin(), e = statuses.cend(); i != e; ++i) {
data.stream << quint64(i.key()) << qint32(i.value());
}
FileWriteDescriptor file(_reportSpamStatusesKey);
file.writeEncrypted(data);
}
}
void _readReportSpamStatuses() {
FileReadDescriptor statuses;
if (!readEncryptedFile(statuses, _reportSpamStatusesKey)) {
clearKey(_reportSpamStatusesKey);
_reportSpamStatusesKey = 0;
_writeMap();
return;
}
ReportSpamStatuses &map(cRefReportSpamStatuses());
map.clear();
qint32 size = 0;
statuses.stream >> size;
for (int32 i = 0; i < size; ++i) {
quint64 peer = 0;
qint32 status = 0;
statuses.stream >> peer >> status;
map.insert(peer, DBIPeerReportSpamStatus(status));
}
}
struct ReadSettingsContext {
int legacyLanguageId = Lang::kLegacyLanguageNone;
QString legacyLanguageFile;
@@ -2352,8 +2295,9 @@ ReadMapState _readMap(const QByteArray &pass) {
case lskLocations: {
map.stream >> locationsKey;
} break;
case lskReportSpamStatuses: {
case lskReportSpamStatusesOld: {
map.stream >> reportSpamStatusesKey;
clearKey(reportSpamStatusesKey);
} break;
case lskTrustedBots: {
map.stream >> trustedBotsKey;
@@ -2412,7 +2356,6 @@ ReadMapState _readMap(const QByteArray &pass) {
_draftsNotReadMap = draftsNotReadMap;
_locationsKey = locationsKey;
_reportSpamStatusesKey = reportSpamStatusesKey;
_trustedBotsKey = trustedBotsKey;
_recentStickersKeyOld = recentStickersKeyOld;
_installedStickersKey = installedStickersKey;
@@ -2437,9 +2380,6 @@ ReadMapState _readMap(const QByteArray &pass) {
if (_locationsKey) {
_readLocations();
}
if (_reportSpamStatusesKey) {
_readReportSpamStatuses();
}
_readUserSettings();
_readMtpData();
@@ -2516,7 +2456,6 @@ void _writeMap(WriteMapWhen when) {
if (!_draftsMap.isEmpty()) mapSize += sizeof(quint32) * 2 + _draftsMap.size() * sizeof(quint64) * 2;
if (!_draftCursorsMap.isEmpty()) mapSize += sizeof(quint32) * 2 + _draftCursorsMap.size() * sizeof(quint64) * 2;
if (_locationsKey) mapSize += sizeof(quint32) + sizeof(quint64);
if (_reportSpamStatusesKey) mapSize += sizeof(quint32) + sizeof(quint64);
if (_trustedBotsKey) mapSize += sizeof(quint32) + sizeof(quint64);
if (_recentStickersKeyOld) mapSize += sizeof(quint32) + sizeof(quint64);
if (_installedStickersKey || _featuredStickersKey || _recentStickersKey || _archivedStickersKey) {
@@ -2548,9 +2487,6 @@ void _writeMap(WriteMapWhen when) {
if (_locationsKey) {
mapData.stream << quint32(lskLocations) << quint64(_locationsKey);
}
if (_reportSpamStatusesKey) {
mapData.stream << quint32(lskReportSpamStatuses) << quint64(_reportSpamStatusesKey);
}
if (_trustedBotsKey) {
mapData.stream << quint32(lskTrustedBots) << quint64(_trustedBotsKey);
}
@@ -2837,7 +2773,7 @@ void reset() {
_fileLocationPairs.clear();
_fileLocationAliases.clear();
_draftsNotReadMap.clear();
_locationsKey = _reportSpamStatusesKey = _trustedBotsKey = 0;
_locationsKey = _trustedBotsKey = 0;
_recentStickersKeyOld = 0;
_installedStickersKey = _featuredStickersKey = _recentStickersKey = _favedStickersKey = _archivedStickersKey = 0;
_savedGifsKey = 0;
@@ -2879,7 +2815,6 @@ void setPasscode(const QByteArray &passcode) {
base::flat_set<QString> CollectGoodNames() {
const auto keys = {
_locationsKey,
_reportSpamStatusesKey,
_userSettingsKey,
_installedStickersKey,
_featuredStickersKey,
@@ -4838,10 +4773,6 @@ Export::Settings ReadExportSettings() {
: Export::Settings();
}
void writeReportSpamStatuses() {
_writeReportSpamStatuses();
}
void writeSelf() {
_mapChanged = true;
_writeMap();
@@ -4976,10 +4907,6 @@ bool ClearManager::addTask(int task) {
_locationsKey = 0;
_mapChanged = true;
}
if (_reportSpamStatusesKey) {
_reportSpamStatusesKey = 0;
_mapChanged = true;
}
if (_trustedBotsKey) {
_trustedBotsKey = 0;
_mapChanged = true;