mirror of https://github.com/procxx/kepka.git
MTP::nonce -> rand_value, fixed first_name and last_name reading from minimal users
This commit is contained in:
parent
d9ef8217e5
commit
ddd63d73b7
|
@ -420,9 +420,13 @@ namespace App {
|
||||||
data->access = UserNoAccess;
|
data->access = UserNoAccess;
|
||||||
status = &emptyStatus;
|
status = &emptyStatus;
|
||||||
} else {
|
} else {
|
||||||
|
// apply first_name and last_name from minimal user only if we don't have
|
||||||
|
// local values for first name and last name already, otherwise skip
|
||||||
|
bool noLocalName = data->firstName.isEmpty() && data->lastName.isEmpty();
|
||||||
|
QString fname = (!minimal || noLocalName) ? (d.has_first_name() ? textOneLine(qs(d.vfirst_name)) : QString()) : data->firstName;
|
||||||
|
QString lname = (!minimal || noLocalName) ? (d.has_last_name() ? textOneLine(qs(d.vlast_name)) : QString()) : data->lastName;
|
||||||
|
|
||||||
QString phone = minimal ? data->phone : (d.has_phone() ? qs(d.vphone) : QString());
|
QString phone = minimal ? data->phone : (d.has_phone() ? qs(d.vphone) : QString());
|
||||||
QString fname = d.has_first_name() ? textOneLine(qs(d.vfirst_name)) : QString();
|
|
||||||
QString lname = d.has_last_name() ? textOneLine(qs(d.vlast_name)) : QString();
|
|
||||||
QString uname = minimal ? data->username : (d.has_username() ? textOneLine(qs(d.vusername)) : QString());
|
QString uname = minimal ? data->username : (d.has_username() ? textOneLine(qs(d.vusername)) : QString());
|
||||||
|
|
||||||
bool phoneChanged = (data->phone != phone);
|
bool phoneChanged = (data->phone != phone);
|
||||||
|
|
|
@ -1004,7 +1004,7 @@ void AppClass::uploadProfilePhoto(const QImage &tosend, const PeerId &peerId) {
|
||||||
QBuffer jpegBuffer(&jpeg);
|
QBuffer jpegBuffer(&jpeg);
|
||||||
full.save(&jpegBuffer, "JPG", 87);
|
full.save(&jpegBuffer, "JPG", 87);
|
||||||
|
|
||||||
PhotoId id = MTP::nonce<PhotoId>();
|
PhotoId id = rand_value<PhotoId>();
|
||||||
|
|
||||||
MTPPhoto photo(MTP_photo(MTP_long(id), MTP_long(0), MTP_int(unixtime()), MTP_vector<MTPPhotoSize>(photoSizes)));
|
MTPPhoto photo(MTP_photo(MTP_long(id), MTP_long(0), MTP_int(unixtime()), MTP_vector<MTPPhotoSize>(photoSizes)));
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ void UpdateChecker::initOutput() {
|
||||||
fileName = m.captured(1).replace(QRegularExpression(qsl("[^a-zA-Z0-9_\\-]")), QString());
|
fileName = m.captured(1).replace(QRegularExpression(qsl("[^a-zA-Z0-9_\\-]")), QString());
|
||||||
}
|
}
|
||||||
if (fileName.isEmpty()) {
|
if (fileName.isEmpty()) {
|
||||||
fileName = qsl("tupdate-%1").arg(MTP::nonce<uint32>() % 1000000);
|
fileName = qsl("tupdate-%1").arg(rand_value<uint32>() % 1000000);
|
||||||
}
|
}
|
||||||
QString dirStr = cWorkingDir() + qsl("tupdates/");
|
QString dirStr = cWorkingDir() + qsl("tupdates/");
|
||||||
fileName = dirStr + fileName;
|
fileName = dirStr + fileName;
|
||||||
|
|
|
@ -188,11 +188,11 @@ void AddContactBox::onSave() {
|
||||||
}
|
}
|
||||||
_sentName = firstName;
|
_sentName = firstName;
|
||||||
if (_user) {
|
if (_user) {
|
||||||
_contactId = MTP::nonce<uint64>();
|
_contactId = rand_value<uint64>();
|
||||||
QVector<MTPInputContact> v(1, MTP_inputPhoneContact(MTP_long(_contactId), MTP_string(_user->phone), MTP_string(firstName), MTP_string(lastName)));
|
QVector<MTPInputContact> v(1, MTP_inputPhoneContact(MTP_long(_contactId), MTP_string(_user->phone), MTP_string(firstName), MTP_string(lastName)));
|
||||||
_addRequest = MTP::send(MTPcontacts_ImportContacts(MTP_vector<MTPInputContact>(v), MTP_bool(false)), rpcDone(&AddContactBox::onSaveUserDone), rpcFail(&AddContactBox::onSaveUserFail));
|
_addRequest = MTP::send(MTPcontacts_ImportContacts(MTP_vector<MTPInputContact>(v), MTP_bool(false)), rpcDone(&AddContactBox::onSaveUserDone), rpcFail(&AddContactBox::onSaveUserFail));
|
||||||
} else {
|
} else {
|
||||||
_contactId = MTP::nonce<uint64>();
|
_contactId = rand_value<uint64>();
|
||||||
QVector<MTPInputContact> v(1, MTP_inputPhoneContact(MTP_long(_contactId), MTP_string(phone), MTP_string(firstName), MTP_string(lastName)));
|
QVector<MTPInputContact> v(1, MTP_inputPhoneContact(MTP_long(_contactId), MTP_string(phone), MTP_string(firstName), MTP_string(lastName)));
|
||||||
_addRequest = MTP::send(MTPcontacts_ImportContacts(MTP_vector<MTPInputContact>(v), MTP_bool(false)), rpcDone(&AddContactBox::onImportDone));
|
_addRequest = MTP::send(MTPcontacts_ImportContacts(MTP_vector<MTPInputContact>(v), MTP_bool(false)), rpcDone(&AddContactBox::onImportDone));
|
||||||
}
|
}
|
||||||
|
|
|
@ -224,7 +224,7 @@ void ContactsInner::onPeerNameChanged(PeerData *peer, const PeerData::Names &old
|
||||||
|
|
||||||
void ContactsInner::onAddBot() {
|
void ContactsInner::onAddBot() {
|
||||||
if (_bot->botInfo && !_bot->botInfo->startGroupToken.isEmpty()) {
|
if (_bot->botInfo && !_bot->botInfo->startGroupToken.isEmpty()) {
|
||||||
MTP::send(MTPmessages_StartBot(_bot->inputUser, _addToPeer->input, MTP_long(MTP::nonce<uint64>()), MTP_string(_bot->botInfo->startGroupToken)), App::main()->rpcDone(&MainWidget::sentUpdatesReceived), App::main()->rpcFail(&MainWidget::addParticipantFail, _bot));
|
MTP::send(MTPmessages_StartBot(_bot->inputUser, _addToPeer->input, MTP_long(rand_value<uint64>()), MTP_string(_bot->botInfo->startGroupToken)), App::main()->rpcDone(&MainWidget::sentUpdatesReceived), App::main()->rpcFail(&MainWidget::addParticipantFail, _bot));
|
||||||
} else {
|
} else {
|
||||||
App::main()->addParticipants(_addToPeer, QVector<UserData*>(1, _bot));
|
App::main()->addParticipants(_addToPeer, QVector<UserData*>(1, _bot));
|
||||||
}
|
}
|
||||||
|
|
|
@ -245,7 +245,7 @@ ClipReader::ClipReader(const FileLocation &location, const QByteArray &data, Cal
|
||||||
_clipManagers.push_back(new ClipReadManager(_clipThreads.back()));
|
_clipManagers.push_back(new ClipReadManager(_clipThreads.back()));
|
||||||
_clipThreads.back()->start();
|
_clipThreads.back()->start();
|
||||||
} else {
|
} else {
|
||||||
_threadIndex = int32(MTP::nonce<uint32>() % _clipThreads.size());
|
_threadIndex = int32(rand_value<uint32>() % _clipThreads.size());
|
||||||
int32 loadLevel = 0x7FFFFFFF;
|
int32 loadLevel = 0x7FFFFFFF;
|
||||||
for (int32 i = 0, l = _clipThreads.size(); i < l; ++i) {
|
for (int32 i = 0, l = _clipThreads.size(); i < l; ++i) {
|
||||||
int32 level = _clipManagers.at(i)->loadLevel();
|
int32 level = _clipManagers.at(i)->loadLevel();
|
||||||
|
|
|
@ -4836,7 +4836,7 @@ void HistoryWidget::onBotStart() {
|
||||||
if (token.isEmpty()) {
|
if (token.isEmpty()) {
|
||||||
sendBotCommand(qsl("/start"), 0);
|
sendBotCommand(qsl("/start"), 0);
|
||||||
} else {
|
} else {
|
||||||
uint64 randomId = MTP::nonce<uint64>();
|
uint64 randomId = rand_value<uint64>();
|
||||||
MTP::send(MTPmessages_StartBot(_peer->asUser()->inputUser, MTP_inputPeerEmpty(), MTP_long(randomId), MTP_string(token)), App::main()->rpcDone(&MainWidget::sentUpdatesReceived), App::main()->rpcFail(&MainWidget::addParticipantFail, _peer->asUser()));
|
MTP::send(MTPmessages_StartBot(_peer->asUser()->inputUser, MTP_inputPeerEmpty(), MTP_long(randomId), MTP_string(token)), App::main()->rpcDone(&MainWidget::sentUpdatesReceived), App::main()->rpcFail(&MainWidget::addParticipantFail, _peer->asUser()));
|
||||||
|
|
||||||
_peer->asUser()->botInfo->startToken = QString();
|
_peer->asUser()->botInfo->startToken = QString();
|
||||||
|
@ -4897,7 +4897,7 @@ void HistoryWidget::onShareContact(const PeerId &peer, UserData *contact) {
|
||||||
void HistoryWidget::shareContact(const PeerId &peer, const QString &phone, const QString &fname, const QString &lname, MsgId replyTo, int32 userId) {
|
void HistoryWidget::shareContact(const PeerId &peer, const QString &phone, const QString &fname, const QString &lname, MsgId replyTo, int32 userId) {
|
||||||
History *h = App::history(peer);
|
History *h = App::history(peer);
|
||||||
|
|
||||||
uint64 randomId = MTP::nonce<uint64>();
|
uint64 randomId = rand_value<uint64>();
|
||||||
FullMsgId newId(peerToChannel(peer), clientMsgId());
|
FullMsgId newId(peerToChannel(peer), clientMsgId());
|
||||||
|
|
||||||
App::main()->readServerHistory(h, false);
|
App::main()->readServerHistory(h, false);
|
||||||
|
@ -5993,7 +5993,7 @@ void HistoryWidget::onPhotoUploaded(const FullMsgId &newId, bool silent, const M
|
||||||
if (!MTP::authedId()) return;
|
if (!MTP::authedId()) return;
|
||||||
HistoryItem *item = App::histItemById(newId);
|
HistoryItem *item = App::histItemById(newId);
|
||||||
if (item) {
|
if (item) {
|
||||||
uint64 randomId = MTP::nonce<uint64>();
|
uint64 randomId = rand_value<uint64>();
|
||||||
App::historyRegRandom(randomId, newId);
|
App::historyRegRandom(randomId, newId);
|
||||||
History *hist = item->history();
|
History *hist = item->history();
|
||||||
MsgId replyTo = item->toHistoryReply() ? item->toHistoryReply()->replyToId() : 0;
|
MsgId replyTo = item->toHistoryReply() ? item->toHistoryReply()->replyToId() : 0;
|
||||||
|
@ -6045,7 +6045,7 @@ void HistoryWidget::onDocumentUploaded(const FullMsgId &newId, bool silent, cons
|
||||||
if (item) {
|
if (item) {
|
||||||
DocumentData *document = item->getMedia() ? item->getMedia()->getDocument() : 0;
|
DocumentData *document = item->getMedia() ? item->getMedia()->getDocument() : 0;
|
||||||
if (document) {
|
if (document) {
|
||||||
uint64 randomId = MTP::nonce<uint64>();
|
uint64 randomId = rand_value<uint64>();
|
||||||
App::historyRegRandom(randomId, newId);
|
App::historyRegRandom(randomId, newId);
|
||||||
History *hist = item->history();
|
History *hist = item->history();
|
||||||
MsgId replyTo = item->toHistoryReply() ? item->toHistoryReply()->replyToId() : 0;
|
MsgId replyTo = item->toHistoryReply() ? item->toHistoryReply()->replyToId() : 0;
|
||||||
|
@ -6074,7 +6074,7 @@ void HistoryWidget::onThumbDocumentUploaded(const FullMsgId &newId, bool silent,
|
||||||
if (item) {
|
if (item) {
|
||||||
DocumentData *document = item->getMedia() ? item->getMedia()->getDocument() : 0;
|
DocumentData *document = item->getMedia() ? item->getMedia()->getDocument() : 0;
|
||||||
if (document) {
|
if (document) {
|
||||||
uint64 randomId = MTP::nonce<uint64>();
|
uint64 randomId = rand_value<uint64>();
|
||||||
App::historyRegRandom(randomId, newId);
|
App::historyRegRandom(randomId, newId);
|
||||||
History *hist = item->history();
|
History *hist = item->history();
|
||||||
MsgId replyTo = item->toHistoryReply() ? item->toHistoryReply()->replyToId() : 0;
|
MsgId replyTo = item->toHistoryReply() ? item->toHistoryReply()->replyToId() : 0;
|
||||||
|
@ -6799,7 +6799,7 @@ void HistoryWidget::onInlineResultSend(InlineResult *result, UserData *bot) {
|
||||||
App::main()->readServerHistory(_history, false);
|
App::main()->readServerHistory(_history, false);
|
||||||
fastShowAtEnd(_history);
|
fastShowAtEnd(_history);
|
||||||
|
|
||||||
uint64 randomId = MTP::nonce<uint64>();
|
uint64 randomId = rand_value<uint64>();
|
||||||
FullMsgId newId(_channel, clientMsgId());
|
FullMsgId newId(_channel, clientMsgId());
|
||||||
|
|
||||||
bool lastKeyboardUsed = lastForceReplyReplied();
|
bool lastKeyboardUsed = lastForceReplyReplied();
|
||||||
|
@ -6854,7 +6854,7 @@ void HistoryWidget::onInlineResultSend(InlineResult *result, UserData *bot) {
|
||||||
tw = th = 0;
|
tw = th = 0;
|
||||||
thumbSize = MTP_photoSizeEmpty(MTP_string(""));
|
thumbSize = MTP_photoSizeEmpty(MTP_string(""));
|
||||||
}
|
}
|
||||||
uint64 docId = MTP::nonce<uint64>();
|
uint64 docId = rand_value<uint64>();
|
||||||
QVector<MTPDocumentAttribute> attributes(1, MTP_documentAttributeFilename(MTP_string((result->content_type == qstr("video/mp4") ? "animation.gif.mp4" : "animation.gif"))));
|
QVector<MTPDocumentAttribute> attributes(1, MTP_documentAttributeFilename(MTP_string((result->content_type == qstr("video/mp4") ? "animation.gif.mp4" : "animation.gif"))));
|
||||||
attributes.push_back(MTP_documentAttributeAnimated());
|
attributes.push_back(MTP_documentAttributeAnimated());
|
||||||
attributes.push_back(MTP_documentAttributeVideo(MTP_int(result->duration), MTP_int(result->width), MTP_int(result->height)));
|
attributes.push_back(MTP_documentAttributeVideo(MTP_int(result->duration), MTP_int(result->width), MTP_int(result->height)));
|
||||||
|
@ -6878,7 +6878,7 @@ void HistoryWidget::onInlineResultSend(InlineResult *result, UserData *bot) {
|
||||||
|
|
||||||
photoSizes.push_back(MTP_photoSize(MTP_string("x"), MTP_fileLocationUnavailable(MTP_long(0), MTP_int(0), MTP_long(0)), MTP_int(result->width), MTP_int(result->height), MTP_int(0)));
|
photoSizes.push_back(MTP_photoSize(MTP_string("x"), MTP_fileLocationUnavailable(MTP_long(0), MTP_int(0), MTP_long(0)), MTP_int(result->width), MTP_int(result->height), MTP_int(0)));
|
||||||
|
|
||||||
uint64 photoId = MTP::nonce<uint64>();
|
uint64 photoId = rand_value<uint64>();
|
||||||
PhotoData *ph = App::photoSet(photoId, 0, 0, unixtime(), thumbPtr, ImagePtr(medium.width(), medium.height()), ImagePtr(result->width, result->height));
|
PhotoData *ph = App::photoSet(photoId, 0, 0, unixtime(), thumbPtr, ImagePtr(medium.width(), medium.height()), ImagePtr(result->width, result->height));
|
||||||
MTPPhoto photo = MTP_photo(MTP_long(photoId), MTP_long(0), MTP_int(ph->date), MTP_vector<MTPPhotoSize>(photoSizes));
|
MTPPhoto photo = MTP_photo(MTP_long(photoId), MTP_long(0), MTP_int(ph->date), MTP_vector<MTPPhotoSize>(photoSizes));
|
||||||
|
|
||||||
|
@ -7020,7 +7020,7 @@ void HistoryWidget::sendExistingDocument(DocumentData *doc, const QString &capti
|
||||||
App::main()->readServerHistory(_history, false);
|
App::main()->readServerHistory(_history, false);
|
||||||
fastShowAtEnd(_history);
|
fastShowAtEnd(_history);
|
||||||
|
|
||||||
uint64 randomId = MTP::nonce<uint64>();
|
uint64 randomId = rand_value<uint64>();
|
||||||
FullMsgId newId(_channel, clientMsgId());
|
FullMsgId newId(_channel, clientMsgId());
|
||||||
|
|
||||||
bool lastKeyboardUsed = lastForceReplyReplied();
|
bool lastKeyboardUsed = lastForceReplyReplied();
|
||||||
|
@ -7076,7 +7076,7 @@ void HistoryWidget::sendExistingPhoto(PhotoData *photo, const QString &caption)
|
||||||
App::main()->readServerHistory(_history, false);
|
App::main()->readServerHistory(_history, false);
|
||||||
fastShowAtEnd(_history);
|
fastShowAtEnd(_history);
|
||||||
|
|
||||||
uint64 randomId = MTP::nonce<uint64>();
|
uint64 randomId = rand_value<uint64>();
|
||||||
FullMsgId newId(_channel, clientMsgId());
|
FullMsgId newId(_channel, clientMsgId());
|
||||||
|
|
||||||
bool lastKeyboardUsed = lastForceReplyReplied();
|
bool lastKeyboardUsed = lastForceReplyReplied();
|
||||||
|
|
|
@ -171,7 +171,7 @@ void TaskQueueWorker::onTaskAdded() {
|
||||||
_inTaskAdded = false;
|
_inTaskAdded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileLoadTask::FileLoadTask(const QString &filepath, PrepareMediaType type, const FileLoadTo &to, FileLoadForceConfirmType confirm) : _id(MTP::nonce<uint64>())
|
FileLoadTask::FileLoadTask(const QString &filepath, PrepareMediaType type, const FileLoadTo &to, FileLoadForceConfirmType confirm) : _id(rand_value<uint64>())
|
||||||
, _to(to)
|
, _to(to)
|
||||||
, _filepath(filepath)
|
, _filepath(filepath)
|
||||||
, _duration(0)
|
, _duration(0)
|
||||||
|
@ -180,7 +180,7 @@ FileLoadTask::FileLoadTask(const QString &filepath, PrepareMediaType type, const
|
||||||
, _result(0) {
|
, _result(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
FileLoadTask::FileLoadTask(const QByteArray &content, PrepareMediaType type, const FileLoadTo &to) : _id(MTP::nonce<uint64>())
|
FileLoadTask::FileLoadTask(const QByteArray &content, PrepareMediaType type, const FileLoadTo &to) : _id(rand_value<uint64>())
|
||||||
, _to(to)
|
, _to(to)
|
||||||
, _content(content)
|
, _content(content)
|
||||||
, _duration(0)
|
, _duration(0)
|
||||||
|
@ -189,7 +189,7 @@ FileLoadTask::FileLoadTask(const QByteArray &content, PrepareMediaType type, con
|
||||||
, _result(0) {
|
, _result(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
FileLoadTask::FileLoadTask(const QImage &image, PrepareMediaType type, const FileLoadTo &to, FileLoadForceConfirmType confirm, const QString &originalText) : _id(MTP::nonce<uint64>())
|
FileLoadTask::FileLoadTask(const QImage &image, PrepareMediaType type, const FileLoadTo &to, FileLoadForceConfirmType confirm, const QString &originalText) : _id(rand_value<uint64>())
|
||||||
, _to(to)
|
, _to(to)
|
||||||
, _image(image)
|
, _image(image)
|
||||||
, _duration(0)
|
, _duration(0)
|
||||||
|
@ -199,7 +199,7 @@ FileLoadTask::FileLoadTask(const QImage &image, PrepareMediaType type, const Fil
|
||||||
, _result(0) {
|
, _result(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
FileLoadTask::FileLoadTask(const QByteArray &voice, int32 duration, const VoiceWaveform &waveform, const FileLoadTo &to) : _id(MTP::nonce<uint64>())
|
FileLoadTask::FileLoadTask(const QByteArray &voice, int32 duration, const VoiceWaveform &waveform, const FileLoadTo &to) : _id(rand_value<uint64>())
|
||||||
, _to(to)
|
, _to(to)
|
||||||
, _content(voice)
|
, _content(voice)
|
||||||
, _duration(duration)
|
, _duration(duration)
|
||||||
|
@ -323,7 +323,7 @@ void FileLoadTask::process() {
|
||||||
thumb = full;
|
thumb = full;
|
||||||
thumbSize = MTP_photoSize(MTP_string(""), MTP_fileLocationUnavailable(MTP_long(0), MTP_int(0), MTP_long(0)), MTP_int(full.width()), MTP_int(full.height()), MTP_int(0));
|
thumbSize = MTP_photoSize(MTP_string(""), MTP_fileLocationUnavailable(MTP_long(0), MTP_int(0), MTP_long(0)), MTP_int(full.width()), MTP_int(full.height()), MTP_int(0));
|
||||||
|
|
||||||
thumbId = MTP::nonce<uint64>();
|
thumbId = rand_value<uint64>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -350,7 +350,7 @@ void FileLoadTask::process() {
|
||||||
thumb = full;
|
thumb = full;
|
||||||
thumbSize = MTP_photoSize(MTP_string(""), MTP_fileLocationUnavailable(MTP_long(0), MTP_int(0), MTP_long(0)), MTP_int(full.width()), MTP_int(full.height()), MTP_int(0));
|
thumbSize = MTP_photoSize(MTP_string(""), MTP_fileLocationUnavailable(MTP_long(0), MTP_int(0), MTP_long(0)), MTP_int(full.width()), MTP_int(full.height()), MTP_int(0));
|
||||||
|
|
||||||
thumbId = MTP::nonce<uint64>();
|
thumbId = rand_value<uint64>();
|
||||||
|
|
||||||
if (filename.endsWith(qstr(".mp4"), Qt::CaseInsensitive)) {
|
if (filename.endsWith(qstr(".mp4"), Qt::CaseInsensitive)) {
|
||||||
filemime = qstr("video/mp4");
|
filemime = qstr("video/mp4");
|
||||||
|
@ -406,7 +406,7 @@ void FileLoadTask::process() {
|
||||||
thumb = full;
|
thumb = full;
|
||||||
thumbSize = MTP_photoSize(MTP_string(""), MTP_fileLocationUnavailable(MTP_long(0), MTP_int(0), MTP_long(0)), MTP_int(full.width()), MTP_int(full.height()), MTP_int(0));
|
thumbSize = MTP_photoSize(MTP_string(""), MTP_fileLocationUnavailable(MTP_long(0), MTP_int(0), MTP_long(0)), MTP_int(full.width()), MTP_int(full.height()), MTP_int(0));
|
||||||
|
|
||||||
thumbId = MTP::nonce<uint64>();
|
thumbId = rand_value<uint64>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,13 +29,13 @@ enum PrepareMediaType {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ToPrepareMedia {
|
struct ToPrepareMedia {
|
||||||
ToPrepareMedia(const QString &file, const PeerId &peer, PrepareMediaType t, bool broadcast, bool ctrlShiftEnter, MsgId replyTo) : id(MTP::nonce<PhotoId>()), file(file), peer(peer), type(t), duration(0), ctrlShiftEnter(ctrlShiftEnter), replyTo(replyTo) {
|
ToPrepareMedia(const QString &file, const PeerId &peer, PrepareMediaType t, bool broadcast, bool ctrlShiftEnter, MsgId replyTo) : id(rand_value<PhotoId>()), file(file), peer(peer), type(t), duration(0), ctrlShiftEnter(ctrlShiftEnter), replyTo(replyTo) {
|
||||||
}
|
}
|
||||||
ToPrepareMedia(const QImage &img, const PeerId &peer, PrepareMediaType t, bool broadcast, bool ctrlShiftEnter, MsgId replyTo) : id(MTP::nonce<PhotoId>()), img(img), peer(peer), type(t), duration(0), ctrlShiftEnter(ctrlShiftEnter), replyTo(replyTo) {
|
ToPrepareMedia(const QImage &img, const PeerId &peer, PrepareMediaType t, bool broadcast, bool ctrlShiftEnter, MsgId replyTo) : id(rand_value<PhotoId>()), img(img), peer(peer), type(t), duration(0), ctrlShiftEnter(ctrlShiftEnter), replyTo(replyTo) {
|
||||||
}
|
}
|
||||||
ToPrepareMedia(const QByteArray &data, const PeerId &peer, PrepareMediaType t, bool broadcast, bool ctrlShiftEnter, MsgId replyTo) : id(MTP::nonce<PhotoId>()), data(data), peer(peer), type(t), duration(0), ctrlShiftEnter(ctrlShiftEnter), replyTo(replyTo) {
|
ToPrepareMedia(const QByteArray &data, const PeerId &peer, PrepareMediaType t, bool broadcast, bool ctrlShiftEnter, MsgId replyTo) : id(rand_value<PhotoId>()), data(data), peer(peer), type(t), duration(0), ctrlShiftEnter(ctrlShiftEnter), replyTo(replyTo) {
|
||||||
}
|
}
|
||||||
ToPrepareMedia(const QByteArray &data, int32 duration, const PeerId &peer, PrepareMediaType t, bool broadcast, bool ctrlShiftEnter, MsgId replyTo) : id(MTP::nonce<PhotoId>()), data(data), peer(peer), type(t), duration(duration), ctrlShiftEnter(ctrlShiftEnter), replyTo(replyTo) {
|
ToPrepareMedia(const QByteArray &data, int32 duration, const PeerId &peer, PrepareMediaType t, bool broadcast, bool ctrlShiftEnter, MsgId replyTo) : id(rand_value<PhotoId>()), data(data), peer(peer), type(t), duration(duration), ctrlShiftEnter(ctrlShiftEnter), replyTo(replyTo) {
|
||||||
}
|
}
|
||||||
PhotoId id;
|
PhotoId id;
|
||||||
QString file;
|
QString file;
|
||||||
|
|
|
@ -113,7 +113,7 @@ namespace {
|
||||||
path.reserve(base.size() + 0x11);
|
path.reserve(base.size() + 0x11);
|
||||||
path += base;
|
path += base;
|
||||||
do {
|
do {
|
||||||
result = MTP::nonce<FileKey>();
|
result = rand_value<FileKey>();
|
||||||
path.resize(base.size());
|
path.resize(base.size());
|
||||||
path += toFilePart(result);
|
path += toFilePart(result);
|
||||||
} while (!result || keyAlreadyUsed(path, options));
|
} while (!result || keyAlreadyUsed(path, options));
|
||||||
|
|
|
@ -637,7 +637,7 @@ void MainWidget::finishForwarding(History *hist, bool broadcast, bool silent) {
|
||||||
ids.reserve(_toForward.size());
|
ids.reserve(_toForward.size());
|
||||||
randomIds.reserve(_toForward.size());
|
randomIds.reserve(_toForward.size());
|
||||||
for (SelectedItemSet::const_iterator i = _toForward.cbegin(), e = _toForward.cend(); i != e; ++i) {
|
for (SelectedItemSet::const_iterator i = _toForward.cbegin(), e = _toForward.cend(); i != e; ++i) {
|
||||||
uint64 randomId = MTP::nonce<uint64>();
|
uint64 randomId = rand_value<uint64>();
|
||||||
if (genClientSideMessage) {
|
if (genClientSideMessage) {
|
||||||
FullMsgId newId(peerToChannel(hist->peer->id), clientMsgId());
|
FullMsgId newId(peerToChannel(hist->peer->id), clientMsgId());
|
||||||
HistoryMessage *msg = static_cast<HistoryMessage*>(_toForward.cbegin().value());
|
HistoryMessage *msg = static_cast<HistoryMessage*>(_toForward.cbegin().value());
|
||||||
|
@ -1366,7 +1366,7 @@ void MainWidget::sendMessage(History *hist, const QString &text, MsgId replyTo,
|
||||||
if (replyTo < 0) replyTo = history.replyToId();
|
if (replyTo < 0) replyTo = history.replyToId();
|
||||||
while (textSplit(sendingText, sendingEntities, leftText, leftEntities, MaxMessageSize)) {
|
while (textSplit(sendingText, sendingEntities, leftText, leftEntities, MaxMessageSize)) {
|
||||||
FullMsgId newId(peerToChannel(hist->peer->id), clientMsgId());
|
FullMsgId newId(peerToChannel(hist->peer->id), clientMsgId());
|
||||||
uint64 randomId = MTP::nonce<uint64>();
|
uint64 randomId = rand_value<uint64>();
|
||||||
|
|
||||||
trimTextWithEntities(sendingText, sendingEntities);
|
trimTextWithEntities(sendingText, sendingEntities);
|
||||||
|
|
||||||
|
|
|
@ -648,8 +648,8 @@ void AbstractTcpConnection::socketRead() {
|
||||||
|
|
||||||
AutoConnection::AutoConnection(QThread *thread) : AbstractTcpConnection()
|
AutoConnection::AutoConnection(QThread *thread) : AbstractTcpConnection()
|
||||||
, status(WaitingBoth)
|
, status(WaitingBoth)
|
||||||
, tcpNonce(MTP::nonce<MTPint128>())
|
, tcpNonce(rand_value<MTPint128>())
|
||||||
, httpNonce(MTP::nonce<MTPint128>())
|
, httpNonce(rand_value<MTPint128>())
|
||||||
, _flagsTcp(0)
|
, _flagsTcp(0)
|
||||||
, _flagsHttp(0)
|
, _flagsHttp(0)
|
||||||
, _tcpTimeout(MTPMinReceiveDelay) {
|
, _tcpTimeout(MTPMinReceiveDelay) {
|
||||||
|
@ -1000,7 +1000,7 @@ void AutoConnection::socketError(QAbstractSocket::SocketError e) {
|
||||||
|
|
||||||
TCPConnection::TCPConnection(QThread *thread)
|
TCPConnection::TCPConnection(QThread *thread)
|
||||||
: status(WaitingTcp)
|
: status(WaitingTcp)
|
||||||
, tcpNonce(MTP::nonce<MTPint128>())
|
, tcpNonce(rand_value<MTPint128>())
|
||||||
, _tcpTimeout(MTPMinReceiveDelay)
|
, _tcpTimeout(MTPMinReceiveDelay)
|
||||||
, _flags(0) {
|
, _flags(0) {
|
||||||
moveToThread(thread);
|
moveToThread(thread);
|
||||||
|
@ -1162,7 +1162,7 @@ void TCPConnection::socketError(QAbstractSocket::SocketError e) {
|
||||||
|
|
||||||
HTTPConnection::HTTPConnection(QThread *thread)
|
HTTPConnection::HTTPConnection(QThread *thread)
|
||||||
: status(WaitingHttp)
|
: status(WaitingHttp)
|
||||||
, httpNonce(MTP::nonce<MTPint128>())
|
, httpNonce(rand_value<MTPint128>())
|
||||||
, _flags(0) {
|
, _flags(0) {
|
||||||
moveToThread(thread);
|
moveToThread(thread);
|
||||||
manager.moveToThread(thread);
|
manager.moveToThread(thread);
|
||||||
|
@ -1541,7 +1541,7 @@ void ConnectionPrivate::resetSession() { // recreate all msg_id and msg_seqno
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64 session = MTP::nonce<uint64>();
|
uint64 session = rand_value<uint64>();
|
||||||
DEBUG_LOG(("MTP Info: creating new session after bad_msg_notification, setting random server_session %1").arg(session));
|
DEBUG_LOG(("MTP Info: creating new session after bad_msg_notification, setting random server_session %1").arg(session));
|
||||||
sessionData->setSession(session);
|
sessionData->setSession(session);
|
||||||
|
|
||||||
|
@ -1698,7 +1698,7 @@ void ConnectionPrivate::tryToSend() {
|
||||||
mtpRequest pingRequest;
|
mtpRequest pingRequest;
|
||||||
if (dc == bareDcId(dc)) { // main session
|
if (dc == bareDcId(dc)) { // main session
|
||||||
if (!prependOnly && !_pingIdToSend && !_pingId && _pingSendAt <= getms(true)) {
|
if (!prependOnly && !_pingIdToSend && !_pingId && _pingSendAt <= getms(true)) {
|
||||||
_pingIdToSend = MTP::nonce<mtpPingId>();
|
_pingIdToSend = rand_value<mtpPingId>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_pingIdToSend) {
|
if (_pingIdToSend) {
|
||||||
|
@ -3317,7 +3317,7 @@ void ConnectionPrivate::updateAuthKey() {
|
||||||
authKeyData = new ConnectionPrivate::AuthKeyCreateData();
|
authKeyData = new ConnectionPrivate::AuthKeyCreateData();
|
||||||
authKeyStrings = new ConnectionPrivate::AuthKeyCreateStrings();
|
authKeyStrings = new ConnectionPrivate::AuthKeyCreateStrings();
|
||||||
authKeyData->req_num = 0;
|
authKeyData->req_num = 0;
|
||||||
authKeyData->nonce = MTP::nonce<MTPint128>();
|
authKeyData->nonce = rand_value<MTPint128>();
|
||||||
|
|
||||||
MTPReq_pq req_pq;
|
MTPReq_pq req_pq;
|
||||||
req_pq.vnonce = authKeyData->nonce;
|
req_pq.vnonce = authKeyData->nonce;
|
||||||
|
@ -3390,7 +3390,7 @@ void ConnectionPrivate::pqAnswered() {
|
||||||
return restart();
|
return restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
authKeyData->new_nonce = MTP::nonce<MTPint256>();
|
authKeyData->new_nonce = rand_value<MTPint256>();
|
||||||
p_q_inner_data.vnew_nonce = authKeyData->new_nonce;
|
p_q_inner_data.vnew_nonce = authKeyData->new_nonce;
|
||||||
|
|
||||||
MTPReq_DH_params req_DH_params;
|
MTPReq_DH_params req_DH_params;
|
||||||
|
@ -3748,7 +3748,7 @@ void ConnectionPrivate::authKeyCreated() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_pingIdToSend = MTP::nonce<uint64>(); // get server_salt
|
_pingIdToSend = rand_value<uint64>(); // get server_salt
|
||||||
|
|
||||||
emit needToSendAsync();
|
emit needToSendAsync();
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,13 +192,6 @@ void clearGlobalHandlers();
|
||||||
|
|
||||||
void updateDcOptions(const QVector<MTPDcOption> &options);
|
void updateDcOptions(const QVector<MTPDcOption> &options);
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
T nonce() {
|
|
||||||
T result;
|
|
||||||
memset_rand(&result, sizeof(T));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
mtpKeysMap getKeys();
|
mtpKeysMap getKeys();
|
||||||
void setKey(int32 dc, mtpAuthKeyPtr key);
|
void setKey(int32 dc, mtpAuthKeyPtr key);
|
||||||
|
|
||||||
|
|
|
@ -78,8 +78,7 @@ public:
|
||||||
}
|
}
|
||||||
void setKey(const mtpAuthKeyPtr &key) {
|
void setKey(const mtpAuthKeyPtr &key) {
|
||||||
if (_authKey != key) {
|
if (_authKey != key) {
|
||||||
uint64 session;
|
uint64 session = rand_value<uint64>();
|
||||||
memsetrnd(session);
|
|
||||||
_authKey = key;
|
_authKey = key;
|
||||||
|
|
||||||
DEBUG_LOG(("MTP Info: new auth key set in SessionData, id %1, setting random server_session %2").arg(key ? key->keyId() : 0).arg(session));
|
DEBUG_LOG(("MTP Info: new auth key set in SessionData, id %1, setting random server_session %2").arg(key ? key->keyId() : 0).arg(session));
|
||||||
|
|
|
@ -3241,7 +3241,7 @@ QString toastImage(const StorageKey &key, PeerData *peer) {
|
||||||
} else {
|
} else {
|
||||||
v.until = 0;
|
v.until = 0;
|
||||||
}
|
}
|
||||||
v.path = cWorkingDir() + qsl("tdata/temp/") + QString::number(MTP::nonce<uint64>(), 16) + qsl(".png");
|
v.path = cWorkingDir() + qsl("tdata/temp/") + QString::number(rand_value<uint64>(), 16) + qsl(".png");
|
||||||
if (key.first || key.second) {
|
if (key.first || key.second) {
|
||||||
peer->saveUserpic(v.path);
|
peer->saveUserpic(v.path);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -2655,7 +2655,7 @@ void psWriteDump() {
|
||||||
// } else {
|
// } else {
|
||||||
// v.until = 0;
|
// v.until = 0;
|
||||||
// }
|
// }
|
||||||
// v.path = cWorkingDir() + qsl("tdata/temp/") + QString::number(MTP::nonce<uint64>(), 16) + qsl(".png");
|
// v.path = cWorkingDir() + qsl("tdata/temp/") + QString::number(rand_value<uint64>(), 16) + qsl(".png");
|
||||||
// if (key.first || key.second) {
|
// if (key.first || key.second) {
|
||||||
// peer->saveUserpic(v.path);
|
// peer->saveUserpic(v.path);
|
||||||
// } else {
|
// } else {
|
||||||
|
|
|
@ -239,11 +239,13 @@ inline char *hashMd5Hex(const void *data, uint32 len, void *dest) { // dest = pt
|
||||||
return hashMd5Hex(HashMd5(data, len).result(), dest);
|
return hashMd5Hex(HashMd5(data, len).result(), dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// good random (using openssl implementation)
|
||||||
void memset_rand(void *data, uint32 len);
|
void memset_rand(void *data, uint32 len);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline void memsetrnd(T &value) {
|
T rand_value() {
|
||||||
memset_rand(&value, sizeof(value));
|
T result;
|
||||||
|
memset_rand(&result, sizeof(result));
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void memset_rand_bad(void *data, uint32 len) {
|
inline void memset_rand_bad(void *data, uint32 len) {
|
||||||
|
|
Loading…
Reference in New Issue