diff options
Diffstat (limited to 'protocols/IcqOscarJ/src/fam_13servclist.cpp')
-rw-r--r-- | protocols/IcqOscarJ/src/fam_13servclist.cpp | 1130 |
1 files changed, 434 insertions, 696 deletions
diff --git a/protocols/IcqOscarJ/src/fam_13servclist.cpp b/protocols/IcqOscarJ/src/fam_13servclist.cpp index 5bf83423f9..050aea947a 100644 --- a/protocols/IcqOscarJ/src/fam_13servclist.cpp +++ b/protocols/IcqOscarJ/src/fam_13servclist.cpp @@ -31,46 +31,36 @@ static int unpackServerListItem(BYTE **pbuf, WORD *pwLen, char *pszRecordName, W void CIcqProto::handleServCListFam(BYTE *pBuffer, WORD wBufferLength, snac_header* pSnacHeader, serverthread_info *info)
{
switch (pSnacHeader->wSubtype) {
-
case ICQ_LISTS_ACK: // UPDATE_ACK
- if (wBufferLength >= 2)
- {
+ if (wBufferLength >= 2) {
WORD wError;
cookie_servlist_action* sc;
unpackWord(&pBuffer, &wError);
- if (FindCookie(pSnacHeader->dwRef, NULL, (void**)&sc))
- { // look for action cookie
-#ifdef _DEBUG
+ if (FindCookie(pSnacHeader->dwRef, NULL, (void**)&sc)) { // look for action cookie
debugLogA("Received expected server list ack, action: %d, result: %d", sc->dwAction, wError);
-#endif
FreeCookie(pSnacHeader->dwRef); // release cookie
- if (sc->dwAction == SSA_ACTION_GROUP)
- { // group cookie, handle sub-items
+ if (sc->dwAction == SSA_ACTION_GROUP) { // group cookie, handle sub-items
int i;
-#ifdef _DEBUG
debugLogA("Server-List: Grouped action contains %d actions.", sc->dwGroupCount);
-#endif
+
pBuffer -= 2; // revoke unpack
- if (wBufferLength != 2*sc->dwGroupCount)
- debugLogA("Error: Server list ack does not contain expected amount of result codes (%u != %u)", wBufferLength/2, sc->dwGroupCount);
+ if (wBufferLength != 2 * sc->dwGroupCount)
+ debugLogA("Error: Server list ack does not contain expected amount of result codes (%u != %u)", wBufferLength / 2, sc->dwGroupCount);
- for (i = 0; i < sc->dwGroupCount; i++)
- {
- if (wBufferLength >= 2)
- { // get proper result code
+ for (i = 0; i < sc->dwGroupCount; i++) {
+ if (wBufferLength >= 2) { // get proper result code
unpackWord(&pBuffer, &wError);
wBufferLength -= 2;
}
else // missing result code, give some special
wError = -1;
-#ifdef _DEBUG
debugLogA("Action: %d, ack result: %d", sc->pGroupItems[i]->dwAction, wError);
-#endif
+
// call normal ack handler
handleServerCListAck(sc->pGroupItems[i], wError);
}
@@ -81,77 +71,56 @@ void CIcqProto::handleServCListFam(BYTE *pBuffer, WORD wBufferLength, snac_heade else // single ack
handleServerCListAck(sc, wError);
}
- else
- {
- debugLogA("Received unexpected server list ack %u", wError);
- }
+ else debugLogA("Received unexpected server list ack %u", wError);
}
break;
case ICQ_LISTS_SRV_REPLYLISTS:
- { /* received server-list rights */
- handleServerCListRightsReply(pBuffer, wBufferLength);
-
-#ifdef _DEBUG
- debugLogA("Server sent SNAC(x13,x03) - SRV_REPLYLISTS");
-#endif
- }
+ /* received server-list rights */
+ handleServerCListRightsReply(pBuffer, wBufferLength);
+ debugLogA("Server sent SNAC(x13,x03) - SRV_REPLYLISTS");
break;
case ICQ_LISTS_LIST: // SRV_REPLYROSTER
{
cookie_servlist_action* sc;
- BOOL blWork;
-
- blWork = bIsSyncingCL;
+ BOOL blWork = bIsSyncingCL;
bIsSyncingCL = TRUE; // this is not used if cookie takes place
- if (FindCookie(pSnacHeader->dwRef, NULL, (void**)&sc))
- { // we do it by reliable cookie
- if (!sc->lParam)
- { // is this first packet ?
+ if (FindCookie(pSnacHeader->dwRef, NULL, (void**)&sc)) { // we do it by reliable cookie
+ if (!sc->lParam) { // is this first packet ?
ResetSettingsOnListReload();
sc->lParam = 1;
}
handleServerCListReply(pBuffer, wBufferLength, pSnacHeader->wFlags, info);
- if (!(pSnacHeader->wFlags & 0x0001))
- { // was that last packet ?
+ if (!(pSnacHeader->wFlags & 0x0001)) // was that last packet ?
ReleaseCookie(pSnacHeader->dwRef); // yes, release cookie
- }
}
- else
- { // use old fake
- if (!blWork)
- { // this can fail on some crazy situations
+ else { // use old fake
+ if (!blWork) // this can fail on some crazy situations
ResetSettingsOnListReload();
- }
+
handleServerCListReply(pBuffer, wBufferLength, pSnacHeader->wFlags, info);
}
- break;
}
+ break;
case ICQ_LISTS_UPTODATE: // SRV_REPLYROSTEROK
+ bIsSyncingCL = FALSE;
{
cookie_servlist_action* sc;
-
- bIsSyncingCL = FALSE;
-
- if (FindCookie(pSnacHeader->dwRef, NULL, (void**)&sc))
- { // we requested servlist check
-#ifdef _DEBUG
+ if (FindCookie(pSnacHeader->dwRef, NULL, (void**)&sc)) { // we requested servlist check
debugLogA("Server stated roster is ok.");
-#endif
ReleaseCookie(pSnacHeader->dwRef);
LoadServerIDs();
}
- else
- debugLogA("Server sent unexpected SNAC(x13,x0F) - SRV_REPLYROSTEROK");
+ else debugLogA("Server sent unexpected SNAC(x13,x0F) - SRV_REPLYROSTEROK");
// This will activate the server side list
sendRosterAck(); // this must be here, cause of failures during cookie alloc
handleServUINSettings(wListenPort, info);
- break;
}
+ break;
case ICQ_LISTS_CLI_MODIFYSTART:
debugLogA("Server sent SNAC(x13,x%02x) - %s", ICQ_LISTS_CLI_MODIFYSTART, "Server is modifying contact list");
@@ -167,21 +136,18 @@ void CIcqProto::handleServCListFam(BYTE *pBuffer, WORD wBufferLength, snac_heade {
int nItems = 0;
- while (wBufferLength >= 10)
- {
+ while (wBufferLength >= 10) {
WORD wGroupId, wItemId, wItemType, wTlvLen;
uid_str szRecordName;
- if (unpackServerListItem(&pBuffer, &wBufferLength, szRecordName, &wGroupId, &wItemId, &wItemType, &wTlvLen))
- {
+ if (unpackServerListItem(&pBuffer, &wBufferLength, szRecordName, &wGroupId, &wItemId, &wItemType, &wTlvLen)) {
BYTE *buf = pBuffer;
oscar_tlv_chain *pChain = NULL;
nItems++;
// parse possible item's data
- if (wBufferLength >= wTlvLen && wTlvLen > 0)
- {
+ if (wBufferLength >= wTlvLen && wTlvLen > 0) {
pChain = readIntoTLVChain(&buf, wTlvLen, 0);
pBuffer += wTlvLen;
wBufferLength -= wTlvLen;
@@ -201,9 +167,9 @@ void CIcqProto::handleServCListFam(BYTE *pBuffer, WORD wBufferLength, snac_heade disposeChain(&pChain);
}
}
- { // log packet basics
+ {
+ // log packet basics
char *szChange;
- char szLogText[MAX_PATH];
if (pSnacHeader->wSubtype == ICQ_LISTS_ADDTOLIST)
szChange = "Server added %u item(s) to list";
@@ -212,6 +178,7 @@ void CIcqProto::handleServCListFam(BYTE *pBuffer, WORD wBufferLength, snac_heade else if (pSnacHeader->wSubtype == ICQ_LISTS_REMOVEFROMLIST)
szChange = "Server removed %u item(s) from list";
+ char szLogText[MAX_PATH];
mir_snprintf(szLogText, MAX_PATH, szChange, nItems);
debugLogA("Server sent SNAC(x13,x%02x) - %s", pSnacHeader->wSubtype, szLogText);
}
@@ -235,22 +202,17 @@ void CIcqProto::handleServCListFam(BYTE *pBuffer, WORD wBufferLength, snac_heade break;
case ICQ_LISTS_ERROR:
- if (wBufferLength >= 2)
- {
+ if (wBufferLength >= 2) {
WORD wError;
cookie_servlist_action* sc;
unpackWord(&pBuffer, &wError);
- if (FindCookie(pSnacHeader->dwRef, NULL, (void**)&sc))
- { // look for action cookie
-#ifdef _DEBUG
+ if (FindCookie(pSnacHeader->dwRef, NULL, (void**)&sc)) { // look for action cookie
debugLogA("Received server list error, action: %d, result: %d", sc->dwAction, wError);
-#endif
FreeCookie(pSnacHeader->dwRef); // release cookie
- if (sc->dwAction==SSA_CHECK_ROSTER)
- { // the serv-list is unavailable turn it off
+ if (sc->dwAction == SSA_CHECK_ROSTER) { // the serv-list is unavailable turn it off
icq_LogMessage(LOG_ERROR, LPGEN("Server contact list is unavailable, Miranda will use local contact list."));
m_bSsiEnabled = 0;
handleServUINSettings(wListenPort, info);
@@ -258,10 +220,7 @@ void CIcqProto::handleServCListFam(BYTE *pBuffer, WORD wBufferLength, snac_heade /// FIXME: properly release pending operations & cookie memory
SAFE_FREE((void**)&sc);
}
- else
- {
- LogFamilyError(ICQ_LISTS_FAMILY, wError);
- }
+ else LogFamilyError(ICQ_LISTS_FAMILY, wError);
}
break;
@@ -309,32 +268,27 @@ static int unpackServerListItem(BYTE **pbuf, WORD *pwLen, char *pszRecordName, W void CIcqProto::handleServerCListRightsReply(BYTE *buf, WORD wLen)
-{ /* received list rights, store the item limits for future use */
+{
+ /* received list rights, store the item limits for future use */
oscar_tlv_chain* chain;
memset(m_wServerListLimits, -1, sizeof(m_wServerListLimits));
m_wServerListGroupMaxContacts = 0;
m_wServerListRecordNameMaxLength = 0xFFFF;
- if (chain = readIntoTLVChain(&buf, wLen, 0))
- {
- oscar_tlv* pTLV;
-
+ if (chain = readIntoTLVChain(&buf, wLen, 0)) {
// determine max number of contacts in a group
m_wServerListGroupMaxContacts = chain->getWord(0x0C, 1);
// determine length limit for server-list item's name
m_wServerListRecordNameMaxLength = chain->getWord(0x06, 1);
- if (pTLV = chain->getTLV(0x04, 1))
- { // limits for item types
- int i;
+ if (oscar_tlv *pTLV = chain->getTLV(0x04, 1)) { // limits for item types
WORD *pLimits = (WORD*)pTLV->pData;
-
- for (i = 0; i < pTLV->wLen / 2; i++)
- {
+ for (int i = 0; i < pTLV->wLen / 2; i++) {
m_wServerListLimits[i] = (pLimits[i] & 0xFF) << 8 | (pLimits[i] >> 8);
- if (i + 1 >= SIZEOF(m_wServerListLimits)) break;
+ if (i + 1 >= SIZEOF(m_wServerListLimits))
+ break;
}
debugLogA("SSI: Max %d contacts (%d per group), %d groups, %d permit, %d deny, %d ignore items.", m_wServerListLimits[SSI_ITEM_BUDDY], m_wServerListGroupMaxContacts, m_wServerListLimits[SSI_ITEM_GROUP], m_wServerListLimits[SSI_ITEM_PERMIT], m_wServerListLimits[SSI_ITEM_DENY], m_wServerListLimits[SSI_ITEM_IGNORE]);
@@ -344,449 +298,379 @@ void CIcqProto::handleServerCListRightsReply(BYTE *buf, WORD wLen) }
}
-
DWORD CIcqProto::updateServerGroupData(WORD wGroupId, void *groupData, int groupSize, DWORD dwOperationFlags)
{
- DWORD dwCookie;
- cookie_servlist_action* ack;
-
- ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action));
- if (!ack)
- {
+ cookie_servlist_action* ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action));
+ if (!ack) {
debugLogA("Updating of group on server list failed (malloc error)");
return 0;
}
ack->dwAction = SSA_GROUP_UPDATE;
ack->szGroupName = getServListGroupName(wGroupId);
ack->wGroupId = wGroupId;
- dwCookie = AllocateCookie(CKT_SERVERLIST, ICQ_LISTS_UPDATEGROUP, 0, ack);
-
+
+ DWORD dwCookie = AllocateCookie(CKT_SERVERLIST, ICQ_LISTS_UPDATEGROUP, 0, ack);
return icq_sendServerGroup(dwCookie, ICQ_LISTS_UPDATEGROUP, ack->wGroupId, ack->szGroupName, groupData, groupSize, dwOperationFlags);
}
-
void CIcqProto::handleServerCListAck(cookie_servlist_action* sc, WORD wError)
{
- switch (sc->dwAction)
- {
+ switch (sc->dwAction) {
case SSA_VISIBILITY:
- {
- if (wError)
- debugLogA("Server visibility update failed, error %d", wError);
- break;
- }
+ if (wError)
+ debugLogA("Server visibility update failed, error %d", wError);
+ break;
+
case SSA_CONTACT_UPDATE:
- {
- servlistPendingRemoveContact(sc->hContact, sc->wContactId, sc->wGroupId, wError ? PENDING_RESULT_FAILED : PENDING_RESULT_SUCCESS);
- if (wError)
- {
- debugLogA("Updating of server contact failed, error %d", wError);
- icq_LogMessage(LOG_WARNING, LPGEN("Updating of server contact failed."));
- }
- break;
+ servlistPendingRemoveContact(sc->hContact, sc->wContactId, sc->wGroupId, wError ? PENDING_RESULT_FAILED : PENDING_RESULT_SUCCESS);
+ if (wError) {
+ debugLogA("Updating of server contact failed, error %d", wError);
+ icq_LogMessage(LOG_WARNING, LPGEN("Updating of server contact failed."));
}
+ break;
+
case SSA_PRIVACY_ADD:
- {
- if (wError)
- {
- debugLogA("Adding of privacy item to server list failed, error %d", wError);
- icq_LogMessage(LOG_WARNING, LPGEN("Adding of privacy item to server list failed."));
- }
- break;
+ if (wError) {
+ debugLogA("Adding of privacy item to server list failed, error %d", wError);
+ icq_LogMessage(LOG_WARNING, LPGEN("Adding of privacy item to server list failed."));
}
+ break;
+
case SSA_PRIVACY_REMOVE:
- {
- if (wError)
- {
- debugLogA("Removing of privacy item from server list failed, error %d", wError);
- icq_LogMessage(LOG_WARNING, LPGEN("Removing of privacy item from server list failed."));
- }
- FreeServerID(sc->wContactId, SSIT_ITEM); // release server id
- break;
+ if (wError) {
+ debugLogA("Removing of privacy item from server list failed, error %d", wError);
+ icq_LogMessage(LOG_WARNING, LPGEN("Removing of privacy item from server list failed."));
}
- case SSA_CONTACT_ADD:
- {
- if (wError)
- {
- if (wError == 0xE) // server refused to add contact w/o auth, add with
- {
- DWORD dwCookie;
+ FreeServerID(sc->wContactId, SSIT_ITEM); // release server id
+ break;
- debugLogA("Contact could not be added without authorization, add with await auth flag.");
+ case SSA_CONTACT_ADD:
+ if (wError) {
+ if (wError == 0xE) { // server refused to add contact w/o auth, add with
+ debugLogA("Contact could not be added without authorization, add with await auth flag.");
- setByte(sc->hContact, "Auth", 1); // we need auth
- dwCookie = AllocateCookie(CKT_SERVERLIST, ICQ_LISTS_ADDTOLIST, sc->hContact, sc);
- icq_sendServerContact(sc->hContact, dwCookie, ICQ_LISTS_ADDTOLIST, sc->wGroupId, sc->wContactId, SSOP_ITEM_ACTION | SSOF_CONTACT, 500, NULL);
+ setByte(sc->hContact, "Auth", 1); // we need auth
+ DWORD dwCookie = AllocateCookie(CKT_SERVERLIST, ICQ_LISTS_ADDTOLIST, sc->hContact, sc);
+ icq_sendServerContact(sc->hContact, dwCookie, ICQ_LISTS_ADDTOLIST, sc->wGroupId, sc->wContactId, SSOP_ITEM_ACTION | SSOF_CONTACT, 500, NULL);
- sc = NULL; // we do not want it to be freed now
- break;
- }
- FreeServerID(sc->wContactId, SSIT_ITEM);
+ sc = NULL; // we do not want it to be freed now
+ break;
+ }
+ FreeServerID(sc->wContactId, SSIT_ITEM);
- debugLogA("Adding of contact to server list failed, error %d", wError);
- icq_LogMessage(LOG_WARNING, LPGEN("Adding of contact to server list failed."));
+ debugLogA("Adding of contact to server list failed, error %d", wError);
+ icq_LogMessage(LOG_WARNING, LPGEN("Adding of contact to server list failed."));
- servlistPendingRemoveContact(sc->hContact, 0, sc->wGroupId, PENDING_RESULT_FAILED);
+ servlistPendingRemoveContact(sc->hContact, 0, sc->wGroupId, PENDING_RESULT_FAILED);
- servlistPostPacket(NULL, 0, SSO_END_OPERATION, 100); // end server modifications here
- }
- else
- {
- void* groupData;
- int groupSize;
+ servlistPostPacket(NULL, 0, SSO_END_OPERATION, 100); // end server modifications here
+ }
+ else {
+ void* groupData;
+ int groupSize;
- setWord(sc->hContact, DBSETTING_SERVLIST_ID, sc->wContactId);
- setWord(sc->hContact, DBSETTING_SERVLIST_GROUP, sc->wGroupId);
+ setWord(sc->hContact, DBSETTING_SERVLIST_ID, sc->wContactId);
+ setWord(sc->hContact, DBSETTING_SERVLIST_GROUP, sc->wGroupId);
- servlistPendingRemoveContact(sc->hContact, sc->wContactId, sc->wGroupId, PENDING_RESULT_SUCCESS);
+ servlistPendingRemoveContact(sc->hContact, sc->wContactId, sc->wGroupId, PENDING_RESULT_SUCCESS);
- if (groupData = collectBuddyGroup(sc->wGroupId, &groupSize))
- { // the group is not empty, just update it
- updateServerGroupData(sc->wGroupId, groupData, groupSize, SSOF_END_OPERATION);
- SAFE_FREE((void**)&groupData);
- }
- else
- { // this should never happen
- debugLogA("Group update failed.");
- servlistPostPacket(NULL, 0, SSO_END_OPERATION, 100); // end server modifications here
- }
+ if (groupData = collectBuddyGroup(sc->wGroupId, &groupSize)) { // the group is not empty, just update it
+ updateServerGroupData(sc->wGroupId, groupData, groupSize, SSOF_END_OPERATION);
+ SAFE_FREE((void**)&groupData);
+ }
+ else { // this should never happen
+ debugLogA("Group update failed.");
+ servlistPostPacket(NULL, 0, SSO_END_OPERATION, 100); // end server modifications here
}
- break;
}
- case SSA_GROUP_ADD:
- {
- if (wError)
- {
- FreeServerID(sc->wGroupId, SSIT_GROUP);
- debugLogA("Adding of group to server list failed, error %d", wError);
- icq_LogMessage(LOG_WARNING, LPGEN("Adding of group to server list failed."));
+ break;
- servlistPendingRemoveGroup(sc->szGroup, 0, PENDING_RESULT_FAILED);
- }
- else // group added, we need to update master group
- {
- void* groupData;
- int groupSize;
- cookie_servlist_action* ack;
- DWORD dwCookie;
+ case SSA_GROUP_ADD:
+ if (wError) {
+ FreeServerID(sc->wGroupId, SSIT_GROUP);
+ debugLogA("Adding of group to server list failed, error %d", wError);
+ icq_LogMessage(LOG_WARNING, LPGEN("Adding of group to server list failed."));
- setServListGroupName(sc->wGroupId, sc->szGroupName); // add group to namelist
- { // add group to known
- char *szCListGroup = getServListGroupCListPath(sc->wGroupId);
+ servlistPendingRemoveGroup(sc->szGroup, 0, PENDING_RESULT_FAILED);
+ }
+ else { // group added, we need to update master group
+ void* groupData;
+ int groupSize;
- // create link to the original CList group
- setServListGroupLinkID(sc->szGroup, sc->wGroupId);
+ setServListGroupName(sc->wGroupId, sc->szGroupName); // add group to namelist
+ { // add group to known
+ char *szCListGroup = getServListGroupCListPath(sc->wGroupId);
- servlistPendingRemoveGroup(sc->szGroup, sc->wGroupId, PENDING_RESULT_SUCCESS);
- SAFE_FREE((void**)&szCListGroup);
- }
+ // create link to the original CList group
+ setServListGroupLinkID(sc->szGroup, sc->wGroupId);
- groupData = collectGroups(&groupSize);
- groupData = SAFE_REALLOC(groupData, groupSize+2);
- *(((WORD*)groupData)+(groupSize>>1)) = sc->wGroupId; // add this new group id
- groupSize += 2;
+ servlistPendingRemoveGroup(sc->szGroup, sc->wGroupId, PENDING_RESULT_SUCCESS);
+ SAFE_FREE((void**)&szCListGroup);
+ }
- ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action));
- if (ack)
- {
- ack->dwAction = SSA_GROUP_UPDATE;
- dwCookie = AllocateCookie(CKT_SERVERLIST, ICQ_LISTS_UPDATEGROUP, 0, ack);
+ groupData = collectGroups(&groupSize);
+ groupData = SAFE_REALLOC(groupData, groupSize + 2);
+ *(((WORD*)groupData) + (groupSize >> 1)) = sc->wGroupId; // add this new group id
+ groupSize += 2;
- icq_sendServerGroup(dwCookie, ICQ_LISTS_UPDATEGROUP, 0, ack->szGroupName, groupData, groupSize, SSOF_END_OPERATION);
- }
- else // end server modifications here
- servlistPostPacket(NULL, 0, SSO_END_OPERATION, 100);
+ cookie_servlist_action *ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action));
+ if (ack) {
+ ack->dwAction = SSA_GROUP_UPDATE;
- SAFE_FREE((void**)&groupData);
+ DWORD dwCookie = AllocateCookie(CKT_SERVERLIST, ICQ_LISTS_UPDATEGROUP, 0, ack);
+ icq_sendServerGroup(dwCookie, ICQ_LISTS_UPDATEGROUP, 0, ack->szGroupName, groupData, groupSize, SSOF_END_OPERATION);
}
- if (sc->szGroup != sc->szGroupName)
- SAFE_FREE((void**)&sc->szGroup);
+ else // end server modifications here
+ servlistPostPacket(NULL, 0, SSO_END_OPERATION, 100);
- SAFE_FREE((void**)&sc->szGroupName);
- break;
+ SAFE_FREE((void**)&groupData);
}
- case SSA_CONTACT_REMOVE:
- {
- if (!wError)
- {
- void* groupData;
- int groupSize;
+ if (sc->szGroup != sc->szGroupName)
+ SAFE_FREE((void**)&sc->szGroup);
- setWord(sc->hContact, DBSETTING_SERVLIST_ID, 0); // clear the values
- setWord(sc->hContact, DBSETTING_SERVLIST_GROUP, 0);
+ SAFE_FREE((void**)&sc->szGroupName);
+ break;
- FreeServerID(sc->wContactId, SSIT_ITEM);
+ case SSA_CONTACT_REMOVE:
+ if (!wError) {
+ void* groupData;
+ int groupSize;
- servlistPendingRemoveContact(sc->hContact, 0, sc->wGroupId, PENDING_RESULT_SUCCESS);
+ setWord(sc->hContact, DBSETTING_SERVLIST_ID, 0); // clear the values
+ setWord(sc->hContact, DBSETTING_SERVLIST_GROUP, 0);
- if (groupData = collectBuddyGroup(sc->wGroupId, &groupSize))
- { // the group is still not empty, just update it
- updateServerGroupData(sc->wGroupId, groupData, groupSize, SSOF_END_OPERATION);
- }
- else // the group is empty, delete it
- {
- char *szGroup = getServListGroupCListPath(sc->wGroupId);
+ FreeServerID(sc->wContactId, SSIT_ITEM);
- servlistRemoveGroup(szGroup, sc->wGroupId);
- SAFE_FREE((void**)&szGroup);
- }
- SAFE_FREE((void**)&groupData); // free the memory
+ servlistPendingRemoveContact(sc->hContact, 0, sc->wGroupId, PENDING_RESULT_SUCCESS);
+
+ if (groupData = collectBuddyGroup(sc->wGroupId, &groupSize)) { // the group is still not empty, just update it
+ updateServerGroupData(sc->wGroupId, groupData, groupSize, SSOF_END_OPERATION);
}
- else
+ else // the group is empty, delete it
{
- debugLogA("Removing of contact from server list failed, error %d", wError);
- icq_LogMessage(LOG_WARNING, LPGEN("Removing of contact from server list failed."));
+ char *szGroup = getServListGroupCListPath(sc->wGroupId);
- servlistPendingRemoveContact(sc->hContact, sc->wContactId, sc->wGroupId, PENDING_RESULT_FAILED);
-
- servlistPostPacket(NULL, 0, SSO_END_OPERATION, 100); // end server modifications here
+ servlistRemoveGroup(szGroup, sc->wGroupId);
+ SAFE_FREE((void**)&szGroup);
}
- break;
+ SAFE_FREE((void**)&groupData); // free the memory
+ }
+ else {
+ debugLogA("Removing of contact from server list failed, error %d", wError);
+ icq_LogMessage(LOG_WARNING, LPGEN("Removing of contact from server list failed."));
+
+ servlistPendingRemoveContact(sc->hContact, sc->wContactId, sc->wGroupId, PENDING_RESULT_FAILED);
+
+ servlistPostPacket(NULL, 0, SSO_END_OPERATION, 100); // end server modifications here
}
+ break;
+
case SSA_GROUP_UPDATE:
- {
- if (wError)
- {
- debugLogA("Updating of group on server list failed, error %d", wError);
- icq_LogMessage(LOG_WARNING, LPGEN("Updating of group on server list failed."));
- }
- SAFE_FREE((void**)&sc->szGroupName);
- break;
+ if (wError) {
+ debugLogA("Updating of group on server list failed, error %d", wError);
+ icq_LogMessage(LOG_WARNING, LPGEN("Updating of group on server list failed."));
}
+ SAFE_FREE((void**)&sc->szGroupName);
+ break;
+
case SSA_GROUP_REMOVE:
- {
- SAFE_FREE((void**)&sc->szGroupName);
- if (wError)
- {
- debugLogA("Removing of group from server list failed, error %d", wError);
- icq_LogMessage(LOG_WARNING, LPGEN("Removing of group from server list failed."));
+ SAFE_FREE((void**)&sc->szGroupName);
+ if (wError) {
+ debugLogA("Removing of group from server list failed, error %d", wError);
+ icq_LogMessage(LOG_WARNING, LPGEN("Removing of group from server list failed."));
- servlistPendingRemoveGroup(sc->szGroup, 0, PENDING_RESULT_FAILED);
+ servlistPendingRemoveGroup(sc->szGroup, 0, PENDING_RESULT_FAILED);
- servlistPostPacket(NULL, 0, SSO_END_OPERATION, 100); // end server modifications here
- SAFE_FREE((void**)&sc->szGroup);
- }
- else // group removed, we need to update master group
- {
- void* groupData;
- int groupSize;
- DWORD dwCookie;
+ servlistPostPacket(NULL, 0, SSO_END_OPERATION, 100); // end server modifications here
+ SAFE_FREE((void**)&sc->szGroup);
+ }
+ else { // group removed, we need to update master group
+ void* groupData;
+ int groupSize;
- setServListGroupName(sc->wGroupId, NULL); // clear group from namelist
- FreeServerID(sc->wGroupId, SSIT_GROUP);
- removeGroupPathLinks(sc->wGroupId);
+ setServListGroupName(sc->wGroupId, NULL); // clear group from namelist
+ FreeServerID(sc->wGroupId, SSIT_GROUP);
+ removeGroupPathLinks(sc->wGroupId);
- servlistPendingRemoveGroup(sc->szGroup, 0, PENDING_RESULT_SUCCESS);
- SAFE_FREE((void**)&sc->szGroup);
+ servlistPendingRemoveGroup(sc->szGroup, 0, PENDING_RESULT_SUCCESS);
+ SAFE_FREE((void**)&sc->szGroup);
- groupData = collectGroups(&groupSize);
- sc->wGroupId = 0;
- sc->dwAction = SSA_GROUP_UPDATE;
- sc->szGroupName = NULL;
- dwCookie = AllocateCookie(CKT_SERVERLIST, ICQ_LISTS_UPDATEGROUP, 0, sc);
+ groupData = collectGroups(&groupSize);
+ sc->wGroupId = 0;
+ sc->dwAction = SSA_GROUP_UPDATE;
+ sc->szGroupName = NULL;
+ DWORD dwCookie = AllocateCookie(CKT_SERVERLIST, ICQ_LISTS_UPDATEGROUP, 0, sc);
- icq_sendServerGroup(dwCookie, ICQ_LISTS_UPDATEGROUP, 0, sc->szGroupName, groupData, groupSize, SSOF_END_OPERATION);
- // end server modifications here
+ icq_sendServerGroup(dwCookie, ICQ_LISTS_UPDATEGROUP, 0, sc->szGroupName, groupData, groupSize, SSOF_END_OPERATION);
+ // end server modifications here
- sc = NULL; // we do not want to be freed here
+ sc = NULL; // we do not want to be freed here
- SAFE_FREE((void**)&groupData);
- }
- break;
+ SAFE_FREE((void**)&groupData);
}
- case SSA_CONTACT_SET_GROUP:
- { // we moved contact to another group
- if (sc->lParam == -1)
- { // the first was an error
- break;
- }
- if (wError)
- {
- if (wError == 0x0E && sc->lParam == 1)
- { // second ack - adding failed with error 0x0E, try to add with AVAIT_AUTH flag
- DWORD dwCookie;
-
- if (!getByte(sc->hContact, "Auth", 0))
- { // we tried without AWAIT_AUTH, try again with it
- debugLogA("Contact could not be added without authorization, add with await auth flag.");
-
- setByte(sc->hContact, "Auth", 1); // we need auth
- }
- else
- { // we tried with AWAIT_AUTH, try again without
- debugLogA("Contact count not be added awaiting authorization, try authorized.");
+ break;
- setByte(sc->hContact, "Auth", 0);
- }
- dwCookie = AllocateCookie(CKT_SERVERLIST, ICQ_LISTS_ADDTOLIST, sc->hContact, sc);
- icq_sendServerContact(sc->hContact, dwCookie, ICQ_LISTS_ADDTOLIST, sc->wNewGroupId, sc->wNewContactId, SSOP_ITEM_ACTION | SSOF_CONTACT, 400, NULL);
+ case SSA_CONTACT_SET_GROUP:
+ // we moved contact to another group
+ if (sc->lParam == -1) // the first was an error
+ break;
- sc->lParam = 2; // do not cycle
- sc = NULL; // we do not want to be freed here
- break;
+ if (wError) {
+ if (wError == 0x0E && sc->lParam == 1) { // second ack - adding failed with error 0x0E, try to add with AVAIT_AUTH flag
+ if (!getByte(sc->hContact, "Auth", 0)) { // we tried without AWAIT_AUTH, try again with it
+ debugLogA("Contact could not be added without authorization, add with await auth flag.");
+ setByte(sc->hContact, "Auth", 1); // we need auth
}
- FreeServerID(sc->wNewContactId, SSIT_ITEM);
- debugLogA("Moving of user to another group on server list failed, error %d", wError);
- icq_LogMessage(LOG_ERROR, LPGEN("Moving of user to another group on server list failed."));
-
- servlistPendingRemoveContact(sc->hContact, 0, (WORD)(sc->lParam ? sc->wGroupId : sc->wNewGroupId), PENDING_RESULT_FAILED);
-
- servlistPostPacket(NULL, 0, SSO_END_OPERATION, 100); // end server modifications here
-
- if (!sc->lParam) // is this first ack ?
- {
- sc->lParam = -1;
- sc = NULL; // this can't be freed here
+ else { // we tried with AWAIT_AUTH, try again without
+ debugLogA("Contact count not be added awaiting authorization, try authorized.");
+ setByte(sc->hContact, "Auth", 0);
}
+ DWORD dwCookie = AllocateCookie(CKT_SERVERLIST, ICQ_LISTS_ADDTOLIST, sc->hContact, sc);
+ icq_sendServerContact(sc->hContact, dwCookie, ICQ_LISTS_ADDTOLIST, sc->wNewGroupId, sc->wNewContactId, SSOP_ITEM_ACTION | SSOF_CONTACT, 400, NULL);
+
+ sc->lParam = 2; // do not cycle
+ sc = NULL; // we do not want to be freed here
break;
}
- if (sc->lParam) // is this the second ack ?
- {
- void* groupData;
- int groupSize;
- int bEnd = 1; // shall we end the sever modifications
+ FreeServerID(sc->wNewContactId, SSIT_ITEM);
+ debugLogA("Moving of user to another group on server list failed, error %d", wError);
+ icq_LogMessage(LOG_ERROR, LPGEN("Moving of user to another group on server list failed."));
- setWord(sc->hContact, DBSETTING_SERVLIST_ID, sc->wNewContactId);
- setWord(sc->hContact, DBSETTING_SERVLIST_GROUP, sc->wNewGroupId);
+ servlistPendingRemoveContact(sc->hContact, 0, (WORD)(sc->lParam ? sc->wGroupId : sc->wNewGroupId), PENDING_RESULT_FAILED);
- servlistPendingRemoveContact(sc->hContact, sc->wNewContactId, sc->wNewGroupId, PENDING_RESULT_SUCCESS);
+ servlistPostPacket(NULL, 0, SSO_END_OPERATION, 100); // end server modifications here
- if (groupData = collectBuddyGroup(sc->wGroupId, &groupSize)) // update the group we moved from
- { // the group is still not empty, just update it
- updateServerGroupData(sc->wGroupId, groupData, groupSize, 0);
- SAFE_FREE((void**)&groupData); // free the memory
- }
- else
- { // the group is empty, delete it
- char* szGroup = getServListGroupCListPath(sc->wGroupId);
+ if (!sc->lParam) { // is this first ack ?
+ sc->lParam = -1;
+ sc = NULL; // this can't be freed here
+ }
+ break;
+ }
- servlistRemoveGroup(szGroup, sc->wGroupId);
- SAFE_FREE((void**)&szGroup);
- bEnd = 0; // here the modifications go on
- }
+ if (sc->lParam) { // is this the second ack ?
+ void* groupData;
+ int groupSize;
+ int bEnd = 1; // shall we end the sever modifications
- groupData = collectBuddyGroup(sc->wNewGroupId, &groupSize); // update the group we moved to
- updateServerGroupData(sc->wNewGroupId, groupData, groupSize, bEnd ? SSOF_END_OPERATION : 0);
- // end server modifications here
- SAFE_FREE((void**)&groupData);
+ setWord(sc->hContact, DBSETTING_SERVLIST_ID, sc->wNewContactId);
+ setWord(sc->hContact, DBSETTING_SERVLIST_GROUP, sc->wNewGroupId);
+
+ servlistPendingRemoveContact(sc->hContact, sc->wNewContactId, sc->wNewGroupId, PENDING_RESULT_SUCCESS);
+ if (groupData = collectBuddyGroup(sc->wGroupId, &groupSize)) // update the group we moved from
+ { // the group is still not empty, just update it
+ updateServerGroupData(sc->wGroupId, groupData, groupSize, 0);
+ SAFE_FREE((void**)&groupData); // free the memory
}
- else // contact was deleted from server-list
- {
- delSetting(sc->hContact, DBSETTING_SERVLIST_ID);
- delSetting(sc->hContact, DBSETTING_SERVLIST_GROUP);
- FreeServerID(sc->wContactId, SSIT_ITEM); // release old contact id
- sc->lParam = 1;
- sc = NULL; // wait for second ack
+ else { // the group is empty, delete it
+ char* szGroup = getServListGroupCListPath(sc->wGroupId);
+
+ servlistRemoveGroup(szGroup, sc->wGroupId);
+ SAFE_FREE((void**)&szGroup);
+ bEnd = 0; // here the modifications go on
}
- break;
+
+ groupData = collectBuddyGroup(sc->wNewGroupId, &groupSize); // update the group we moved to
+ updateServerGroupData(sc->wNewGroupId, groupData, groupSize, bEnd ? SSOF_END_OPERATION : 0);
+ // end server modifications here
+ SAFE_FREE((void**)&groupData);
+
}
- case SSA_CONTACT_FIX_AUTH:
+ else // contact was deleted from server-list
{
- if (wError)
- { // FIXME: something failed, we should handle it properly
- }
- break;
+ delSetting(sc->hContact, DBSETTING_SERVLIST_ID);
+ delSetting(sc->hContact, DBSETTING_SERVLIST_GROUP);
+ FreeServerID(sc->wContactId, SSIT_ITEM); // release old contact id
+ sc->lParam = 1;
+ sc = NULL; // wait for second ack
+ }
+ break;
+
+ case SSA_CONTACT_FIX_AUTH:
+ if (wError) { // FIXME: something failed, we should handle it properly
}
+ break;
+
case SSA_GROUP_RENAME:
- {
- if (wError)
- {
- debugLogA("Renaming of server group failed, error %d", wError);
- icq_LogMessage(LOG_WARNING, LPGEN("Renaming of server group failed."));
+ if (wError) {
+ debugLogA("Renaming of server group failed, error %d", wError);
+ icq_LogMessage(LOG_WARNING, LPGEN("Renaming of server group failed."));
- servlistPendingRemoveGroup(sc->szGroup, sc->wGroupId, PENDING_RESULT_FAILED);
- }
- else
- {
- setServListGroupName(sc->wGroupId, sc->szGroupName);
- removeGroupPathLinks(sc->wGroupId);
- { // add group to known
- char *szCListGroup = getServListGroupCListPath(sc->wGroupId);
-
- /// FIXME: need to create link to the new group name before unique item name correction as well
- setServListGroupLinkID(szCListGroup, sc->wGroupId);
- SAFE_FREE((void**)&szCListGroup);
- }
- servlistPendingRemoveGroup(sc->szGroup, sc->wGroupId, PENDING_RESULT_SUCCESS);
+ servlistPendingRemoveGroup(sc->szGroup, sc->wGroupId, PENDING_RESULT_FAILED);
+ }
+ else {
+ setServListGroupName(sc->wGroupId, sc->szGroupName);
+ removeGroupPathLinks(sc->wGroupId);
+ { // add group to known
+ char *szCListGroup = getServListGroupCListPath(sc->wGroupId);
+
+ /// FIXME: need to create link to the new group name before unique item name correction as well
+ setServListGroupLinkID(szCListGroup, sc->wGroupId);
+ SAFE_FREE((void**)&szCListGroup);
}
- SAFE_FREE((void**)&sc->szGroupName);
- SAFE_FREE((void**)&sc->szGroup);
- break;
+ servlistPendingRemoveGroup(sc->szGroup, sc->wGroupId, PENDING_RESULT_SUCCESS);
}
+ SAFE_FREE((void**)&sc->szGroupName);
+ SAFE_FREE((void**)&sc->szGroup);
+ break;
+
case SSA_SETAVATAR:
- {
- if (wError)
- {
- debugLogA("Uploading of avatar hash failed.");
- if (sc->wGroupId) // is avatar added or updated?
- {
- FreeServerID(sc->wContactId, SSIT_ITEM);
- delSetting(DBSETTING_SERVLIST_AVATAR); // to fix old versions
- }
- }
- else
- {
- setWord(DBSETTING_SERVLIST_AVATAR, sc->wContactId);
+ if (wError) {
+ debugLogA("Uploading of avatar hash failed.");
+ if (sc->wGroupId) { // is avatar added or updated?
+ FreeServerID(sc->wContactId, SSIT_ITEM);
+ delSetting(DBSETTING_SERVLIST_AVATAR); // to fix old versions
}
- break;
}
+ else setWord(DBSETTING_SERVLIST_AVATAR, sc->wContactId);
+ break;
+
case SSA_REMOVEAVATAR:
- {
- if (wError)
- debugLogA("Removing of avatar hash failed.");
- else
- {
- FreeServerID(sc->wContactId, SSIT_ITEM);
- delSetting(DBSETTING_SERVLIST_AVATAR);
- }
- break;
+ if (wError)
+ debugLogA("Removing of avatar hash failed.");
+ else {
+ FreeServerID(sc->wContactId, SSIT_ITEM);
+ delSetting(DBSETTING_SERVLIST_AVATAR);
}
+ break;
+
case SSA_SERVLIST_ACK:
- {
- ProtoBroadcastAck(sc->hContact, ICQACKTYPE_SERVERCLIST, wError?ACKRESULT_FAILED:ACKRESULT_SUCCESS, (HANDLE)sc->lParam, wError);
- break;
- }
+ ProtoBroadcastAck(sc->hContact, ICQACKTYPE_SERVERCLIST, wError ? ACKRESULT_FAILED : ACKRESULT_SUCCESS, (HANDLE)sc->lParam, wError);
+ break;
+
case SSA_IMPORT:
- {
- if (wError)
- debugLogA("Re-starting import sequence failed, error %d", wError);
- else
- {
- setWord("SrvImportID", 0);
- delSetting("ImportTS");
- }
- break;
+ if (wError)
+ debugLogA("Re-starting import sequence failed, error %d", wError);
+ else {
+ setWord("SrvImportID", 0);
+ delSetting("ImportTS");
}
+ break;
+
default:
debugLogA("Server ack cookie type (%d) not recognized.", sc->dwAction);
}
- SAFE_FREE((void**)&sc); // free the memory
+ SAFE_FREE((void**)&sc); // free the memory
return;
}
-
MCONTACT CIcqProto::HContactFromRecordName(const char* szRecordName, int *bAdded)
{
MCONTACT hContact = INVALID_CONTACT_ID;
- if (!IsStringUIN(szRecordName))
- { // probably AIM contact
+ if (!IsStringUIN(szRecordName)) // probably AIM contact
hContact = HContactFromUID(0, szRecordName, bAdded);
- }
- else
- { // this should be ICQ number
+ else { // this should be ICQ number
DWORD dwUin = atoi(szRecordName);
-
hContact = HContactFromUIN(dwUin, bAdded);
}
return hContact;
}
-
int CIcqProto::getServerDataFromItemTLV(oscar_tlv_chain* pChain, unsigned char *buf) /// FIXME: need to keep original order
-{ // get server-list item's TLV data
+{
+ // get server-list item's TLV data
oscar_tlv_chain* list = pChain;
int datalen = 0;
icq_packet pBuf;
@@ -795,14 +679,12 @@ int CIcqProto::getServerDataFromItemTLV(oscar_tlv_chain* pChain, unsigned char * pBuf.wPlace = 0;
pBuf.pData = buf;
- while (list)
- { // collect non-standard TLVs and save them to DB
+ while (list) { // collect non-standard TLVs and save them to DB
if (list->tlv.wType != SSI_TLV_AWAITING_AUTH &&
- list->tlv.wType != SSI_TLV_NAME &&
- list->tlv.wType != SSI_TLV_COMMENT &&
- list->tlv.wType != SSI_TLV_METAINFO_TOKEN &&
- list->tlv.wType != SSI_TLV_METAINFO_TIME)
- { // only TLVs which we do not handle on our own
+ list->tlv.wType != SSI_TLV_NAME &&
+ list->tlv.wType != SSI_TLV_COMMENT &&
+ list->tlv.wType != SSI_TLV_METAINFO_TOKEN &&
+ list->tlv.wType != SSI_TLV_METAINFO_TIME) { // only TLVs which we do not handle on our own
packTLV(&pBuf, list->tlv.wType, list->tlv.wLen, list->tlv.pData);
datalen += list->tlv.wLen + 4;
@@ -812,7 +694,6 @@ int CIcqProto::getServerDataFromItemTLV(oscar_tlv_chain* pChain, unsigned char * return datalen;
}
-
void CIcqProto::handleServerCListReply(BYTE *buf, WORD wLen, WORD wFlags, serverthread_info *info)
{
BYTE bySSIVersion;
@@ -854,76 +735,58 @@ void CIcqProto::handleServerCListReply(BYTE *buf, WORD wLen, WORD wFlags, server wLen -= 2;
debugLogA("SSI: number of entries is %u, version is %u", wRecordCount, bySSIVersion);
-
// Loop over all items in the packet
- for (wRecord = 0; wRecord < wRecordCount; wRecord++)
- {
+ for (wRecord = 0; wRecord < wRecordCount; wRecord++) {
debugLogA("SSI: parsing record %u", wRecord + 1);
- if (wLen < 10)
- { // minimum: name length (zero), group ID, item ID, empty TLV
+ if (wLen < 10) { // minimum: name length (zero), group ID, item ID, empty TLV
debugLogA("Warning: SSI parsing error (%d)", 0);
break;
}
- if (!unpackServerListItem(&buf, &wLen, szRecordName, &wGroupId, &wItemId, &wTlvType, &wTlvLength))
- { // unpack basic structure
+ if (!unpackServerListItem(&buf, &wLen, szRecordName, &wGroupId, &wItemId, &wTlvType, &wTlvLength)) { // unpack basic structure
debugLogA("Warning: SSI parsing error (%d)", 1);
break;
}
debugLogA("Name: '%s', GroupID: %u, EntryID: %u, EntryType: %u, TLVlength: %u",
- szRecordName, wGroupId, wItemId, wTlvType, wTlvLength);
+ szRecordName, wGroupId, wItemId, wTlvType, wTlvLength);
- if (wLen < wTlvLength)
- {
+ if (wLen < wTlvLength) {
debugLogA("Warning: SSI parsing error (%d)", 2);
break;
}
// Initialize the tlv chain
- if (wTlvLength > 0)
- {
+ if (wTlvLength > 0) {
pChain = readIntoTLVChain(&buf, wTlvLength, 0);
wLen -= wTlvLength;
}
- else
- {
- pChain = NULL;
- }
-
-
- switch (wTlvType)
- {
+ else pChain = NULL;
+ switch (wTlvType) {
case SSI_ITEM_BUDDY:
{
/* this is a contact */
- MCONTACT hContact;
int bAdded;
+ MCONTACT hContact = HContactFromRecordName(szRecordName, &bAdded);
- hContact = HContactFromRecordName(szRecordName, &bAdded);
-
- if (hContact != INVALID_CONTACT_ID)
- {
+ if (hContact != INVALID_CONTACT_ID) {
int bRegroup = 0;
int bNicked = 0;
- if (bAdded)
- { // Not already on list: added
+ if (bAdded) { // Not already on list: added
debugLogA("SSI added new %s contact '%s'", "ICQ", szRecordName);
AddJustAddedContact(hContact);
}
- else
- { // we should add new contacts and this contact was just added, show it
- if (IsContactJustAdded(hContact))
- {
+ else { // we should add new contacts and this contact was just added, show it
+ if (IsContactJustAdded(hContact)) {
setContactHidden(hContact, 0);
bAdded = 1; // we want details for new contacts
}
- else
- debugLogA("SSI ignoring existing contact '%s'", szRecordName);
+ else debugLogA("SSI ignoring existing contact '%s'", szRecordName);
+
// Contact on server is always on list
db_set_b(hContact, "CList", "NotOnList", 0);
}
@@ -933,26 +796,22 @@ void CIcqProto::handleServerCListReply(BYTE *buf, WORD wLen, WORD wFlags, server setWord(hContact, DBSETTING_SERVLIST_GROUP, wGroupId);
ReserveServerID(wItemId, SSIT_ITEM, 0);
- if (!bAdded && getByte("LoadServerDetails", DEFAULT_SS_LOAD))
- { // check if the contact has been moved on the server
- if (wActiveSrvGroupId != wGroupId || !szActiveSrvGroup)
- {
+ if (!bAdded && getByte("LoadServerDetails", DEFAULT_SS_LOAD)) { // check if the contact has been moved on the server
+ if (wActiveSrvGroupId != wGroupId || !szActiveSrvGroup) {
SAFE_FREE(&szActiveSrvGroup);
szActiveSrvGroup = getServListGroupCListPath(wGroupId);
wActiveSrvGroupId = wGroupId;
}
char *szLocalGroup = getContactCListGroup(hContact);
- if (!strlennull(szLocalGroup))
- { // no CListGroup
+ if (!strlennull(szLocalGroup)) { // no CListGroup
SAFE_FREE(&szLocalGroup);
szLocalGroup = null_strdup(DEFAULT_SS_GROUP);
}
if (strcmpnull(szActiveSrvGroup, szLocalGroup) &&
- (strlennull(szActiveSrvGroup) >= strlennull(szLocalGroup) || (szActiveSrvGroup && _strnicmp(szActiveSrvGroup, szLocalGroup, strlennull(szLocalGroup)))))
- { // contact moved to new group or sub-group or not to master group
+ (strlennull(szActiveSrvGroup) >= strlennull(szLocalGroup) || (szActiveSrvGroup && _strnicmp(szActiveSrvGroup, szLocalGroup, strlennull(szLocalGroup))))) { // contact moved to new group or sub-group or not to master group
bRegroup = 1;
}
if (bRegroup && !stricmpnull(DEFAULT_SS_GROUP, szActiveSrvGroup)) /// TODO: invent something more clever for "root" group
@@ -962,27 +821,21 @@ void CIcqProto::handleServerCListReply(BYTE *buf, WORD wLen, WORD wFlags, server SAFE_FREE(&szLocalGroup);
}
- if (bRegroup || bAdded)
- { // if we should load server details or contact was just added, update its group
- if (wActiveSrvGroupId != wGroupId || !szActiveSrvGroup)
- {
+ if (bRegroup || bAdded) { // if we should load server details or contact was just added, update its group
+ if (wActiveSrvGroupId != wGroupId || !szActiveSrvGroup) {
SAFE_FREE(&szActiveSrvGroup);
szActiveSrvGroup = getServListGroupCListPath(wGroupId);
wActiveSrvGroupId = wGroupId;
}
- if (szActiveSrvGroup)
- { // try to get Miranda Group path from groupid, if succeeded save to db
+ if (szActiveSrvGroup) { // try to get Miranda Group path from groupid, if succeeded save to db
moveContactToCListGroup(hContact, szActiveSrvGroup);
}
}
- if (pChain)
- { // Look for nickname TLV and copy it to the db if necessary
- if (pTLV = pChain->getTLV(SSI_TLV_NAME, 1))
- {
- if (pTLV->pData && (pTLV->wLen > 0))
- {
+ if (pChain) { // Look for nickname TLV and copy it to the db if necessary
+ if (pTLV = pChain->getTLV(SSI_TLV_NAME, 1)) {
+ if (pTLV->pData && (pTLV->wLen > 0)) {
char *pszNick;
WORD wNickLength;
@@ -998,45 +851,35 @@ void CIcqProto::handleServerCListReply(BYTE *buf, WORD wLen, WORD wFlags, server bNicked = 1;
// Write nickname to database
- if (getByte("LoadServerDetails", DEFAULT_SS_LOAD) || bAdded)
- { // if just added contact, save details always - does no harm
+ if (getByte("LoadServerDetails", DEFAULT_SS_LOAD) || bAdded) { // if just added contact, save details always - does no harm
char *szOldNick;
- if (szOldNick = getSettingStringUtf(hContact, "CList", "MyHandle", NULL))
- {
- if ((strcmpnull(szOldNick, pszNick)) && (strlennull(pszNick) > 0))
- { // check if the truncated nick changed, i.e. do not overwrite locally stored longer nick
- if (strlennull(szOldNick) <= strlennull(pszNick) || strncmp(szOldNick, pszNick, null_strcut(szOldNick, MAX_SSI_TLV_NAME_SIZE)))
- {
+ if (szOldNick = getSettingStringUtf(hContact, "CList", "MyHandle", NULL)) {
+ if ((strcmpnull(szOldNick, pszNick)) && (strlennull(pszNick) > 0)) { // check if the truncated nick changed, i.e. do not overwrite locally stored longer nick
+ if (strlennull(szOldNick) <= strlennull(pszNick) || strncmp(szOldNick, pszNick, null_strcut(szOldNick, MAX_SSI_TLV_NAME_SIZE))) {
// Yes, we really do need to delete it first. Otherwise the CLUI nick
// cache isn't updated (I'll look into it)
- db_unset(hContact,"CList","MyHandle");
+ db_unset(hContact, "CList", "MyHandle");
db_set_utf(hContact, "CList", "MyHandle", pszNick);
}
}
SAFE_FREE(&szOldNick);
}
- else if (strlennull(pszNick) > 0)
- {
- db_unset(hContact,"CList","MyHandle");
+ else if (strlennull(pszNick) > 0) {
+ db_unset(hContact, "CList", "MyHandle");
db_set_utf(hContact, "CList", "MyHandle", pszNick);
}
}
SAFE_FREE(&pszNick);
}
- else
- {
- debugLogA("Invalid nickname");
- }
+ else debugLogA("Invalid nickname");
}
if (bAdded && !bNicked)
icq_QueueUser(hContact); // queue user without nick for fast auto info update
// Look for comment TLV and copy it to the db if necessary
- if (pTLV = pChain->getTLV(SSI_TLV_COMMENT, 1))
- {
- if (pTLV->pData && (pTLV->wLen > 0))
- {
+ if (pTLV = pChain->getTLV(SSI_TLV_COMMENT, 1)) {
+ if (pTLV->pData && (pTLV->wLen > 0)) {
char *pszComment;
WORD wCommentLength;
@@ -1051,91 +894,70 @@ void CIcqProto::handleServerCListReply(BYTE *buf, WORD wLen, WORD wFlags, server debugLogA("Comment is '%s'", pszComment);
// Write comment to database
- if (getByte("LoadServerDetails", DEFAULT_SS_LOAD) || bAdded)
- { // if just added contact, save details always - does no harm
+ if (getByte("LoadServerDetails", DEFAULT_SS_LOAD) || bAdded) { // if just added contact, save details always - does no harm
char *szOldComment;
- if (szOldComment = getSettingStringUtf(hContact, "UserInfo", "MyNotes", NULL))
- {
- if ((strcmpnull(szOldComment, pszComment)) && (strlennull(pszComment) > 0))
- { // check if the truncated comment changed, i.e. do not overwrite locally stored longer comment
+ if (szOldComment = getSettingStringUtf(hContact, "UserInfo", "MyNotes", NULL)) {
+ if ((strcmpnull(szOldComment, pszComment)) && (strlennull(pszComment) > 0)) // check if the truncated comment changed, i.e. do not overwrite locally stored longer comment
if (strlennull(szOldComment) <= strlennull(pszComment) || strncmp((char*)szOldComment, (char*)pszComment, null_strcut(szOldComment, MAX_SSI_TLV_COMMENT_SIZE)))
- {
db_set_utf(hContact, "UserInfo", "MyNotes", pszComment);
- }
- }
+
SAFE_FREE((void**)&szOldComment);
}
else if (strlennull(pszComment) > 0)
- {
db_set_utf(hContact, "UserInfo", "MyNotes", pszComment);
- }
}
SAFE_FREE((void**)&pszComment);
}
- else
- {
- debugLogA("Invalid comment");
- }
+ else debugLogA("Invalid comment");
}
// Look for need-authorization TLV
- if (pChain->getTLV(SSI_TLV_AWAITING_AUTH, 1))
- {
+ if (pChain->getTLV(SSI_TLV_AWAITING_AUTH, 1)) {
setByte(hContact, "Auth", 1);
debugLogA("SSI contact need authorization");
}
- else
- {
- setByte(hContact, "Auth", 0);
- }
+ else setByte(hContact, "Auth", 0);
- if (pTLV = pChain->getTLV(SSI_TLV_METAINFO_TOKEN, 1))
- {
+ if (pTLV = pChain->getTLV(SSI_TLV_METAINFO_TOKEN, 1)) {
setSettingBlob(hContact, DBSETTING_METAINFO_TOKEN, pTLV->pData, pTLV->wLen);
if (pChain->getTLV(SSI_TLV_METAINFO_TIME, 1))
setSettingDouble(hContact, DBSETTING_METAINFO_TIME, pChain->getDouble(SSI_TLV_METAINFO_TIME, 1));
debugLogA("SSI contact has meta info token");
}
- else
- {
+ else {
delSetting(hContact, DBSETTING_METAINFO_TOKEN);
delSetting(hContact, DBSETTING_METAINFO_TIME);
}
- { // store server-list item's TLV data
- BYTE* data = (BYTE*)SAFE_MALLOC(wTlvLength);
- int datalen = getServerDataFromItemTLV(pChain, data);
+ { // store server-list item's TLV data
+ BYTE* data = (BYTE*)SAFE_MALLOC(wTlvLength);
+ int datalen = getServerDataFromItemTLV(pChain, data);
- if (datalen > 0)
- setSettingBlob(hContact, DBSETTING_SERVLIST_DATA, data, datalen);
- else
- delSetting(hContact, DBSETTING_SERVLIST_DATA);
+ if (datalen > 0)
+ setSettingBlob(hContact, DBSETTING_SERVLIST_DATA, data, datalen);
+ else
+ delSetting(hContact, DBSETTING_SERVLIST_DATA);
- SAFE_FREE((void**)&data);
- }
+ SAFE_FREE((void**)&data);
+ }
}
}
- else
- { // failed to add or other error
+ else // failed to add or other error
debugLogA("SSI failed to handle %s Item '%s'", "Buddy", szRecordName);
- }
}
break;
case SSI_ITEM_GROUP:
- if ((wGroupId == 0) && (wItemId == 0))
- {
+ if ((wGroupId == 0) && (wItemId == 0)) {
/* list of groups. wTlvType=1, data is TLV(C8) containing list of WORDs which */
/* is the group ids
/* we don't need to use this. Our processing is on-the-fly */
/* this record is always sent first in the first packet only, */
}
- else if (wGroupId != 0)
- {
+ else if (wGroupId != 0) {
/* wGroupId != 0: a group record */
- if (wItemId == 0)
- { /* no item ID: this is a group */
+ if (wItemId == 0) { /* no item ID: this is a group */
/* pszRecordName is the name of the group */
ReserveServerID(wGroupId, SSIT_GROUP, 0);
@@ -1151,15 +973,9 @@ void CIcqProto::handleServerCListReply(BYTE *buf, WORD wLen, WORD wFlags, server /* TLV contains a TLV(C8) with a list of WORDs of contained contact IDs */
/* our processing is good enough that we don't need this duplication */
}
- else
- {
- debugLogA("Unhandled type 0x01, wItemID != 0");
- }
- }
- else
- {
- debugLogA("Unhandled type 0x01");
+ else debugLogA("Unhandled type 0x01, wItemID != 0");
}
+ else debugLogA("Unhandled type 0x01");
break;
case SSI_ITEM_PERMIT:
@@ -1167,23 +983,18 @@ void CIcqProto::handleServerCListReply(BYTE *buf, WORD wLen, WORD wFlags, server /* item on visible list */
/* wItemId not related to contact ID */
/* pszRecordName is the UIN */
- MCONTACT hContact;
int bAdded;
+ MCONTACT hContact = HContactFromRecordName(szRecordName, &bAdded);
- hContact = HContactFromRecordName(szRecordName, &bAdded);
-
- if (hContact != INVALID_CONTACT_ID)
- {
- if (bAdded)
- {
+ if (hContact != INVALID_CONTACT_ID) {
+ if (bAdded) {
debugLogA("SSI added new %s contact '%s'", "Permit", szRecordName);
// It wasn't previously in the list, we hide it so it only appears in the visible list
setContactHidden(hContact, 1);
// Add it to the list, so it can be added properly if proper contact
AddJustAddedContact(hContact);
}
- else
- debugLogA("SSI %s contact already exists '%s'", "Permit", szRecordName);
+ else debugLogA("SSI %s contact already exists '%s'", "Permit", szRecordName);
// Save permit ID
setWord(hContact, DBSETTING_SERVLIST_PERMIT, wItemId);
@@ -1192,10 +1003,8 @@ void CIcqProto::handleServerCListReply(BYTE *buf, WORD wLen, WORD wFlags, server setWord(hContact, "ApparentMode", ID_STATUS_ONLINE);
debugLogA("Visible-contact (%s)", szRecordName);
}
- else
- { // failed to add or other error
+ else { // failed to add or other error
debugLogA("SSI failed to handle %s Item '%s'", "Permit", szRecordName);
-
ReserveServerID(wItemId, SSIT_ITEM, SSIF_UNHANDLED);
}
}
@@ -1206,15 +1015,11 @@ void CIcqProto::handleServerCListReply(BYTE *buf, WORD wLen, WORD wFlags, server /* Item on invisible list */
/* wItemId not related to contact ID */
/* pszRecordName is the UIN */
- MCONTACT hContact;
int bAdded;
+ MCONTACT hContact = HContactFromRecordName(szRecordName, &bAdded);
- hContact = HContactFromRecordName(szRecordName, &bAdded);
-
- if (hContact != INVALID_CONTACT_ID)
- {
- if (bAdded)
- {
+ if (hContact != INVALID_CONTACT_ID) {
+ if (bAdded) {
/* not already on list: added */
debugLogA("SSI added new %s contact '%s'", "Deny", szRecordName);
// It wasn't previously in the list, we hide it so it only appears in the visible list
@@ -1222,8 +1027,7 @@ void CIcqProto::handleServerCListReply(BYTE *buf, WORD wLen, WORD wFlags, server // Add it to the list, so it can be added properly if proper contact
AddJustAddedContact(hContact);
}
- else
- debugLogA("SSI %s contact already exists '%s'", "Deny", szRecordName);
+ else debugLogA("SSI %s contact already exists '%s'", "Deny", szRecordName);
// Save Deny ID
setWord(hContact, DBSETTING_SERVLIST_DENY, wItemId);
@@ -1233,30 +1037,22 @@ void CIcqProto::handleServerCListReply(BYTE *buf, WORD wLen, WORD wFlags, server setWord(hContact, "ApparentMode", ID_STATUS_OFFLINE);
debugLogA("Invisible-contact (%s)", szRecordName);
}
- else
- { // failed to add or other error
+ else { // failed to add or other error
debugLogA("SSI failed to handle %s Item '%s'", "Deny", szRecordName);
-
ReserveServerID(wItemId, SSIT_ITEM, SSIF_UNHANDLED);
}
}
break;
case SSI_ITEM_VISIBILITY: /* My visibility settings */
- {
- BYTE bVisibility;
-
- // Look for visibility TLV
- if (bVisibility = pChain->getByte(SSI_TLV_VISIBILITY, 1))
- { // found it, store the id, we do not need current visibility - we do not rely on it
- setWord(DBSETTING_SERVLIST_PRIVACY, wItemId);
- ReserveServerID(wItemId, SSIT_ITEM, 0);
+ // Look for visibility TLV
+ if (BYTE bVisibility = pChain->getByte(SSI_TLV_VISIBILITY, 1)) { // found it, store the id, we do not need current visibility - we do not rely on it
+ setWord(DBSETTING_SERVLIST_PRIVACY, wItemId);
+ ReserveServerID(wItemId, SSIT_ITEM, 0);
- debugLogA("Visibility is %u", bVisibility);
- }
- else
- ReserveServerID(wItemId, SSIT_ITEM, SSIF_UNHANDLED);
+ debugLogA("Visibility is %u", bVisibility);
}
+ else ReserveServerID(wItemId, SSIT_ITEM, SSIF_UNHANDLED);
break;
case SSI_ITEM_IGNORE:
@@ -1264,15 +1060,11 @@ void CIcqProto::handleServerCListReply(BYTE *buf, WORD wLen, WORD wFlags, server /* item on ignore list */
/* wItemId not related to contact ID */
/* pszRecordName is the UIN */
- MCONTACT hContact;
int bAdded;
+ MCONTACT hContact = HContactFromRecordName(szRecordName, &bAdded);
- hContact = HContactFromRecordName(szRecordName, &bAdded);
-
- if (hContact != INVALID_CONTACT_ID)
- {
- if (bAdded)
- {
+ if (hContact != INVALID_CONTACT_ID) {
+ if (bAdded) {
/* not already on list: add */
debugLogA("SSI added new %s contact '%s'", "Ignore", szRecordName);
// It wasn't previously in the list, we hide it
@@ -1280,8 +1072,7 @@ void CIcqProto::handleServerCListReply(BYTE *buf, WORD wLen, WORD wFlags, server // Add it to the list, so it can be added properly if proper contact
AddJustAddedContact(hContact);
}
- else
- debugLogA("SSI %s contact already exists '%s'", "Ignore", szRecordName);
+ else debugLogA("SSI %s contact already exists '%s'", "Ignore", szRecordName);
// Save Ignore ID
setWord(hContact, DBSETTING_SERVLIST_IGNORE, wItemId);
@@ -1293,10 +1084,8 @@ void CIcqProto::handleServerCListReply(BYTE *buf, WORD wLen, WORD wFlags, server CallService(MS_IGNORE_IGNORE, hContact, IGNOREEVENT_ALL);
debugLogA("Ignore-contact (%s)", szRecordName);
}
- else
- { // failed to add or other error
+ else { // failed to add or other error
debugLogA("SSI failed to handle %s Item '%s'", "Ignore", szRecordName);
-
ReserveServerID(wItemId, SSIT_ITEM, SSIF_UNHANDLED);
}
}
@@ -1309,8 +1098,7 @@ void CIcqProto::handleServerCListReply(BYTE *buf, WORD wLen, WORD wFlags, server break;
case SSI_ITEM_IMPORTTIME:
- if (wGroupId == 0)
- {
+ if (wGroupId == 0) {
/* time our list was first imported */
/* pszRecordName is "Import Time" */
/* data is TLV(13) {TLV(D4) {time_t importTime}} */
@@ -1322,20 +1110,17 @@ void CIcqProto::handleServerCListReply(BYTE *buf, WORD wLen, WORD wFlags, server break;
case SSI_ITEM_BUDDYICON:
- if (wGroupId == 0)
- {
+ if (wGroupId == 0) {
/* our avatar MD5-hash */
/* pszRecordName is "1" */
/* data is TLV(D5) hash */
/* we ignore this, just save the id */
/* cause we get the hash again after login */
- if (!strcmpnull(szRecordName, "12"))
- { // need to handle Photo Item separately
+ if (!strcmpnull(szRecordName, "12")) { // need to handle Photo Item separately
setWord(DBSETTING_SERVLIST_PHOTO, wItemId);
debugLogA("SSI %s item recognized", "Photo");
}
- else
- {
+ else {
setWord(DBSETTING_SERVLIST_AVATAR, wItemId);
debugLogA("SSI %s item recognized", "Avatar");
}
@@ -1344,8 +1129,7 @@ void CIcqProto::handleServerCListReply(BYTE *buf, WORD wLen, WORD wFlags, server break;
case SSI_ITEM_METAINFO:
- if (wGroupId == 0)
- {
+ if (wGroupId == 0) {
/* our meta info token & last update time */
/* pszRecordName is "ICQ-MDIR" */
/* data is TLV(15C) and TLV(15D) */
@@ -1364,8 +1148,7 @@ void CIcqProto::handleServerCListReply(BYTE *buf, WORD wLen, WORD wFlags, server break;
case SSI_ITEM_CLIENTDATA:
- if (wGroupId == 0)
- {
+ if (wGroupId == 0) {
/* ICQ2k ShortcutBar Items */
/* data is TLV(CD) text */
if (wItemId)
@@ -1394,8 +1177,7 @@ void CIcqProto::handleServerCListReply(BYTE *buf, WORD wLen, WORD wFlags, server setWord("SrvRecordCount", (WORD)(wRecord + getWord("SrvRecordCount", 0)));
- if (bIsLastPacket)
- {
+ if (bIsLastPacket) {
// No contacts left to sync
bIsSyncingCL = FALSE;
@@ -1403,8 +1185,7 @@ void CIcqProto::handleServerCListReply(BYTE *buf, WORD wLen, WORD wFlags, server icq_RescanInfoUpdate();
- if (wLen >= 4)
- {
+ if (wLen >= 4) {
DWORD dwLastUpdateTime;
/* finally we get a time_t of the last update time */
@@ -1417,15 +1198,11 @@ void CIcqProto::handleServerCListReply(BYTE *buf, WORD wLen, WORD wFlags, server servlistProcessLogin();
}
- else
- {
- debugLogA("Last packet missed update time...");
- }
- if (getWord("SrvRecordCount", 0) == 0)
- { // we got empty serv-list, create master group
+ else debugLogA("Last packet missed update time...");
+
+ if (getWord("SrvRecordCount", 0) == 0) { // we got empty serv-list, create master group
cookie_servlist_action* ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action));
- if (ack)
- {
+ if (ack) {
DWORD dwCookie;
ack->dwAction = SSA_GROUP_UPDATE;
@@ -1437,25 +1214,18 @@ void CIcqProto::handleServerCListReply(BYTE *buf, WORD wLen, WORD wFlags, server // serv-list sync finished, clear just added contacts
FlushJustAddedContacts();
}
- else
- {
- debugLogA("Waiting for more packets");
- }
+ else debugLogA("Waiting for more packets");
}
-
void CIcqProto::handleServerCListItemAdd(const char *szRecordName, WORD wGroupId, WORD wItemId, WORD wItemType, oscar_tlv_chain *pItemData)
{
- if (wItemType == SSI_ITEM_IMPORTTIME)
- {
- if (pItemData)
- {
+ if (wItemType == SSI_ITEM_IMPORTTIME) {
+ if (pItemData) {
setDword("ImportTS", pItemData->getDWord(SSI_TLV_TIMESTAMP, 1));
setWord("SrvImportID", wItemId);
ReserveServerID(wItemId, SSIT_ITEM, 0);
debugLogA("Server added Import timestamp to list");
-
return;
}
}
@@ -1463,20 +1233,16 @@ void CIcqProto::handleServerCListItemAdd(const char *szRecordName, WORD wGroupId ReserveServerID(wItemId, wItemType == SSI_ITEM_GROUP ? SSIT_GROUP : SSIT_ITEM, SSIF_UNHANDLED);
}
-
void CIcqProto::handleServerCListItemUpdate(const char *szRecordName, WORD wGroupId, WORD wItemId, WORD wItemType, oscar_tlv_chain *pItemData)
{
MCONTACT hContact = (wItemType == SSI_ITEM_BUDDY || wItemType == SSI_ITEM_DENY || wItemType == SSI_ITEM_PERMIT || wItemType == SSI_ITEM_IGNORE) ? HContactFromRecordName(szRecordName, NULL) : NULL;
- if (hContact != INVALID_CONTACT_ID && wItemType == SSI_ITEM_BUDDY)
- { // a contact was updated on server
- if (pItemData)
- {
- oscar_tlv* pAuth = pItemData->getTLV(SSI_TLV_AWAITING_AUTH, 1);
+ if (hContact != INVALID_CONTACT_ID && wItemType == SSI_ITEM_BUDDY) { // a contact was updated on server
+ if (pItemData) {
+ oscar_tlv *pAuth = pItemData->getTLV(SSI_TLV_AWAITING_AUTH, 1);
BYTE bAuth = getByte(hContact, "Auth", 0);
- if (bAuth && !pAuth)
- { // server authorized our contact
+ if (bAuth && !pAuth) { // server authorized our contact
char str[MAX_PATH];
char msg[MAX_PATH];
char *nick = NickFromHandleUtf(hContact);
@@ -1486,8 +1252,7 @@ void CIcqProto::handleServerCListItemUpdate(const char *szRecordName, WORD wGrou icq_LogMessage(LOG_WARNING, str);
SAFE_FREE(&nick);
}
- else if (!bAuth && pAuth)
- { // server took away authorization of our contact
+ else if (!bAuth && pAuth) { // server took away authorization of our contact
char str[MAX_PATH];
char msg[MAX_PATH];
char *nick = NickFromHandleUtf(hContact);
@@ -1497,16 +1262,14 @@ void CIcqProto::handleServerCListItemUpdate(const char *szRecordName, WORD wGrou icq_LogMessage(LOG_WARNING, str);
SAFE_FREE(&nick);
}
-
- { // update metainfo data
- DBVARIANT dbv = {0};
+ {
+ // update metainfo data
+ DBVARIANT dbv = { 0 };
oscar_tlv *pToken = pItemData->getTLV(SSI_TLV_METAINFO_TOKEN, 1);
oscar_tlv *pTime = pItemData->getTLV(SSI_TLV_METAINFO_TIME, 1);
- if (!getSetting(hContact, DBSETTING_METAINFO_TOKEN, &dbv))
- {
- if (!pToken || dbv.cpbVal != pToken->wLen || memcmp(dbv.pbVal, pToken->pData, dbv.cpbVal))
- {
+ if (!getSetting(hContact, DBSETTING_METAINFO_TOKEN, &dbv)) {
+ if (!pToken || dbv.cpbVal != pToken->wLen || memcmp(dbv.pbVal, pToken->pData, dbv.cpbVal)) {
if (!pToken)
debugLogA("Contact %s, meta info token removed", szRecordName);
else
@@ -1519,8 +1282,7 @@ void CIcqProto::handleServerCListItemUpdate(const char *szRecordName, WORD wGrou db_free(&dbv);
}
- else if (pToken)
- {
+ else if (pToken) {
debugLogA("Contact %s, meta info token added", szRecordName);
// user info was changed, refresh
@@ -1533,8 +1295,8 @@ void CIcqProto::handleServerCListItemUpdate(const char *szRecordName, WORD wGrou if (pTime)
setSettingDouble(hContact, DBSETTING_METAINFO_TIME, pItemData->getDouble(SSI_TLV_METAINFO_TIME, 1));
}
-
- { // update server's data - otherwise consequent operations can fail with 0x0E
+ {
+ // update server's data - otherwise consequent operations can fail with 0x0E
BYTE *data = (BYTE*)_alloca(pItemData->getChainLength());
int datalen = getServerDataFromItemTLV(pItemData, data);
@@ -1545,18 +1307,14 @@ void CIcqProto::handleServerCListItemUpdate(const char *szRecordName, WORD wGrou }
}
}
- else if (wItemType == SSI_ITEM_METAINFO)
- { // owner MetaInfo data updated
- if (pItemData)
- {
- DBVARIANT dbv = {0};
+ else if (wItemType == SSI_ITEM_METAINFO) { // owner MetaInfo data updated
+ if (pItemData) {
+ DBVARIANT dbv = { 0 };
oscar_tlv *pToken = pItemData->getTLV(SSI_TLV_METAINFO_TOKEN, 1);
oscar_tlv *pTime = pItemData->getTLV(SSI_TLV_METAINFO_TIME, 1);
- if (!getSetting(hContact, DBSETTING_METAINFO_TOKEN, &dbv))
- {
- if (!pToken || dbv.cpbVal != pToken->wLen || memcmp(dbv.pbVal, pToken->pData, dbv.cpbVal))
- {
+ if (!getSetting(hContact, DBSETTING_METAINFO_TOKEN, &dbv)) {
+ if (!pToken || dbv.cpbVal != pToken->wLen || memcmp(dbv.pbVal, pToken->pData, dbv.cpbVal)) {
if (!pToken)
debugLogA("Owner meta info token removed");
else
@@ -1572,41 +1330,33 @@ void CIcqProto::handleServerCListItemUpdate(const char *szRecordName, WORD wGrou setSettingDouble(hContact, DBSETTING_METAINFO_TIME, pItemData->getDouble(SSI_TLV_METAINFO_TIME, 1));
}
}
- else if (wItemType == SSI_ITEM_GROUP)
- { // group updated
+ else if (wItemType == SSI_ITEM_GROUP) // group updated
debugLogA("Server updated our group \"%s\" on list", szRecordName);
- }
}
-
void CIcqProto::handleServerCListItemDelete(const char *szRecordName, WORD wGroupId, WORD wItemId, WORD wItemType, oscar_tlv_chain *pItemData)
{
MCONTACT hContact = (wItemType == SSI_ITEM_BUDDY || wItemType == SSI_ITEM_DENY || wItemType == SSI_ITEM_PERMIT || wItemType == SSI_ITEM_IGNORE) ? HContactFromRecordName(szRecordName, NULL) : NULL;
- if (hContact != INVALID_CONTACT_ID && wItemType == SSI_ITEM_BUDDY)
- { // a contact was removed from our list
- if (getWord(hContact, DBSETTING_SERVLIST_ID, 0) == wItemId)
- {
+ if (hContact != INVALID_CONTACT_ID && wItemType == SSI_ITEM_BUDDY) { // a contact was removed from our list
+ if (getWord(hContact, DBSETTING_SERVLIST_ID, 0) == wItemId) {
delSetting(hContact, DBSETTING_SERVLIST_ID);
delSetting(hContact, DBSETTING_SERVLIST_GROUP);
delSetting(hContact, "Auth");
- {
- char str[MAX_PATH];
- char msg[MAX_PATH];
- char *nick = NickFromHandleUtf(hContact);
+ char str[MAX_PATH];
+ char msg[MAX_PATH];
+ char *nick = NickFromHandleUtf(hContact);
- mir_snprintf(str, MAX_PATH, ICQTranslateUtfStatic(LPGEN("User \"%s\" was removed from server list."), msg, MAX_PATH), nick);
- icq_LogMessage(LOG_WARNING, str);
- SAFE_FREE(&nick);
- }
+ mir_snprintf(str, MAX_PATH, ICQTranslateUtfStatic(LPGEN("User \"%s\" was removed from server list."), msg, MAX_PATH), nick);
+ icq_LogMessage(LOG_WARNING, str);
+ SAFE_FREE(&nick);
}
}
// Release server-list ID
FreeServerID(wItemId, wItemType == SSI_ITEM_GROUP ? SSIT_GROUP : SSIT_ITEM);
}
-
void CIcqProto::handleRecvAuthRequest(unsigned char *buf, WORD wLen)
{
DWORD dwUin;
@@ -1630,7 +1380,7 @@ void CIcqProto::handleRecvAuthRequest(unsigned char *buf, WORD wLen) PROTORECVEVENT pre = { 0 };
pre.timestamp = time(NULL);
- pre.lParam = sizeof(DWORD)*2 + 5;
+ pre.lParam = sizeof(DWORD) * 2 + 5;
// Prepare reason
char *szReason = (char*)SAFE_MALLOC(wReasonLen + 1);
int nReasonLen = 0;
@@ -1721,8 +1471,7 @@ void CIcqProto::handleRecvAdded(unsigned char *buf, WORD wLen) nNickLen = strlennull(szNick);
}
}
- else
- nNickLen = strlennull(szUid);
+ else nNickLen = strlennull(szUid);
cbBlob += nNickLen;
@@ -1747,7 +1496,6 @@ void CIcqProto::handleRecvAdded(unsigned char *buf, WORD wLen) AddEvent(NULL, EVENTTYPE_ADDED, time(NULL), 0, cbBlob, pBlob);
}
-
void CIcqProto::handleRecvAuthResponse(unsigned char *buf, WORD wLen)
{
DWORD dwUin;
@@ -1785,7 +1533,6 @@ void CIcqProto::handleRecvAuthResponse(unsigned char *buf, WORD wLen) }
switch (bResponse) {
-
case 0:
debugLogA("Authorization request %s by %s", "denied", strUID(dwUin, szUid));
// TODO: Add to system history as soon as new auth system is ready
@@ -1805,7 +1552,6 @@ void CIcqProto::handleRecvAuthResponse(unsigned char *buf, WORD wLen) SAFE_FREE(&szNick);
}
-
// Updates the visibility code used while in SSI mode. If a server ID is
// not stored in the local DB, a new ID will be added to the server list.
//
@@ -1837,14 +1583,11 @@ void CIcqProto::updateServVisibilityCode(BYTE bCode) wVisibilityID = GenerateServerID(SSIT_ITEM, 0);
setWord(DBSETTING_SERVLIST_PRIVACY, wVisibilityID);
wCommand = ICQ_LISTS_ADDTOLIST;
-#ifdef _DEBUG
+
debugLogA("Made new srvVisibilityID, id is %u, code is %u", wVisibilityID, bCode);
-#endif
}
else {
-#ifdef _DEBUG
debugLogA("Reused srvVisibilityID, id is %u, code is %u", wVisibilityID, bCode);
-#endif
wCommand = ICQ_LISTS_UPDATEGROUP;
}
@@ -1853,6 +1596,7 @@ void CIcqProto::updateServVisibilityCode(BYTE bCode) debugLogA("Cookie alloc failure.");
return; // out of memory, go away
}
+
ack->dwAction = SSA_VISIBILITY; // update visibility
dwCookie = AllocateCookie(CKT_SERVERLIST, wCommand, 0, ack); // take cookie
@@ -1924,14 +1668,10 @@ void CIcqProto::updateServAvatarHash(BYTE *pHash, int size) // No, create a new random ID
wAvatarID = GenerateServerID(SSIT_ITEM, 0);
wCommand = ICQ_LISTS_ADDTOLIST;
-#ifdef _DEBUG
debugLogA("Made new srvAvatarID, id is %u", wAvatarID);
-#endif
}
else {
-#ifdef _DEBUG
debugLogA("Reused srvAvatarID, id is %u", wAvatarID);
-#endif
wCommand = ICQ_LISTS_UPDATEGROUP;
}
@@ -2011,7 +1751,5 @@ void CIcqProto::sendRosterAck(void) packFNACHeader(&packet, ICQ_LISTS_FAMILY, ICQ_LISTS_GOTLIST);
sendServPacket(&packet);
-#ifdef _DEBUG
debugLogA("Sent SNAC(x13,x07) - CLI_ROSTERACK");
-#endif
}
|