1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Revert "Always offer avatars to friend who come online"

This reverts commit e30fb4d919.
This commit is contained in:
tux3 2015-12-19 04:20:05 +01:00
parent 7319df10e8
commit 8f06dfe254
No known key found for this signature in database
GPG Key ID: 7E086DD661263264
2 changed files with 9 additions and 1 deletions

View File

@ -24,6 +24,7 @@
#include <QDebug>
QByteArray AvatarBroadcaster::avatarData;
QMap<uint32_t, bool> AvatarBroadcaster::friendsSentTo;
static QMetaObject::Connection autoBroadcastConn;
static auto autoBroadcast = [](uint32_t friendId, Status)
@ -34,6 +35,7 @@ static auto autoBroadcast = [](uint32_t friendId, Status)
void AvatarBroadcaster::setAvatar(QByteArray data)
{
avatarData = data;
friendsSentTo.clear();
QVector<uint32_t> friends = Core::getInstance()->getFriendList();
for (uint32_t friendId : friends)
@ -42,9 +44,12 @@ void AvatarBroadcaster::setAvatar(QByteArray data)
void AvatarBroadcaster::sendAvatarTo(uint32_t friendId)
{
if (friendsSentTo.contains(friendId) && friendsSentTo[friendId])
return;
if (!Core::getInstance()->isFriendOnline(friendId))
return;
Core::getInstance()->sendAvatarFile(friendId, avatarData);
friendsSentTo[friendId] = true;
}
void AvatarBroadcaster::enableAutoBroadcast(bool state)

View File

@ -24,7 +24,9 @@
#include <QByteArray>
#include <QMap>
/// Takes care of broadcasting avatar changes to our friends
/// Takes care of broadcasting avatar changes to our friends in a smart way
/// Cache a copy of our current avatar and friends who have received it
/// so we don't spam avatar transfers to a friend who already has it.
class AvatarBroadcaster
{
private:
@ -40,6 +42,7 @@ public:
private:
static QByteArray avatarData;
static QMap<uint32_t, bool> friendsSentTo;
};
#endif // AVATARBROADCASTER_H