diff options
Diffstat (limited to 'protocols/JabberG/src')
-rw-r--r-- | protocols/JabberG/src/jabber_iq_handlers.cpp | 11 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_iqid.cpp | 19 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_util.cpp | 14 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_vcard.cpp | 10 |
4 files changed, 14 insertions, 40 deletions
diff --git a/protocols/JabberG/src/jabber_iq_handlers.cpp b/protocols/JabberG/src/jabber_iq_handlers.cpp index 924b335afc..e532340acc 100644 --- a/protocols/JabberG/src/jabber_iq_handlers.cpp +++ b/protocols/JabberG/src/jabber_iq_handlers.cpp @@ -151,14 +151,9 @@ BOOL CJabberProto::OnIqRequestAvatar(HXML, CJabberIqInfo *pInfo) if (pictureType == PA_FORMAT_UNKNOWN)
return TRUE;
- wchar_t *szMimeType;
- switch (pictureType) {
- case PA_FORMAT_JPEG: szMimeType = L"image/jpeg"; break;
- case PA_FORMAT_GIF: szMimeType = L"image/gif"; break;
- case PA_FORMAT_PNG: szMimeType = L"image/png"; break;
- case PA_FORMAT_BMP: szMimeType = L"image/bmp"; break;
- default: return TRUE;
- }
+ const wchar_t *szMimeType = ProtoGetAvatarMimeType(pictureType);
+ if (szMimeType == NULL)
+ return TRUE;
wchar_t szFileName[MAX_PATH];
GetAvatarFileName(NULL, szFileName, _countof(szFileName));
diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp index a91cd1d3d4..df2fd4cf42 100644 --- a/protocols/JabberG/src/jabber_iqid.cpp +++ b/protocols/JabberG/src/jabber_iqid.cpp @@ -1405,19 +1405,14 @@ void CJabberProto::OnIqResultGotAvatar(MCONTACT hContact, HXML n, const wchar_t return;
int pictureType;
- if (mimeType != NULL) {
- if (!mir_wstrcmp(mimeType, L"image/jpeg")) pictureType = PA_FORMAT_JPEG;
- else if (!mir_wstrcmp(mimeType, L"image/png")) pictureType = PA_FORMAT_PNG;
- else if (!mir_wstrcmp(mimeType, L"image/gif")) pictureType = PA_FORMAT_GIF;
- else if (!mir_wstrcmp(mimeType, L"image/bmp")) pictureType = PA_FORMAT_BMP;
- else {
-LBL_ErrFormat:
- debugLogW(L"Invalid mime type specified for picture: %s", mimeType);
- return;
- }
+ if (mimeType != NULL)
+ pictureType = ProtoGetAvatarFormatByMimeType(mimeType);
+ else
+ pictureType = ProtoGetBufferFormat(body, 0);
+ if (pictureType == PA_FORMAT_UNKNOWN) {
+ debugLogW(L"Invalid mime type specified for picture: %s", mimeType);
+ return;
}
- else if ((pictureType = ProtoGetBufferFormat(body, 0)) == PA_FORMAT_UNKNOWN)
- goto LBL_ErrFormat;
PROTO_AVATAR_INFORMATION ai;
ai.format = pictureType;
diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp index c1fb18a4e2..19de86f090 100644 --- a/protocols/JabberG/src/jabber_util.cpp +++ b/protocols/JabberG/src/jabber_util.cpp @@ -587,20 +587,10 @@ wchar_t* __stdcall JabberStripJid(const wchar_t *jid, wchar_t *dest, size_t dest LPCTSTR __stdcall JabberGetPictureType(HXML node, const char *picBuf)
{
if (LPCTSTR ptszType = XmlGetText(XmlGetChild(node, "TYPE")))
- if (!mir_wstrcmp(ptszType, L"image/jpeg") ||
- !mir_wstrcmp(ptszType, L"image/png") ||
- !mir_wstrcmp(ptszType, L"image/gif") ||
- !mir_wstrcmp(ptszType, L"image/bmp"))
+ if (ProtoGetAvatarFormatByMimeType(ptszType) != PA_FORMAT_UNKNOWN)
return ptszType;
- switch (ProtoGetBufferFormat(picBuf)) {
- case PA_FORMAT_GIF: return L"image/gif";
- case PA_FORMAT_BMP: return L"image/bmp";
- case PA_FORMAT_PNG: return L"image/png";
- case PA_FORMAT_JPEG: return L"image/jpeg";
- }
-
- return NULL;
+ return ProtoGetAvatarMimeType(ProtoGetBufferFormat(picBuf));
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/JabberG/src/jabber_vcard.cpp b/protocols/JabberG/src/jabber_vcard.cpp index 2150161afd..16e57c3817 100644 --- a/protocols/JabberG/src/jabber_vcard.cpp +++ b/protocols/JabberG/src/jabber_vcard.cpp @@ -1132,15 +1132,9 @@ void CJabberProto::SetServerVcard(BOOL bPhotoChanged, wchar_t* szPhotoFileName) DWORD nRead;
if (ReadFile(hFile, buffer, st.st_size, &nRead, NULL)) {
ptrA str(mir_base64_encode((PBYTE)(LPSTR)buffer, nRead));
- if (str != NULL) {
+ const wchar_t *szFileType = ProtoGetAvatarMimeType(ProtoGetBufferFormat(buffer));
+ if (str != NULL && szFileType != NULL) {
n = v << XCHILD(L"PHOTO");
- wchar_t *szFileType;
- switch (ProtoGetBufferFormat(buffer)) {
- case PA_FORMAT_PNG: szFileType = L"image/png"; break;
- case PA_FORMAT_GIF: szFileType = L"image/gif"; break;
- case PA_FORMAT_BMP: szFileType = L"image/bmp"; break;
- default: szFileType = L"image/jpeg"; break;
- }
n << XCHILD(L"TYPE", szFileType);
n << XCHILD(L"BINVAL", _A2T(str));
|