Skip to content

Commit

Permalink
Move export descriptions to lang.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Jun 24, 2018
1 parent b9250ed commit 2522e66
Show file tree
Hide file tree
Showing 15 changed files with 130 additions and 132 deletions.
7 changes: 7 additions & 0 deletions Telegram/Resources/langs/lang.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1715,6 +1715,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_export_suggest_title" = "Data export ready";
"lng_export_suggest_text" = "You can now download the data you requested. Start exporting data?";
"lng_export_suggest_cancel" = "Not now";
"lng_export_about_telegram" = "Here is all the data you requested. Remember: we don’t use your data for ad targeting, we don’t sell it to others, and we’re not part of any “family of companies.”\n\nTelegram only keeps the information it needs to function as a feature-rich cloud service – for example, your cloud chats so that you can access them from any devices without using third-party backups, or your contacts so that you can rely on your existing social graph when messaging people on Telegram.\n\nCheck out Settings > Privacy & Security on Telegram's mobile apps for relevant settings.";
"lng_export_about_contacts" = "If you allow access, your contacts are continuously synced with Telegram. Thanks to this, you can easily switch to Telegram without losing your existing social graph – and connect with friends across all your devices. We use data about your contacts to let you know when they join Telegram. We also use it to make sure that you see the names you have in your phone book instead of the screen names people choose for themselves.\n\nYou can disable contacts syncing or delete your stored contacts in Settings > Privacy & Security on Telegram's mobile apps.";
"lng_export_about_frequent" = "This rating shows which people you are likelier to message frequently. Telegram uses this data to populate the 'People' box at the top of the Search section. The rating is also calculated for inline bots so that the app can suggest you the bots you are most likely to use in the attachment menu (or when you start a new message with \"@\").\n\nTo delete this data, go to Settings > Privacy & Security and disable 'Suggest Frequent Contacts' (requires Telegram for iOS v.4.8.3 or Telegram for Android v.4.8.10 or higher). See this page for more information: https://telegram.org/faq_export";
"lng_export_about_sessions" = "We store this to display your connected devices in Settings > Privacy & Security > Active Sessions. Terminating a session removes this data from Telegram servers.";
"lng_export_about_web_sessions" = "We store this to display you the websites where you used Telegram to log in in Settings > Privacy & Security > Active Sessions. Disconnecting a website removes this data from Telegram servers.";
"lng_export_about_chats" = "This page lists all chats from this export and where to look for their data.";
"lng_export_about_left_chats" = "This page lists all supergroups and channels from this export that you've left and where to look for their data.";

// Wnd specific

Expand Down
85 changes: 0 additions & 85 deletions Telegram/SourceFiles/export/data/export_data_about.h

This file was deleted.

