summaryrefslogtreecommitdiff
path: root/src/mir_app
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-02-03 16:08:38 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-02-03 16:08:38 +0300
commit1ef4b90ce07ccc4e372f0b8179c69438bff24ae2 (patch)
treeeb9cda4038333ff654e4da664325569d493c9648 /src/mir_app
parentceb375ad7f99c4169ffb3041037583996122fa57 (diff)
mime type standardization
Diffstat (limited to 'src/mir_app')
-rw-r--r--src/mir_app/src/mir_app.def2
-rw-r--r--src/mir_app/src/mir_app64.def2
-rw-r--r--src/mir_app/src/proto_utils.cpp31
3 files changed, 35 insertions, 0 deletions
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index e3106f9927..473761ff35 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -396,3 +396,5 @@ Netlib_NtlmCreateResponse @383
?makeBlob@DB_AUTH_BLOB@@AAEPAEXZ @397 NONAME
?size@DB_AUTH_BLOB@@QBEKXZ @398 NONAME
Chat_UnescapeTags @399 NONAME
+ProtoGetAvatarFormatByMimeType @400
+ProtoGetAvatarMimeType @401
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index da54dec2d5..044ee43a95 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -396,3 +396,5 @@ Netlib_NtlmCreateResponse @383
?makeBlob@DB_AUTH_BLOB@@AEAAPEAEXZ @397 NONAME
?size@DB_AUTH_BLOB@@QEBAKXZ @398 NONAME
Chat_UnescapeTags @399 NONAME
+ProtoGetAvatarFormatByMimeType @400
+ProtoGetAvatarMimeType @401
diff --git a/src/mir_app/src/proto_utils.cpp b/src/mir_app/src/proto_utils.cpp
index 94e54a0ed3..32d8c10f8c 100644
--- a/src/mir_app/src/proto_utils.cpp
+++ b/src/mir_app/src/proto_utils.cpp
@@ -235,6 +235,37 @@ MIR_APP_DLL(int) ProtoGetAvatarFileFormat(const wchar_t *ptszFileName)
}
/////////////////////////////////////////////////////////////////////////////////////////
+// mime type functions
+
+static wchar_t *wszMimeTypes[] =
+{
+ L"binary", // 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
+};
+
+MIR_APP_DLL(const wchar_t*) ProtoGetAvatarMimeType(int iFileType)
+{
+ if (iFileType >= 0 && iFileType <= _countof(wszMimeTypes))
+ return wszMimeTypes[iFileType];
+ return NULL;
+}
+
+MIR_APP_DLL(int) ProtoGetAvatarFormatByMimeType(const wchar_t *pwszMimeType)
+{
+ for (int i = 0; i < _countof(wszMimeTypes); i++)
+ if (!mir_wstrcmp(pwszMimeType, wszMimeTypes[i]))
+ return i;
+
+ return PA_FORMAT_UNKNOWN;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
// default PROTO_INTERFACE method implementations
MCONTACT PROTO_INTERFACE::AddToList(int, PROTOSEARCHRESULT*)