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/Tox | |
parent | 893fe6d2f16f5e70087aa9d5949aff5aaff556d2 (diff) |
PROTO_INTERFACE::GetAvatarPath - new helper for calculating avatars' root for an account
Diffstat (limited to 'protocols/Tox')
-rw-r--r-- | protocols/Tox/src/tox_avatars.cpp | 17 | ||||
-rw-r--r-- | protocols/Tox/src/tox_proto.cpp | 2 |
2 files changed, 7 insertions, 12 deletions
diff --git a/protocols/Tox/src/tox_avatars.cpp b/protocols/Tox/src/tox_avatars.cpp index 5e30c5c442..701b28710a 100644 --- a/protocols/Tox/src/tox_avatars.cpp +++ b/protocols/Tox/src/tox_avatars.cpp @@ -2,21 +2,16 @@ wchar_t* CToxProto::GetAvatarFilePath(MCONTACT hContact)
{
- wchar_t *path = (wchar_t*)mir_calloc(MAX_PATH * sizeof(wchar_t) + 1);
- mir_snwprintf(path, MAX_PATH, L"%s\\%S", VARSW(L"%miranda_avatarcache%").get(), m_szModuleName);
- CreateDirectoryTreeW(path);
-
ptrW address(getWStringA(hContact, TOX_SETTINGS_ID));
- if (address == NULL) {
- mir_free(path);
+ if (address == NULL)
return mir_wstrdup(L"");
- }
if (hContact && mir_wstrlen(address) > TOX_PUBLIC_KEY_SIZE * 2)
address[TOX_PUBLIC_KEY_SIZE * 2] = 0;
- mir_snwprintf(path, MAX_PATH, L"%s\\%s.png", path, address.get());
- return path;
+ CMStringW wszPath(GetAvatarPath());
+ wszPath.AppendFormat(L"\\%s.png", address.get());
+ return wszPath.Detach();
}
void CToxProto::SetToxAvatar(const wchar_t* path)
@@ -210,9 +205,7 @@ void CToxProto::OnGotFriendAvatarInfo(Tox *tox, AvatarTransferParam *transfer) db_free(&dbv);
}
- wchar_t path[MAX_PATH];
- mir_snwprintf(path, L"%s\\%S", VARSW(L"%miranda_avatarcache%").get(), m_szModuleName);
- OnFileAllow(tox, transfer->pfts.hContact, transfer, path);
+ OnFileAllow(tox, transfer->pfts.hContact, transfer, GetAvatarPath());
}
void CToxProto::OnGotFriendAvatarData(AvatarTransferParam *transfer)
diff --git a/protocols/Tox/src/tox_proto.cpp b/protocols/Tox/src/tox_proto.cpp index 1862bbc926..7a231ef89d 100644 --- a/protocols/Tox/src/tox_proto.cpp +++ b/protocols/Tox/src/tox_proto.cpp @@ -20,6 +20,8 @@ CToxProto::CToxProto(const char* protoName, const wchar_t* userName) setAllContactStatuses(ID_STATUS_OFFLINE);
// avatars
+ CreateDirectoryTreeW(GetAvatarPath());
+
CreateProtoService(PS_GETAVATARCAPS, &CToxProto::GetAvatarCaps);
CreateProtoService(PS_GETAVATARINFO, &CToxProto::GetAvatarInfo);
CreateProtoService(PS_GETMYAVATAR, &CToxProto::GetMyAvatar);
|