diff options
author | George Hazan <george.hazan@gmail.com> | 2013-08-11 10:41:37 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-08-11 10:41:37 +0000 |
commit | 94dcc72f13094157f344f284aec4edf0c0f5faa1 (patch) | |
tree | 74c078daadd4abe5aea9e9e0a73b4dd7c4a7fde1 /protocols/AimOscar/src/avatars.cpp | |
parent | 42ff2169dbddd25d06404623dba2fff222d17c73 (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/AimOscar/src/avatars.cpp')
-rw-r--r-- | protocols/AimOscar/src/avatars.cpp | 41 |
1 files changed, 1 insertions, 40 deletions
diff --git a/protocols/AimOscar/src/avatars.cpp b/protocols/AimOscar/src/avatars.cpp index 7f54961398..dea8de177e 100644 --- a/protocols/AimOscar/src/avatars.cpp +++ b/protocols/AimOscar/src/avatars.cpp @@ -102,7 +102,7 @@ void CAimProto::avatar_retrieval_handler(const char* sn, const char* hash, const if (data_len > 0)
{
const TCHAR *type;
- AI.format = detect_image_type(data, type);
+ AI.format = ProtoGetBufferFormat(data, &type);
get_avatar_filename(AI.hContact, AI.filename, SIZEOF(AI.filename), type);
int fileId = _topen(AI.filename, _O_CREAT | _O_TRUNC | _O_WRONLY | O_BINARY, _S_IREAD | _S_IWRITE);
@@ -123,45 +123,6 @@ void CAimProto::avatar_retrieval_handler(const char* sn, const char* hash, const ProtoBroadcastAck(AI.hContact, ACKTYPE_AVATAR, res ? ACKRESULT_SUCCESS : ACKRESULT_FAILED, &AI, 0);
}
-int detect_image_type(const char* stream, const TCHAR* &type_ret)
-{
- if (stream[0]=='G'&&stream[1]=='I'&&stream[2]=='F')
- {
- type_ret = _T(".gif");
- return PA_FORMAT_GIF;
- }
- else if (stream[1]=='P'&&stream[2]=='N'&&stream[3]=='G')
- {
- type_ret = _T(".png");
- return PA_FORMAT_PNG;
- }
- else if (stream[0]=='B'&&stream[1]=='M')
- {
- type_ret = _T(".bmp");
- return PA_FORMAT_BMP;
- }
- else//assume jpg
- {
- type_ret = _T(".jpg");
- return PA_FORMAT_JPEG;
- }
-}
-
-int detect_image_type(const TCHAR* file)
-{
- const TCHAR *ext = _tcsrchr(file, '.');
- if (ext == NULL)
- return PA_FORMAT_UNKNOWN;
- if (_tcsicmp(ext, _T(".gif")) == 0)
- return PA_FORMAT_GIF;
- else if (_tcsicmp(ext, _T(".bmp")) == 0)
- return PA_FORMAT_BMP;
- else if (_tcsicmp(ext, _T(".png")) == 0)
- return PA_FORMAT_PNG;
- else
- return PA_FORMAT_JPEG;
-}
-
void CAimProto::init_custom_folders(void)
{
if (init_cst_fld_ran) return;
|