2014-11-22 09:45:04 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2014-12-01 10:47:38 +00:00
|
|
|
the official desktop version of Telegram messaging app, see https://telegram.org
|
2014-11-22 09:45:04 +00:00
|
|
|
|
|
|
|
Telegram Desktop is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
It is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
2015-10-03 13:16:42 +00:00
|
|
|
In addition, as a special exception, the copyright holders give permission
|
|
|
|
to link the code of portions of this program with the OpenSSL library.
|
|
|
|
|
2014-11-22 09:45:04 +00:00
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
2017-01-11 18:31:31 +00:00
|
|
|
Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
2014-11-22 09:45:04 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
#include "core/basic_types.h"
|
2017-03-04 19:36:59 +00:00
|
|
|
#include "storage/file_download.h"
|
2017-04-09 18:06:06 +00:00
|
|
|
#include "auth_session.h"
|
2014-11-22 09:45:04 +00:00
|
|
|
|
2016-10-28 12:44:28 +00:00
|
|
|
namespace Window {
|
|
|
|
namespace Theme {
|
|
|
|
struct Cached;
|
|
|
|
} // namespace Theme
|
|
|
|
} // namespace Window
|
|
|
|
|
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
|
|
|
|
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);
|
|
|
|
FileLocation readFileLocation(MediaKey location, bool check = true);
|
|
|
|
|
|
|
|
void writeImage(const StorageKey &location, const ImagePtr &img);
|
|
|
|
void writeImage(const StorageKey &location, const StorageImageSaved &jpeg, bool overwrite = true);
|
|
|
|
TaskId startImageLoad(const StorageKey &location, mtpFileLoader *loader);
|
|
|
|
int32 hasImages();
|
|
|
|
qint64 storageImagesSize();
|
|
|
|
|
|
|
|
void writeStickerImage(const StorageKey &location, const QByteArray &data, bool overwrite = true);
|
|
|
|
TaskId startStickerImageLoad(const StorageKey &location, mtpFileLoader *loader);
|
|
|
|
bool willStickerImageLoad(const StorageKey &location);
|
|
|
|
bool copyStickerImage(const StorageKey &oldLocation, const StorageKey &newLocation);
|
|
|
|
int32 hasStickers();
|
|
|
|
qint64 storageStickersSize();
|
|
|
|
|
|
|
|
void writeAudio(const StorageKey &location, const QByteArray &data, bool overwrite = true);
|
|
|
|
TaskId startAudioLoad(const StorageKey &location, mtpFileLoader *loader);
|
|
|
|
bool copyAudio(const StorageKey &oldLocation, const StorageKey &newLocation);
|
|
|
|
int32 hasAudios();
|
|
|
|
qint64 storageAudiosSize();
|
|
|
|
|
|
|
|
void writeWebFile(const QString &url, const QByteArray &data, bool overwrite = true);
|
|
|
|
TaskId startWebFileLoad(const QString &url, webFileLoader *loader);
|
|
|
|
int32 hasWebFiles();
|
|
|
|
qint64 storageWebFilesSize();
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
void writeBackground(int32 id, const QImage &img);
|
|
|
|
bool readBackground();
|
|
|
|
|
2016-10-28 12:44:28 +00:00
|
|
|
void writeTheme(const QString &pathRelative, const QString &pathAbsolute, const QByteArray &content, const Window::Theme::Cached &cache);
|
2016-12-20 13:03:51 +00:00
|
|
|
void clearTheme();
|
|
|
|
bool hasTheme();
|
2017-06-29 19:09:10 +00:00
|
|
|
QString themeAbsolutePath();
|
2017-02-03 20:07:26 +00:00
|
|
|
QString themePaletteAbsolutePath();
|
|
|
|
bool copyThemeColorsToPalette(const QString &file);
|
2016-10-28 12:44:28 +00:00
|
|
|
|
2017-04-13 17:59:05 +00:00
|
|
|
void writeLangPack();
|
|
|
|
|
2016-09-15 19:15:49 +00:00
|
|
|
void writeRecentHashtagsAndBots();
|
|
|
|
void readRecentHashtagsAndBots();
|
|
|
|
|
|
|
|
void addSavedPeer(PeerData *peer, const QDateTime &position);
|
|
|
|
void removeSavedPeer(PeerData *peer);
|
|
|
|
void readSavedPeers();
|
|
|
|
|
|
|
|
void writeReportSpamStatuses();
|
|
|
|
|
|
|
|
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
|