From 9f8d61ab2f01a50ca508e0349b167dd14e2e98af Mon Sep 17 00:00:00 2001 From: John Preston Date: Sat, 23 Jun 2018 00:53:03 +0100 Subject: [PATCH] Add information about saved data. --- Telegram/Resources/langs/lang.strings | 3 ++ .../export/data/export_data_about.h | 35 +++++++++++++++++++ .../export/output/export_output_json.cpp | 12 +++++++ .../export/output/export_output_text.cpp | 14 ++++++-- Telegram/SourceFiles/export/view/export.style | 6 ++++ .../export/view/export_view_settings.cpp | 32 ++++++++++++++--- .../export/view/export_view_settings.h | 5 +++ Telegram/gyp/lib_export.gyp | 1 + 8 files changed, 102 insertions(+), 6 deletions(-) create mode 100644 Telegram/SourceFiles/export/data/export_data_about.h diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index ad2e207b5e23aa..31043d9b4b79f7 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -1657,8 +1657,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_export_title" = "Export Personal Data"; "lng_export_progress_title" = "Exporting personal data"; "lng_export_option_info" = "Personal information"; +"lng_export_option_info_about" = "Your chosen screen name, username and profile pictures are public and available to everyone. You don't have to supply your real name."; "lng_export_option_contacts" = "Contacts list"; +"lng_export_option_contacts_about" = "To let you connect with friends across all your devices, your contacts are continuosly synced with Telegram. You can disable syncing or delete your stored contacts in Settings > Privacy & Security."; "lng_export_option_sessions" = "Sessions list"; +"lng_export_option_sessions_about" = "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_header_chats" = "Chat export settings"; "lng_export_option_personal_chats" = "Personal chats"; "lng_export_option_bot_chats" = "Bot chats"; diff --git a/Telegram/SourceFiles/export/data/export_data_about.h b/Telegram/SourceFiles/export/data/export_data_about.h new file mode 100644 index 00000000000000..d9c4690416cfd3 --- /dev/null +++ b/Telegram/SourceFiles/export/data/export_data_about.h @@ -0,0 +1,35 @@ +/* +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/data/export_data_types.h" + +namespace Export { +namespace Data { + +inline Utf8String AboutPersonalInfo() { + return "Your chosen screen name, username and profile pictures " + "are public and available to everyone. " + "You don't have to supply your real name."; +} + +inline Utf8String AboutContacts() { + return "To let you connect with friends across all your devices, " + "your contacts are continuosly synced with Telegram. " + "You can disable syncing or delete your stored contacts " + "in Settings > Privacy & Security."; +} + +inline Utf8String AboutSessions() { + return "We store this to display your connected devices " + "in Settings > Privacy & Security > Active Sessions. " + "Terminating a session removes this data from Telegram servers."; +} + +} // namespace Data +} // namespace Export diff --git a/Telegram/SourceFiles/export/output/export_output_json.cpp b/Telegram/SourceFiles/export/output/export_output_json.cpp index 70ffe02bcdfbbb..adc12f4098cbd9 100644 --- a/Telegram/SourceFiles/export/output/export_output_json.cpp +++ b/Telegram/SourceFiles/export/output/export_output_json.cpp @@ -9,6 +9,7 @@ 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 @@ -615,6 +616,7 @@ Result JsonWriter::writePersonal(const Data::PersonalInfo &data) { return _output->writeBlock( prepareObjectItemStart("personal_information") + SerializeObject(_context, { + { "about", SerializeString(Data::AboutPersonalInfo()) }, { "first_name", SerializeString(info.firstName) }, { "last_name", SerializeString(info.lastName) }, { @@ -687,6 +689,10 @@ Result JsonWriter::writeSavedContacts(const Data::ContactsList &data) { Expects(_output != nullptr); auto block = prepareObjectItemStart("contacts"); + block.append(pushNesting(Context::kObject)); + block.append(prepareObjectItemStart("about")); + block.append(SerializeString(Data::AboutContacts())); + block.append(prepareObjectItemStart("list")); block.append(pushNesting(Context::kArray)); for (const auto index : Data::SortedContactsIndices(data)) { const auto &contact = data.list[index]; @@ -711,6 +717,7 @@ Result JsonWriter::writeSavedContacts(const Data::ContactsList &data) { })); } } + block.append(popNesting()); return _output->writeBlock(block + popNesting()); } @@ -765,6 +772,10 @@ Result JsonWriter::writeSessions(const Data::SessionsList &data) { Expects(_output != nullptr); auto block = prepareObjectItemStart("sessions"); + block.append(pushNesting(Context::kObject)); + block.append(prepareObjectItemStart("about")); + block.append(SerializeString(Data::AboutSessions())); + block.append(prepareObjectItemStart("list")); block.append(pushNesting(Context::kArray)); for (const auto &session : data.list) { block.append(prepareArrayItemStart()); @@ -787,6 +798,7 @@ Result JsonWriter::writeSessions(const Data::SessionsList &data) { { "created", SerializeDate(session.created) }, })); } + block.append(popNesting()); return _output->writeBlock(block + popNesting()); } diff --git a/Telegram/SourceFiles/export/output/export_output_text.cpp b/Telegram/SourceFiles/export/output/export_output_text.cpp index dba99d442ac49f..35245bb40271f3 100644 --- a/Telegram/SourceFiles/export/output/export_output_text.cpp +++ b/Telegram/SourceFiles/export/output/export_output_text.cpp @@ -9,6 +9,7 @@ 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 @@ -457,6 +458,9 @@ Result TextWriter::writePersonal(const Data::PersonalInfo &data) { { "Username", FormatUsername(data.user.username) }, { "Bio", data.bio }, }) + + kLineBreak + + Data::AboutPersonalInfo() + + kLineBreak + kLineBreak; return _summary->writeBlock(serialized); } @@ -545,7 +549,10 @@ Result TextWriter::writeSavedContacts(const Data::ContactsList &data) { })); } } - const auto full = JoinList(kLineBreak, list); + const auto full = Data::AboutContacts() + + kLineBreak + + kLineBreak + + JoinList(kLineBreak, list); if (const auto result = file->writeBlock(full); !result) { return result; } @@ -663,7 +670,10 @@ Result TextWriter::writeSessions(const Data::SessionsList &data) { { "Created", Data::FormatDateTime(session.created) }, })); } - const auto full = JoinList(kLineBreak, list); + const auto full = Data::AboutSessions() + + kLineBreak + + kLineBreak + + JoinList(kLineBreak, list); if (const auto result = file->writeBlock(full); !result) { return result; } diff --git a/Telegram/SourceFiles/export/view/export.style b/Telegram/SourceFiles/export/view/export.style index 1dec02d28847e6..1fd397ea14ae69 100644 --- a/Telegram/SourceFiles/export/view/export.style +++ b/Telegram/SourceFiles/export/view/export.style @@ -43,6 +43,12 @@ exportLocationLabel: FlatLabel(boxLabel) { } exportLocationPadding: margins(22px, 8px, 22px, 8px); +exportAboutOptionLabel: FlatLabel(defaultFlatLabel) { + textFg: windowSubTextFg; + minWidth: 175px; +} +exportAboutOptionPadding: margins(22px, 0px, 22px, 16px); + exportErrorLabel: FlatLabel(boxLabel) { minWidth: 175px; align: align(top); diff --git a/Telegram/SourceFiles/export/view/export_view_settings.cpp b/Telegram/SourceFiles/export/view/export_view_settings.cpp index 8ca45c9a287494..88ced9f3ff7022 100644 --- a/Telegram/SourceFiles/export/view/export_view_settings.cpp +++ b/Telegram/SourceFiles/export/view/export_view_settings.cpp @@ -95,12 +95,21 @@ void SettingsWidget::setupContent() { } void SettingsWidget::setupOptions(not_null container) { - addOption( + addOptionWithAbout( container, lng_export_option_info, - Type::PersonalInfo | Type::Userpics); - addOption(container, lng_export_option_contacts, Type::Contacts); - addOption(container, lng_export_option_sessions, Type::Sessions); + Type::PersonalInfo | Type::Userpics, + lng_export_option_info_about); + addOptionWithAbout( + container, + lng_export_option_contacts, + Type::Contacts, + lng_export_option_contacts_about); + addOptionWithAbout( + container, + lng_export_option_sessions, + Type::Sessions, + lng_export_option_sessions_about); addHeader(container, lng_export_header_chats); addOption( container, @@ -311,6 +320,21 @@ not_null SettingsWidget::addOption( return checkbox; } +void SettingsWidget::addOptionWithAbout( + not_null container, + LangKey key, + Types types, + LangKey about) { + addOption(container, key, types); + const auto label = container->add( + object_ptr( + container, + lang(about), + Ui::FlatLabel::InitType::Simple, + st::exportAboutOptionLabel), + st::exportAboutOptionPadding); +} + void SettingsWidget::addChatOption( not_null container, LangKey key, diff --git a/Telegram/SourceFiles/export/view/export_view_settings.h b/Telegram/SourceFiles/export/view/export_view_settings.h index 227712c8faddd1..34c804afa329dd 100644 --- a/Telegram/SourceFiles/export/view/export_view_settings.h +++ b/Telegram/SourceFiles/export/view/export_view_settings.h @@ -51,6 +51,11 @@ class SettingsWidget : public Ui::RpWidget { not_null container, LangKey key, Types types); + void addOptionWithAbout( + not_null container, + LangKey key, + Types types, + LangKey about); void addChatOption( not_null container, LangKey key, diff --git a/Telegram/gyp/lib_export.gyp b/Telegram/gyp/lib_export.gyp index 5840dd1ee27ee8..b56db601b2229a 100644 --- a/Telegram/gyp/lib_export.gyp +++ b/Telegram/gyp/lib_export.gyp @@ -56,6 +56,7 @@ '<(src_loc)/export/export_controller.h', '<(src_loc)/export/export_settings.cpp', '<(src_loc)/export/export_settings.h', + '<(src_loc)/export/data/export_data_about.h', '<(src_loc)/export/data/export_data_types.cpp', '<(src_loc)/export/data/export_data_types.h', '<(src_loc)/export/output/export_output_abstract.cpp',