diff options
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:
|