From 266102df2fe48804105f95c680bead4158fab41d Mon Sep 17 00:00:00 2001 From: John Preston Date: Sun, 24 Jun 2018 14:19:49 +0100 Subject: [PATCH] Some phrases fixed, some logs added. --- Telegram/Resources/langs/lang.strings | 12 ++-- .../SourceFiles/export/export_api_wrap.cpp | 9 ++- Telegram/SourceFiles/export/export_settings.h | 1 - .../export/output/export_output_html.cpp | 7 ++- .../export/output/export_output_json.cpp | 6 +- .../export/output/export_output_text.cpp | 7 ++- .../export/view/export_view_settings.cpp | 10 ++-- Telegram/SourceFiles/mtproto/mtp_instance.cpp | 55 +++++++++++-------- 8 files changed, 64 insertions(+), 43 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index a88544c3c0f83..16505d920afdc 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -1661,10 +1661,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_export_option_contacts" = "Contacts list"; "lng_export_option_contacts_about" = "If you allow access, contacts are continuously synced with Telegram. You can adjust this in Settings > Privacy & Security on mobile devices."; "lng_export_option_sessions" = "Active sessions"; -"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_option_sessions_about" = "We store this to display your connected devices in Settings > Privacy & Security > Active Sessions."; "lng_export_header_other" = "Other"; "lng_export_option_other" = "Miscellaneous data"; -"lng_export_option_other_about" = "Other types of data not mentioned above. (beta)"; +"lng_export_option_other_about" = "Other types of data not mentioned above (beta)."; "lng_export_header_chats" = "Chat export settings"; "lng_export_option_personal_chats" = "Personal chats"; "lng_export_option_bot_chats" = "Bot chats"; @@ -1708,7 +1708,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_export_total_size" = "Total size: {size}."; "lng_export_folder" = "Choose export folder"; "lng_export_invalid" = "Sorry, you have started a new data export, so this data export is now cancelled."; -"lng_export_delay" = "Sorry, for security reasons, you will be able to begin downloading your data in {hours}. We have notified all your devices about the export request to make sure it's authorized and give you time to react if it's not.\n\nPlease come back on {date} and repeat the request using the same device."; +"lng_export_delay" = "Sorry, for security reasons, you will be able to begin downloading your data in {hours}. We have notified all your devices about the export request to make sure it's authorized and to give you time to react if it's not.\n\nPlease come back on {date} and repeat the request using the same device."; "lng_export_delay_less_than_hour" = "less than an hour"; "lng_export_delay_hours#one" = "{count} hour"; "lng_export_delay_hours#other" = "{count} hours"; @@ -1718,10 +1718,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "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_sessions" = "We store session info to display your connected devices in Settings > Privacy & Security > Active Sessions."; +"lng_export_about_web_sessions" = "We store web login info 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."; +"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.\n\nNote that when you leave a channel or supergroup you've created, you have the option to either delete it, or simply leave (in case you want to rejoin later, or keep the community alive despite not being a member)."; // Wnd specific diff --git a/Telegram/SourceFiles/export/export_api_wrap.cpp b/Telegram/SourceFiles/export/export_api_wrap.cpp index 58d39e05d2f8c..987bad86bc770 100644 --- a/Telegram/SourceFiles/export/export_api_wrap.cpp +++ b/Telegram/SourceFiles/export/export_api_wrap.cpp @@ -491,15 +491,18 @@ void ApiWrap::requestDialogsList( } void ApiWrap::startMainSession(FnMut done) { + using Type = Settings::Type; const auto sizeLimit = _settings->media.sizeLimit; - const auto hasFiles = (_settings->media.types != 0) && (sizeLimit > 0); + const auto hasFiles = ((_settings->media.types != 0) && (sizeLimit > 0)) + || (_settings->types & Type::Userpics); - using Type = Settings::Type; using Flag = MTPaccount_InitTakeoutSession::Flag; const auto flags = Flag(0) | (_settings->types & Type::Contacts ? Flag::f_contacts : Flag(0)) | (hasFiles ? Flag::f_files : Flag(0)) - | (sizeLimit < kFileMaxSize ? Flag::f_file_max_size : Flag(0)) + | ((hasFiles && sizeLimit < kFileMaxSize) + ? Flag::f_file_max_size + : Flag(0)) | (_settings->types & (Type::PersonalChats | Type::BotChats) ? Flag::f_message_users : Flag(0)) diff --git a/Telegram/SourceFiles/export/export_settings.h b/Telegram/SourceFiles/export/export_settings.h index fc4afb28a33b9..cd14698cdb60b 100644 --- a/Telegram/SourceFiles/export/export_settings.h +++ b/Telegram/SourceFiles/export/export_settings.h @@ -82,7 +82,6 @@ struct Settings { return Type::PersonalInfo | Type::Userpics | Type::Contacts - | Type::Sessions | Type::PersonalChats | Type::PrivateGroups; } diff --git a/Telegram/SourceFiles/export/output/export_output_html.cpp b/Telegram/SourceFiles/export/output/export_output_html.cpp index 9a795f42fe353..5c35060ee895e 100644 --- a/Telegram/SourceFiles/export/output/export_output_html.cpp +++ b/Telegram/SourceFiles/export/output/export_output_html.cpp @@ -295,7 +295,9 @@ QByteArray SerializeMessage( ? QByteArray() : SerializeString(name + ' '); switch (file.skipReason) { - case SkipReason::Unavailable: return pre + "(file unavailable)"; + case SkipReason::Unavailable: + return pre + "(" + label + " unavailable, " + "please try again later)"; case SkipReason::FileSize: return pre + "(" + label + " exceeds maximum size. " "Change data exporting settings to download.)"; @@ -764,7 +766,8 @@ Result HtmlWriter::writeUserpicsSlice(const Data::UserpicsSlice &data) { || file.skipReason != SkipReason::None); const auto path = [&]() -> Data::Utf8String { switch (file.skipReason) { - case SkipReason::Unavailable: return "(file unavailable)"; + case SkipReason::Unavailable: + return "(Photo unavailable, please try again later)"; case SkipReason::FileSize: return "(Photo exceeds maximum size. " "Change data exporting settings to download.)"; diff --git a/Telegram/SourceFiles/export/output/export_output_json.cpp b/Telegram/SourceFiles/export/output/export_output_json.cpp index 8ae76dfca7eb1..4a051ed3adcec 100644 --- a/Telegram/SourceFiles/export/output/export_output_json.cpp +++ b/Telegram/SourceFiles/export/output/export_output_json.cpp @@ -329,7 +329,8 @@ QByteArray SerializeMessage( push(label, [&]() -> QByteArray { const auto pre = name.isEmpty() ? QByteArray() : name + ' '; switch (file.skipReason) { - case SkipReason::Unavailable: return pre + "(file unavailable)"; + case SkipReason::Unavailable: + return pre + "(File unavailable, please try again later)"; case SkipReason::FileSize: return pre + "(File exceeds maximum size. " "Change data exporting settings to download.)"; @@ -667,7 +668,8 @@ Result JsonWriter::writeUserpicsSlice(const Data::UserpicsSlice &data) { || file.skipReason != SkipReason::None); const auto path = [&]() -> Data::Utf8String { switch (file.skipReason) { - case SkipReason::Unavailable: return "(file unavailable)"; + case SkipReason::Unavailable: + return "(Photo unavailable, please try again later)"; case SkipReason::FileSize: return "(Photo exceeds maximum size. " "Change data exporting settings to download.)"; diff --git a/Telegram/SourceFiles/export/output/export_output_text.cpp b/Telegram/SourceFiles/export/output/export_output_text.cpp index c8cda3b1c93e1..b5b4e6e2a1aa6 100644 --- a/Telegram/SourceFiles/export/output/export_output_text.cpp +++ b/Telegram/SourceFiles/export/output/export_output_text.cpp @@ -197,7 +197,9 @@ QByteArray SerializeMessage( push(label, [&]() -> QByteArray { const auto pre = name.isEmpty() ? QByteArray() : name + ' '; switch (file.skipReason) { - case SkipReason::Unavailable: return pre + "(file unavailable)"; + case SkipReason::Unavailable: + return pre + "(" + label + " unavailable, " + "please try again later)"; case SkipReason::FileSize: return pre + "(" + label + " exceeds maximum size. " "Change data exporting settings to download.)"; @@ -506,7 +508,8 @@ Result TextWriter::writeUserpicsSlice(const Data::UserpicsSlice &data) { || file.skipReason != SkipReason::None); const auto path = [&]() -> Data::Utf8String { switch (file.skipReason) { - case SkipReason::Unavailable: return "(file unavailable)"; + case SkipReason::Unavailable: + return "(Photo unavailable, please try again later)"; case SkipReason::FileSize: return "(Photo exceeds maximum size. " "Change data exporting settings to download.)"; diff --git a/Telegram/SourceFiles/export/view/export_view_settings.cpp b/Telegram/SourceFiles/export/view/export_view_settings.cpp index b9ee8f2045503..37050b426c068 100644 --- a/Telegram/SourceFiles/export/view/export_view_settings.cpp +++ b/Telegram/SourceFiles/export/view/export_view_settings.cpp @@ -105,11 +105,6 @@ void SettingsWidget::setupOptions(not_null 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, @@ -136,6 +131,11 @@ void SettingsWidget::setupOptions(not_null container) { setupMediaOptions(container); addHeader(container, lng_export_header_other); + addOptionWithAbout( + container, + lng_export_option_sessions, + Type::Sessions, + lng_export_option_sessions_about); addOptionWithAbout( container, lng_export_option_other, diff --git a/Telegram/SourceFiles/mtproto/mtp_instance.cpp b/Telegram/SourceFiles/mtproto/mtp_instance.cpp index 02884d1aa2b0a..ea35f22353cd8 100644 --- a/Telegram/SourceFiles/mtproto/mtp_instance.cpp +++ b/Telegram/SourceFiles/mtproto/mtp_instance.cpp @@ -512,6 +512,7 @@ void Instance::Private::ping() { void Instance::Private::cancel(mtpRequestId requestId) { if (!requestId) return; + DEBUG_LOG(("MTP Info: Cancel request %1.").arg(requestId)); const auto shiftedDcId = queryRequestByDc(requestId); auto msgId = mtpMsgId(0); { @@ -884,6 +885,8 @@ void Instance::Private::registerRequest( } void Instance::Private::unregisterRequest(mtpRequestId requestId) { + DEBUG_LOG(("MTP Info: unregistering request %1.").arg(requestId)); + _requestsDelays.erase(requestId); { @@ -968,12 +971,13 @@ void Instance::Private::clearCallbacks( for (const auto &clearRequest : ids) { if (Logs::DebugEnabled()) { QMutexLocker locker(&_parserMapLock); - if (_parserMap.find(clearRequest.requestId) != _parserMap.end()) { - DEBUG_LOG(("RPC Info: " - "clearing delayed callback %1, error code %2" - ).arg(clearRequest.requestId - ).arg(clearRequest.errorCode)); - } + const auto hasParsers = (_parserMap.find(clearRequest.requestId) + != _parserMap.end()); + DEBUG_LOG(("RPC Info: " + "clearing delayed callback %1, error code %2, parsers: %3" + ).arg(clearRequest.requestId + ).arg(clearRequest.errorCode + ).arg(Logs::b(hasParsers))); } clearCallbacks(clearRequest.requestId, clearRequest.errorCode); unregisterRequest(clearRequest.requestId); @@ -996,35 +1000,42 @@ void Instance::Private::execCallback( } } if (h.onDone || h.onFail) { + const auto handleError = [&](const MTPRpcError &error) { + const auto wrapped = RPCError(error); + DEBUG_LOG(("RPC Info: " + "error received, code %1, type %2, description: %3" + ).arg(wrapped.code() + ).arg(wrapped.type() + ).arg(wrapped.description())); + if (rpcErrorOccured(requestId, h, wrapped)) { + unregisterRequest(requestId); + } else { + QMutexLocker locker(&_parserMapLock); + _parserMap.emplace(requestId, h); + } + }; + try { if (from >= end) throw mtpErrorInsufficient(); - if (*from == mtpc_rpc_error) { - auto mtpError = MTPRpcError(); - mtpError.read(from, end); - auto error = RPCError(mtpError); - DEBUG_LOG(("RPC Info: error received, code %1, type %2, description: %3").arg(error.code()).arg(error.type()).arg(error.description())); - if (!rpcErrorOccured(requestId, h, error)) { - QMutexLocker locker(&_parserMapLock); - _parserMap.emplace(requestId, h); - return; - } + auto error = MTPRpcError(); + error.read(from, end); + handleError(error); } else { if (h.onDone) { (*h.onDone)(requestId, from, end); } + unregisterRequest(requestId); } } catch (Exception &e) { - if (!rpcErrorOccured(requestId, h, internal::rpcClientError("RESPONSE_PARSE_FAILED", QString("exception text: ") + e.what()))) { - QMutexLocker locker(&_parserMapLock); - _parserMap.emplace(requestId, h); - return; - } + handleError(internal::rpcClientError( + "RESPONSE_PARSE_FAILED", + QString("exception text: ") + e.what())); } } else { DEBUG_LOG(("RPC Info: parser not found for %1").arg(requestId)); + unregisterRequest(requestId); } - unregisterRequest(requestId); } bool Instance::Private::hasCallbacks(mtpRequestId requestId) {