mirror of https://github.com/procxx/kepka.git
Send init connection params.
This commit is contained in:
parent
699761b42f
commit
6882093ed1
|
@ -482,6 +482,27 @@ mtpMsgId SessionPrivate::placeToContainer(
|
||||||
return msgId;
|
return msgId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MTPVector<MTPJSONObjectValue> SessionPrivate::prepareInitParams() {
|
||||||
|
const auto local = QDateTime::currentDateTime();
|
||||||
|
const auto utc = QDateTime(local.date(), local.time(), Qt::UTC);
|
||||||
|
const auto shift = base::unixtime::now() - (TimeId)::time(nullptr);
|
||||||
|
const auto delta = int(utc.toTime_t()) - int(local.toTime_t()) - shift;
|
||||||
|
auto sliced = delta;
|
||||||
|
while (sliced < -12 * 3600) {
|
||||||
|
sliced += 24 * 3600;
|
||||||
|
}
|
||||||
|
while (sliced > 14 * 3600) {
|
||||||
|
sliced -= 24 * 3600;
|
||||||
|
}
|
||||||
|
const auto sign = (sliced < 0) ? -1 : 1;
|
||||||
|
const auto rounded = std::round(std::abs(sliced) / 900.) * 900 * sign;
|
||||||
|
return MTP_vector<MTPJSONObjectValue>(
|
||||||
|
1,
|
||||||
|
MTP_jsonObjectValue(
|
||||||
|
MTP_string("tz_offset"),
|
||||||
|
MTP_jsonNumber(MTP_double(rounded))));
|
||||||
|
}
|
||||||
|
|
||||||
void SessionPrivate::tryToSend() {
|
void SessionPrivate::tryToSend() {
|
||||||
DEBUG_LOG(("MTP Info: tryToSend for dc %1.").arg(_shiftedDcId));
|
DEBUG_LOG(("MTP Info: tryToSend for dc %1.").arg(_shiftedDcId));
|
||||||
if (!_connection) {
|
if (!_connection) {
|
||||||
|
@ -612,7 +633,8 @@ void SessionPrivate::tryToSend() {
|
||||||
: MTPInputClientProxy();
|
: MTPInputClientProxy();
|
||||||
using Flag = MTPInitConnection<SerializedRequest>::Flag;
|
using Flag = MTPInitConnection<SerializedRequest>::Flag;
|
||||||
initWrapper = MTPInitConnection<SerializedRequest>(
|
initWrapper = MTPInitConnection<SerializedRequest>(
|
||||||
MTP_flags(mtprotoProxy ? Flag::f_proxy : Flag(0)),
|
MTP_flags(Flag::f_params
|
||||||
|
| (mtprotoProxy ? Flag::f_proxy : Flag(0))),
|
||||||
MTP_int(ApiId),
|
MTP_int(ApiId),
|
||||||
MTP_string(deviceModel),
|
MTP_string(deviceModel),
|
||||||
MTP_string(systemVersion),
|
MTP_string(systemVersion),
|
||||||
|
@ -621,7 +643,7 @@ void SessionPrivate::tryToSend() {
|
||||||
MTP_string(langPackName),
|
MTP_string(langPackName),
|
||||||
MTP_string(cloudLangCode),
|
MTP_string(cloudLangCode),
|
||||||
clientProxyFields,
|
clientProxyFields,
|
||||||
MTPJSONValue(), // #TODO polls timezone
|
MTP_jsonObject(prepareInitParams()),
|
||||||
SerializedRequest());
|
SerializedRequest());
|
||||||
initSizeInInts = (tl::count_length(initWrapper) >> 2) + 2;
|
initSizeInInts = (tl::count_length(initWrapper) >> 2) + 2;
|
||||||
initSize = initSizeInInts * sizeof(mtpPrime);
|
initSize = initSizeInInts * sizeof(mtpPrime);
|
||||||
|
|
|
@ -166,6 +166,7 @@ private:
|
||||||
[[nodiscard]] uint32 nextRequestSeqNumber(bool needAck);
|
[[nodiscard]] uint32 nextRequestSeqNumber(bool needAck);
|
||||||
|
|
||||||
[[nodiscard]] bool realDcTypeChanged();
|
[[nodiscard]] bool realDcTypeChanged();
|
||||||
|
[[nodiscard]] MTPVector<MTPJSONObjectValue> prepareInitParams();
|
||||||
|
|
||||||
const not_null<Instance*> _instance;
|
const not_null<Instance*> _instance;
|
||||||
const ShiftedDcId _shiftedDcId = 0;
|
const ShiftedDcId _shiftedDcId = 0;
|
||||||
|
|
Loading…
Reference in New Issue