forked from blue/squawk
hopefully end of refactoring of vcard to Info widget
This commit is contained in:
parent
bf11d8a74e
commit
e4a2728ef8
20 changed files with 268 additions and 1717 deletions
|
@ -156,7 +156,7 @@ void Core::RosterHandler::careAboutAvatar(Core::RosterItem* item, QMap<QString,
|
|||
} else {
|
||||
data.insert("avatarState", QVariant::fromValue(Shared::Avatar::empty));
|
||||
data.insert("avatarPath", "");
|
||||
acc->requestVCard(item->jid);
|
||||
acc->vh->requestVCard(item->jid);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -197,7 +197,7 @@ void Core::RosterHandler::handleNewRosterItem(Core::RosterItem* contact)
|
|||
connect(contact, &RosterItem::historyResponse, this->acc, &Account::onContactHistoryResponse);
|
||||
connect(contact, &RosterItem::nameChanged, this, &RosterHandler::onContactNameChanged);
|
||||
connect(contact, &RosterItem::avatarChanged, this, &RosterHandler::onContactAvatarChanged);
|
||||
connect(contact, &RosterItem::requestVCard, this->acc, &Account::requestVCard);
|
||||
connect(contact, &RosterItem::requestVCard, this->acc->vh, &VCardHandler::requestVCard);
|
||||
}
|
||||
|
||||
void Core::RosterHandler::handleNewContact(Core::Contact* contact)
|
||||
|
|
|
@ -80,9 +80,7 @@ void Core::VCardHandler::initialize() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void Core::VCardHandler::onVCardReceived(const QXmppVCardIq& card)
|
||||
{
|
||||
void Core::VCardHandler::onVCardReceived(const QXmppVCardIq& card) {
|
||||
QString id = card.from();
|
||||
QStringList comps = id.split("/");
|
||||
QString jid = comps.front().toLower();
|
||||
|
@ -102,13 +100,13 @@ void Core::VCardHandler::onVCardReceived(const QXmppVCardIq& card)
|
|||
return;
|
||||
}
|
||||
|
||||
Shared::VCard vCard = item->handleResponseVCard(card, resource);
|
||||
Shared::Info info(jid, Shared::EntryType::contact);
|
||||
info.vcard = item->handleResponseVCard(card, resource);
|
||||
|
||||
emit acc->receivedVCard(jid, vCard);
|
||||
emit acc->infoReady(info);
|
||||
}
|
||||
|
||||
void Core::VCardHandler::onOwnVCardReceived(const QXmppVCardIq& card)
|
||||
{
|
||||
void Core::VCardHandler::onOwnVCardReceived(const QXmppVCardIq& card) {
|
||||
QByteArray ava = card.photo();
|
||||
bool avaChanged = false;
|
||||
QString path = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/" + acc->name + "/";
|
||||
|
@ -189,32 +187,30 @@ void Core::VCardHandler::onOwnVCardReceived(const QXmppVCardIq& card)
|
|||
|
||||
ownVCardRequestInProgress = false;
|
||||
|
||||
Shared::VCard vCard;
|
||||
initializeVCard(vCard, card);
|
||||
Shared::Info info(acc->getBareJid(), Shared::EntryType::contact, true);
|
||||
initializeVCard(info.vcard, card);
|
||||
|
||||
if (avatarType.size() > 0) {
|
||||
vCard.setAvatarType(Shared::Avatar::valid);
|
||||
vCard.setAvatarPath(path + "avatar." + avatarType);
|
||||
info.vcard.setAvatarType(Shared::Avatar::valid);
|
||||
info.vcard.setAvatarPath(path + "avatar." + avatarType);
|
||||
} else {
|
||||
vCard.setAvatarType(Shared::Avatar::empty);
|
||||
info.vcard.setAvatarType(Shared::Avatar::empty);
|
||||
}
|
||||
|
||||
emit acc->receivedVCard(acc->getBareJid(), vCard);
|
||||
emit acc->infoReady(info);
|
||||
}
|
||||
|
||||
void Core::VCardHandler::handleOffline()
|
||||
{
|
||||
void Core::VCardHandler::handleOffline() {
|
||||
pendingVCardRequests.clear();
|
||||
Shared::VCard vCard; //just to show, that there is now more pending request
|
||||
for (const QString& jid : pendingVCardRequests) {
|
||||
emit acc->receivedVCard(jid, vCard); //need to show it better in the future, like with an error
|
||||
Shared::Info info(jid, Shared::EntryType::contact);
|
||||
emit acc->infoReady(info); //need to show it better in the future, like with an error
|
||||
}
|
||||
pendingVCardRequests.clear();
|
||||
ownVCardRequestInProgress = false;
|
||||
}
|
||||
|
||||
void Core::VCardHandler::requestVCard(const QString& jid)
|
||||
{
|
||||
void Core::VCardHandler::requestVCard(const QString& jid) {
|
||||
if (pendingVCardRequests.find(jid) == pendingVCardRequests.end()) {
|
||||
qDebug() << "requesting vCard" << jid;
|
||||
if (jid == acc->getBareJid()) {
|
||||
|
@ -229,8 +225,7 @@ void Core::VCardHandler::requestVCard(const QString& jid)
|
|||
}
|
||||
}
|
||||
|
||||
void Core::VCardHandler::handlePresenceOfMyAccountChange(const QXmppPresence& p_presence)
|
||||
{
|
||||
void Core::VCardHandler::handlePresenceOfMyAccountChange(const QXmppPresence& p_presence) {
|
||||
if (!ownVCardRequestInProgress) {
|
||||
switch (p_presence.vCardUpdateType()) {
|
||||
case QXmppPresence::VCardUpdateNone: //this presence has nothing to do with photo
|
||||
|
@ -253,8 +248,7 @@ void Core::VCardHandler::handlePresenceOfMyAccountChange(const QXmppPresence& p_
|
|||
}
|
||||
}
|
||||
|
||||
void Core::VCardHandler::uploadVCard(const Shared::VCard& card)
|
||||
{
|
||||
void Core::VCardHandler::uploadVCard(const Shared::VCard& card) {
|
||||
QXmppVCardIq iq;
|
||||
initializeQXmppVCard(iq, card);
|
||||
|
||||
|
@ -283,11 +277,10 @@ void Core::VCardHandler::uploadVCard(const Shared::VCard& card)
|
|||
} else {
|
||||
if (avatarType.size() > 0) {
|
||||
QFile oA(oldPath);
|
||||
if (!oA.open(QFile::ReadOnly)) {
|
||||
if (!oA.open(QFile::ReadOnly))
|
||||
qDebug() << "Couldn't read old avatar of account" << acc->name << ", uploading empty avatar";
|
||||
} else {
|
||||
else
|
||||
data = oA.readAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -303,11 +296,9 @@ void Core::VCardHandler::uploadVCard(const Shared::VCard& card)
|
|||
onOwnVCardReceived(iq);
|
||||
}
|
||||
|
||||
QString Core::VCardHandler::getAvatarPath() const
|
||||
{
|
||||
if (avatarType.size() == 0) {
|
||||
QString Core::VCardHandler::getAvatarPath() const {
|
||||
if (avatarType.size() == 0)
|
||||
return "";
|
||||
} else {
|
||||
else
|
||||
return QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/" + acc->name + "/" + "avatar." + avatarType;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue