From 7dc3df386f9b0fadc115ff55eefb8fbeb1c3077a Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 5 Jan 2013 15:07:22 +0000 Subject: - fix for Unicode popups; - code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@2980 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Yahoo/src/avatar.cpp | 86 ++++++------- protocols/Yahoo/src/file_transfer.cpp | 26 ++-- protocols/Yahoo/src/http_gateway.cpp | 4 +- protocols/Yahoo/src/im.cpp | 14 +- protocols/Yahoo/src/libyahoo2/libyahoo2.c | 6 +- protocols/Yahoo/src/libyahoo2/yahoo_debug.h | 18 +-- protocols/Yahoo/src/libyahoo2/yahoo_httplib.c | 26 ++-- protocols/Yahoo/src/libyahoo2/yahoo_list.c | 2 +- protocols/Yahoo/src/libyahoo2/yahoo_util.c | 14 +- protocols/Yahoo/src/libyahoo2/yahoo_util.h | 4 +- protocols/Yahoo/src/main.cpp | 6 +- protocols/Yahoo/src/options.cpp | 48 +++---- protocols/Yahoo/src/proto.cpp | 46 +++---- protocols/Yahoo/src/proto.h | 8 +- protocols/Yahoo/src/search.cpp | 2 +- protocols/Yahoo/src/server.cpp | 18 +-- protocols/Yahoo/src/services.cpp | 78 +++++------ protocols/Yahoo/src/user_info.cpp | 6 +- protocols/Yahoo/src/util.cpp | 151 ++++++++++------------ protocols/Yahoo/src/yahoo.cpp | 178 ++++++++++++++------------ protocols/Yahoo/src/yahoo.h | 4 +- 21 files changed, 369 insertions(+), 376 deletions(-) diff --git a/protocols/Yahoo/src/avatar.cpp b/protocols/Yahoo/src/avatar.cpp index c35707203d..20429bcf66 100644 --- a/protocols/Yahoo/src/avatar.cpp +++ b/protocols/Yahoo/src/avatar.cpp @@ -193,7 +193,7 @@ void __cdecl CYahooProto::recv_avatarthread(void *pavt) nlhrReply=(NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION,(WPARAM)m_hNetlibUser,(LPARAM)&nlhr); - if(nlhrReply) { + if (nlhrReply) { if (nlhrReply->resultCode != 200) { LOG(("Update server returned '%d' instead of 200. It also sent the following: %s", nlhrReply->resultCode, nlhrReply->szResultDescr)); @@ -206,7 +206,7 @@ void __cdecl CYahooProto::recv_avatarthread(void *pavt) } else { HANDLE myhFile; - GetAvatarFileName(hContact, buf, 1024, DBGetContactSettingByte(hContact, m_szModuleName,"AvatarType", 0)); + GetAvatarFileName(hContact, buf, 1024, db_get_b(hContact, m_szModuleName,"AvatarType", 0)); DeleteFile(buf); LOG(("Saving file: %s size: %u", buf, nlhrReply->dataLength)); @@ -215,10 +215,10 @@ void __cdecl CYahooProto::recv_avatarthread(void *pavt) FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); - if(myhFile !=INVALID_HANDLE_VALUE) { + if (myhFile !=INVALID_HANDLE_VALUE) { DWORD c; - WriteFile(myhFile, nlhrReply->pData, nlhrReply->dataLength, &c, NULL ); + WriteFile(myhFile, nlhrReply->pData, nlhrReply->dataLength, &c, NULL); CloseHandle(myhFile); SetDword(hContact, "PictLastCheck", 0); @@ -277,7 +277,7 @@ void CYahooProto::ext_got_picture(const char *me, const char *who, const char *p DBVARIANT dbv; /* need to send avatar info */ - if (!GetByte( "ShowAvatars", 1 )) { + 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; @@ -304,10 +304,10 @@ void CYahooProto::ext_got_picture(const char *me, const char *who, const char *p if (!DBGetContactSettingTString(NULL, m_szModuleName, "AvatarFile", &dbv)) { struct _stat statbuf; - if (_tstat( dbv.ptszVal, &statbuf ) != 0 ) { + if (_tstat( dbv.ptszVal, &statbuf ) != 0) { LOG(("[ext_yahoo_got_picture] Avatar File Missing? Can't find file: %s", dbv.ptszVal)); } else { - DBWriteContactSettingString(NULL, m_szModuleName, "AvatarInv", who); + db_set_s(NULL, m_szModuleName, "AvatarInv", who); SendAvatar(dbv.ptszVal); } @@ -323,7 +323,7 @@ void CYahooProto::ext_got_picture(const char *me, const char *who, const char *p case 2: /* * We got Avatar Info for our buddy. */ - if (!GetByte( "ShowAvatars", 1 )) { + if (!GetByte("ShowAvatars", 1 )) { LOG(("[ext_yahoo_got_picture] We are not using/showing avatars!")); return; } @@ -344,7 +344,7 @@ 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.")); - DBWriteContactSettingDword(hContact, m_szModuleName, "PictCK", 0); + db_set_dw(hContact, m_szModuleName, "PictCK", 0); reset_avatar(hContact); } else { @@ -354,11 +354,11 @@ void CYahooProto::ext_got_picture(const char *me, const char *who, const char *p } TCHAR z[1024]; - GetAvatarFileName(hContact, z, 1024, DBGetContactSettingByte(hContact, m_szModuleName,"AvatarType", 0)); + GetAvatarFileName(hContact, z, 1024, db_get_b(hContact, m_szModuleName,"AvatarType", 0)); - if (DBGetContactSettingDword(hContact, m_szModuleName,"PictCK", 0) != cksum || _taccess( z, 0 ) != 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)DBGetContactSettingDword(hContact, m_szModuleName,"PictCK", 0), cksum); + 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)); avt->who = strdup(who); @@ -380,7 +380,7 @@ void CYahooProto::ext_got_picture(const char *me, const char *who, const char *p DBVARIANT dbv; /* need to send avatar info */ - if (!GetByte( "ShowAvatars", 1 )) { + 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; @@ -424,7 +424,7 @@ void CYahooProto::ext_got_picture(const char *me, const char *who, const char *p DBDeleteContactSetting(NULL, m_szModuleName, "AvatarURL"); if (!DBGetContactSettingTString(NULL, m_szModuleName, "AvatarFile", &dbv2)) { - DBWriteContactSettingString(NULL, m_szModuleName, "AvatarInv", who); + db_set_s(NULL, m_szModuleName, "AvatarInv", who); SendAvatar(dbv2.ptszVal); DBFreeVariant(&dbv2); } else { @@ -462,14 +462,14 @@ void CYahooProto::ext_got_picture_checksum(const char *me, const char *who, int /* Last thing check the checksum and request new one if we need to */ if (!cksum || cksum == -1) { - DBWriteContactSettingDword(hContact, m_szModuleName, "PictCK", 0); + db_set_dw(hContact, m_szModuleName, "PictCK", 0); reset_avatar(hContact); } else { - if (DBGetContactSettingDword(hContact, m_szModuleName,"PictCK", 0) != cksum) { + if (db_get_dw(hContact, m_szModuleName,"PictCK", 0) != cksum) { // Now save the new checksum. No rush requesting new avatar yet. - DBWriteContactSettingDword(hContact, m_szModuleName, "PictCK", cksum); + db_set_dw(hContact, m_szModuleName, "PictCK", cksum); // Need to delete the Avatar File!! TCHAR szFile[MAX_PATH]; @@ -481,7 +481,7 @@ void CYahooProto::ext_got_picture_checksum(const char *me, const char *who, int // Request new avatar here... (might also want to check the sharing status?) - if (GetByte( "ShareAvatar", 0 ) == 2) + if (GetByte("ShareAvatar", 0) == 2) request_avatar(who); } } @@ -499,7 +499,7 @@ void CYahooProto::ext_got_picture_update(const char *me, const char *who, int bu return; } - DBWriteContactSettingByte(hContact, m_szModuleName, "AvatarType", buddy_icon); + db_set_b(hContact, m_szModuleName, "AvatarType", buddy_icon); /* Last thing check the checksum and request new one if we need to */ reset_avatar(hContact); @@ -517,7 +517,7 @@ void CYahooProto::ext_got_picture_status(const char *me, const char *who, int bu return; } - DBWriteContactSettingByte(hContact, m_szModuleName, "AvatarType", buddy_icon); + db_set_b(hContact, m_szModuleName, "AvatarType", buddy_icon); /* Last thing check the checksum and request new one if we need to */ reset_avatar(hContact); @@ -570,7 +570,7 @@ void CYahooProto::ext_got_avatar_share(int buddy_icon) { LOG(("[ext_yahoo_got_avatar_share] buddy icon: %d", buddy_icon)); - SetByte( "ShareAvatar", buddy_icon ); + SetByte("ShareAvatar", buddy_icon ); } void CYahooProto::reset_avatar(HANDLE hContact) @@ -586,7 +586,7 @@ void CYahooProto::request_avatar(const char* who) HANDLE hContact = 0; //char szFile[MAX_PATH]; - if (!GetByte( "ShowAvatars", 1 )) { + if (!GetByte("ShowAvatars", 1 )) { LOG(("Avatars disabled, but available for: %s", who)); return; } @@ -596,19 +596,19 @@ void CYahooProto::request_avatar(const char* who) if (!hContact) return; - /*GetAvatarFileName(hContact, szFile, sizeof szFile, DBGetContactSettingByte(hContact, m_szModuleName,"AvatarType", 0)); + /*GetAvatarFileName(hContact, szFile, sizeof szFile, db_get_b(hContact, m_szModuleName,"AvatarType", 0)); DeleteFile(szFile);*/ time(&cur_time); - last_chk = DBGetContactSettingDword(hContact, m_szModuleName, "PictLastCheck", 0); + last_chk = db_get_dw(hContact, m_szModuleName, "PictLastCheck", 0); /* * time() - in seconds ( 60*60 = 1 hour) */ - if (DBGetContactSettingDword(hContact, m_szModuleName,"PictCK", 0) == 0 || + if (db_get_dw(hContact, m_szModuleName,"PictCK", 0) == 0 || last_chk == 0 || (cur_time - last_chk) > 60) { - DBWriteContactSettingDword(hContact, m_szModuleName, "PictLastCheck", (DWORD)cur_time); + db_set_dw(hContact, m_szModuleName, "PictLastCheck", (DWORD)cur_time); LOG(("Requesting Avatar for: %s", who)); yahoo_request_buddy_avatar(m_id, who); @@ -651,7 +651,7 @@ void CYahooProto::GetAvatarFileName(HANDLE hContact, TCHAR* pszDest, int cbLen, CallService(MS_UTILS_CREATEDIRTREET, 0, (LPARAM)pszDest); if (hContact != NULL) { - int ck_sum = DBGetContactSettingDword(hContact, m_szModuleName,"PictCK", 0); + 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); @@ -673,13 +673,13 @@ INT_PTR __cdecl CYahooProto::GetAvatarInfo(WPARAM wParam,LPARAM lParam) DebugLog("[YAHOO_GETAVATARINFO]"); } - if (!GetByte( "ShowAvatars", 1 ) || !m_bLoggedIn) { + if (!GetByte("ShowAvatars", 1 ) || !m_bLoggedIn) { DebugLog("[YAHOO_GETAVATARINFO] %s", m_bLoggedIn ? "We are not using/showing avatars!" : "We are not logged in. Can't load avatars now!"); return GAIR_NOAVATAR; } - avtType = DBGetContactSettingByte(AI->hContact, m_szModuleName,"AvatarType", 0); + avtType = db_get_b(AI->hContact, m_szModuleName,"AvatarType", 0); DebugLog("[YAHOO_GETAVATARINFO] Avatar Type: %d", avtType); if ( avtType != 2) { @@ -689,17 +689,17 @@ INT_PTR __cdecl CYahooProto::GetAvatarInfo(WPARAM wParam,LPARAM lParam) return GAIR_NOAVATAR; } - if (DBGetContactSettingDword(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), DBGetContactSettingByte(AI->hContact, m_szModuleName,"AvatarType", 0)); + 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)) { @@ -755,7 +755,7 @@ INT_PTR __cdecl CYahooProto::GetAvatarCaps(WPARAM wParam, LPARAM lParam) case AF_ENABLED: LOG(("[YahooGetAvatarCaps] AF_ENABLED")); - res = (GetByte( "ShowAvatars", 1 )) ? 1 : 0; + res = (GetByte("ShowAvatars", 1 )) ? 1 : 0; break; case AF_DONTNEEDDELAYS: @@ -793,7 +793,7 @@ INT_PTR __cdecl CYahooProto::GetMyAvatar(WPARAM wParam, LPARAM lParam) if (buffer == NULL || size <= 0) return -1; - if (!GetByte( "ShowAvatars", 1 )) + if (!GetByte("ShowAvatars", 1 )) return -2; DBVARIANT dbv; @@ -855,16 +855,16 @@ INT_PTR __cdecl CYahooProto::SetMyAvatar(WPARAM wParam, LPARAM lParam) NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, - 0 ); + 0); if ( hFile == INVALID_HANDLE_VALUE ) return 1; - dwPngSize = GetFileSize( hFile, NULL ); - if (( pResult = ( BYTE* )malloc( dwPngSize )) == NULL ) + dwPngSize = GetFileSize( hFile, NULL); + if (( pResult = ( BYTE* )malloc( dwPngSize )) == NULL) return 2; - ReadFile( hFile, pResult, dwPngSize, &dw, NULL ); + ReadFile( hFile, pResult, dwPngSize, &dw, NULL); CloseHandle( hFile ); hFile = CreateFile(tszMyFile, @@ -876,7 +876,7 @@ INT_PTR __cdecl CYahooProto::SetMyAvatar(WPARAM wParam, LPARAM lParam) if ( hFile == INVALID_HANDLE_VALUE ) return 1; - WriteFile( hFile, pResult, dwPngSize, &dw, NULL ); + WriteFile( hFile, pResult, dwPngSize, &dw, NULL); SetEndOfFile( hFile); CloseHandle( hFile ); @@ -889,11 +889,11 @@ INT_PTR __cdecl CYahooProto::SetMyAvatar(WPARAM wParam, LPARAM lParam) /* now check and make sure we don't reupload same thing over again */ if (hash != GetDword("AvatarHash", 0)) { SetStringT(NULL, "AvatarFile", tszMyFile); - DBWriteContactSettingDword(NULL, m_szModuleName, "TMPAvatarHash", hash); + db_set_dw(NULL, m_szModuleName, "TMPAvatarHash", hash); /* Set Sharing to ON if it's OFF */ - if (GetByte( "ShareAvatar", 0 ) != 2) { - SetByte( "ShareAvatar", 2 ); + if (GetByte("ShareAvatar", 0) != 2) { + SetByte("ShareAvatar", 2 ); yahoo_send_picture_status(m_id, 2); } diff --git a/protocols/Yahoo/src/file_transfer.cpp b/protocols/Yahoo/src/file_transfer.cpp index 0cc2f4ba8c..55a9db1c26 100644 --- a/protocols/Yahoo/src/file_transfer.cpp +++ b/protocols/Yahoo/src/file_transfer.cpp @@ -44,12 +44,12 @@ static y_filetransfer* new_ft(CYahooProto* ppro, int id, HANDLE hContact, const ft->cancel = 0; ft->y7 = y7; - ft->hWaitEvent = CreateEvent( NULL, FALSE, FALSE, NULL ); + ft->hWaitEvent = CreateEvent( NULL, FALSE, FALSE, NULL); ft->pfts.cbSize = sizeof(PROTOFILETRANSFERSTATUS); ft->pfts.hContact = hContact; ft->pfts.flags = PFTS_TCHAR; - ft->pfts.flags |= (sending != 0 ) ? PFTS_SENDING : PFTS_RECEIVING; + ft->pfts.flags |= (sending != 0) ? PFTS_SENDING : PFTS_RECEIVING; ft->pfts.tszWorkingDir = NULL; ft->pfts.currentFileTime = 0; @@ -171,7 +171,7 @@ static void upload_file(int id, int fd, int error, void *data) FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, 0); - if(myhFile !=INVALID_HANDLE_VALUE) { + if (myhFile !=INVALID_HANDLE_VALUE) { DWORD lNotify = GetTickCount(); LOG(("proto: %s, hContact: %p", sf->ppro->m_szModuleName, sf->hContact)); @@ -196,7 +196,7 @@ static void upload_file(int id, int fd, int error, void *data) } else size += rw; - if(GetTickCount() >= lNotify + 500 || rw < 1024 || size == fi->filesize) { + if (GetTickCount() >= lNotify + 500 || rw < 1024 || size == fi->filesize) { LOG(("DOING UI Notify. Got %lu/%lu", size, fi->filesize)); sf->pfts.totalProgress = size; sf->pfts.currentFileProgress = size; @@ -319,7 +319,7 @@ static void dl_file(int id, int fd, int error, const char *filename, unsigned lo ResetEvent(sf->hWaitEvent); - if ( sf->ppro->SendBroadcast( sf->hContact, ACKTYPE_FILE, ACKRESULT_FILERESUME, sf, ( LPARAM )&sf->pfts )) { + if ( sf->ppro->SendBroadcast( sf->hContact, ACKTYPE_FILE, ACKRESULT_FILERESUME, sf, (LPARAM)&sf->pfts )) { WaitForSingleObject( sf->hWaitEvent, INFINITE ); LOG(("[dl_file] Got action: %ld", sf->action)); @@ -351,7 +351,7 @@ static void dl_file(int id, int fd, int error, const char *filename, unsigned lo FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); - if(myhFile !=INVALID_HANDLE_VALUE) { + if (myhFile !=INVALID_HANDLE_VALUE) { DWORD lNotify = GetTickCount(); SetEndOfFile(myhFile); @@ -369,7 +369,7 @@ static void dl_file(int id, int fd, int error, const char *filename, unsigned lo sf->pfts.totalProgress += dw; sf->pfts.currentFileProgress += dw; - if(GetTickCount() >= lNotify + 500 || dw <= 0 || rsize == size) { + if (GetTickCount() >= lNotify + 500 || dw <= 0 || rsize == size) { LOG(("DOING UI Notify. Got %lu/%lu", rsize, size)); @@ -624,7 +624,7 @@ void ext_yahoo_send_file7info(int id, const char *me, const char *who, const cha fi = (yahoo_file_info *) ft->files->data; c = strrchr(fi->filename, '\\'); - if (c != NULL ) { + if (c != NULL) { c++; } else { c = fi->filename; @@ -637,7 +637,7 @@ void ext_yahoo_send_file7info(int id, const char *me, const char *who, const cha ft->relay = strdup( inet_ntoa(*( PIN_ADDR )he->h_addr_list[0])); LOG(("Got Relay IP: %s", ft->relay)); } else { - ft->relay = strdup( "98.136.112.33" ); + ft->relay = strdup("98.136.112.33"); LOG(("DNS Lookup failed. Using Relay IP: %s", ft->relay)); } @@ -715,7 +715,7 @@ HANDLE __cdecl CYahooProto::SendFile( HANDLE hContact, const PROTOCHAR* szDescri /*DebugLog("Getting Files"); - if ( ppszFiles[1] != NULL ) { + if ( ppszFiles[1] != NULL) { MessageBoxA(NULL, "YAHOO protocol allows only one file to be sent at a time", "Yahoo", MB_OK | MB_ICONINFORMATION); return 0; } @@ -732,7 +732,7 @@ HANDLE __cdecl CYahooProto::SendFile( HANDLE hContact, const PROTOCHAR* szDescri char *s; while (ppszFiles[i] != NULL) { - if ( _tstat( ppszFiles[i], &statbuf ) == 0 ) + if ( _tstat( ppszFiles[i], &statbuf ) == 0) tFileSize = statbuf.st_size; fi = y_new(struct yahoo_file_info,1); @@ -837,7 +837,7 @@ int __cdecl CYahooProto::FileDeny( HANDLE /*hContact*/, HANDLE hTransfer, const DebugLog("[YahooFileDeny]"); - if ( !m_bLoggedIn || ft == NULL ) { + if ( !m_bLoggedIn || ft == NULL) { DebugLog("[YahooFileDeny] Not logged-in or some other error!"); return 1; } @@ -867,7 +867,7 @@ int __cdecl CYahooProto::FileResume( HANDLE hTransfer, int* action, const PROTOC DebugLog("[YahooFileResume] Action: %d", *action); - if ( !m_bLoggedIn || ft == NULL ) { + if ( !m_bLoggedIn || ft == NULL) { DebugLog("[YahooFileResume] Not loggedin or some other error!"); return 1; } diff --git a/protocols/Yahoo/src/http_gateway.cpp b/protocols/Yahoo/src/http_gateway.cpp index e62219f108..188d0a36ad 100644 --- a/protocols/Yahoo/src/http_gateway.cpp +++ b/protocols/Yahoo/src/http_gateway.cpp @@ -42,7 +42,7 @@ int YAHOO_httpGatewayWrapSend(HANDLE hConn, PBYTE buf, int len, int flags, MIRAN if (z != NULL) { DebugLog("YAHOO_httpGatewayWrapSend!!! Got Len: %d", n); NETLIBBUFFER tBuf = { ( char* )z, n, flags }; - ret = pfnNetlibSend(( LPARAM )hConn, (WPARAM) &tBuf ); + ret = pfnNetlibSend((LPARAM)hConn, (WPARAM) &tBuf ); FREE(z); } else { DebugLog("YAHOO_httpGatewayWrapSend!!! GOT NULL???"); @@ -52,7 +52,7 @@ int YAHOO_httpGatewayWrapSend(HANDLE hConn, PBYTE buf, int len, int flags, MIRAN } else { NETLIBBUFFER tBuf = { ( char* )buf, len, flags }; - return pfnNetlibSend(( LPARAM )hConn, (WPARAM) &tBuf ); + return pfnNetlibSend((LPARAM)hConn, (WPARAM) &tBuf ); } } diff --git a/protocols/Yahoo/src/im.cpp b/protocols/Yahoo/src/im.cpp index 7b8b8b1ea1..52d21112ae 100644 --- a/protocols/Yahoo/src/im.cpp +++ b/protocols/Yahoo/src/im.cpp @@ -35,17 +35,17 @@ void CYahooProto::ext_got_im(const char *me, const char *who, int protocol, cons const char *c = msg; int oidx = 0; PROTORECVEVENT pre; - HANDLE hContact; + HANDLE hContact = NULL; LOG(("YAHOO_GOT_IM id:%s %s: %s (len: %d) tm:%lu stat:%i utf8:%i buddy_icon: %i", me, who, msg, lstrlenA(msg), tm, stat, utf8, buddy_icon)); - if(stat == 2) { + if (stat == 2) { char z[1024]; snprintf(z, sizeof z, "Error sending message to %s", who); LOG((z)); - ShowError(Translate("Yahoo Error"), z); + ShowError( TranslateT("Yahoo Error"), _A2T(z)); return; } @@ -54,7 +54,7 @@ void CYahooProto::ext_got_im(const char *me, const char *who, int protocol, cons return; } - if (GetByte( "IgnoreUnknown", 0 )) { + if (GetByte("IgnoreUnknown", 0)) { /* * Check our buddy list to see if we have it there. And if it's not on the list then we don't accept any IMs. @@ -145,10 +145,10 @@ void CYahooProto::ext_got_im(const char *me, const char *who, int protocol, cons if (buddy_icon < 0) return; //?? Don't generate floods!! - DBWriteContactSettingByte(hContact, m_szModuleName, "AvatarType", (BYTE)buddy_icon); + db_set_b(hContact, m_szModuleName, "AvatarType", (BYTE)buddy_icon); if (buddy_icon != 2) { reset_avatar(hContact); - } else if (DBGetContactSettingDword(hContact, m_szModuleName,"PictCK", 0) == 0) { + } else if (db_get_dw(hContact, m_szModuleName,"PictCK", 0) == 0) { /* request the buddy image */ request_avatar(who); } @@ -182,7 +182,7 @@ int __cdecl CYahooProto::SendMsg( HANDLE hContact, int flags, const char* pszSrc char *msg; int bANSI; - bANSI = 0;/*GetByte( "DisableUTF8", 0 );*/ + bANSI = 0;/*GetByte("DisableUTF8", 0);*/ if (!m_bLoggedIn) {/* don't send message if we not connected! */ YForkThread( &CYahooProto::im_sendackfail, hContact ); diff --git a/protocols/Yahoo/src/libyahoo2/libyahoo2.c b/protocols/Yahoo/src/libyahoo2/libyahoo2.c index f51475a5ca..3da50e7b67 100644 --- a/protocols/Yahoo/src/libyahoo2/libyahoo2.c +++ b/protocols/Yahoo/src/libyahoo2/libyahoo2.c @@ -1995,7 +1995,7 @@ static void yahoo_process_logon(struct yahoo_input_data *yid, struct yahoo_packe case 60: /* SMS -> 1 MOBILE USER */ /* sometimes going offline makes this 2, but invisible never sends it */ //NOTICE(("key %d:%s", pair->key, pair->value)); - if (atoi(pair->value) > 0 ) + if (atoi(pair->value) > 0) mobile = 1; break; @@ -2132,7 +2132,7 @@ static void yahoo_process_status(struct yahoo_input_data *yid, struct yahoo_pack case 60: /* SMS -> 1 MOBILE USER */ /* sometimes going offline makes this 2, but invisible never sends it */ NOTICE(("key %d:%s", pair->key, pair->value)); - if (atoi(pair->value) > 0 ) + if (atoi(pair->value) > 0) mobile = 1; break; case 16: /* Custom error message */ @@ -2421,7 +2421,7 @@ GET /config/pwtoken_login?src=ymsgr&ts=1195577376&token=token HTTP/1.1 **/ yss = yd->server_settings; - if (yd->pw_token == NULL ) { + if (yd->pw_token == NULL) { c = yahoo_urlencode(yd->password); diff --git a/protocols/Yahoo/src/libyahoo2/yahoo_debug.h b/protocols/Yahoo/src/libyahoo2/yahoo_debug.h index b9d048b53d..9a847c9051 100644 --- a/protocols/Yahoo/src/libyahoo2/yahoo_debug.h +++ b/protocols/Yahoo/src/libyahoo2/yahoo_debug.h @@ -26,33 +26,33 @@ #endif /* -#define NOTICE(x) if(yahoo_get_log_level() >= YAHOO_LOG_NOTICE) { yahoo_log_message x; yahoo_log_message("\n"); } +#define NOTICE(x) if (yahoo_get_log_level() >= YAHOO_LOG_NOTICE) { yahoo_log_message x; yahoo_log_message("\n"); } -#define LOG(x) if(yahoo_get_log_level() >= YAHOO_LOG_INFO) { yahoo_log_message("%s:%d: ", __FILE__, __LINE__); \ +#define LOG(x) if (yahoo_get_log_level() >= YAHOO_LOG_INFO) { yahoo_log_message("%s:%d: ", __FILE__, __LINE__); \ yahoo_log_message x; \ yahoo_log_message("\n"); } -#define WARNING(x) if(yahoo_get_log_level() >= YAHOO_LOG_WARNING) { yahoo_log_message("%s:%d: warning: ", __FILE__, __LINE__); \ +#define WARNING(x) if (yahoo_get_log_level() >= YAHOO_LOG_WARNING) { yahoo_log_message("%s:%d: warning: ", __FILE__, __LINE__); \ yahoo_log_message x; \ yahoo_log_message("\n"); } -#define DEBUG_MSG(x) if(yahoo_get_log_level() >= YAHOO_LOG_DEBUG) { yahoo_log_message("%s:%d: debug: ", __FILE__, __LINE__); \ +#define DEBUG_MSG(x) if (yahoo_get_log_level() >= YAHOO_LOG_DEBUG) { yahoo_log_message("%s:%d: debug: ", __FILE__, __LINE__); \ yahoo_log_message x; \ yahoo_log_message("\n"); } */ -#define NOTICE(x) if(yahoo_get_log_level() >= YAHOO_LOG_NOTICE) { yahoo_log_message x; yahoo_log_message(" "); } +#define NOTICE(x) if (yahoo_get_log_level() >= YAHOO_LOG_NOTICE) { yahoo_log_message x; yahoo_log_message(" "); } -#define LOG(x) if(yahoo_get_log_level() >= YAHOO_LOG_INFO) { yahoo_log_message("%s:%d: ", __FILE__, __LINE__); \ +#define LOG(x) if (yahoo_get_log_level() >= YAHOO_LOG_INFO) { yahoo_log_message("%s:%d: ", __FILE__, __LINE__); \ yahoo_log_message x; \ yahoo_log_message(" "); } -#define WARNING(x) if(yahoo_get_log_level() >= YAHOO_LOG_WARNING) { yahoo_log_message("%s:%d: warning: ", __FILE__, __LINE__); \ +#define WARNING(x) if (yahoo_get_log_level() >= YAHOO_LOG_WARNING) { yahoo_log_message("%s:%d: warning: ", __FILE__, __LINE__); \ yahoo_log_message x; \ yahoo_log_message(" "); } -#define DEBUG_MSG(x) if(yahoo_get_log_level() >= YAHOO_LOG_DEBUG) { yahoo_log_message("%s:%d: debug: ", __FILE__, __LINE__); \ +#define DEBUG_MSG(x) if (yahoo_get_log_level() >= YAHOO_LOG_DEBUG) { yahoo_log_message("%s:%d: debug: ", __FILE__, __LINE__); \ yahoo_log_message x; \ yahoo_log_message(" "); } -#define DEBUG_MSG1(x) if(yahoo_get_log_level() >= YAHOO_LOG_DEBUG) { \ +#define DEBUG_MSG1(x) if (yahoo_get_log_level() >= YAHOO_LOG_DEBUG) { \ yahoo_log_message x; } diff --git a/protocols/Yahoo/src/libyahoo2/yahoo_httplib.c b/protocols/Yahoo/src/libyahoo2/yahoo_httplib.c index 7305157d83..c3543917f1 100644 --- a/protocols/Yahoo/src/libyahoo2/yahoo_httplib.c +++ b/protocols/Yahoo/src/libyahoo2/yahoo_httplib.c @@ -79,7 +79,7 @@ int yahoo_tcp_readline(char *ptr, int maxlen, int fd) } while(rc == -1 && (errno == EINTR || errno == EAGAIN)); /* this is bad - it should be done asynchronously */ if (rc == 1) { - if(c == '\r') /* get rid of \r */ + if (c == '\r') /* get rid of \r */ continue; *ptr = c; if (c == '\n') @@ -116,7 +116,7 @@ int url_to_host_port_path(const char *url, char *host, int *port, char *path) * http://hostname:port/path:foo */ - if(strstr(url, "http://") == url) { + if (strstr(url, "http://") == url) { urlcopy = strdup(url+7); } else { WARNING(("Weird url - unknown protocol: %s", url)); @@ -193,7 +193,7 @@ char *yahoo_urldecode(const char *instr) while(instr[ipos]) { while(instr[ipos] && instr[ipos]!='%') - if(instr[ipos]=='+') { + if (instr[ipos]=='+') { str[bpos++]=' '; ipos++; } else @@ -201,7 +201,7 @@ char *yahoo_urldecode(const char *instr) if (!instr[ipos]) break; - if(instr[ipos+1] && instr[ipos+2]) { + if (instr[ipos+1] && instr[ipos+2]) { ipos++; entity[0]=instr[ipos++]; entity[1]=instr[ipos++]; @@ -240,7 +240,7 @@ char *yahoo_xmldecode(const char *instr) while(instr[ipos]) { while(instr[ipos] && instr[ipos]!='&') - if(instr[ipos]=='+') { + if (instr[ipos]=='+') { str[bpos++]=' '; ipos++; } else @@ -249,7 +249,7 @@ char *yahoo_xmldecode(const char *instr) break; ipos++; - if(instr[ipos] == '#') { + if (instr[ipos] == '#') { ipos++; epos=0; while(instr[ipos] != ';') @@ -290,7 +290,7 @@ static void connect_complete(int fd, int error, void *data) { struct callback_data *ccd = (struct callback_data *) data; - if(error == 0 && fd > 0) + if (error == 0 && fd > 0) write(fd, ccd->request, strlen(ccd->request)); FREE(ccd->request); @@ -386,7 +386,7 @@ static void yahoo_got_url_fd(int id, int fd, int error, void *data) struct url_data *ud = (struct url_data *) data; - if(error || fd < 0) { + if (error || fd < 0) { ud->callback(id, fd, error, filename, filesize, ud->user_data); FREE(ud); return; @@ -400,20 +400,20 @@ static void yahoo_got_url_fd(int id, int fd, int error, void *data) if ( !strncasecmp(buff, "Content-length:", strlen("Content-length:"))) { tmp = strrchr(buff, ' '); - if(tmp) + if (tmp) filesize = atol(tmp); } if ( !strncasecmp(buff, "Content-disposition:", strlen("Content-disposition:"))) { tmp = strstr(buff, "name="); - if(tmp) { + if (tmp) { tmp+=strlen("name="); - if(tmp[0] == '"') { + if (tmp[0] == '"') { char *tmp2; tmp++; tmp2 = strchr(tmp, '"'); - if(tmp2) + if (tmp2) *tmp2 = '\0'; } else { char *tmp2; @@ -422,7 +422,7 @@ static void yahoo_got_url_fd(int id, int fd, int error, void *data) tmp2 = strchr(tmp, '\r'); if (!tmp2) tmp2 = strchr(tmp, '\n'); - if(tmp2) + if (tmp2) *tmp2 = '\0'; } diff --git a/protocols/Yahoo/src/libyahoo2/yahoo_list.c b/protocols/Yahoo/src/libyahoo2/yahoo_list.c index b3e40c208e..42af4e2046 100644 --- a/protocols/Yahoo/src/libyahoo2/yahoo_list.c +++ b/protocols/Yahoo/src/libyahoo2/yahoo_list.c @@ -226,7 +226,7 @@ YList *y_list_insert_sorted(YList * list, void *data, YListCompFunc comp) n->next = l; - if(n->prev) { + if (n->prev) { n->prev->next = n; return list; } else { diff --git a/protocols/Yahoo/src/libyahoo2/yahoo_util.c b/protocols/Yahoo/src/libyahoo2/yahoo_util.c index a2de75c050..cd76a77ba7 100644 --- a/protocols/Yahoo/src/libyahoo2/yahoo_util.c +++ b/protocols/Yahoo/src/libyahoo2/yahoo_util.c @@ -44,7 +44,7 @@ char * y_string_append(char * string, char * append) int size = strlen(string) + strlen(append) + 1; char * new_string = y_renew(char, string, size); - if(new_string == NULL) { + if (new_string == NULL) { new_string = y_new(char, size); strcpy(new_string, string); FREE(string); @@ -60,7 +60,7 @@ char * y_string_append(char * string, char * append) unsigned int n, i = 0; char *result = NULL; - if(in == NULL || *in == '\0') + if (in == NULL || *in == '\0') return ""; result = y_new(char, strlen(in) * 2 + 1); @@ -86,7 +86,7 @@ char * y_utf8_to_str(const char *in) unsigned int n; char *result = NULL; - if(in == NULL || *in == '\0') + if (in == NULL || *in == '\0') return ""; result = y_new(char, strlen(in) + 1); @@ -122,13 +122,13 @@ char ** y_strsplit(char * str, char * sep, int nelem) char *s, *p; int i=0; int l = strlen(sep); - if(nelem <= 0) { + if (nelem <= 0) { char * s; nelem=0; if (*str) { for(s=strstr(str, sep); s; s=strstr(s+l, sep),nelem++) ; - if(strcmp(str+strlen(str)-l, sep)) + if (strcmp(str+strlen(str)-l, sep)) nelem++; } } @@ -142,7 +142,7 @@ char ** y_strsplit(char * str, char * sep, int nelem) vector[i][len] = '\0'; } - if(i -# define FREE(x) if(x) {g_free(x); x=NULL;} +# define FREE(x) if (x) {g_free(x); x=NULL;} # define y_new g_new # define y_new0 g_new0 @@ -50,7 +50,7 @@ # include # include -# define FREE(x) if(x) {free(x); x=NULL;} +# define FREE(x) if (x) {free(x); x=NULL;} # define y_new(type, n) (type *)malloc(sizeof(type) * (n)) # define y_new0(type, n) (type *)calloc((n), sizeof(type)) diff --git a/protocols/Yahoo/src/main.cpp b/protocols/Yahoo/src/main.cpp index 2d3b3dd715..76eb107410 100644 --- a/protocols/Yahoo/src/main.cpp +++ b/protocols/Yahoo/src/main.cpp @@ -102,14 +102,14 @@ extern "C" int __declspec(dllexport)Load(void) pd.type = PROTOTYPE_PROTOCOL; pd.fnInit = ( pfnInitProto )yahooProtoInit; pd.fnUninit = ( pfnUninitProto )yahooProtoUninit; - CallService( MS_PROTO_REGISTERMODULE, 0, ( LPARAM )&pd ); + CallService( MS_PROTO_REGISTERMODULE, 0, (LPARAM)&pd ); NETLIBUSER nlu = {0}; nlu.cbSize = sizeof(nlu); nlu.flags = NUF_TCHAR | NUF_OUTGOING | NUF_HTTPCONNS; nlu.szSettingsModule = "YAHOO/libyahoo2"; nlu.ptszDescriptiveName = TranslateT("YAHOO plugin HTTP connections"); - g_hNetlibUser = ( HANDLE )CallService( MS_NETLIB_REGISTERUSER, 0, ( LPARAM )&nlu ); + g_hNetlibUser = ( HANDLE )CallService( MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu ); YmsgrLinksInit(); /** @@ -127,7 +127,7 @@ extern "C" int __declspec(dllexport)Load(void) extern "C" int __declspec(dllexport) Unload(void) { - LOG(( "Unload" )); + LOG(("Unload")); YmsgrLinksUninit(); Netlib_CloseHandle( g_hNetlibUser ); diff --git a/protocols/Yahoo/src/options.cpp b/protocols/Yahoo/src/options.cpp index 0ea1cb4049..f377fa6fdd 100644 --- a/protocols/Yahoo/src/options.cpp +++ b/protocols/Yahoo/src/options.cpp @@ -41,24 +41,24 @@ static INT_PTR CALLBACK DlgProcYahooOpts(HWND hwndDlg, UINT msg, WPARAM wParam, DBFreeVariant(&dbv); } - if ( !ppro->GetString( "Nick", &dbv )) { + if ( !ppro->GetString("Nick", &dbv )) { SetDlgItemTextA(hwndDlg,IDC_NICK,dbv.pszVal); DBFreeVariant(&dbv); } if ( !ppro->GetString( YAHOO_PASSWORD, &dbv )) { //bit of a security hole here, since it's easy to extract a password from an edit box - CallService( MS_DB_CRYPT_DECODESTRING, strlen( dbv.pszVal )+1, ( LPARAM )dbv.pszVal ); + CallService( MS_DB_CRYPT_DECODESTRING, strlen( dbv.pszVal )+1, (LPARAM)dbv.pszVal ); SetDlgItemTextA( hwndDlg, IDC_PASSWORD, dbv.pszVal ); DBFreeVariant( &dbv ); } - //SetButtonCheck( hwndDlg, IDC_DISABLE_UTF8, ppro->GetByte( "DisableUTF8", 0 )); - SetButtonCheck( hwndDlg, IDC_USE_YAB, ppro->GetByte( "UseYAB", 1 )); - SetButtonCheck( hwndDlg, IDC_SHOW_AVATARS, ppro->GetByte( "ShowAvatars", 1 )); - SetButtonCheck( hwndDlg, IDC_MAIL_AUTOLOGIN, ppro->GetByte( "MailAutoLogin", 1 )); - SetButtonCheck( hwndDlg, IDC_DISABLEYAHOOMAIL, !ppro->GetByte( "DisableYahoomail", 0 )); - SetButtonCheck( hwndDlg, IDC_SHOW_ERRORS, ppro->GetByte( "ShowErrors", 1 )); + //SetButtonCheck( hwndDlg, IDC_DISABLE_UTF8, ppro->GetByte("DisableUTF8", 0)); + SetButtonCheck( hwndDlg, IDC_USE_YAB, ppro->GetByte("UseYAB", 1 )); + SetButtonCheck( hwndDlg, IDC_SHOW_AVATARS, ppro->GetByte("ShowAvatars", 1 )); + SetButtonCheck( hwndDlg, IDC_MAIL_AUTOLOGIN, ppro->GetByte("MailAutoLogin", 1 )); + SetButtonCheck( hwndDlg, IDC_DISABLEYAHOOMAIL, !ppro->GetByte("DisableYahoomail", 0)); + SetButtonCheck( hwndDlg, IDC_SHOW_ERRORS, ppro->GetByte("ShowErrors", 1 )); return TRUE; @@ -67,9 +67,9 @@ static INT_PTR CALLBACK DlgProcYahooOpts(HWND hwndDlg, UINT msg, WPARAM wParam, switch ( LOWORD( wParam )) { case IDC_NEWYAHOOACCOUNTLINK: CallService( MS_UTILS_OPENURL, 1, - ppro->GetByte( "YahooJapan", 0 ) ? + ppro->GetByte("YahooJapan", 0) ? (LPARAM)"http://edit.yahoo.co.jp/config/eval_register" : - (LPARAM)"http://edit.yahoo.com/config/eval_register" ); + (LPARAM)"http://edit.yahoo.com/config/eval_register"); return TRUE; //case IDC_DISABLE_UTF8: @@ -104,17 +104,17 @@ static INT_PTR CALLBACK DlgProcYahooOpts(HWND hwndDlg, UINT msg, WPARAM wParam, if ( ppro->GetString( YAHOO_LOGINID, &dbv ) || lstrcmpA( str, dbv.pszVal )) reconnectRequired = TRUE; - if ( dbv.pszVal != NULL ) + if ( dbv.pszVal != NULL) DBFreeVariant( &dbv ); ppro->SetString( YAHOO_LOGINID, str ); GetDlgItemTextA( hwndDlg, IDC_PASSWORD, str, sizeof( str )); - CallService( MS_DB_CRYPT_ENCODESTRING, sizeof( str ),( LPARAM )str ); + CallService( MS_DB_CRYPT_ENCODESTRING, sizeof( str ),(LPARAM)str ); dbv.pszVal = NULL; if ( ppro->GetString( YAHOO_PASSWORD, &dbv ) || lstrcmpA( str, dbv.pszVal )) reconnectRequired = TRUE; - if ( dbv.pszVal != NULL ) + if ( dbv.pszVal != NULL) DBFreeVariant( &dbv ); ppro->SetString( YAHOO_PASSWORD, str ); @@ -123,10 +123,10 @@ static INT_PTR CALLBACK DlgProcYahooOpts(HWND hwndDlg, UINT msg, WPARAM wParam, if (str[0] == '\0') { /* Check for empty Nick, if so delete the key in the DB */ - DBDeleteContactSetting( NULL, ppro->m_szModuleName, "Nick" ); + DBDeleteContactSetting( NULL, ppro->m_szModuleName, "Nick"); } else { /* otherwise save the new Nick */ - ppro->SetString( "Nick", str ); + ppro->SetString("Nick", str ); } //ppro->SetByte("DisableUTF8", ( BYTE )IsDlgButtonChecked( hwndDlg, IDC_DISABLE_UTF8 )); @@ -141,10 +141,10 @@ static INT_PTR CALLBACK DlgProcYahooOpts(HWND hwndDlg, UINT msg, WPARAM wParam, } /*if ( restartRequired ) - MessageBoxA( hwndDlg, Translate( "The changes you have made require you to restart Miranda NG before they take effect"), Translate("YAHOO Options"), MB_OK ); + MessageBoxA( hwndDlg, Translate("The changes you have made require you to restart Miranda NG before they take effect"), Translate("YAHOO Options"), MB_OK ); else */ if ( reconnectRequired && ppro->m_bLoggedIn ) - MessageBoxA( hwndDlg, Translate( "The changes you have made require you to reconnect to the Yahoo network before they take effect"), Translate("YAHOO Options"), MB_OK ); + MessageBoxA( hwndDlg, Translate("The changes you have made require you to reconnect to the Yahoo network before they take effect"), Translate("YAHOO Options"), MB_OK ); return TRUE; } @@ -174,13 +174,13 @@ static INT_PTR CALLBACK DlgProcYahooOptsConn(HWND hwndDlg, UINT msg, WPARAM wPar DBFreeVariant( &dbv ); } else SetDlgItemTextA( hwndDlg, IDC_LOGINSERVER, - ppro->GetByte( "YahooJapan", 0 ) + ppro->GetByte("YahooJapan", 0) ? YAHOO_DEFAULT_JAPAN_LOGIN_SERVER : YAHOO_DEFAULT_LOGIN_SERVER ); SetDlgItemInt( hwndDlg, IDC_YAHOOPORT, ppro->GetWord( NULL, YAHOO_LOGINPORT, YAHOO_DEFAULT_PORT ), FALSE ); - SetButtonCheck( hwndDlg, IDC_YAHOO_JAPAN, ppro->GetByte( "YahooJapan", 0 )); + SetButtonCheck( hwndDlg, IDC_YAHOO_JAPAN, ppro->GetByte("YahooJapan", 0)); return TRUE; case WM_COMMAND: @@ -224,7 +224,7 @@ static INT_PTR CALLBACK DlgProcYahooOptsConn(HWND hwndDlg, UINT msg, WPARAM wPar if ( ppro->GetString( YAHOO_LOGINSERVER, &dbv ) || lstrcmpA( str, dbv.pszVal )) reconnectRequired = TRUE; - if ( dbv.pszVal != NULL ) + if ( dbv.pszVal != NULL) DBFreeVariant( &dbv ); ppro->SetString( YAHOO_LOGINSERVER, str ); @@ -238,10 +238,10 @@ static INT_PTR CALLBACK DlgProcYahooOptsConn(HWND hwndDlg, UINT msg, WPARAM wPar ppro->SetByte("YahooJapan", ( BYTE )IsDlgButtonChecked( hwndDlg, IDC_YAHOO_JAPAN )); /*if ( restartRequired ) - MessageBoxA( hwndDlg, Translate( "The changes you have made require you to restart Miranda NG before they take effect"), Translate("YAHOO Options"), MB_OK ); + MessageBoxA( hwndDlg, Translate("The changes you have made require you to restart Miranda NG before they take effect"), Translate("YAHOO Options"), MB_OK ); else */ if ( reconnectRequired && ppro->m_bLoggedIn ) - MessageBoxA( hwndDlg, Translate( "The changes you have made require you to reconnect to the Yahoo network before they take effect"), Translate("YAHOO Options"), MB_OK ); + MessageBoxA( hwndDlg, Translate("The changes you have made require you to reconnect to the Yahoo network before they take effect"), Translate("YAHOO Options"), MB_OK ); return TRUE; } @@ -265,7 +265,7 @@ static INT_PTR CALLBACK DlgProcYahooOptsIgnore(HWND hwndDlg, UINT msg, WPARAM wP ppro = ( CYahooProto* )lParam; SetWindowLongPtr( hwndDlg, GWLP_USERDATA, lParam ); - if ( ppro->GetByte( "IgnoreUnknown", 0 )) { + if ( ppro->GetByte("IgnoreUnknown", 0)) { CheckDlgButton(hwndDlg, IDC_OPT_IGN_UNKNOWN, 1); EnableWindow( GetDlgItem(hwndDlg, IDC_IGN_ADD), 0); @@ -322,7 +322,7 @@ static INT_PTR CALLBACK DlgProcYahooOptsIgnore(HWND hwndDlg, UINT msg, WPARAM wP } ppro->IgnoreBuddy(id, 0); SendMessageA(GetDlgItem(hwndDlg,IDC_YIGN_LIST), LB_ADDSTRING, 0, (LPARAM)id); - SetDlgItemTextA( hwndDlg, IDC_YIGN_EDIT, "" ); + SetDlgItemTextA( hwndDlg, IDC_YIGN_EDIT, ""); } break; diff --git a/protocols/Yahoo/src/proto.cpp b/protocols/Yahoo/src/proto.cpp index 6f4ad4306d..46616b1d46 100644 --- a/protocols/Yahoo/src/proto.cpp +++ b/protocols/Yahoo/src/proto.cpp @@ -29,7 +29,7 @@ CYahooProto::CYahooProto( const char* aProtoName, const TCHAR* aUserName ) : m_bLoggedIn( FALSE ), - poll_loop( 0 ), + poll_loop( 0), m_chatrooms(3, ChatRoom::compare) { m_iVersion = 2; @@ -80,7 +80,7 @@ int CYahooProto::OnModulesLoadedEx( WPARAM, LPARAM ) YHookEvent( ME_CLIST_PREBUILDCONTACTMENU, &CYahooProto::OnPrebuildContactMenu ); TCHAR tModuleDescr[ 100 ]; - mir_sntprintf(tModuleDescr, SIZEOF(tModuleDescr), TranslateT( "%s plugin connections" ), m_tszUserName); + mir_sntprintf(tModuleDescr, SIZEOF(tModuleDescr), TranslateT("%s plugin connections"), m_tszUserName); NETLIBUSER nlu = {0}; nlu.cbSize = sizeof(nlu); @@ -102,7 +102,7 @@ int CYahooProto::OnModulesLoadedEx( WPARAM, LPARAM ) nlu.pfnHttpGatewayUnwrapRecv = YAHOO_httpGatewayUnwrapRecv; #endif - m_hNetlibUser = ( HANDLE )CallService( MS_NETLIB_REGISTERUSER, 0, ( LPARAM )&nlu ); + m_hNetlibUser = ( HANDLE )CallService( MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu ); MenuContactInit(); return 0; @@ -128,7 +128,7 @@ HANDLE CYahooProto::AddToList( int flags, PROTOSEARCHRESULT* psr ) char *id = psr->flags & PSR_UNICODE ? mir_utf8encodeW((wchar_t*)psr->id) : mir_utf8encode((char*)psr->id); HANDLE hContact = getbuddyH(id); if (hContact != NULL) { - if (DBGetContactSettingByte(hContact, "CList", "NotOnList", 0)) { + if (db_get_b(hContact, "CList", "NotOnList", 0)) { DebugLog("[YahooAddToList] Temporary Buddy:%s already on our buddy list", id); //return 0; } else { @@ -154,14 +154,14 @@ HANDLE __cdecl CYahooProto::AddToListByEvent( int flags, int /*iContact*/, HANDL return 0; DBEVENTINFO dbei = { sizeof( dbei ) }; - if (( dbei.cbBlob = CallService( MS_DB_EVENT_GETBLOBSIZE, ( LPARAM )hDbEvent, 0 )) == -1 ) { + if (( dbei.cbBlob = CallService( MS_DB_EVENT_GETBLOBSIZE, (LPARAM)hDbEvent, 0)) == -1 ) { DebugLog("[YahooAddToListByEvent] ERROR: Can't get blob size."); return 0; } DebugLog("[YahooAddToListByEvent] Got blob size: %lu", dbei.cbBlob); dbei.pBlob = ( PBYTE )_alloca( dbei.cbBlob ); - if ( CallService( MS_DB_EVENT_GET, ( WPARAM )hDbEvent, ( LPARAM )&dbei )) { + if ( CallService( MS_DB_EVENT_GET, ( WPARAM )hDbEvent, (LPARAM)&dbei )) { DebugLog("[YahooAddToListByEvent] ERROR: Can't get event."); return 0; } @@ -197,11 +197,11 @@ int CYahooProto::Authorize( HANDLE hdbe ) } DBEVENTINFO dbei = { sizeof(dbei) }; - if (( dbei.cbBlob = CallService( MS_DB_EVENT_GETBLOBSIZE, ( WPARAM )hdbe, 0 )) == -1 ) + if (( dbei.cbBlob = CallService( MS_DB_EVENT_GETBLOBSIZE, ( WPARAM )hdbe, 0)) == -1 ) return 1; dbei.pBlob = ( PBYTE )_alloca( dbei.cbBlob ); - if ( CallService( MS_DB_EVENT_GET, ( WPARAM )hdbe, ( LPARAM )&dbei )) + if ( CallService( MS_DB_EVENT_GET, ( WPARAM )hdbe, (LPARAM)&dbei )) return 1; if (dbei.eventType != EVENTTYPE_AUTHREQUEST) @@ -241,13 +241,13 @@ int CYahooProto::AuthDeny( HANDLE hdbe, const TCHAR* reason ) memset( &dbei, 0, sizeof( dbei )); dbei.cbSize = sizeof( dbei ); - if (( dbei.cbBlob = CallService( MS_DB_EVENT_GETBLOBSIZE, ( WPARAM )hdbe, 0 )) == -1 ) { + if (( dbei.cbBlob = CallService( MS_DB_EVENT_GETBLOBSIZE, ( WPARAM )hdbe, 0)) == -1 ) { DebugLog("[YahooAuthDeny] ERROR: Can't get blob size"); return 1; } dbei.pBlob = ( PBYTE )alloca( dbei.cbBlob ); - if ( CallService( MS_DB_EVENT_GET, ( WPARAM )hdbe, ( LPARAM )&dbei )) { + if ( CallService( MS_DB_EVENT_GET, ( WPARAM )hdbe, (LPARAM)&dbei )) { DebugLog("YahooAuthDeny - Can't get db event!"); return 1; } @@ -517,7 +517,7 @@ int __cdecl CYahooProto::SetStatus( int iNewStatus ) if (err != 0) { BroadcastStatus(ID_STATUS_OFFLINE); - ShowError(Translate("Yahoo Login Error"), errmsg); + ShowError( TranslateT("Yahoo Login Error"), _A2T(errmsg)); return 0; } @@ -534,7 +534,7 @@ int __cdecl CYahooProto::SetStatus( int iNewStatus ) DBFreeVariant(&dbv); } - //DBWriteContactSettingWord(NULL, m_szModuleName, "StartupStatus", status); + //db_get_w(NULL, m_szModuleName, "StartupStatus", status); m_startStatus = iNewStatus; //reset the unread email count. We'll get a new packet since we are connecting. @@ -621,7 +621,7 @@ void __cdecl CYahooProto::get_status_thread(HANDLE hContact) FREE(sm); - SendBroadcast( hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, ( HANDLE )1, ( LPARAM )( TCHAR* )_A2T(fm)); + SendBroadcast( hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, ( HANDLE )1, (LPARAM)( TCHAR* )_A2T(fm)); } HANDLE __cdecl CYahooProto::GetAwayMsg( HANDLE hContact ) @@ -687,9 +687,9 @@ int __cdecl CYahooProto::SetAwayMsg( int status, const PROTOCHAR* msg ) /* now decide what we tell the server */ if (c != 0) { m_startMsg = strdup(c); - if(status == ID_STATUS_ONLINE) { + if (status == ID_STATUS_ONLINE) { set_status(YAHOO_CUSTOM_STATUS, c, 0); - } else if(status != ID_STATUS_INVISIBLE) { + } else if (status != ID_STATUS_INVISIBLE) { set_status(YAHOO_CUSTOM_STATUS, c, 1); } } else { @@ -744,8 +744,8 @@ int __cdecl CYahooProto::UserIsTyping( HANDLE hContact, int type ) int __cdecl CYahooProto::OnEvent( PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM lParam ) { switch( eventType ) { - case EV_PROTO_ONLOAD: return OnModulesLoadedEx( 0, 0 ); - //case EV_PROTO_ONEXIT: return OnPreShutdown( 0, 0 ); + case EV_PROTO_ONLOAD: return OnModulesLoadedEx( 0, 0); + //case EV_PROTO_ONEXIT: return OnPreShutdown( 0, 0); case EV_PROTO_ONOPTIONS: return OnOptionsInit( wParam, lParam ); case EV_PROTO_ONMENU: @@ -795,7 +795,7 @@ INT_PTR CALLBACK first_run_dialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM DBFreeVariant(&dbv); } - SetButtonCheck( hwndDlg, IDC_YAHOO_JAPAN, ppro->GetByte( "YahooJapan", 0 )); + SetButtonCheck( hwndDlg, IDC_YAHOO_JAPAN, ppro->GetByte("YahooJapan", 0)); return TRUE; } @@ -804,8 +804,8 @@ INT_PTR CALLBACK first_run_dialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM CallService( MS_UTILS_OPENURL, 1, (( BYTE )IsDlgButtonChecked( hwndDlg, IDC_YAHOO_JAPAN ) == 1) ? - ( LPARAM ) "http://edit.yahoo.co.jp/config/eval_register" : - ( LPARAM ) "http://edit.yahoo.com/config/eval_register" + (LPARAM) "http://edit.yahoo.co.jp/config/eval_register" : + (LPARAM) "http://edit.yahoo.com/config/eval_register" ); return TRUE; } @@ -836,7 +836,7 @@ INT_PTR CALLBACK first_run_dialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM if ( ppro->GetString( YAHOO_LOGINID, &dbv ) || lstrcmpA( str, dbv.pszVal )) reconnectRequired = TRUE; - if ( dbv.pszVal != NULL ) + if ( dbv.pszVal != NULL) DBFreeVariant( &dbv ); ppro->SetString(YAHOO_LOGINID, str); @@ -845,7 +845,7 @@ INT_PTR CALLBACK first_run_dialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM dbv.pszVal = NULL; if ( ppro->GetString( YAHOO_PASSWORD, &dbv ) || lstrcmpA( str, dbv.pszVal )) reconnectRequired = TRUE; - if ( dbv.pszVal != NULL ) + if ( dbv.pszVal != NULL) DBFreeVariant( &dbv ); if (reconnectRequired ) { @@ -857,7 +857,7 @@ INT_PTR CALLBACK first_run_dialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM ppro->SetByte("YahooJapan", ( BYTE )IsDlgButtonChecked( hwndDlg, IDC_YAHOO_JAPAN )); if ( reconnectRequired && ppro->m_bLoggedIn ) - MessageBoxA( hwndDlg, Translate( "The changes you have made require you to reconnect to the Yahoo network before they take effect"), Translate("YAHOO Options"), MB_OK ); + MessageBoxA( hwndDlg, Translate("The changes you have made require you to reconnect to the Yahoo network before they take effect"), Translate("YAHOO Options"), MB_OK ); return TRUE; } diff --git a/protocols/Yahoo/src/proto.h b/protocols/Yahoo/src/proto.h index e40c465632..7c6150f1aa 100644 --- a/protocols/Yahoo/src/proto.h +++ b/protocols/Yahoo/src/proto.h @@ -57,7 +57,7 @@ struct CYahooProto : public PROTO_INTERFACE, public MZeroedObject virtual int __cdecl FileDeny( HANDLE hContact, HANDLE hTransfer, const PROTOCHAR* szReason ); virtual int __cdecl FileResume( HANDLE hTransfer, int* action, const PROTOCHAR** szFilename ); - virtual DWORD_PTR __cdecl GetCaps( int type, HANDLE hContact = NULL ); + virtual DWORD_PTR __cdecl GetCaps( int type, HANDLE hContact = NULL); virtual HICON __cdecl GetIcon( int iconIndex ); virtual int __cdecl GetInfo( HANDLE hContact, int infoType ); @@ -268,9 +268,9 @@ struct CYahooProto : public PROTO_INTERFACE, public MZeroedObject int SendBroadcast( HANDLE hContact, int type, int result, HANDLE hProcess, LPARAM lParam ); - int ShowNotification(const char *title, const char *info, DWORD flags); - void ShowError(const char *title, const char *buff); - int ShowPopup( const char* nickname, const char* msg, const char *szURL ); + int ShowNotification(const TCHAR *title, const TCHAR *info, DWORD flags); + void ShowError(const TCHAR *title, const TCHAR *buff); + int ShowPopup( const TCHAR* nickname, const TCHAR* msg, const char *szURL ); bool IsMyContact(HANDLE hContact); #ifdef __GNUC__ diff --git a/protocols/Yahoo/src/search.cpp b/protocols/Yahoo/src/search.cpp index af0e9f7460..e36439bc2c 100644 --- a/protocols/Yahoo/src/search.cpp +++ b/protocols/Yahoo/src/search.cpp @@ -145,7 +145,7 @@ static INT_PTR CALLBACK YahooSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPARA HWND __cdecl CYahooProto::CreateExtendedSearchUI( HWND parent ) { if ( parent && hInstance ) - return CreateDialogParam( hInstance, MAKEINTRESOURCE(IDD_SEARCHUSER), parent, YahooSearchAdvancedDlgProc, ( LPARAM )this ); + return CreateDialogParam( hInstance, MAKEINTRESOURCE(IDD_SEARCHUSER), parent, YahooSearchAdvancedDlgProc, (LPARAM)this ); return 0; } diff --git a/protocols/Yahoo/src/server.cpp b/protocols/Yahoo/src/server.cpp index 34ccfe8dc3..329b797789 100644 --- a/protocols/Yahoo/src/server.cpp +++ b/protocols/Yahoo/src/server.cpp @@ -78,7 +78,7 @@ void __cdecl CYahooProto::server_main(void *empty) for(l=m_connections; l; ) { struct _conn *c = ( _conn * )l->data; //LOG(("Connection tag:%d id:%d fd:%d remove:%d", c->tag, c->id, c->fd, c->remove)); - if(c->remove) { + if (c->remove) { YList *n = y_list_next(l); //LOG(("Removing id:%d fd:%d tag:%d", c->id, c->fd, c->tag)); m_connections = y_list_remove_link(m_connections, l); @@ -86,13 +86,13 @@ void __cdecl CYahooProto::server_main(void *empty) FREE(c); l=n; } else { - if(c->cond & YAHOO_INPUT_READ) { - //LOG(( "[YAHOO_INPUT_READ] Waiting on read. Tag: %d fd: %d", c->tag, c->fd )); + if (c->cond & YAHOO_INPUT_READ) { + //LOG(("[YAHOO_INPUT_READ] Waiting on read. Tag: %d fd: %d", c->tag, c->fd )); nls.hReadConns[ridx++] = (HANDLE)c->fd; } - if(c->cond & YAHOO_INPUT_WRITE) { - //LOG(( "[YAHOO_INPUT_WRITE] Waiting on write. Tag: %d fd: %d", c->tag, c->fd )); + if (c->cond & YAHOO_INPUT_WRITE) { + //LOG(("[YAHOO_INPUT_WRITE] Waiting on write. Tag: %d fd: %d", c->tag, c->fd )); nls.hWriteConns[widx++] =(HANDLE) c->fd; } @@ -160,12 +160,12 @@ void __cdecl CYahooProto::server_main(void *empty) continue; /* are we waiting for a Read request? */ - if(c->cond & YAHOO_INPUT_READ) { + if (c->cond & YAHOO_INPUT_READ) { for (i = 0; i < ridx; i++) { if ((HANDLE)c->fd == nls.hReadConns[i]) { if (nls.hReadStatus[i]) { - //LOG(( "[YAHOO_INPUT_READ] Read Ready. Tag: %d fd: %d", c->tag, c->fd )); + //LOG(("[YAHOO_INPUT_READ] Read Ready. Tag: %d fd: %d", c->tag, c->fd )); yahoo_callback(c, YAHOO_INPUT_READ); } }//if c->fd= @@ -174,12 +174,12 @@ void __cdecl CYahooProto::server_main(void *empty) } /* are we waiting for a Write request? */ - if(c->cond & YAHOO_INPUT_WRITE) { + if (c->cond & YAHOO_INPUT_WRITE) { for (i = 0; i < widx; i++) { if ((HANDLE)c->fd == nls.hWriteConns[i]) { if (nls.hWriteStatus[i]) { - //LOG(( "[YAHOO_INPUT_WRITE] Write ready. Tag: %d fd: %d", c->tag, c->fd )); + //LOG(("[YAHOO_INPUT_WRITE] Write ready. Tag: %d fd: %d", c->tag, c->fd )); yahoo_callback(c, YAHOO_INPUT_WRITE); } } // if c->fd == nls diff --git a/protocols/Yahoo/src/services.cpp b/protocols/Yahoo/src/services.cpp index 641b4e609c..2193aec50a 100644 --- a/protocols/Yahoo/src/services.cpp +++ b/protocols/Yahoo/src/services.cpp @@ -32,17 +32,17 @@ void CYahooProto::logoff_buddies() { //set all contacts to 'offline' HANDLE hContact = db_find_first(); - while ( hContact != NULL ) + while ( hContact != NULL) { if (IsMyContact(hContact)) { SetWord( hContact, "Status", ID_STATUS_OFFLINE ); SetDword(hContact, "IdleTS", 0); SetDword(hContact, "PictLastCheck", 0); SetDword(hContact, "PictLoading", 0); - DBDeleteContactSetting(hContact, "CList", "StatusMsg" ); - DBDeleteContactSetting(hContact, m_szModuleName, "YMsg" ); - DBDeleteContactSetting(hContact, m_szModuleName, "YGMsg" ); - //DBDeleteContactSetting(hContact, m_szModuleName, "MirVer" ); + DBDeleteContactSetting(hContact, "CList", "StatusMsg"); + DBDeleteContactSetting(hContact, m_szModuleName, "YMsg"); + DBDeleteContactSetting(hContact, m_szModuleName, "YGMsg"); + //DBDeleteContactSetting(hContact, m_szModuleName, "MirVer"); } hContact = db_find_next(hContact); @@ -100,7 +100,7 @@ int __cdecl CYahooProto::OnContactDeleted( WPARAM wParam, LPARAM lParam ) } // he is not a permanent contact! - if (DBGetContactSettingByte(hContact, "CList", "NotOnList", 0) != 0) { + if (db_get_b(hContact, "CList", "NotOnList", 0) != 0) { DebugLog("[YahooContactDeleted] Not a permanent buddy!!!"); return 0; } @@ -130,21 +130,21 @@ static INT_PTR CALLBACK DlgProcSetCustStat(HWND hwndDlg, UINT msg, WPARAM wParam CYahooProto* ppro = ( CYahooProto* )lParam; SetWindowLongPtr( hwndDlg, GWLP_USERDATA, lParam ); - SendMessage( hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)ppro->LoadIconEx( "yahoo", true )); - SendMessage( hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)ppro->LoadIconEx( "yahoo" )); + SendMessage( hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)ppro->LoadIconEx("yahoo", true )); + SendMessage( hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)ppro->LoadIconEx("yahoo")); if ( !DBGetContactSettingString( NULL, ppro->m_szModuleName, YAHOO_CUSTSTATDB, &dbv )) { SetDlgItemTextA( hwndDlg, IDC_CUSTSTAT, dbv. pszVal ); - EnableWindow( GetDlgItem( hwndDlg, IDOK ), lstrlenA(dbv.pszVal) > 0 ); + EnableWindow( GetDlgItem( hwndDlg, IDOK ), lstrlenA(dbv.pszVal) > 0); DBFreeVariant( &dbv ); } else { - SetDlgItemTextA( hwndDlg, IDC_CUSTSTAT, "" ); + SetDlgItemTextA( hwndDlg, IDC_CUSTSTAT, ""); EnableWindow( GetDlgItem( hwndDlg, IDOK ), FALSE ); } - CheckDlgButton( hwndDlg, IDC_CUSTSTATBUSY, ppro->GetByte( "BusyCustStat", 0 )); + CheckDlgButton( hwndDlg, IDC_CUSTSTATBUSY, ppro->GetByte("BusyCustStat", 0)); } return TRUE; @@ -208,11 +208,11 @@ static INT_PTR CALLBACK DlgProcSetCustStat(HWND hwndDlg, UINT msg, WPARAM wParam INT_PTR __cdecl CYahooProto::SetCustomStatCommand( WPARAM wParam, LPARAM lParam ) { if ( !m_bLoggedIn ) { - ShowNotification(Translate("Yahoo Error"), Translate("You need to be connected to set the custom message"), NIIF_ERROR); + ShowNotification( TranslateT("Yahoo Error"), TranslateT("You need to be connected to set the custom message"), NIIF_ERROR); return 0; } - HWND hwndSetCustomStatus = CreateDialogParam(hInstance, MAKEINTRESOURCE( IDD_SETCUSTSTAT ), NULL, DlgProcSetCustStat, ( LPARAM )this ); + HWND hwndSetCustomStatus = CreateDialogParam(hInstance, MAKEINTRESOURCE( IDD_SETCUSTSTAT ), NULL, DlgProcSetCustStat, (LPARAM)this ); SetForegroundWindow( hwndSetCustomStatus ); SetFocus( hwndSetCustomStatus ); ShowWindow( hwndSetCustomStatus, SW_SHOW ); @@ -228,7 +228,7 @@ void CYahooProto::OpenURL(const char *url, int autoLogin) DebugLog("[YahooOpenURL] url: %s Auto Login: %d", url, autoLogin); - if (autoLogin && GetByte( "MailAutoLogin", 0 ) && m_bLoggedIn && m_id > 0) { + if (autoLogin && GetByte("MailAutoLogin", 0) && m_bLoggedIn && m_id > 0) { char *y, *t, *u; y = yahoo_urlencode(yahoo_get_cookie(m_id, "y")); @@ -247,7 +247,7 @@ void CYahooProto::OpenURL(const char *url, int autoLogin) DebugLog("[YahooOpenURL] url: %s Final URL: %s", url, tUrl); - CallService( MS_UTILS_OPENURL, TRUE, ( LPARAM )tUrl ); + CallService( MS_UTILS_OPENURL, TRUE, (LPARAM)tUrl ); } //======================================================= @@ -289,7 +289,7 @@ INT_PTR __cdecl CYahooProto::OnShowMyProfileCommand( WPARAM wParam, LPARAM lPara DBVARIANT dbv; if ( GetString( YAHOO_LOGINID, &dbv ) != 0) { - ShowError(Translate("Yahoo Error"), Translate("Please enter your yahoo id in Options/Network/Yahoo")); + ShowError( TranslateT("Yahoo Error"), TranslateT("Please enter your yahoo id in Options/Network/Yahoo")); return 0; } @@ -306,7 +306,7 @@ INT_PTR __cdecl CYahooProto::OnShowMyProfileCommand( WPARAM wParam, LPARAM lPara //======================================================= INT_PTR __cdecl CYahooProto::OnGotoMailboxCommand( WPARAM wParam, LPARAM lParam ) { - if (GetByte( "YahooJapan", 0 )) + if (GetByte("YahooJapan", 0)) OpenURL("http://mail.yahoo.co.jp/", 1); else OpenURL("http://mail.yahoo.com/", 1); @@ -332,7 +332,7 @@ INT_PTR __cdecl CYahooProto::OnCalendarCommand( WPARAM wParam, LPARAM lParam ) INT_PTR __cdecl CYahooProto::OnRefreshCommand( WPARAM wParam, LPARAM lParam ) { if ( !m_bLoggedIn ) { - ShowNotification(Translate("Yahoo Error"), Translate("You need to be connected to refresh your buddy list"), NIIF_ERROR); + ShowNotification(TranslateT("Yahoo Error"), TranslateT("You need to be connected to refresh your buddy list"), NIIF_ERROR); return 0; } @@ -382,7 +382,7 @@ void CYahooProto::MenuMainInit( void ) mi.pszService = servicefunction; HGENMENU hRoot = MO_GetProtoRootMenu( m_szModuleName ); - if ( hRoot == NULL ) { + if ( hRoot == NULL) { mi.position = 500015000; mi.hParentMenu = HGENMENU_ROOT; mi.flags = CMIF_ICONFROMICOLIB | CMIF_ROOTPOPUP | CMIF_TCHAR | CMIF_KEEPUNTRANSLATED; @@ -392,7 +392,7 @@ void CYahooProto::MenuMainInit( void ) } else { if ( mainMenuRoot ) - CallService( MS_CLIST_REMOVEMAINMENUITEM, ( WPARAM )mainMenuRoot, 0 ); + CallService( MS_CLIST_REMOVEMAINMENUITEM, ( WPARAM )mainMenuRoot, 0); mainMenuRoot = NULL; } @@ -405,7 +405,7 @@ void CYahooProto::MenuMainInit( void ) mi.position = 290000; mi.icolibItem = GetIconHandle( IDI_SET_STATUS ); - mi.pszName = LPGEN( "Set &Custom Status" ); + mi.pszName = LPGEN("Set &Custom Status"); menuItemsAll[0] = Menu_AddProtoMenuItem(&mi); @@ -415,7 +415,7 @@ void CYahooProto::MenuMainInit( void ) mi.position = 290005; mi.icolibItem = GetIconHandle( IDI_PROFILE ); - mi.pszName = LPGEN( "&Edit My Profile" ); + mi.pszName = LPGEN("&Edit My Profile"); menuItemsAll[1] = Menu_AddProtoMenuItem(&mi); // Show My profile @@ -424,7 +424,7 @@ void CYahooProto::MenuMainInit( void ) mi.position = 290006; mi.icolibItem = GetIconHandle( IDI_PROFILE ); - mi.pszName = LPGEN( "&My Profile" ); + mi.pszName = LPGEN("&My Profile"); menuItemsAll[2] = Menu_AddProtoMenuItem(&mi); // Show Yahoo mail @@ -433,7 +433,7 @@ void CYahooProto::MenuMainInit( void ) mi.position = 290010; mi.icolibItem = GetIconHandle( IDI_INBOX ); - mi.pszName = LPGEN( "&Yahoo Mail" ); + mi.pszName = LPGEN("&Yahoo Mail"); menuItemsAll[3] = Menu_AddProtoMenuItem(&mi); // Show Address Book @@ -442,7 +442,7 @@ void CYahooProto::MenuMainInit( void ) mi.position = 290015; mi.icolibItem = GetIconHandle( IDI_YAB ); - mi.pszName = LPGEN( "&Address Book" ); + mi.pszName = LPGEN("&Address Book"); menuItemsAll[4] = Menu_AddProtoMenuItem(&mi); // Show Calendar @@ -451,9 +451,9 @@ void CYahooProto::MenuMainInit( void ) mi.position = 290017; mi.icolibItem = GetIconHandle( IDI_CALENDAR ); - mi.pszName = LPGEN( "&Calendar" ); + mi.pszName = LPGEN("&Calendar"); menuItemsAll[5] = Menu_AddProtoMenuItem(&mi); - strcpy( tDest, "/JoinChatRoom" ); + strcpy( tDest, "/JoinChatRoom"); YCreateService("/JoinChatRoom", &CYahooProto::CreateConference); mi.position = 290018; @@ -468,7 +468,7 @@ void CYahooProto::MenuMainInit( void ) mi.position = 500090015; mi.icolibItem = GetIconHandle( IDI_REFRESH ); - mi.pszName = LPGEN( "&Refresh" ); + mi.pszName = LPGEN("&Refresh"); menuItemsAll[7] = Menu_AddProtoMenuItem(&mi); */ } @@ -490,7 +490,7 @@ void CYahooProto::MenuContactInit( void ) mi.position = -2000006000; mi.icolibItem = GetIconHandle( IDI_PROFILE ); - mi.pszName = LPGEN( "&Show Profile" ); + mi.pszName = LPGEN("&Show Profile"); hShowProfileMenuItem = Menu_AddContactMenuItem(&mi); } @@ -498,9 +498,9 @@ void CYahooProto::MenuContactInit( void ) void CYahooProto::MenuUninit( void ) { if ( mainMenuRoot ) - CallService( MS_CLIST_REMOVEMAINMENUITEM, ( WPARAM )mainMenuRoot, 0 ); + CallService( MS_CLIST_REMOVEMAINMENUITEM, ( WPARAM )mainMenuRoot, 0); - CallService( MS_CLIST_REMOVECONTACTMENUITEM, ( WPARAM )hShowProfileMenuItem, 0 ); + CallService( MS_CLIST_REMOVECONTACTMENUITEM, ( WPARAM )hShowProfileMenuItem, 0); } int __cdecl CYahooProto::OnPrebuildContactMenu(WPARAM wParam, LPARAM) @@ -551,26 +551,26 @@ void CYahooProto::LoadYahooServices( void ) //----| Set resident variables |------------------------------------------------------ mir_snprintf( path, sizeof( path ), "%s/Status", m_szModuleName ); - CallService( MS_DB_SETSETTINGRESIDENT, TRUE, ( LPARAM )path ); + CallService( MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)path ); mir_snprintf( path, sizeof( path ), "%s/YStatus", m_szModuleName ); - CallService( MS_DB_SETSETTINGRESIDENT, TRUE, ( LPARAM )path ); + CallService( MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)path ); mir_snprintf( path, sizeof( path ), "%s/YAway", m_szModuleName ); - CallService( MS_DB_SETSETTINGRESIDENT, TRUE, ( LPARAM )path ); + CallService( MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)path ); mir_snprintf( path, sizeof( path ), "%s/Mobile", m_szModuleName ); - CallService( MS_DB_SETSETTINGRESIDENT, TRUE, ( LPARAM )path ); + CallService( MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)path ); mir_snprintf( path, sizeof( path ), "%s/YGMsg", m_szModuleName ); - CallService( MS_DB_SETSETTINGRESIDENT, TRUE, ( LPARAM )path ); + CallService( MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)path ); mir_snprintf( path, sizeof( path ), "%s/IdleTS", m_szModuleName ); - CallService( MS_DB_SETSETTINGRESIDENT, TRUE, ( LPARAM )path ); + CallService( MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)path ); mir_snprintf( path, sizeof( path ), "%s/PictLastCheck", m_szModuleName ); - CallService( MS_DB_SETSETTINGRESIDENT, TRUE, ( LPARAM )path ); + CallService( MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)path ); mir_snprintf( path, sizeof( path ), "%s/PictLoading", m_szModuleName ); - CallService( MS_DB_SETSETTINGRESIDENT, TRUE, ( LPARAM )path ); + CallService( MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)path ); } diff --git a/protocols/Yahoo/src/user_info.cpp b/protocols/Yahoo/src/user_info.cpp index c957dbc81d..1b768a7c78 100644 --- a/protocols/Yahoo/src/user_info.cpp +++ b/protocols/Yahoo/src/user_info.cpp @@ -34,7 +34,7 @@ static INT_PTR CALLBACK YahooUserInfoDlgProc( HWND hwndDlg, UINT msg, WPARAM wPa break; case WM_NOTIFY: - if (( ( LPNMHDR )lParam )->idFrom == 0 ) { + if (( ( LPNMHDR )lParam )->idFrom == 0) { switch (( ( LPNMHDR )lParam )->code ) { case PSN_PARAMCHANGED: SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (( PSHNOTIFY* )lParam )->lParam ); @@ -113,13 +113,13 @@ static INT_PTR CALLBACK YahooUserInfoDlgProc( HWND hwndDlg, UINT msg, WPARAM wPa int __cdecl CYahooProto::OnUserInfoInit( WPARAM wParam, LPARAM lParam ) { - //if ( !JCallService( MS_PROTO_ISPROTOCOLLOADED, 0, ( LPARAM )m_szModuleName )) + //if ( !JCallService( MS_PROTO_ISPROTOCOLLOADED, 0, (LPARAM)m_szModuleName )) // return 0; OPTIONSDIALOGPAGE odp = {0}; odp.cbSize = sizeof( odp ); odp.hInstance = hInstance; - odp.dwInitParam = ( LPARAM )this; + odp.dwInitParam = (LPARAM)this; HANDLE hContact = ( HANDLE )lParam; if ( IsMyContact(hContact)) { diff --git a/protocols/Yahoo/src/util.cpp b/protocols/Yahoo/src/util.cpp index d3a31ccebd..5b315fc0df 100644 --- a/protocols/Yahoo/src/util.cpp +++ b/protocols/Yahoo/src/util.cpp @@ -56,12 +56,12 @@ int CYahooProto::DebugLog( const char *fmt, ... ) va_start( vararg, fmt ); int tBytes = _vsnprintf( str, sizeof( str ), fmt, vararg ); - if ( tBytes > 0 ) + if ( tBytes > 0) str[ tBytes ] = 0; va_end( vararg ); - return CallService( MS_NETLIB_LOG, ( WPARAM )m_hNetlibUser, ( LPARAM )str ); + return CallService( MS_NETLIB_LOG, ( WPARAM )m_hNetlibUser, (LPARAM)str ); } extern HANDLE g_hNetlibUser; @@ -73,64 +73,64 @@ int DebugLog( const char *fmt, ... ) va_start( vararg, fmt ); int tBytes = _vsnprintf( str, sizeof( str ), fmt, vararg ); - if ( tBytes > 0 ) + if ( tBytes > 0) str[ tBytes ] = 0; va_end( vararg ); - return CallService( MS_NETLIB_LOG, ( WPARAM )g_hNetlibUser, ( LPARAM )str ); + return CallService( MS_NETLIB_LOG, ( WPARAM )g_hNetlibUser, (LPARAM)str ); } int CYahooProto::GetByte( const char* valueName, int parDefltValue ) { - return DBGetContactSettingByte( NULL, m_szModuleName, valueName, parDefltValue ); + return db_get_b( NULL, m_szModuleName, valueName, parDefltValue ); } int CYahooProto::SetByte( const char* valueName, int parValue ) { - return DBWriteContactSettingByte( NULL, m_szModuleName, valueName, parValue ); + return db_set_b( NULL, m_szModuleName, valueName, parValue ); } int CYahooProto::GetByte( HANDLE hContact, const char* valueName, int parDefltValue ) { - return DBGetContactSettingByte( hContact, m_szModuleName, valueName, parDefltValue ); + return db_get_b( hContact, m_szModuleName, valueName, parDefltValue ); } int CYahooProto::SetByte( HANDLE hContact, const char* valueName, int parValue ) { - return DBWriteContactSettingByte( hContact, m_szModuleName, valueName, parValue ); + return db_set_b( hContact, m_szModuleName, valueName, parValue ); } DWORD CYahooProto::GetDword( HANDLE hContact, const char* valueName, DWORD parDefltValue ) { - return DBGetContactSettingDword( hContact, m_szModuleName, valueName, parDefltValue ); + return db_get_dw( hContact, m_szModuleName, valueName, parDefltValue ); } DWORD CYahooProto::SetDword( const char* valueName, DWORD parValue ) { - return DBWriteContactSettingDword( NULL, m_szModuleName, valueName, parValue); + return db_set_dw( NULL, m_szModuleName, valueName, parValue); } DWORD CYahooProto::GetDword( const char* valueName, DWORD parDefltValue ) { - return DBGetContactSettingDword( NULL, m_szModuleName, valueName, parDefltValue ); + return db_get_dw( NULL, m_szModuleName, valueName, parDefltValue ); } DWORD CYahooProto::SetDword( HANDLE hContact, const char* valueName, DWORD parValue ) { - return DBWriteContactSettingDword( hContact, m_szModuleName, valueName, parValue); + return db_set_dw( hContact, m_szModuleName, valueName, parValue); } WORD CYahooProto::SetWord( HANDLE hContact, const char* valueName, int parValue ) { - return DBWriteContactSettingWord( hContact, m_szModuleName, valueName, parValue ); + return db_get_w( hContact, m_szModuleName, valueName, parValue ); } WORD CYahooProto::GetWord( HANDLE hContact, const char* valueName, int parDefltValue ) { - return DBGetContactSettingWord( hContact, m_szModuleName, valueName, parDefltValue ); + return db_set_w( hContact, m_szModuleName, valueName, parDefltValue ); } DWORD CYahooProto::Set_Protocol( HANDLE hContact, int protocol ) @@ -155,47 +155,42 @@ DWORD CYahooProto::Set_Protocol( HANDLE hContact, int protocol ) int CYahooProto::SendBroadcast( HANDLE hContact, int type, int result, HANDLE hProcess, LPARAM lParam ) { - ACKDATA ack; - - ZeroMemory(&ack, sizeof(ack)); - - ack.cbSize = sizeof( ACKDATA ); + ACKDATA ack = { sizeof( ACKDATA ) }; ack.szModule = m_szModuleName; ack.hContact = hContact; ack.type = type; ack.result = result; ack.hProcess = hProcess; ack.lParam = lParam; - return CallService( MS_PROTO_BROADCASTACK, 0, ( LPARAM )&ack ); + return CallService(MS_PROTO_BROADCASTACK, 0, (LPARAM)&ack); } -int CYahooProto::GetString( const char* name, DBVARIANT* result ) -{ return DBGetContactSettingString( NULL, m_szModuleName, name, result ); +int CYahooProto::GetString(const char* name, DBVARIANT* result) +{ return DBGetContactSettingString(NULL, m_szModuleName, name, result); } -int CYahooProto::GetString( HANDLE hContact, const char* name, DBVARIANT* result ) -{ return DBGetContactSettingString( hContact, m_szModuleName, name, result ); +int CYahooProto::GetString(HANDLE hContact, const char* name, DBVARIANT* result) +{ return DBGetContactSettingString(hContact, m_szModuleName, name, result); } -int CYahooProto::GetStringUtf( HANDLE hContact, const char* name, DBVARIANT* result ) +int CYahooProto::GetStringUtf(HANDLE hContact, const char* name, DBVARIANT* result) { return DBGetContactSettingStringUtf(hContact, m_szModuleName, name, result); } -void CYahooProto::SetString( const char* name, const char* value ) -{ DBWriteContactSettingString(NULL, m_szModuleName, name, value ); +void CYahooProto::SetString(const char* name, const char* value) +{ db_set_s(NULL, m_szModuleName, name, value); } -void CYahooProto::SetString( HANDLE hContact, const char* name, const char* value ) -{ DBWriteContactSettingString(hContact, m_szModuleName, name, value ); +void CYahooProto::SetString( HANDLE hContact, const char* name, const char* value) +{ db_set_s(hContact, m_szModuleName, name, value); } -void CYahooProto::SetStringT( HANDLE hContact, const char* name, const TCHAR* value ) -{ DBWriteContactSettingTString(hContact, m_szModuleName, name, value ); +void CYahooProto::SetStringT( HANDLE hContact, const char* name, const TCHAR* value) +{ db_set_ts(hContact, m_szModuleName, name, value); } -DWORD CYahooProto::SetStringUtf( HANDLE hContact, const char* valueName, const char* parValue ) -{ - return DBWriteContactSettingStringUtf( hContact, m_szModuleName, valueName, parValue ); +DWORD CYahooProto::SetStringUtf(HANDLE hContact, const char* valueName, const char* parValue) +{ return db_set_utf(hContact, m_szModuleName, valueName, parValue); } ///////////////////////////////////////////////////////////////////////////////////////// @@ -203,29 +198,29 @@ DWORD CYahooProto::SetStringUtf( HANDLE hContact, const char* valueName, const c static int CALLBACK PopupWindowProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) { - switch( message ) { + switch(message) { case WM_COMMAND: DebugLog("[PopupWindowProc] WM_COMMAND"); - if ( HIWORD( wParam ) == STN_CLICKED) { - char *szURL = (char *)PUGetPluginData( hWnd ); - if ( szURL != NULL ) - CallService( MS_UTILS_OPENURL, TRUE, ( LPARAM )szURL ); + if ( HIWORD(wParam) == STN_CLICKED) { + char *szURL = (char*)PUGetPluginData(hWnd); + if (szURL != NULL) + CallService(MS_UTILS_OPENURL, TRUE, (LPARAM)szURL); - PUDeletePopUp( hWnd ); + PUDeletePopUp(hWnd); return 0; } break; case WM_CONTEXTMENU: DebugLog("[PopupWindowProc] WM_CONTEXTMENU"); - PUDeletePopUp( hWnd ); + PUDeletePopUp(hWnd); return TRUE; case UM_FREEPLUGINDATA: DebugLog("[PopupWindowProc] UM_FREEPLUGINDATA"); { - char *szURL = (char *)PUGetPluginData( hWnd ); - if ( szURL != NULL ) + char *szURL = (char *)PUGetPluginData(hWnd); + if (szURL != NULL) free(szURL); } @@ -235,79 +230,64 @@ static int CALLBACK PopupWindowProc( HWND hWnd, UINT message, WPARAM wParam, LPA return DefWindowProc(hWnd, message, wParam, lParam); } -int CYahooProto::ShowPopup( const char* nickname, const char* msg, const char *szURL ) +int CYahooProto::ShowPopup(const TCHAR* nickname, const TCHAR* msg, const char *szURL) { - POPUPDATAEX ppd; - - if ( !ServiceExists( MS_POPUP_ADDPOPUPEX )) + if ( !ServiceExists(MS_POPUP_ADDPOPUPEX)) return 0; - ZeroMemory(&ppd, sizeof(ppd)); - lstrcpyA( ppd.lpzContactName, nickname ); - lstrcpyA( ppd.lpzText, msg ); - - ppd.PluginWindowProc = ( WNDPROC )PopupWindowProc; + POPUPDATAT ppd = { 0 }; + ppd.PluginWindowProc = (WNDPROC)PopupWindowProc; + lstrcpyn(ppd.lptzContactName, nickname, SIZEOF(ppd.lptzContactName)); + lstrcpyn(ppd.lptzText, msg, SIZEOF(ppd.lptzText)); if (szURL != NULL) { - if (lstrcmpiA(szURL, "http://mail.yahoo.com") == 0) { - ppd.lchIcon = LoadIconEx( "mail" ); - } else { - ppd.lchIcon = LoadIconEx( "calendar" ); - } - - ppd.PluginData = (void *) strdup( szURL ); - } else { - ppd.lchIcon = LoadIconEx( "yahoo" ); + ppd.lchIcon = LoadIconEx( !lstrcmpiA(szURL, "http://mail.yahoo.com") ? "mail" : "calendar"); + ppd.PluginData = (void*)strdup(szURL); } + else ppd.lchIcon = LoadIconEx("yahoo"); - DebugLog("[MS_POPUP_ADDPOPUPEX] Generating a popup for [%s] %s", nickname, msg); - - CallService( MS_POPUP_ADDPOPUPEX, (WPARAM)&ppd, 0 ); + DebugLog("[MS_POPUP_ADDPOPUPEX] Generating a popup for [%S] %S", nickname, msg); + CallService(MS_POPUP_ADDPOPUPT, (WPARAM)&ppd, 0); return 1; } -int CYahooProto::ShowNotification(const char *title, const char *info, DWORD flags) +int CYahooProto::ShowNotification(const TCHAR *title, const TCHAR *info, DWORD flags) { if (ServiceExists(MS_CLIST_SYSTRAY_NOTIFY)) { MIRANDASYSTRAYNOTIFY err; - int ret; - err.szProto = m_szModuleName; err.cbSize = sizeof(err); - err.szInfoTitle = (char *)title; - err.szInfo = (char *)info; - err.dwInfoFlags = flags; + err.tszInfoTitle = (TCHAR*)title; + err.tszInfo = (TCHAR*)info; + err.dwInfoFlags = flags | NIIF_INTERN_UNICODE; err.uTimeout = 1000 * 3; - ret = CallService(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM) & err); - + int ret = CallService(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM) & err); if (ret == 0) return 1; } - MessageBoxA(NULL, info, title, MB_OK | MB_ICONINFORMATION); + MessageBox(NULL, info, title, MB_OK | MB_ICONINFORMATION); return 0; } -void CYahooProto::ShowError(const char *title, const char *buff) +void CYahooProto::ShowError(const TCHAR *title, const TCHAR *buff) { - if (GetByte( "ShowErrors", 1 )) - if (!ShowPopup(title, buff, NULL)) + if ( GetByte("ShowErrors", 1)) + if ( !ShowPopup(title, buff, NULL)) ShowNotification(title, buff, NIIF_ERROR); } int __cdecl CYahooProto::OnSettingChanged(WPARAM wParam, LPARAM lParam) { - DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *) lParam; - if (!wParam || !m_bLoggedIn) return 0; - if (!strcmp(cws->szSetting, "ApparentMode")) { - DBVARIANT dbv; - + DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*) lParam; + if ( !strcmp(cws->szSetting, "ApparentMode")) { DebugLog("DB Setting changed. YAHOO user's visible setting changed."); + DBVARIANT dbv; if (!GetString((HANDLE)wParam, YAHOO_LOGINID, &dbv)) { int iAdd = (ID_STATUS_OFFLINE == GetWord((HANDLE) wParam, "ApparentMode", 0)); stealth(dbv.pszVal, iAdd); @@ -319,15 +299,16 @@ int __cdecl CYahooProto::OnSettingChanged(WPARAM wParam, LPARAM lParam) bool CYahooProto::IsMyContact(HANDLE hContact) { - if (!hContact) return false; + if (!hContact) + return false; char* szProto = GetContactProto(hContact); return szProto && !strcmp(szProto, m_szModuleName); } -char* YAHOO_GetContactName( HANDLE hContact ) +char* YAHOO_GetContactName(HANDLE hContact) { - return ( char* )CallService( MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) hContact, 0 ); + return (char*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, 0); } extern PLUGININFOEX pluginInfo; @@ -347,5 +328,5 @@ void SetButtonCheck(HWND hwndDlg, int CtrlID, BOOL bCheck) { HWND hwndCtrl = GetDlgItem(hwndDlg, CtrlID); - Button_SetCheck(hwndCtrl, (bCheck)?BST_CHECKED:BST_UNCHECKED); + Button_SetCheck(hwndCtrl, (bCheck) ? BST_CHECKED : BST_UNCHECKED); } diff --git a/protocols/Yahoo/src/yahoo.cpp b/protocols/Yahoo/src/yahoo.cpp index a99136403a..1e3a0984ad 100644 --- a/protocols/Yahoo/src/yahoo.cpp +++ b/protocols/Yahoo/src/yahoo.cpp @@ -71,7 +71,7 @@ char * yahoo_status_code(enum yahoo_status s) int i; for(i=0; yahoo_status_codes[i].label; i++) - if(yahoo_status_codes[i].id == s) + if (yahoo_status_codes[i].id == s) return yahoo_status_codes[i].label; return "Unknown"; @@ -320,11 +320,11 @@ HANDLE CYahooProto::add_buddy( const char *yahoo_id, const char *yahoo_name, int hContact = getbuddyH(yid); if (hContact != NULL) { LOG(("[add_buddy] Found buddy id: %s, handle: %p", yid, hContact)); - if ( !( flags & PALF_TEMPORARY ) && DBGetContactSettingByte( hContact, "CList", "NotOnList", 1 )) + if ( !( flags & PALF_TEMPORARY ) && db_get_b( hContact, "CList", "NotOnList", 1 )) { LOG(("[add_buddy] Making Perm id: %s, flags: %lu", yahoo_id, flags)); - DBDeleteContactSetting( hContact, "CList", "NotOnList" ); - DBDeleteContactSetting( hContact, "CList", "Hidden" ); + DBDeleteContactSetting( hContact, "CList", "NotOnList"); + DBDeleteContactSetting( hContact, "CList", "Hidden"); } @@ -334,8 +334,8 @@ HANDLE CYahooProto::add_buddy( const char *yahoo_id, const char *yahoo_name, int //not already there: add LOG(("[add_buddy] Adding buddy id: %s (Nick: %s), flags: %lu", yid, yahoo_name, flags)); - hContact = ( HANDLE )CallService( MS_DB_CONTACT_ADD, 0, 0 ); - CallService( MS_PROTO_ADDTOCONTACT, ( WPARAM )hContact,( LPARAM )m_szModuleName ); + hContact = ( HANDLE )CallService( MS_DB_CONTACT_ADD, 0, 0); + CallService( MS_PROTO_ADDTOCONTACT, ( WPARAM )hContact,(LPARAM)m_szModuleName ); SetString( hContact, YAHOO_LOGINID, yid ); Set_Protocol( hContact, protocol ); @@ -345,8 +345,8 @@ HANDLE CYahooProto::add_buddy( const char *yahoo_id, const char *yahoo_name, int SetStringUtf( hContact, "Nick", yahoo_id ); if (flags & PALF_TEMPORARY ) { - DBWriteContactSettingByte( hContact, "CList", "NotOnList", 1 ); - DBWriteContactSettingByte( hContact, "CList", "Hidden", 1 ); + db_set_b( hContact, "CList", "NotOnList", 1 ); + db_set_b( hContact, "CList", "Hidden", 1 ); } FREE(yid); @@ -407,15 +407,15 @@ void CYahooProto::ext_status_changed(const char *who, int protocol, int stat, co SetWord(hContact, "YAway", away); SetWord(hContact, "Mobile", mobile); - if(msg) { + if (msg) { YAHOO_DEBUGLOG("[ext_status_changed] %s custom message '%s'", who, msg); if (utf8) - DBWriteContactSettingStringUtf( hContact, "CList", "StatusMsg", msg); + db_set_utf( hContact, "CList", "StatusMsg", msg); else - DBWriteContactSettingString( hContact, "CList", "StatusMsg", msg); + db_set_s( hContact, "CList", "StatusMsg", msg); } - else DBDeleteContactSetting(hContact, "CList", "StatusMsg" ); + else DBDeleteContactSetting(hContact, "CList", "StatusMsg"); if (stat == YAHOO_STATUS_OFFLINE) { /* @@ -433,7 +433,7 @@ void CYahooProto::ext_status_changed(const char *who, int protocol, int stat, co } } - DBWriteContactSettingDword(hContact, m_szModuleName, "IdleTS", idlets); + db_set_dw(hContact, m_szModuleName, "IdleTS", idlets); } YAHOO_DEBUGLOG("[ext_status_changed] exiting"); @@ -545,23 +545,23 @@ void CYahooProto::ext_status_logon(const char *who, int protocol, int stat, cons } /* Add the client_Version # to the contact DB entry */ - DBWriteContactSettingDword( hContact, m_szModuleName, "ClientVersion", client_version); + db_set_dw( hContact, m_szModuleName, "ClientVersion", client_version); /* Last thing check the checksum and request new one if we need to */ if (buddy_icon == -1) { YAHOO_DEBUGLOG("[ext_status_logon] No avatar information in this packet? Not touching stuff!"); } else { // we got some avatartype info - DBWriteContactSettingByte(hContact, m_szModuleName, "AvatarType", buddy_icon); + db_set_b(hContact, m_szModuleName, "AvatarType", buddy_icon); if (cksum == 0 || cksum == -1) { // no avatar - DBWriteContactSettingDword(hContact, m_szModuleName, "PictCK", 0); - } else if (DBGetContactSettingDword(hContact, m_szModuleName,"PictCK", 0) != (unsigned)cksum) { + db_set_dw(hContact, m_szModuleName, "PictCK", 0); + } else if (db_get_dw(hContact, m_szModuleName,"PictCK", 0) != (unsigned)cksum) { //char szFile[MAX_PATH]; // Save new Checksum - DBWriteContactSettingDword(hContact, m_szModuleName, "PictCK", cksum); + db_set_dw(hContact, m_szModuleName, "PictCK", cksum); // Need to delete the Avatar File!! //GetAvatarFileName(hContact, szFile, sizeof szFile, 0); @@ -605,8 +605,9 @@ void CYahooProto::ext_got_calendar(const char *url, int type, const char *msg, i { LOG(("[ext_got_calendar] URL:%s type: %d msg: %s svc: %d", url, type, msg, svc)); - if (!ShowPopup( Translate("Calendar Reminder"), msg, url)) - ShowNotification(Translate("Calendar Reminder"), msg, NIIF_INFO); + mir_ptr tszMsg(mir_utf8decodeT(msg)); + if (!ShowPopup( TranslateT("Calendar Reminder"), tszMsg, url)) + ShowNotification(TranslateT("Calendar Reminder"), tszMsg, NIIF_INFO); } void CYahooProto::ext_got_stealth(char *stealthlist) @@ -705,7 +706,7 @@ void CYahooProto::ext_got_buddies(YList * buds) } //if (bud->auth) - // YAHOO_DEBUGLOG( "Auth request waiting for: %s", bud->id ); + // YAHOO_DEBUGLOG("Auth request waiting for: %s", bud->id ); SetByte(hContact, "YAuth", bud->auth); if (bud->real_name) { @@ -750,14 +751,17 @@ void CYahooProto::ext_rejected(const char *who, const char *msg) /* * Make sure the contact is temporary so we could delete it w/o extra traffic */ - DBWriteContactSettingByte( hContact, "CList", "NotOnList", 1 ); + db_set_b( hContact, "CList", "NotOnList", 1 ); CallService( MS_DB_CONTACT_DELETE, (WPARAM) hContact, 0); } else LOG(("[ext_rejected] Buddy not on our buddy list")); - char buff[1024]; - mir_snprintf(buff, sizeof(buff), Translate("%s has rejected your request and sent the following message:"), who); - MessageBoxA( NULL, msg, buff, MB_OK | MB_ICONINFORMATION ); + mir_ptr tszWho( mir_utf8decodeT(who)); + mir_ptr tszMsg( mir_utf8decodeT(msg)); + + TCHAR buff[1024]; + mir_sntprintf(buff, SIZEOF(buff), TranslateT("%s has rejected your request and sent the following message:"), (TCHAR*)tszWho); + MessageBox(NULL, tszMsg, buff, MB_OK | MB_ICONINFORMATION ); } void CYahooProto::ext_buddy_added(char *myid, char *who, char *group, int status, int auth) @@ -770,16 +774,16 @@ void CYahooProto::ext_buddy_added(char *myid, char *who, char *group, int status case 0: /* we are ok */ case 2: /* seems that we ok, not sure what this means.. we already on buddy list? */ case 40: /* When adding MSN Live contacts we get this one? */ - DBDeleteContactSetting( hContact, "CList", "NotOnList" ); - DBDeleteContactSetting( hContact, "CList", "Hidden" ); + DBDeleteContactSetting( hContact, "CList", "NotOnList"); + DBDeleteContactSetting( hContact, "CList", "Hidden"); break; case 1: /* invalid ID? */ case 3: /* invalid ID */ if (hContact != NULL) { - ShowPopup( "Invalid Contact", "The id you tried to add is invalid.", NULL); + ShowPopup( TranslateT("Invalid Contact"), TranslateT("The id you tried to add is invalid."), NULL); /* Make it TEMP first, we don't want to send any extra packets for FALSE ids */ - DBWriteContactSettingByte( hContact, "CList", "NotOnList", 1 ); + db_set_b( hContact, "CList", "NotOnList", 1 ); CallService( MS_DB_CONTACT_DELETE, (WPARAM) hContact, 0); } break; @@ -787,9 +791,9 @@ void CYahooProto::ext_buddy_added(char *myid, char *who, char *group, int status default: /* ??? */ if (hContact != NULL) { - ShowPopup( "Invalid Contact", "Unknown Error??.", NULL); + ShowPopup( TranslateT("Invalid Contact"), TranslateT("Unknown Error??."), NULL); /* Make it TEMP first, we don't want to send any extra packets for FALSE ids */ - DBWriteContactSettingByte( hContact, "CList", "NotOnList", 1 ); + db_set_b( hContact, "CList", "NotOnList", 1 ); CallService( MS_DB_CONTACT_DELETE, (WPARAM) hContact, 0); } @@ -1002,31 +1006,37 @@ void CYahooProto::ext_mail_notify(const char *from, const char *subj, int cnt) if (cnt > 0) { SkinPlaySound("mail"); - if (!GetByte( "DisableYahoomail", 0)) { - char z[MAX_SECONDLINE], title[MAX_CONTACTNAME]; + if (!GetByte("DisableYahoomail", 0)) { + TCHAR z[MAX_SECONDLINE], title[MAX_CONTACTNAME]; if (from == NULL) { - snprintf(title, sizeof(title), "%s: %s", m_szModuleName, Translate("New Mail")); - snprintf(z, sizeof(z), Translate("You Have %i unread msgs"), cnt); - } else { - snprintf(title, sizeof(title), Translate("New Mail (%i msgs)"), cnt); - snprintf(z, sizeof(z), Translate("From: %s\nSubject: %s"), from, subj); + mir_sntprintf(title, SIZEOF(title), _T("%s: %s"), m_tszUserName, TranslateT("New Mail")); + mir_sntprintf(z, SIZEOF(z), TranslateT("You Have %i unread msgs"), cnt); + } + else { + mir_sntprintf(title, SIZEOF(title), TranslateT("New Mail (%i msgs)"), cnt); + + mir_ptr tszFrom( mir_utf8decodeT(from)); + mir_ptr tszSubj( mir_utf8decodeT(subj)); + mir_sntprintf(z, SIZEOF(z), TranslateT("From: %s\nSubject: %s"), (TCHAR*)tszFrom, (TCHAR*)tszSubj); } - if(!ShowPopup( title, z, "http://mail.yahoo.com" )) + if ( !ShowPopup(title, z, "http://mail.yahoo.com")) ShowNotification(title, z, NIIF_INFO); } } m_unreadMessages = cnt; - SendBroadcast( NULL, ACKTYPE_EMAIL, ACKRESULT_STATUS, NULL, 0 ); + SendBroadcast( NULL, ACKTYPE_EMAIL, ACKRESULT_STATUS, NULL, 0); } void CYahooProto::ext_system_message(const char *me, const char *who, const char *msg) { LOG(("[ext_system_message] System Message to: %s from: %s msg: %s", me, who, msg)); - - ShowPopup( (who != NULL) ? who : "Yahoo System Message", msg, NULL); + + mir_ptr tszWho( mir_utf8decodeT(who)); + mir_ptr tszMsg( mir_utf8decodeT(msg)); + ShowPopup((who != NULL) ? tszWho : TranslateT("Yahoo System Message"), tszMsg, NULL); } void CYahooProto::ext_got_identities(const char *nick, const char *fname, const char *lname, YList * ids) @@ -1084,7 +1094,8 @@ void CYahooProto::ext_got_ping(const char *errormsg) if (errormsg) { LOG(("[ext_got_ping] Error msg: %s", errormsg)); - ShowError(Translate("Yahoo Ping Error"), errormsg); + mir_ptr tszMsg( mir_utf8decodeT(errormsg)); + ShowError( TranslateT("Yahoo Ping Error"), tszMsg); return; } @@ -1106,7 +1117,7 @@ void CYahooProto::ext_got_ping(const char *errormsg) /** * Now load the YAB. */ - if (GetByte( "UseYAB", 1 )) { + if (GetByte("UseYAB", 1 )) { LOG(("[ext_got_ping] GET YAB")); if (m_iStatus != ID_STATUS_OFFLINE) mir_forkthread(yahoo_get_yab_thread, (void *)m_id); @@ -1118,11 +1129,11 @@ void CYahooProto::ext_got_ping(const char *errormsg) void CYahooProto::ext_login_response(int succ, const char *url) { - char buff[1024]; + TCHAR buff[1024]; LOG(("[ext_login_response] succ: %d, url: %s", succ, url)); - if(succ == YAHOO_LOGIN_OK) { + if (succ == YAHOO_LOGIN_OK) { const char *c; m_status = yahoo_current_status(m_id); @@ -1136,34 +1147,34 @@ void CYahooProto::ext_login_response(int succ, const char *url) return; } - if(succ == YAHOO_LOGIN_UNAME) { - snprintf(buff, sizeof(buff), Translate("Could not log into Yahoo service - username not recognised. Please verify that your username is correctly typed.")); + if (succ == YAHOO_LOGIN_UNAME) { + mir_sntprintf(buff, SIZEOF(buff), TranslateT("Could not log into Yahoo service - username not recognised. Please verify that your username is correctly typed.")); ProtoBroadcastAck(m_szModuleName, NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_BADUSERID); } - else if(succ == YAHOO_LOGIN_PASSWD) { - snprintf(buff, sizeof(buff), Translate("Could not log into Yahoo service - password incorrect. Please verify that your username and password are correctly typed.")); + else if (succ == YAHOO_LOGIN_PASSWD) { + mir_sntprintf(buff, SIZEOF(buff), TranslateT("Could not log into Yahoo service - password incorrect. Please verify that your username and password are correctly typed.")); ProtoBroadcastAck(m_szModuleName, NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_WRONGPASSWORD); } - else if(succ == YAHOO_LOGIN_LOCK) { - snprintf(buff, sizeof(buff), Translate("Could not log into Yahoo service. Your account has been locked.\nVisit %s to reactivate it."), url); + 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); } - else if(succ == YAHOO_LOGIN_DUPL) { - snprintf(buff, sizeof(buff), Translate("You have been logged out of the yahoo service, possibly due to a duplicate login.")); + 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.")); ProtoBroadcastAck(m_szModuleName, NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_OTHERLOCATION); } - else if(succ == YAHOO_LOGIN_LOGOFF) { - //snprintf(buff, sizeof(buff), Translate("You have been logged out of the yahoo service.")); + else if (succ == YAHOO_LOGIN_LOGOFF) { + //mir_sntprintf(buff, SIZEOF(buff), TranslateT("You have been logged out of the yahoo service.")); //ProtoBroadcastAck(m_szModuleName, NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_OTHERLOCATION); return; // we logged out.. so just sign-off.. } - else if(succ == -1) { + else if (succ == -1) { /// Can't Connect or got disconnected. if (m_iStatus == ID_STATUS_CONNECTING) - snprintf(buff, sizeof(buff), Translate("Could not connect to the Yahoo service. Check your server/port and proxy settings.")); + mir_sntprintf(buff, SIZEOF(buff), TranslateT("Could not connect to the Yahoo service. Check your server/port and proxy settings.")); else return; } - else snprintf(buff, sizeof(buff),Translate("Could not log in, unknown reason: %d."), succ); + else mir_sntprintf(buff, SIZEOF(buff), TranslateT("Could not log in, unknown reason: %d."), succ); DBDeleteContactSetting(NULL, m_szModuleName, YAHOO_PWTOKEN); @@ -1172,7 +1183,7 @@ void CYahooProto::ext_login_response(int succ, const char *url) /* * Show Error Message */ - ShowError(Translate("Yahoo Login Error"), buff); + ShowError( TranslateT("Yahoo Login Error"), buff); /* * Stop the server thread and let Server cleanup @@ -1182,44 +1193,45 @@ void CYahooProto::ext_login_response(int succ, const char *url) void CYahooProto::ext_error(const char *err, int fatal, int num) { - char buff[1024]; + mir_ptr tszErr( mir_utf8decodeT(err)); + TCHAR buff[1024]; LOG(("[ext_error] Error: fatal: %d, num: %d, err: %s", fatal, num, err)); switch(num) { case E_UNKNOWN: - snprintf(buff, sizeof(buff), Translate("Unknown error %s"), err); + mir_sntprintf(buff, SIZEOF(buff), TranslateT("Unknown error %s"), (TCHAR*)tszErr); break; case E_CUSTOM: - snprintf(buff, sizeof(buff), Translate("Custom error %s"), err); + mir_sntprintf(buff, SIZEOF(buff), TranslateT("Custom error %s"), (TCHAR*)tszErr); break; case E_CONFNOTAVAIL: - snprintf(buff, sizeof(buff), Translate("%s is not available for the conference"), err); + mir_sntprintf(buff, SIZEOF(buff), TranslateT("%s is not available for the conference"), (TCHAR*)tszErr); break; case E_IGNOREDUP: - snprintf(buff, sizeof(buff), Translate("%s is already ignored"), err); + mir_sntprintf(buff, SIZEOF(buff), TranslateT("%s is already ignored"), (TCHAR*)tszErr); break; case E_IGNORENONE: - snprintf(buff, sizeof(buff), Translate("%s is not in the ignore list"), err); + mir_sntprintf(buff, SIZEOF(buff), TranslateT("%s is not in the ignore list"), (TCHAR*)tszErr); break; case E_IGNORECONF: - snprintf(buff, sizeof(buff), Translate("%s is in buddy list - cannot ignore "), err); + mir_sntprintf(buff, SIZEOF(buff), TranslateT("%s is in buddy list - cannot ignore "), (TCHAR*)tszErr); break; case E_SYSTEM: - snprintf(buff, sizeof(buff), Translate("System Error: %s"), err); + mir_sntprintf(buff, SIZEOF(buff), TranslateT("System Error: %s"), (TCHAR*)tszErr); break; case E_CONNECTION: - snprintf(buff, sizeof(buff), Translate("Server Connection Error: %s"), err); - YAHOO_DEBUGLOG("Error: %s", buff); + mir_sntprintf(buff, SIZEOF(buff), TranslateT("Server Connection Error: %s"), (TCHAR*)tszErr); + YAHOO_DEBUGLOG("Error: %S", buff); return; } - YAHOO_DEBUGLOG("Error: %s", buff); + YAHOO_DEBUGLOG("Error: %S", buff); /* * Show Error Message */ - ShowError(Translate("Yahoo Error"), buff); + ShowError( TranslateT("Yahoo Error"), buff); } extern HANDLE g_hNetlibUser; @@ -1350,7 +1362,7 @@ void CYahooProto::ext_remove_handler(unsigned int tag) for(l = m_connections; l; l = y_list_next(l)) { struct _conn *c = ( _conn* )l->data; - if(c->tag == tag) { + if (c->tag == tag) { /* don't actually remove it, just mark it for removal */ /* we'll remove when we start the next poll cycle */ LOG(("Marking id:%d fd:%d tag:%d for removal", c->id, c->fd, c->tag)); @@ -1384,9 +1396,9 @@ static void connect_complete(void *data, int source, yahoo_input_condition condi //tSelect.dwTimeout = T->mGatewayTimeout * 1000; tSelect.dwTimeout = 1; tSelect.hReadConns[ 0 ] = ( HANDLE )source; - error = CallService( MS_NETLIB_SELECT, 0, ( LPARAM )&tSelect ); + error = CallService( MS_NETLIB_SELECT, 0, (LPARAM)&tSelect ); - if(error) { + if (error) { //close(source); Netlib_CloseHandle((HANDLE)source); source = -1; @@ -1403,18 +1415,18 @@ void yahoo_callback(struct _conn *c, yahoo_input_condition cond) int ret=1; //LOG(("[yahoo_callback] id: %d, fd: %d tag: %d", c->id, c->fd, c->tag)); - if(c->id < 0) { + if (c->id < 0) { connect_complete(c->data, c->fd, cond); } else if (c->fd > 0) { - if(cond & YAHOO_INPUT_READ) + if (cond & YAHOO_INPUT_READ) ret = yahoo_read_ready(c->id, c->fd, c->data); - if(ret>0 && cond & YAHOO_INPUT_WRITE) + if (ret>0 && cond & YAHOO_INPUT_WRITE) ret = yahoo_write_ready(c->id, c->fd, c->data); if (ret == -1) { LOG(("Yahoo read error (%d): %s", errno, strerror(errno))); - } else if(ret == 0) + } else if (ret == 0) LOG(("Yahoo read error: Server closed socket")); } @@ -1471,7 +1483,7 @@ char * CYahooProto::ext_send_https_request(struct yahoo_data *yd, const char *ho nlhr.headers[2].szValue = "close"; /*"Keep-Alive";*/ nlhrReply=(NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION,(WPARAM)g_hNetlibUser,(LPARAM)&nlhr); - if(nlhrReply) { + if (nlhrReply) { if (nlhrReply->resultCode == 200 && nlhrReply->pData != NULL) { result = strdup(nlhrReply->pData); @@ -1533,7 +1545,7 @@ void CYahooProto::ext_login(enum yahoo_status login_mode) nlhr.szUrl = z; nlhrReply=(NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION,(WPARAM)g_hNetlibUser,(LPARAM)&nlhr); - if(nlhrReply) { + if (nlhrReply) { if (nlhrReply->resultCode == 200 && nlhrReply->pData != NULL) { char *c = strstr(nlhrReply->pData,"CS_IP_ADDRESS="); @@ -1551,7 +1563,7 @@ void CYahooProto::ext_login(enum yahoo_status login_mode) LOG(("Got Host: %s", host)); } } else { - LOG(( "Problem retrieving a response from VIP server." )); + LOG(("Problem retrieving a response from VIP server.")); } CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)nlhrReply); @@ -1600,7 +1612,7 @@ void CYahooProto::ext_login(enum yahoo_status login_mode) if (m_id <= 0) { LOG(("Could not connect to Yahoo server. Please verify that you are connected to the net and the pager host and port are correctly entered.")); - ShowError(Translate("Yahoo Login Error"), Translate("Could not connect to Yahoo server. Please verify that you are connected to the net and the pager host and port are correctly entered.")); + ShowError( TranslateT("Yahoo Login Error"), TranslateT("Could not connect to Yahoo server. Please verify that you are connected to the net and the pager host and port are correctly entered.")); return; } diff --git a/protocols/Yahoo/src/yahoo.h b/protocols/Yahoo/src/yahoo.h index 001e1a2b3b..f60556bf97 100644 --- a/protocols/Yahoo/src/yahoo.h +++ b/protocols/Yahoo/src/yahoo.h @@ -78,7 +78,7 @@ extern "C" extern int do_yahoo_debug; -#define LOG(x) if(do_yahoo_debug) { YAHOO_DEBUGLOG("%s:%d: ", __FILE__, __LINE__); \ +#define LOG(x) if (do_yahoo_debug) { YAHOO_DEBUGLOG("%s:%d: ", __FILE__, __LINE__); \ YAHOO_DEBUGLOG x; \ YAHOO_DEBUGLOG(" ");} @@ -95,7 +95,7 @@ extern int do_yahoo_debug; #define STYLE_DEFAULTBGCOLOUR RGB(173,206,247) -#define LocalEventUnhook(hook) if(hook) UnhookEvent(hook) +#define LocalEventUnhook(hook) if (hook) UnhookEvent(hook) struct _conn { unsigned int tag; -- cgit v1.2.3