summaryrefslogtreecommitdiff
path: root/protocols/Yahoo
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Yahoo')
-rw-r--r--protocols/Yahoo/src/avatar.cpp39
-rw-r--r--protocols/Yahoo/src/chat.cpp1
-rw-r--r--protocols/Yahoo/src/proto.cpp5
-rw-r--r--protocols/Yahoo/src/webcam.cpp2
-rw-r--r--protocols/Yahoo/src/yahoo.cpp85
5 files changed, 45 insertions, 87 deletions
diff --git a/protocols/Yahoo/src/avatar.cpp b/protocols/Yahoo/src/avatar.cpp
index f698adb092..9fb6eb893e 100644
--- a/protocols/Yahoo/src/avatar.cpp
+++ b/protocols/Yahoo/src/avatar.cpp
@@ -133,7 +133,7 @@ void CYahooProto::SendAvatar(const TCHAR *szFile)
sf->filesize = statbuf.st_size;
wchar_t tszFilename[MAX_PATH];
- wcscpy(tszFilename, szFile);
+ wcsncpy(tszFilename, szFile, SIZEOF(szFile)-1);
GetShortPathNameW(szFile, tszFilename, SIZEOF(tszFilename));
char szFilename[MAX_PATH];
WideCharToMultiByte(CP_ACP, 0, tszFilename, -1, szFilename, MAX_PATH, 0, 0);
@@ -152,7 +152,6 @@ struct avatar_info{
void __cdecl CYahooProto::recv_avatarthread(void *pavt)
{
- PROTO_AVATAR_INFORMATIONT AI;
struct avatar_info *avt = ( avatar_info* )pavt;
int error = 0;
TCHAR buf[4096];
@@ -203,13 +202,11 @@ void __cdecl CYahooProto::recv_avatarthread(void *pavt)
LOG(("No data??? Got %d bytes.", nlhrReply->dataLength));
error = 1;
} else {
- HANDLE myhFile;
-
GetAvatarFileName(hContact, buf, 1024, getByte(hContact, "AvatarType", 0));
DeleteFile(buf);
LOG(("Saving file: %s size: %u", buf, nlhrReply->dataLength));
- myhFile = CreateFile(buf,
+ HANDLE myhFile = CreateFile(buf,
GENERIC_WRITE,
FILE_SHARE_WRITE,
NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
@@ -244,11 +241,12 @@ void __cdecl CYahooProto::recv_avatarthread(void *pavt)
free(avt->who);
free(avt->pic_url);
free(avt);
-
+
+ PROTO_AVATAR_INFORMATIONT AI;
AI.cbSize = sizeof AI;
AI.format = PA_FORMAT_PNG;
AI.hContact = hContact;
- _tcsncpy(AI.filename, buf, SIZEOF(AI.filename));
+ _tcsncpy(AI.filename, buf, SIZEOF(AI.filename)-1);
if (error)
setDword(hContact, "PictCK", 0);
@@ -450,11 +448,9 @@ void CYahooProto::ext_got_picture(const char *me, const char *who, const char *p
void CYahooProto::ext_got_picture_checksum(const char *me, const char *who, int cksum)
{
- MCONTACT hContact = 0;
-
LOG(("ext_yahoo_got_picture_checksum for %s checksum: %d", who, cksum));
- hContact = getbuddyH(who);
+ MCONTACT hContact = getbuddyH(who);
if (hContact == NULL) {
LOG(("Buddy Not Found. Skipping avatar update"));
return;
@@ -472,7 +468,7 @@ void CYahooProto::ext_got_picture_checksum(const char *me, const char *who, int
// Need to delete the Avatar File!!
TCHAR szFile[MAX_PATH];
- GetAvatarFileName(hContact, szFile, sizeof szFile, 0);
+ GetAvatarFileName(hContact, szFile, SIZEOF(szFile)-1, 0);
DeleteFile(szFile);
// Reset the avatar and cleanup.
@@ -488,11 +484,9 @@ void CYahooProto::ext_got_picture_checksum(const char *me, const char *who, int
void CYahooProto::ext_got_picture_update(const char *me, const char *who, int buddy_icon)
{
- MCONTACT hContact = 0;
-
LOG(("ext_got_picture_update for %s buddy_icon: %d", who, buddy_icon));
- hContact = getbuddyH(who);
+ MCONTACT hContact = getbuddyH(who);
if (hContact == NULL) {
LOG(("Buddy Not Found. Skipping avatar update"));
return;
@@ -806,12 +800,7 @@ INT_PTR __cdecl CYahooProto::SetMyAvatar(WPARAM wParam, LPARAM lParam)
DeleteFile(tszMyFile);
} else {
- DWORD dwPngSize, dw;
- BYTE* pResult;
- unsigned int hash;
- HANDLE hFile;
-
- hFile = CreateFile(tszFile,
+ HANDLE hFile = CreateFile(tszFile,
GENERIC_READ,
FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL,
@@ -822,10 +811,14 @@ INT_PTR __cdecl CYahooProto::SetMyAvatar(WPARAM wParam, LPARAM lParam)
if ( hFile == INVALID_HANDLE_VALUE )
return 1;
- dwPngSize = GetFileSize( hFile, NULL);
- if (( pResult = ( BYTE* )malloc( dwPngSize )) == NULL)
+ DWORD dwPngSize = GetFileSize( hFile, NULL);
+ BYTE *pResult = ( BYTE* )malloc(dwPngSize);
+ if (pResult == NULL) {
+ CloseHandle(hFile);
return 2;
+ }
+ DWORD dw;
ReadFile( hFile, pResult, dwPngSize, &dw, NULL);
CloseHandle( hFile );
@@ -842,7 +835,7 @@ INT_PTR __cdecl CYahooProto::SetMyAvatar(WPARAM wParam, LPARAM lParam)
SetEndOfFile( hFile);
CloseHandle( hFile );
- hash = YAHOO_avt_hash(( const char* )pResult, dwPngSize);
+ unsigned int hash = YAHOO_avt_hash(( const char* )pResult, dwPngSize);
free( pResult );
if ( hash ) {
diff --git a/protocols/Yahoo/src/chat.cpp b/protocols/Yahoo/src/chat.cpp
index c35b1d0432..b99cd41887 100644
--- a/protocols/Yahoo/src/chat.cpp
+++ b/protocols/Yahoo/src/chat.cpp
@@ -106,6 +106,7 @@ void ext_yahoo_conf_userjoin(int id, const char *me, const char *who, const char
if (!ppro) return;
CYahooProto::ChatRoom *cm = ppro->m_chatrooms.find((CYahooProto::ChatRoom*)&room);
+ if (!cm) return;
for (YList *l = cm->members; l; l = l->next)
{
if (!strcmp(who, (char*)l->data))
diff --git a/protocols/Yahoo/src/proto.cpp b/protocols/Yahoo/src/proto.cpp
index cac60ea904..af005ccd85 100644
--- a/protocols/Yahoo/src/proto.cpp
+++ b/protocols/Yahoo/src/proto.cpp
@@ -367,9 +367,7 @@ int __cdecl CYahooProto::SetStatus(int iNewStatus)
LOG(("[SetStatus] New status %S", pcli->pfnGetStatusModeDescription(iNewStatus, 0)));
if (iNewStatus == ID_STATUS_OFFLINE) {
-
logout();
-
}
else if (!m_bLoggedIn) {
DBVARIANT dbv;
@@ -423,9 +421,6 @@ int __cdecl CYahooProto::SetStatus(int iNewStatus)
return 0;
}
- if (iNewStatus == ID_STATUS_OFFLINE)
- iNewStatus = ID_STATUS_ONLINE;
-
FREE(m_pw_token); // No Token yet.
if (!getString(YAHOO_PWTOKEN, &dbv)) {
diff --git a/protocols/Yahoo/src/webcam.cpp b/protocols/Yahoo/src/webcam.cpp
index ce8759ba67..62973c5b58 100644
--- a/protocols/Yahoo/src/webcam.cpp
+++ b/protocols/Yahoo/src/webcam.cpp
@@ -1,5 +1,5 @@
/*
- * $Id: webcam.cpp 9228 2009-03-26 13:47:12Z ghazan $
+ * $Id: webcam.cpp 9228 2009-03-26 13:47:12Z ghazan $
*
* myYahoo Miranda Plugin
*
diff --git a/protocols/Yahoo/src/yahoo.cpp b/protocols/Yahoo/src/yahoo.cpp
index c26ff0573a..9ffbc0ac99 100644
--- a/protocols/Yahoo/src/yahoo.cpp
+++ b/protocols/Yahoo/src/yahoo.cpp
@@ -68,9 +68,7 @@ extern int poll_loop;
char * yahoo_status_code(enum yahoo_status s)
{
- int i;
-
- for(i=0; yahoo_status_codes[i].label; i++)
+ for(int i=0; yahoo_status_codes[i].label; i++)
if (yahoo_status_codes[i].id == s)
return yahoo_status_codes[i].label;
@@ -79,86 +77,58 @@ char * yahoo_status_code(enum yahoo_status s)
yahoo_status miranda_to_yahoo(int myyahooStatus)
{
- yahoo_status ret = YAHOO_STATUS_AVAILABLE;
-
switch (myyahooStatus) {
case ID_STATUS_OFFLINE:
- ret = YAHOO_STATUS_OFFLINE;
- break;
-
+ return YAHOO_STATUS_OFFLINE;
case ID_STATUS_FREECHAT:
case ID_STATUS_ONLINE:
- ret = YAHOO_STATUS_AVAILABLE;
- break;
-
+ return YAHOO_STATUS_AVAILABLE;
case ID_STATUS_AWAY:
- ret = YAHOO_STATUS_STEPPEDOUT;
- break;
-
+ return YAHOO_STATUS_STEPPEDOUT;
case ID_STATUS_NA:
- ret = YAHOO_STATUS_BRB;
- break;
-
+ return YAHOO_STATUS_BRB;
case ID_STATUS_OCCUPIED:
- ret = YAHOO_STATUS_BUSY;
- break;
-
+ return YAHOO_STATUS_BUSY;
case ID_STATUS_DND:
- ret = YAHOO_STATUS_BUSY;
- break;
-
+ return YAHOO_STATUS_BUSY;
case ID_STATUS_ONTHEPHONE:
- ret = YAHOO_STATUS_ONPHONE;
- break;
-
+ return YAHOO_STATUS_ONPHONE;
case ID_STATUS_OUTTOLUNCH:
- ret = YAHOO_STATUS_OUTTOLUNCH;
- break;
-
+ return YAHOO_STATUS_OUTTOLUNCH;
case ID_STATUS_INVISIBLE:
- ret = YAHOO_STATUS_INVISIBLE;
- break;
- }
-
- return ret;
+ return YAHOO_STATUS_INVISIBLE;
+ default:
+ return YAHOO_STATUS_AVAILABLE;
+ }
}
int yahoo_to_miranda_status(int m_iStatus, int away)
{
- int ret = ID_STATUS_OFFLINE;
-
switch (m_iStatus) {
case YAHOO_STATUS_AVAILABLE:
- ret = ID_STATUS_ONLINE;
- break;
+ return ID_STATUS_ONLINE;
case YAHOO_STATUS_BRB:
- ret = ID_STATUS_NA;
- break;
+ return ID_STATUS_NA;
case YAHOO_STATUS_BUSY:
- ret = ID_STATUS_OCCUPIED;
- break;
+ return ID_STATUS_OCCUPIED;
case YAHOO_STATUS_ONPHONE:
- ret = ID_STATUS_ONTHEPHONE;
- break;
+ return ID_STATUS_ONTHEPHONE;
case YAHOO_STATUS_OUTTOLUNCH:
- ret = ID_STATUS_OUTTOLUNCH;
- break;
+ return ID_STATUS_OUTTOLUNCH;
case YAHOO_STATUS_INVISIBLE:
- ret = ID_STATUS_INVISIBLE;
- break;
+ return ID_STATUS_INVISIBLE;
case YAHOO_STATUS_NOTATHOME:
case YAHOO_STATUS_NOTATDESK:
case YAHOO_STATUS_NOTINOFFICE:
case YAHOO_STATUS_ONVACATION:
case YAHOO_STATUS_STEPPEDOUT:
case YAHOO_STATUS_IDLE:
- ret = ID_STATUS_AWAY;
- break;
+ return ID_STATUS_AWAY;
case YAHOO_STATUS_CUSTOM:
- ret = (away ? ID_STATUS_AWAY:ID_STATUS_ONLINE);
- break;
+ return (away ? ID_STATUS_AWAY:ID_STATUS_ONLINE);
+ default:
+ return ID_STATUS_OFFLINE;
}
- return ret;
}
void CYahooProto::set_status(int myyahooStatus, char *msg, int away)
@@ -340,15 +310,14 @@ MCONTACT CYahooProto::add_buddy(const char *yahoo_id, const char *yahoo_name, in
const char* CYahooProto::find_buddy( const char *yahoo_id)
{
static char nick[128];
- MCONTACT hContact;
DBVARIANT dbv;
- hContact = getbuddyH(yahoo_id);
+ MCONTACT hContact = getbuddyH(yahoo_id);
if (hContact != NULL) {
if (GetStringUtf(hContact, "Nick", &dbv))
return NULL;
- strncpy(nick, dbv.pszVal, 128);
+ strncpy(nick, dbv.pszVal, sizeof(nick)-1);
db_free(&dbv);
return nick;
}
@@ -961,7 +930,7 @@ void CYahooProto::ext_game_notify(const char *me, const char *who, int stat, con
mir_strcat(z, "\r\n\r\nhttp://games.yahoo.com/games/");
mir_strcat(z, u);
c = strchr(z, 0x09);
- (*c) = '\0';
+ if (c) (*c) = '\0';
}
SetStringUtf(hContact, "YGMsg", z);
@@ -1129,7 +1098,7 @@ void CYahooProto::ext_login_response(int succ, const char *url)
ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_WRONGPASSWORD);
}
else if (succ == YAHOO_LOGIN_LOCK) {
- mir_sntprintf(buff, SIZEOF(buff), TranslateT("Could not log into Yahoo service. Your account has been locked.\nVisit %s to reactivate it."), url);
+ mir_sntprintf(buff, SIZEOF(buff), TranslateT("Could not log into Yahoo service. Your account has been locked.\nVisit %s to reactivate it."), _A2T(url));
}
else if (succ == YAHOO_LOGIN_DUPL) {
mir_sntprintf(buff, SIZEOF(buff), TranslateT("You have been logged out of the Yahoo service, possibly due to a duplicate login."));