From aa7e0aa1859e017780d250d3c7b8190f309b450b Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 26 Sep 2012 11:32:52 +0000 Subject: final fix for EVENTTYPE_ADDED git-svn-id: http://svn.miranda-ng.org/main/trunk@1663 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/IcqOscarJ/fam_04message.cpp | 48 ++++++++++++++++----------------- protocols/IcqOscarJ/fam_13servclist.cpp | 42 ++++++++++++++--------------- src/modules/ignore/ignore.cpp | 20 +++++++------- 3 files changed, 54 insertions(+), 56 deletions(-) diff --git a/protocols/IcqOscarJ/fam_04message.cpp b/protocols/IcqOscarJ/fam_04message.cpp index 1a4974e998..7d1bc6a829 100644 --- a/protocols/IcqOscarJ/fam_04message.cpp +++ b/protocols/IcqOscarJ/fam_04message.cpp @@ -417,7 +417,7 @@ void CIcqProto::handleRecvServMsgType1(BYTE *buf, WORD wLen, DWORD dwUin, char * else NetLog_Server("Failed to read TLV chain in message (format 1)"); } - else + else NetLog_Server("Unsupported TLV (%u) in message (format %u)", wTLVType, 1); SAFE_FREE((void**)&pMsgTLV); @@ -1117,7 +1117,7 @@ void CIcqProto::handleRecvServMsgContacts(BYTE *buf, WORD wLen, DWORD dwUin, cha SAFE_FREE(&szUid); } - else + else { if (wContactsGroup) valid = 0; break; @@ -1188,7 +1188,7 @@ void CIcqProto::handleRecvServMsgContacts(BYTE *buf, WORD wLen, DWORD dwUin, cha iContact++; if (iContact >= nContacts) break; } - else + else break; wContactsGroup--; @@ -1463,7 +1463,7 @@ int CIcqProto::unpackPluginTypeId(BYTE **pBuffer, WORD *pwLen, int *pTypeId, WOR DWORD q1,q2,q3,q4; WORD qt; - if (wLen < 24) + if (wLen < 24) return 0; // Failure unpackLEWord(pBuffer, &wInfoLen); @@ -1592,7 +1592,7 @@ void packPluginTypeId(icq_packet *packet, int nTypeID) packDWord(packet, 0x00000000); packDWord(packet, 0x00000000); packDWord(packet, 0x00000000); - packByte(packet, 0x00); + packByte(packet, 0x00); break; @@ -1610,7 +1610,7 @@ void packPluginTypeId(icq_packet *packet, int nTypeID) packDWord(packet, 0x00000000); packDWord(packet, 0x00000000); packDWord(packet, 0x00000000); - packByte(packet, 0x00); + packByte(packet, 0x00); break; @@ -1627,7 +1627,7 @@ void packPluginTypeId(icq_packet *packet, int nTypeID) packDWord(packet, 0x00000000); packDWord(packet, 0x00000000); packDWord(packet, 0x00000000); - packByte(packet, 0x00); + packByte(packet, 0x00); break; } @@ -1752,7 +1752,7 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp, } char *szMsg = (char *)SAFE_MALLOC(wMsgLen + 1); - if (wMsgLen > 0) + if (wMsgLen > 0) { memcpy(szMsg, pMsg, wMsgLen); pMsg += wMsgLen; @@ -1956,16 +1956,16 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp, hContact = HContactFromUIN(dwUin, &bAdded); /*blob is: uin(DWORD), hcontact(HANDLE), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ) */ - cbBlob=sizeof(DWORD)+sizeof(HANDLE)+strlennull(pszMsgField[0])+strlennull(pszMsgField[1])+strlennull(pszMsgField[2])+strlennull(pszMsgField[3])+4; + cbBlob=sizeof(DWORD)*2+strlennull(pszMsgField[0])+strlennull(pszMsgField[1])+strlennull(pszMsgField[2])+strlennull(pszMsgField[3])+4; pCurBlob=pBlob=(PBYTE)_alloca(cbBlob); - memcpy(pCurBlob,&dwUin,sizeof(DWORD)); pCurBlob+=sizeof(DWORD); - memcpy(pCurBlob,&hContact,sizeof(HANDLE)); pCurBlob+=sizeof(HANDLE); - strcpy((char *)pCurBlob,pszMsgField[0]); pCurBlob+=strlennull((char *)pCurBlob)+1; - strcpy((char *)pCurBlob,pszMsgField[1]); pCurBlob+=strlennull((char *)pCurBlob)+1; - strcpy((char *)pCurBlob,pszMsgField[2]); pCurBlob+=strlennull((char *)pCurBlob)+1; + *(DWORD*)pCurBlob = dwUin; pCurBlob += sizeof(DWORD); + *(DWORD*)pCurBlob = DWORD(hContact); pCurBlob += sizeof(DWORD); + strcpy((char *)pCurBlob,pszMsgField[0]); pCurBlob += strlennull((char *)pCurBlob)+1; + strcpy((char *)pCurBlob,pszMsgField[1]); pCurBlob += strlennull((char *)pCurBlob)+1; + strcpy((char *)pCurBlob,pszMsgField[2]); pCurBlob += strlennull((char *)pCurBlob)+1; strcpy((char *)pCurBlob,pszMsgField[3]); - AddEvent(NULL, EVENTTYPE_ADDED, dwTimestamp, 0, cbBlob, pBlob); + AddEvent(NULL, EVENTTYPE_ADDED, dwTimestamp, 0, cbBlob, pBlob); } break; @@ -2152,10 +2152,10 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp, char **szMsg = MirandaStatusToAwayMsg(AwayMsgTypeToStatus(type)); if (szMsg) { - struct rates_status_message_response: public rates_queue_item + struct rates_status_message_response: public rates_queue_item { protected: - virtual rates_queue_item* copyItem(rates_queue_item *aDest = NULL) + virtual rates_queue_item* copyItem(rates_queue_item *aDest = NULL) { rates_status_message_response *pDest = (rates_status_message_response*)aDest; if (!pDest) @@ -2174,10 +2174,10 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp, rates_status_message_response(CIcqProto *ppro, WORD wGroup): rates_queue_item(ppro, wGroup) { }; virtual ~rates_status_message_response() { }; - virtual void execute() + virtual void execute() { char **pszMsg = ppro->MirandaStatusToAwayMsg(AwayMsgTypeToStatus(nMsgType)); - if (bExtended) + if (bExtended) ppro->icq_sendAwayMsgReplyServExt(dwUin, szUid, dwMsgID1, dwMsgID2, wCookie, wVersion, nMsgType, pszMsg); else if (dwUin) ppro->icq_sendAwayMsgReplyServ(dwUin, dwMsgID1, dwMsgID2, wCookie, wVersion, (BYTE)nMsgType, pszMsg); @@ -2284,7 +2284,7 @@ void CIcqProto::handleRecvMsgResponse(BYTE *buf, WORD wLen, WORD wFlags, DWORD d unpackLEWord(&buf, &wLength); wLen -= 2; } - else + else wLength = 0; if (wLength == 0x1b && pCookieData->bMessageType != MTYPE_REVERSE_REQUEST) @@ -2386,7 +2386,7 @@ void CIcqProto::handleRecvMsgResponse(BYTE *buf, WORD wLen, WORD wFlags, DWORD d wLen -= 2; szMsg = (char *)_alloca(wMsgLen + 1); szMsg[wMsgLen] = '\0'; - if (wMsgLen > 0) + if (wMsgLen > 0) { memcpy(szMsg, buf, wMsgLen); buf += wMsgLen; @@ -2424,7 +2424,7 @@ void CIcqProto::handleRecvMsgResponse(BYTE *buf, WORD wLen, WORD wFlags, DWORD d wLen -= wMsgLen; // This packet is malformed. Possibly a file accept from Miranda IM 0.1.2.1 - if (wLen < 20) + if (wLen < 20) { ReleaseCookie(dwCookie); return; @@ -2645,7 +2645,7 @@ void CIcqProto::handleRecvServMsgError(BYTE *buf, WORD wLen, WORD wFlags, DWORD break; case 0x0004: // Recipient is not logged in (resend in a offline message) - if (pCookieData->bMessageType == MTYPE_PLAIN) + if (pCookieData->bMessageType == MTYPE_PLAIN) { if (pCookieData->isOffline) { // offline failed - most probably to AIM contact @@ -2915,7 +2915,7 @@ void CIcqProto::handleOffineMessagesReply(BYTE *buf, WORD wLen, WORD wFlags, DWO NetLog_Server("End of offline msgs, %u received", cookie->nMessages); if (cookie->nMissed) { // NASTY WORKAROUND!! - // The ICQ server has a bug that causes offline messages to be received again and again when some + // The ICQ server has a bug that causes offline messages to be received again and again when some // missed message notification is present (most probably it is not processed correctly and causes // the server to fail the purging process); try to purge them using the old offline messages // protocol. 2008/05/21 diff --git a/protocols/IcqOscarJ/fam_13servclist.cpp b/protocols/IcqOscarJ/fam_13servclist.cpp index 1e92b034c9..5df30ee5ec 100644 --- a/protocols/IcqOscarJ/fam_13servclist.cpp +++ b/protocols/IcqOscarJ/fam_13servclist.cpp @@ -374,7 +374,7 @@ void CIcqProto::handleServerCListAck(cookie_servlist_action* sc, WORD wError) { switch (sc->dwAction) { - case SSA_VISIBILITY: + case SSA_VISIBILITY: { if (wError) NetLog_Server("Server visibility update failed, error %d", wError); @@ -390,7 +390,7 @@ void CIcqProto::handleServerCListAck(cookie_servlist_action* sc, WORD wError) } break; } - case SSA_PRIVACY_ADD: + case SSA_PRIVACY_ADD: { if (wError) { @@ -399,7 +399,7 @@ void CIcqProto::handleServerCListAck(cookie_servlist_action* sc, WORD wError) } break; } - case SSA_PRIVACY_REMOVE: + case SSA_PRIVACY_REMOVE: { if (wError) { @@ -520,7 +520,7 @@ void CIcqProto::handleServerCListAck(cookie_servlist_action* sc, WORD wError) setSettingWord(sc->hContact, DBSETTING_SERVLIST_ID, 0); // clear the values setSettingWord(sc->hContact, DBSETTING_SERVLIST_GROUP, 0); - FreeServerID(sc->wContactId, SSIT_ITEM); + FreeServerID(sc->wContactId, SSIT_ITEM); servlistPendingRemoveContact(sc->hContact, 0, sc->wGroupId, PENDING_RESULT_SUCCESS); @@ -703,7 +703,7 @@ void CIcqProto::handleServerCListAck(cookie_servlist_action* sc, WORD wError) servlistPendingRemoveGroup(sc->szGroup, sc->wGroupId, PENDING_RESULT_FAILED); } else - { + { setServListGroupName(sc->wGroupId, sc->szGroupName); removeGroupPathLinks(sc->wGroupId); { // add group to known @@ -955,7 +955,7 @@ void CIcqProto::handleServerCListReply(BYTE *buf, WORD wLen, WORD wFlags, server szLocalGroup = null_strdup(DEFAULT_SS_GROUP); } - if (strcmpnull(szActiveSrvGroup, szLocalGroup) && + if (strcmpnull(szActiveSrvGroup, szLocalGroup) && (strlennull(szActiveSrvGroup) >= strlennull(szLocalGroup) || _strnicmp(szActiveSrvGroup, szLocalGroup, strlennull(szLocalGroup)))) { // contact moved to new group or sub-group or not to master group bRegroup = 1; @@ -1264,7 +1264,7 @@ void CIcqProto::handleServerCListReply(BYTE *buf, WORD wLen, WORD wFlags, server } break; - case SSI_ITEM_IGNORE: + case SSI_ITEM_IGNORE: { /* item on ignore list */ /* wItemId not related to contact ID */ @@ -1430,7 +1430,7 @@ void CIcqProto::handleServerCListReply(BYTE *buf, WORD wLen, WORD wFlags, server { // we got empty serv-list, create master group cookie_servlist_action* ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action)); if (ack) - { + { DWORD dwCookie; ack->dwAction = SSA_GROUP_UPDATE; @@ -1440,7 +1440,7 @@ void CIcqProto::handleServerCListReply(BYTE *buf, WORD wLen, WORD wFlags, server } } // serv-list sync finished, clear just added contacts - FlushJustAddedContacts(); + FlushJustAddedContacts(); } else { @@ -1453,7 +1453,7 @@ void CIcqProto::handleServerCListItemAdd(const char *szRecordName, WORD wGroupId { if (wItemType == SSI_ITEM_IMPORTTIME) { - if (pItemData) + if (pItemData) { setSettingDword(NULL, "ImportTS", pItemData->getDWord(SSI_TLV_TIMESTAMP, 1)); setSettingWord(NULL, "SrvImportID", wItemId); @@ -1475,7 +1475,7 @@ void CIcqProto::handleServerCListItemUpdate(const char *szRecordName, WORD wGrou if (hContact != INVALID_HANDLE_VALUE && wItemType == SSI_ITEM_BUDDY) { // a contact was updated on server - if (pItemData) + if (pItemData) { oscar_tlv* pAuth = pItemData->getTLV(SSI_TLV_AWAITING_AUTH, 1); BYTE bAuth = getSettingByte(hContact, "Auth", 0); @@ -1653,7 +1653,7 @@ void CIcqProto::handleRecvAuthRequest(unsigned char *buf, WORD wLen) nReasonLen = strlennull(szReason); char *temp = (char*)_alloca(nReasonLen + 2); - if (!IsUSASCII(szReason, nReasonLen) && UTF8_IsValid(szReason) && utf8_decode_static(szReason, temp, nReasonLen + 1)) + if (!IsUSASCII(szReason, nReasonLen) && UTF8_IsValid(szReason) && utf8_decode_static(szReason, temp, nReasonLen + 1)) pre.flags |= PREF_UTF; } // Read nick name from DB @@ -1682,7 +1682,7 @@ void CIcqProto::handleRecvAuthRequest(unsigned char *buf, WORD wLen) char *pCurBlob = szBlob; memcpy(pCurBlob, &dwUin, sizeof(DWORD)); pCurBlob += sizeof(DWORD); memcpy(pCurBlob, &hContact, sizeof(HANDLE)); pCurBlob += sizeof(HANDLE); - if (nNickLen) + if (nNickLen) { // if we have nick we add it, otherwise keep trailing zero memcpy(pCurBlob, szNick, nNickLen); pCurBlob += nNickLen; @@ -1729,7 +1729,7 @@ void CIcqProto::handleRecvAdded(unsigned char *buf, WORD wLen) HANDLE hContact = HContactFromUID(dwUin, szUid, &bAdded); - cbBlob=sizeof(DWORD)+sizeof(HANDLE)+4; + cbBlob=sizeof(DWORD)*2+4; if (dwUin) { @@ -1748,9 +1748,9 @@ void CIcqProto::handleRecvAdded(unsigned char *buf, WORD wLen) pCurBlob=pBlob=(PBYTE)_alloca(cbBlob); /*blob is: uin(DWORD), hContact(HANDLE), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ) */ - memcpy(pCurBlob,&dwUin,sizeof(DWORD)); pCurBlob+=sizeof(DWORD); - memcpy(pCurBlob,&hContact,sizeof(HANDLE)); pCurBlob+=sizeof(HANDLE); - if (nNickLen && dwUin) + *(DWORD*)pCurBlob = dwUin; pCurBlob += sizeof(DWORD); + *(DWORD*)pCurBlob = DWORD(hContact); pCurBlob += sizeof(DWORD); + if (nNickLen && dwUin) { // if we have nick we add it, otherwise keep trailing zero memcpy(pCurBlob, szNick, nNickLen); pCurBlob+=nNickLen; @@ -1879,7 +1879,7 @@ void CIcqProto::updateServVisibilityCode(BYTE bCode) } ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action)); - if (!ack) + if (!ack) { NetLog_Server("Cookie alloc failure."); return; // out of memory, go away @@ -1942,7 +1942,7 @@ void CIcqProto::updateServAvatarHash(BYTE *pHash, int size) if (wAvatarID = getSettingWord(NULL, DBSETTING_SERVLIST_AVATAR, 0)) { ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action)); - if (!ack) + if (!ack) { NetLog_Server("Cookie alloc failure."); return; // out of memory, go away @@ -1982,7 +1982,7 @@ void CIcqProto::updateServAvatarHash(BYTE *pHash, int size) } ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action)); - if (!ack) + if (!ack) { NetLog_Server("Cookie alloc failure."); return; // out of memory, go away @@ -2037,7 +2037,7 @@ void CIcqProto::icq_sendServerBeginOperation(int bImport) serverPacketInit(&packet, (WORD)(bImport?14:10)); packFNACHeader(&packet, ICQ_LISTS_FAMILY, ICQ_LISTS_CLI_MODIFYSTART); - if (bImport) packDWord(&packet, 1<<0x10); + if (bImport) packDWord(&packet, 1<<0x10); sendServPacket(&packet); } diff --git a/src/modules/ignore/ignore.cpp b/src/modules/ignore/ignore.cpp index 819cac6070..5cb9f64651 100644 --- a/src/modules/ignore/ignore.cpp +++ b/src/modules/ignore/ignore.cpp @@ -2,8 +2,8 @@ Miranda IM: the free IM client for Microsoft* Windows* -Copyright 2000-2009 Miranda ICQ/IM project, -all portions of this codebase are copyrighted to the people +Copyright 2000-2009 Miranda ICQ/IM project, +all portions of this codebase are copyrighted to the people listed in contributors.txt. This program is free software; you can redistribute it and/or @@ -11,7 +11,7 @@ modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. -This program is distributed in the hope that it will be useful, +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -143,7 +143,7 @@ static void InitialiseItem(HWND hwndList, HANDLE hContact, HANDLE hItem, DWORD p { DWORD mask; int i; - + mask = GetMask(hContact); for (i=0;ieventType == EVENTTYPE_ADDED && dbei->pBlob != NULL) { - HANDLE hContact; - - hContact = *((PHANDLE)(dbei->pBlob+sizeof(DWORD))); - if (CallService(MS_DB_CONTACT_IS, (WPARAM)hContact, 0) && IsIgnored((WPARAM)hContact, IGNOREEVENT_YOUWEREADDED)) + HANDLE hContact = DbGetAuthEventContact(dbei); + if (CallService(MS_DB_CONTACT_IS, (WPARAM)hContact, 0) && IsIgnored((WPARAM)hContact, IGNOREEVENT_YOUWEREADDED)) return 1; } return 0; @@ -429,9 +427,9 @@ static int IgnoreAddedNotify(WPARAM, LPARAM lParam) static int IgnoreModernOptInit(WPARAM wParam, LPARAM) { - static int iBoldControls[] = + static int iBoldControls[] = { - IDC_TXT_TITLE1, IDC_TXT_TITLE2, IDC_TXT_TITLE3, + IDC_TXT_TITLE1, IDC_TXT_TITLE2, IDC_TXT_TITLE3, MODERNOPT_CTRL_LAST }; @@ -460,7 +458,7 @@ int LoadIgnoreModule(void) HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); while (hContact != NULL) { - if ( !CallService(MS_PROTO_ISPROTOONCONTACT, (WPARAM)hContact, (LPARAM)"Ignore")) + if ( !CallService(MS_PROTO_ISPROTOONCONTACT, (WPARAM)hContact, (LPARAM)"Ignore")) CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContact, (LPARAM)"Ignore"); hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); } -- cgit v1.2.3