summaryrefslogtreecommitdiff
path: root/protocols/AimOscar/src/avatars.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-08-13 17:08:34 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-08-13 17:08:34 +0000
commit1ea84dc56d95ceaf85c036127c5045eba0ad50ee (patch)
treea8392d1877470f4d7513e3ad853fa843d564a544 /protocols/AimOscar/src/avatars.cpp
parent5c84f735bc4f40d3f2f645d003ef9a08576878d8 (diff)
massive name conflict resolution
git-svn-id: http://svn.miranda-ng.org/main/trunk@14941 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/AimOscar/src/avatars.cpp')
-rw-r--r--protocols/AimOscar/src/avatars.cpp89
1 files changed, 37 insertions, 52 deletions
diff --git a/protocols/AimOscar/src/avatars.cpp b/protocols/AimOscar/src/avatars.cpp
index 298a11f899..0b21052483 100644
--- a/protocols/AimOscar/src/avatars.cpp
+++ b/protocols/AimOscar/src/avatars.cpp
@@ -16,6 +16,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+
#include "stdafx.h"
void __cdecl CAimProto::avatar_request_thread(void* param)
@@ -25,8 +26,7 @@ void __cdecl CAimProto::avatar_request_thread(void* param)
char *sn = getStringA(hContact, AIM_KEY_SN);
debugLogA("Starting avatar request thread for %s)", sn);
- if (wait_conn(hAvatarConn, hAvatarEvent, 0x10))
- {
+ if (wait_conn(m_hAvatarConn, m_hAvatarEvent, 0x10)) {
char *hash_str = getStringA(hContact, AIM_KEY_AH);
if (!hash_str) {
mir_free(sn);
@@ -35,10 +35,10 @@ void __cdecl CAimProto::avatar_request_thread(void* param)
char type = getByte(hContact, AIM_KEY_AHT, 1);
size_t len = (mir_strlen(hash_str) + 1) / 2;
- char* hash = (char*)alloca(len);
+ char *hash = (char*)alloca(len);
string_to_bytes(hash_str, hash);
debugLogA("Requesting an Avatar: %s (Hash: %s)", sn, hash_str);
- aim_request_avatar(hAvatarConn, avatar_seqno, sn, type, hash, (unsigned short)len);
+ aim_request_avatar(m_hAvatarConn, m_avatar_seqno, sn, type, hash, (unsigned short)len);
mir_free(hash_str);
}
@@ -50,42 +50,35 @@ void __cdecl CAimProto::avatar_upload_thread(void* param)
{
avatar_up_req* req = (avatar_up_req*)param;
- if (wait_conn(hAvatarConn, hAvatarEvent, 0x10))
- {
- if (req->size2)
- {
- aim_upload_avatar(hAvatarConn, avatar_seqno, 1, req->data2, req->size2);
- aim_upload_avatar(hAvatarConn, avatar_seqno, 12, req->data1, req->size1);
+ if (wait_conn(m_hAvatarConn, m_hAvatarEvent, 0x10)) {
+ if (req->size2) {
+ aim_upload_avatar(m_hAvatarConn, m_avatar_seqno, 1, req->data2, req->size2);
+ aim_upload_avatar(m_hAvatarConn, m_avatar_seqno, 12, req->data1, req->size1);
}
- else
- aim_upload_avatar(hAvatarConn, avatar_seqno, 1, req->data1, req->size1);
+ else aim_upload_avatar(m_hAvatarConn, m_avatar_seqno, 1, req->data1, req->size1);
}
delete req;
}
void CAimProto::avatar_request_handler(MCONTACT hContact, char* hash, unsigned char type)//checks to see if the avatar needs requested
{
- if (hContact == NULL)
- {
- hash = hash_lg ? hash_lg : hash_sm;
- type = hash_lg ? 12 : 1;
+ if (hContact == NULL) {
+ hash = m_hash_lg ? m_hash_lg : m_hash_sm;
+ type = m_hash_lg ? 12 : 1;
}
- char* saved_hash = getStringA(hContact, AIM_KEY_AH);
+ char *saved_hash = getStringA(hContact, AIM_KEY_AH);
if (hash && _stricmp(hash, "0201d20472") && _stricmp(hash, "2b00003341")) //gaim default icon fix- we don't want their blank icon displaying.
{
- if (mir_strcmp(saved_hash, hash))
- {
+ if (mir_strcmp(saved_hash, hash)) {
setByte(hContact, AIM_KEY_AHT, type);
setString(hContact, AIM_KEY_AH, hash);
ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, NULL, 0);
}
}
- else
- {
- if (saved_hash)
- {
+ else {
+ if (saved_hash) {
delSetting(hContact, AIM_KEY_AHT);
delSetting(hContact, AIM_KEY_AH);
@@ -106,7 +99,7 @@ void CAimProto::avatar_retrieval_handler(const char* sn, const char* /*hash*/, c
ai.format = ProtoGetBufferFormat(data, &type);
get_avatar_filename(ai.hContact, ai.filename, _countof(ai.filename), type);
- int fileId = _topen(ai.filename, _O_CREAT | _O_TRUNC | _O_WRONLY | O_BINARY, _S_IREAD | _S_IWRITE);
+ int fileId = _topen(ai.filename, _O_CREAT | _O_TRUNC | _O_WRONLY | O_BINARY, _S_IREAD | _S_IWRITE);
if (fileId >= 0) {
_write(fileId, data, data_len);
_close(fileId);
@@ -125,7 +118,7 @@ void CAimProto::avatar_retrieval_handler(const char* sn, const char* /*hash*/, c
int CAimProto::get_avatar_filename(MCONTACT hContact, TCHAR* pszDest, size_t cbLen, const TCHAR *ext)
{
- int tPathLen = mir_sntprintf(pszDest, cbLen, _T("%s\\%S"), VARST( _T("%miranda_avatarcache%")), m_szModuleName);
+ int tPathLen = mir_sntprintf(pszDest, cbLen, _T("%s\\%S"), VARST(_T("%miranda_avatarcache%")), m_szModuleName);
if (ext && _taccess(pszDest, 0))
CreateDirectoryTreeT(pszDest);
@@ -138,28 +131,24 @@ int CAimProto::get_avatar_filename(MCONTACT hContact, TCHAR* pszDest, size_t cbL
db_free(&dbv);
bool found = false;
- if (ext == NULL)
- {
+ if (ext == NULL) {
mir_sntprintf(pszDest + tPathLen, cbLen - tPathLen, _T(".*"));
_tfinddata_t c_file;
long hFile = _tfindfirst(pszDest, &c_file);
- if (hFile > -1L)
- {
+ if (hFile > -1L) {
do {
- if (_tcsrchr(c_file.name, '.'))
- {
+ if (_tcsrchr(c_file.name, '.')) {
mir_sntprintf(pszDest + tPathLen2, cbLen - tPathLen2, _T("\\%s"), c_file.name);
found = true;
}
} while (_tfindnext(hFile, &c_file) == 0);
- _findclose( hFile );
+ _findclose(hFile);
}
if (!found) pszDest[0] = 0;
}
- else
- {
+ else {
mir_sntprintf(pszDest + tPathLen, cbLen - tPathLen, ext);
found = _taccess(pszDest, 0) == 0;
}
@@ -173,8 +162,7 @@ bool get_avatar_hash(const TCHAR* file, char* hash, char** data, unsigned short
if (fileId == -1) return false;
long lAvatar = _filelength(fileId);
- if (lAvatar <= 0)
- {
+ if (lAvatar <= 0) {
_close(fileId);
return false;
}
@@ -183,8 +171,7 @@ bool get_avatar_hash(const TCHAR* file, char* hash, char** data, unsigned short
int res = _read(fileId, pResult, lAvatar);
_close(fileId);
- if (res <= 0)
- {
+ if (res <= 0) {
mir_free(pResult);
return false;
}
@@ -194,8 +181,7 @@ bool get_avatar_hash(const TCHAR* file, char* hash, char** data, unsigned short
mir_md5_append(&state, (unsigned char*)pResult, lAvatar);
mir_md5_finish(&state, (unsigned char*)hash);
- if (data)
- {
+ if (data) {
*data = pResult;
size = (unsigned short)lAvatar;
}
@@ -208,29 +194,28 @@ bool get_avatar_hash(const TCHAR* file, char* hash, char** data, unsigned short
void rescale_image(char *data, unsigned short size, char *&data1, unsigned short &size1)
{
FI_INTERFACE *fei = NULL;
- CallService(MS_IMG_GETINTERFACE, FI_IF_VERSION, (LPARAM) &fei);
+ CallService(MS_IMG_GETINTERFACE, FI_IF_VERSION, (LPARAM)&fei);
if (fei == NULL) return;
- FIMEMORY *hmem = fei->FI_OpenMemory((BYTE *)data, size);
- FREE_IMAGE_FORMAT fif = fei->FI_GetFileTypeFromMemory(hmem, 0);
- FIBITMAP *dib = fei->FI_LoadFromMemory(fif, hmem, 0);
- fei->FI_CloseMemory(hmem);
+ FIMEMORY *hmem = fei->FI_OpenMemory((BYTE *)data, size);
+ FREE_IMAGE_FORMAT fif = fei->FI_GetFileTypeFromMemory(hmem, 0);
+ FIBITMAP *dib = fei->FI_LoadFromMemory(fif, hmem, 0);
+ fei->FI_CloseMemory(hmem);
- if (fei->FI_GetWidth(dib) > 64)
- {
+ if (fei->FI_GetWidth(dib) > 64) {
FIBITMAP *dib1 = fei->FI_Rescale(dib, 64, 64, FILTER_BSPLINE);
- FIMEMORY *hmem = fei->FI_OpenMemory(NULL, 0);
- fei->FI_SaveToMemory(fif, dib1, hmem, 0);
+ FIMEMORY *hmem2 = fei->FI_OpenMemory(NULL, 0);
+ fei->FI_SaveToMemory(fif, dib1, hmem2, 0);
BYTE *data2; DWORD size2;
- fei->FI_AcquireMemory(hmem, &data2, &size2);
+ fei->FI_AcquireMemory(hmem2, &data2, &size2);
data1 = (char*)mir_alloc(size2);
memcpy(data1, data2, size2);
size1 = size2;
- fei->FI_CloseMemory(hmem);
+ fei->FI_CloseMemory(hmem2);
fei->FI_Unload(dib1);
}
fei->FI_Unload(dib);
-} \ No newline at end of file
+}