Skip to content

Commit

Permalink
Some phrases fixed, some logs added.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Jun 24, 2018
1 parent f7aadc3 commit 266102d
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 43 deletions.
12 changes: 6 additions & 6 deletions Telegram/Resources/langs/lang.strings
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand All @@ -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

Expand Down
9 changes: 6 additions & 3 deletions Telegram/SourceFiles/export/export_api_wrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,15 +491,18 @@ void ApiWrap::requestDialogsList(
}

void ApiWrap::startMainSession(FnMut<void()> 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))
Expand Down
1 change: 0 additions & 1 deletion Telegram/SourceFiles/export/export_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ struct Settings {
return Type::PersonalInfo
| Type::Userpics
| Type::Contacts
| Type::Sessions
| Type::PersonalChats
| Type::PrivateGroups;
}
Expand Down
7 changes: 5 additions & 2 deletions Telegram/SourceFiles/export/output/export_output_html.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.)";
Expand Down Expand Up @@ -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.)";
Expand Down
6 changes: 4 additions & 2 deletions Telegram/SourceFiles/export/output/export_output_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.)";
Expand Down Expand Up @@ -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.)";
Expand Down
7 changes: 5 additions & 2 deletions Telegram/SourceFiles/export/output/export_output_text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.)";
Expand Down Expand Up @@ -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.)";
Expand Down
10 changes: 5 additions & 5 deletions Telegram/SourceFiles/export/view/export_view_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,6 @@ void SettingsWidget::setupOptions(not_null<Ui::VerticalLayout*> 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,
Expand All @@ -136,6 +131,11 @@ void SettingsWidget::setupOptions(not_null<Ui::VerticalLayout*> 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,
Expand Down
55 changes: 33 additions & 22 deletions Telegram/SourceFiles/mtproto/mtp_instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
{
Expand Down Expand Up @@ -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);

{
Expand Down Expand Up @@ -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);
Expand All @@ -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) {
Expand Down

0 comments on commit 266102d

Please sign in to comment.