summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2022-08-15 20:51:04 +0300
committerGeorge Hazan <ghazan@miranda.im>2022-08-15 20:51:04 +0300
commit319f0c53660aa80d357715881fd4b8068cdb73ca (patch)
tree02887301dfa363972cf555695621302e4b8f876d
parent55d19a5ced6bf185c96a13b4498121405fef8662 (diff)
Jabber: ability to load group chat avatars (once in a day)
-rw-r--r--protocols/JabberG/src/jabber_chat.cpp6
-rw-r--r--protocols/JabberG/src/jabber_groupchat.cpp5
-rw-r--r--protocols/JabberG/src/jabber_iqid.cpp5
-rw-r--r--protocols/JabberG/src/jabber_util.cpp8
-rw-r--r--protocols/JabberG/src/jabber_vcard.cpp2
5 files changed, 21 insertions, 5 deletions
diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp
index bd74e32719..a657f1af40 100644
--- a/protocols/JabberG/src/jabber_chat.cpp
+++ b/protocols/JabberG/src/jabber_chat.cpp
@@ -155,6 +155,12 @@ int CJabberProto::GcInit(JABBER_LIST_ITEM *item)
Chat_Control(m_szModuleName, wszJid, (item->bAutoJoin && m_bAutoJoinHidden) ? WINDOW_HIDDEN : SESSION_INITDONE);
Chat_Control(m_szModuleName, wszJid, SESSION_ONLINE);
+
+ time_t lastDate = getDword(si->hContact, "LastGetVcard"), now = time(0);
+ if (now - lastDate > 24 * 60 * 60) {
+ SendGetVcard(si->hContact);
+ setDword(si->hContact, "LastGetVcard", now);
+ }
return 0;
}
diff --git a/protocols/JabberG/src/jabber_groupchat.cpp b/protocols/JabberG/src/jabber_groupchat.cpp
index 03d7d5c0a1..838c0f8d71 100644
--- a/protocols/JabberG/src/jabber_groupchat.cpp
+++ b/protocols/JabberG/src/jabber_groupchat.cpp
@@ -1008,6 +1008,11 @@ void CJabberProto::GroupchatProcessMessage(const TiXmlElement *node)
if (resource != nullptr && *++resource == '\0')
resource = nullptr;
+ for (auto *x : TiXmlFilter(node, "x"))
+ if (!mir_strcmp(XmlGetAttr(x, "xmlns"), JABBER_FEAT_MUC_USER))
+ if (XmlGetChildByTag(x, "status", "code", "104"))
+ SendGetVcard(item->hContact);
+
if ((n = XmlFirstChild(node, "subject")) != nullptr) {
msgText = n->GetText();
if (msgText == nullptr || msgText[0] == '\0')
diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp
index db8652dfd4..e0daa61151 100644
--- a/protocols/JabberG/src/jabber_iqid.cpp
+++ b/protocols/JabberG/src/jabber_iqid.cpp
@@ -616,9 +616,12 @@ void CJabberProto::OnIqResultGetVcardPhoto(const TiXmlElement *n, MCONTACT hCont
ReportSelfAvatarChanged();
}
else {
- ptrA jid(getUStringA(hContact, "jid"));
+ ptrA jid(ContactToJID(hContact));
if (jid != nullptr) {
JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, jid);
+ if (item == nullptr)
+ item = ListGetItemPtr(LIST_CHATROOM, jid);
+
if (item == nullptr) {
item = ListAdd(LIST_VCARD_TEMP, jid); // adding to the temp list to store information about photo
if (item != nullptr)
diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp
index 9da3058bf4..437b2b482d 100644
--- a/protocols/JabberG/src/jabber_util.cpp
+++ b/protocols/JabberG/src/jabber_util.cpp
@@ -55,12 +55,14 @@ MCONTACT CJabberProto::HContactFromJID(const char *jid, bool bStripResource)
if (item != nullptr && item->hContact)
return item->hContact;
+ item = ListGetItemPtr(LIST_CHATROOM, jid);
+ if (item != nullptr && item->hContact)
+ return item->hContact;
+
if (bStripResource) {
char szJid[JABBER_MAX_JID_LEN];
JabberStripJid(jid, szJid, _countof(szJid));
- item = ListGetItemPtr(LIST_ROSTER, szJid);
- if (item != nullptr && item->hContact)
- return item->hContact;
+ return HContactFromJID(szJid, false);
}
return 0;
diff --git a/protocols/JabberG/src/jabber_vcard.cpp b/protocols/JabberG/src/jabber_vcard.cpp
index 97de0efe7a..d8ba73b3ca 100644
--- a/protocols/JabberG/src/jabber_vcard.cpp
+++ b/protocols/JabberG/src/jabber_vcard.cpp
@@ -43,7 +43,7 @@ int CJabberProto::SendGetVcard(MCONTACT hContact)
pInfo = AddIQ(&CJabberProto::OnIqResultGetVcard, JABBER_IQ_TYPE_GET, m_szJabberJID);
}
else {
- ptrA jid(getUStringA(hContact, "jid"));
+ ptrA jid(ContactToJID(hContact));
if (jid == nullptr)
return -1;