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 | |
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')
-rw-r--r-- | protocols/AimOscar/src/avatars.cpp | 41 | ||||
-rw-r--r-- | protocols/AimOscar/src/avatars.h | 2 | ||||
-rw-r--r-- | protocols/AimOscar/src/services.cpp | 2 |
3 files changed, 2 insertions, 43 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;
diff --git a/protocols/AimOscar/src/avatars.h b/protocols/AimOscar/src/avatars.h index 69c7ec49bf..1188a1ec82 100644 --- a/protocols/AimOscar/src/avatars.h +++ b/protocols/AimOscar/src/avatars.h @@ -46,8 +46,6 @@ struct avatar_up_req { mir_free(data1); mir_free(data2); }
};
-int detect_image_type(const char* stream, const TCHAR* &type_ret);
-int detect_image_type(const TCHAR* file);
bool get_avatar_hash(const TCHAR* file, char* hash, char** data, unsigned short &size);
void rescale_image(char *data, unsigned short size, char *&data1, unsigned short &size1);
diff --git a/protocols/AimOscar/src/services.cpp b/protocols/AimOscar/src/services.cpp index bfc0ca83ed..721751016c 100644 --- a/protocols/AimOscar/src/services.cpp +++ b/protocols/AimOscar/src/services.cpp @@ -384,7 +384,7 @@ INT_PTR CAimProto::GetAvatarInfo(WPARAM wParam, LPARAM lParam) return GAIR_SUCCESS;
case GAIR_WAITFOR:
- AI->format = detect_image_type(AI->filename);
+ AI->format = ProtoGetAvatarFormat(AI->filename);
break;
default:
|