muc participant avatars

This commit is contained in:
Blue 2019-12-30 23:22:04 +03:00
parent efc90e18c3
commit 55703c2007
15 changed files with 506 additions and 221 deletions

View file

@ -68,3 +68,33 @@ void Core::Contact::setSubscriptionState(Shared::SubscriptionState state)
emit subscriptionStateChanged(subscriptionState);
}
}
void Core::Contact::handlePresence(const QXmppPresence& pres)
{
switch (pres.vCardUpdateType()) {
case QXmppPresence::VCardUpdateNone: //this presence has nothing to do with photo
break;
case QXmppPresence::VCardUpdateNotReady: //let's say the photo didn't change here
break;
case QXmppPresence::VCardUpdateNoPhoto: { //there is no photo, need to drop if any
Archive::AvatarInfo info;
bool hasAvatar = readAvatarInfo(info);
if (!hasAvatar || !info.autogenerated) {
setAutoGeneratedAvatar();
}
}
break;
case QXmppPresence::VCardUpdateValidPhoto:{ //there is a photo, need to load
Archive::AvatarInfo info;
bool hasAvatar = readAvatarInfo(info);
if (hasAvatar) {
if (info.autogenerated || info.hash != pres.photoHash()) {
emit requestVCard(jid);
}
} else {
emit requestVCard(jid);
}
break;
}
}
}