summaryrefslogtreecommitdiff
path: root/protocols/JabberG/src/jabber_misc.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-08-11 10:41:37 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-08-11 10:41:37 +0000
commit94dcc72f13094157f344f284aec4edf0c0f5faa1 (patch)
tree74c078daadd4abe5aea9e9e0a73b4dd7c4a7fde1 /protocols/JabberG/src/jabber_misc.cpp
parent42ff2169dbddd25d06404623dba2fff222d17c73 (diff)
ProtoGetAvatarFormat, ProtoGetAvatarFileFormat, ProtoGetBufferFormat, ProtoGetAvatarExtension - standard helpers for protocol avatars' processing instead of the zoo that existed previously
git-svn-id: http://svn.miranda-ng.org/main/trunk@5645 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/JabberG/src/jabber_misc.cpp')
-rw-r--r--protocols/JabberG/src/jabber_misc.cpp24
1 files changed, 6 insertions, 18 deletions
diff --git a/protocols/JabberG/src/jabber_misc.cpp b/protocols/JabberG/src/jabber_misc.cpp
index eb0f091f22..9f636480a2 100644
--- a/protocols/JabberG/src/jabber_misc.cpp
+++ b/protocols/JabberG/src/jabber_misc.cpp
@@ -267,13 +267,7 @@ void CJabberProto::GetAvatarFileName(HANDLE hContact, TCHAR* pszDest, size_t cbL
pszDest[ tPathLen++ ] = '\\';
- char* szFileType = NULL;
- switch(getByte(hContact, "AvatarType", PA_FORMAT_PNG)) {
- case PA_FORMAT_JPEG: szFileType = "jpg"; break;
- case PA_FORMAT_PNG: szFileType = "png"; break;
- case PA_FORMAT_GIF: szFileType = "gif"; break;
- case PA_FORMAT_BMP: szFileType = "bmp"; break;
- }
+ const TCHAR* szFileType = ProtoGetAvatarExtension( getByte(hContact, "AvatarType", PA_FORMAT_PNG));
if (hContact != NULL) {
char str[ 256 ];
@@ -284,22 +278,16 @@ void CJabberProto::GetAvatarFileName(HANDLE hContact, TCHAR* pszDest, size_t cbL
db_free(&dbv);
}
else _i64toa((LONG_PTR)hContact, str, 10);
- mir_sntprintf(pszDest + tPathLen, MAX_PATH - tPathLen, _T("%S.%S"), ptrA(JabberSha1(str)), szFileType);
+ mir_sntprintf(pszDest + tPathLen, MAX_PATH - tPathLen, _T("%S%s"), ptrA(JabberSha1(str)), szFileType);
}
else if (m_ThreadInfo != NULL) {
- mir_sntprintf(pszDest + tPathLen, MAX_PATH - tPathLen, _T("%s@%S avatar.%S"),
+ mir_sntprintf(pszDest + tPathLen, MAX_PATH - tPathLen, _T("%s@%S avatar%s"),
m_ThreadInfo->username, m_ThreadInfo->server, szFileType);
}
else {
- DBVARIANT dbv1, dbv2;
- BOOL res1 = getString("LoginName", &dbv1);
- BOOL res2 = getString("LoginServer", &dbv2);
- mir_sntprintf(pszDest + tPathLen, MAX_PATH - tPathLen, _T("%S@%S avatar.%S"),
- res1 ? "noname" : dbv1.pszVal,
- res2 ? m_szModuleName : dbv2.pszVal,
- szFileType);
- if ( !res1) db_free(&dbv1);
- if ( !res2) db_free(&dbv2);
+ ptrA res1( getStringA("LoginName")), res2( getStringA("LoginServer"));
+ mir_sntprintf(pszDest + tPathLen, MAX_PATH - tPathLen, _T("%S@%S avatar%s"),
+ res1 ? res1 : "noname", res2 ? res2 : m_szModuleName, szFileType);
}
}