safePasswords #36

Manually merged
blue merged 9 commits from safePasswords into master 2020-04-14 16:32:29 +00:00
3 changed files with 40 additions and 17 deletions
Showing only changes of commit 95f0d4008a - Show all commits

View File

@ -1374,13 +1374,13 @@ void Core::Account::addNewRoom(const QString& jid, const QString& nick, const QS
bool hasAvatar = conf->readAvatarInfo(info); bool hasAvatar = conf->readAvatarInfo(info);
if (hasAvatar) { if (hasAvatar) {
if (info.autogenerated) { if (info.autogenerated) {
cData.insert("avatarState", static_cast<uint>(Shared::Avatar::valid)); cData.insert("avatarState", QVariant::fromValue(Shared::Avatar::autocreated));
} else { } else {
cData.insert("avatarState", static_cast<uint>(Shared::Avatar::autocreated)); cData.insert("avatarState", QVariant::fromValue(Shared::Avatar::valid));
} }
cData.insert("avatarPath", conf->avatarPath() + "." + info.type); cData.insert("avatarPath", conf->avatarPath() + "." + info.type);
} else { } else {
cData.insert("avatarState", static_cast<uint>(Shared::Avatar::empty)); cData.insert("avatarState", QVariant::fromValue(Shared::Avatar::empty));
cData.insert("avatarPath", ""); cData.insert("avatarPath", "");
requestVCard(jid); requestVCard(jid);
} }

View File

@ -134,17 +134,20 @@ void Core::Conference::onRoomParticipantAdded(const QString& p_name)
{ {
QStringList comps = p_name.split("/"); QStringList comps = p_name.split("/");
QString resource = comps.back(); QString resource = comps.back();
if (resource == jid) {
qDebug() << "Room" << jid << "is reporting of adding itself to the list participants. Not sure what to do with that yet, skipping";
} else {
QXmppPresence pres = room->participantPresence(p_name); QXmppPresence pres = room->participantPresence(p_name);
QXmppMucItem mi = pres.mucItem();
if (resource == jid) {
resource = "";
}
Archive::AvatarInfo info;
bool hasAvatar = readAvatarInfo(info, resource);
if (resource.size() > 0) {
QDateTime lastInteraction = pres.lastUserInteraction(); QDateTime lastInteraction = pres.lastUserInteraction();
if (!lastInteraction.isValid()) { if (!lastInteraction.isValid()) {
lastInteraction = QDateTime::currentDateTimeUtc(); lastInteraction = QDateTime::currentDateTimeUtc();
} }
QXmppMucItem mi = pres.mucItem();
Archive::AvatarInfo info;
bool hasAvatar = readAvatarInfo(info, resource);
QMap<QString, QVariant> cData = { QMap<QString, QVariant> cData = {
{"lastActivity", lastInteraction}, {"lastActivity", lastInteraction},
@ -169,22 +172,43 @@ void Core::Conference::onRoomParticipantAdded(const QString& p_name)
emit addParticipant(resource, cData); emit addParticipant(resource, cData);
} }
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
if (!hasAvatar || !info.autogenerated) {
setAutoGeneratedAvatar(resource);
}
}
break;
case QXmppPresence::VCardUpdateValidPhoto:{ //there is a photo, need to load
if (hasAvatar) {
if (info.autogenerated || info.hash != pres.photoHash()) {
emit requestVCard(p_name);
}
} else {
emit requestVCard(p_name);
}
break;
}
}
} }
void Core::Conference::onRoomParticipantChanged(const QString& p_name) void Core::Conference::onRoomParticipantChanged(const QString& p_name)
{ {
QStringList comps = p_name.split("/"); QStringList comps = p_name.split("/");
QString resource = comps.back(); QString resource = comps.back();
if (resource == jid) {
qDebug() << "Room" << jid << "is reporting of changing his own presence. Not sure what to do with that yet, skipping";
} else {
QXmppPresence pres = room->participantPresence(p_name); QXmppPresence pres = room->participantPresence(p_name);
QXmppMucItem mi = pres.mucItem();
handlePresence(pres);
if (resource != jid) {
QDateTime lastInteraction = pres.lastUserInteraction(); QDateTime lastInteraction = pres.lastUserInteraction();
if (!lastInteraction.isValid()) { if (!lastInteraction.isValid()) {
lastInteraction = QDateTime::currentDateTimeUtc(); lastInteraction = QDateTime::currentDateTimeUtc();
} }
QXmppMucItem mi = pres.mucItem();
handlePresence(pres);
emit changeParticipant(resource, { emit changeParticipant(resource, {
{"lastActivity", lastInteraction}, {"lastActivity", lastInteraction},
@ -265,7 +289,7 @@ bool Core::Conference::setAutoGeneratedAvatar(const QString& resource)
if (result && resource.size() != 0) { if (result && resource.size() != 0) {
emit changeParticipant(resource, { emit changeParticipant(resource, {
{"avatarState", static_cast<uint>(Shared::Avatar::autocreated)}, {"avatarState", static_cast<uint>(Shared::Avatar::autocreated)},
{"availability", avatarPath(resource) + ".png"} {"avatarPath", avatarPath(resource) + ".png"}
}); });
} }

View File

@ -501,7 +501,6 @@ Shared::VCard Core::RosterItem::handleResponseVCard(const QXmppVCardIq& card, co
path = avatarPath(resource) + ".png"; path = avatarPath(resource) + ".png";
} }
vCard.setAvatarType(type); vCard.setAvatarType(type);
vCard.setAvatarPath(path); vCard.setAvatarPath(path);