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.
|
|
|
|
|
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
2014-12-01 10:47:38 +00:00
|
|
|
Copyright (c) 2014 John Preston, https://desktop.telegram.org
|
2014-11-22 09:45:04 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "types.h"
|
|
|
|
|
|
|
|
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();
|
|
|
|
void stop();
|
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);
|
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-03-19 09:18:19 +00:00
|
|
|
struct MessageDraft {
|
|
|
|
MessageDraft(MsgId replyTo = 0, QString text = QString()) : replyTo(replyTo), text(text) {
|
|
|
|
}
|
|
|
|
MsgId replyTo;
|
|
|
|
QString text;
|
|
|
|
};
|
|
|
|
void writeDraft(const PeerId &peer, const MessageDraft &draft);
|
|
|
|
MessageDraft readDraft(const PeerId &peer);
|
2014-11-22 09:45:04 +00:00
|
|
|
void writeDraftPositions(const PeerId &peer, const MessageCursor &cur);
|
|
|
|
MessageCursor readDraftPositions(const PeerId &peer);
|
|
|
|
bool hasDraftPositions(const PeerId &peer);
|
|
|
|
|
2014-12-05 13:44:27 +00:00
|
|
|
void writeFileLocation(const StorageKey &location, const FileLocation &local);
|
|
|
|
FileLocation readFileLocation(const StorageKey &location, bool check = true);
|
|
|
|
|
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);
|
|
|
|
StorageImageSaved readImage(const StorageKey &location);
|
|
|
|
int32 hasImages();
|
2015-01-02 14:55:24 +00:00
|
|
|
qint64 storageImagesSize();
|
|
|
|
|
|
|
|
void writeSticker(const StorageKey &location, const QByteArray &data, bool overwrite = true);
|
|
|
|
QByteArray readSticker(const StorageKey &location);
|
|
|
|
int32 hasStickers();
|
|
|
|
qint64 storageStickersSize();
|
|
|
|
|
|
|
|
void writeAudio(const StorageKey &location, const QByteArray &data, bool overwrite = true);
|
|
|
|
QByteArray readAudio(const StorageKey &location);
|
|
|
|
int32 hasAudios();
|
|
|
|
qint64 storageAudiosSize();
|
|
|
|
|
|
|
|
void writeRecentStickers();
|
|
|
|
void readRecentStickers();
|
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();
|
|
|
|
|
2015-03-24 10:00:27 +00:00
|
|
|
void writeRecentHashtags();
|
|
|
|
void readRecentHashtags();
|
|
|
|
|
2014-11-22 09:45:04 +00:00
|
|
|
};
|