diff options
author | George Hazan <ghazan@miranda.im> | 2023-01-17 14:37:50 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2023-01-17 14:37:50 +0300 |
commit | 4c60037f6852f7771ed86e0b285a872e4bbadb87 (patch) | |
tree | a6977ea0a68db5612f3ac8664efd9d66a483e52c /protocols/JabberG/src | |
parent | 893fe6d2f16f5e70087aa9d5949aff5aaff556d2 (diff) |
PROTO_INTERFACE::GetAvatarPath - new helper for calculating avatars' root for an account
Diffstat (limited to 'protocols/JabberG/src')
-rw-r--r-- | protocols/JabberG/src/jabber_misc.cpp | 19 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_proto.cpp | 3 |
2 files changed, 11 insertions, 11 deletions
diff --git a/protocols/JabberG/src/jabber_misc.cpp b/protocols/JabberG/src/jabber_misc.cpp index 71115ef87a..68f83280bf 100644 --- a/protocols/JabberG/src/jabber_misc.cpp +++ b/protocols/JabberG/src/jabber_misc.cpp @@ -135,13 +135,10 @@ bool CJabberProto::AddDbPresenceEvent(MCONTACT hContact, uint8_t btEventType) ///////////////////////////////////////////////////////////////////////////////
// JabberGetAvatarFileName() - gets a file name for the avatar image
-void CJabberProto::GetAvatarFileName(MCONTACT hContact, wchar_t* pszDest, size_t cbLen)
+void CJabberProto::GetAvatarFileName(MCONTACT hContact, wchar_t *pszDest, size_t cbLen)
{
- size_t tPathLen = mir_snwprintf(pszDest, cbLen, L"%s\\%S", VARSW(L"%miranda_avatarcache%").get(), m_szModuleName);
-
- CreateDirectoryTreeW(pszDest);
-
- pszDest[tPathLen++] = '\\';
+ CMStringW wszPath(GetAvatarPath());
+ wszPath += '\\';
const wchar_t* szFileType = ProtoGetAvatarExtension(getByte(hContact, "AvatarType", PA_FORMAT_PNG));
@@ -153,17 +150,17 @@ void CJabberProto::GetAvatarFileName(MCONTACT hContact, wchar_t* pszDest, size_t 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);
+ wszPath.AppendFormat(L"%S%s", JabberSha1(str, buf), szFileType);
}
else if (m_ThreadInfo != nullptr) {
- mir_snwprintf(pszDest + tPathLen, MAX_PATH - tPathLen, L"%s@%s avatar%s",
- Utf2T(m_ThreadInfo->conn.username).get(), Utf2T(m_ThreadInfo->conn.server).get(), szFileType);
+ wszPath.AppendFormat(L"%s@%s avatar%s", Utf2T(m_ThreadInfo->conn.username).get(), Utf2T(m_ThreadInfo->conn.server).get(), szFileType);
}
else {
ptrA res1(getStringA("LoginName")), res2(getStringA("LoginServer"));
- mir_snwprintf(pszDest + tPathLen, MAX_PATH - tPathLen, L"%S@%S avatar%s",
- (res1) ? (LPSTR)res1 : "noname", (res2) ? (LPSTR)res2 : m_szModuleName, szFileType);
+ wszPath.AppendFormat(L"%S@%S avatar%s", (res1) ? (LPSTR)res1 : "noname", (res2) ? (LPSTR)res2 : m_szModuleName, szFileType);
}
+
+ wcsncpy_s(pszDest, cbLen, wszPath, _TRUNCATE);
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index 4fb6dbf5a9..9762a297f8 100644 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -218,6 +218,9 @@ CJabberProto::CJabberProto(const char *aProtoName, const wchar_t *aUserName) : OmemoInitDevice();
}
+ // avatars
+ CreateDirectoryTreeW(GetAvatarPath());
+
// network initialization
NETLIBUSER nlu = {};
nlu.flags = NUF_OUTGOING | NUF_INCOMING | NUF_HTTPCONNS | NUF_UNICODE;
|