| 111 | } |
| 112 | |
| 113 | uint32 peerSize(not_null<PeerData*> peer) { |
| 114 | uint32 result = sizeof(quint64) // id |
| 115 | + sizeof(quint64) // version tag |
| 116 | + sizeof(qint32) // version |
| 117 | + sizeof(quint64) // userpic photo id |
| 118 | + imageLocationSize(peer->userpicLocation()) |
| 119 | + sizeof(qint32); // userpic has video |
| 120 | if (const auto user = peer->asUser()) { |
| 121 | const auto botInlinePlaceholder = user->isBot() |
| 122 | ? user->botInfo->inlinePlaceholder |
| 123 | : QString(); |
| 124 | result += stringSize(user->firstName) |
| 125 | + stringSize(user->lastName) |
| 126 | + stringSize(user->phone()) |
| 127 | + stringSize(user->username()) |
| 128 | + sizeof(quint64) // access |
| 129 | + sizeof(qint32) // flags |
| 130 | + stringSize(botInlinePlaceholder) |
| 131 | + sizeof(quint32) // lastseen |
| 132 | + sizeof(qint32) // contact |
| 133 | + sizeof(qint32) // botInfoVersion |
| 134 | + sizeof(qint32); // supportsGuestChat |
| 135 | } else if (const auto chat = peer->asChat()) { |
| 136 | result += stringSize(chat->name()) |
| 137 | + sizeof(qint32) // count |
| 138 | + sizeof(qint32) // date |
| 139 | + sizeof(qint32) // version |
| 140 | + sizeof(qint32) // creator id 1 |
| 141 | + sizeof(qint32) // creator id 2 |
| 142 | + sizeof(quint32) // flags |
| 143 | + stringSize(chat->inviteLink()); |
| 144 | } else if (const auto channel = peer->asChannel()) { |
| 145 | result += stringSize(channel->name()) |
| 146 | + sizeof(quint64) // access |
| 147 | + sizeof(qint32) // date |
| 148 | + sizeof(qint32) // version |
| 149 | + sizeof(qint32) // old forbidden |
| 150 | + sizeof(quint32) // flags |
| 151 | + stringSize(channel->inviteLink()); |
| 152 | } |
| 153 | return result; |
| 154 | } |
| 155 | |
| 156 | void writePeer(QDataStream &stream, not_null<PeerData*> peer) { |
| 157 | stream |
no test coverage detected