2018-06-23 20:27:41 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop application for the Telegram messaging service.
|
|
|
|
|
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "export/output/export_output_abstract.h"
|
|
|
|
#include "export/output/export_output_file.h"
|
|
|
|
#include "export/export_settings.h"
|
|
|
|
#include "export/data/export_data_types.h"
|
|
|
|
|
|
|
|
namespace Export {
|
|
|
|
namespace Output {
|
2018-06-29 21:10:21 +00:00
|
|
|
namespace details {
|
|
|
|
|
|
|
|
class HtmlContext {
|
|
|
|
public:
|
|
|
|
[[nodiscard]] QByteArray pushTag(
|
|
|
|
const QByteArray &tag,
|
|
|
|
std::map<QByteArray, QByteArray> &&attributes = {});
|
|
|
|
[[nodiscard]] QByteArray popTag();
|
|
|
|
[[nodiscard]] QByteArray indent() const;
|
|
|
|
[[nodiscard]] bool empty() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
struct Tag {
|
|
|
|
QByteArray name;
|
|
|
|
bool block = true;
|
|
|
|
};
|
|
|
|
std::vector<Tag> _tags;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
struct UserpicData;
|
2018-07-03 23:09:25 +00:00
|
|
|
struct PeersMap;
|
|
|
|
struct MediaData;
|
2018-06-29 21:10:21 +00:00
|
|
|
|
|
|
|
} // namespace details
|
2018-06-23 20:27:41 +00:00
|
|
|
|
|
|
|
class HtmlWriter : public AbstractWriter {
|
|
|
|
public:
|
|
|
|
HtmlWriter();
|
|
|
|
|
|
|
|
Format format() override {
|
|
|
|
return Format::Html;
|
|
|
|
}
|
|
|
|
|
2018-06-24 02:06:11 +00:00
|
|
|
Result start(
|
|
|
|
const Settings &settings,
|
|
|
|
const Environment &environment,
|
|
|
|
Stats *stats) override;
|
2018-06-23 20:27:41 +00:00
|
|
|
|
|
|
|
Result writePersonal(const Data::PersonalInfo &data) override;
|
|
|
|
|
|
|
|
Result writeUserpicsStart(const Data::UserpicsInfo &data) override;
|
|
|
|
Result writeUserpicsSlice(const Data::UserpicsSlice &data) override;
|
|
|
|
Result writeUserpicsEnd() override;
|
|
|
|
|
|
|
|
Result writeContactsList(const Data::ContactsList &data) override;
|
|
|
|
|
|
|
|
Result writeSessionsList(const Data::SessionsList &data) override;
|
|
|
|
|
2018-06-24 00:33:47 +00:00
|
|
|
Result writeOtherData(const Data::File &data) override;
|
|
|
|
|
2018-06-23 20:27:41 +00:00
|
|
|
Result writeDialogsStart(const Data::DialogsInfo &data) override;
|
|
|
|
Result writeDialogStart(const Data::DialogInfo &data) override;
|
|
|
|
Result writeDialogSlice(const Data::MessagesSlice &data) override;
|
|
|
|
Result writeDialogEnd() override;
|
|
|
|
Result writeDialogsEnd() override;
|
|
|
|
|
|
|
|
Result writeLeftChannelsStart(const Data::DialogsInfo &data) override;
|
|
|
|
Result writeLeftChannelStart(const Data::DialogInfo &data) override;
|
|
|
|
Result writeLeftChannelSlice(const Data::MessagesSlice &data) override;
|
|
|
|
Result writeLeftChannelEnd() override;
|
|
|
|
Result writeLeftChannelsEnd() override;
|
|
|
|
|
|
|
|
Result finish() override;
|
|
|
|
|
|
|
|
QString mainFilePath() override;
|
|
|
|
|
|
|
|
~HtmlWriter();
|
|
|
|
|
|
|
|
private:
|
2018-06-29 21:10:21 +00:00
|
|
|
using Context = details::HtmlContext;
|
|
|
|
using UserpicData = details::UserpicData;
|
2018-07-03 23:09:25 +00:00
|
|
|
using MediaData = details::MediaData;
|
2018-06-23 20:27:41 +00:00
|
|
|
class Wrap;
|
2018-07-03 23:09:25 +00:00
|
|
|
struct MessageInfo;
|
2018-06-23 20:27:41 +00:00
|
|
|
|
2018-06-29 21:10:21 +00:00
|
|
|
[[nodiscard]] Result copyFile(
|
2018-06-23 20:27:41 +00:00
|
|
|
const QString &source,
|
|
|
|
const QString &relativePath) const;
|
|
|
|
|
|
|
|
QString mainFileRelativePath() const;
|
|
|
|
QString pathWithRelativePath(const QString &path) const;
|
|
|
|
std::unique_ptr<Wrap> fileWithRelativePath(const QString &path) const;
|
2018-06-24 11:43:57 +00:00
|
|
|
QString messagesFile(int index) const;
|
2018-06-23 20:27:41 +00:00
|
|
|
|
2018-06-29 21:10:21 +00:00
|
|
|
[[nodiscard]] Result writeSavedContacts(const Data::ContactsList &data);
|
|
|
|
[[nodiscard]] Result writeFrequentContacts(const Data::ContactsList &data);
|
2018-06-23 20:27:41 +00:00
|
|
|
|
2018-06-29 21:10:21 +00:00
|
|
|
[[nodiscard]] Result writeSessions(const Data::SessionsList &data);
|
|
|
|
[[nodiscard]] Result writeWebSessions(const Data::SessionsList &data);
|
2018-06-23 20:27:41 +00:00
|
|
|
|
2018-06-29 21:10:21 +00:00
|
|
|
[[nodiscard]] Result writeChatsStart(
|
2018-06-23 20:27:41 +00:00
|
|
|
const Data::DialogsInfo &data,
|
|
|
|
const QByteArray &listName,
|
2018-07-03 23:09:25 +00:00
|
|
|
const QByteArray &buttonClass,
|
2018-06-23 21:08:03 +00:00
|
|
|
const QByteArray &about,
|
2018-06-23 20:27:41 +00:00
|
|
|
const QString &fileName);
|
2018-06-29 21:10:21 +00:00
|
|
|
[[nodiscard]] Result writeChatStart(const Data::DialogInfo &data);
|
|
|
|
[[nodiscard]] Result writeChatSlice(const Data::MessagesSlice &data);
|
|
|
|
[[nodiscard]] Result writeChatEnd();
|
|
|
|
[[nodiscard]] Result writeChatsEnd();
|
|
|
|
[[nodiscard]] Result switchToNextChatFile(int index);
|
|
|
|
|
|
|
|
void pushSection(
|
|
|
|
int priority,
|
|
|
|
const QByteArray &label,
|
|
|
|
const QByteArray &type,
|
|
|
|
int count,
|
|
|
|
const QString &path);
|
|
|
|
[[nodiscard]] Result writeSections();
|
|
|
|
|
|
|
|
[[nodiscard]] Result writeDefaultPersonal(
|
|
|
|
const Data::PersonalInfo &data);
|
|
|
|
[[nodiscard]] Result writeDelayedPersonal(const QString &userpicPath);
|
|
|
|
[[nodiscard]] Result writePreparedPersonal(
|
|
|
|
const Data::PersonalInfo &data,
|
|
|
|
const QString &userpicPath);
|
|
|
|
void pushUserpicsSection();
|
|
|
|
|
|
|
|
[[nodiscard]] QString userpicsFilePath() const;
|
2018-06-23 20:27:41 +00:00
|
|
|
|
|
|
|
Settings _settings;
|
2018-06-24 02:06:11 +00:00
|
|
|
Environment _environment;
|
2018-06-23 20:27:41 +00:00
|
|
|
Stats *_stats = nullptr;
|
|
|
|
|
2018-06-29 21:10:21 +00:00
|
|
|
struct SavedSection;
|
|
|
|
std::vector<SavedSection> _savedSections;
|
|
|
|
|
2018-06-23 20:27:41 +00:00
|
|
|
std::unique_ptr<Wrap> _summary;
|
2018-06-29 21:10:21 +00:00
|
|
|
bool _summaryNeedDivider = false;
|
|
|
|
bool _haveSections = false;
|
|
|
|
|
|
|
|
int _selfColorIndex = 0;
|
|
|
|
std::unique_ptr<Data::PersonalInfo> _delayedPersonalInfo;
|
2018-06-23 20:27:41 +00:00
|
|
|
|
|
|
|
int _userpicsCount = 0;
|
|
|
|
std::unique_ptr<Wrap> _userpics;
|
|
|
|
|
|
|
|
int _dialogsCount = 0;
|
|
|
|
int _dialogIndex = 0;
|
2018-06-29 21:10:21 +00:00
|
|
|
QString _dialogsRelativePath;
|
2018-06-23 20:27:41 +00:00
|
|
|
Data::DialogInfo _dialog;
|
|
|
|
|
|
|
|
int _messagesCount = 0;
|
2018-07-03 23:09:25 +00:00
|
|
|
std::unique_ptr<MessageInfo> _lastMessageInfo;
|
2018-07-03 14:15:53 +00:00
|
|
|
int _dateMessageId = 0;
|
2018-06-23 20:27:41 +00:00
|
|
|
std::unique_ptr<Wrap> _chats;
|
|
|
|
std::unique_ptr<Wrap> _chat;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Output
|
|
|
|
} // namespace Export
|