This commit is contained in:
John Preston 2016-10-03 11:22:43 +03:00
commit 1a645a8496
7 changed files with 829 additions and 1390 deletions

View File

@ -567,7 +567,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
"lng_action_changed_title" = "{from} changed group name to «{title}»";
"lng_action_changed_title_channel" = "Channel name was changed to «{title}»";
"lng_action_created_chat" = "{from} created group «{title}»";
"lng_action_created_channel" = "Channel «{title}» created";
"lng_action_created_channel" = "Channel created";
"lng_action_group_migrate" = "The group was upgraded to a supergroup";
"lng_action_pinned_message" = "{from} pinned «{text}»";
"lng_action_pinned_media" = "{from} pinned {media}";

View File

@ -1808,7 +1808,7 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) {
case mtpc_messageActionChannelCreate: {
auto &d = action.c_messageActionChannelCreate();
if (isPost()) {
text = lng_action_created_channel(lt_title, textClean(qs(d.vtitle)));
text = lang(lng_action_created_channel);
} else {
text = lng_action_created_chat(lt_from, from, lt_title, textClean(qs(d.vtitle)));
}

View File

@ -44,17 +44,17 @@ public:
}
uint32 getDC() const {
if (!_isset) throw mtpErrorKeyNotReady("getDC()");
t_assert(_isset);
return _dc;
}
uint64 keyId() const {
if (!_isset) throw mtpErrorKeyNotReady("keyId()");
t_assert(_isset);
return _keyId;
}
void prepareAES(const MTPint128 &msgKey, MTPint256 &aesKey, MTPint256 &aesIV, bool send = true) const {
if (!_isset) throw mtpErrorKeyNotReady(QString("prepareAES(..., %1)").arg(Logs::b(send)));
t_assert(_isset);
uint32 x = send ? 0 : 8;
@ -90,7 +90,7 @@ public:
}
void write(QDataStream &to) const {
if (!_isset) throw mtpErrorKeyNotReady("write(...)");
t_assert(_isset);
to.writeRawData(_key, 256);
}

View File

@ -199,30 +199,12 @@ public:
}
};
class mtpErrorUninitialized : public Exception {
public:
mtpErrorUninitialized() : Exception("MTP Uninitialized variable write attempt") {
}
};
class mtpErrorBadTypeId : public Exception {
public:
mtpErrorBadTypeId(mtpTypeId typeId, const QString &type) : Exception(QString("MTP Bad type id %1 passed to constructor of %2").arg(typeId).arg(type)) {
}
};
class mtpErrorWrongTypeId : public Exception {
public:
mtpErrorWrongTypeId(mtpTypeId typeId, mtpTypeId required) : Exception(QString("MTP Wrong type id %1 for this data conversion, must be %2").arg(typeId).arg(required)) {
}
};
class mtpErrorKeyNotReady : public Exception {
public:
mtpErrorKeyNotReady(const QString &method) : Exception(QString("MTP Auth key is used in %1 without being created").arg(method)) {
}
};
class mtpData {
public:
mtpData() : cnt(1) {
@ -686,12 +668,12 @@ public:
}
MTPDstring &_string() {
if (!data) throw mtpErrorUninitialized();
t_assert(data != nullptr);
split();
return *(MTPDstring*)data;
}
const MTPDstring &c_string() const {
if (!data) throw mtpErrorUninitialized();
t_assert(data != nullptr);
return *(const MTPDstring*)data;
}
@ -823,12 +805,12 @@ public:
}
MTPDvector<T> &_vector() {
if (!data) throw mtpErrorUninitialized();
t_assert(data != nullptr);
split();
return *(MTPDvector<T>*)data;
}
const MTPDvector<T> &c_vector() const {
if (!data) throw mtpErrorUninitialized();
t_assert(data != nullptr);
return *(const MTPDvector<T>*)data;
}

View File

@ -22,7 +22,7 @@ import glob
import re
import binascii
# define some checked flag convertions
# define some checked flag conversions
# the key flag type should be a subset of the value flag type
# with exact the same names, then the key flag can be implicitly
# casted to the value flag type
@ -612,17 +612,19 @@ for restype in typesList:
withData = 1;
getters += '\n\tMTPD' + name + ' &_' + name + '() {\n'; # splitting getter
getters += '\t\tif (!data) throw mtpErrorUninitialized();\n';
if (withType):
getters += '\t\tif (_type != mtpc_' + name + ') throw mtpErrorWrongTypeId(_type, mtpc_' + name + ');\n';
getters += '\t\tt_assert(data != nullptr && _type == mtpc_' + name + ');\n';
else:
getters += '\t\tt_assert(data != nullptr);\n';
getters += '\t\tsplit();\n';
getters += '\t\treturn *(MTPD' + name + '*)data;\n';
getters += '\t}\n';
getters += '\tconst MTPD' + name + ' &c_' + name + '() const {\n'; # const getter
getters += '\t\tif (!data) throw mtpErrorUninitialized();\n';
if (withType):
getters += '\t\tif (_type != mtpc_' + name + ') throw mtpErrorWrongTypeId(_type, mtpc_' + name + ');\n';
getters += '\t\tt_assert(data != nullptr && _type == mtpc_' + name + ');\n';
else:
getters += '\t\tt_assert(data != nullptr);\n';
getters += '\t\treturn *(const MTPD' + name + '*)data;\n';
getters += '\t}\n';
@ -783,7 +785,7 @@ for restype in typesList:
typesText += '\tmtpTypeId type() const;\n'; # type id method
inlineMethods += 'inline mtpTypeId MTP' + restype + '::type() const {\n';
if (withType):
inlineMethods += '\tif (!_type) throw mtpErrorUninitialized();\n';
inlineMethods += '\tt_assert(_type != 0);\n';
inlineMethods += '\treturn _type;\n';
else:
inlineMethods += '\treturn mtpc_' + v[0][0] + ';\n';

File diff suppressed because it is too large Load Diff

View File

@ -67,7 +67,8 @@ CoverWidget::CoverWidget(QWidget *parent, PeerData *peer) : TWidget(parent)
auto observeEvents = ButtonsUpdateFlags
| UpdateFlag::NameChanged
| UpdateFlag::UserOnlineChanged;
| UpdateFlag::UserOnlineChanged
| UpdateFlag::MembersChanged;
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(observeEvents, [this](const Notify::PeerUpdate &update) {
notifyPeerUpdated(update);
}));
@ -336,7 +337,7 @@ void CoverWidget::notifyPeerUpdated(const Notify::PeerUpdate &update) {
if (update.flags & UpdateFlag::NameChanged) {
refreshNameText();
}
if (update.flags & UpdateFlag::UserOnlineChanged) {
if (update.flags & (UpdateFlag::UserOnlineChanged | UpdateFlag::MembersChanged)) {
refreshStatusText();
}
}