summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xprotocols/JabberG/src/jabber_misc.cpp12
-rwxr-xr-xprotocols/JabberG/src/jabber_thread.cpp9
2 files changed, 12 insertions, 9 deletions
diff --git a/protocols/JabberG/src/jabber_misc.cpp b/protocols/JabberG/src/jabber_misc.cpp
index e4693220ae..74f6900762 100755
--- a/protocols/JabberG/src/jabber_misc.cpp
+++ b/protocols/JabberG/src/jabber_misc.cpp
@@ -148,13 +148,11 @@ void CJabberProto::GetAvatarFileName(MCONTACT hContact, wchar_t* pszDest, size_t
if (hContact != 0) {
char str[256];
JabberShaStrBuf buf;
- DBVARIANT dbv;
- if (!db_get_utf(hContact, m_szModuleName, "jid", &dbv)) {
- strncpy_s(str, dbv.pszVal, _TRUNCATE);
- str[sizeof(str) - 1] = 0;
- db_free(&dbv);
- }
- else _i64toa((LONG_PTR)hContact, str, 10);
+ ptrA szJid(getUStringA(hContact, "jid"));
+ if (szJid)
+ strncpy_s(str, szJid, _TRUNCATE);
+ else
+ _i64toa((LONG_PTR)hContact, str, 10);
mir_snwprintf(pszDest + tPathLen, MAX_PATH - tPathLen, L"%S%s", JabberSha1(str, buf), szFileType);
}
else if (m_ThreadInfo != nullptr) {
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp
index 29e11ee2cc..04c1aaad32 100755
--- a/protocols/JabberG/src/jabber_thread.cpp
+++ b/protocols/JabberG/src/jabber_thread.cpp
@@ -1643,12 +1643,17 @@ void CJabberProto::OnProcessPresence(const TiXmlElement *node, ThreadData *info)
auto *szPhoto = XmlGetChildText(xNode, "photo");
if (szPhoto && !bHasAvatar) {
if (mir_strlen(szPhoto)) {
+ // no file - no saved hash
+ wchar_t tszFileName[MAX_PATH];
+ GetAvatarFileName(hContact, tszFileName, _countof(tszFileName));
+ if (::_waccess(tszFileName, 0) != 0)
+ delSetting(hContact, "AvatarHash");
+
bHasAvatar = true;
ptrA saved(getStringA(hContact, "AvatarHash"));
if (saved == nullptr || mir_strcmp(saved, szPhoto)) {
debugLogA("Avatar was changed, reloading");
- setString(hContact, "AvatarHash", szPhoto);
- ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, nullptr, 0);
+ SendGetVcard(hContact);
continue;
}
}