2014-11-22 09:45:04 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2014-11-22 09:45:04 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2014-11-22 09:45:04 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2017-03-04 19:36:59 +00:00
|
|
|
#include "storage/file_download.h"
|
2018-08-27 11:35:58 +00:00
|
|
|
#include "storage/cache/storage_cache_database.h"
|
|
|
|
#include "storage/localimageloader.h"
|
2019-07-24 11:45:24 +00:00
|
|
|
#include "main/main_session.h"
|
2014-11-22 09:45:04 +00:00
|
|
|
|
2019-09-13 06:06:02 +00:00
|
|
|
#include <QtCore/QTimer>
|
|
|
|
|
|
|
|
class History;
|
|
|
|
|
2019-01-16 17:26:26 +00:00
|
|
|
namespace Data {
|
2019-01-28 13:59:49 +00:00
|
|
|
class WallPaper;
|
2019-01-16 17:26:26 +00:00
|
|
|
} // namespace Data
|
|
|
|
|
2018-10-30 11:23:54 +00:00
|
|
|
namespace Lang {
|
|
|
|
struct Language;
|
|
|
|
} // namespace Lang
|
|
|
|
|
2018-08-27 11:35:58 +00:00
|
|
|
namespace Storage {
|
|
|
|
class EncryptionKey;
|
|
|
|
} // namespace Storage
|
|
|
|
|
2016-10-28 12:44:28 +00:00
|
|
|
namespace Window {
|
|
|
|
namespace Theme {
|
2019-09-05 20:21:44 +00:00
|
|
|
struct Object;
|
2018-07-19 14:58:40 +00:00
|
|
|
struct Saved;
|
2016-10-28 12:44:28 +00:00
|
|
|
} // namespace Theme
|
|
|
|
} // namespace Window
|
|
|
|
|
2018-06-22 21:32:00 +00:00
|
|
|
namespace Export {
|
|
|
|
struct Settings;
|
|
|
|
} // namespace Export
|
|
|
|
|
2016-09-15 19:15:49 +00:00
|
|
|
namespace Local {
|
2014-11-22 09:45:04 +00:00
|
|
|
|
2016-09-15 19:15:49 +00:00
|
|
|
void start();
|
|
|
|
void finish();
|
2014-11-22 09:45:04 +00:00
|
|
|
|
2016-09-15 19:15:49 +00:00
|
|
|
void readSettings();
|
|
|
|
void writeSettings();
|
|
|
|
void writeUserSettings();
|
|
|
|
void writeMtpData();
|
2014-11-22 09:45:04 +00:00
|
|
|
|
2018-05-03 06:39:10 +00:00
|
|
|
void writeAutoupdatePrefix(const QString &prefix);
|
|
|
|
QString readAutoupdatePrefix();
|
|
|
|
|
2016-09-15 19:15:49 +00:00
|
|
|
void reset();
|
2014-11-22 09:45:04 +00:00
|
|
|
|
2016-09-15 19:15:49 +00:00
|
|
|
bool checkPasscode(const QByteArray &passcode);
|
|
|
|
void setPasscode(const QByteArray &passcode);
|
2014-11-22 09:45:04 +00:00
|
|
|
|
2016-09-15 19:15:49 +00:00
|
|
|
enum ClearManagerTask {
|
|
|
|
ClearManagerAll = 0xFFFF,
|
|
|
|
ClearManagerDownloads = 0x01,
|
|
|
|
ClearManagerStorage = 0x02,
|
|
|
|
};
|
2014-11-22 09:45:04 +00:00
|
|
|
|
2016-09-15 19:15:49 +00:00
|
|
|
struct ClearManagerData;
|
|
|
|
class ClearManager : public QObject {
|
|
|
|
Q_OBJECT
|
2014-11-22 09:45:04 +00:00
|
|
|
|
2016-09-15 19:15:49 +00:00
|
|
|
public:
|
|
|
|
ClearManager();
|
|
|
|
bool addTask(int task);
|
|
|
|
bool hasTask(ClearManagerTask task);
|
|
|
|
void start();
|
|
|
|
void stop();
|
2014-11-22 09:45:04 +00:00
|
|
|
|
2016-09-15 19:15:49 +00:00
|
|
|
signals:
|
|
|
|
void succeed(int task, void *manager);
|
|
|
|
void failed(int task, void *manager);
|
2014-12-05 13:44:27 +00:00
|
|
|
|
2016-09-15 19:15:49 +00:00
|
|
|
private slots:
|
|
|
|
void onStart();
|
2014-11-22 09:45:04 +00:00
|
|
|
|
2016-09-15 19:15:49 +00:00
|
|
|
private:
|
|
|
|
~ClearManager();
|
2014-11-22 09:45:04 +00:00
|
|
|
|
2016-09-15 19:15:49 +00:00
|
|
|
ClearManagerData *data;
|
2014-11-22 09:45:04 +00:00
|
|
|
|
2016-09-15 19:15:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum ReadMapState {
|
|
|
|
ReadMapFailed = 0,
|
|
|
|
ReadMapDone = 1,
|
|
|
|
ReadMapPassNeeded = 2,
|
|
|
|
};
|
|
|
|
ReadMapState readMap(const QByteArray &pass);
|
|
|
|
int32 oldMapVersion();
|
|
|
|
|
|
|
|
int32 oldSettingsVersion();
|
|
|
|
|
|
|
|
struct MessageDraft {
|
|
|
|
MessageDraft(MsgId msgId = 0, TextWithTags textWithTags = TextWithTags(), bool previewCancelled = false)
|
|
|
|
: msgId(msgId)
|
|
|
|
, textWithTags(textWithTags)
|
|
|
|
, previewCancelled(previewCancelled) {
|
|
|
|
}
|
|
|
|
MsgId msgId;
|
|
|
|
TextWithTags textWithTags;
|
|
|
|
bool previewCancelled;
|
|
|
|
};
|
|
|
|
void writeDrafts(const PeerId &peer, const MessageDraft &localDraft, const MessageDraft &editDraft);
|
|
|
|
void readDraftsWithCursors(History *h);
|
|
|
|
void writeDraftCursors(const PeerId &peer, const MessageCursor &localCursor, const MessageCursor &editCursor);
|
|
|
|
bool hasDraftCursors(const PeerId &peer);
|
|
|
|
bool hasDraft(const PeerId &peer);
|
|
|
|
|
|
|
|
void writeFileLocation(MediaKey location, const FileLocation &local);
|
2019-05-31 16:45:03 +00:00
|
|
|
FileLocation readFileLocation(MediaKey location);
|
|
|
|
void removeFileLocation(MediaKey location);
|
2016-09-15 19:15:49 +00:00
|
|
|
|
2018-08-27 11:35:58 +00:00
|
|
|
Storage::EncryptionKey cacheKey();
|
2019-02-25 17:26:08 +00:00
|
|
|
QString cachePath();
|
2018-08-31 13:01:42 +00:00
|
|
|
Storage::Cache::Database::Settings cacheSettings();
|
2019-03-01 14:20:04 +00:00
|
|
|
void updateCacheSettings(
|
|
|
|
Storage::Cache::Database::SettingsUpdate &update,
|
|
|
|
Storage::Cache::Database::SettingsUpdate &updateBig);
|
2016-09-15 19:15:49 +00:00
|
|
|
|
2019-02-25 17:26:08 +00:00
|
|
|
Storage::EncryptionKey cacheBigFileKey();
|
|
|
|
QString cacheBigFilePath();
|
|
|
|
Storage::Cache::Database::Settings cacheBigFileSettings();
|
|
|
|
|
2016-09-15 19:15:49 +00:00
|
|
|
void countVoiceWaveform(DocumentData *document);
|
|
|
|
|
|
|
|
void cancelTask(TaskId id);
|
|
|
|
|
|
|
|
void writeInstalledStickers();
|
|
|
|
void writeFeaturedStickers();
|
|
|
|
void writeRecentStickers();
|
2017-08-02 15:07:28 +00:00
|
|
|
void writeFavedStickers();
|
2016-09-15 19:15:49 +00:00
|
|
|
void writeArchivedStickers();
|
|
|
|
void readInstalledStickers();
|
|
|
|
void readFeaturedStickers();
|
|
|
|
void readRecentStickers();
|
2017-08-02 15:07:28 +00:00
|
|
|
void readFavedStickers();
|
2016-09-15 19:15:49 +00:00
|
|
|
void readArchivedStickers();
|
|
|
|
int32 countStickersHash(bool checkOutdatedInfo = false);
|
|
|
|
int32 countRecentStickersHash();
|
2017-08-02 15:07:28 +00:00
|
|
|
int32 countFavedStickersHash();
|
2016-09-15 19:15:49 +00:00
|
|
|
int32 countFeaturedStickersHash();
|
|
|
|
|
|
|
|
void writeSavedGifs();
|
|
|
|
void readSavedGifs();
|
|
|
|
int32 countSavedGifsHash();
|
|
|
|
|
2019-01-29 07:29:38 +00:00
|
|
|
void writeBackground(const Data::WallPaper &paper, const QImage &image);
|
2016-09-15 19:15:49 +00:00
|
|
|
bool readBackground();
|
|
|
|
|
2018-07-19 14:58:40 +00:00
|
|
|
void writeTheme(const Window::Theme::Saved &saved);
|
2016-12-20 13:03:51 +00:00
|
|
|
void clearTheme();
|
2019-09-05 20:21:44 +00:00
|
|
|
[[nodiscard]] Window::Theme::Saved readThemeAfterSwitch();
|
|
|
|
|
|
|
|
[[nodiscard]] Window::Theme::Object ReadThemeContent();
|
2016-10-28 12:44:28 +00:00
|
|
|
|
2017-04-13 17:59:05 +00:00
|
|
|
void writeLangPack();
|
2018-10-30 11:23:54 +00:00
|
|
|
void pushRecentLanguage(const Lang::Language &language);
|
2018-11-01 07:10:15 +00:00
|
|
|
std::vector<Lang::Language> readRecentLanguages();
|
|
|
|
void saveRecentLanguages(const std::vector<Lang::Language> &list);
|
|
|
|
void removeRecentLanguage(const QString &id);
|
2017-04-13 17:59:05 +00:00
|
|
|
|
2016-09-15 19:15:49 +00:00
|
|
|
void writeRecentHashtagsAndBots();
|
|
|
|
void readRecentHashtagsAndBots();
|
2018-06-26 15:34:38 +00:00
|
|
|
void saveRecentSentHashtags(const QString &text);
|
|
|
|
void saveRecentSearchHashtags(const QString &text);
|
2016-09-15 19:15:49 +00:00
|
|
|
|
2018-06-22 21:32:00 +00:00
|
|
|
void WriteExportSettings(const Export::Settings &settings);
|
|
|
|
Export::Settings ReadExportSettings();
|
|
|
|
|
2018-09-11 14:36:09 +00:00
|
|
|
void writeSelf();
|
|
|
|
void readSelf(const QByteArray &serialized, int32 streamVersion);
|
|
|
|
|
2016-09-15 19:15:49 +00:00
|
|
|
void makeBotTrusted(UserData *bot);
|
|
|
|
bool isBotTrusted(UserData *bot);
|
|
|
|
|
|
|
|
bool encrypt(const void *src, void *dst, uint32 len, const void *key128);
|
|
|
|
bool decrypt(const void *src, void *dst, uint32 len, const void *key128);
|
|
|
|
|
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
class Manager : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
Manager();
|
|
|
|
|
|
|
|
void writeMap(bool fast);
|
|
|
|
void writingMap();
|
|
|
|
void writeLocations(bool fast);
|
|
|
|
void writingLocations();
|
2016-01-11 15:43:29 +00:00
|
|
|
void finish();
|
2015-03-02 12:34:16 +00:00
|
|
|
|
2016-11-24 19:28:23 +00:00
|
|
|
public slots:
|
2016-09-15 19:15:49 +00:00
|
|
|
void mapWriteTimeout();
|
|
|
|
void locationsWriteTimeout();
|
|
|
|
|
|
|
|
private:
|
|
|
|
QTimer _mapWriteTimer;
|
|
|
|
QTimer _locationsWriteTimer;
|
2016-09-07 09:04:57 +00:00
|
|
|
|
2014-11-22 09:45:04 +00:00
|
|
|
};
|
2016-09-15 19:15:49 +00:00
|
|
|
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace Local
|