mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Add url with the Focus Assist API information.
Thanks https://www.withinrafael.com/2019/09/19/ determine-if-your-app-is-in-a-focus-assist-profiles-priority-list/
This commit is contained in:
parent
2730ab1596
commit
2843500ce3
2 changed files with 15 additions and 17 deletions
|
@ -1273,16 +1273,9 @@ void SessionPrivate::handleReceived() {
|
||||||
auto msgId = *(uint64*)&decryptedInts[4];
|
auto msgId = *(uint64*)&decryptedInts[4];
|
||||||
auto seqNo = *(uint32*)&decryptedInts[6];
|
auto seqNo = *(uint32*)&decryptedInts[6];
|
||||||
auto needAck = ((seqNo & 0x01) != 0);
|
auto needAck = ((seqNo & 0x01) != 0);
|
||||||
|
|
||||||
auto messageLength = *(uint32*)&decryptedInts[7];
|
auto messageLength = *(uint32*)&decryptedInts[7];
|
||||||
if (messageLength > kMaxMessageLength) {
|
|
||||||
LOG(("TCP Error: bad messageLength %1").arg(messageLength));
|
|
||||||
TCP_LOG(("TCP Error: bad message %1").arg(Logs::mb(ints, intsCount * kIntSize).str()));
|
|
||||||
|
|
||||||
return restart();
|
|
||||||
|
|
||||||
}
|
|
||||||
auto fullDataLength = kEncryptedHeaderIntsCount * kIntSize + messageLength; // Without padding.
|
auto fullDataLength = kEncryptedHeaderIntsCount * kIntSize + messageLength; // Without padding.
|
||||||
|
auto badMessageLength = (messageLength > kMaxMessageLength);
|
||||||
|
|
||||||
// Can underflow, but it is an unsigned type, so we just check the range later.
|
// Can underflow, but it is an unsigned type, so we just check the range later.
|
||||||
auto paddingSize = static_cast<uint32>(encryptedBytesCount) - static_cast<uint32>(fullDataLength);
|
auto paddingSize = static_cast<uint32>(encryptedBytesCount) - static_cast<uint32>(fullDataLength);
|
||||||
|
@ -1290,7 +1283,7 @@ void SessionPrivate::handleReceived() {
|
||||||
#ifdef TDESKTOP_MTPROTO_OLD
|
#ifdef TDESKTOP_MTPROTO_OLD
|
||||||
constexpr auto kMinPaddingSize_oldmtp = 0U;
|
constexpr auto kMinPaddingSize_oldmtp = 0U;
|
||||||
constexpr auto kMaxPaddingSize_oldmtp = 15U;
|
constexpr auto kMaxPaddingSize_oldmtp = 15U;
|
||||||
auto badMessageLength = (/*paddingSize < kMinPaddingSize_oldmtp || */paddingSize > kMaxPaddingSize_oldmtp);
|
badMessageLength |= (/*paddingSize < kMinPaddingSize_oldmtp || */paddingSize > kMaxPaddingSize_oldmtp);
|
||||||
|
|
||||||
auto hashedDataLength = badMessageLength ? encryptedBytesCount : fullDataLength;
|
auto hashedDataLength = badMessageLength ? encryptedBytesCount : fullDataLength;
|
||||||
auto sha1ForMsgKeyCheck = hashSha1(decryptedInts, hashedDataLength);
|
auto sha1ForMsgKeyCheck = hashSha1(decryptedInts, hashedDataLength);
|
||||||
|
@ -1305,7 +1298,7 @@ void SessionPrivate::handleReceived() {
|
||||||
#else // TDESKTOP_MTPROTO_OLD
|
#else // TDESKTOP_MTPROTO_OLD
|
||||||
constexpr auto kMinPaddingSize = 12U;
|
constexpr auto kMinPaddingSize = 12U;
|
||||||
constexpr auto kMaxPaddingSize = 1024U;
|
constexpr auto kMaxPaddingSize = 1024U;
|
||||||
auto badMessageLength = (paddingSize < kMinPaddingSize || paddingSize > kMaxPaddingSize);
|
badMessageLength |= (paddingSize < kMinPaddingSize || paddingSize > kMaxPaddingSize);
|
||||||
|
|
||||||
std::array<uchar, 32> sha256Buffer = { { 0 } };
|
std::array<uchar, 32> sha256Buffer = { { 0 } };
|
||||||
|
|
||||||
|
|
|
@ -689,6 +689,7 @@ void QueryQuietHours() {
|
||||||
|
|
||||||
bool FocusAssistBlocks = false;
|
bool FocusAssistBlocks = false;
|
||||||
|
|
||||||
|
// Thanks https://www.withinrafael.com/2019/09/19/determine-if-your-app-is-in-a-focus-assist-profiles-priority-list/
|
||||||
void QueryFocusAssist() {
|
void QueryFocusAssist() {
|
||||||
ComPtr<IQuietHoursSettings> quietHoursSettings;
|
ComPtr<IQuietHoursSettings> quietHoursSettings;
|
||||||
auto hr = CoCreateInstance(
|
auto hr = CoCreateInstance(
|
||||||
|
@ -709,18 +710,22 @@ void QueryFocusAssist() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto profileName = QString::fromWCharArray(profileId);
|
const auto profileName = QString::fromWCharArray(profileId);
|
||||||
if (profileName.endsWith(".unrestricted", Qt::CaseInsensitive)) {
|
if (profileName.endsWith(".alarmsonly", Qt::CaseInsensitive)) {
|
||||||
if (FocusAssistBlocks) {
|
|
||||||
LOG(("Focus Assist: Unrestricted."));
|
|
||||||
FocusAssistBlocks = false;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
} else if (profileName.endsWith(".alarmsonly", Qt::CaseInsensitive)) {
|
|
||||||
if (!FocusAssistBlocks) {
|
if (!FocusAssistBlocks) {
|
||||||
LOG(("Focus Assist: Alarms Only."));
|
LOG(("Focus Assist: Alarms Only."));
|
||||||
FocusAssistBlocks = true;
|
FocusAssistBlocks = true;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
} else if (!profileName.endsWith(".priorityonly", Qt::CaseInsensitive)) {
|
||||||
|
if (!profileName.endsWith(".unrestricted", Qt::CaseInsensitive)) {
|
||||||
|
LOG(("Focus Assist Warning: Unknown profile '%1'"
|
||||||
|
).arg(profileName));
|
||||||
|
}
|
||||||
|
if (FocusAssistBlocks) {
|
||||||
|
LOG(("Focus Assist: Unrestricted."));
|
||||||
|
FocusAssistBlocks = false;
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
const auto appUserModelId = std::wstring(AppUserModelId::getId());
|
const auto appUserModelId = std::wstring(AppUserModelId::getId());
|
||||||
auto blocked = true;
|
auto blocked = true;
|
||||||
|
|
Loading…
Add table
Reference in a new issue