diff options
Diffstat (limited to 'protocols/JabberG/src')
-rw-r--r-- | protocols/JabberG/src/jabber.h | 1 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_iqid.cpp | 2 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_misc.cpp | 24 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_svc.cpp | 2 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_util.cpp | 16 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_vcard.cpp | 4 |
6 files changed, 12 insertions, 37 deletions
diff --git a/protocols/JabberG/src/jabber.h b/protocols/JabberG/src/jabber.h index 4c3108726d..f36d0822b5 100644 --- a/protocols/JabberG/src/jabber.h +++ b/protocols/JabberG/src/jabber.h @@ -753,7 +753,6 @@ void __stdcall JabberStringAppend(char* *str, int *sizeAlloced, const c TCHAR* __stdcall JabberStripJid(const TCHAR *jid, TCHAR* dest, size_t destLen);
int __stdcall JabberGetPacketID(HXML n);
-int __stdcall JabberGetPictureType(const char* buf);
LPCTSTR __stdcall JabberGetPictureType(HXML node, const char *picBuf);
TCHAR* time2str(time_t _time, TCHAR *buf, size_t bufLen);
diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp index d36c82292d..60517cc113 100644 --- a/protocols/JabberG/src/jabber_iqid.cpp +++ b/protocols/JabberG/src/jabber_iqid.cpp @@ -1457,7 +1457,7 @@ LBL_ErrFormat: Log("Invalid mime type specified for picture: %S", mimeType);
return;
} }
- else if ((pictureType = JabberGetPictureType(body)) == PA_FORMAT_UNKNOWN)
+ else if ((pictureType = ProtoGetBufferFormat(body, 0)) == PA_FORMAT_UNKNOWN)
goto LBL_ErrFormat;
TCHAR tszFileName[ MAX_PATH ];
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);
}
}
diff --git a/protocols/JabberG/src/jabber_svc.cpp b/protocols/JabberG/src/jabber_svc.cpp index c4fb05571e..60978c69f3 100644 --- a/protocols/JabberG/src/jabber_svc.cpp +++ b/protocols/JabberG/src/jabber_svc.cpp @@ -327,7 +327,7 @@ INT_PTR __cdecl CJabberProto::JabberSetAvatar(WPARAM, LPARAM lParam) for (int i=0; i<MIR_SHA1_HASH_SIZE; i++)
sprintf(buf+(i<<1), "%02x", digest[i]);
- m_options.AvatarType = JabberGetPictureType(pResult);
+ m_options.AvatarType = ProtoGetBufferFormat(pResult);
GetAvatarFileName(NULL, tFileName, MAX_PATH);
FILE* out = _tfopen(tFileName, _T("wb"));
diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp index 34f429c83b..2a319cd7ea 100644 --- a/protocols/JabberG/src/jabber_util.cpp +++ b/protocols/JabberG/src/jabber_util.cpp @@ -969,18 +969,6 @@ TCHAR* __stdcall JabberStripJid(const TCHAR *jid, TCHAR *dest, size_t destLen) /////////////////////////////////////////////////////////////////////////////////////////
// JabberGetPictureType - tries to autodetect the picture type from the buffer
-int __stdcall JabberGetPictureType(const char* buf)
-{
- if (buf != NULL) {
- if (memcmp(buf, "GIF8", 4) == 0) return PA_FORMAT_GIF;
- if (memcmp(buf, "\x89PNG", 4) == 0) return PA_FORMAT_PNG;
- if (memcmp(buf, "BM", 2) == 0) return PA_FORMAT_BMP;
- if (memcmp(buf, "\xFF\xD8", 2) == 0) return PA_FORMAT_JPEG;
- }
-
- return PA_FORMAT_UNKNOWN;
-}
-
LPCTSTR __stdcall JabberGetPictureType(HXML node, const char *picBuf)
{
if (LPCTSTR ptszType = xmlGetText( xmlGetChild(node , "TYPE")))
@@ -990,7 +978,7 @@ LPCTSTR __stdcall JabberGetPictureType(HXML node, const char *picBuf) !_tcscmp(ptszType, _T("image/bmp")))
return ptszType;
- switch(JabberGetPictureType(picBuf)) {
+ switch( ProtoGetBufferFormat(picBuf)) {
case PA_FORMAT_GIF: return _T("image/gif");
case PA_FORMAT_BMP: return _T("image/bmp");
case PA_FORMAT_PNG: return _T("image/png");
@@ -1641,7 +1629,7 @@ void __cdecl CJabberProto::LoadHttpAvatars(void* param) if (res) {
hHttpCon = res->nlc;
if (res->resultCode == 200 && res->dataLength) {
- int pictureType = JabberGetPictureType(res->pData);
+ int pictureType = ProtoGetBufferFormat(res->pData);
if (pictureType != PA_FORMAT_UNKNOWN) {
PROTO_AVATAR_INFORMATIONT AI;
AI.cbSize = sizeof(AI);
diff --git a/protocols/JabberG/src/jabber_vcard.cpp b/protocols/JabberG/src/jabber_vcard.cpp index 566c276bf2..08b1e70b13 100644 --- a/protocols/JabberG/src/jabber_vcard.cpp +++ b/protocols/JabberG/src/jabber_vcard.cpp @@ -1158,7 +1158,7 @@ void CJabberProto::SetServerVcard(BOOL bPhotoChanged, TCHAR* szPhotoFileName) if ((str=mir_base64_encode((PBYTE)buffer, nRead)) != NULL) {
n = v << XCHILD(_T("PHOTO"));
TCHAR *szFileType;
- switch(JabberGetPictureType(buffer)) {
+ switch( ProtoGetBufferFormat(buffer)) {
case PA_FORMAT_PNG: szFileType = _T("image/png"); break;
case PA_FORMAT_GIF: szFileType = _T("image/gif"); break;
case PA_FORMAT_BMP: szFileType = _T("image/bmp"); break;
@@ -1181,7 +1181,7 @@ void CJabberProto::SetServerVcard(BOOL bPhotoChanged, TCHAR* szPhotoFileName) for (int j=0; j<MIR_SHA1_HASH_SIZE; j++)
sprintf(buf+(j<<1), "%02x", digest[j]);
- m_options.AvatarType = JabberGetPictureType(buffer);
+ m_options.AvatarType = ProtoGetBufferFormat(buffer);
if (bPhotoChanged) {
DeleteFile(szAvatarName);
|