From 2e125090810014fa46cd9bb27b2e4daea32ba2f4 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 17 Feb 2019 23:04:21 +0300 Subject: MIME types are of type char, not wchar_t --- include/m_core.h | 4 ++-- protocols/Discord/src/avatars.cpp | 8 ++++---- protocols/ICQ-WIM/src/utils.cpp | 2 +- src/mir_app/src/proto_utils.cpp | 26 +++++++++++++------------- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/include/m_core.h b/include/m_core.h index a13d9fc118..65a24c3eab 100644 --- a/include/m_core.h +++ b/include/m_core.h @@ -324,10 +324,10 @@ MIR_APP_DLL(int) ProtoGetAvatarFormat(const wchar_t *ptszFileName); MIR_APP_DLL(int) ProtoGetAvatarFileFormat(const wchar_t *ptszFileName); // returns the mime type according to a picture type (PA_*) passed -MIR_APP_DLL(const wchar_t*) ProtoGetAvatarMimeType(int iFileType); +MIR_APP_DLL(const char*) ProtoGetAvatarMimeType(int iFileType); // returns the picture type (PA_*) according to a mime type passed -MIR_APP_DLL(int) ProtoGetAvatarFormatByMimeType(const wchar_t *pwszMimeType); +MIR_APP_DLL(int) ProtoGetAvatarFormatByMimeType(const char *pwszMimeType); // returns the image format and extension by the first bytes of picture // ptszExtension might be NULL diff --git a/protocols/Discord/src/avatars.cpp b/protocols/Discord/src/avatars.cpp index 150bc39ac6..19a8adc158 100644 --- a/protocols/Discord/src/avatars.cpp +++ b/protocols/Discord/src/avatars.cpp @@ -71,7 +71,7 @@ LBL_Error: for (int i = 0; i < reply->headersCount; i++) if (!mir_strcmp(reply->headers[i].szName, "Content-Type")) { - ai.format = ProtoGetAvatarFormatByMimeType(_A2T(reply->headers[i].szValue)); + ai.format = ProtoGetAvatarFormatByMimeType(reply->headers[i].szValue); break; } @@ -170,12 +170,12 @@ INT_PTR CDiscordProto::SetMyAvatar(WPARAM, LPARAM lParam) CMStringA szPayload("data:"); - const wchar_t *wszMimeType = ProtoGetAvatarMimeType(ProtoGetAvatarFileFormat(pwszFilename)); - if (wszMimeType == nullptr) { + const char *szMimeType = ProtoGetAvatarMimeType(ProtoGetAvatarFileFormat(pwszFilename)); + if (szMimeType == nullptr) { debugLogA("invalid file format for avatar %S", pwszFilename); return 1; } - szPayload.AppendFormat("%S;base64,", wszMimeType); + szPayload.AppendFormat("%s;base64,", szMimeType); FILE *in = _wfopen(pwszFilename, L"rb"); if (in == nullptr) { debugLogA("cannot open avatar file %S for reading", pwszFilename); diff --git a/protocols/ICQ-WIM/src/utils.cpp b/protocols/ICQ-WIM/src/utils.cpp index bbb0faef31..7467ffee31 100644 --- a/protocols/ICQ-WIM/src/utils.cpp +++ b/protocols/ICQ-WIM/src/utils.cpp @@ -223,7 +223,7 @@ INT_PTR __cdecl CIcqProto::SetAvatar(WPARAM, LPARAM lParam) return 3; } - pReq->AddHeader("Content-Type", _T2A(ProtoGetAvatarMimeType(iAvatarType))); + pReq->AddHeader("Content-Type", ProtoGetAvatarMimeType(iAvatarType)); } Push(pReq); diff --git a/src/mir_app/src/proto_utils.cpp b/src/mir_app/src/proto_utils.cpp index 9e575e3d00..12d6ac1202 100644 --- a/src/mir_app/src/proto_utils.cpp +++ b/src/mir_app/src/proto_utils.cpp @@ -371,29 +371,29 @@ MIR_APP_DLL(int) ProtoGetAvatarFileFormat(const wchar_t *ptszFileName) ///////////////////////////////////////////////////////////////////////////////////////// // mime type functions -static wchar_t *wszMimeTypes[] = -{ - L"application/octet-stream", // PA_FORMAT_UNKNOWN - L"image/png", // PA_FORMAT_PNG - L"image/jpeg", // PA_FORMAT_JPEG - L"image/icon", // PA_FORMAT_ICON - L"image/bmp", // PA_FORMAT_BMP - L"image/gif", // PA_FORMAT_GIF - L"image/swf", // PA_FORMAT_SWF - L"application/xml" // PA_FORMAT_XML +static char *wszMimeTypes[] = +{ + "application/octet-stream", // PA_FORMAT_UNKNOWN + "image/png", // PA_FORMAT_PNG + "image/jpeg", // PA_FORMAT_JPEG + "image/icon", // PA_FORMAT_ICON + "image/bmp", // PA_FORMAT_BMP + "image/gif", // PA_FORMAT_GIF + "image/swf", // PA_FORMAT_SWF + "application/xml" // PA_FORMAT_XML }; -MIR_APP_DLL(const wchar_t*) ProtoGetAvatarMimeType(int iFileType) +MIR_APP_DLL(const char*) ProtoGetAvatarMimeType(int iFileType) { if (iFileType >= 0 && iFileType < _countof(wszMimeTypes)) return wszMimeTypes[iFileType]; return nullptr; } -MIR_APP_DLL(int) ProtoGetAvatarFormatByMimeType(const wchar_t *pwszMimeType) +MIR_APP_DLL(int) ProtoGetAvatarFormatByMimeType(const char *pwszMimeType) { for (int i = 0; i < _countof(wszMimeTypes); i++) - if (!mir_wstrcmp(pwszMimeType, wszMimeTypes[i])) + if (!mir_strcmp(pwszMimeType, wszMimeTypes[i])) return i; return PA_FORMAT_UNKNOWN; -- cgit v1.2.3