summaryrefslogtreecommitdiff
path: root/protocols/IcqOscarJ
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-08-29 17:51:10 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-08-29 17:51:10 +0000
commit995d9bcf3ef85618ac6bc44e3b0543f9e357e661 (patch)
treee9f3816ab36c2e5cbdfebff73858d8a33a4fa02c /protocols/IcqOscarJ
parent6ebe0cdcc6bef0b8628a75d3bec6f70d2987bc94 (diff)
oops... some more 'hides' warnings
git-svn-id: http://svn.miranda-ng.org/main/trunk@15100 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/IcqOscarJ')
-rw-r--r--protocols/IcqOscarJ/src/icq_clients.cpp8
-rw-r--r--protocols/IcqOscarJ/src/icq_uploadui.cpp526
-rw-r--r--protocols/IcqOscarJ/src/oscar_filetransfer.cpp10
-rw-r--r--protocols/IcqOscarJ/src/tlv.cpp94
4 files changed, 299 insertions, 339 deletions
diff --git a/protocols/IcqOscarJ/src/icq_clients.cpp b/protocols/IcqOscarJ/src/icq_clients.cpp
index 1eaa7898ae..add5fa3ad4 100644
--- a/protocols/IcqOscarJ/src/icq_clients.cpp
+++ b/protocols/IcqOscarJ/src/icq_clients.cpp
@@ -296,8 +296,8 @@ const char* CIcqProto::detectUserClient(
szClient = "Virus";
// capabilities based detection
- capstr* capId;
- char ver[10];
+ capstr *capId;
+ char ver[16];
if (nIsICQ && caps) {
// check capabilities for client identification
@@ -526,8 +526,6 @@ const char* CIcqProto::detectUserClient(
else if (capId = MatchCapability(caps, wLen, &capCorePager, 0xA)) {
mir_strcpy(szClientBuf, "CORE Pager");
if (dwFT2 == 0x0FFFF0011 && dwFT3 == 0x1100FFFF && (dwFT1 >> 0x18)) {
- char ver[16];
-
mir_snprintf(ver, " %d.%d", dwFT1 >> 0x18, (dwFT1 >> 0x10) & 0xFF);
if ((dwFT1 & 0xFF) == 0x0B)
mir_strcat(ver, " Beta");
@@ -940,7 +938,7 @@ const char* CIcqProto::detectUserClient(
// custom miranda packs
if (caps && bMirandaIM) {
- capstr *capId = MatchCapability(caps, wLen, &capMimPack, 4);
+ capId = MatchCapability(caps, wLen, &capMimPack, 4);
if (capId) {
char szPack[16];
mir_snprintf(szPack, " [%.12s]", (*capId) + 4);
diff --git a/protocols/IcqOscarJ/src/icq_uploadui.cpp b/protocols/IcqOscarJ/src/icq_uploadui.cpp
index a39ec5864f..1dba00dda6 100644
--- a/protocols/IcqOscarJ/src/icq_uploadui.cpp
+++ b/protocols/IcqOscarJ/src/icq_uploadui.cpp
@@ -33,18 +33,18 @@ static int bListInit = 0;
static HANDLE hItemAll;
static int dwUploadDelay = 1000; // initial setting, it is too low for icq server but good for short updates
-static HWND hwndUploadContacts=NULL;
-static const UINT settingsControls[]={IDOK};
+static HWND hwndUploadContacts = NULL;
+static const UINT settingsControls[] = { IDOK };
-static WORD* pwGroupIds = NULL;
+static WORD *pwGroupIds = NULL;
static int cbGroupIds = 0;
// Init default clist options
static void ResetCListOptions(HWND hwndList)
{
- SetWindowLongPtr(hwndList, GWL_STYLE, GetWindowLongPtr(hwndList, GWL_STYLE)|CLS_SHOWHIDDEN);
+ SetWindowLongPtr(hwndList, GWL_STYLE, GetWindowLongPtr(hwndList, GWL_STYLE) | CLS_SHOWHIDDEN);
if (CallService(MS_CLUI_GETCAPS, 0, 0) & CLUIF_HIDEEMPTYGROUPS) // hide empty groups
- SendMessage(hwndList, CLM_SETHIDEEMPTYGROUPS, (WPARAM) TRUE, 0);
+ SendMessage(hwndList, CLM_SETHIDEEMPTYGROUPS, (WPARAM)TRUE, 0);
}
// Selects the "All contacts" checkbox if all other list entries
@@ -54,13 +54,10 @@ static void UpdateAllContactsCheckmark(HWND hwndList, CIcqProto* ppro, HANDLE ph
int check = 1;
MCONTACT hContact = db_find_first(ppro->m_szModuleName);
- while (hContact)
- {
+ while (hContact) {
HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, hContact, 0);
- if (hItem)
- {
- if (!SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)hItem, 0))
- { // if any of our contacts is unchecked, uncheck all contacts as well
+ if (hItem) {
+ if (!SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)hItem, 0)) { // if any of our contacts is unchecked, uncheck all contacts as well
check = 0;
break;
}
@@ -79,11 +76,9 @@ static int UpdateCheckmarks(HWND hwndList, CIcqProto* ppro, HANDLE phItemAll)
bListInit = 1; // lock CLC events
MCONTACT hContact = db_find_first(ppro->m_szModuleName);
- while (hContact)
- {
+ while (hContact) {
HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, hContact, 0);
- if (hItem)
- {
+ if (hItem) {
if (ppro->getWord(hContact, DBSETTING_SERVLIST_ID, 0))
SendMessage(hwndList, CLM_SETCHECKMARK, (WPARAM)hItem, 1);
else
@@ -127,25 +122,25 @@ static void AppendToUploadLog(HWND hwndDlg, const char *fmt, ...)
static void DeleteLastUploadLogLine(HWND hwndDlg)
{
- SendDlgItemMessage(hwndDlg, IDC_LOG, LB_DELETESTRING, SendDlgItemMessage(hwndDlg, IDC_LOG, LB_GETCOUNT, 0, 0)-1, 0);
+ SendDlgItemMessage(hwndDlg, IDC_LOG, LB_DELETESTRING, SendDlgItemMessage(hwndDlg, IDC_LOG, LB_GETCOUNT, 0, 0) - 1, 0);
}
static void GetLastUploadLogLine(HWND hwndDlg, char *szBuf, size_t cbBuf)
{
WCHAR str[MAX_PATH];
- SendDlgItemMessageW(hwndDlg, IDC_LOG, LB_GETTEXT, SendDlgItemMessage(hwndDlg, IDC_LOG, LB_GETCOUNT, 0, 0)-1, (LPARAM)str);
+ SendDlgItemMessageW(hwndDlg, IDC_LOG, LB_GETTEXT, SendDlgItemMessage(hwndDlg, IDC_LOG, LB_GETCOUNT, 0, 0) - 1, (LPARAM)str);
make_utf8_string_static(str, szBuf, cbBuf);
}
-static int GroupEnumIdsEnumProc(const char *szSetting,LPARAM lParam)
-{
+static int GroupEnumIdsEnumProc(const char *szSetting, LPARAM lParam)
+{
// it is probably server group
if (szSetting && mir_strlen(szSetting) < 5) {
- char val[MAX_PATH+2]; // dummy
+ char val[MAX_PATH + 2]; // dummy
if (db_get_static(NULL, (char*)lParam, szSetting, val, MAX_PATH))
return 0; // this converts all string types to DBVT_ASCIIZ
- pwGroupIds = (WORD*)SAFE_REALLOC(pwGroupIds, (cbGroupIds+1)*sizeof(WORD));
+ pwGroupIds = (WORD*)SAFE_REALLOC(pwGroupIds, (cbGroupIds + 1)*sizeof(WORD));
pwGroupIds[cbGroupIds] = (WORD)strtoul(szSetting, NULL, 0x10);
cbGroupIds++;
}
@@ -154,7 +149,7 @@ static int GroupEnumIdsEnumProc(const char *szSetting,LPARAM lParam)
static void enumServerGroups(CIcqProto* ppro)
{
- char szModule[MAX_PATH+9];
+ char szModule[MAX_PATH + 9];
mir_snprintf(szModule, "%s%s", ppro->m_szModuleName, "SrvGroups");
DBCONTACTENUMSETTINGS dbces = { 0 };
@@ -169,8 +164,7 @@ static DWORD sendUploadGroup(CIcqProto* ppro, WORD wAction, WORD wGroupId, char*
DWORD dwCookie;
cookie_servlist_action* ack;
- if (ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action)))
- { // we have cookie good, go on
+ if (ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action))) { // we have cookie good, go on
ack->wGroupId = wGroupId;
ack->dwAction = SSA_SERVLIST_ACK;
dwCookie = ppro->AllocateCookie(CKT_SERVERLIST, wAction, 0, ack);
@@ -184,38 +178,35 @@ static DWORD sendUploadGroup(CIcqProto* ppro, WORD wAction, WORD wGroupId, char*
static DWORD sendUploadBuddy(CIcqProto* ppro, MCONTACT hContact, WORD wAction, DWORD dwUin, char *szUID, WORD wContactId, WORD wGroupId, WORD wItemType)
{
- DWORD dwCookie;
- cookie_servlist_action* ack;
-
- if (ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action)))
- { // we have cookie good, go on
- ack->hContact = hContact;
- ack->wContactId = wContactId;
- ack->wGroupId = wGroupId;
- ack->dwAction = SSA_SERVLIST_ACK;
- dwCookie = ppro->AllocateCookie(CKT_SERVERLIST, wAction, hContact, ack);
- ack->lParam = dwCookie;
-
- if (wItemType == SSI_ITEM_BUDDY)
- ppro->icq_sendServerContact(hContact, dwCookie, wAction, ack->wGroupId, ack->wContactId, SSOP_ITEM_ACTION | SSOF_CONTACT, 500, NULL);
- else
- ppro->icq_sendSimpleItem(dwCookie, wAction, dwUin, szUID, ack->wGroupId, ack->wContactId, wItemType, SSOP_ITEM_ACTION, 500);
-
- return dwCookie;
- }
- return 0;
+ cookie_servlist_action *ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action));
+ if (ack == NULL)
+ return 0;
+
+ // we have cookie good, go on
+ ack->hContact = hContact;
+ ack->wContactId = wContactId;
+ ack->wGroupId = wGroupId;
+ ack->dwAction = SSA_SERVLIST_ACK;
+ DWORD dwCookie = ppro->AllocateCookie(CKT_SERVERLIST, wAction, hContact, ack);
+ ack->lParam = dwCookie;
+
+ if (wItemType == SSI_ITEM_BUDDY)
+ ppro->icq_sendServerContact(hContact, dwCookie, wAction, ack->wGroupId, ack->wContactId, SSOP_ITEM_ACTION | SSOF_CONTACT, 500, NULL);
+ else
+ ppro->icq_sendSimpleItem(dwCookie, wAction, dwUin, szUID, ack->wGroupId, ack->wContactId, wItemType, SSOP_ITEM_ACTION, 500);
+
+ return dwCookie;
}
static char* getServerResultDesc(int wCode)
{
- switch (wCode)
- {
- case 0: return LPGEN("OK");
- case 2: return LPGEN("NOT FOUND");
- case 3: return LPGEN("ALREADY EXISTS");
- case 0xA: return LPGEN("INVALID DATA");
- case 0xC: return LPGEN("LIST FULL");
- default: return LPGEN("FAILED");
+ switch (wCode) {
+ case 0: return LPGEN("OK");
+ case 2: return LPGEN("NOT FOUND");
+ case 3: return LPGEN("ALREADY EXISTS");
+ case 0xA: return LPGEN("INVALID DATA");
+ case 0xC: return LPGEN("LIST FULL");
+ default: return LPGEN("FAILED");
}
}
@@ -245,6 +236,7 @@ static char* getServerResultDesc(int wCode)
static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
CIcqProto* ppro = (CIcqProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ MCONTACT hContact;
static int working;
static HANDLE hProtoAckHook;
@@ -280,195 +272,184 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa
// The M_PROTOACK message is received when the
// server has responded to our last update packet
case M_PROTOACK:
- {
- int bMulti = 0;
- ACKDATA *ack = (ACKDATA*)lParam;
- char szLastLogLine[MAX_PATH];
- char str[MAX_PATH];
-
- // Is this an ack we are waiting for?
- if (mir_strcmp(ack->szModule, ppro->m_szModuleName))
- break;
-
- if (ack->type == ICQACKTYPE_RATEWARNING) { // we are sending tooo fast, slow down the process
- if (ack->hProcess != (HANDLE)1) break; // check class
- if (ack->lParam == 2 || ack->lParam == 3) // check status
- {
- GetLastUploadLogLine(hwndDlg, szLastLogLine, MAX_PATH);
- DeleteLastUploadLogLine(hwndDlg);
- AppendToUploadLog(hwndDlg, ICQTranslateUtfStatic(LPGEN("Server rate warning -> slowing down the process."), str, MAX_PATH));
- AppendToUploadLog(hwndDlg, szLastLogLine);
-
- dwUploadDelay *= 2;
+ {
+ int bMulti = 0;
+ ACKDATA *ack = (ACKDATA*)lParam;
+ char szLastLogLine[MAX_PATH];
+ char str[MAX_PATH];
+ // Is this an ack we are waiting for?
+ if (mir_strcmp(ack->szModule, ppro->m_szModuleName))
break;
- }
- if (ack->lParam == 4) dwUploadDelay /= 2; // the rate is ok, turn up
- }
- if (ack->type != ICQACKTYPE_SERVERCLIST)
- break;
+ if (ack->type == ICQACKTYPE_RATEWARNING) { // we are sending tooo fast, slow down the process
+ if (ack->hProcess != (HANDLE)1) break; // check class
+ if (ack->lParam == 2 || ack->lParam == 3) { // check status
+ GetLastUploadLogLine(hwndDlg, szLastLogLine, MAX_PATH);
+ DeleteLastUploadLogLine(hwndDlg);
+ AppendToUploadLog(hwndDlg, ICQTranslateUtfStatic(LPGEN("Server rate warning -> slowing down the process."), str, MAX_PATH));
+ AppendToUploadLog(hwndDlg, szLastLogLine);
- if ((INT_PTR)ack->hProcess != currentSequence)
- break;
+ dwUploadDelay *= 2;
- lastAckResult = ack->result == ACKRESULT_SUCCESS ? 0 : 1;
+ break;
+ }
+ if (ack->lParam == 4) dwUploadDelay /= 2; // the rate is ok, turn up
+ }
- switch (currentAction) {
- case ACTION_ADDBUDDY:
- if (ack->result == ACKRESULT_SUCCESS) {
- ppro->setByte(hCurrentContact, "Auth", 0);
- ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_ID, wNewContactId);
- ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_GROUP, wNewGroupId);
+ if (ack->type != ICQACKTYPE_SERVERCLIST)
break;
- }
- else { // If the server refused to add the contact without authorization,
- // we try again _with_ authorization TLV
- ppro->setByte(hCurrentContact, "Auth", 1);
-
- DWORD dwUIN;
- uid_str szUID;
- if (!ppro->getContactUid(hCurrentContact, &dwUIN, &szUID)) {
- currentAction = ACTION_ADDBUDDYAUTH;
- currentSequence = sendUploadBuddy(ppro, hCurrentContact, ICQ_LISTS_ADDTOLIST, dwUIN, szUID, wNewContactId, wNewGroupId, SSI_ITEM_BUDDY);
- }
- return FALSE;
- }
+ if ((INT_PTR)ack->hProcess != currentSequence)
+ break;
- case ACTION_ADDBUDDYAUTH:
- if (ack->result == ACKRESULT_SUCCESS) {
- ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_ID, wNewContactId);
- ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_GROUP, wNewGroupId);
- }
- else {
- db_unset(hCurrentContact, ppro->m_szModuleName, "Auth");
- ppro->FreeServerID(wNewContactId, SSIT_ITEM);
- }
+ lastAckResult = ack->result == ACKRESULT_SUCCESS ? 0 : 1;
- break;
+ switch (currentAction) {
+ case ACTION_ADDBUDDY:
+ if (ack->result == ACKRESULT_SUCCESS) {
+ ppro->setByte(hCurrentContact, "Auth", 0);
+ ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_ID, wNewContactId);
+ ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_GROUP, wNewGroupId);
+ break;
+ }
+ else { // If the server refused to add the contact without authorization,
+ // we try again _with_ authorization TLV
+ ppro->setByte(hCurrentContact, "Auth", 1);
+
+ DWORD dwUIN;
+ uid_str szUID;
+ if (!ppro->getContactUid(hCurrentContact, &dwUIN, &szUID)) {
+ currentAction = ACTION_ADDBUDDYAUTH;
+ currentSequence = sendUploadBuddy(ppro, hCurrentContact, ICQ_LISTS_ADDTOLIST, dwUIN, szUID, wNewContactId, wNewGroupId, SSI_ITEM_BUDDY);
+ }
- case ACTION_REMOVEBUDDY:
- if (ack->result == ACKRESULT_SUCCESS) { // clear obsolete settings
- ppro->FreeServerID(wNewContactId, SSIT_ITEM);
- db_unset(hCurrentContact, ppro->m_szModuleName, DBSETTING_SERVLIST_ID);
- db_unset(hCurrentContact, ppro->m_szModuleName, DBSETTING_SERVLIST_GROUP);
- db_unset(hCurrentContact, ppro->m_szModuleName, "Auth");
- }
- break;
+ return FALSE;
+ }
- case ACTION_ADDGROUP:
- if (ack->result == ACKRESULT_SUCCESS) {
- void* groupData;
- int groupSize;
- cookie_servlist_action* ack;
+ case ACTION_ADDBUDDYAUTH:
+ if (ack->result == ACKRESULT_SUCCESS) {
+ ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_ID, wNewContactId);
+ ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_GROUP, wNewGroupId);
+ }
+ else {
+ db_unset(hCurrentContact, ppro->m_szModuleName, "Auth");
+ ppro->FreeServerID(wNewContactId, SSIT_ITEM);
+ }
+ break;
- ppro->setServListGroupName(wNewGroupId, szNewGroupName); // add group to list
- ppro->setServListGroupLinkID(szNewGroupName, wNewGroupId); // grouppath is known
+ case ACTION_REMOVEBUDDY:
+ if (ack->result == ACKRESULT_SUCCESS) { // clear obsolete settings
+ ppro->FreeServerID(wNewContactId, SSIT_ITEM);
+ db_unset(hCurrentContact, ppro->m_szModuleName, DBSETTING_SERVLIST_ID);
+ db_unset(hCurrentContact, ppro->m_szModuleName, DBSETTING_SERVLIST_GROUP);
+ db_unset(hCurrentContact, ppro->m_szModuleName, "Auth");
+ }
+ break;
- groupData = ppro->collectGroups(&groupSize);
- groupData = SAFE_REALLOC(groupData, groupSize + 2);
- *(((WORD*)groupData) + (groupSize >> 1)) = wNewGroupId; // add this new group id
- groupSize += 2;
+ case ACTION_ADDGROUP:
+ if (ack->result == ACKRESULT_SUCCESS) {
+ ppro->setServListGroupName(wNewGroupId, szNewGroupName); // add group to list
+ ppro->setServListGroupLinkID(szNewGroupName, wNewGroupId); // grouppath is known
- ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action));
- if (ack) {
- DWORD dwCookie; // we do not use this
+ int groupSize;
+ void *groupData = ppro->collectGroups(&groupSize);
+ groupData = SAFE_REALLOC(groupData, groupSize + 2);
+ *(((WORD*)groupData) + (groupSize >> 1)) = wNewGroupId; // add this new group id
+ groupSize += 2;
- ack->dwAction = SSA_SERVLIST_ACK;
- dwCookie = ppro->AllocateCookie(CKT_SERVERLIST, ICQ_LISTS_UPDATEGROUP, 0, ack);
+ cookie_servlist_action *action = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action));
+ if (action) {
+ DWORD dwCookie; // we do not use this
- ppro->icq_sendServerGroup(dwCookie, ICQ_LISTS_UPDATEGROUP, 0, ack->szGroupName, groupData, groupSize, 0);
- }
- SAFE_FREE((void**)&groupData);
- }
- else
- ppro->FreeServerID(wNewGroupId, SSIT_GROUP);
+ action->dwAction = SSA_SERVLIST_ACK;
+ dwCookie = ppro->AllocateCookie(CKT_SERVERLIST, ICQ_LISTS_UPDATEGROUP, 0, action);
- SAFE_FREE((void**)&szNewGroupName);
- break;
+ ppro->icq_sendServerGroup(dwCookie, ICQ_LISTS_UPDATEGROUP, 0, action->szGroupName, groupData, groupSize, 0);
+ }
+ SAFE_FREE((void**)&groupData);
+ }
+ else ppro->FreeServerID(wNewGroupId, SSIT_GROUP);
- case ACTION_REMOVEGROUP:
- if (ack->result == ACKRESULT_SUCCESS) {
- void* groupData;
- int groupSize;
- cookie_servlist_action* ack;
+ SAFE_FREE((void**)&szNewGroupName);
+ break;
- ppro->FreeServerID(wNewGroupId, SSIT_GROUP);
- ppro->setServListGroupName(wNewGroupId, NULL); // remove group from list
- ppro->removeGroupPathLinks(wNewGroupId); // grouppath is known
+ case ACTION_REMOVEGROUP:
+ if (ack->result == ACKRESULT_SUCCESS) {
+ ppro->FreeServerID(wNewGroupId, SSIT_GROUP);
+ ppro->setServListGroupName(wNewGroupId, NULL); // remove group from list
+ ppro->removeGroupPathLinks(wNewGroupId); // grouppath is known
- groupData = ppro->collectGroups(&groupSize);
+ int groupSize;
+ void *groupData = ppro->collectGroups(&groupSize);
- ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action));
- if (ack) {
- DWORD dwCookie; // we do not use this
+ cookie_servlist_action *action = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action));
+ if (action) {
+ DWORD dwCookie; // we do not use this
- ack->dwAction = SSA_SERVLIST_ACK;
- dwCookie = ppro->AllocateCookie(CKT_SERVERLIST, ICQ_LISTS_UPDATEGROUP, 0, ack);
+ action->dwAction = SSA_SERVLIST_ACK;
+ dwCookie = ppro->AllocateCookie(CKT_SERVERLIST, ICQ_LISTS_UPDATEGROUP, 0, action);
- ppro->icq_sendServerGroup(dwCookie, ICQ_LISTS_UPDATEGROUP, 0, ack->szGroupName, groupData, groupSize, 0);
+ ppro->icq_sendServerGroup(dwCookie, ICQ_LISTS_UPDATEGROUP, 0, action->szGroupName, groupData, groupSize, 0);
+ }
+ SAFE_FREE((void**)&groupData);
}
- SAFE_FREE((void**)&groupData);
- }
- break;
+ break;
- case ACTION_UPDATESTATE:
- // do nothing
- break;
+ case ACTION_UPDATESTATE:
+ // do nothing
+ break;
- case ACTION_MOVECONTACT:
- if (ack->result == ACKRESULT_SUCCESS) {
- ppro->FreeServerID(ppro->getWord(hCurrentContact, DBSETTING_SERVLIST_ID, 0), SSIT_ITEM);
- ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_ID, wNewContactId);
- ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_GROUP, wNewGroupId);
- dwUploadDelay *= 2; // we double the delay here (2 packets)
- }
- break;
+ case ACTION_MOVECONTACT:
+ if (ack->result == ACKRESULT_SUCCESS) {
+ ppro->FreeServerID(ppro->getWord(hCurrentContact, DBSETTING_SERVLIST_ID, 0), SSIT_ITEM);
+ ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_ID, wNewContactId);
+ ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_GROUP, wNewGroupId);
+ dwUploadDelay *= 2; // we double the delay here (2 packets)
+ }
+ break;
- case ACTION_ADDVISIBLE:
- if (ack->result == ACKRESULT_SUCCESS)
- ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_PERMIT, wNewContactId);
- else
- ppro->FreeServerID(wNewContactId, SSIT_ITEM);
- break;
+ case ACTION_ADDVISIBLE:
+ if (ack->result == ACKRESULT_SUCCESS)
+ ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_PERMIT, wNewContactId);
+ else
+ ppro->FreeServerID(wNewContactId, SSIT_ITEM);
+ break;
- case ACTION_ADDINVISIBLE:
- if (ack->result == ACKRESULT_SUCCESS)
- ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_DENY, wNewContactId);
- else
- ppro->FreeServerID(wNewContactId, SSIT_ITEM);
- break;
+ case ACTION_ADDINVISIBLE:
+ if (ack->result == ACKRESULT_SUCCESS)
+ ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_DENY, wNewContactId);
+ else
+ ppro->FreeServerID(wNewContactId, SSIT_ITEM);
+ break;
- case ACTION_REMOVEVISIBLE:
- if (ack->result == ACKRESULT_SUCCESS) {
- ppro->FreeServerID(wNewContactId, SSIT_ITEM);
- ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_PERMIT, 0);
- }
- break;
+ case ACTION_REMOVEVISIBLE:
+ if (ack->result == ACKRESULT_SUCCESS) {
+ ppro->FreeServerID(wNewContactId, SSIT_ITEM);
+ ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_PERMIT, 0);
+ }
+ break;
- case ACTION_REMOVEINVISIBLE:
- if (ack->result == ACKRESULT_SUCCESS) {
- ppro->FreeServerID(wNewContactId, SSIT_ITEM);
- ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_DENY, 0);
+ case ACTION_REMOVEINVISIBLE:
+ if (ack->result == ACKRESULT_SUCCESS) {
+ ppro->FreeServerID(wNewContactId, SSIT_ITEM);
+ ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_DENY, 0);
+ }
+ break;
}
- break;
- }
- // Update the log window
- GetLastUploadLogLine(hwndDlg, szLastLogLine, MAX_PATH);
- DeleteLastUploadLogLine(hwndDlg);
- AppendToUploadLog(hwndDlg, "%s%s", szLastLogLine,
- ICQTranslateUtfStatic(getServerResultDesc(ack->lParam), str, MAX_PATH));
+ // Update the log window
+ GetLastUploadLogLine(hwndDlg, szLastLogLine, MAX_PATH);
+ DeleteLastUploadLogLine(hwndDlg);
+ AppendToUploadLog(hwndDlg, "%s%s", szLastLogLine,
+ ICQTranslateUtfStatic(getServerResultDesc(ack->lParam), str, MAX_PATH));
- if (!bMulti) {
- SetTimer(hwndDlg, M_UPLOADMORE, dwUploadDelay, 0); // delay
+ if (!bMulti)
+ SetTimer(hwndDlg, M_UPLOADMORE, dwUploadDelay, 0); // delay
}
- }
break;
case WM_TIMER:
- {
switch (wParam) {
case M_UPLOADMORE:
KillTimer(hwndDlg, M_UPLOADMORE);
@@ -476,31 +457,19 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa
dwUploadDelay /= 2; // turn it back
PostMessage(hwndDlg, M_UPLOADMORE, 0, 0);
-
return 0;
}
- }
// The M_UPLOADMORE window message is received when the user presses 'Update'
// and every time an ack from the server has been taken care of.
case M_UPLOADMORE:
{
- MCONTACT hContact;
- HANDLE hItem;
- char *pszNick;
- char *pszGroup;
- int isChecked;
- int isOnServer;
- BOOL bUidOk;
char str[MAX_PATH];
- HWND hwndList = GetDlgItem(hwndDlg, IDC_CLIST);
switch (currentState) {
case STATE_REGROUP:
-
// TODO: iterate over all checked groups and create if needed
// if creation requires reallocation of groups do it here
-
currentState = STATE_ITEMS;
hCurrentContact = NULL;
PostMessage(hwndDlg, M_UPLOADMORE, 0, 0);
@@ -520,22 +489,23 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa
while (hContact) {
hCurrentContact = hContact;
- hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, hContact, 0);
+ HWND hwndList = GetDlgItem(hwndDlg, IDC_CLIST);
+ HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, hContact, 0);
if (hItem) {
- isChecked = SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)hItem, 0) != 0;
- isOnServer = ppro->getWord(hContact, DBSETTING_SERVLIST_ID, 0) != 0;
+ int isChecked = SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)hItem, 0) != 0;
+ int isOnServer = ppro->getWord(hContact, DBSETTING_SERVLIST_ID, 0) != 0;
DWORD dwUin;
uid_str szUid;
- bUidOk = !ppro->getContactUid(hContact, &dwUin, &szUid);
+ BOOL bUidOk = !ppro->getContactUid(hContact, &dwUin, &szUid);
// Is this one out of sync?
if (bUidOk && (isChecked != isOnServer)) {
// Only upload custom nicks
- pszNick = ppro->getSettingStringUtf(hContact, "CList", "MyHandle", NULL);
+ char *pszNick = ppro->getSettingStringUtf(hContact, "CList", "MyHandle", NULL);
if (isChecked) { // Queue for uploading
- pszGroup = ppro->getContactCListGroup(hContact);
+ char *pszGroup = ppro->getContactCListGroup(hContact);
if (!mir_strlen(pszGroup))
pszGroup = null_strdup(DEFAULT_SS_GROUP);
@@ -566,11 +536,11 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa
wNewContactId = ppro->GenerateServerID(SSIT_ITEM, 0);
currentSequence = sendUploadBuddy(ppro, hCurrentContact, ICQ_LISTS_ADDTOLIST, dwUin, szUid,
- wNewContactId, wNewGroupId, SSI_ITEM_BUDDY);
+ wNewContactId, wNewGroupId, SSI_ITEM_BUDDY);
SAFE_FREE(&pszNick);
return FALSE;
}
-
+
char szLastLogLine[MAX_PATH];
// Update the log window with the failure and continue with next contact
GetLastUploadLogLine(hwndDlg, szLastLogLine, MAX_PATH);
@@ -590,7 +560,7 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa
wNewContactId = ppro->getWord(hContact, DBSETTING_SERVLIST_ID, 0);
currentAction = ACTION_REMOVEBUDDY;
currentSequence = sendUploadBuddy(ppro, hContact, ICQ_LISTS_REMOVEFROMLIST, dwUin, szUid,
- wNewContactId, wNewGroupId, SSI_ITEM_BUDDY);
+ wNewContactId, wNewGroupId, SSI_ITEM_BUDDY);
}
SAFE_FREE((void**)&pszNick);
break;
@@ -600,9 +570,10 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa
if (bUidOk && isChecked) {
WORD wCurrentGroupId = ppro->getWord(hContact, DBSETTING_SERVLIST_GROUP, 0);
- pszGroup = ppro->getContactCListGroup(hContact);
+ char *pszGroup = ppro->getContactCListGroup(hContact);
if (!mir_strlen(pszGroup))
pszGroup = null_strdup(DEFAULT_SS_GROUP);
+
wNewGroupId = ppro->getServListGroupLinkID(pszGroup);
if (!wNewGroupId && strstrnull(pszGroup, "\\") != NULL) { // if it is sub-group, take master parent
strstrnull(pszGroup, "\\")[0] = '\0';
@@ -624,7 +595,7 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa
if (wNewGroupId && (wNewGroupId != wCurrentGroupId)) {
WORD wCurrentContactId = ppro->getWord(hContact, DBSETTING_SERVLIST_ID, 0);
- pszNick = ppro->getSettingStringUtf(hContact, "CList", "MyHandle", NULL);
+ char *pszNick = ppro->getSettingStringUtf(hContact, "CList", "MyHandle", NULL);
if (pszNick)
AppendToUploadLog(hwndDlg, ICQTranslateUtfStatic(LPGEN("Moving %s to group \"%s\"..."), str, MAX_PATH), pszNick, pszGroup);
else
@@ -733,7 +704,7 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa
wNewGroupId = pwGroupIds[cbGroupIds];
if (groupData = ppro->collectBuddyGroup(wNewGroupId, &groupSize)) { // the group is still not empty, just update it
- char* pszGroup = ppro->getServListGroupName(wNewGroupId);
+ char *pszGroup = ppro->getServListGroupName(wNewGroupId);
cookie_servlist_action* ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action));
ack->dwAction = SSA_SERVLIST_ACK;
@@ -789,7 +760,7 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa
// end server modifications here
ppro->servlistPostPacket(NULL, 0, SSO_END_OPERATION, 100);
working = 0;
- UpdateCheckmarks(hwndList, ppro, hItemAll);
+ UpdateCheckmarks(GetDlgItem(hwndDlg, IDC_CLIST), ppro, hItemAll);
if (hProtoAckHook)
UnhookEvent(hProtoAckHook);
}
@@ -810,10 +781,9 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa
currentState = STATE_REGROUP;
currentAction = ACTION_NONE;
icq_ShowMultipleControls(hwndDlg, settingsControls, _countof(settingsControls), SW_HIDE);
- // SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETGREYOUTFLAGS, 0xFFFFFFFF, 0);
- // InvalidateRect(GetDlgItem(hwndDlg, IDC_CLIST), NULL, FALSE);
EnableDlgItem(hwndDlg, IDC_CLIST, FALSE);
hProtoAckHook = HookEventMessage(ME_PROTO_ACK, hwndDlg, M_PROTOACK);
+
// start server modifications here
ppro->servlistPostPacket(NULL, 0, SSO_BEGIN_OPERATION | SSOF_IMPORT_OPERATION, 100);
PostMessage(hwndDlg, M_UPLOADMORE, 0, 0);
@@ -826,67 +796,63 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wPa
break;
case WM_NOTIFY:
- switch (((NMHDR*)lParam)->idFrom) {
- case IDC_CLIST:
- {
- HWND hClist = GetDlgItem(hwndDlg, IDC_CLIST);
-
- switch (((NMHDR*)lParam)->code) {
- case CLN_OPTIONSCHANGED:
- ResetCListOptions(hClist);
- break;
+ if (((NMHDR*)lParam)->idFrom == IDC_CLIST) {
+ HWND hClist = GetDlgItem(hwndDlg, IDC_CLIST);
- case CLN_NEWCONTACT:
- case CLN_CONTACTMOVED:
- // Delete non-icq contacts
- DeleteOtherContactsFromControl(hClist, ppro);
- if (hItemAll)
- UpdateAllContactsCheckmark(hClist, ppro, hItemAll);
- break;
+ switch (((NMHDR*)lParam)->code) {
+ case CLN_OPTIONSCHANGED:
+ ResetCListOptions(hClist);
+ break;
- case CLN_LISTREBUILT:
- {
- int bCheck = false;
+ case CLN_NEWCONTACT:
+ case CLN_CONTACTMOVED:
+ // Delete non-icq contacts
+ DeleteOtherContactsFromControl(hClist, ppro);
+ if (hItemAll)
+ UpdateAllContactsCheckmark(hClist, ppro, hItemAll);
+ break;
- // Delete non-icq contacts
- if (ppro) {
- DeleteOtherContactsFromControl(hClist, ppro);
- if (!bListInit) // do not enter twice
- bCheck = UpdateCheckmarks(hClist, ppro, NULL);
- }
+ case CLN_LISTREBUILT:
+ {
+ int bCheck = false;
- if (!hItemAll) { // Add the "All contacts" item
- CLCINFOITEM cii = { 0 };
- cii.cbSize = sizeof(cii);
- cii.flags = CLCIIF_GROUPFONT | CLCIIF_CHECKBOX;
- cii.pszText = TranslateT(LPGEN("** All contacts **"));
- hItemAll = (HANDLE)SendMessage(hClist, CLM_ADDINFOITEM, 0, (LPARAM)&cii);
- }
+ // Delete non-icq contacts
+ if (ppro) {
+ DeleteOtherContactsFromControl(hClist, ppro);
+ if (!bListInit) // do not enter twice
+ bCheck = UpdateCheckmarks(hClist, ppro, NULL);
+ }
- SendMessage(hClist, CLM_SETCHECKMARK, (WPARAM)hItemAll, bCheck);
+ if (!hItemAll) { // Add the "All contacts" item
+ CLCINFOITEM cii = { 0 };
+ cii.cbSize = sizeof(cii);
+ cii.flags = CLCIIF_GROUPFONT | CLCIIF_CHECKBOX;
+ cii.pszText = TranslateT(LPGEN("** All contacts **"));
+ hItemAll = (HANDLE)SendMessage(hClist, CLM_ADDINFOITEM, 0, (LPARAM)&cii);
}
- break;
- case CLN_CHECKCHANGED:
- if (!bListInit) {
- NMCLISTCONTROL *nm = (NMCLISTCONTROL*)lParam;
- if (nm->flags&CLNF_ISINFO) {
- int check = SendMessage(hClist, CLM_GETCHECKMARK, (WPARAM)hItemAll, 0);
-
- MCONTACT hContact = db_find_first(ppro->m_szModuleName);
- while (hContact) {
- HANDLE hItem = (HANDLE)SendMessage(hClist, CLM_FINDCONTACT, hContact, 0);
- if (hItem)
- SendMessage(hClist, CLM_SETCHECKMARK, (WPARAM)hItem, check);
- hContact = db_find_next(hContact, ppro->m_szModuleName);
- }
+ SendMessage(hClist, CLM_SETCHECKMARK, (WPARAM)hItemAll, bCheck);
+ }
+ break;
+
+ case CLN_CHECKCHANGED:
+ if (!bListInit) {
+ NMCLISTCONTROL *nm = (NMCLISTCONTROL*)lParam;
+ if (nm->flags&CLNF_ISINFO) {
+ int check = SendMessage(hClist, CLM_GETCHECKMARK, (WPARAM)hItemAll, 0);
+
+ hContact = db_find_first(ppro->m_szModuleName);
+ while (hContact) {
+ HANDLE hItem = (HANDLE)SendMessage(hClist, CLM_FINDCONTACT, hContact, 0);
+ if (hItem)
+ SendMessage(hClist, CLM_SETCHECKMARK, (WPARAM)hItem, check);
+ hContact = db_find_next(hContact, ppro->m_szModuleName);
}
- else UpdateAllContactsCheckmark(hClist, ppro, hItemAll);
}
- break;
+ else UpdateAllContactsCheckmark(hClist, ppro, hItemAll);
}
+ break;
}
- break;
}
break;
diff --git a/protocols/IcqOscarJ/src/oscar_filetransfer.cpp b/protocols/IcqOscarJ/src/oscar_filetransfer.cpp
index 4367dadc88..6305536dcb 100644
--- a/protocols/IcqOscarJ/src/oscar_filetransfer.cpp
+++ b/protocols/IcqOscarJ/src/oscar_filetransfer.cpp
@@ -432,9 +432,9 @@ void CIcqProto::handleRecvServMsgOFT(BYTE *buf, size_t wLen, DWORD dwUin, char *
return;
}
- BYTE* tBuf = tlv->pData;
+ BYTE *tBuf = tlv->pData;
size_t tLen = tlv->wLen;
- WORD wFlag;
+ WORD wFlag;
unpackWord(&tBuf, &wFlag); // FT flag
unpackWord(&tBuf, &ft->wFilesCount);
@@ -488,9 +488,7 @@ void CIcqProto::handleRecvServMsgOFT(BYTE *buf, size_t wLen, DWORD dwUin, char *
}
}
int bAdded;
- MCONTACT hContact = HContactFromUID(dwUin, szUID, &bAdded);
-
- ft->hContact = hContact;
+ ft->hContact = HContactFromUID(dwUin, szUID, &bAdded);
ft->fileId = -1;
// Send chain event
@@ -508,7 +506,7 @@ void CIcqProto::handleRecvServMsgOFT(BYTE *buf, size_t wLen, DWORD dwUin, char *
pre.descr.t = mir_utf8decodeT(pszDescription);
pre.files.t = &ptszFileName;
pre.lParam = (LPARAM)ft;
- ProtoChainRecvFile(hContact, &pre);
+ ProtoChainRecvFile(ft->hContact, &pre);
mir_free(pre.descr.t);
mir_free(ptszFileName);
diff --git a/protocols/IcqOscarJ/src/tlv.cpp b/protocols/IcqOscarJ/src/tlv.cpp
index 81488e8c78..30625b6708 100644
--- a/protocols/IcqOscarJ/src/tlv.cpp
+++ b/protocols/IcqOscarJ/src/tlv.cpp
@@ -115,10 +115,10 @@ WORD oscar_tlv_chain::getChainLength()
oscar_tlv* oscar_tlv_chain::putTLV(WORD wType, size_t wLen, BYTE *pData, BOOL bReplace)
{
- oscar_tlv *tlv = getTLV(wType, 1);
+ oscar_tlv *pTLV = getTLV(wType, 1);
- if (tlv && bReplace)
- SAFE_FREE((void**)&tlv->pData);
+ if (pTLV && bReplace)
+ SAFE_FREE((void**)&pTLV->pData);
else {
oscar_tlv_chain *last = this;
@@ -127,26 +127,26 @@ oscar_tlv* oscar_tlv_chain::putTLV(WORD wType, size_t wLen, BYTE *pData, BOOL bR
if (last) {
last->next = (oscar_tlv_chain*)SAFE_MALLOC(sizeof(oscar_tlv_chain));
- tlv = &last->next->tlv;
- tlv->wType = wType;
+ pTLV = &last->next->tlv;
+ pTLV->wType = wType;
}
}
- if (tlv) {
- tlv->wLen = WORD(wLen);
- tlv->pData = (PBYTE)SAFE_MALLOC(wLen);
- memcpy(tlv->pData, pData, wLen);
+ if (pTLV) {
+ pTLV->wLen = WORD(wLen);
+ pTLV->pData = (PBYTE)SAFE_MALLOC(wLen);
+ memcpy(pTLV->pData, pData, wLen);
}
- return tlv;
+ return pTLV;
}
-oscar_tlv_chain* oscar_tlv_chain::removeTLV(oscar_tlv *tlv)
+oscar_tlv_chain* oscar_tlv_chain::removeTLV(oscar_tlv *pTLV)
{
oscar_tlv_chain *list = this, *prev = NULL, *chain = this;
while (list) {
- if (&list->tlv == tlv) {
+ if (&list->tlv == pTLV) {
if (prev) // relink
prev->next = list->next;
- else if (list->next) { // move second item's tlv to the first item
+ else if (list->next) { // move second item's pTLV to the first item
list->tlv = list->next->tlv;
list = list->next;
}
@@ -165,9 +165,9 @@ oscar_tlv_chain* oscar_tlv_chain::removeTLV(oscar_tlv *tlv)
WORD oscar_tlv_chain::getLength(WORD wType, WORD wIndex)
{
- oscar_tlv *tlv = getTLV(wType, wIndex);
- if (tlv)
- return tlv->wLen;
+ oscar_tlv *pTLV = getTLV(wType, wIndex);
+ if (pTLV)
+ return pTLV->wLen;
return 0;
}
@@ -180,12 +180,12 @@ DWORD oscar_tlv_chain::getDWord(WORD wType, WORD wIndex)
{
DWORD dw = 0;
- oscar_tlv *tlv = getTLV(wType, wIndex);
- if (tlv && tlv->wLen >= 4) {
- dw |= (*((tlv->pData) + 0) << 24);
- dw |= (*((tlv->pData) + 1) << 16);
- dw |= (*((tlv->pData) + 2) << 8);
- dw |= (*((tlv->pData) + 3));
+ oscar_tlv *pTLV = getTLV(wType, wIndex);
+ if (pTLV && pTLV->wLen >= 4) {
+ dw |= (*((pTLV->pData) + 0) << 24);
+ dw |= (*((pTLV->pData) + 1) << 16);
+ dw |= (*((pTLV->pData) + 2) << 8);
+ dw |= (*((pTLV->pData) + 3));
}
return dw;
@@ -195,10 +195,10 @@ WORD oscar_tlv_chain::getWord(WORD wType, WORD wIndex)
{
WORD w = 0;
- oscar_tlv *tlv = getTLV(wType, wIndex);
- if (tlv && tlv->wLen >= 2) {
- w |= (*((tlv->pData) + 0) << 8);
- w |= (*((tlv->pData) + 1));
+ oscar_tlv *pTLV = getTLV(wType, wIndex);
+ if (pTLV && pTLV->wLen >= 2) {
+ w |= (*((pTLV->pData) + 0) << 8);
+ w |= (*((pTLV->pData) + 1));
}
return w;
@@ -208,22 +208,22 @@ BYTE oscar_tlv_chain::getByte(WORD wType, WORD wIndex)
{
BYTE b = 0;
- oscar_tlv *tlv = getTLV(wType, wIndex);
- if (tlv && tlv->wLen)
- b = *(tlv->pData);
+ oscar_tlv *pTLV = getTLV(wType, wIndex);
+ if (pTLV && pTLV->wLen)
+ b = *(pTLV->pData);
return b;
}
int oscar_tlv_chain::getNumber(WORD wType, WORD wIndex)
{
- oscar_tlv *tlv = getTLV(wType, wIndex);
- if (tlv) {
- if (tlv->wLen == 1)
+ oscar_tlv *pTLV = getTLV(wType, wIndex);
+ if (pTLV) {
+ if (pTLV->wLen == 1)
return getByte(wType, wIndex);
- if (tlv->wLen == 2)
+ if (pTLV->wLen == 2)
return getWord(wType, wIndex);
- if (tlv->wLen == 4)
+ if (pTLV->wLen == 4)
return getDWord(wType, wIndex);
}
return 0;
@@ -231,9 +231,9 @@ int oscar_tlv_chain::getNumber(WORD wType, WORD wIndex)
double oscar_tlv_chain::getDouble(WORD wType, WORD wIndex)
{
- oscar_tlv *tlv = getTLV(wType, wIndex);
- if (tlv && tlv->wLen == 8) {
- BYTE *buf = tlv->pData;
+ oscar_tlv *pTLV = getTLV(wType, wIndex);
+ if (pTLV && pTLV->wLen == 8) {
+ BYTE *buf = pTLV->pData;
double d = 0;
unpackQWord(&buf, (DWORD64*)&d);
@@ -245,19 +245,18 @@ double oscar_tlv_chain::getDouble(WORD wType, WORD wIndex)
char* oscar_tlv_chain::getString(WORD wType, WORD wIndex)
{
- char *str = NULL;
-
- oscar_tlv *tlv = getTLV(wType, wIndex);
- if (tlv) {
- str = (char*)SAFE_MALLOC(tlv->wLen + 1); /* For \0 */
-
- if (!str) return NULL;
+ oscar_tlv *pTLV = getTLV(wType, wIndex);
+ if (pTLV) {
+ char *str = (char*)SAFE_MALLOC(pTLV->wLen + 1); /* For \0 */
+ if (!str)
+ return NULL;
- memcpy(str, tlv->pData, tlv->wLen);
- str[tlv->wLen] = '\0';
+ memcpy(str, pTLV->pData, pTLV->wLen);
+ str[pTLV->wLen] = '\0';
+ return str;
}
- return str;
+ return NULL;
}
void disposeChain(oscar_tlv_chain **chain)
@@ -266,7 +265,6 @@ void disposeChain(oscar_tlv_chain **chain)
return;
oscar_tlv_chain *now = *chain;
-
while (now) {
oscar_tlv_chain *next = now->next;