summaryrefslogtreecommitdiff
path: root/protocols/JabberG
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-07-15 13:13:54 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-07-15 13:13:54 +0300
commit28ff0c36aee829b301d451ad232185c96e273f57 (patch)
tree4f4ad7d3f9def7f53183273582c954917ca03117 /protocols/JabberG
parentc311534fbf724850cbd8555a9e57f67b3096d7a0 (diff)
JABBER: support for obsolete XEP-0008 (iq based avatars) removed
Diffstat (limited to 'protocols/JabberG')
-rwxr-xr-xprotocols/JabberG/src/jabber_caps.cpp1
-rwxr-xr-xprotocols/JabberG/src/jabber_caps.h4
-rw-r--r--protocols/JabberG/src/jabber_iq.cpp3
-rw-r--r--protocols/JabberG/src/jabber_iq_handlers.cpp35
-rwxr-xr-xprotocols/JabberG/src/jabber_iqid.cpp44
-rwxr-xr-xprotocols/JabberG/src/jabber_proto.h2
-rw-r--r--protocols/JabberG/src/jabber_svc.cpp11
-rwxr-xr-xprotocols/JabberG/src/jabber_thread.cpp19
8 files changed, 6 insertions, 113 deletions
diff --git a/protocols/JabberG/src/jabber_caps.cpp b/protocols/JabberG/src/jabber_caps.cpp
index b4c4ad2923..5a6114e426 100755
--- a/protocols/JabberG/src/jabber_caps.cpp
+++ b/protocols/JabberG/src/jabber_caps.cpp
@@ -50,7 +50,6 @@ const JabberFeatCapPair g_JabberFeatCapPairs[] =
{ JABBER_FEAT_DATA_FORMS, JABBER_CAPS_DATA_FORMS, LPGEN("Supports data forms") },
{ JABBER_FEAT_MESSAGE_EVENTS, JABBER_CAPS_MESSAGE_EVENTS, LPGEN("Can request and respond to events relating to the delivery, display, and composition of messages") },
{ JABBER_FEAT_VCARD_TEMP, JABBER_CAPS_VCARD_TEMP, LPGEN("Supports vCard") },
- { JABBER_FEAT_AVATAR, JABBER_CAPS_AVATAR, LPGEN("Supports iq-based avatars") },
{ JABBER_FEAT_XHTML, JABBER_CAPS_XHTML, LPGEN("Supports XHTML formatting of chat messages") },
{ JABBER_FEAT_AGENTS, JABBER_CAPS_AGENTS, LPGEN("Supports Jabber Browsing") },
{ JABBER_FEAT_BROWSE, JABBER_CAPS_BROWSE, LPGEN("Supports Jabber Browsing") },
diff --git a/protocols/JabberG/src/jabber_caps.h b/protocols/JabberG/src/jabber_caps.h
index 4899eced24..75beba61de 100755
--- a/protocols/JabberG/src/jabber_caps.h
+++ b/protocols/JabberG/src/jabber_caps.h
@@ -83,9 +83,6 @@ typedef unsigned __int64 JabberCapsBits;
#define JABBER_CAPS_MESSAGE_EVENTS ((JabberCapsBits)1<<17)
#define JABBER_FEAT_VCARD_TEMP "vcard-temp"
#define JABBER_CAPS_VCARD_TEMP ((JabberCapsBits)1<<18)
-#define JABBER_FEAT_AVATAR "jabber:iq:avatar"
-#define JABBER_FEAT_SERVER_AVATAR "storage:client:avatar"
-#define JABBER_CAPS_AVATAR ((JabberCapsBits)1<<19)
#define JABBER_FEAT_XHTML "http://jabber.org/protocol/xhtml-im"
#define JABBER_CAPS_XHTML ((JabberCapsBits)1<<20)
#define JABBER_FEAT_AGENTS "jabber:iq:agents"
@@ -125,6 +122,7 @@ typedef unsigned __int64 JabberCapsBits;
#define JABBER_FEAT_PRIVATE_STORAGE "jabber:iq:private"
#define JABBER_CAPS_PRIVATE_STORAGE ((JabberCapsBits)1<<33)
+#define JABBER_FEAT_SERVER_AVATAR "storage:client:avatar"
#define JABBER_FEAT_ARCHIVE "urn:xmpp:archive"
#define JABBER_FEAT_ARCHIVE_AUTO "urn:xmpp:archive:auto"
#define JABBER_CAPS_ARCHIVE_AUTO ((JabberCapsBits)1<<34)
diff --git a/protocols/JabberG/src/jabber_iq.cpp b/protocols/JabberG/src/jabber_iq.cpp
index fc0f50d997..158d8febf6 100644
--- a/protocols/JabberG/src/jabber_iq.cpp
+++ b/protocols/JabberG/src/jabber_iq.cpp
@@ -99,9 +99,6 @@ void CJabberIqManager::FillPermanentHandlers()
// entity time (XEP-0090)
AddPermanentHandler(&CJabberProto::OnIqProcessIqOldTime, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, JABBER_FEAT_ENTITY_TIME_OLD, FALSE, "query");
- // old avatars support (deprecated XEP-0008)
- AddPermanentHandler(&CJabberProto::OnIqRequestAvatar, JABBER_IQ_TYPE_GET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, JABBER_FEAT_AVATAR, FALSE, "query");
-
// privacy lists (XEP-0016)
AddPermanentHandler(&CJabberProto::OnIqRequestPrivacyLists, JABBER_IQ_TYPE_SET, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_ID_STR, JABBER_FEAT_PRIVACY_LISTS, FALSE, "query");
diff --git a/protocols/JabberG/src/jabber_iq_handlers.cpp b/protocols/JabberG/src/jabber_iq_handlers.cpp
index bed8949e14..d443d4fdc9 100644
--- a/protocols/JabberG/src/jabber_iq_handlers.cpp
+++ b/protocols/JabberG/src/jabber_iq_handlers.cpp
@@ -146,41 +146,6 @@ BOOL CJabberProto::OnIqProcessIqOldTime(const TiXmlElement*, CJabberIqInfo *pInf
return TRUE;
}
-BOOL CJabberProto::OnIqRequestAvatar(const TiXmlElement*, CJabberIqInfo *pInfo)
-{
- if (!m_bEnableAvatars)
- return TRUE;
-
- int pictureType = m_bAvatarType;
- if (pictureType == PA_FORMAT_UNKNOWN)
- return TRUE;
-
- const char *szMimeType = ProtoGetAvatarMimeType(pictureType);
- if (szMimeType == nullptr)
- return TRUE;
-
- wchar_t szFileName[MAX_PATH];
- GetAvatarFileName(0, szFileName, _countof(szFileName));
-
- FILE* in = _wfopen(szFileName, L"rb");
- if (in == nullptr)
- return TRUE;
-
- long bytes = _filelength(_fileno(in));
- ptrA buffer((char*)mir_alloc(bytes * 4 / 3 + bytes + 1000));
- if (buffer == nullptr) {
- fclose(in);
- return TRUE;
- }
-
- fread(buffer, bytes, 1, in);
- fclose(in);
-
- ptrA str(mir_base64_encode(buffer, bytes));
- m_ThreadInfo->send(XmlNodeIq("result", pInfo) << XQUERY(JABBER_FEAT_AVATAR) << XCHILD("query", str) << XATTR("mimetype", szMimeType));
- return TRUE;
-}
-
BOOL CJabberProto::OnSiRequest(const TiXmlElement *node, CJabberIqInfo *pInfo)
{
const char *szProfile = XmlGetAttr(pInfo->GetChildNode(), "profile");
diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp
index e5a231f64c..9150e6aeb2 100755
--- a/protocols/JabberG/src/jabber_iqid.cpp
+++ b/protocols/JabberG/src/jabber_iqid.cpp
@@ -1255,50 +1255,8 @@ void CJabberProto::OnIqResultGetVCardAvatar(const TiXmlElement *iqNode, CJabberI
return;
}
- if (auto *pszText = XmlGetChildText(vCard, "BINVAL")) {
- setByte(hContact, "AvatarXVcard", 1);
+ if (auto *pszText = XmlGetChildText(vCard, "BINVAL"))
OnIqResultGotAvatar(hContact, pszText, XmlGetChildText(vCard, "TYPE"));
- }
-}
-
-void CJabberProto::OnIqResultGetClientAvatar(const TiXmlElement *iqNode, CJabberIqInfo*)
-{
- const char *type;
-
- debugLogA("<iq/> iqIdResultGetClientAvatar");
-
- const char *from = XmlGetAttr(iqNode, "from");
- if (from == nullptr)
- return;
- MCONTACT hContact = HContactFromJID(from);
- if (hContact == 0)
- return;
-
- const TiXmlElement *n = nullptr;
- if ((type = XmlGetAttr(iqNode, "type")) != nullptr && !mir_strcmp(type, "result")) {
- auto *queryNode = XmlFirstChild(iqNode, "query");
- if (queryNode != nullptr) {
- const char *xmlns = XmlGetAttr(queryNode, "xmlns");
- if (!mir_strcmp(xmlns, JABBER_FEAT_AVATAR))
- n = XmlFirstChild(queryNode, "data");
- }
- }
-
- if (n != nullptr) {
- OnIqResultGotAvatar(hContact, n->GetText(), XmlGetAttr(n, "mimetype"));
- return;
- }
-
- char szJid[JABBER_MAX_JID_LEN];
- mir_strncpy(szJid, from, _countof(szJid));
- char *res = strchr(szJid, '/');
- if (res != nullptr)
- *res = 0;
-
- // Try server stored avatar
- XmlNodeIq iq(AddIQ(&CJabberProto::OnIqResultGetServerAvatar, JABBER_IQ_TYPE_GET, szJid));
- iq << XQUERY(JABBER_FEAT_SERVER_AVATAR);
- m_ThreadInfo->send(iq);
}
void CJabberProto::OnIqResultGetServerAvatar(const TiXmlElement *iqNode, CJabberIqInfo*)
diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h
index d91582c5eb..dd29dda47b 100755
--- a/protocols/JabberG/src/jabber_proto.h
+++ b/protocols/JabberG/src/jabber_proto.h
@@ -504,7 +504,6 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
void OnIqResultExtSearch(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
void OnIqResultGetAuth(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
void OnIqResultGetVCardAvatar(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
- void OnIqResultGetClientAvatar(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
void OnIqResultGetServerAvatar(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
void OnIqResultGotAvatar(MCONTACT hContact, const char *pszText, const char *mimeType);
void OnIqResultGetMuc(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
@@ -537,7 +536,6 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
BOOL OnIqRequestPing(const TiXmlElement *node, CJabberIqInfo *pInfo);
BOOL OnIqRequestTime(const TiXmlElement *node, CJabberIqInfo *pInfo);
BOOL OnIqProcessIqOldTime(const TiXmlElement *node, CJabberIqInfo *pInfo);
- BOOL OnIqRequestAvatar(const TiXmlElement *node, CJabberIqInfo *pInfo);
BOOL OnSiRequest(const TiXmlElement *node, CJabberIqInfo *pInfo);
BOOL OnRosterPushRequest(const TiXmlElement *node, CJabberIqInfo *pInfo);
BOOL OnIqRequestOOB(const TiXmlElement *node, CJabberIqInfo *pInfo);
diff --git a/protocols/JabberG/src/jabber_svc.cpp b/protocols/JabberG/src/jabber_svc.cpp
index 83d7a0c600..fccdcdef0b 100644
--- a/protocols/JabberG/src/jabber_svc.cpp
+++ b/protocols/JabberG/src/jabber_svc.cpp
@@ -139,21 +139,16 @@ INT_PTR __cdecl CJabberProto::JabberGetAvatarInfo(WPARAM wParam, LPARAM lParam)
if (tszJid != nullptr) {
JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, tszJid);
if (item != nullptr) {
- BOOL isXVcard = getByte(pai->hContact, "AvatarXVcard", 0);
-
CMStringA szJid;
- if (item->arResources.getCount() != 0 && !isXVcard)
+ if (item->arResources.getCount() != 0)
if (char *bestResName = ListGetBestClientResourceNamePtr(tszJid))
szJid = MakeJid(tszJid, bestResName);
if (szJid.IsEmpty())
szJid = tszJid;
- debugLogA("Rereading %s for %s", isXVcard ? JABBER_FEAT_VCARD_TEMP : JABBER_FEAT_AVATAR, szJid.c_str());
-
- m_ThreadInfo->send((isXVcard) ?
- XmlNodeIq(AddIQ(&CJabberProto::OnIqResultGetVCardAvatar, JABBER_IQ_TYPE_GET, szJid)) << XCHILDNS("vCard", JABBER_FEAT_VCARD_TEMP) :
- XmlNodeIq(AddIQ(&CJabberProto::OnIqResultGetClientAvatar, JABBER_IQ_TYPE_GET, szJid)) << XQUERY(JABBER_FEAT_AVATAR));
+ debugLogA("Rereading %s for %s", JABBER_FEAT_VCARD_TEMP, szJid.c_str());
+ m_ThreadInfo->send(XmlNodeIq(AddIQ(&CJabberProto::OnIqResultGetVCardAvatar, JABBER_IQ_TYPE_GET, szJid)) << XCHILDNS("vCard", JABBER_FEAT_VCARD_TEMP));
return GAIR_WAITFOR;
}
}
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp
index 3cb112f60d..545c20131b 100755
--- a/protocols/JabberG/src/jabber_thread.cpp
+++ b/protocols/JabberG/src/jabber_thread.cpp
@@ -1637,27 +1637,10 @@ void CJabberProto::OnProcessPresence(const TiXmlElement *node, ThreadData *info)
debugLogA("Avatar enabled");
for (auto *xNode : TiXmlFilter(node, "x")) {
- if (!bHasAvatar && !mir_strcmp(XmlGetAttr(xNode, "xmlns"), "jabber:x:avatar")) {
- auto *szHash = XmlGetChildText(xNode, "hash");
- if (szHash != nullptr) {
- delSetting(hContact, "AvatarXVcard");
- debugLogA("AvatarXVcard deleted");
- setString(hContact, "AvatarHash", szHash);
- bHasAvatar = true;
- ptrA saved(getStringA(hContact, "AvatarSaved"));
- if (saved == nullptr || mir_strcmp(saved, szHash)) {
- debugLogA("Avatar was changed");
- ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, nullptr, 0);
- }
- }
- else bRemovedAvatar = true;
- }
- else if (!mir_strcmp(XmlGetAttr(xNode, "xmlns"), "vcard-temp:x:update")) {
+ if (!mir_strcmp(XmlGetAttr(xNode, "xmlns"), "vcard-temp:x:update")) {
auto *szPhoto = XmlGetChildText(xNode, "photo");
if (szPhoto && !bHasAvatar) {
if (mir_strlen(szPhoto)) {
- setByte(hContact, "AvatarXVcard", 1);
- debugLogA("AvatarXVcard set");
setString(hContact, "AvatarHash", szPhoto);
bHasAvatar = true;
ptrA saved(getStringA(hContact, "AvatarSaved"));