vCard #29

Manually merged
blue merged 20 commits from vCard into master 2019-11-08 07:47:38 +00:00
4 changed files with 153 additions and 0 deletions
Showing only changes of commit d050cd82dd - Show all commits

View File

@ -1341,6 +1341,7 @@ void Core::Account::onVCardReceived(const QXmppVCardIq& card)
if (confItr == conferences.end()) { if (confItr == conferences.end()) {
if (jid == getLogin() + "@" + getServer()) { if (jid == getLogin() + "@" + getServer()) {
onOwnVCardReceived(card); onOwnVCardReceived(card);
} else { } else {
qDebug() << "received vCard" << jid << "doesn't belong to any of known contacts or conferences, skipping"; qDebug() << "received vCard" << jid << "doesn't belong to any of known contacts or conferences, skipping";
} }
@ -1353,11 +1354,32 @@ void Core::Account::onVCardReceived(const QXmppVCardIq& card)
} }
QByteArray ava = card.photo(); QByteArray ava = card.photo();
if (ava.size() > 0) { if (ava.size() > 0) {
item->setAvatar(ava); item->setAvatar(ava);
} else { } else {
item->setAutoGeneratedAvatar(); item->setAutoGeneratedAvatar();
} }
Shared::VCard vCard;
vCard.setFirstName(card.firstName());
vCard.setMiddleName(card.middleName());
vCard.setLastName(card.lastName());
vCard.setBirthday(card.birthday());
vCard.setNickName(card.nickName());
vCard.setDescription(card.description());
if (item->hasAvatar()) {
if (item->isAvatarAutoGenerated()) {
vCard.setAvatarType(Shared::Avatar::valid);
} else {
vCard.setAvatarType(Shared::Avatar::autocreated);
}
vCard.setAvatarPath(item->avatarPath());
} else {
vCard.setAvatarType(Shared::Avatar::empty);
}
emit receivedVCard(jid, vCard);
} }
void Core::Account::onOwnVCardReceived(const QXmppVCardIq& card) void Core::Account::onOwnVCardReceived(const QXmppVCardIq& card)
@ -1438,6 +1460,22 @@ void Core::Account::onOwnVCardReceived(const QXmppVCardIq& card)
} }
ownVCardRequestInProgress = false; ownVCardRequestInProgress = false;
Shared::VCard vCard;
vCard.setFirstName(card.firstName());
vCard.setMiddleName(card.middleName());
vCard.setLastName(card.lastName());
vCard.setBirthday(card.birthday());
vCard.setNickName(card.nickName());
vCard.setDescription(card.description());
if (avatarType.size() > 0) {
vCard.setAvatarType(Shared::Avatar::valid);
vCard.setAvatarPath(path + "avatar." + avatarType);
} else {
vCard.setAvatarType(Shared::Avatar::empty);
}
emit receivedVCard(getLogin() + "@" + getServer(), vCard);
} }
QString Core::Account::getAvatarPath() const QString Core::Account::getAvatarPath() const

View File

@ -87,6 +87,7 @@ public:
void setRoomAutoJoin(const QString& jid, bool joined); void setRoomAutoJoin(const QString& jid, bool joined);
void removeRoomRequest(const QString& jid); void removeRoomRequest(const QString& jid);
void addRoomRequest(const QString& jid, const QString& nick, const QString& password, bool autoJoin); void addRoomRequest(const QString& jid, const QString& nick, const QString& password, bool autoJoin);
void requestVCard(const QString& jid);
signals: signals:
void changed(const QMap<QString, QVariant>& data); void changed(const QMap<QString, QVariant>& data);
@ -109,6 +110,7 @@ signals:
void addRoomParticipant(const QString& jid, const QString& nickName, const QMap<QString, QVariant>& data); void addRoomParticipant(const QString& jid, const QString& nickName, const QMap<QString, QVariant>& data);
void changeRoomParticipant(const QString& jid, const QString& nickName, const QMap<QString, QVariant>& data); void changeRoomParticipant(const QString& jid, const QString& nickName, const QMap<QString, QVariant>& data);
void removeRoomParticipant(const QString& jid, const QString& nickName); void removeRoomParticipant(const QString& jid, const QString& nickName);
void receivedVCard(const QString& jid, const Shared::VCard& card);
private: private:
QString name; QString name;

View File

@ -353,6 +353,102 @@ Shared::VCard::VCard(const QDateTime& creationTime):
{ {
} }
QString Shared::VCard::getAvatarPath() const
{
return photoPath;
}
Shared::Avatar Shared::VCard::getAvatarType() const
{
return photoType;
}
QDate Shared::VCard::getBirthday() const
{
return birthday;
}
QString Shared::VCard::getDescription() const
{
return description;
}
QString Shared::VCard::getFirstName() const
{
return firstName;
}
QString Shared::VCard::getLastName() const
{
return lastName;
}
QString Shared::VCard::getMiddleName() const
{
return middleName;
}
QString Shared::VCard::getNickName() const
{
return nickName;
}
void Shared::VCard::setAvatarPath(const QString& path)
{
if (path != photoPath) {
photoPath = path;
}
}
void Shared::VCard::setAvatarType(Shared::Avatar type)
{
if (photoType != type) {
photoType = type;
}
}
void Shared::VCard::setBirthday(const QDate& date)
{
if (date.isValid() && birthday != date) {
birthday = date;
}
}
void Shared::VCard::setDescription(const QString& descr)
{
if (description != descr) {
description = descr;
}
}
void Shared::VCard::setFirstName(const QString& first)
{
if (firstName != first) {
firstName = first;
}
}
void Shared::VCard::setLastName(const QString& last)
{
if (lastName != last) {
lastName = last;
}
}
void Shared::VCard::setMiddleName(const QString& middle)
{
if (middleName != middle) {
middleName = middle;
}
}
void Shared::VCard::setNickName(const QString& nick)
{
if (nickName != nick) {
nickName = nick;
}
}
QIcon Shared::availabilityIcon(Shared::Availability av, bool big) QIcon Shared::availabilityIcon(Shared::Availability av, bool big)
{ {
const std::deque<QString>& fallback = QApplication::palette().window().color().lightnessF() > 0.5 ? const std::deque<QString>& fallback = QApplication::palette().window().color().lightnessF() > 0.5 ?

View File

@ -272,6 +272,23 @@ public:
VCard(); VCard();
VCard(const QDateTime& creationTime); VCard(const QDateTime& creationTime);
QString getFirstName() const;
void setFirstName(const QString& first);
QString getMiddleName() const;
void setMiddleName(const QString& middle);
QString getLastName() const;
void setLastName(const QString& last);
QString getNickName() const;
void setNickName(const QString& nick);
QString getDescription() const;
void setDescription(const QString& descr);
QDate getBirthday() const;
void setBirthday(const QDate& date);
Avatar getAvatarType() const;
void setAvatarType(Avatar type);
QString getAvatarPath() const;
void setAvatarPath(const QString& path);
private: private:
QString firstName; QString firstName;
QString middleName; QString middleName;