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
|
2016-02-08 10:56:18 +00:00
|
|
|
Copyright (c) 2014-2016 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"
|
2014-11-22 09:45:04 +00:00
|
|
|
|
|
|
|
namespace _local_inner {
|
|
|
|
|
|
|
|
class Manager : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
Manager();
|
|
|
|
|
|
|
|
void writeMap(bool fast);
|
|
|
|
void writingMap();
|
2014-12-05 13:44:27 +00:00
|
|
|
void writeLocations(bool fast);
|
|
|
|
void writingLocations();
|
2014-11-22 09:45:04 +00:00
|
|
|
void finish();
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
|
|
|
void mapWriteTimeout();
|
2014-12-05 13:44:27 +00:00
|
|
|
void locationsWriteTimeout();
|
2014-11-22 09:45:04 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
QTimer _mapWriteTimer;
|
2014-12-05 13:44:27 +00:00
|
|
|
QTimer _locationsWriteTimer;
|
|
|
|
|
2014-11-22 09:45:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Local {
|
|
|
|
|
|
|
|
void start();
|
2016-01-11 15:43:29 +00:00
|
|
|
void finish();
|
2015-03-02 12:34:16 +00:00
|
|
|
|
|
|
|
void readSettings();
|
|
|
|
void writeSettings();
|
|
|
|
void writeUserSettings();
|
|
|
|
void writeMtpData();
|
|
|
|
|
|
|
|
void reset();
|
|
|
|
|
|
|
|
bool checkPasscode(const QByteArray &passcode);
|
|
|
|
void setPasscode(const QByteArray &passcode);
|
2015-12-31 15:27:21 +00:00
|
|
|
|
2014-11-22 09:45:04 +00:00
|
|
|
enum ClearManagerTask {
|
|
|
|
ClearManagerAll = 0xFFFF,
|
|
|
|
ClearManagerDownloads = 0x01,
|
2015-01-02 14:55:24 +00:00
|
|
|
ClearManagerStorage = 0x02,
|
2014-11-22 09:45:04 +00:00
|
|
|
};
|
|
|
|
|
2014-11-22 10:01:28 +00:00
|
|
|
struct ClearManagerData;
|
2014-11-22 09:45:04 +00:00
|
|
|
class ClearManager : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
ClearManager();
|
|
|
|
bool addTask(int task);
|
|
|
|
bool hasTask(ClearManagerTask task);
|
|
|
|
void start();
|
|
|
|
~ClearManager();
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void onStart();
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void succeed(int task, void *manager);
|
|
|
|
void failed(int task, void *manager);
|
|
|
|
|
|
|
|
private:
|
|
|
|
ClearManagerData *data;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ReadMapState {
|
|
|
|
ReadMapFailed = 0,
|
|
|
|
ReadMapDone = 1,
|
|
|
|
ReadMapPassNeeded = 2,
|
|
|
|
};
|
|
|
|
ReadMapState readMap(const QByteArray &pass);
|
2014-12-03 13:10:32 +00:00
|
|
|
int32 oldMapVersion();
|
2014-11-22 09:45:04 +00:00
|
|
|
|
2015-08-13 15:11:07 +00:00
|
|
|
int32 oldSettingsVersion();
|
|
|
|
|
2016-05-05 16:04:17 +00:00
|
|
|
using TextWithTags = FlatTextarea::TextWithTags;
|
2015-03-19 09:18:19 +00:00
|
|
|
struct MessageDraft {
|
2016-05-05 16:04:17 +00:00
|
|
|
MessageDraft(MsgId msgId = 0, TextWithTags textWithTags = TextWithTags(), bool previewCancelled = false)
|
|
|
|
: msgId(msgId)
|
|
|
|
, textWithTags(textWithTags)
|
|
|
|
, previewCancelled(previewCancelled) {
|
2015-03-19 09:18:19 +00:00
|
|
|
}
|
2016-02-25 10:32:31 +00:00
|
|
|
MsgId msgId;
|
2016-05-05 16:04:17 +00:00
|
|
|
TextWithTags textWithTags;
|
2015-04-06 22:15:29 +00:00
|
|
|
bool previewCancelled;
|
2015-03-19 09:18:19 +00:00
|
|
|
};
|
2016-06-03 18:24:27 +00:00
|
|
|
void writeDrafts(const PeerId &peer, const MessageDraft &localDraft, const MessageDraft &editDraft);
|
2016-02-25 10:32:31 +00:00
|
|
|
void readDraftsWithCursors(History *h);
|
2016-06-03 18:24:27 +00:00
|
|
|
void writeDraftCursors(const PeerId &peer, const MessageCursor &localCursor, const MessageCursor &editCursor);
|
2016-02-25 10:32:31 +00:00
|
|
|
bool hasDraftCursors(const PeerId &peer);
|
2016-05-31 09:46:31 +00:00
|
|
|
bool hasDraft(const PeerId &peer);
|
2014-11-22 09:45:04 +00:00
|
|
|
|
2015-06-30 21:07:05 +00:00
|
|
|
void writeFileLocation(MediaKey location, const FileLocation &local);
|
|
|
|
FileLocation readFileLocation(MediaKey location, bool check = true);
|
2014-12-05 13:44:27 +00:00
|
|
|
|
2014-11-22 09:45:04 +00:00
|
|
|
void writeImage(const StorageKey &location, const ImagePtr &img);
|
|
|
|
void writeImage(const StorageKey &location, const StorageImageSaved &jpeg, bool overwrite = true);
|
2015-09-29 18:44:31 +00:00
|
|
|
TaskId startImageLoad(const StorageKey &location, mtpFileLoader *loader);
|
2014-11-22 09:45:04 +00:00
|
|
|
int32 hasImages();
|
2015-01-02 14:55:24 +00:00
|
|
|
qint64 storageImagesSize();
|
|
|
|
|
2015-05-19 15:46:45 +00:00
|
|
|
void writeStickerImage(const StorageKey &location, const QByteArray &data, bool overwrite = true);
|
2015-09-29 18:44:31 +00:00
|
|
|
TaskId startStickerImageLoad(const StorageKey &location, mtpFileLoader *loader);
|
2015-12-24 19:26:28 +00:00
|
|
|
bool willStickerImageLoad(const StorageKey &location);
|
2016-04-10 14:53:01 +00:00
|
|
|
bool copyStickerImage(const StorageKey &oldLocation, const StorageKey &newLocation);
|
2015-01-02 14:55:24 +00:00
|
|
|
int32 hasStickers();
|
|
|
|
qint64 storageStickersSize();
|
|
|
|
|
|
|
|
void writeAudio(const StorageKey &location, const QByteArray &data, bool overwrite = true);
|
2015-09-29 18:44:31 +00:00
|
|
|
TaskId startAudioLoad(const StorageKey &location, mtpFileLoader *loader);
|
2016-04-10 14:53:01 +00:00
|
|
|
bool copyAudio(const StorageKey &oldLocation, const StorageKey &newLocation);
|
2015-01-02 14:55:24 +00:00
|
|
|
int32 hasAudios();
|
|
|
|
qint64 storageAudiosSize();
|
|
|
|
|
2015-12-31 15:27:21 +00:00
|
|
|
void writeWebFile(const QString &url, const QByteArray &data, bool overwrite = true);
|
|
|
|
TaskId startWebFileLoad(const QString &url, webFileLoader *loader);
|
|
|
|
int32 hasWebFiles();
|
|
|
|
qint64 storageWebFilesSize();
|
|
|
|
|
2016-02-12 16:35:06 +00:00
|
|
|
void countVoiceWaveform(DocumentData *document);
|
|
|
|
|
2015-09-29 18:44:31 +00:00
|
|
|
void cancelTask(TaskId id);
|
|
|
|
|
2015-05-19 15:46:45 +00:00
|
|
|
void writeStickers();
|
|
|
|
void readStickers();
|
2015-12-27 21:37:48 +00:00
|
|
|
int32 countStickersHash(bool checkOfficial = false);
|
2016-06-27 16:25:21 +00:00
|
|
|
int32 countFeaturedStickersHash();
|
2015-12-27 21:37:48 +00:00
|
|
|
|
|
|
|
void writeSavedGifs();
|
|
|
|
void readSavedGifs();
|
|
|
|
int32 countSavedGifsHash();
|
2014-11-22 09:45:04 +00:00
|
|
|
|
2015-02-03 15:02:46 +00:00
|
|
|
void writeBackground(int32 id, const QImage &img);
|
|
|
|
bool readBackground();
|
|
|
|
|
2016-01-01 14:48:32 +00:00
|
|
|
void writeRecentHashtagsAndBots();
|
|
|
|
void readRecentHashtagsAndBots();
|
2015-03-24 10:00:27 +00:00
|
|
|
|
2015-08-07 12:11:50 +00:00
|
|
|
void addSavedPeer(PeerData *peer, const QDateTime &position);
|
|
|
|
void removeSavedPeer(PeerData *peer);
|
|
|
|
void readSavedPeers();
|
|
|
|
|
2015-09-07 15:53:46 +00:00
|
|
|
void writeReportSpamStatuses();
|
|
|
|
|
2014-11-22 09:45:04 +00:00
|
|
|
};
|