35 changes: 25 additions & 10 deletions Telegram/SourceFiles/export/export_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ class Controller {
//void cancelUnconfirmedPassword();

// Processing step.
void startExport(const Settings &settings);
void startExport(
const Settings &settings,
const Environment &environment);
void cancelExportFast();

private:
Expand All @@ -51,6 +53,7 @@ class Controller {
void fillSubstepsInSteps(const ApiWrap::StartInfo &info);
void exportNext();
void initialize();
void initialized(const ApiWrap::StartInfo &info);
void collectLeftChannels();
void collectDialogsList();
void exportPersonalInfo();
Expand Down Expand Up @@ -92,6 +95,7 @@ class Controller {

ApiWrap _api;
Settings _settings;
Environment _environment;

Data::DialogsInfo _leftChannelsInfo;
int _leftChannelIndex = -1;
Expand Down Expand Up @@ -219,11 +223,14 @@ bool Controller::ioCatchError(Output::Result result) {
//
//}

void Controller::startExport(const Settings &settings) {
void Controller::startExport(
const Settings &settings,
const Environment &environment) {
if (!_settings.path.isEmpty()) {
return;
}
_settings = base::duplicate(settings);
_environment = environment;

_settings.path = Output::NormalizePath(_settings.path);
_writer = Output::CreateWriter(_settings.format);
Expand Down Expand Up @@ -339,14 +346,18 @@ void Controller::exportNext() {
void Controller::initialize() {
setState(stateInitializing());
_api.startExport(_settings, &_stats, [=](ApiWrap::StartInfo info) {
if (ioCatchError(_writer->start(_settings, &_stats))) {
return;
}
fillSubstepsInSteps(info);
exportNext();
initialized(info);
});
}

void Controller::initialized(const ApiWrap::StartInfo &info) {
if (ioCatchError(_writer->start(_settings, _environment, &_stats))) {
return;
}
fillSubstepsInSteps(info);
exportNext();
}

void Controller::collectLeftChannels() {
setState(stateLeftChannelsList(0));
_api.requestLeftChannelsList([=](int count) {
Expand Down Expand Up @@ -707,11 +718,13 @@ rpl::producer<State> ControllerWrap::state() const {
// });
//}

void ControllerWrap::startExport(const Settings &settings) {
void ControllerWrap::startExport(
const Settings &settings,
const Environment &environment) {
LOG(("Export Info: Started export to '%1'.").arg(settings.path));

_wrapped.with([=](Controller &controller) {
controller.startExport(settings);
controller.startExport(settings, environment);
});
}

Expand All @@ -727,6 +740,8 @@ rpl::lifetime &ControllerWrap::lifetime() {
return _lifetime;
}

ControllerWrap::~ControllerWrap() = default;
ControllerWrap::~ControllerWrap() {
LOG(("Export Info: Controller destroyed."));
}

} // namespace Export
5 changes: 4 additions & 1 deletion Telegram/SourceFiles/export/export_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace Export {

class Controller;
struct Settings;
struct Environment;

struct PasswordCheckState {
QString hint;
Expand Down Expand Up @@ -117,7 +118,9 @@ class ControllerWrap {
//void cancelUnconfirmedPassword();

// Processing step.
void startExport(const Settings &settings);
void startExport(
const Settings &settings,
const Environment &environment);
void cancelExportFast();

rpl::lifetime &lifetime();
Expand Down
12 changes: 11 additions & 1 deletion Telegram/SourceFiles/export/export_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ struct Settings {
friend inline constexpr auto is_flag_type(Type) { return true; };

QString path;
QString internalLinksDomain;
Output::Format format = Output::Format();

Types types = DefaultTypes();
Expand All @@ -95,4 +94,15 @@ struct Settings {

};

struct Environment {
QString internalLinksDomain;
QByteArray aboutTelegram;
QByteArray aboutContacts;
QByteArray aboutFrequent;
QByteArray aboutSessions;
QByteArray aboutWebSessions;
QByteArray aboutChats;
QByteArray aboutLeftChats;
};

} // namespace Export
13 changes: 11 additions & 2 deletions Telegram/SourceFiles/export/output/export_output_abstract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,20 @@ std::unique_ptr<AbstractWriter> CreateWriter(Format format) {
Stats AbstractWriter::produceTestExample(const QString &path) {
auto result = Stats();
const auto folder = QDir(path).absolutePath();
auto environment = Environment();
environment.internalLinksDomain = "https://t.me/";
environment.aboutTelegram = "About Telegram";
environment.aboutContacts = "About contacts";
environment.aboutFrequent = "About frequent";
environment.aboutSessions = "About sessions";
environment.aboutWebSessions = "About web sessions";
environment.aboutChats = "About chats";
environment.aboutLeftChats = "About left chats";

auto settings = Settings();
settings.format = format();
settings.path = (folder.endsWith('/') ? folder : (folder + '/'))
+ "ExportExample/";
settings.internalLinksDomain = "https://t.me/";
settings.types = Settings::Type::AllMask;
settings.fullChats = Settings::Type::AllMask
& ~(Settings::Type::PublicChannels | Settings::Type::PublicGroups);
Expand All @@ -74,7 +83,7 @@ Stats AbstractWriter::produceTestExample(const QString &path) {
Assert(result.isSuccess());
};

check(start(settings, &result));
check(start(settings, environment, &result));

const auto counter = [&] {
static auto GlobalCounter = 0;
Expand Down
2 changes: 2 additions & 0 deletions Telegram/SourceFiles/export/output/export_output_abstract.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ struct File;
} // namespace Data

struct Settings;
struct Environment;

namespace Output {

Expand All @@ -44,6 +45,7 @@ class AbstractWriter {

[[nodiscard]] virtual Result start(
const Settings &settings,
const Environment &environment,
Stats *stats) = 0;

[[nodiscard]] virtual Result writePersonal(
Expand Down
24 changes: 14 additions & 10 deletions Telegram/SourceFiles/export/output/export_output_html.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ For license and copyright information please follow this link:

#include "export/output/export_output_result.h"
#include "export/data/export_data_types.h"
#include "export/data/export_data_about.h"
#include "core/utils.h"

#include <QtCore/QFile>
Expand Down Expand Up @@ -681,10 +680,14 @@ HtmlWriter::Wrap::~Wrap() {

HtmlWriter::HtmlWriter() = default;

Result HtmlWriter::start(const Settings &settings, Stats *stats) {
Result HtmlWriter::start(
const Settings &settings,
const Environment &environment,
Stats *stats) {
Expects(settings.path.endsWith('/'));

_settings = base::duplicate(settings);
_environment = environment;
_stats = stats;
_summary = fileWithRelativePath(mainFileRelativePath());

Expand All @@ -699,7 +702,7 @@ Result HtmlWriter::start(const Settings &settings, Stats *stats) {
return result;
}
return _summary->writeBlock(
MakeLinks(SerializeString(Data::AboutTelegram()))
MakeLinks(SerializeString(_environment.aboutTelegram))
+ kLineBreak
+ kLineBreak);
}
Expand Down Expand Up @@ -833,7 +836,7 @@ Result HtmlWriter::writeSavedContacts(const Data::ContactsList &data) {
}));
}
}
const auto full = MakeLinks(SerializeString(Data::AboutContacts()))
const auto full = MakeLinks(SerializeString(_environment.aboutContacts))
+ kLineBreak
+ kLineBreak
+ JoinList(kLineBreak, list);
Expand Down Expand Up @@ -922,7 +925,7 @@ Result HtmlWriter::writeFrequentContacts(const Data::ContactsList &data) {
writeList(data.correspondents, "People");
writeList(data.inlineBots, "Inline bots");
writeList(data.phoneCalls, "Calls");
const auto full = MakeLinks(SerializeString(Data::AboutFrequent()))
const auto full = MakeLinks(SerializeString(_environment.aboutFrequent))
+ kLineBreak
+ kLineBreak
+ JoinList(kLineBreak, list);
Expand Down Expand Up @@ -988,7 +991,7 @@ Result HtmlWriter::writeSessions(const Data::SessionsList &data) {
{ "Created", Data::FormatDateTime(session.created) },
}));
}
const auto full = MakeLinks(SerializeString(Data::AboutSessions()))
const auto full = MakeLinks(SerializeString(_environment.aboutSessions))
+ kLineBreak
+ kLineBreak
+ JoinList(kLineBreak, list);
Expand Down Expand Up @@ -1046,7 +1049,8 @@ Result HtmlWriter::writeWebSessions(const Data::SessionsList &data) {
},
}));
}
const auto full = MakeLinks(SerializeString(Data::AboutWebSessions()))
const auto full = MakeLinks(
SerializeString(_environment.aboutWebSessions))
+ kLineBreak
+ kLineBreak
+ JoinList(kLineBreak, list);
Expand Down Expand Up @@ -1080,7 +1084,7 @@ Result HtmlWriter::writeDialogsStart(const Data::DialogsInfo &data) {
return writeChatsStart(
data,
"Chats",
Data::AboutChats(),
_environment.aboutChats,
"lists/chats.html");
}

Expand All @@ -1104,7 +1108,7 @@ Result HtmlWriter::writeLeftChannelsStart(const Data::DialogsInfo &data) {
return writeChatsStart(
data,
"Left chats",
Data::AboutLeftChats(),
_environment.aboutLeftChats,
"lists/left_chats.html");
}

Expand Down Expand Up @@ -1178,7 +1182,7 @@ Result HtmlWriter::writeChatSlice(const Data::MessagesSlice &data) {
[&](QString path) { return _chat->relativePath(path); },
message,
data.peers,
_settings.internalLinksDomain));
_environment.internalLinksDomain));
}
const auto full = _chat->empty()
? JoinList(kLineBreak, list)
Expand Down
6 changes: 5 additions & 1 deletion Telegram/SourceFiles/export/output/export_output_html.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ class HtmlWriter : public AbstractWriter {
return Format::Html;
}

Result start(const Settings &settings, Stats *stats) override;
Result start(
const Settings &settings,
const Environment &environment,
Stats *stats) override;

Result writePersonal(const Data::PersonalInfo &data) override;

Expand Down Expand Up @@ -83,6 +86,7 @@ class HtmlWriter : public AbstractWriter {
Result writeChatsEnd();

Settings _settings;
Environment _environment;
Stats *_stats = nullptr;

std::unique_ptr<Wrap> _summary;
Expand Down
Loading

0 comments on commit 2522e66

Please sign in to comment.