diff options
Diffstat (limited to 'protocols/IcqOscarJ/src/fam_04message.cpp')
-rw-r--r-- | protocols/IcqOscarJ/src/fam_04message.cpp | 1284 |
1 files changed, 504 insertions, 780 deletions
diff --git a/protocols/IcqOscarJ/src/fam_04message.cpp b/protocols/IcqOscarJ/src/fam_04message.cpp index 538ce9741e..203ac55b95 100644 --- a/protocols/IcqOscarJ/src/fam_04message.cpp +++ b/protocols/IcqOscarJ/src/fam_04message.cpp @@ -32,7 +32,6 @@ void CIcqProto::handleMsgFam(BYTE *pBuffer, WORD wBufferLength, snac_header *pSnacHeader)
{
switch (pSnacHeader->wSubtype) {
-
case ICQ_MSG_SRV_ERROR: // SNAC(4, 0x01)
handleRecvServMsgError(pBuffer, wBufferLength, pSnacHeader->wFlags, pSnacHeader->dwRef);
break;
@@ -71,7 +70,6 @@ void CIcqProto::handleMsgFam(BYTE *pBuffer, WORD wBufferLength, snac_header *pSn }
}
-
static void setMsgChannelParams(CIcqProto *ppro, WORD wChan, DWORD dwFlags)
{
icq_packet packet;
@@ -89,7 +87,6 @@ static void setMsgChannelParams(CIcqProto *ppro, WORD wChan, DWORD dwFlags) ppro->sendServPacket(&packet);
}
-
void CIcqProto::handleReplyICBM(BYTE *buf, WORD wLen, WORD wFlags, DWORD dwRef)
{ // we don't care about the stuff, just change the params
DWORD dwFlags = 0x00000303;
@@ -104,7 +101,6 @@ void CIcqProto::handleReplyICBM(BYTE *buf, WORD wLen, WORD wFlags, DWORD dwRef) setMsgChannelParams(this, 0x0000, dwFlags);
}
-
void CIcqProto::handleRecvServMsg(BYTE *buf, WORD wLen, WORD wFlags, DWORD dwRef)
{
DWORD dwUin;
@@ -114,8 +110,7 @@ void CIcqProto::handleRecvServMsg(BYTE *buf, WORD wLen, WORD wFlags, DWORD dwRef WORD wMessageFormat;
uid_str szUID;
- if (wLen < 11)
- { // just do some basic packet checking
+ if (wLen < 11) { // just do some basic packet checking
debugLogA("Error: Malformed message thru server");
return;
}
@@ -134,14 +129,12 @@ void CIcqProto::handleRecvServMsg(BYTE *buf, WORD wLen, WORD wFlags, DWORD dwRef // Sender UIN
if (!unpackUID(&buf, &wLen, &dwUin, &szUID)) return;
- if (dwUin && IsOnSpammerList(dwUin))
- {
+ if (dwUin && IsOnSpammerList(dwUin)) {
debugLogA("Ignored Message from known Spammer");
return;
}
- if (wLen < 4)
- { // just do some basic packet checking
+ if (wLen < 4) { // just do some basic packet checking
debugLogA("Error: Malformed message thru server");
return;
}
@@ -153,8 +146,7 @@ void CIcqProto::handleRecvServMsg(BYTE *buf, WORD wLen, WORD wFlags, DWORD dwRef // Number of following TLVs, until msg-format dependant TLVs
unpackWord(&buf, &wTLVCount);
wLen -= 2;
- if (wTLVCount > 0)
- {
+ if (wTLVCount > 0) {
// Save current buffer pointer so we can calculate
// how much data we have left after the chain read.
BYTE *pBufStart = buf;
@@ -194,11 +186,9 @@ void CIcqProto::handleRecvServMsg(BYTE *buf, WORD wLen, WORD wFlags, DWORD dwRef default:
debugLogA("Unknown format message thru server - Ref %u, Type: %u, UID: %s", dwRef, wMessageFormat, strUID(dwUin, szUID));
break;
-
}
}
-
char* CIcqProto::convertMsgToUserSpecificUtf(MCONTACT hContact, const char *szMsg)
{
WORD wCP = getWord(hContact, "CodePage", m_wAnsiCodepage);
@@ -210,15 +200,13 @@ char* CIcqProto::convertMsgToUserSpecificUtf(MCONTACT hContact, const char *szMs return usMsg;
}
-
void CIcqProto::handleRecvServMsgType1(BYTE *buf, WORD wLen, DWORD dwUin, char *szUID, DWORD dwMsgID1, DWORD dwMsgID2, DWORD dwRef)
{
WORD wTLVType;
WORD wTLVLen;
BYTE* pMsgTLV;
- if (wLen < 4)
- { // just perform basic structure check
+ if (wLen < 4) { // just perform basic structure check
debugLogA("Message (format %u) - Ignoring empty message", 1);
return;
}
@@ -228,8 +216,7 @@ void CIcqProto::handleRecvServMsgType1(BYTE *buf, WORD wLen, DWORD dwUin, char * debugLogA("Message (format %u) - UID: %s", 1, strUID(dwUin, szUID));
// It must be TLV(2)
- if (wTLVType == 2)
- {
+ if (wTLVType == 2) {
BYTE *pDataBuf = pMsgTLV;
oscar_tlv_chain *pChain = readIntoTLVChain(&pDataBuf, wTLVLen, 0);
@@ -237,42 +224,31 @@ void CIcqProto::handleRecvServMsgType1(BYTE *buf, WORD wLen, DWORD dwUin, char * // TLV(1281): Capability
// TLV(257): This TLV contains the actual message (can be fragmented)
- if (pChain)
- {
- oscar_tlv* pMessageTLV;
- oscar_tlv* pCapabilityTLV;
- WORD wMsgPart = 1;
-
+ if (pChain) {
// Find the capability TLV
- pCapabilityTLV = pChain->getTLV(0x0501, 1);
- if (pCapabilityTLV && (pCapabilityTLV->wLen > 0))
- {
- WORD wDataLen;
- BYTE *pDataBuf;
-
- wDataLen = pCapabilityTLV->wLen;
- pDataBuf = pCapabilityTLV->pData;
-
+ oscar_tlv *pCapabilityTLV = pChain->getTLV(0x0501, 1);
+ if (pCapabilityTLV && (pCapabilityTLV->wLen > 0)) {
+ WORD wDataLen = pCapabilityTLV->wLen;
+ BYTE *pDataBuf = pCapabilityTLV->pData;
if (wDataLen > 0)
debugLogA("Message (format 1) - Message has %d caps.", wDataLen);
}
- else
- debugLogA("Message (format 1) - No message cap.");
+ else debugLogA("Message (format 1) - No message cap.");
- { // Parse the message parts, usually only one 0x0101 TLV containing the message,
+ {
+ // Parse the message parts, usually only one 0x0101 TLV containing the message,
// but in some cases there can be more 0x0101 TLVs containing message parts in
// different encodings (just like the new format of Offline Messages).
DWORD dwRecvTime;
char* szMsg = NULL;
- PROTORECVEVENT pre = {0};
- int bAdded;
+ PROTORECVEVENT pre = { 0 };
+ int bAdded;
MCONTACT hContact = HContactFromUID(dwUin, szUID, &bAdded);
- while (pMessageTLV = pChain->getTLV(0x0101, wMsgPart))
- { // Loop thru all message parts
- if (pMessageTLV->wLen > 4)
- {
+ WORD wMsgPart = 1;
+ while (oscar_tlv *pMessageTLV = pChain->getTLV(0x0101, wMsgPart)) { // Loop thru all message parts
+ if (pMessageTLV->wLen > 4) {
WORD wMsgLen;
BYTE *pMsgBuf;
WORD wEncoding;
@@ -296,36 +272,31 @@ void CIcqProto::handleRecvServMsgType1(BYTE *buf, WORD wLen, DWORD dwUin, char * case 2: // UCS-2
{
- WCHAR* usMsgPart = (WCHAR*)SAFE_MALLOC(wMsgLen + 2);
+ WCHAR *usMsgPart = (WCHAR*)SAFE_MALLOC(wMsgLen + 2);
unpackWideString(&pMsgBuf, usMsgPart, wMsgLen);
- usMsgPart[wMsgLen/sizeof(WCHAR)] = 0;
+ usMsgPart[wMsgLen / sizeof(WCHAR)] = 0;
szMsgPart = make_utf8_string(usMsgPart);
if (!IsUSASCII(szMsgPart, strlennull(szMsgPart)))
bMsgPartUnicode = TRUE;
SAFE_FREE(&usMsgPart);
-
- break;
}
+ break;
case 0: // us-ascii
case 3: // ANSI
default:
- {
- // Copy the message text into a new proper string.
- szMsgPart = (char*)SAFE_MALLOC(wMsgLen + 1);
- memcpy(szMsgPart, pMsgBuf, wMsgLen);
- szMsgPart[wMsgLen] = '\0';
+ // Copy the message text into a new proper string.
+ szMsgPart = (char*)SAFE_MALLOC(wMsgLen + 1);
+ memcpy(szMsgPart, pMsgBuf, wMsgLen);
+ szMsgPart[wMsgLen] = '\0';
- break;
- }
+ break;
}
// Check if the new part is compatible with the message
- if (!pre.flags && bMsgPartUnicode)
- { // make the resulting message utf-8 encoded - need to append utf-8 encoded part
- if (szMsg)
- { // not necessary to convert - appending first part, only set flags
+ if (!pre.flags && bMsgPartUnicode) { // make the resulting message utf-8 encoded - need to append utf-8 encoded part
+ if (szMsg) { // not necessary to convert - appending first part, only set flags
char *szUtfMsg = ansi_to_utf8_codepage(szMsg, getWord(hContact, "CodePage", m_wAnsiCodepage));
SAFE_FREE(&szMsg);
@@ -333,8 +304,7 @@ void CIcqProto::handleRecvServMsgType1(BYTE *buf, WORD wLen, DWORD dwUin, char * }
pre.flags = PREF_UTF;
}
- if (!bMsgPartUnicode && pre.flags == PREF_UTF)
- { // convert message part to utf-8 and append
+ if (!bMsgPartUnicode && pre.flags == PREF_UTF) { // convert message part to utf-8 and append
char *szUtfPart = ansi_to_utf8_codepage((char*)szMsgPart, getWord(hContact, "CodePage", m_wAnsiCodepage));
SAFE_FREE(&szMsgPart);
@@ -348,18 +318,13 @@ void CIcqProto::handleRecvServMsgType1(BYTE *buf, WORD wLen, DWORD dwUin, char * }
wMsgPart++;
}
- if (strlennull(szMsg))
- {
- if (_strnicmp(szMsg, "<html>", 6) == 0)
- { // strip HTML formating from AIM message
+ if (strlennull(szMsg)) {
+ if (_strnicmp(szMsg, "<html>", 6) == 0) // strip HTML formating from AIM message
szMsg = EliminateHtml(szMsg, strlennull(szMsg));
- }
- if (!pre.flags && !IsUSASCII(szMsg, strlennull(szMsg)))
- { // message is Ansi and contains national characters, create Unicode part by codepage
+ if (!pre.flags && !IsUSASCII(szMsg, strlennull(szMsg))) { // message is Ansi and contains national characters, create Unicode part by codepage
char *usMsg = convertMsgToUserSpecificUtf(hContact, szMsg);
- if (usMsg)
- {
+ if (usMsg) {
SAFE_FREE(&szMsg);
szMsg = usMsg;
pre.flags = PREF_UTF;
@@ -370,17 +335,13 @@ void CIcqProto::handleRecvServMsgType1(BYTE *buf, WORD wLen, DWORD dwUin, char * { // Check if the message was received as offline
cookie_offline_messages *cookie;
+ if (!(dwRef & 0x80000000) && FindCookie(dwRef, NULL, (void**)&cookie)) {
+ cookie->nMessages++;
- if (!(dwRef & 0x80000000) && FindCookie(dwRef, NULL, (void**)&cookie))
- {
WORD wTimeTLVType, wTimeTLVLen;
BYTE *pTimeTLV;
-
- cookie->nMessages++;
-
unpackTypedTLV(buf, wLen, 0x16, &wTimeTLVType, &wTimeTLVLen, &pTimeTLV);
- if (pTimeTLV && wTimeTLVType == 0x16 && wTimeTLVLen == 4)
- { // found Offline timestamp
+ if (pTimeTLV && wTimeTLVType == 0x16 && wTimeTLVLen == 4) { // found Offline timestamp
BYTE *pBuf = pTimeTLV;
unpackDWord(&pBuf, &dwRecvTime);
@@ -397,7 +358,7 @@ void CIcqProto::handleRecvServMsgType1(BYTE *buf, WORD wLen, DWORD dwUin, char * debugLogA("Message (format 1) received");
// Save tick value
- setDword(hContact, "TickTS", time(NULL) - (dwMsgID1/1000));
+ setDword(hContact, "TickTS", time(NULL) - (dwMsgID1 / 1000));
}
else debugLogA("Message (format %u) - Ignoring empty message", 1);
@@ -407,25 +368,20 @@ void CIcqProto::handleRecvServMsgType1(BYTE *buf, WORD wLen, DWORD dwUin, char * // Free the chain memory
disposeChain(&pChain);
}
- else
- debugLogA("Failed to read TLV chain in message (format 1)");
+ else debugLogA("Failed to read TLV chain in message (format 1)");
}
- else
- debugLogA("Unsupported TLV (%u) in message (format %u)", wTLVType, 1);
+ else debugLogA("Unsupported TLV (%u) in message (format %u)", wTLVType, 1);
SAFE_FREE((void**)&pMsgTLV);
}
-
void CIcqProto::handleRecvServMsgType2(BYTE *buf, WORD wLen, DWORD dwUin, char *szUID, DWORD dwMsgID1, DWORD dwMsgID2, DWORD dwRef)
{
WORD wTLVType;
WORD wTLVLen;
BYTE *pDataBuf = NULL;
- BYTE *pBuf;
- if (wLen < 4)
- {
+ if (wLen < 4) {
debugLogA("Message (format %u) - Ignoring empty message", 2);
return;
}
@@ -433,28 +389,28 @@ void CIcqProto::handleRecvServMsgType2(BYTE *buf, WORD wLen, DWORD dwUin, char * // Unpack the first TLV(5)
unpackTypedTLV(buf, wLen, 5, &wTLVType, &wTLVLen, &pDataBuf);
debugLogA("Message (format %u) - UID: %s", 2, strUID(dwUin, szUID));
- pBuf = pDataBuf;
+ BYTE *pBuf = pDataBuf;
// It must be TLV(5)
- if (wTLVType == 5)
- {
+ if (wTLVType == 5) {
WORD wCommand;
oscar_tlv_chain* chain;
oscar_tlv* tlv;
- DWORD q1,q2,q3,q4;
+ DWORD q1, q2, q3, q4;
- if (wTLVLen < 26)
- { // just check if all basic data is there
+ if (wTLVLen < 26) { // just check if all basic data is there
debugLogA("Message (format %u) - Ignoring empty message", 2);
SAFE_FREE((void**)&pBuf);
return;
}
unpackWord(&pDataBuf, &wCommand);
- wTLVLen -= 2; // Command 0x0000 - Normal message/file send request
-#ifdef _DEBUG // 0x0001 - Abort request
- debugLogA("Command is %u", wCommand); // 0x0002 - Acknowledge request
-#endif
+ wTLVLen -= 2;
+
+ // Command 0x0000 - Normal message/file send request
+ // 0x0001 - Abort request
+ // 0x0002 - Acknowledge request
+ debugLogA("Command is %u", wCommand);
// Some stuff we don't use
pDataBuf += 8; // dwID1 and dwID2 again
@@ -465,19 +421,16 @@ void CIcqProto::handleRecvServMsgType2(BYTE *buf, WORD wLen, DWORD dwUin, char * unpackDWord(&pDataBuf, &q4); // Message Capability
wTLVLen -= 16;
- if (CompareGUIDs(q1,q2,q3,q4, MCAP_SRV_RELAY_FMT))
- { // we surely have at least 4 bytes for TLV chain
+ if (CompareGUIDs(q1, q2, q3, q4, MCAP_SRV_RELAY_FMT)) { // we surely have at least 4 bytes for TLV chain
MCONTACT hContact = HContactFromUID(dwUin, szUID, NULL);
- if (wCommand == 1)
- {
+ if (wCommand == 1) {
debugLogA("Cannot handle abort messages yet... :(");
SAFE_FREE((void**)&pBuf);
return;
}
- if (wTLVLen < 4)
- { // just check if at least one tlv is there
+ if (wTLVLen < 4) { // just check if at least one tlv is there
debugLogA("Message (format %u) - Ignoring empty message", 2);
SAFE_FREE((void**)&pBuf);
return;
@@ -493,8 +446,7 @@ void CIcqProto::handleRecvServMsgType2(BYTE *buf, WORD wLen, DWORD dwUin, char * // TLV(0x2711): The next message level
chain = readIntoTLVChain(&pDataBuf, wTLVLen, 0);
- if (!chain)
- { // sanity check
+ if (!chain) { // sanity check
debugLogA("Message (format %u) - Invalid data", 2);
SAFE_FREE((void**)&pBuf);
return;
@@ -503,8 +455,7 @@ void CIcqProto::handleRecvServMsgType2(BYTE *buf, WORD wLen, DWORD dwUin, char * WORD wAckType = chain->getWord(0x0A, 1);
// Update the saved DC info (if contact already exists)
- if (hContact != INVALID_CONTACT_ID)
- {
+ if (hContact != INVALID_CONTACT_ID) {
DWORD dwIP, dwExternalIP;
WORD wPort;
@@ -518,46 +469,38 @@ void CIcqProto::handleRecvServMsgType2(BYTE *buf, WORD wLen, DWORD dwUin, char * // Save tick value
BYTE bClientID = getByte(hContact, "ClientID", 0);
if (bClientID == CLID_GENERIC || bClientID == CLID_ICQ6)
- setDword(hContact, "TickTS", time(NULL) - (dwMsgID1/1000));
+ setDword(hContact, "TickTS", time(NULL) - (dwMsgID1 / 1000));
else
setDword(hContact, "TickTS", 0);
}
// Parse the next message level
if (tlv = chain->getTLV(0x2711, 1))
- {
parseServRelayData(tlv->pData, tlv->wLen, hContact, dwUin, szUID, dwMsgID1, dwMsgID2, wAckType);
- }
else
- {
debugLogA("Warning, no 0x2711 TLV in message (format 2)");
- }
+
// Clean up
disposeChain(&chain);
}
- else if (CompareGUIDs(q1,q2,q3,q4, MCAP_REVERSE_DC_REQ))
- { // Handle reverse DC request
- if (wCommand == 1)
- {
+ else if (CompareGUIDs(q1, q2, q3, q4, MCAP_REVERSE_DC_REQ)) { // Handle reverse DC request
+ if (wCommand == 1) {
debugLogA("Cannot handle abort messages yet... :(");
SAFE_FREE((void**)&pBuf);
return;
}
- if (wTLVLen < 4)
- { // just check if at least one tlv is there
+ if (wTLVLen < 4) { // just check if at least one tlv is there
debugLogA("Message (format %u) - Ignoring empty message", 2);
SAFE_FREE((void**)&pBuf);
return;
}
- if (!dwUin)
- { // AIM cannot send this, just sanity
+ if (!dwUin) { // AIM cannot send this, just sanity
debugLogA("Error: Malformed UIN in packet");
SAFE_FREE((void**)&pBuf);
return;
}
chain = readIntoTLVChain(&pDataBuf, wTLVLen, 0);
- if (!chain)
- { // Malformed packet
+ if (!chain) { // Malformed packet
debugLogA("Error: Malformed data in packet");
SAFE_FREE((void**)&pBuf);
return;
@@ -565,10 +508,8 @@ void CIcqProto::handleRecvServMsgType2(BYTE *buf, WORD wLen, DWORD dwUin, char * WORD wAckType = chain->getWord(0x0A, 1);
// Parse the next message level
- if (tlv = chain->getTLV(0x2711, 1))
- {
- if (tlv->wLen == 0x1B)
- {
+ if (tlv = chain->getTLV(0x2711, 1)) {
+ if (tlv->wLen == 0x1B) {
BYTE *buf = tlv->pData;
DWORD dwUin;
@@ -576,11 +517,8 @@ void CIcqProto::handleRecvServMsgType2(BYTE *buf, WORD wLen, DWORD dwUin, char * MCONTACT hContact = HContactFromUIN(dwUin, NULL);
if (hContact == INVALID_CONTACT_ID)
- {
debugLogA("Error: %s from unknown contact %u", "Reverse Connect Request", dwUin);
- }
- else
- {
+ else {
DWORD dwIp, dwPort;
WORD wVersion;
BYTE bMode;
@@ -596,11 +534,10 @@ void CIcqProto::handleRecvServMsgType2(BYTE *buf, WORD wLen, DWORD dwUin, char * unpackLEWord(&buf, &wVersion);
setDword(hContact, "IP", dwIp);
- setWord(hContact, "UserPort", (WORD)dwPort);
- setByte(hContact, "DCType", bMode);
- setWord(hContact, "Version", wVersion);
- if (wVersion > 6)
- {
+ setWord(hContact, "UserPort", (WORD)dwPort);
+ setByte(hContact, "DCType", bMode);
+ setWord(hContact, "Version", wVersion);
+ if (wVersion > 6) {
cookie_reverse_connect *pCookie = (cookie_reverse_connect*)SAFE_MALLOC(sizeof(cookie_reverse_connect));
unpackLEDWord(&buf, (DWORD*)&pCookie->ft);
@@ -609,39 +546,26 @@ void CIcqProto::handleRecvServMsgType2(BYTE *buf, WORD wLen, DWORD dwUin, char * OpenDirectConnection(hContact, DIRECTCONN_REVERSE, (void*)pCookie);
}
- else
- debugLogA("Warning: Unsupported direct protocol version in %s", "Reverse Connect Request");
+ else debugLogA("Warning: Unsupported direct protocol version in %s", "Reverse Connect Request");
}
}
- else
- {
- debugLogA("Malformed %s", "Reverse Connect Request");
- }
- }
- else
- {
- debugLogA("Warning, no 0x2711 TLV in message (format 2)");
+ else debugLogA("Malformed %s", "Reverse Connect Request");
}
+ else debugLogA("Warning, no 0x2711 TLV in message (format 2)");
+
// Clean up
disposeChain(&chain);
}
- else if (CompareGUIDs(q1,q2,q3,q4, MCAP_FILE_TRANSFER))
- { // this is an OFT packet
+ else if (CompareGUIDs(q1, q2, q3, q4, MCAP_FILE_TRANSFER)) // this is an OFT packet
handleRecvServMsgOFT(pDataBuf, wTLVLen, dwUin, szUID, dwMsgID1, dwMsgID2, wCommand);
- }
- else if (CompareGUIDs(q1,q2,q3,q4, MCAP_CONTACTS))
- { // this is Contacts Transfer
+
+ else if (CompareGUIDs(q1, q2, q3, q4, MCAP_CONTACTS)) // this is Contacts Transfer
handleRecvServMsgContacts(pDataBuf, wTLVLen, dwUin, szUID, dwMsgID1, dwMsgID2, wCommand);
- }
+
else // here should be detection of extra data streams (Xtraz)
- {
debugLogA("Unknown Message Format Capability");
- }
- }
- else
- {
- debugLogA("Unsupported TLV (%u) in message (format %u)", wTLVType, 2);
}
+ else debugLogA("Unsupported TLV (%u) in message (format %u)", wTLVType, 2);
SAFE_FREE((void**)&pBuf);
}
@@ -651,8 +575,7 @@ void CIcqProto::parseServRelayData(BYTE *pDataBuf, WORD wLen, MCONTACT hContact, {
WORD wId;
- if (wLen < 2)
- {
+ if (wLen < 2) {
debugLogA("Message (format %u) - Ignoring empty message", 2);
return;
}
@@ -661,14 +584,12 @@ void CIcqProto::parseServRelayData(BYTE *pDataBuf, WORD wLen, MCONTACT hContact, wLen -= 2;
// Only 0x1B are real messages
- if (wId == 0x001B)
- {
+ if (wId == 0x001B) {
WORD wVersion;
WORD wCookie;
- DWORD dwGuid1,dwGuid2,dwGuid3,dwGuid4;
+ DWORD dwGuid1, dwGuid2, dwGuid3, dwGuid4;
- if (wLen < 31)
- { // just check if we have data to work with
+ if (wLen < 31) { // just check if we have data to work with
debugLogA("Message (format %u) - Ignoring empty message", 2);
return;
}
@@ -695,15 +616,13 @@ void CIcqProto::parseServRelayData(BYTE *pDataBuf, WORD wLen, MCONTACT hContact, unpackLEWord(&pDataBuf, &wCookie);
wLen -= 2;
- if (CompareGUIDs(dwGuid1, dwGuid2, dwGuid3, dwGuid4, PSIG_MESSAGE))
- { // is this a normal message ?
+ if (CompareGUIDs(dwGuid1, dwGuid2, dwGuid3, dwGuid4, PSIG_MESSAGE)) { // is this a normal message ?
BYTE bMsgType;
BYTE bFlags;
WORD wStatus, wPritority;
WORD wMsgLen;
- if (wLen < 20)
- { // check if there is everything that should be there
+ if (wLen < 20) { // check if there is everything that should be there
debugLogA("Message (format %u) - Ignoring empty message", 2);
return;
}
@@ -729,17 +648,13 @@ void CIcqProto::parseServRelayData(BYTE *pDataBuf, WORD wLen, MCONTACT hContact, wLen -= 2;
// HANDLERS
- switch (bMsgType)
- {
- // File messages, handled by the file module
+ switch (bMsgType) { // File messages, handled by the file module
case MTYPE_FILEREQ:
+ if (!dwUin) { // AIM cannot send this, just sanity
+ debugLogA("Error: Malformed UIN in packet");
+ return;
+ }
{
- if (!dwUin)
- { // AIM cannot send this, just sanity
- debugLogA("Error: Malformed UIN in packet");
- return;
- }
-
char* szMsg = (char *)_alloca(wMsgLen + 1);
memcpy(szMsg, pDataBuf, wMsgLen);
szMsg[wMsgLen] = '\0';
@@ -747,68 +662,52 @@ void CIcqProto::parseServRelayData(BYTE *pDataBuf, WORD wLen, MCONTACT hContact, wLen -= wMsgLen;
if (wAckType == 0 || wAckType == 1)
- {
// File requests 7
handleFileRequest(pDataBuf, wLen, dwUin, wCookie, dwMsgID1, dwMsgID2, szMsg, 7, FALSE);
- }
else if (wAckType == 2)
- {
// File reply 7
handleFileAck(pDataBuf, wLen, dwUin, wCookie, wStatus, szMsg);
- }
else
- {
debugLogA("Ignored strange file message");
- }
-
- break;
}
+ break;
- // Chat messages, handled by the chat module
+ // Chat messages, handled by the chat module
case MTYPE_CHAT:
- { // TODO: this type is deprecated
- break;
- }
+ // TODO: this type is deprecated
+ break;
- // Plugin messages, need further parsing
+ // Plugin messages, need further parsing
case MTYPE_PLUGIN:
- {
- if (wLen < wMsgLen)
- { // sanity check
- debugLogA("Error: Malformed server Greeting message");
- return;
- }
-
- parseServRelayPluginData(pDataBuf + wMsgLen, wLen - wMsgLen, hContact, dwUin, szUID, dwMsgID1, dwMsgID2, wAckType, bFlags, wStatus, wCookie, wVersion);
- break;
+ if (wLen < wMsgLen) { // sanity check
+ debugLogA("Error: Malformed server Greeting message");
+ return;
}
- // Everything else
+ parseServRelayPluginData(pDataBuf + wMsgLen, wLen - wMsgLen, hContact, dwUin, szUID, dwMsgID1, dwMsgID2, wAckType, bFlags, wStatus, wCookie, wVersion);
+ break;
+
+ // Everything else
default:
- {
- if (!dwUin)
- { // AIM cannot send this, just sanity
- debugLogA("Error: Malformed UIN in packet");
- return;
- }
- message_ack_params pMsgAck = {0};
-
- pMsgAck.bType = MAT_SERVER_ADVANCED;
- pMsgAck.dwUin = dwUin;
- pMsgAck.dwMsgID1 = dwMsgID1;
- pMsgAck.dwMsgID2 = dwMsgID2;
- pMsgAck.wCookie = wCookie;
- pMsgAck.msgType = bMsgType;
- pMsgAck.bFlags = bFlags;
- handleMessageTypes(dwUin, szUID, time(NULL), dwMsgID1, dwMsgID2, wCookie, wVersion, bMsgType, bFlags, wAckType, wLen, wMsgLen, (char*)pDataBuf, 0, &pMsgAck);
- break;
+ if (!dwUin) { // AIM cannot send this, just sanity
+ debugLogA("Error: Malformed UIN in packet");
+ return;
}
+
+ message_ack_params pMsgAck = { 0 };
+ pMsgAck.bType = MAT_SERVER_ADVANCED;
+ pMsgAck.dwUin = dwUin;
+ pMsgAck.dwMsgID1 = dwMsgID1;
+ pMsgAck.dwMsgID2 = dwMsgID2;
+ pMsgAck.wCookie = wCookie;
+ pMsgAck.msgType = bMsgType;
+ pMsgAck.bFlags = bFlags;
+ handleMessageTypes(dwUin, szUID, time(NULL), dwMsgID1, dwMsgID2, wCookie, wVersion, bMsgType, bFlags, wAckType, wLen, wMsgLen, (char*)pDataBuf, 0, &pMsgAck);
+ break;
}
}
- else if (CompareGUIDs(dwGuid1, dwGuid2, dwGuid3, dwGuid4, PSIG_INFO_PLUGIN))
- { // info manager plugin - obsolete
- if (!dwUin)
- { // AIM cannot send this, just sanity
+ else if (CompareGUIDs(dwGuid1, dwGuid2, dwGuid3, dwGuid4, PSIG_INFO_PLUGIN)) { // info manager plugin - obsolete
+ if (!dwUin) { // AIM cannot send this, just sanity
debugLogA("Error: Malformed UIN in packet");
return;
}
@@ -824,8 +723,7 @@ void CIcqProto::parseServRelayData(BYTE *pDataBuf, WORD wLen, MCONTACT hContact, pDataBuf += 3; // unknown
wLen -= 3;
unpackByte(&pDataBuf, &bLevel);
- if (bLevel != 0 || wLen < 16)
- {
+ if (bLevel != 0 || wLen < 16) {
debugLogA("Invalid %s Manager Plugin message from %u", "Info", dwUin);
return;
}
@@ -836,16 +734,12 @@ void CIcqProto::parseServRelayData(BYTE *pDataBuf, WORD wLen, MCONTACT hContact, wLen -= 16;
if (CompareGUIDs(dwGuid1, dwGuid2, dwGuid3, dwGuid4, PMSG_QUERY_INFO))
- {
debugLogA("User %u requests our %s plugin list. NOT SUPPORTED", dwUin, "info");
- }
else
debugLogA("Unknown %s Manager message from %u", "Info", dwUin);
}
- else if (CompareGUIDs(dwGuid1, dwGuid2, dwGuid3, dwGuid4, PSIG_STATUS_PLUGIN))
- { // status manager plugin - obsolete
- if (!dwUin)
- { // AIM cannot send this, just sanity
+ else if (CompareGUIDs(dwGuid1, dwGuid2, dwGuid3, dwGuid4, PSIG_STATUS_PLUGIN)) { // status manager plugin - obsolete
+ if (!dwUin) { // AIM cannot send this, just sanity
debugLogA("Error: Malformed UIN in packet");
return;
}
@@ -861,8 +755,7 @@ void CIcqProto::parseServRelayData(BYTE *pDataBuf, WORD wLen, MCONTACT hContact, pDataBuf += 3; // unknown
wLen -= 3;
unpackByte(&pDataBuf, &bLevel);
- if (bLevel != 0 || wLen < 16)
- {
+ if (bLevel != 0 || wLen < 16) {
debugLogA("Invalid %s Manager Plugin message from %u", "Status", dwUin);
return;
}
@@ -877,14 +770,11 @@ void CIcqProto::parseServRelayData(BYTE *pDataBuf, WORD wLen, MCONTACT hContact, else
debugLogA("Unknown %s Manager message from %u", "Status", dwUin);
}
- else
- debugLogA("Unknown signature (%08x-%08x-%08x-%08x) in message (format 2)", dwGuid1, dwGuid2, dwGuid3, dwGuid4);
+ else debugLogA("Unknown signature (%08x-%08x-%08x-%08x) in message (format 2)", dwGuid1, dwGuid2, dwGuid3, dwGuid4);
}
- else
- debugLogA("Unknown wId1 (%u) in message (format 2)", wId);
+ else debugLogA("Unknown wId1 (%u) in message (format 2)", wId);
}
-
void CIcqProto::parseServRelayPluginData(BYTE *pDataBuf, WORD wLen, MCONTACT hContact, DWORD dwUin, char *szUID, DWORD dwMsgID1, DWORD dwMsgID2, WORD wAckType, BYTE bFlags, WORD wStatus, WORD wCookie, WORD wVersion)
{
int nTypeId;
@@ -895,8 +785,7 @@ void CIcqProto::parseServRelayPluginData(BYTE *pDataBuf, WORD wLen, MCONTACT hCo // Message plugin identification
if (!unpackPluginTypeId(&pDataBuf, &wLen, &nTypeId, &wFunction, FALSE)) return;
- if (wLen > 8)
- {
+ if (wLen > 8) {
DWORD dwLengthToEnd;
DWORD dwDataLen;
@@ -910,10 +799,8 @@ void CIcqProto::parseServRelayPluginData(BYTE *pDataBuf, WORD wLen, MCONTACT hCo if (dwDataLen > wLen)
dwDataLen = wLen;
- if (nTypeId == MTYPE_FILEREQ && wAckType == 2)
- {
- if (!dwUin)
- { // AIM cannot send this, just sanity
+ if (nTypeId == MTYPE_FILEREQ && wAckType == 2) {
+ if (!dwUin) { // AIM cannot send this, just sanity
debugLogA("Error: Malformed UIN in packet");
return;
}
@@ -927,10 +814,8 @@ void CIcqProto::parseServRelayPluginData(BYTE *pDataBuf, WORD wLen, MCONTACT hCo handleFileAck(pDataBuf, wLen, dwUin, wCookie, wStatus, szMsg);
}
- else if (nTypeId == MTYPE_FILEREQ && wAckType == 1)
- {
- if (!dwUin)
- { // AIM cannot send this, just sanity
+ else if (nTypeId == MTYPE_FILEREQ && wAckType == 1) {
+ if (!dwUin) { // AIM cannot send this, just sanity
debugLogA("Error: Malformed UIN in packet");
return;
}
@@ -944,10 +829,8 @@ void CIcqProto::parseServRelayPluginData(BYTE *pDataBuf, WORD wLen, MCONTACT hCo handleFileRequest(pDataBuf, wLen, dwUin, wCookie, dwMsgID1, dwMsgID2, szMsg, 8, FALSE);
}
- else if (nTypeId == MTYPE_CHAT && wAckType == 1)
- { // TODO: this is deprecated
- if (!dwUin)
- { // AIM cannot send this, just sanity
+ else if (nTypeId == MTYPE_CHAT && wAckType == 1) { // TODO: this is deprecated
+ if (!dwUin) { // AIM cannot send this, just sanity
debugLogA("Error: Malformed UIN in packet");
return;
}
@@ -961,12 +844,10 @@ void CIcqProto::parseServRelayPluginData(BYTE *pDataBuf, WORD wLen, MCONTACT hCo // handleChatRequest(pDataBuf, wLen, dwUin, wCookie, dwMsgID1, dwMsgID2, szMsg, 8);
}
- else if (nTypeId == MTYPE_STATUSMSGEXT && wFunction >= 1 && wFunction <= 3)
- { // handle extended status message request
+ else if (nTypeId == MTYPE_STATUSMSGEXT && wFunction >= 1 && wFunction <= 3) { // handle extended status message request
int nMsgType = 0;
- switch (wFunction)
- {
+ switch (wFunction) {
case 1: // Away
if (m_iStatus == ID_STATUS_ONLINE || m_iStatus == ID_STATUS_INVISIBLE)
nMsgType = MTYPE_AUTOONLINE;
@@ -989,14 +870,12 @@ void CIcqProto::parseServRelayPluginData(BYTE *pDataBuf, WORD wLen, MCONTACT hCo }
handleMessageTypes(dwUin, szUID, time(NULL), dwMsgID1, dwMsgID2, wCookie, wVersion, nMsgType, bFlags, wAckType, dwLengthToEnd, 0, (char*)pDataBuf, MTF_PLUGIN | MTF_STATUS_EXTENDED, NULL);
}
- else if (nTypeId)
- {
- if (!dwUin)
- { // AIM cannot send this, just sanity
+ else if (nTypeId) {
+ if (!dwUin) { // AIM cannot send this, just sanity
debugLogA("Error: Malformed UIN in packet");
return;
}
- message_ack_params pMsgAck = {0};
+ message_ack_params pMsgAck = { 0 };
pMsgAck.bType = MAT_SERVER_ADVANCED;
pMsgAck.dwUin = dwUin;
@@ -1007,43 +886,33 @@ void CIcqProto::parseServRelayPluginData(BYTE *pDataBuf, WORD wLen, MCONTACT hCo pMsgAck.bFlags = bFlags;
handleMessageTypes(dwUin, szUID, time(NULL), dwMsgID1, dwMsgID2, wCookie, wVersion, nTypeId, bFlags, wAckType, dwLengthToEnd, (WORD)dwDataLen, (char*)pDataBuf, MTF_PLUGIN, &pMsgAck);
}
- else
- {
- debugLogA("Unsupported plugin message type %d", nTypeId);
- }
+ else debugLogA("Unsupported plugin message type %d", nTypeId);
}
- else
- debugLogA("Error: Malformed server plugin message");
+ else debugLogA("Error: Malformed server plugin message");
}
-
void CIcqProto::handleRecvServMsgContacts(BYTE *buf, WORD wLen, DWORD dwUin, char *szUID, DWORD dwID1, DWORD dwID2, WORD wCommand)
{
MCONTACT hContact = HContactFromUID(dwUin, szUID, NULL);
- if (wCommand == 0)
- { // received contacts
- if (wLen < 4)
- { // just check if at least one tlv is there
+ if (wCommand == 0) { // received contacts
+ if (wLen < 4) { // just check if at least one tlv is there
debugLogA("Message (format %u) - Ignoring empty contacts message", 2);
return;
}
oscar_tlv_chain *chain = readIntoTLVChain(&buf, wLen, 0);
- if (!chain)
- { // sanity check
+ if (!chain) { // sanity check
debugLogA("Message (format %u) - Invalid data", 2);
return;
}
WORD wAckType = chain->getWord(0x0A, 1);
- if (wAckType == 1)
- { // it is really message containing contacts, parse them
+ if (wAckType == 1) { // it is really message containing contacts, parse them
oscar_tlv *tlvUins = chain->getTLV(0x2711, 1);
oscar_tlv *tlvNames = chain->getTLV(0x2712, 1);
- if (!tlvUins || tlvUins->wLen < 4)
- {
+ if (!tlvUins || tlvUins->wLen < 4) {
debugLogA("Malformed '%s' message", "contacts");
disposeChain(&chain);
return;
@@ -1055,16 +924,13 @@ void CIcqProto::handleRecvServMsgContacts(BYTE *buf, WORD wLen, DWORD dwUin, cha BYTE *pBuffer = tlvUins->pData;
int nLen = tlvUins->wLen;
- while (nLen > 2)
- { // parse UIDs
- if (!wContactsGroup)
- {
+ while (nLen > 2) { // parse UIDs
+ if (!wContactsGroup) {
WORD wGroupLen;
unpackWord(&pBuffer, &wGroupLen);
nLen -= 2;
- if (nLen >= wGroupLen + 2)
- {
+ if (nLen >= wGroupLen + 2) {
pBuffer += wGroupLen;
unpackWord(&pBuffer, &wContactsGroup);
nLen -= wGroupLen + 2;
@@ -1072,20 +938,17 @@ void CIcqProto::handleRecvServMsgContacts(BYTE *buf, WORD wLen, DWORD dwUin, cha else
break;
}
- else
- { // group parsed, UIDs waiting
+ else { // group parsed, UIDs waiting
WORD wUidLen;
unpackWord(&pBuffer, &wUidLen);
nLen -= 2;
- if (nLen >= wUidLen)
- {
+ if (nLen >= wUidLen) {
char *szUid = (char*)SAFE_MALLOC(wUidLen + 1);
unpackString(&pBuffer, szUid, wUidLen);
nLen -= wUidLen;
- if (iContact >= nContacts)
- { // the list is too small, resize it
+ if (iContact >= nContacts) { // the list is too small, resize it
nContacts += 0x10;
contacts = (ICQSEARCHRESULT**)SAFE_REALLOC(contacts, nContacts * sizeof(ICQSEARCHRESULT*));
}
@@ -1095,14 +958,12 @@ void CIcqProto::handleRecvServMsgContacts(BYTE *buf, WORD wLen, DWORD dwUin, cha contacts[iContact]->hdr.nick = null_strdup(_T(""));
contacts[iContact]->hdr.id = ansi_to_tchar(szUid);
- if (IsStringUIN(szUid))
- { // icq contact
+ if (IsStringUIN(szUid)) { // icq contact
contacts[iContact]->uin = atoi(szUid);
if (contacts[iContact]->uin == 0)
valid = 0;
}
- else
- { // aim contact
+ else { // aim contact
if (!strlennull(szUid))
valid = 0;
}
@@ -1110,8 +971,7 @@ void CIcqProto::handleRecvServMsgContacts(BYTE *buf, WORD wLen, DWORD dwUin, cha SAFE_FREE(&szUid);
}
- else
- {
+ else {
if (wContactsGroup) valid = 0;
break;
}
@@ -1119,12 +979,10 @@ void CIcqProto::handleRecvServMsgContacts(BYTE *buf, WORD wLen, DWORD dwUin, cha wContactsGroup--;
}
}
- if (!iContact || !valid)
- {
+ if (!iContact || !valid) {
debugLogA("Malformed '%s' message", "contacts");
disposeChain(&chain);
- for (int i = 0; i < iContact; i++)
- {
+ for (int i = 0; i < iContact; i++) {
SAFE_FREE(&contacts[i]->hdr.id);
SAFE_FREE(&contacts[i]->hdr.nick);
SAFE_FREE((void**)&contacts[i]);
@@ -1133,22 +991,18 @@ void CIcqProto::handleRecvServMsgContacts(BYTE *buf, WORD wLen, DWORD dwUin, cha return;
}
nContacts = iContact;
- if (tlvNames && tlvNames->wLen >= 4)
- { // parse names, if available
+ if (tlvNames && tlvNames->wLen >= 4) { // parse names, if available
pBuffer = tlvNames->pData;
nLen = tlvNames->wLen;
iContact = 0;
- while (nLen > 2)
- { // parse Names
- if (!wContactsGroup)
- {
+ while (nLen > 2) { // parse Names
+ if (!wContactsGroup) {
WORD wGroupLen;
unpackWord(&pBuffer, &wGroupLen);
nLen -= 2;
- if (nLen >= wGroupLen + 2)
- {
+ if (nLen >= wGroupLen + 2) {
pBuffer += wGroupLen;
unpackWord(&pBuffer, &wContactsGroup);
nLen -= wGroupLen + 2;
@@ -1156,20 +1010,17 @@ void CIcqProto::handleRecvServMsgContacts(BYTE *buf, WORD wLen, DWORD dwUin, cha else
break;
}
- else
- { // group parsed, Names waiting
+ else { // group parsed, Names waiting
WORD wNickLen;
unpackWord(&pBuffer, &wNickLen);
nLen -= 2;
- if (nLen >= wNickLen)
- {
+ if (nLen >= wNickLen) {
WORD wNickTLV, wNickTLVLen;
char *pNick = NULL;
unpackTypedTLV(pBuffer, wNickLen, 0x01, &wNickTLV, &wNickTLVLen, (LPBYTE*)&pNick);
- if (wNickTLV == 0x01)
- {
+ if (wNickTLV == 0x01) {
SAFE_FREE(&contacts[iContact]->hdr.nick);
contacts[iContact]->hdr.nick = utf8_to_tchar(pNick);
}
@@ -1190,18 +1041,15 @@ void CIcqProto::handleRecvServMsgContacts(BYTE *buf, WORD wLen, DWORD dwUin, cha }
if (!valid)
- {
debugLogA("Malformed '%s' message", "contacts");
- }
- else
- {
+ else {
int bAdded;
hContact = HContactFromUID(dwUin, szUID, &bAdded);
// ack the message
icq_sendContactsAck(dwUin, szUID, dwID1, dwID2);
- PROTORECVEVENT pre = {0};
+ PROTORECVEVENT pre = { 0 };
pre.timestamp = (DWORD)time(NULL);
pre.szMessage = (char *)contacts;
pre.lParam = nContacts;
@@ -1209,8 +1057,7 @@ void CIcqProto::handleRecvServMsgContacts(BYTE *buf, WORD wLen, DWORD dwUin, cha ProtoChainRecv(hContact, PSR_CONTACTS, 0, (LPARAM)&pre);
}
- for (int i = 0; i < iContact; i++)
- {
+ for (int i = 0; i < iContact; i++) {
SAFE_FREE(&contacts[i]->hdr.id);
SAFE_FREE(&contacts[i]->hdr.nick);
SAFE_FREE((void**)&contacts[i]);
@@ -1222,13 +1069,10 @@ void CIcqProto::handleRecvServMsgContacts(BYTE *buf, WORD wLen, DWORD dwUin, cha // Clean up
disposeChain(&chain);
}
- else if (wCommand == 1)
- {
+ else if (wCommand == 1) {
debugLogA("Cannot handle abort messages yet... :(");
- return;
}
- else if (wCommand == 2)
- { // acknowledgement
+ else if (wCommand == 2) { // acknowledgement
DWORD dwCookie;
MCONTACT hCookieContact;
if (FindMessageCookie(dwID1, dwID2, &dwCookie, &hCookieContact, NULL)) {
@@ -1243,7 +1087,6 @@ void CIcqProto::handleRecvServMsgContacts(BYTE *buf, WORD wLen, DWORD dwUin, cha }
}
-
void CIcqProto::handleRecvServMsgType4(BYTE *buf, WORD wLen, DWORD dwUin, char *szUID, DWORD dwMsgID1, DWORD dwMsgID2, DWORD dwRef)
{
WORD wTLVType;
@@ -1251,8 +1094,7 @@ void CIcqProto::handleRecvServMsgType4(BYTE *buf, WORD wLen, DWORD dwUin, char * BYTE* pDataBuf;
DWORD dwUin2;
- if (wLen < 2)
- {
+ if (wLen < 2) {
debugLogA("Message (format %u) - Ignoring empty message", 4);
return;
}
@@ -1262,8 +1104,7 @@ void CIcqProto::handleRecvServMsgType4(BYTE *buf, WORD wLen, DWORD dwUin, char * debugLogA("Message (format %u) - UID: %s", 4, strUID(dwUin, szUID));
// It must be TLV(5)
- if (wTLVType == 5)
- {
+ if (wTLVType == 5) {
BYTE bMsgType;
BYTE bFlags;
BYTE* pmsg = pDataBuf;
@@ -1272,41 +1113,33 @@ void CIcqProto::handleRecvServMsgType4(BYTE *buf, WORD wLen, DWORD dwUin, char * unpackLEDWord(&pmsg, &dwUin2);
- if (dwUin2 == dwUin)
- {
+ if (dwUin2 == dwUin) {
unpackByte(&pmsg, &bMsgType);
unpackByte(&pmsg, &bFlags);
unpackLEWord(&pmsg, &wMsgLen);
if (bMsgType == 0 && wMsgLen == 1)
- {
debugLogA("User %u probably checks his ignore state.", dwUin);
- }
- else
- {
+ else {
cookie_offline_messages *cookie;
DWORD dwRecvTime = (DWORD)time(NULL);
- if (!(dwRef & 0x80000000) && FindCookie(dwRef, NULL, (void**)&cookie))
- {
+ if (!(dwRef & 0x80000000) && FindCookie(dwRef, NULL, (void**)&cookie)) {
WORD wTimeTLVType, wTimeTLVLen;
BYTE *pTimeTLV = NULL;
cookie->nMessages++;
unpackTypedTLV(buf, wLen, 0x16, &wTimeTLVType, &wTimeTLVLen, &pTimeTLV);
- if (pTimeTLV && wTimeTLVType == 0x16 && wTimeTLVLen == 4)
- { // found Offline timestamp
+ if (pTimeTLV && wTimeTLVType == 0x16 && wTimeTLVLen == 4) { // found Offline timestamp
BYTE *pBuf = pTimeTLV;
-
unpackDWord(&pBuf, &dwRecvTime);
debugLogA("Message (format %u) - Offline timestamp is %s", 4, time2text(dwRecvTime));
}
SAFE_FREE((void**)&pTimeTLV);
}
- if (bMsgType == MTYPE_PLUGIN)
- {
+ if (bMsgType == MTYPE_PLUGIN) {
WORD wLen = wTLVLen - 8;
int typeId;
@@ -1315,8 +1148,7 @@ void CIcqProto::handleRecvServMsgType4(BYTE *buf, WORD wLen, DWORD dwUin, char * pmsg += wMsgLen;
wLen -= wMsgLen;
- if (unpackPluginTypeId(&pmsg, &wLen, &typeId, NULL, FALSE) && wLen > 8)
- {
+ if (unpackPluginTypeId(&pmsg, &wLen, &typeId, NULL, FALSE) && wLen > 8) {
DWORD dwLengthToEnd;
DWORD dwDataLen;
@@ -1330,33 +1162,22 @@ void CIcqProto::handleRecvServMsgType4(BYTE *buf, WORD wLen, DWORD dwUin, char * if (dwDataLen > wLen)
dwDataLen = wLen;
- if (typeId)
- {
+ if (typeId) {
uid_str szUID;
handleMessageTypes(dwUin, szUID, dwRecvTime, dwMsgID1, dwMsgID2, 0, 0, typeId, bFlags, 0, dwLengthToEnd, (WORD)dwDataLen, (char*)pmsg, MTF_PLUGIN, NULL);
}
- else
- {
- debugLogA("Unsupported plugin message type %d", typeId);
- }
+ else debugLogA("Unsupported plugin message type %d", typeId);
}
}
- else
- {
+ else {
uid_str szUID;
handleMessageTypes(dwUin, szUID, dwRecvTime, dwMsgID1, dwMsgID2, 0, 0, bMsgType, bFlags, 0, wTLVLen - 8, wMsgLen, (char*)pmsg, 0, NULL);
}
}
}
- else
- {
- debugLogA("Ignoring spoofed TYPE4 message thru server from %d", dwUin);
- }
- }
- else
- {
- debugLogA("Unsupported TLV (%u) in message (format %u)", wTLVType, 4);
+ else debugLogA("Ignoring spoofed TYPE4 message thru server from %d", dwUin);
}
+ else debugLogA("Unsupported TLV (%u) in message (format %u)", wTLVType, 4);
SAFE_FREE((void**)&pDataBuf);
}
@@ -1370,67 +1191,50 @@ static int TypeGUIDToTypeId(DWORD dwGuid1, DWORD dwGuid2, DWORD dwGuid3, DWORD d {
int nTypeID = MTYPE_UNKNOWN;
- if (CompareGUIDs(dwGuid1, dwGuid2, dwGuid3, dwGuid4, MGTYPE_STATUSMSGEXT))
- {
+ if (CompareGUIDs(dwGuid1, dwGuid2, dwGuid3, dwGuid4, MGTYPE_STATUSMSGEXT)) {
nTypeID = MTYPE_STATUSMSGEXT;
}
- else if (wType==MGTYPE_UNDEFINED)
- {
- if (CompareGUIDs(dwGuid1, dwGuid2, dwGuid3, dwGuid4, PSIG_MESSAGE))
- { // icq6 message ack
+ else if (wType == MGTYPE_UNDEFINED) {
+ if (CompareGUIDs(dwGuid1, dwGuid2, dwGuid3, dwGuid4, PSIG_MESSAGE)) { // icq6 message ack
nTypeID = MTYPE_PLAIN;
}
}
- else if (wType==MGTYPE_STANDARD_SEND)
- {
- if (CompareGUIDs(dwGuid1, dwGuid2, dwGuid3, dwGuid4, MGTYPE_WEBURL))
- {
+ else if (wType == MGTYPE_STANDARD_SEND) {
+ if (CompareGUIDs(dwGuid1, dwGuid2, dwGuid3, dwGuid4, MGTYPE_WEBURL)) {
nTypeID = MTYPE_URL;
}
- else if (CompareGUIDs(dwGuid1, dwGuid2, dwGuid3, dwGuid4, MGTYPE_CONTACTS))
- {
+ else if (CompareGUIDs(dwGuid1, dwGuid2, dwGuid3, dwGuid4, MGTYPE_CONTACTS)) {
nTypeID = MTYPE_CONTACTS;
}
- else if (CompareGUIDs(dwGuid1, dwGuid2, dwGuid3, dwGuid4, MGTYPE_CHAT))
- {
+ else if (CompareGUIDs(dwGuid1, dwGuid2, dwGuid3, dwGuid4, MGTYPE_CHAT)) {
nTypeID = MTYPE_CHAT;
}
- else if (CompareGUIDs(dwGuid1, dwGuid2, dwGuid3, dwGuid4, MGTYPE_FILE))
- {
+ else if (CompareGUIDs(dwGuid1, dwGuid2, dwGuid3, dwGuid4, MGTYPE_FILE)) {
nTypeID = MTYPE_FILEREQ;
}
- else if (CompareGUIDs(dwGuid1, dwGuid2, dwGuid3, dwGuid4, MGTYPE_GREETING_CARD))
- {
+ else if (CompareGUIDs(dwGuid1, dwGuid2, dwGuid3, dwGuid4, MGTYPE_GREETING_CARD)) {
nTypeID = MTYPE_GREETINGCARD;
}
- else if (CompareGUIDs(dwGuid1, dwGuid2, dwGuid3, dwGuid4, MGTYPE_MESSAGE))
- {
+ else if (CompareGUIDs(dwGuid1, dwGuid2, dwGuid3, dwGuid4, MGTYPE_MESSAGE)) {
nTypeID = MTYPE_MESSAGE;
}
- else if (CompareGUIDs(dwGuid1, dwGuid2, dwGuid3, dwGuid4, MGTYPE_SMS_MESSAGE))
- {
+ else if (CompareGUIDs(dwGuid1, dwGuid2, dwGuid3, dwGuid4, MGTYPE_SMS_MESSAGE)) {
nTypeID = MTYPE_SMS_MESSAGE;
}
}
- else if (wType==MGTYPE_CONTACTS_REQUEST)
- {
- if (CompareGUIDs(dwGuid1, dwGuid2, dwGuid3, dwGuid4, MGTYPE_CONTACTS))
- {
+ else if (wType == MGTYPE_CONTACTS_REQUEST) {
+ if (CompareGUIDs(dwGuid1, dwGuid2, dwGuid3, dwGuid4, MGTYPE_CONTACTS)) {
nTypeID = MTYPE_REQUESTCONTACTS;
}
- else if (CompareGUIDs(dwGuid1, dwGuid2, dwGuid3, dwGuid4, MGTYPE_XTRAZ_SCRIPT))
- {
+ else if (CompareGUIDs(dwGuid1, dwGuid2, dwGuid3, dwGuid4, MGTYPE_XTRAZ_SCRIPT)) {
nTypeID = MTYPE_SCRIPT_DATA;
}
}
- else if (CompareGUIDs(dwGuid1, dwGuid2, dwGuid3, dwGuid4, MGTYPE_XTRAZ_SCRIPT))
- {
- if (wType==MGTYPE_SCRIPT_INVITATION)
- {
+ else if (CompareGUIDs(dwGuid1, dwGuid2, dwGuid3, dwGuid4, MGTYPE_XTRAZ_SCRIPT)) {
+ if (wType == MGTYPE_SCRIPT_INVITATION) {
nTypeID = MTYPE_SCRIPT_INVITATION;
}
- else if (wType==MGTYPE_SCRIPT_NOTIFY)
- {
+ else if (wType == MGTYPE_SCRIPT_NOTIFY) {
nTypeID = MTYPE_SCRIPT_NOTIFY;
}
}
@@ -1444,7 +1248,7 @@ int CIcqProto::unpackPluginTypeId(BYTE **pBuffer, WORD *pwLen, int *pTypeId, WOR WORD wLen = *pwLen;
WORD wInfoLen;
DWORD dwPluginNameLen;
- DWORD q1,q2,q3,q4;
+ DWORD q1, q2, q3, q4;
WORD qt;
if (wLen < 24)
@@ -1464,8 +1268,7 @@ int CIcqProto::unpackPluginTypeId(BYTE **pBuffer, WORD *pwLen, int *pTypeId, WOR unpackLEDWord(pBuffer, &dwPluginNameLen);
wLen -= 4;
- if (dwPluginNameLen > wLen)
- { // check for malformed plugin name
+ if (dwPluginNameLen > wLen) { // check for malformed plugin name
dwPluginNameLen = wLen;
NetLog_Uni(bThruDC, "Warning: malformed size of plugin name.");
}
@@ -1478,15 +1281,13 @@ int CIcqProto::unpackPluginTypeId(BYTE **pBuffer, WORD *pwLen, int *pTypeId, WOR int typeId = TypeGUIDToTypeId(q1, q2, q3, q4, qt);
if (!typeId)
- NetLog_Uni(bThruDC, "Error: Unknown type {%08x-%08x-%08x-%08x:%04x}: %s", q1,q2,q3,q4,qt, szPluginName);
+ NetLog_Uni(bThruDC, "Error: Unknown type {%08x-%08x-%08x-%08x:%04x}: %s", q1, q2, q3, q4, qt, szPluginName);
- if (wInfoLen >= 22 + dwPluginNameLen)
- { // sanity checking
+ if (wInfoLen >= 22 + dwPluginNameLen) { // sanity checking
wInfoLen -= (WORD)(22 + dwPluginNameLen);
// check if enough data is available - skip remaining bytes of info block
- if (wLen >= wInfoLen)
- {
+ if (wLen >= wInfoLen) {
*pBuffer += wInfoLen;
wLen -= wInfoLen;
}
@@ -1501,8 +1302,7 @@ int CIcqProto::unpackPluginTypeId(BYTE **pBuffer, WORD *pwLen, int *pTypeId, WOR int getPluginTypeIdLen(int nTypeID)
{
- switch (nTypeID)
- {
+ switch (nTypeID) {
case MTYPE_SCRIPT_NOTIFY:
return 0x51;
@@ -1527,8 +1327,7 @@ int getPluginTypeIdLen(int nTypeID) void packPluginTypeId(icq_packet *packet, int nTypeID)
{
- switch (nTypeID)
- {
+ switch (nTypeID) {
case MTYPE_SCRIPT_NOTIFY:
packLEWord(packet, 0x04f); // Length
@@ -1632,7 +1431,7 @@ void CIcqProto::handleStatusMsgReply(const char *szPrefix, MCONTACT hContact, DW }
// it is probably UTF-8 status reply
- PROTORECVEVENT pre = {0};
+ PROTORECVEVENT pre = { 0 };
if (wVersion >= 9)
if (UTF8_IsValid(szMsg))
pre.flags |= PREF_UTF;
@@ -1646,23 +1445,20 @@ void CIcqProto::handleStatusMsgReply(const char *szPrefix, MCONTACT hContact, DW HANDLE CIcqProto::handleMessageAck(DWORD dwUin, char *szUID, WORD wCookie, WORD wVersion, int type, WORD wMsgLen, PBYTE buf, BYTE bFlags, int nMsgFlags)
{
- if (bFlags == 3)
- {
+ if (bFlags == 3) {
MCONTACT hCookieContact;
cookie_message_data *pCookieData = NULL;
MCONTACT hContact = HContactFromUID(dwUin, szUID, NULL);
- if (!FindCookie(wCookie, &hCookieContact, (void**)&pCookieData))
- {
+ if (!FindCookie(wCookie, &hCookieContact, (void**)&pCookieData)) {
debugLogA("%sIgnoring unrequested status message from %u", "handleMessageAck: ", dwUin);
ReleaseCookie(wCookie);
return INVALID_HANDLE_VALUE;
}
- if (hContact != hCookieContact)
- {
+ if (hContact != hCookieContact) {
debugLogA("%sAck Contact does not match Cookie Contact(0x%x != 0x%x)", "handleMessageAck: ", hContact, hCookieContact);
ReleaseCookie(wCookie);
@@ -1672,11 +1468,8 @@ HANDLE CIcqProto::handleMessageAck(DWORD dwUin, char *szUID, WORD wCookie, WORD handleStatusMsgReply("handleMessageAck: ", hContact, dwUin, wVersion, type, wCookie, (char*)buf, nMsgFlags);
}
- else
- {
- // Should not happen
+ else // Should not happen
debugLogA("%sIgnored type %u ack message (this should not happen)", "handleMessageAck: ", type);
- }
return INVALID_HANDLE_VALUE;
}
@@ -1685,18 +1478,14 @@ HANDLE CIcqProto::handleMessageAck(DWORD dwUin, char *szUID, WORD wCookie, WORD /* this function send all acks from handleMessageTypes */
void CIcqProto::sendMessageTypesAck(MCONTACT hContact, int bUnicode, message_ack_params *pArgs)
{
- if (pArgs)
- {
+ if (pArgs) {
if ((pArgs->msgType == MTYPE_PLAIN && !CallService(MS_IGNORE_ISIGNORED, hContact, IGNOREEVENT_MESSAGE))
- || (pArgs->msgType == MTYPE_URL && !CallService(MS_IGNORE_ISIGNORED, hContact, IGNOREEVENT_URL))
- || pArgs->msgType == MTYPE_CONTACTS)
- {
- if (pArgs->bType == MAT_SERVER_ADVANCED)
- { // Only ack message packets
+ || (pArgs->msgType == MTYPE_URL && !CallService(MS_IGNORE_ISIGNORED, hContact, IGNOREEVENT_URL))
+ || pArgs->msgType == MTYPE_CONTACTS) {
+ if (pArgs->bType == MAT_SERVER_ADVANCED) { // Only ack message packets
icq_sendAdvancedMsgAck(pArgs->dwUin, pArgs->dwMsgID1, pArgs->dwMsgID2, pArgs->wCookie, (BYTE)pArgs->msgType, pArgs->bFlags);
}
- else if (pArgs->bType == MAT_DIRECT)
- { // Send acknowledgement
+ else if (pArgs->bType == MAT_DIRECT) { // Send acknowledgement
icq_sendDirectMsgAck(pArgs->pDC, pArgs->wCookie, (BYTE)pArgs->msgType, pArgs->bFlags, bUnicode ? (char *)CAP_UTF8MSGS : NULL);
}
}
@@ -1712,22 +1501,18 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp, BOOL bThruDC = (nMsgFlags & MTF_DIRECT) == MTF_DIRECT;
int bAdded;
-
- if (dwDataLen < wMsgLen)
- {
+ if (dwDataLen < wMsgLen) {
NetLog_Uni(bThruDC, "Ignoring overflowed message");
return;
}
- if (wAckType == 2)
- {
+ if (wAckType == 2) {
handleMessageAck(dwUin, szUID, wCookie, wVersion, type, wMsgLen, (LPBYTE)pMsg, (BYTE)flags, nMsgFlags);
return;
}
char *szMsg = (char *)SAFE_MALLOC(wMsgLen + 1);
- if (wMsgLen > 0)
- {
+ if (wMsgLen > 0) {
memcpy(szMsg, pMsg, wMsgLen);
pMsg += wMsgLen;
dwDataLen -= wMsgLen;
@@ -1735,16 +1520,13 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp, szMsg[wMsgLen] = '\0';
- char* pszMsgField[2*MAX_CONTACTSSEND+1];
+ char *pszMsgField[2 * MAX_CONTACTSSEND + 1];
int nMsgFields = 0;
pszMsgField[0] = szMsg;
- if (type == MTYPE_URL || type == MTYPE_AUTHREQ || type == MTYPE_ADDED || type == MTYPE_CONTACTS || type == MTYPE_EEXPRESS || type == MTYPE_WWP)
- {
- for (char *pszMsg=szMsg, nMsgFields=1; *pszMsg; pszMsg++)
- {
- if ((BYTE)*pszMsg == 0xFE)
- {
+ if (type == MTYPE_URL || type == MTYPE_AUTHREQ || type == MTYPE_ADDED || type == MTYPE_CONTACTS || type == MTYPE_EEXPRESS || type == MTYPE_WWP) {
+ for (char *pszMsg = szMsg, nMsgFields = 1; *pszMsg; pszMsg++) {
+ if ((BYTE)*pszMsg == 0xFE) {
*pszMsg = '\0';
pszMsgField[nMsgFields++] = pszMsg + 1;
if (nMsgFields >= SIZEOF(pszMsgField))
@@ -1754,23 +1536,19 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp, }
switch (type) {
-
case MTYPE_PLAIN: /* plain message */
{
- PROTORECVEVENT pre = {0};
+ PROTORECVEVENT pre = { 0 };
// Check if this message is marked as UTF8 encoded
- if (dwDataLen > 12)
- {
+ if (dwDataLen > 12) {
DWORD dwGuidLen = 0;
int bDoubleMsg = 0;
- if (bThruDC)
- {
+ if (bThruDC) {
DWORD dwExtraLen = *(DWORD*)pMsg;
- if (dwExtraLen < dwDataLen && !strncmp(szMsg, "{\\rtf", 5))
- { // it is icq5 sending us crap, get real message from it
+ if (dwExtraLen < dwDataLen && !strncmp(szMsg, "{\\rtf", 5)) { // it is icq5 sending us crap, get real message from it
WCHAR* usMsg = (WCHAR*)_alloca((dwExtraLen + 1)*sizeof(WCHAR));
// make sure it is null-terminated
wcsncpy(usMsg, (WCHAR*)(pMsg + 4), dwExtraLen);
@@ -1785,22 +1563,18 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp, }
}
- if (!bDoubleMsg)
- {
- dwGuidLen = *(DWORD*)(pMsg+8);
+ if (!bDoubleMsg) {
+ dwGuidLen = *(DWORD*)(pMsg + 8);
dwDataLen -= 12;
pMsg += 12;
}
- while ((dwGuidLen >= 38) && (dwDataLen >= dwGuidLen))
- {
- if (!strncmp(pMsg, CAP_UTF8MSGS, 38))
- { // Found UTF8 cap, convert message to ansi
+ while ((dwGuidLen >= 38) && (dwDataLen >= dwGuidLen)) {
+ if (!strncmp(pMsg, CAP_UTF8MSGS, 38)) { // Found UTF8 cap, convert message to ansi
pre.flags = PREF_UTF;
break;
}
- else if (!strncmp(pMsg, CAP_RTFMSGS, 38))
- { // Found RichText cap
+ else if (!strncmp(pMsg, CAP_RTFMSGS, 38)) { // Found RichText cap
NetLog_Uni(bThruDC, "Warning: User %u sends us RichText.", dwUin);
break;
}
@@ -1814,11 +1588,9 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp, hContact = HContactFromUIN(dwUin, &bAdded);
sendMessageTypesAck(hContact, pre.flags & PREF_UTF, pAckParams);
- if (!pre.flags && !IsUSASCII(szMsg, strlennull(szMsg)))
- { // message is Ansi and contains national characters, create Unicode part by codepage
+ if (!pre.flags && !IsUSASCII(szMsg, strlennull(szMsg))) { // message is Ansi and contains national characters, create Unicode part by codepage
char *usMsg = convertMsgToUserSpecificUtf(hContact, szMsg);
- if (usMsg)
- {
+ if (usMsg) {
SAFE_FREE(&szMsg);
szMsg = (char*)usMsg;
pre.flags = PREF_UTF;
@@ -1832,18 +1604,14 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp, break;
case MTYPE_URL:
- {
- PROTORECVEVENT pre = {0};
-
- if (nMsgFields < 2)
- {
- NetLog_Uni(bThruDC, "Malformed '%s' message", "URL");
- break;
- }
-
- hContact = HContactFromUIN(dwUin, &bAdded);
- sendMessageTypesAck(hContact, 0, pAckParams);
+ if (nMsgFields < 2) {
+ NetLog_Uni(bThruDC, "Malformed '%s' message", "URL");
+ break;
+ }
+ hContact = HContactFromUIN(dwUin, &bAdded);
+ sendMessageTypesAck(hContact, 0, pAckParams);
+ {
char *szTitle = ICQTranslateUtf(LPGEN("Incoming URL:"));
char *szDataDescr = ansi_to_utf8(pszMsgField[0]);
char *szDataUrl = ansi_to_utf8(pszMsgField[1]);
@@ -1857,6 +1625,7 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp, SAFE_FREE(&szDataDescr);
SAFE_FREE(&szDataUrl);
+ PROTORECVEVENT pre = { 0 };
pre.timestamp = dwTimestamp;
pre.szMessage = (char *)szBlob;
pre.flags = PREF_UTF;
@@ -1873,9 +1642,9 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp, break;
}
{
- PROTORECVEVENT pre = {0};
- pre.timestamp=dwTimestamp;
- pre.lParam=sizeof(DWORD)*2+strlennull(pszMsgField[0])+strlennull(pszMsgField[1])+strlennull(pszMsgField[2])+strlennull(pszMsgField[3])+strlennull(pszMsgField[5])+5;
+ PROTORECVEVENT pre = { 0 };
+ pre.timestamp = dwTimestamp;
+ pre.lParam = sizeof(DWORD) * 2 + strlennull(pszMsgField[0]) + strlennull(pszMsgField[1]) + strlennull(pszMsgField[2]) + strlennull(pszMsgField[3]) + strlennull(pszMsgField[5]) + 5;
// blob is: uin(DWORD), hcontact(HANDLE), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ), reason(ASCIIZ)
char *szBlob, *pCurBlob = szBlob = (char *)_alloca(pre.lParam);
@@ -1916,61 +1685,52 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp, {
char* pszNContactsEnd;
int nContacts;
- int i;
-
- if (nMsgFields < 3
- || (nContacts = strtol(pszMsgField[0], &pszNContactsEnd, 10)) == 0
- || pszNContactsEnd - pszMsgField[0] != (int)strlennull(pszMsgField[0])
- || nMsgFields < nContacts * 2 + 1)
+ if (nMsgFields < 3 ||
+ (nContacts = strtol(pszMsgField[0], &pszNContactsEnd, 10)) == 0 ||
+ pszNContactsEnd - pszMsgField[0] != (int)strlennull(pszMsgField[0]) ||
+ nMsgFields < nContacts * 2 + 1)
{
NetLog_Uni(bThruDC, "Malformed '%s' message", "contacts");
- break;
}
-
- int valid = 1;
- ICQSEARCHRESULT** isrList = (ICQSEARCHRESULT**)_alloca(nContacts * sizeof(ICQSEARCHRESULT*));
- for (i = 0; i < nContacts; i++)
- {
- isrList[i] = (ICQSEARCHRESULT*)SAFE_MALLOC(sizeof(ICQSEARCHRESULT));
- isrList[i]->hdr.cbSize = sizeof(ICQSEARCHRESULT);
- isrList[i]->hdr.flags = PSR_TCHAR;
- if (IsStringUIN(pszMsgField[1 + i * 2]))
- { // icq contact
- isrList[i]->uin = atoi(pszMsgField[1 + i * 2]);
- if (isrList[i]->uin == 0)
- valid = 0;
- }
- else
- { // aim contact
- if (!strlennull(pszMsgField[1 + i * 2]))
- valid = 0;
+ else {
+ int valid = 1;
+ ICQSEARCHRESULT** isrList = (ICQSEARCHRESULT**)_alloca(nContacts * sizeof(ICQSEARCHRESULT*));
+ for (int i = 0; i < nContacts; i++) {
+ isrList[i] = (ICQSEARCHRESULT*)SAFE_MALLOC(sizeof(ICQSEARCHRESULT));
+ isrList[i]->hdr.cbSize = sizeof(ICQSEARCHRESULT);
+ isrList[i]->hdr.flags = PSR_TCHAR;
+ if (IsStringUIN(pszMsgField[1 + i * 2])) { // icq contact
+ isrList[i]->uin = atoi(pszMsgField[1 + i * 2]);
+ if (isrList[i]->uin == 0)
+ valid = 0;
+ }
+ else { // aim contact
+ if (!strlennull(pszMsgField[1 + i * 2]))
+ valid = 0;
+ }
+ isrList[i]->hdr.id = ansi_to_tchar(pszMsgField[1 + i * 2]);
+ isrList[i]->hdr.nick = ansi_to_tchar(pszMsgField[2 + i * 2]);
}
- isrList[i]->hdr.id = ansi_to_tchar(pszMsgField[1 + i * 2]);
- isrList[i]->hdr.nick = ansi_to_tchar(pszMsgField[2 + i * 2]);
- }
-
- if (!valid)
- {
- NetLog_Uni(bThruDC, "Malformed '%s' message", "contacts");
- }
- else
- {
- hContact = HContactFromUIN(dwUin, &bAdded);
- sendMessageTypesAck(hContact, 0, pAckParams);
- PROTORECVEVENT pre = {0};
- pre.timestamp = dwTimestamp;
- pre.szMessage = (char *)isrList;
- pre.lParam = nContacts;
- pre.flags = PREF_TCHAR;
- ProtoChainRecv(hContact, PSR_CONTACTS, 0, (LPARAM)&pre);
- }
+ if (!valid)
+ NetLog_Uni(bThruDC, "Malformed '%s' message", "contacts");
+ else {
+ hContact = HContactFromUIN(dwUin, &bAdded);
+ sendMessageTypesAck(hContact, 0, pAckParams);
+
+ PROTORECVEVENT pre = { 0 };
+ pre.timestamp = dwTimestamp;
+ pre.szMessage = (char *)isrList;
+ pre.lParam = nContacts;
+ pre.flags = PREF_TCHAR;
+ ProtoChainRecv(hContact, PSR_CONTACTS, 0, (LPARAM)&pre);
+ }
- for (i = 0; i < nContacts; i++)
- {
- SAFE_FREE(&isrList[i]->hdr.id);
- SAFE_FREE(&isrList[i]->hdr.nick);
- SAFE_FREE((void**)&isrList[i]);
+ for (int i = 0; i < nContacts; i++) {
+ SAFE_FREE(&isrList[i]->hdr.id);
+ SAFE_FREE(&isrList[i]->hdr.nick);
+ SAFE_FREE((void**)&isrList[i]);
+ }
}
}
break;
@@ -1978,17 +1738,15 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp, case MTYPE_PLUGIN: // FIXME: this should be removed - it is never called
hContact = NULL;
- switch(dwUin)
- {
+ switch (dwUin) {
case 1111: /* icqmail 'you've got mail' - not processed */
break;
}
break;
case MTYPE_SMS_MESSAGE:
- /* it's a SMS message from a mobile - broadcast to SMS plugin */
- if (dwUin != 1002)
- {
+ // it's a SMS message from a mobile - broadcast to SMS plugin
+ if (dwUin != 1002) {
NetLog_Uni(bThruDC, "Malformed '%s' message", "SMS Mobile");
break;
}
@@ -1998,54 +1756,38 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp, break;
case MTYPE_STATUSMSGEXT:
- /* it's either extended StatusMsg reply from icq2003b or a IcqWebMessage */
+ // it's either extended StatusMsg reply from icq2003b or a IcqWebMessage
if (dwUin == 1003)
- {
debugLogA("Received ICQWebMessage - NOT SUPPORTED");
- }
break;
case MTYPE_WWP:
- /* format: fromname FE FE FE fromemail FE unknownbyte FE 'Sender IP: xxx.xxx.xxx.xxx' 0D 0A body */
- {
- DWORD cbBlob;
- PBYTE pBlob, pCurBlob;
-
- if (nMsgFields < 6)
- {
- debugLogA("Malformed '%s' message", "web pager");
- break;
- }
-
- /*blob is: body(ASCIIZ), name(ASCIIZ), email(ASCIIZ) */
- cbBlob=strlennull(pszMsgField[0])+strlennull(pszMsgField[3])+strlennull(pszMsgField[5])+3;
- pCurBlob=pBlob=(PBYTE)_alloca(cbBlob);
- strcpy((char *)pCurBlob,pszMsgField[5]); pCurBlob+=strlennull((char *)pCurBlob)+1;
- strcpy((char *)pCurBlob,pszMsgField[0]); pCurBlob+=strlennull((char *)pCurBlob)+1;
- strcpy((char *)pCurBlob,pszMsgField[3]);
+ // format: fromname FE FE FE fromemail FE unknownbyte FE 'Sender IP: xxx.xxx.xxx.xxx' 0D 0A body
+ if (nMsgFields < 6)
+ debugLogA("Malformed '%s' message", "web pager");
+ else {
+ // blob is: body(ASCIIZ), name(ASCIIZ), email(ASCIIZ)
+ DWORD cbBlob = strlennull(pszMsgField[0]) + strlennull(pszMsgField[3]) + strlennull(pszMsgField[5]) + 3;
+ PBYTE pBlob, pCurBlob = pBlob = (PBYTE)_alloca(cbBlob);
+ strcpy((char *)pCurBlob, pszMsgField[5]); pCurBlob += strlennull((char *)pCurBlob) + 1;
+ strcpy((char *)pCurBlob, pszMsgField[0]); pCurBlob += strlennull((char *)pCurBlob) + 1;
+ strcpy((char *)pCurBlob, pszMsgField[3]);
AddEvent(NULL, ICQEVENTTYPE_WEBPAGER, dwTimestamp, 0, cbBlob, pBlob);
}
break;
case MTYPE_EEXPRESS:
- /* format: fromname FE FE FE fromemail FE unknownbyte FE body */
- {
- DWORD cbBlob;
- PBYTE pBlob, pCurBlob;
-
- if (nMsgFields < 6)
- {
- debugLogA("Malformed '%s' message", "e-mail express");
- break;
- }
-
- /*blob is: body(ASCIIZ), name(ASCIIZ), email(ASCIIZ) */
- cbBlob=strlennull(pszMsgField[0])+strlennull(pszMsgField[3])+strlennull(pszMsgField[5])+3;
- pCurBlob=pBlob=(PBYTE)_alloca(cbBlob);
- strcpy((char *)pCurBlob,pszMsgField[5]); pCurBlob+=strlennull((char *)pCurBlob)+1;
- strcpy((char *)pCurBlob,pszMsgField[0]); pCurBlob+=strlennull((char *)pCurBlob)+1;
- strcpy((char *)pCurBlob,pszMsgField[3]);
+ // format: fromname FE FE FE fromemail FE unknownbyte FE body
+ if (nMsgFields < 6)
+ debugLogA("Malformed '%s' message", "e-mail express");
+ else {
+ // blob is: body(ASCIIZ), name(ASCIIZ), email(ASCIIZ)
+ DWORD cbBlob = strlennull(pszMsgField[0]) + strlennull(pszMsgField[3]) + strlennull(pszMsgField[5]) + 3;
+ PBYTE pBlob, pCurBlob = pBlob = (PBYTE)_alloca(cbBlob);
+ strcpy((char *)pCurBlob, pszMsgField[5]); pCurBlob += strlennull((char *)pCurBlob) + 1;
+ strcpy((char *)pCurBlob, pszMsgField[0]); pCurBlob += strlennull((char *)pCurBlob) + 1;
+ strcpy((char *)pCurBlob, pszMsgField[3]);
AddEvent(NULL, ICQEVENTTYPE_EMAILEXPRESS, dwTimestamp, 0, cbBlob, pBlob);
}
@@ -2085,72 +1827,71 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp, case MTYPE_AUTONA:
case MTYPE_AUTODND:
case MTYPE_AUTOFFC:
- {
- char **szMsg = MirandaStatusToAwayMsg(AwayMsgTypeToStatus(type));
- if (szMsg)
+ {
+ 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)
{
- protected:
- virtual rates_queue_item* copyItem(rates_queue_item *aDest = NULL)
- {
- rates_status_message_response *pDest = (rates_status_message_response*)aDest;
- if (!pDest)
- pDest = new rates_status_message_response(ppro, wGroup);
-
- pDest->bExtended = bExtended;
- pDest->dwMsgID1 = dwMsgID1;
- pDest->dwMsgID2 = dwMsgID2;
- pDest->wCookie = wCookie;
- pDest->wVersion = wVersion;
- pDest->nMsgType = nMsgType;
-
- return rates_queue_item::copyItem(pDest);
- };
- public:
- rates_status_message_response(CIcqProto *ppro, WORD wGroup): rates_queue_item(ppro, wGroup) { };
- virtual ~rates_status_message_response() { };
-
- virtual void execute()
- {
- char **pszMsg = ppro->MirandaStatusToAwayMsg(AwayMsgTypeToStatus(nMsgType));
- 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);
- else
- ppro->debugLogA("Error: Malformed UIN in packet");
- };
-
- BOOL bExtended;
- DWORD dwMsgID1;
- DWORD dwMsgID2;
- WORD wCookie;
- WORD wVersion;
- int nMsgType;
+ rates_status_message_response *pDest = (rates_status_message_response*)aDest;
+ if (!pDest)
+ pDest = new rates_status_message_response(ppro, wGroup);
+
+ pDest->bExtended = bExtended;
+ pDest->dwMsgID1 = dwMsgID1;
+ pDest->dwMsgID2 = dwMsgID2;
+ pDest->wCookie = wCookie;
+ pDest->wVersion = wVersion;
+ pDest->nMsgType = nMsgType;
+
+ return rates_queue_item::copyItem(pDest);
};
+ public:
+ rates_status_message_response(CIcqProto *ppro, WORD wGroup) : rates_queue_item(ppro, wGroup) {};
+ virtual ~rates_status_message_response() {};
- m_ratesMutex->Enter();
- WORD wGroup = m_rates->getGroupFromSNAC(ICQ_MSG_FAMILY, ICQ_MSG_RESPONSE);
- m_ratesMutex->Leave();
-
- rates_status_message_response rr(this, wGroup);
- rr.bExtended = (nMsgFlags & MTF_STATUS_EXTENDED) == MTF_STATUS_EXTENDED;
- rr.hContact = hContact;
- rr.dwUin = dwUin;
- rr.szUid = szUID;
- rr.dwMsgID1 = dwMsgID;
- rr.dwMsgID2 = dwMsgID2;
- rr.wCookie = wCookie;
- rr.wVersion = wVersion;
- rr.nMsgType = type;
-
- handleRateItem(&rr, RQT_RESPONSE);
- }
+ virtual void execute()
+ {
+ char **pszMsg = ppro->MirandaStatusToAwayMsg(AwayMsgTypeToStatus(nMsgType));
+ 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);
+ else
+ ppro->debugLogA("Error: Malformed UIN in packet");
+ };
- break;
+ BOOL bExtended;
+ DWORD dwMsgID1;
+ DWORD dwMsgID2;
+ WORD wCookie;
+ WORD wVersion;
+ int nMsgType;
+ };
+
+ m_ratesMutex->Enter();
+ WORD wGroup = m_rates->getGroupFromSNAC(ICQ_MSG_FAMILY, ICQ_MSG_RESPONSE);
+ m_ratesMutex->Leave();
+
+ rates_status_message_response rr(this, wGroup);
+ rr.bExtended = (nMsgFlags & MTF_STATUS_EXTENDED) == MTF_STATUS_EXTENDED;
+ rr.hContact = hContact;
+ rr.dwUin = dwUin;
+ rr.szUid = szUID;
+ rr.dwMsgID1 = dwMsgID;
+ rr.dwMsgID2 = dwMsgID2;
+ rr.wCookie = wCookie;
+ rr.wVersion = wVersion;
+ rr.nMsgType = type;
+
+ handleRateItem(&rr, RQT_RESPONSE);
}
+ break;
+ }
+
case MTYPE_FILEREQ: // Never happens
default:
NetLog_Uni(bThruDC, "Unprocessed message type %d", type);
@@ -2183,8 +1924,7 @@ void CIcqProto::handleRecvMsgResponse(BYTE *buf, WORD wLen, WORD wFlags, DWORD d unpackWord(&buf, &wMessageFormat);
wLen -= 2;
- if (wMessageFormat != 2)
- {
+ if (wMessageFormat != 2) {
debugLogA("SNAC(4.B) Unknown type");
return;
}
@@ -2254,8 +1994,7 @@ void CIcqProto::handleRecvMsgResponse(BYTE *buf, WORD wLen, WORD wFlags, DWORD d // use old reliable method
debugLogA("Warning: Invalid cookie in %s from (%u)", "message response", dwUin);
- if (pCookieData->bMessageType != MTYPE_AUTOAWAY && bFlags == 3)
- { // most probably a broken ack of some kind (e.g. from R&Q), try to fix that
+ if (pCookieData->bMessageType != MTYPE_AUTOAWAY && bFlags == 3) { // most probably a broken ack of some kind (e.g. from R&Q), try to fix that
bMsgType = pCookieData->bMessageType;
bFlags = 0;
@@ -2301,154 +2040,154 @@ void CIcqProto::handleRecvMsgResponse(BYTE *buf, WORD wLen, WORD wFlags, DWORD d switch (bMsgType) {
case MTYPE_FILEREQ:
- {
- char* szMsg;
- WORD wMsgLen;
-
- // Message length
- unpackLEWord(&buf, &wMsgLen);
- wLen -= 2;
- szMsg = (char *)_alloca(wMsgLen + 1);
- szMsg[wMsgLen] = '\0';
- if (wMsgLen > 0) {
- memcpy(szMsg, buf, wMsgLen);
- buf += wMsgLen;
- wLen -= wMsgLen;
- }
- handleFileAck(buf, wLen, dwUin, dwCookie, wStatus, szMsg);
- // No success protoack will be sent here, since all file requests
- // will have been 'sent' when the server returns its ack
- return;
+ {
+ char* szMsg;
+ WORD wMsgLen;
+
+ // Message length
+ unpackLEWord(&buf, &wMsgLen);
+ wLen -= 2;
+ szMsg = (char *)_alloca(wMsgLen + 1);
+ szMsg[wMsgLen] = '\0';
+ if (wMsgLen > 0) {
+ memcpy(szMsg, buf, wMsgLen);
+ buf += wMsgLen;
+ wLen -= wMsgLen;
}
+ handleFileAck(buf, wLen, dwUin, dwCookie, wStatus, szMsg);
+ // No success protoack will be sent here, since all file requests
+ // will have been 'sent' when the server returns its ack
+ return;
+ }
case MTYPE_PLUGIN:
- {
- WORD wMsgLen;
- DWORD dwLengthToEnd;
- DWORD dwDataLen;
- int typeId;
- WORD wFunctionId;
+ {
+ WORD wMsgLen;
+ DWORD dwLengthToEnd;
+ DWORD dwDataLen;
+ int typeId;
+ WORD wFunctionId;
- if (wLength != 0x1B) {
- debugLogA("Invalid Greeting %s", "message response");
+ if (wLength != 0x1B) {
+ debugLogA("Invalid Greeting %s", "message response");
- ReleaseCookie(dwCookie);
- return;
- }
+ ReleaseCookie(dwCookie);
+ return;
+ }
- debugLogA("Parsing Greeting %s", "message response");
+ debugLogA("Parsing Greeting %s", "message response");
- // Message
- unpackLEWord(&buf, &wMsgLen);
- wLen -= 2;
- buf += wMsgLen;
- wLen -= wMsgLen;
+ // Message
+ unpackLEWord(&buf, &wMsgLen);
+ wLen -= 2;
+ buf += wMsgLen;
+ wLen -= wMsgLen;
- // This packet is malformed. Possibly a file accept from Miranda IM 0.1.2.1
- if (wLen < 20) {
- ReleaseCookie(dwCookie);
- return;
- }
+ // This packet is malformed. Possibly a file accept from Miranda IM 0.1.2.1
+ if (wLen < 20) {
+ ReleaseCookie(dwCookie);
+ return;
+ }
- if (!unpackPluginTypeId(&buf, &wLen, &typeId, &wFunctionId, FALSE)) {
- ReleaseCookie(dwCookie);
- return;
- }
+ if (!unpackPluginTypeId(&buf, &wLen, &typeId, &wFunctionId, FALSE)) {
+ ReleaseCookie(dwCookie);
+ return;
+ }
- if (wLen < 4) {
- debugLogA("Error: Invalid greeting %s", "message response");
- ReleaseCookie(dwCookie);
- return;
- }
+ if (wLen < 4) {
+ debugLogA("Error: Invalid greeting %s", "message response");
+ ReleaseCookie(dwCookie);
+ return;
+ }
- // Length of remaining data
- unpackLEDWord(&buf, &dwLengthToEnd);
- wLen -= 4;
+ // Length of remaining data
+ unpackLEDWord(&buf, &dwLengthToEnd);
+ wLen -= 4;
- if (wLen >= 4 && dwLengthToEnd > 0)
- unpackLEDWord(&buf, &dwDataLen); // Length of message
- else
- dwDataLen = 0;
+ if (wLen >= 4 && dwLengthToEnd > 0)
+ unpackLEDWord(&buf, &dwDataLen); // Length of message
+ else
+ dwDataLen = 0;
- switch (typeId) {
- case MTYPE_PLAIN:
- if (pCookieData && pCookieData->bMessageType == MTYPE_AUTOAWAY && dwLengthToEnd >= 4) {
- // ICQ 6 invented this
- char *szMsg = (char*)_alloca(dwDataLen + 1);
+ switch (typeId) {
+ case MTYPE_PLAIN:
+ if (pCookieData && pCookieData->bMessageType == MTYPE_AUTOAWAY && dwLengthToEnd >= 4) {
+ // ICQ 6 invented this
+ char *szMsg = (char*)_alloca(dwDataLen + 1);
- if (dwDataLen > 0)
- memcpy(szMsg, buf, dwDataLen);
- szMsg[dwDataLen] = '\0';
- handleStatusMsgReply("SNAC(4.B) ", hContact, dwUin, wVersion, pCookieData->nAckType, (WORD)dwCookie, szMsg, 0);
+ if (dwDataLen > 0)
+ memcpy(szMsg, buf, dwDataLen);
+ szMsg[dwDataLen] = '\0';
+ handleStatusMsgReply("SNAC(4.B) ", hContact, dwUin, wVersion, pCookieData->nAckType, (WORD)dwCookie, szMsg, 0);
- ReleaseCookie(dwCookie);
- return;
- }
- ackType = ACKTYPE_MESSAGE;
- break;
+ ReleaseCookie(dwCookie);
+ return;
+ }
+ ackType = ACKTYPE_MESSAGE;
+ break;
- case MTYPE_URL:
- ackType = ACKTYPE_URL;
- break;
+ case MTYPE_URL:
+ ackType = ACKTYPE_URL;
+ break;
- case MTYPE_CONTACTS:
- ackType = ACKTYPE_CONTACTS;
- break;
+ case MTYPE_CONTACTS:
+ ackType = ACKTYPE_CONTACTS;
+ break;
- case MTYPE_FILEREQ:
- debugLogA("This is file ack");
- {
- char *szMsg = (char *)_alloca(dwDataLen + 1);
-
- if (dwDataLen > 0)
- memcpy(szMsg, buf, dwDataLen);
- szMsg[dwDataLen] = '\0';
- buf += dwDataLen;
- wLen -= (WORD)dwDataLen;
-
- handleFileAck(buf, wLen, dwUin, dwCookie, wStatus, szMsg);
- // No success protoack will be sent here, since all file requests
- // will have been 'sent' when the server returns its ack
- }
- return;
+ case MTYPE_FILEREQ:
+ debugLogA("This is file ack");
+ {
+ char *szMsg = (char *)_alloca(dwDataLen + 1);
- case MTYPE_SCRIPT_NOTIFY:
- {
- char *szMsg = (char*)_alloca(dwDataLen + 1);
+ if (dwDataLen > 0)
+ memcpy(szMsg, buf, dwDataLen);
+ szMsg[dwDataLen] = '\0';
+ buf += dwDataLen;
+ wLen -= (WORD)dwDataLen;
- if (dwDataLen > 0)
- memcpy(szMsg, buf, dwDataLen);
- szMsg[dwDataLen] = '\0';
+ handleFileAck(buf, wLen, dwUin, dwCookie, wStatus, szMsg);
+ // No success protoack will be sent here, since all file requests
+ // will have been 'sent' when the server returns its ack
+ }
+ return;
- handleXtrazNotifyResponse(dwUin, hContact, (WORD)dwCookie, szMsg, dwDataLen);
+ case MTYPE_SCRIPT_NOTIFY:
+ {
+ char *szMsg = (char*)_alloca(dwDataLen + 1);
- ReleaseCookie(dwCookie);
- }
- return;
+ if (dwDataLen > 0)
+ memcpy(szMsg, buf, dwDataLen);
+ szMsg[dwDataLen] = '\0';
- case MTYPE_STATUSMSGEXT:
- { // handle Away Message response (ICQ 6)
- char *szMsg = (char*)SAFE_MALLOC(dwDataLen + 1);
+ handleXtrazNotifyResponse(dwUin, hContact, (WORD)dwCookie, szMsg, dwDataLen);
- if (dwDataLen > 0)
- memcpy(szMsg, buf, dwDataLen);
- szMsg[dwDataLen] = '\0';
- szMsg = EliminateHtml(szMsg, dwDataLen);
+ ReleaseCookie(dwCookie);
+ }
+ return;
- handleStatusMsgReply("SNAC(4.B) ", hContact, dwUin, wVersion, pCookieData->nAckType, (WORD)dwCookie, szMsg, MTF_PLUGIN | MTF_STATUS_EXTENDED);
+ case MTYPE_STATUSMSGEXT:
+ { // handle Away Message response (ICQ 6)
+ char *szMsg = (char*)SAFE_MALLOC(dwDataLen + 1);
- SAFE_FREE(&szMsg);
+ if (dwDataLen > 0)
+ memcpy(szMsg, buf, dwDataLen);
+ szMsg[dwDataLen] = '\0';
+ szMsg = EliminateHtml(szMsg, dwDataLen);
- ReleaseCookie(dwCookie);
- }
- return;
+ handleStatusMsgReply("SNAC(4.B) ", hContact, dwUin, wVersion, pCookieData->nAckType, (WORD)dwCookie, szMsg, MTF_PLUGIN | MTF_STATUS_EXTENDED);
- default:
- debugLogA("Error: Unknown plugin message response, type %d.", typeId);
- return;
- }
+ SAFE_FREE(&szMsg);
+
+ ReleaseCookie(dwCookie);
+ }
+ return;
+
+ default:
+ debugLogA("Error: Unknown plugin message response, type %d.", typeId);
+ return;
}
+ }
break;
case MTYPE_PLAIN:
@@ -2473,21 +2212,20 @@ void CIcqProto::handleRecvMsgResponse(BYTE *buf, WORD wLen, WORD wFlags, DWORD d break;
case MTYPE_REVERSE_REQUEST:
- {
- cookie_reverse_connect *pReverse = (cookie_reverse_connect*)pCookieData;
-
- if (pReverse->ft)
- {
- filetransfer *ft = (filetransfer*)pReverse->ft;
+ {
+ cookie_reverse_connect *pReverse = (cookie_reverse_connect*)pCookieData;
- ProtoBroadcastAck(ft->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0);
- }
- debugLogA("Reverse Connect request failed");
- // Set DC status to failed
- setByte(hContact, "DCStatus", 2);
+ if (pReverse->ft) {
+ filetransfer *ft = (filetransfer*)pReverse->ft;
- ReleaseCookie(dwCookie);
+ ProtoBroadcastAck(ft->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0);
}
+ debugLogA("Reverse Connect request failed");
+ // Set DC status to failed
+ setByte(hContact, "DCStatus", 2);
+
+ ReleaseCookie(dwCookie);
+ }
return;
case MTYPE_CHAT:
@@ -2647,7 +2385,7 @@ void CIcqProto::handleRecvServMsgError(BYTE *buf, WORD wLen, WORD wFlags, DWORD if (pCookieData->bMessageType != MTYPE_FILEREQ)
SAFE_FREE((void**)&pCookieData);
}
- else {
+ else {
unpackWord(&buf, &wError);
LogFamilyError(ICQ_MSG_FAMILY, wError);
}
@@ -2678,14 +2416,11 @@ void CIcqProto::handleServerAck(BYTE *buf, WORD wLen, WORD wFlags, DWORD dwSeque MCONTACT hContact = HContactFromUID(dwUin, szUID, NULL);
- if (FindCookie((WORD)dwSequence, NULL, (void**)&pCookieData))
- {
+ if (FindCookie((WORD)dwSequence, NULL, (void**)&pCookieData)) {
// If the user requested a full ack, the
// server ack should be ignored here.
- if (pCookieData && (pCookieData->nAckType == ACKTYPE_SERVER))
- {
- if ((hContact != NULL) && (hContact != INVALID_CONTACT_ID))
- {
+ if (pCookieData && (pCookieData->nAckType == ACKTYPE_SERVER)) {
+ if ((hContact != NULL) && (hContact != INVALID_CONTACT_ID)) {
int ackType;
int ackRes = ACKRESULT_SUCCESS;
@@ -2764,7 +2499,7 @@ void CIcqProto::handleMissedMsg(BYTE *buf, WORD wLen, WORD wFlags, DWORD dwRef) wLen -= 2;
// Read past user info TLVs
- oscar_tlv_chain *pChain = readIntoTLVChain(&buf, (WORD)(wLen-4), wTLVCount);
+ oscar_tlv_chain *pChain = readIntoTLVChain(&buf, (WORD)(wLen - 4), wTLVCount);
if (pChain)
disposeChain(&pChain);
@@ -2811,11 +2546,9 @@ void CIcqProto::handleOffineMessagesReply(BYTE *buf, WORD wLen, WORD wFlags, DWO {
cookie_offline_messages *cookie;
- if (FindCookie(dwRef, NULL, (void**)&cookie))
- {
+ if (FindCookie(dwRef, NULL, (void**)&cookie)) {
debugLogA("End of offline msgs, %u received", cookie->nMessages);
- if (cookie->nMissed)
- { // NASTY WORKAROUND!!
+ if (cookie->nMissed) { // NASTY WORKAROUND!!
// 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
@@ -2839,8 +2572,7 @@ void CIcqProto::handleOffineMessagesReply(BYTE *buf, WORD wLen, WORD wFlags, DWO ReleaseCookie(dwRef);
}
- else
- debugLogA("Error: Received unexpected end of offline msgs.");
+ else debugLogA("Error: Received unexpected end of offline msgs.");
}
@@ -2851,19 +2583,11 @@ void CIcqProto::handleTypingNotification(BYTE *buf, WORD wLen, WORD wFlags, DWOR WORD wChannel;
WORD wNotification;
- if (wLen < 14)
- {
+ if (wLen < 14) {
debugLogA("Ignoring SNAC(4.x11) Packet to short");
return;
}
-#ifndef DBG_CAPMTN
- {
- debugLogA("Ignoring unexpected typing notification");
- return;
- }
-#endif
-
// The message ID, unused?
buf += 8;
wLen -= 8;
|