safePasswords #36
@ -14,6 +14,7 @@
|
|||||||
- going offline related segfault fix
|
- going offline related segfault fix
|
||||||
- statuses now behave better: they wrap if they don't fit, you can select them, you can follow links from there
|
- statuses now behave better: they wrap if they don't fit, you can select them, you can follow links from there
|
||||||
- messages and statuses don't loose content if you use < ore > symbols
|
- messages and statuses don't loose content if you use < ore > symbols
|
||||||
|
- now avatars of those who are not in the MUC right now but was also display next to the message
|
||||||
|
|
||||||
|
|
||||||
## Squawk 0.1.3 (Mar 31, 2020)
|
## Squawk 0.1.3 (Mar 31, 2020)
|
||||||
|
@ -1063,6 +1063,7 @@ void Core::Account::onContactHistoryResponse(const std::list<Shared::Message>& l
|
|||||||
|
|
||||||
void Core::Account::onClientError(QXmppClient::Error err)
|
void Core::Account::onClientError(QXmppClient::Error err)
|
||||||
{
|
{
|
||||||
|
qDebug() << "Error";
|
||||||
QString errorText;
|
QString errorText;
|
||||||
QString errorType;
|
QString errorType;
|
||||||
switch (err) {
|
switch (err) {
|
||||||
@ -1140,6 +1141,9 @@ void Core::Account::onClientError(QXmppClient::Error err)
|
|||||||
case QXmppStanza::Error::UnexpectedRequest:
|
case QXmppStanza::Error::UnexpectedRequest:
|
||||||
errorText = "Unexpected request";
|
errorText = "Unexpected request";
|
||||||
break;
|
break;
|
||||||
|
case QXmppStanza::Error::PolicyViolation:
|
||||||
|
errorText = "Policy violation";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
errorType = "Client stream error";
|
errorType = "Client stream error";
|
||||||
@ -1367,7 +1371,8 @@ void Core::Account::addNewRoom(const QString& jid, const QString& nick, const QS
|
|||||||
{"autoJoin", conf->getAutoJoin()},
|
{"autoJoin", conf->getAutoJoin()},
|
||||||
{"joined", conf->getJoined()},
|
{"joined", conf->getJoined()},
|
||||||
{"nick", conf->getNick()},
|
{"nick", conf->getNick()},
|
||||||
{"name", conf->getName()}
|
{"name", conf->getName()},
|
||||||
|
{"avatars", conf->getAllAvatars()}
|
||||||
};
|
};
|
||||||
|
|
||||||
Archive::AvatarInfo info;
|
Archive::AvatarInfo info;
|
||||||
|
@ -675,7 +675,7 @@ bool Core::Archive::dropAvatar(const std::string& resource)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Core::Archive::setAvatar(const QByteArray& data, bool generated, const QString& resource)
|
bool Core::Archive::setAvatar(const QByteArray& data, AvatarInfo& newInfo, bool generated, const QString& resource)
|
||||||
{
|
{
|
||||||
if (!opened) {
|
if (!opened) {
|
||||||
throw Closed("setAvatar", jid.toStdString());
|
throw Closed("setAvatar", jid.toStdString());
|
||||||
@ -726,7 +726,9 @@ bool Core::Archive::setAvatar(const QByteArray& data, bool generated, const QStr
|
|||||||
|
|
||||||
MDB_val lmdbKey, lmdbData;
|
MDB_val lmdbKey, lmdbData;
|
||||||
QByteArray value;
|
QByteArray value;
|
||||||
AvatarInfo newInfo(ext, newHash, generated);
|
newInfo.type = ext;
|
||||||
|
newInfo.hash = newHash;
|
||||||
|
newInfo.autogenerated = generated;
|
||||||
newInfo.serialize(&value);
|
newInfo.serialize(&value);
|
||||||
lmdbKey.mv_size = res.size();
|
lmdbKey.mv_size = res.size();
|
||||||
lmdbKey.mv_data = (char*)res.c_str();
|
lmdbKey.mv_data = (char*)res.c_str();
|
||||||
@ -802,6 +804,33 @@ bool Core::Archive::readAvatarInfo(Core::Archive::AvatarInfo& target, const std:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Core::Archive::readAllResourcesAvatars(std::map<QString, AvatarInfo>& data) const
|
||||||
|
{
|
||||||
|
if (!opened) {
|
||||||
|
throw Closed("readAllResourcesAvatars", jid.toStdString());
|
||||||
|
}
|
||||||
|
|
||||||
|
int rc;
|
||||||
|
MDB_val lmdbKey, lmdbData;
|
||||||
|
MDB_txn *txn;
|
||||||
|
MDB_cursor* cursor;
|
||||||
|
mdb_txn_begin(environment, NULL, MDB_RDONLY, &txn);
|
||||||
|
mdb_cursor_open(txn, avatars, &cursor);
|
||||||
|
rc = mdb_cursor_get(cursor, &lmdbKey, &lmdbData, MDB_FIRST);
|
||||||
|
|
||||||
|
do {
|
||||||
|
std::string sId((char*)lmdbKey.mv_data, lmdbKey.mv_size);
|
||||||
|
QString res(sId.c_str());
|
||||||
|
if (res != jid) {
|
||||||
|
data.emplace(res, AvatarInfo());
|
||||||
|
data[res].deserialize((char*)lmdbData.mv_data, lmdbData.mv_size);
|
||||||
|
}
|
||||||
|
} while (mdb_cursor_get(cursor, &lmdbKey, &lmdbData, MDB_NEXT) == 0);
|
||||||
|
|
||||||
|
mdb_cursor_close(cursor);
|
||||||
|
mdb_txn_abort(txn);
|
||||||
|
}
|
||||||
|
|
||||||
Core::Archive::AvatarInfo Core::Archive::getAvatarInfo(const QString& resource) const
|
Core::Archive::AvatarInfo Core::Archive::getAvatarInfo(const QString& resource) const
|
||||||
{
|
{
|
||||||
if (!opened) {
|
if (!opened) {
|
||||||
|
@ -56,9 +56,10 @@ public:
|
|||||||
std::list<Shared::Message> getBefore(int count, const QString& id);
|
std::list<Shared::Message> getBefore(int count, const QString& id);
|
||||||
bool isFromTheBeginning();
|
bool isFromTheBeginning();
|
||||||
void setFromTheBeginning(bool is);
|
void setFromTheBeginning(bool is);
|
||||||
bool setAvatar(const QByteArray& data, bool generated = false, const QString& resource = "");
|
bool setAvatar(const QByteArray& data, AvatarInfo& info, bool generated = false, const QString& resource = "");
|
||||||
AvatarInfo getAvatarInfo(const QString& resource = "") const;
|
AvatarInfo getAvatarInfo(const QString& resource = "") const;
|
||||||
bool readAvatarInfo(AvatarInfo& target, const QString& resource = "") const;
|
bool readAvatarInfo(AvatarInfo& target, const QString& resource = "") const;
|
||||||
|
void readAllResourcesAvatars(std::map<QString, AvatarInfo>& data) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const QString jid;
|
const QString jid;
|
||||||
|
@ -25,7 +25,8 @@ Core::Conference::Conference(const QString& p_jid, const QString& p_account, boo
|
|||||||
nick(p_nick),
|
nick(p_nick),
|
||||||
room(p_room),
|
room(p_room),
|
||||||
joined(false),
|
joined(false),
|
||||||
autoJoin(p_autoJoin)
|
autoJoin(p_autoJoin),
|
||||||
|
exParticipants()
|
||||||
{
|
{
|
||||||
muc = true;
|
muc = true;
|
||||||
name = p_name;
|
name = p_name;
|
||||||
@ -44,6 +45,8 @@ Core::Conference::Conference(const QString& p_jid, const QString& p_account, boo
|
|||||||
if (autoJoin) {
|
if (autoJoin) {
|
||||||
room->join();
|
room->join();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
archive->readAllResourcesAvatars(exParticipants);
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::Conference::~Conference()
|
Core::Conference::~Conference()
|
||||||
@ -140,8 +143,8 @@ void Core::Conference::onRoomParticipantAdded(const QString& p_name)
|
|||||||
resource = "";
|
resource = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
Archive::AvatarInfo info;
|
std::map<QString, Archive::AvatarInfo>::const_iterator itr = exParticipants.find(resource);
|
||||||
bool hasAvatar = readAvatarInfo(info, resource);
|
bool hasAvatar = itr != exParticipants.end();
|
||||||
|
|
||||||
if (resource.size() > 0) {
|
if (resource.size() > 0) {
|
||||||
QDateTime lastInteraction = pres.lastUserInteraction();
|
QDateTime lastInteraction = pres.lastUserInteraction();
|
||||||
@ -158,12 +161,12 @@ void Core::Conference::onRoomParticipantAdded(const QString& p_name)
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (hasAvatar) {
|
if (hasAvatar) {
|
||||||
if (info.autogenerated) {
|
if (itr->second.autogenerated) {
|
||||||
cData.insert("avatarState", static_cast<uint>(Shared::Avatar::valid));
|
cData.insert("avatarState", static_cast<uint>(Shared::Avatar::valid));
|
||||||
} else {
|
} else {
|
||||||
cData.insert("avatarState", static_cast<uint>(Shared::Avatar::autocreated));
|
cData.insert("avatarState", static_cast<uint>(Shared::Avatar::autocreated));
|
||||||
}
|
}
|
||||||
cData.insert("avatarPath", avatarPath(resource) + "." + info.type);
|
cData.insert("avatarPath", avatarPath(resource) + "." + itr->second.type);
|
||||||
} else {
|
} else {
|
||||||
cData.insert("avatarState", static_cast<uint>(Shared::Avatar::empty));
|
cData.insert("avatarState", static_cast<uint>(Shared::Avatar::empty));
|
||||||
cData.insert("avatarPath", "");
|
cData.insert("avatarPath", "");
|
||||||
@ -179,14 +182,14 @@ void Core::Conference::onRoomParticipantAdded(const QString& p_name)
|
|||||||
case QXmppPresence::VCardUpdateNotReady: //let's say the photo didn't change here
|
case QXmppPresence::VCardUpdateNotReady: //let's say the photo didn't change here
|
||||||
break;
|
break;
|
||||||
case QXmppPresence::VCardUpdateNoPhoto: { //there is no photo, need to drop if any
|
case QXmppPresence::VCardUpdateNoPhoto: { //there is no photo, need to drop if any
|
||||||
if (!hasAvatar || !info.autogenerated) {
|
if (!hasAvatar || !itr->second.autogenerated) {
|
||||||
setAutoGeneratedAvatar(resource);
|
setAutoGeneratedAvatar(resource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case QXmppPresence::VCardUpdateValidPhoto:{ //there is a photo, need to load
|
case QXmppPresence::VCardUpdateValidPhoto:{ //there is a photo, need to load
|
||||||
if (hasAvatar) {
|
if (hasAvatar) {
|
||||||
if (info.autogenerated || info.hash != pres.photoHash()) {
|
if (itr->second.autogenerated || itr->second.hash != pres.photoHash()) {
|
||||||
emit requestVCard(p_name);
|
emit requestVCard(p_name);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -285,30 +288,46 @@ void Core::Conference::handlePresence(const QXmppPresence& pres)
|
|||||||
|
|
||||||
bool Core::Conference::setAutoGeneratedAvatar(const QString& resource)
|
bool Core::Conference::setAutoGeneratedAvatar(const QString& resource)
|
||||||
{
|
{
|
||||||
bool result = RosterItem::setAutoGeneratedAvatar(resource);
|
Archive::AvatarInfo newInfo;
|
||||||
|
bool result = RosterItem::setAutoGeneratedAvatar(newInfo, resource);
|
||||||
if (result && resource.size() != 0) {
|
if (result && resource.size() != 0) {
|
||||||
|
std::map<QString, Archive::AvatarInfo>::iterator itr = exParticipants.find(resource);
|
||||||
|
if (itr == exParticipants.end()) {
|
||||||
|
exParticipants.insert(std::make_pair(resource, newInfo));
|
||||||
|
} else {
|
||||||
|
itr->second = newInfo;
|
||||||
|
}
|
||||||
emit changeParticipant(resource, {
|
emit changeParticipant(resource, {
|
||||||
{"avatarState", static_cast<uint>(Shared::Avatar::autocreated)},
|
{"avatarState", static_cast<uint>(Shared::Avatar::autocreated)},
|
||||||
{"avatarPath", avatarPath(resource) + ".png"}
|
{"avatarPath", avatarPath(resource) + "." + newInfo.type}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Core::Conference::setAvatar(const QByteArray& data, const QString& resource)
|
bool Core::Conference::setAvatar(const QByteArray& data, Archive::AvatarInfo& info, const QString& resource)
|
||||||
{
|
{
|
||||||
bool result = RosterItem::setAvatar(data, resource);
|
bool result = RosterItem::setAvatar(data, info, resource);
|
||||||
if (result && resource.size() != 0) {
|
if (result && resource.size() != 0) {
|
||||||
if (data.size() > 0) {
|
if (data.size() > 0) {
|
||||||
QMimeDatabase db;
|
std::map<QString, Archive::AvatarInfo>::iterator itr = exParticipants.find(resource);
|
||||||
QMimeType type = db.mimeTypeForData(data);
|
if (itr == exParticipants.end()) {
|
||||||
QString ext = type.preferredSuffix();
|
exParticipants.insert(std::make_pair(resource, info));
|
||||||
|
} else {
|
||||||
|
itr->second = info;
|
||||||
|
}
|
||||||
|
|
||||||
emit changeParticipant(resource, {
|
emit changeParticipant(resource, {
|
||||||
{"avatarState", static_cast<uint>(Shared::Avatar::autocreated)},
|
{"avatarState", static_cast<uint>(Shared::Avatar::autocreated)},
|
||||||
{"avatarPath", avatarPath(resource) + "." + ext}
|
{"avatarPath", avatarPath(resource) + "." + info.type}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
std::map<QString, Archive::AvatarInfo>::iterator itr = exParticipants.find(resource);
|
||||||
|
if (itr != exParticipants.end()) {
|
||||||
|
exParticipants.erase(itr);
|
||||||
|
}
|
||||||
|
|
||||||
emit changeParticipant(resource, {
|
emit changeParticipant(resource, {
|
||||||
{"avatarState", static_cast<uint>(Shared::Avatar::empty)},
|
{"avatarState", static_cast<uint>(Shared::Avatar::empty)},
|
||||||
{"avatarPath", ""}
|
{"avatarPath", ""}
|
||||||
@ -333,3 +352,12 @@ Shared::VCard Core::Conference::handleResponseVCard(const QXmppVCardIq& card, co
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QMap<QString, QVariant> Core::Conference::getAllAvatars() const
|
||||||
|
{
|
||||||
|
QMap<QString, QVariant> result;
|
||||||
|
for (const std::pair<QString, Archive::AvatarInfo>& pair : exParticipants) {
|
||||||
|
result.insert(pair.first, avatarPath(pair.first) + "." + pair.second.type);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
@ -19,9 +19,15 @@
|
|||||||
#ifndef CORE_CONFERENCE_H
|
#ifndef CORE_CONFERENCE_H
|
||||||
#define CORE_CONFERENCE_H
|
#define CORE_CONFERENCE_H
|
||||||
|
|
||||||
#include "rosteritem.h"
|
#include <QDir>
|
||||||
|
|
||||||
#include <QXmppMucManager.h>
|
#include <QXmppMucManager.h>
|
||||||
|
|
||||||
|
#include <set>
|
||||||
|
|
||||||
|
#include "rosteritem.h"
|
||||||
|
#include "shared/global.h"
|
||||||
|
|
||||||
namespace Core
|
namespace Core
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -46,8 +52,8 @@ public:
|
|||||||
void setAutoJoin(bool p_autoJoin);
|
void setAutoJoin(bool p_autoJoin);
|
||||||
void handlePresence(const QXmppPresence & pres) override;
|
void handlePresence(const QXmppPresence & pres) override;
|
||||||
bool setAutoGeneratedAvatar(const QString& resource = "") override;
|
bool setAutoGeneratedAvatar(const QString& resource = "") override;
|
||||||
bool setAvatar(const QByteArray &data, const QString &resource = "") override;
|
|
||||||
Shared::VCard handleResponseVCard(const QXmppVCardIq & card, const QString &resource) override;
|
Shared::VCard handleResponseVCard(const QXmppVCardIq & card, const QString &resource) override;
|
||||||
|
QMap<QString, QVariant> getAllAvatars() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void nickChanged(const QString& nick);
|
void nickChanged(const QString& nick);
|
||||||
@ -58,11 +64,16 @@ signals:
|
|||||||
void changeParticipant(const QString& name, const QMap<QString, QVariant>& data);
|
void changeParticipant(const QString& name, const QMap<QString, QVariant>& data);
|
||||||
void removeParticipant(const QString& name);
|
void removeParticipant(const QString& name);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool setAvatar(const QByteArray &data, Archive::AvatarInfo& info, const QString &resource = "") override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString nick;
|
QString nick;
|
||||||
QXmppMucRoom* room;
|
QXmppMucRoom* room;
|
||||||
bool joined;
|
bool joined;
|
||||||
bool autoJoin;
|
bool autoJoin;
|
||||||
|
std::map<QString, Archive::AvatarInfo> exParticipants;
|
||||||
|
static const std::set<QString> supportedList;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onRoomJoined();
|
void onRoomJoined();
|
||||||
|
@ -410,28 +410,37 @@ bool Core::RosterItem::isMuc() const
|
|||||||
|
|
||||||
QString Core::RosterItem::avatarPath(const QString& resource) const
|
QString Core::RosterItem::avatarPath(const QString& resource) const
|
||||||
{
|
{
|
||||||
QString path(QStandardPaths::writableLocation(QStandardPaths::CacheLocation));
|
QString path = folderPath() + "/" + (resource.size() == 0 ? jid : resource);
|
||||||
path += "/" + account + "/" + jid + "/" + (resource.size() == 0 ? jid : resource);
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Core::RosterItem::setAvatar(const QByteArray& data, const QString& resource)
|
QString Core::RosterItem::folderPath() const
|
||||||
{
|
{
|
||||||
bool result = archive->setAvatar(data, false, resource);
|
QString path(QStandardPaths::writableLocation(QStandardPaths::CacheLocation));
|
||||||
|
path += "/" + account + "/" + jid;
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Core::RosterItem::setAvatar(const QByteArray& data, Archive::AvatarInfo& info, const QString& resource)
|
||||||
|
{
|
||||||
|
bool result = archive->setAvatar(data, info, false, resource);
|
||||||
if (resource.size() == 0 && result) {
|
if (resource.size() == 0 && result) {
|
||||||
if (data.size() == 0) {
|
if (data.size() == 0) {
|
||||||
emit avatarChanged(Shared::Avatar::empty, "");
|
emit avatarChanged(Shared::Avatar::empty, "");
|
||||||
} else {
|
} else {
|
||||||
QMimeDatabase db;
|
emit avatarChanged(Shared::Avatar::valid, avatarPath(resource) + "." + info.type);
|
||||||
QMimeType type = db.mimeTypeForData(data);
|
|
||||||
QString ext = type.preferredSuffix();
|
|
||||||
emit avatarChanged(Shared::Avatar::valid, avatarPath(resource) + "." + ext);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Core::RosterItem::setAutoGeneratedAvatar(const QString& resource)
|
bool Core::RosterItem::setAutoGeneratedAvatar(const QString& resource)
|
||||||
|
{
|
||||||
|
Archive::AvatarInfo info;
|
||||||
|
return setAutoGeneratedAvatar(info, resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Core::RosterItem::setAutoGeneratedAvatar(Archive::AvatarInfo& info, const QString& resource)
|
||||||
{
|
{
|
||||||
QImage image(96, 96, QImage::Format_ARGB32_Premultiplied);
|
QImage image(96, 96, QImage::Format_ARGB32_Premultiplied);
|
||||||
QPainter painter(&image);
|
QPainter painter(&image);
|
||||||
@ -453,7 +462,7 @@ bool Core::RosterItem::setAutoGeneratedAvatar(const QString& resource)
|
|||||||
stream.open(QBuffer::WriteOnly);
|
stream.open(QBuffer::WriteOnly);
|
||||||
image.save(&stream, "PNG");
|
image.save(&stream, "PNG");
|
||||||
stream.close();
|
stream.close();
|
||||||
bool result = archive->setAvatar(arr, true, resource);
|
bool result = archive->setAvatar(arr, info, true, resource);
|
||||||
if (resource.size() == 0 && result) {
|
if (resource.size() == 0 && result) {
|
||||||
emit avatarChanged(Shared::Avatar::autocreated, avatarPath(resource) + ".png");
|
emit avatarChanged(Shared::Avatar::autocreated, avatarPath(resource) + ".png");
|
||||||
}
|
}
|
||||||
@ -468,6 +477,7 @@ bool Core::RosterItem::readAvatarInfo(Archive::AvatarInfo& target, const QString
|
|||||||
Shared::VCard Core::RosterItem::handleResponseVCard(const QXmppVCardIq& card, const QString& resource)
|
Shared::VCard Core::RosterItem::handleResponseVCard(const QXmppVCardIq& card, const QString& resource)
|
||||||
{
|
{
|
||||||
Archive::AvatarInfo info;
|
Archive::AvatarInfo info;
|
||||||
|
Archive::AvatarInfo newInfo;
|
||||||
bool hasAvatar = readAvatarInfo(info, resource);
|
bool hasAvatar = readAvatarInfo(info, resource);
|
||||||
|
|
||||||
QByteArray ava = card.photo();
|
QByteArray ava = card.photo();
|
||||||
@ -477,13 +487,10 @@ Shared::VCard Core::RosterItem::handleResponseVCard(const QXmppVCardIq& card, co
|
|||||||
QString path = "";
|
QString path = "";
|
||||||
|
|
||||||
if (ava.size() > 0) {
|
if (ava.size() > 0) {
|
||||||
bool changed = setAvatar(ava, resource);
|
bool changed = setAvatar(ava, newInfo, resource);
|
||||||
if (changed) {
|
if (changed) {
|
||||||
type = Shared::Avatar::valid;
|
type = Shared::Avatar::valid;
|
||||||
QMimeDatabase db;
|
path = avatarPath(resource) + "." + newInfo.type;
|
||||||
QMimeType type = db.mimeTypeForData(ava);
|
|
||||||
QString ext = type.preferredSuffix();
|
|
||||||
path = avatarPath(resource) + "." + ext;
|
|
||||||
} else if (hasAvatar) {
|
} else if (hasAvatar) {
|
||||||
if (info.autogenerated) {
|
if (info.autogenerated) {
|
||||||
type = Shared::Avatar::autocreated;
|
type = Shared::Avatar::autocreated;
|
||||||
|
@ -69,8 +69,8 @@ public:
|
|||||||
void requestHistory(int count, const QString& before);
|
void requestHistory(int count, const QString& before);
|
||||||
void requestFromEmpty(int count, const QString& before);
|
void requestFromEmpty(int count, const QString& before);
|
||||||
QString avatarPath(const QString& resource = "") const;
|
QString avatarPath(const QString& resource = "") const;
|
||||||
|
QString folderPath() const;
|
||||||
bool readAvatarInfo(Archive::AvatarInfo& target, const QString& resource = "") const;
|
bool readAvatarInfo(Archive::AvatarInfo& target, const QString& resource = "") const;
|
||||||
virtual bool setAvatar(const QByteArray& data, const QString& resource = "");
|
|
||||||
virtual bool setAutoGeneratedAvatar(const QString& resource = "");
|
virtual bool setAutoGeneratedAvatar(const QString& resource = "");
|
||||||
virtual Shared::VCard handleResponseVCard(const QXmppVCardIq& card, const QString& resource);
|
virtual Shared::VCard handleResponseVCard(const QXmppVCardIq& card, const QString& resource);
|
||||||
virtual void handlePresence(const QXmppPresence& pres) = 0;
|
virtual void handlePresence(const QXmppPresence& pres) = 0;
|
||||||
@ -89,6 +89,10 @@ public:
|
|||||||
const QString jid;
|
const QString jid;
|
||||||
const QString account;
|
const QString account;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual bool setAvatar(const QByteArray& data, Archive::AvatarInfo& info, const QString& resource = "");
|
||||||
|
virtual bool setAutoGeneratedAvatar(Archive::AvatarInfo& info, const QString& resource = "");
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QString name;
|
QString name;
|
||||||
ArchiveState archiveState;
|
ArchiveState archiveState;
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "enums.h"
|
#include "enums.h"
|
||||||
|
|
||||||
Shared::Global* Shared::Global::instance = 0;
|
Shared::Global* Shared::Global::instance = 0;
|
||||||
|
const std::set<QString> Shared::Global::supportedImagesExts = {"png", "jpg", "webp", "jpeg", "gif", "svg"};
|
||||||
|
|
||||||
Shared::Global::Global():
|
Shared::Global::Global():
|
||||||
availability({
|
availability({
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
#include "exception.h"
|
#include "exception.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <set>
|
||||||
|
#include <deque>
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@ -60,6 +62,8 @@ namespace Shared {
|
|||||||
static bool supported(const QString& pluginName);
|
static bool supported(const QString& pluginName);
|
||||||
static void setSupported(const QString& pluginName, bool support);
|
static void setSupported(const QString& pluginName, bool support);
|
||||||
|
|
||||||
|
static const std::set<QString> supportedImagesExts;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static T fromInt(int src);
|
static T fromInt(int src);
|
||||||
|
|
||||||
|
@ -32,7 +32,8 @@ Models::Room::Room(const QString& p_jid, const QMap<QString, QVariant>& data, Mo
|
|||||||
avatarState(Shared::Avatar::empty),
|
avatarState(Shared::Avatar::empty),
|
||||||
avatarPath(""),
|
avatarPath(""),
|
||||||
messages(),
|
messages(),
|
||||||
participants()
|
participants(),
|
||||||
|
exParticipantAvatars()
|
||||||
{
|
{
|
||||||
QMap<QString, QVariant>::const_iterator itr = data.find("autoJoin");
|
QMap<QString, QVariant>::const_iterator itr = data.find("autoJoin");
|
||||||
if (itr != data.end()) {
|
if (itr != data.end()) {
|
||||||
@ -62,6 +63,15 @@ Models::Room::Room(const QString& p_jid, const QMap<QString, QVariant>& data, Mo
|
|||||||
if (itr != data.end()) {
|
if (itr != data.end()) {
|
||||||
setAvatarPath(itr.value().toString());
|
setAvatarPath(itr.value().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
itr = data.find("avatars");
|
||||||
|
if (itr != data.end()) {
|
||||||
|
QMap<QString, QVariant> avs = itr.value().toMap();
|
||||||
|
for (QMap<QString, QVariant>::const_iterator itr = avs.begin(), end = avs.end(); itr != end; ++itr) {
|
||||||
|
exParticipantAvatars.insert(std::make_pair(itr.key(), itr.value().toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Models::Room::~Room()
|
Models::Room::~Room()
|
||||||
@ -284,6 +294,11 @@ void Models::Room::addParticipant(const QString& p_name, const QMap<QString, QVa
|
|||||||
qDebug() << "An attempt to add already existing participant" << p_name << "to the room" << name << ", updating instead";
|
qDebug() << "An attempt to add already existing participant" << p_name << "to the room" << name << ", updating instead";
|
||||||
handleParticipantUpdate(itr, data);
|
handleParticipantUpdate(itr, data);
|
||||||
} else {
|
} else {
|
||||||
|
std::map<QString, QString>::const_iterator eitr = exParticipantAvatars.find(name);
|
||||||
|
if (eitr != exParticipantAvatars.end()) {
|
||||||
|
exParticipantAvatars.erase(eitr);
|
||||||
|
}
|
||||||
|
|
||||||
Participant* part = new Participant(data);
|
Participant* part = new Participant(data);
|
||||||
part->setName(p_name);
|
part->setName(p_name);
|
||||||
participants.insert(std::make_pair(p_name, part));
|
participants.insert(std::make_pair(p_name, part));
|
||||||
@ -311,6 +326,11 @@ void Models::Room::removeParticipant(const QString& p_name)
|
|||||||
Participant* p = itr->second;
|
Participant* p = itr->second;
|
||||||
participants.erase(itr);
|
participants.erase(itr);
|
||||||
removeChild(p->row());
|
removeChild(p->row());
|
||||||
|
|
||||||
|
if (p->getAvatarState() != Shared::Avatar::empty) {
|
||||||
|
exParticipantAvatars.insert(std::make_pair(p_name, p->getAvatarPath()));
|
||||||
|
}
|
||||||
|
|
||||||
p->deleteLater();
|
p->deleteLater();
|
||||||
emit participantLeft(p_name);
|
emit participantLeft(p_name);
|
||||||
}
|
}
|
||||||
@ -408,3 +428,8 @@ QString Models::Room::getParticipantIconPath(const QString& name) const
|
|||||||
|
|
||||||
return itr->second->getAvatarPath();
|
return itr->second->getAvatarPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::map<QString, QString> Models::Room::getExParticipantAvatars() const
|
||||||
|
{
|
||||||
|
return exParticipantAvatars;
|
||||||
|
}
|
||||||
|
@ -75,6 +75,7 @@ public:
|
|||||||
QString getAvatarPath() const;
|
QString getAvatarPath() const;
|
||||||
std::map<QString, const Participant&> getParticipants() const;
|
std::map<QString, const Participant&> getParticipants() const;
|
||||||
QString getParticipantIconPath(const QString& name) const;
|
QString getParticipantIconPath(const QString& name) const;
|
||||||
|
std::map<QString, QString> getExParticipantAvatars() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void participantJoined(const Participant& participant);
|
void participantJoined(const Participant& participant);
|
||||||
@ -99,6 +100,7 @@ private:
|
|||||||
QString avatarPath;
|
QString avatarPath;
|
||||||
Messages messages;
|
Messages messages;
|
||||||
std::map<QString, Participant*> participants;
|
std::map<QString, Participant*> participants;
|
||||||
|
std::map<QString, QString> exParticipantAvatars;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ MessageLine::MessageLine(bool p_room, QWidget* parent):
|
|||||||
palMessages(),
|
palMessages(),
|
||||||
uploadPaths(),
|
uploadPaths(),
|
||||||
palAvatars(),
|
palAvatars(),
|
||||||
|
exPalAvatars(),
|
||||||
layout(new QVBoxLayout(this)),
|
layout(new QVBoxLayout(this)),
|
||||||
myName(),
|
myName(),
|
||||||
myAvatarPath(),
|
myAvatarPath(),
|
||||||
@ -80,6 +81,11 @@ MessageLine::Position MessageLine::message(const Shared::Message& msg, bool forc
|
|||||||
std::map<QString, QString>::iterator aItr = palAvatars.find(sender);
|
std::map<QString, QString>::iterator aItr = palAvatars.find(sender);
|
||||||
if (aItr != palAvatars.end()) {
|
if (aItr != palAvatars.end()) {
|
||||||
aPath = aItr->second;
|
aPath = aItr->second;
|
||||||
|
} else {
|
||||||
|
aItr = exPalAvatars.find(sender);
|
||||||
|
if (aItr != exPalAvatars.end()) {
|
||||||
|
aPath = aItr->second;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
outgoing = false;
|
outgoing = false;
|
||||||
}
|
}
|
||||||
@ -248,6 +254,11 @@ void MessageLine::setPalAvatar(const QString& jid, const QString& path)
|
|||||||
std::map<QString, QString>::iterator itr = palAvatars.find(jid);
|
std::map<QString, QString>::iterator itr = palAvatars.find(jid);
|
||||||
if (itr == palAvatars.end()) {
|
if (itr == palAvatars.end()) {
|
||||||
palAvatars.insert(std::make_pair(jid, path));
|
palAvatars.insert(std::make_pair(jid, path));
|
||||||
|
|
||||||
|
std::map<QString, QString>::const_iterator eitr = exPalAvatars.find(jid);
|
||||||
|
if (eitr != exPalAvatars.end()) {
|
||||||
|
exPalAvatars.erase(eitr);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
itr->second = path;
|
itr->second = path;
|
||||||
}
|
}
|
||||||
@ -265,6 +276,12 @@ void MessageLine::dropPalAvatar(const QString& jid)
|
|||||||
std::map<QString, QString>::iterator itr = palAvatars.find(jid);
|
std::map<QString, QString>::iterator itr = palAvatars.find(jid);
|
||||||
if (itr != palAvatars.end()) {
|
if (itr != palAvatars.end()) {
|
||||||
palAvatars.erase(itr);
|
palAvatars.erase(itr);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::map<QString, QString>::const_iterator eitr = exPalAvatars.find(jid);
|
||||||
|
if (eitr != exPalAvatars.end()) {
|
||||||
|
exPalAvatars.erase(eitr);
|
||||||
|
}
|
||||||
|
|
||||||
std::map<QString, Index>::iterator pItr = palMessages.find(jid);
|
std::map<QString, Index>::iterator pItr = palMessages.find(jid);
|
||||||
if (pItr != palMessages.end()) {
|
if (pItr != palMessages.end()) {
|
||||||
@ -273,6 +290,20 @@ void MessageLine::dropPalAvatar(const QString& jid)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MessageLine::movePalAvatarToEx(const QString& name)
|
||||||
|
{
|
||||||
|
std::map<QString, QString>::iterator itr = palAvatars.find(name);
|
||||||
|
if (itr != palAvatars.end()) {
|
||||||
|
std::map<QString, QString>::iterator eitr = exPalAvatars.find(name);
|
||||||
|
if (eitr != exPalAvatars.end()) {
|
||||||
|
eitr->second = itr->second;
|
||||||
|
} else {
|
||||||
|
exPalAvatars.insert(std::make_pair(name, itr->second));
|
||||||
|
}
|
||||||
|
|
||||||
|
palAvatars.erase(itr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageLine::resizeEvent(QResizeEvent* event)
|
void MessageLine::resizeEvent(QResizeEvent* event)
|
||||||
@ -459,3 +490,19 @@ void MessageLine::setMyAvatarPath(const QString& p_path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MessageLine::setExPalAvatars(const std::map<QString, QString>& data)
|
||||||
|
{
|
||||||
|
exPalAvatars = data;
|
||||||
|
|
||||||
|
for (const std::pair<QString, Index>& pair : palMessages) {
|
||||||
|
if (palAvatars.find(pair.first) == palAvatars.end()) {
|
||||||
|
std::map<QString, QString>::const_iterator eitr = exPalAvatars.find(pair.first);
|
||||||
|
if (eitr != exPalAvatars.end()) {
|
||||||
|
for (const std::pair<QString, Message*>& mp : pair.second) {
|
||||||
|
mp.second->setAvatarPath(eitr->second);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -59,6 +59,8 @@ public:
|
|||||||
void setPalAvatar(const QString& jid, const QString& path);
|
void setPalAvatar(const QString& jid, const QString& path);
|
||||||
void dropPalAvatar(const QString& jid);
|
void dropPalAvatar(const QString& jid);
|
||||||
void changeMessage(const QString& id, const QMap<QString, QVariant>& data);
|
void changeMessage(const QString& id, const QMap<QString, QVariant>& data);
|
||||||
|
void setExPalAvatars(const std::map<QString, QString>& data);
|
||||||
|
void movePalAvatarToEx(const QString& name);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void resize(int amount);
|
void resize(int amount);
|
||||||
@ -90,6 +92,7 @@ private:
|
|||||||
std::map<QString, Index> palMessages;
|
std::map<QString, Index> palMessages;
|
||||||
std::map<QString, QString> uploadPaths;
|
std::map<QString, QString> uploadPaths;
|
||||||
std::map<QString, QString> palAvatars;
|
std::map<QString, QString> palAvatars;
|
||||||
|
std::map<QString, QString> exPalAvatars;
|
||||||
QVBoxLayout* layout;
|
QVBoxLayout* layout;
|
||||||
|
|
||||||
QString myName;
|
QString myName;
|
||||||
|
@ -92,6 +92,16 @@ Conversation::Conversation(bool muc, Models::Account* acc, const QString pJid, c
|
|||||||
line->setMyAvatarPath(acc->getAvatarPath());
|
line->setMyAvatarPath(acc->getAvatarPath());
|
||||||
line->setMyName(acc->getName());
|
line->setMyName(acc->getName());
|
||||||
|
|
||||||
|
QFont nf = m_ui->nameLabel->font();
|
||||||
|
nf.setBold(true);
|
||||||
|
nf.setPointSize(nf.pointSize() + 2);
|
||||||
|
m_ui->nameLabel->setFont(nf);
|
||||||
|
|
||||||
|
QFont sf = statusLabel->font();
|
||||||
|
sf.setItalic(true);
|
||||||
|
sf.setPointSize(sf.pointSize() - 2);
|
||||||
|
statusLabel->setFont(sf);
|
||||||
|
|
||||||
applyVisualEffects();
|
applyVisualEffects();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,8 @@ Room::Room(Models::Account* acc, Models::Room* p_room, QWidget* parent):
|
|||||||
line->setPalAvatar(pair.first, aPath);
|
line->setPalAvatar(pair.first, aPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
line->setExPalAvatars(room->getExParticipantAvatars());
|
||||||
}
|
}
|
||||||
|
|
||||||
Room::~Room()
|
Room::~Room()
|
||||||
@ -104,5 +106,5 @@ void Room::onParticipantJoined(const Models::Participant& participant)
|
|||||||
|
|
||||||
void Room::onParticipantLeft(const QString& name)
|
void Room::onParticipantLeft(const QString& name)
|
||||||
{
|
{
|
||||||
line->dropPalAvatar(name);
|
line->movePalAvatarToEx(name);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user