2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

pausing of mtp while animating, fixed message field while animating

This commit is contained in:
John Preston
2015-10-15 12:18:24 +02:00
parent 1c28d59ed2
commit f12f21b16b
15 changed files with 99 additions and 2 deletions

View File

@@ -352,6 +352,8 @@ namespace {
return false;
}
bool _paused = false;
}
namespace _mtp_internal {
@@ -371,6 +373,10 @@ namespace _mtp_internal {
sessions.insert(dcWithShift, result);
return result;
}
bool paused() {
return _paused;
}
void registerRequest(mtpRequestId requestId, int32 dcWithShift) {
{
@@ -643,6 +649,7 @@ namespace MTP {
(*i)->restart();
}
}
void restart(int32 dcMask) {
if (!_started) return;
@@ -654,6 +661,19 @@ namespace MTP {
}
}
void pause() {
if (!_started) return;
_paused = true;
}
void unpause() {
if (!_started) return;
_paused = false;
for (Sessions::const_iterator i = sessions.cbegin(), e = sessions.cend(); i != e; ++i) {
(*i)->unpaused();
}
}
void configure(int32 dc, int32 user) {
if (_started) return;
mtpSetDC(dc);

View File

@@ -26,6 +26,8 @@ Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
namespace _mtp_internal {
MTProtoSessionPtr getSession(int32 dc = 0); // 0 - current set dc
bool paused();
void registerRequest(mtpRequestId requestId, int32 dc);
void unregisterRequest(mtpRequestId requestId);
@@ -86,6 +88,9 @@ namespace MTP {
void restart();
void restart(int32 dcMask);
void pause();
void unpause();
void configure(int32 dc, int32 user);
void setdc(int32 dc, bool fromZeroOnly = false);

View File

@@ -66,7 +66,15 @@ void MTPSessionData::clear() {
}
MTProtoSession::MTProtoSession() : _killed(false), data(this), dcWithShift(0), dc(0), msSendCall(0), msWait(0), _ping(false) {
MTProtoSession::MTProtoSession() : QObject()
, _killed(false)
, _needToReceive(false)
, data(this)
, dcWithShift(0)
, dc(0)
, msSendCall(0)
, msWait(0)
, _ping(false) {
}
void MTProtoSession::start(int32 dcenter) {
@@ -144,6 +152,13 @@ void MTProtoSession::kill() {
DEBUG_LOG(("Session Info: marked session dcWithShift %1 as killed").arg(dcWithShift));
}
void MTProtoSession::unpaused() {
if (_needToReceive) {
_needToReceive = false;
tryToReceive();
}
}
void MTProtoSession::sendAnything(quint64 msCanWait) {
if (_killed) {
DEBUG_LOG(("Session Error: can't send anything in a killed session"));
@@ -492,6 +507,10 @@ int32 MTProtoSession::getDcWithShift() const {
}
void MTProtoSession::tryToReceive() {
if (_mtp_internal::paused()) {
_needToReceive = true;
return;
}
int32 cnt = 0;
while (true) {
mtpRequestId requestId;

View File

@@ -229,6 +229,8 @@ public:
void stop();
void kill();
void unpaused();
int32 getDcWithShift() const;
~MTProtoSession();
@@ -281,6 +283,7 @@ private:
MTProtoConnections connections;
bool _killed;
bool _needToReceive;
MTPSessionData data;