summaryrefslogtreecommitdiff
path: root/protocols/Yahoo/src
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Yahoo/src')
-rw-r--r--protocols/Yahoo/src/avatar.cpp146
1 files changed, 73 insertions, 73 deletions
diff --git a/protocols/Yahoo/src/avatar.cpp b/protocols/Yahoo/src/avatar.cpp
index 3af58910f5..7386810eb1 100644
--- a/protocols/Yahoo/src/avatar.cpp
+++ b/protocols/Yahoo/src/avatar.cpp
@@ -1,9 +1,9 @@
/*
* $Id: avatar.cpp 14178 2012-03-11 15:02:54Z borkra $
*
- * myYahoo Miranda Plugin
+ * myYahoo Miranda Plugin
*
- * Authors: Gennady Feldman (aka Gena01)
+ * Authors: Gennady Feldman (aka Gena01)
* Laurent Marechal (aka Peorth)
*
* This code is under GPL and is based on AIM, MSN and Miranda source code.
@@ -26,9 +26,9 @@
int YAHOO_avt_hash(const char *key, DWORD len)
{
- /*
+ /*
Thank you Pidgin and Kopete devs. It seems that both clients are using this code now.
-
+
*/
const unsigned char *p = (const unsigned char *)key;
@@ -42,7 +42,7 @@ int YAHOO_avt_hash(const char *key, DWORD len)
checksum &= ~g;
}
-
+
return checksum;
}
@@ -103,7 +103,7 @@ void upload_avt(int id, int fd, int error, void *data)
LOG(("File send complete!"));
}
-void __cdecl CYahooProto::send_avt_thread(void *psf)
+void __cdecl CYahooProto::send_avt_thread(void *psf)
{
struct yahoo_file_info *sf = ( yahoo_file_info* )psf;
if (sf == NULL) {
@@ -150,7 +150,7 @@ struct avatar_info{
int cksum;
};
-void __cdecl CYahooProto::recv_avatarthread(void *pavt)
+void __cdecl CYahooProto::recv_avatarthread(void *pavt)
{
PROTO_AVATAR_INFORMATIONT AI;
struct avatar_info *avt = ( avatar_info* )pavt;
@@ -234,12 +234,12 @@ void __cdecl CYahooProto::recv_avatarthread(void *pavt)
if (GetDword(hContact, "PictCK", 0) != avt->cksum) {
LOG(("WARNING: Checksum updated during download?!"));
error = 1; /* don't use this one? */
- }
+ }
SetDword(hContact, "PictLoading", 0);
LOG(("File download complete!?"));
- if (error)
+ if (error)
buf[0]='\0';
free(avt->who);
@@ -250,8 +250,8 @@ void __cdecl CYahooProto::recv_avatarthread(void *pavt)
AI.format = PA_FORMAT_PNG;
AI.hContact = hContact;
_tcsncpy(AI.filename, buf, SIZEOF(AI.filename));
-
- if (error)
+
+ if (error)
SetDword(hContact, "PictCK", 0);
ProtoBroadcastAck(m_szModuleName, hContact, ACKTYPE_AVATAR, !error ? ACKRESULT_SUCCESS:ACKRESULT_FAILED,(HANDLE) &AI, 0);
@@ -260,29 +260,29 @@ void __cdecl CYahooProto::recv_avatarthread(void *pavt)
void CYahooProto::ext_got_picture(const char *me, const char *who, const char *pic_url, int cksum, int type)
{
HANDLE hContact = 0;
-
+
LOG(("[ext_yahoo_got_picture] for %s with url %s (checksum: %d) type: %d", who, pic_url, cksum, type));
-
+
/*
Type:
-
+
1 - Send Avatar Info
2 - Got Avatar Info
3 - YIM6 didn't like my avatar? Expired? We need to invalidate and re-load
*/
switch (type) {
- case 1:
+ case 1:
{
int cksum=0;
DBVARIANT dbv;
-
+
/* need to send avatar info */
if (!GetByte("ShowAvatars", 1 )) {
LOG(("[ext_yahoo_got_picture] We are not using/showing avatars!"));
yahoo_send_picture_update(m_id, who, 0); // no avatar (disabled)
return;
}
-
+
LOG(("[ext_yahoo_got_picture] Getting ready to send info!"));
/* need to read CheckSum */
cksum = GetDword("AvatarHash", 0);
@@ -295,7 +295,7 @@ void CYahooProto::ext_got_picture(const char *me, const char *who, const char *p
break;
} else
LOG(("No AvatarURL???"));
-
+
/*
* Try to re-upload the avatar
*/
@@ -303,39 +303,39 @@ void CYahooProto::ext_got_picture(const char *me, const char *who, const char *p
// NO avatar URL??
if (!DBGetContactSettingTString(NULL, m_szModuleName, "AvatarFile", &dbv)) {
struct _stat statbuf;
-
+
if (_tstat( dbv.ptszVal, &statbuf ) != 0) {
LOG(("[ext_yahoo_got_picture] Avatar File Missing? Can't find file: %s", dbv.ptszVal));
} else {
db_set_s(NULL, m_szModuleName, "AvatarInv", who);
SendAvatar(dbv.ptszVal);
}
-
+
DBFreeVariant(&dbv);
} else {
LOG(("[ext_yahoo_got_picture] No Local Avatar File??? "));
}
- } else
+ } else
LOG(("[ext_yahoo_got_picture] Another avatar upload in progress?"));
}
}
break;
case 2: /*
- * We got Avatar Info for our buddy.
+ * We got Avatar Info for our buddy.
*/
if (!GetByte("ShowAvatars", 1 )) {
LOG(("[ext_yahoo_got_picture] We are not using/showing avatars!"));
return;
}
-
+
/* got avatar info, so set miranda up */
hContact = getbuddyH(who);
-
+
if (!hContact) {
LOG(("[ext_yahoo_got_picture] Buddy not on my buddy list?."));
return;
}
-
+
if (!cksum && pic_url) {
const char *chk = strstr(pic_url, "chksum=");
if (chk)
@@ -345,19 +345,19 @@ void CYahooProto::ext_got_picture(const char *me, const char *who, const char *p
if (!cksum || cksum == -1) {
LOG(("[ext_yahoo_got_picture] Resetting avatar."));
db_set_dw(hContact, m_szModuleName, "PictCK", 0);
-
+
reset_avatar(hContact);
} else {
if (pic_url == NULL) {
LOG(("[ext_yahoo_got_picture] WARNING: Empty URL for avatar?"));
return;
}
-
+
TCHAR z[1024];
GetAvatarFileName(hContact, z, 1024, db_get_b(hContact, m_szModuleName,"AvatarType", 0));
-
+
if (db_get_dw(hContact, m_szModuleName,"PictCK", 0) != cksum || _taccess( z, 0) != 0) {
-
+
DebugLog("[ext_yahoo_got_picture] Checksums don't match or avatar file is missing. Current: %d, New: %d",(int)db_get_dw(hContact, m_szModuleName,"PictCK", 0), cksum);
struct avatar_info *avt = ( avatar_info* )malloc(sizeof(struct avatar_info));
@@ -370,7 +370,7 @@ void CYahooProto::ext_got_picture(const char *me, const char *who, const char *p
}
break;
- case 3:
+ case 3:
/*
* Our Avatar is not good anymore? Need to re-upload??
*/
@@ -378,14 +378,14 @@ void CYahooProto::ext_got_picture(const char *me, const char *who, const char *p
{
int mcksum=0;
DBVARIANT dbv;
-
+
/* need to send avatar info */
if (!GetByte("ShowAvatars", 1 )) {
LOG(("[ext_yahoo_got_picture] We are not using/showing avatars!"));
yahoo_send_picture_update(m_id, who, 0); // no avatar (disabled)
return;
}
-
+
LOG(("[ext_yahoo_got_picture] Getting ready to send info!"));
/* need to read CheckSum */
mcksum = GetDword("AvatarHash", 0);
@@ -395,34 +395,34 @@ void CYahooProto::ext_got_picture(const char *me, const char *who, const char *p
yahoo_send_picture_update(m_id, who, 0); // no avatar (disabled)
return;
}
-
+
LOG(("[ext_yahoo_got_picture] My Checksum: %d", mcksum));
-
+
if (!GetString("AvatarURL", &dbv)) {
if (lstrcmpiA(pic_url, dbv.pszVal) == 0) {
DBVARIANT dbv2;
/*time_t ts;
DWORD ae;*/
-
+
if (mcksum != cksum)
- LOG(("[ext_yahoo_got_picture] WARNING: Checksums don't match!"));
-
+ LOG(("[ext_yahoo_got_picture] WARNING: Checksums don't match!"));
+
/*time(&ts);
ae = GetDword("AvatarExpires", 0);
-
+
if (ae != 0 && ae > (ts - 300)) {
LOG(("[ext_yahoo_got_picture] Current Time: %lu Expires: %lu ", ts, ae));
LOG(("[ext_yahoo_got_picture] We just reuploaded! Stop screwing with Yahoo FT. "));
-
+
// don't leak stuff
DBFreeVariant(&dbv);
break;
}*/
-
+
LOG(("[ext_yahoo_got_picture] Buddy: %s told us this is bad??Expired??. Re-uploading", who));
db_unset(NULL, m_szModuleName, "AvatarURL");
-
+
if (!DBGetContactSettingTString(NULL, m_szModuleName, "AvatarFile", &dbv2)) {
db_set_s(NULL, m_szModuleName, "AvatarInv", who);
SendAvatar(dbv2.ptszVal);
@@ -444,7 +444,7 @@ void CYahooProto::ext_got_picture(const char *me, const char *who, const char *p
default:
LOG(("[ext_yahoo_got_picture] Unknown request/packet type exiting!"));
}
-
+
LOG(("ext_yahoo_got_picture exiting"));
}
@@ -526,7 +526,7 @@ void CYahooProto::ext_got_picture_status(const char *me, const char *who, int bu
void CYahooProto::ext_got_picture_upload(const char *me, const char *url,unsigned int ts)
{
int cksum = 0;
- DBVARIANT dbv;
+ DBVARIANT dbv;
LOG(("[ext_yahoo_got_picture_upload] url: %s timestamp: %d", url, ts));
@@ -605,7 +605,7 @@ void CYahooProto::request_avatar(const char* who)
/*
* time() - in seconds ( 60*60 = 1 hour)
*/
- if (db_get_dw(hContact, m_szModuleName,"PictCK", 0) == 0 ||
+ if (db_get_dw(hContact, m_szModuleName,"PictCK", 0) == 0 ||
last_chk == 0 || (cur_time - last_chk) > 60) {
db_set_dw(hContact, m_szModuleName, "PictLastCheck", (DWORD)cur_time);
@@ -620,12 +620,12 @@ void CYahooProto::request_avatar(const char* who)
void CYahooProto::InitCustomFolders(void)
{
if (InitCstFldRan)
- return;
+ return;
InitCstFldRan = true;
TCHAR AvatarsFolder[MAX_PATH];
- mir_sntprintf(AvatarsFolder, MAX_PATH, _T("%%miranda_avatarcache%%\\") _T(TCHAR_STR_PARAM), m_szModuleName);
+ mir_sntprintf(AvatarsFolder, MAX_PATH, _T("%%miranda_avatarcache%%\\%S"), m_szModuleName);
hYahooAvatarsFolder = FoldersRegisterCustomPathT("Avatars", m_szModuleName, AvatarsFolder);
}
@@ -642,7 +642,7 @@ void CYahooProto::GetAvatarFileName(HANDLE hContact, TCHAR* pszDest, int cbLen,
tPathLen = _tcslen( pszDest );
} else {
TCHAR *tmpPath = Utils_ReplaceVarsT( _T("%miranda_avatarcache%"));
- tPathLen = mir_sntprintf(pszDest, cbLen, _T("%s\\") _T(TCHAR_STR_PARAM), tmpPath, m_szModuleName);
+ tPathLen = mir_sntprintf(pszDest, cbLen, _T("%s\\%S"), tmpPath, m_szModuleName);
mir_free(tmpPath);
}
@@ -653,9 +653,9 @@ void CYahooProto::GetAvatarFileName(HANDLE hContact, TCHAR* pszDest, int cbLen,
int ck_sum = db_get_dw(hContact, m_szModuleName,"PictCK", 0);
tPathLen += mir_sntprintf(pszDest + tPathLen, cbLen - tPathLen, _T("\\%lX"), ck_sum);
} else {
- tPathLen += mir_sntprintf(pszDest + tPathLen, cbLen - tPathLen, _T("\\") _T(TCHAR_STR_PARAM) _T(" avatar"), m_szModuleName);
+ tPathLen += mir_sntprintf(pszDest + tPathLen, cbLen - tPathLen, _T("\\%S avatar"), m_szModuleName);
}
-
+
mir_sntprintf(pszDest + tPathLen, cbLen - tPathLen, _T("%s"), type == 1 ? _T(".swf") : _T(".png"));
}
@@ -688,17 +688,17 @@ INT_PTR __cdecl CYahooProto::GetAvatarInfo(WPARAM wParam,LPARAM lParam)
return GAIR_NOAVATAR;
}
- if (db_get_dw(AI->hContact, m_szModuleName,"PictCK", 0) == 0)
+ if (db_get_dw(AI->hContact, m_szModuleName,"PictCK", 0) == 0)
return GAIR_NOAVATAR;
GetAvatarFileName(AI->hContact, AI->filename, SIZEOF(AI->filename), db_get_b(AI->hContact, m_szModuleName,"AvatarType", 0));
AI->format = PA_FORMAT_PNG;
DebugLog("[YAHOO_GETAVATARINFO] filename: %s", AI->filename);
- if (_taccess( AI->filename, 0) == 0)
+ if (_taccess( AI->filename, 0) == 0)
return GAIR_SUCCESS;
- if (( wParam & GAIF_FORCE ) != 0 && AI->hContact != NULL) {
+ if (( wParam & GAIF_FORCE ) != 0 && AI->hContact != NULL) {
/* need to request it again? */
if (GetDword(AI->hContact, "PictLoading", 0) != 0 &&
(time(NULL) - GetDword(AI->hContact, "PictLastCheck", 0) < 500)) {
@@ -732,7 +732,7 @@ INT_PTR __cdecl CYahooProto::GetAvatarCaps(WPARAM wParam, LPARAM lParam)
int res = 0;
switch (wParam) {
- case AF_MAXSIZE:
+ case AF_MAXSIZE:
LOG(("[YahooGetAvatarCaps] AF_MAXSIZE"));
((POINT*)lParam)->x = 96;
@@ -740,7 +740,7 @@ INT_PTR __cdecl CYahooProto::GetAvatarCaps(WPARAM wParam, LPARAM lParam)
break;
- case AF_PROPORTION:
+ case AF_PROPORTION:
LOG(("[YahooGetAvatarCaps] AF_PROPORTION"));
res = PIP_NONE;
@@ -828,13 +828,13 @@ INT_PTR __cdecl CYahooProto::SetMyAvatar(WPARAM wParam, LPARAM lParam)
GetAvatarFileName(NULL, tszMyFile, MAX_PATH, 2);
if (tszFile == NULL) {
- DebugLog("[Deleting Avatar Info]");
+ DebugLog("[Deleting Avatar Info]");
/* remove ALL our Avatar Info Keys */
- db_unset(NULL, m_szModuleName, "AvatarFile");
+ db_unset(NULL, m_szModuleName, "AvatarFile");
db_unset(NULL, m_szModuleName, "AvatarHash");
- db_unset(NULL, m_szModuleName, "AvatarURL");
- db_unset(NULL, m_szModuleName, "AvatarTS");
+ db_unset(NULL, m_szModuleName, "AvatarURL");
+ db_unset(NULL, m_szModuleName, "AvatarTS");
/* Send a Yahoo packet saying we don't got an avatar anymore */
yahoo_send_picture_status(m_id, 0);
@@ -848,12 +848,12 @@ INT_PTR __cdecl CYahooProto::SetMyAvatar(WPARAM wParam, LPARAM lParam)
unsigned int hash;
HANDLE hFile;
- hFile = CreateFile(tszFile,
- GENERIC_READ,
- FILE_SHARE_READ|FILE_SHARE_WRITE,
- NULL,
- OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN,
+ hFile = CreateFile(tszFile,
+ GENERIC_READ,
+ FILE_SHARE_READ|FILE_SHARE_WRITE,
+ NULL,
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN,
0);
if ( hFile == INVALID_HANDLE_VALUE )
@@ -866,13 +866,13 @@ INT_PTR __cdecl CYahooProto::SetMyAvatar(WPARAM wParam, LPARAM lParam)
ReadFile( hFile, pResult, dwPngSize, &dw, NULL);
CloseHandle( hFile );
- hFile = CreateFile(tszMyFile,
- GENERIC_WRITE,
- FILE_SHARE_WRITE,
- NULL,
- OPEN_ALWAYS,
+ hFile = CreateFile(tszMyFile,
+ GENERIC_WRITE,
+ FILE_SHARE_WRITE,
+ NULL,
+ OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL, 0);
- if ( hFile == INVALID_HANDLE_VALUE )
+ if ( hFile == INVALID_HANDLE_VALUE )
return 1;
WriteFile( hFile, pResult, dwPngSize, &dw, NULL);
@@ -883,7 +883,7 @@ INT_PTR __cdecl CYahooProto::SetMyAvatar(WPARAM wParam, LPARAM lParam)
free( pResult );
if ( hash ) {
- LOG(("[YAHOO_SetAvatar] File: '%s' CK: %d", tszMyFile, hash));
+ LOG(("[YAHOO_SetAvatar] File: '%s' CK: %d", tszMyFile, hash));
/* now check and make sure we don't reupload same thing over again */
if (hash != GetDword("AvatarHash", 0)) {
@@ -897,8 +897,8 @@ INT_PTR __cdecl CYahooProto::SetMyAvatar(WPARAM wParam, LPARAM lParam)
}
SendAvatar(tszMyFile);
- }
- else LOG(("[YAHOO_SetAvatar] Same checksum and avatar on YahooFT. Not Reuploading."));
+ }
+ else LOG(("[YAHOO_SetAvatar] Same checksum and avatar on YahooFT. Not Reuploading."));
} }
return 0;