From 612fc2f36903f0168f88622f61e1a0de4dae5b92 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 1 Jun 2015 22:15:26 +0000 Subject: - atavism named MS_UTILS_LOADBITMAP removed; - bmpfilter.cpp also removed; - Bitmap_Load() function added instead; - various bitmap related crap fixed; git-svn-id: http://svn.miranda-ng.org/main/trunk@13966 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/IcqOscarJ/src/icqosc_svcs.cpp | 63 ++++++++++++++++----------------- 1 file changed, 31 insertions(+), 32 deletions(-) (limited to 'protocols/IcqOscarJ') diff --git a/protocols/IcqOscarJ/src/icqosc_svcs.cpp b/protocols/IcqOscarJ/src/icqosc_svcs.cpp index b7d887bad7..6d4b130956 100644 --- a/protocols/IcqOscarJ/src/icqosc_svcs.cpp +++ b/protocols/IcqOscarJ/src/icqosc_svcs.cpp @@ -482,59 +482,58 @@ INT_PTR CIcqProto::SendYouWereAdded(WPARAM, LPARAM lParam) INT_PTR CIcqProto::SetMyAvatar(WPARAM, LPARAM lParam) { - TCHAR* tszFile = (TCHAR*)lParam; - int iRet = -1; - - if (!m_bAvatarsEnabled || !m_bSsiEnabled) return -2; + if (!m_bAvatarsEnabled || !m_bSsiEnabled) + return -2; + TCHAR *tszFile = (TCHAR*)lParam; if (tszFile) { // set file for avatar int dwPaFormat = ::ProtoGetAvatarFileFormat(tszFile); if (dwPaFormat != PA_FORMAT_XML) { // if it should be image, check if it is valid - HBITMAP avt = (HBITMAP)CallService(MS_UTILS_LOADBITMAPT, 0, (WPARAM)tszFile); - if (!avt) return iRet; + HBITMAP avt = Bitmap_Load(tszFile); + if (!avt) + return -1; + DeleteObject(avt); } TCHAR tszMyFile[MAX_PATH + 1]; GetFullAvatarFileName(0, NULL, dwPaFormat, tszMyFile, MAX_PATH); + // if not in our storage, copy if (mir_tstrcmp(tszFile, tszMyFile) && !CopyFile(tszFile, tszMyFile, FALSE)) { debugLogA("Failed to copy our avatar to local storage."); - return iRet; + return -1; } BYTE *hash = calcMD5HashOfFile(tszMyFile); - if (hash) { - BYTE ihash[0x14]; - // upload hash to server - ihash[0] = 0; //unknown - ihash[1] = dwPaFormat == PA_FORMAT_XML ? AVATAR_HASH_FLASH : AVATAR_HASH_STATIC; //hash type - ihash[2] = 1; //hash status - ihash[3] = 0x10; //hash len - memcpy((ihash + 4), hash, 0x10); - updateServAvatarHash(ihash, 0x14); - - if (setSettingBlob(NULL, "AvatarHash", ihash, 0x14)) - debugLogA("Failed to save avatar hash."); - - TCHAR tmp[MAX_PATH]; - PathToRelativeT(tszMyFile, tmp); - setTString(NULL, "AvatarFile", tmp); - - iRet = 0; - - SAFE_FREE((void**)&hash); - } + if (hash == NULL) + return -1; + + BYTE ihash[0x14]; + // upload hash to server + ihash[0] = 0; //unknown + ihash[1] = dwPaFormat == PA_FORMAT_XML ? AVATAR_HASH_FLASH : AVATAR_HASH_STATIC; //hash type + ihash[2] = 1; //hash status + ihash[3] = 0x10; //hash len + memcpy((ihash + 4), hash, 0x10); + updateServAvatarHash(ihash, 0x14); + + if (setSettingBlob(NULL, "AvatarHash", ihash, 0x14)) + debugLogA("Failed to save avatar hash."); + + TCHAR tmp[MAX_PATH]; + PathToRelativeT(tszMyFile, tmp); + setTString(NULL, "AvatarFile", tmp); + SAFE_FREE((void**)&hash); } - else { // delete user avatar + else { + // delete user avatar delSetting("AvatarFile"); setSettingBlob(NULL, "AvatarHash", hashEmptyAvatar, 9); updateServAvatarHash(hashEmptyAvatar, 9); // set blank avatar - iRet = 0; } - - return iRet; + return 0; } INT_PTR CIcqProto::SetNickName(WPARAM wParam, LPARAM lParam) -- cgit v1.2.3