summaryrefslogtreecommitdiff
path: root/protocols/IcqOscarJ/src/icq_uploadui.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/IcqOscarJ/src/icq_uploadui.cpp')
-rw-r--r--protocols/IcqOscarJ/src/icq_uploadui.cpp542
1 files changed, 238 insertions, 304 deletions
diff --git a/protocols/IcqOscarJ/src/icq_uploadui.cpp b/protocols/IcqOscarJ/src/icq_uploadui.cpp
index 5dbeef6d8e..96fb4a82b7 100644
--- a/protocols/IcqOscarJ/src/icq_uploadui.cpp
+++ b/protocols/IcqOscarJ/src/icq_uploadui.cpp
@@ -62,7 +62,7 @@ static void UpdateAllContactsCheckmark(HWND hwndList, CIcqProto* ppro, HANDLE ph
{
int check = 1;
- MCONTACT hContact = ppro->FindFirstContact();
+ MCONTACT hContact = db_find_first(ppro->m_szModuleName);
while (hContact)
{
HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, hContact, 0);
@@ -74,7 +74,7 @@ static void UpdateAllContactsCheckmark(HWND hwndList, CIcqProto* ppro, HANDLE ph
break;
}
}
- hContact = ppro->FindNextContact(hContact);
+ hContact = db_find_next(hContact, ppro->m_szModuleName);
}
SendMessage(hwndList, CLM_SETCHECKMARK, (WPARAM)phItemAll, check);
@@ -87,7 +87,7 @@ static int UpdateCheckmarks(HWND hwndList, CIcqProto* ppro, HANDLE phItemAll)
int bAll = 1;
bListInit = 1; // lock CLC events
- MCONTACT hContact = ppro->FindFirstContact();
+ MCONTACT hContact = db_find_first(ppro->m_szModuleName);
while (hContact)
{
HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, hContact, 0);
@@ -98,7 +98,7 @@ static int UpdateCheckmarks(HWND hwndList, CIcqProto* ppro, HANDLE phItemAll)
else
bAll = 0;
}
- hContact = ppro->FindNextContact(hContact);
+ hContact = db_find_next(hContact, ppro->m_szModuleName);
}
// Update the "All contacts" checkmark
@@ -251,7 +251,7 @@ static char* getServerResultDesc(int wCode)
#define M_UPLOADMORE (WM_USER+101)
#define M_INITCLIST (WM_USER+102)
-static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg,UINT message,WPARAM wParam,LPARAM lParam)
+static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
CIcqProto* ppro = (CIcqProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
@@ -267,7 +267,7 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg,UINT message,WPARAM wPara
static char *szNewGroupName;
static WORD wNewVisibilityId;
- switch(message) {
+ switch (message) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
@@ -289,223 +289,207 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg,UINT message,WPARAM wPara
// 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 (strcmpnull(ack->szModule, ppro->m_szModuleName))
- break;
+ {
+ int bMulti = 0;
+ ACKDATA *ack = (ACKDATA*)lParam;
+ char szLastLogLine[MAX_PATH];
+ char str[MAX_PATH];
- 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);
+ // Is this an ack we are waiting for?
+ if (strcmpnull(ack->szModule, ppro->m_szModuleName))
+ break;
- dwUploadDelay *= 2;
+ 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);
- break;
- }
- if (ack->lParam == 4) dwUploadDelay /= 2; // the rate is ok, turn up
- }
+ dwUploadDelay *= 2;
- if (ack->type != ICQACKTYPE_SERVERCLIST)
break;
+ }
+ if (ack->lParam == 4) dwUploadDelay /= 2; // the rate is ok, turn up
+ }
- if ((int)ack->hProcess != currentSequence)
- break;
+ if (ack->type != ICQACKTYPE_SERVERCLIST)
+ break;
- lastAckResult = ack->result == ACKRESULT_SUCCESS ? 0 : 1;
+ if ((int)ack->hProcess != currentSequence)
+ 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
- DWORD dwUIN;
- uid_str szUID;
+ lastAckResult = ack->result == ACKRESULT_SUCCESS ? 0 : 1;
- ppro->setByte(hCurrentContact, "Auth", 1);
+ 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
+ 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);
- }
+ ppro->setByte(hCurrentContact, "Auth", 1);
- return FALSE;
+ 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_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);
- }
+ return FALSE;
+ }
- 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);
+ }
- 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;
+ break;
- case ACTION_ADDGROUP:
- if (ack->result == ACKRESULT_SUCCESS)
- {
- void* groupData;
- int groupSize;
- cookie_servlist_action* ack;
+ 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;
- ppro->setServListGroupName(wNewGroupId, szNewGroupName); // add group to list
- ppro->setServListGroupLinkID(szNewGroupName, wNewGroupId); // grouppath is known
+ case ACTION_ADDGROUP:
+ if (ack->result == ACKRESULT_SUCCESS) {
+ void* groupData;
+ int groupSize;
+ cookie_servlist_action* ack;
- groupData = ppro->collectGroups(&groupSize);
- groupData = SAFE_REALLOC(groupData, groupSize+2);
- *(((WORD*)groupData)+(groupSize>>1)) = wNewGroupId; // add this new group id
- groupSize += 2;
+ 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
+ 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);
+ ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action));
+ if (ack) {
+ DWORD dwCookie; // we do not use this
- ppro->icq_sendServerGroup(dwCookie, ICQ_LISTS_UPDATEGROUP, 0, ack->szGroupName, groupData, groupSize, 0);
- }
- SAFE_FREE((void**)&groupData);
+ ack->dwAction = SSA_SERVLIST_ACK;
+ dwCookie = ppro->AllocateCookie(CKT_SERVERLIST, ICQ_LISTS_UPDATEGROUP, 0, ack);
+
+ ppro->icq_sendServerGroup(dwCookie, ICQ_LISTS_UPDATEGROUP, 0, ack->szGroupName, groupData, groupSize, 0);
}
- else
- ppro->FreeServerID(wNewGroupId, SSIT_GROUP);
+ SAFE_FREE((void**)&groupData);
+ }
+ else
+ ppro->FreeServerID(wNewGroupId, SSIT_GROUP);
- SAFE_FREE((void**)&szNewGroupName);
- break;
+ SAFE_FREE((void**)&szNewGroupName);
+ break;
- case ACTION_REMOVEGROUP:
- if (ack->result == ACKRESULT_SUCCESS)
- {
- void* groupData;
- int groupSize;
- cookie_servlist_action* ack;
+ case ACTION_REMOVEGROUP:
+ if (ack->result == ACKRESULT_SUCCESS) {
+ void* groupData;
+ int groupSize;
+ cookie_servlist_action* ack;
- ppro->FreeServerID(wNewGroupId, SSIT_GROUP);
- ppro->setServListGroupName(wNewGroupId, NULL); // remove group from list
- ppro->removeGroupPathLinks(wNewGroupId); // grouppath is known
+ ppro->FreeServerID(wNewGroupId, SSIT_GROUP);
+ ppro->setServListGroupName(wNewGroupId, NULL); // remove group from list
+ ppro->removeGroupPathLinks(wNewGroupId); // grouppath is known
- groupData = ppro->collectGroups(&groupSize);
+ groupData = ppro->collectGroups(&groupSize);
- ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action));
- if (ack)
- {
- DWORD dwCookie; // we do not use this
+ ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action));
+ if (ack) {
+ DWORD dwCookie; // we do not use this
- ack->dwAction = SSA_SERVLIST_ACK;
- dwCookie = ppro->AllocateCookie(CKT_SERVERLIST, ICQ_LISTS_UPDATEGROUP, 0, ack);
+ ack->dwAction = SSA_SERVLIST_ACK;
+ dwCookie = ppro->AllocateCookie(CKT_SERVERLIST, ICQ_LISTS_UPDATEGROUP, 0, ack);
- ppro->icq_sendServerGroup(dwCookie, ICQ_LISTS_UPDATEGROUP, 0, ack->szGroupName, groupData, groupSize, 0);
- }
- SAFE_FREE((void**)&groupData);
+ ppro->icq_sendServerGroup(dwCookie, ICQ_LISTS_UPDATEGROUP, 0, ack->szGroupName, groupData, groupSize, 0);
}
- break;
+ SAFE_FREE((void**)&groupData);
+ }
+ 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);
- }
- break;
+ case ACTION_REMOVEINVISIBLE:
+ if (ack->result == ACKRESULT_SUCCESS) {
+ ppro->FreeServerID(wNewContactId, SSIT_ITEM);
+ ppro->setWord(hCurrentContact, DBSETTING_SERVLIST_DENY, 0);
}
+ 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);
- if (currentAction == ACTION_MOVECONTACT)
- dwUploadDelay /= 2; // turn it back
+ {
+ switch (wParam) {
+ case M_UPLOADMORE:
+ KillTimer(hwndDlg, M_UPLOADMORE);
+ if (currentAction == ACTION_MOVECONTACT)
+ dwUploadDelay /= 2; // turn it back
- PostMessage(hwndDlg, M_UPLOADMORE, 0, 0);
+ PostMessage(hwndDlg, M_UPLOADMORE, 0, 0);
- return 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.
@@ -523,8 +507,7 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg,UINT message,WPARAM wPara
char str[MAX_PATH];
HWND hwndList = GetDlgItem(hwndDlg, IDC_CLIST);
- switch (currentState)
- {
+ switch (currentState) {
case STATE_REGROUP:
// TODO: iterate over all checked groups and create if needed
@@ -539,47 +522,40 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg,UINT message,WPARAM wPara
// Iterate over all contacts until one is found that
// needs to be updated on the server
if (hCurrentContact == NULL)
- hContact = ppro->FindFirstContact();
- else // we do not want to go thru all contacts over and over again
- {
+ hContact = db_find_first(ppro->m_szModuleName);
+ else { // we do not want to go thru all contacts over and over again
hContact = hCurrentContact;
if (lastAckResult) // if the last operation on this contact fail, do not do it again, go to next
- hContact = ppro->FindNextContact(hContact);
+ hContact = db_find_next(hContact, ppro->m_szModuleName);
}
- while (hContact)
- {
+ while (hContact) {
hCurrentContact = hContact;
hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, hContact, 0);
- if (hItem)
- {
+ if (hItem) {
isChecked = SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)hItem, 0) != 0;
isOnServer = ppro->getWord(hContact, DBSETTING_SERVLIST_ID, 0) != 0;
bUidOk = !ppro->getContactUid(hContact, &dwUin, &szUid);
// Is this one out of sync?
- if (bUidOk && (isChecked != isOnServer))
- {
+ if (bUidOk && (isChecked != isOnServer)) {
// Only upload custom nicks
pszNick = ppro->getSettingStringUtf(hContact, "CList", "MyHandle", NULL);
- if (isChecked)
- { // Queue for uploading
+ if (isChecked) { // Queue for uploading
pszGroup = ppro->getContactCListGroup(hContact);
if (!strlennull(pszGroup))
pszGroup = null_strdup(DEFAULT_SS_GROUP);
// Get group ID from cache, if not ready use parent group, if still not ready create one
wNewGroupId = ppro->getServListGroupLinkID(pszGroup);
- if (!wNewGroupId && strstrnull(pszGroup, "\\") != NULL)
- { // if it is sub-group, take master parent
- strstrnull(pszGroup, "\\")[0] = '\0';
+ if (!wNewGroupId && strstrnull(pszGroup, "\\") != NULL) { // if it is sub-group, take master parent
+ strstrnull(pszGroup, "\\")[0] = '\0';
wNewGroupId = ppro->getServListGroupLinkID(pszGroup);
}
- if (!wNewGroupId && currentAction != ACTION_ADDGROUP)
- { // if the group still does not exist and there was no try before, try to add group
+ if (!wNewGroupId && currentAction != ACTION_ADDGROUP) { // if the group still does not exist and there was no try before, try to add group
AppendToUploadLog(hwndDlg, ICQTranslateUtfStatic(LPGEN("Adding group \"%s\"..."), str, MAX_PATH), pszGroup);
wNewGroupId = ppro->GenerateServerID(SSIT_GROUP, 0); // ???
@@ -587,7 +563,6 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg,UINT message,WPARAM wPara
currentAction = ACTION_ADDGROUP;
currentSequence = sendUploadGroup(ppro, ICQ_LISTS_ADDTOLIST, wNewGroupId, pszGroup);
SAFE_FREE(&pszNick);
-
return FALSE;
}
@@ -597,30 +572,25 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg,UINT message,WPARAM wPara
currentAction = ACTION_ADDBUDDY;
- if (wNewGroupId)
- {
+ if (wNewGroupId) {
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;
}
- else
- {
- char szLastLogLine[MAX_PATH];
- // Update the log window with the failure and continue with next contact
- GetLastUploadLogLine(hwndDlg, szLastLogLine, MAX_PATH);
- DeleteLastUploadLogLine(hwndDlg);
- AppendToUploadLog(hwndDlg, "%s%s", szLastLogLine, ICQTranslateUtfStatic(LPGEN("FAILED"), str, MAX_PATH));
- AppendToUploadLog(hwndDlg, ICQTranslateUtfStatic(LPGEN("No upload group available"), str, MAX_PATH));
- ppro->debugLogA("Upload failed, no group");
- currentState = STATE_READY;
- }
+
+ char szLastLogLine[MAX_PATH];
+ // Update the log window with the failure and continue with next contact
+ GetLastUploadLogLine(hwndDlg, szLastLogLine, MAX_PATH);
+ DeleteLastUploadLogLine(hwndDlg);
+ AppendToUploadLog(hwndDlg, "%s%s", szLastLogLine, ICQTranslateUtfStatic(LPGEN("FAILED"), str, MAX_PATH));
+ AppendToUploadLog(hwndDlg, ICQTranslateUtfStatic(LPGEN("No upload group available"), str, MAX_PATH));
+ ppro->debugLogA("Upload failed, no group");
+ currentState = STATE_READY;
}
- else
- { // Queue for deletion
+ else { // Queue for deletion
if (pszNick)
AppendToUploadLog(hwndDlg, ICQTranslateUtfStatic(LPGEN("Deleting %s..."), str, MAX_PATH), pszNick);
else
@@ -630,38 +600,38 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg,UINT message,WPARAM wPara
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;
}
- else if (bUidOk && isChecked)
- { // the contact is and should be on server, check if it is in correct group, move otherwise
+
+ // the contact is and should be on server, check if it is in correct group, move otherwise
+ if (bUidOk && isChecked) {
WORD wCurrentGroupId = ppro->getWord(hContact, DBSETTING_SERVLIST_GROUP, 0);
pszGroup = ppro->getContactCListGroup(hContact);
if (!strlennull(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';
+ if (!wNewGroupId && strstrnull(pszGroup, "\\") != NULL) { // if it is sub-group, take master parent
+ strstrnull(pszGroup, "\\")[0] = '\0';
wNewGroupId = ppro->getServListGroupLinkID(pszGroup);
}
- if (!wNewGroupId && currentAction != ACTION_ADDGROUP)
- { // if the group still does not exist and there was no try before, try to add group
+
+ // if the group still does not exist and there was no try before, try to add group
+ if (!wNewGroupId && currentAction != ACTION_ADDGROUP) {
AppendToUploadLog(hwndDlg, ICQTranslateUtfStatic(LPGEN("Adding group \"%s\"..."), str, MAX_PATH), pszGroup);
wNewGroupId = ppro->GenerateServerID(SSIT_GROUP, 0);
szNewGroupName = pszGroup;
currentAction = ACTION_ADDGROUP;
currentSequence = sendUploadGroup(ppro, ICQ_LISTS_ADDTOLIST, wNewGroupId, pszGroup);
-
return FALSE;
}
- if (wNewGroupId && (wNewGroupId != wCurrentGroupId))
- { // we have a group the contact should be in, move it
+
+ // we have a group the contact should be in, move it
+ if (wNewGroupId && (wNewGroupId != wCurrentGroupId)) {
WORD wCurrentContactId = ppro->getWord(hContact, DBSETTING_SERVLIST_ID, 0);
BYTE bAuth = ppro->getByte(hContact, "Auth", 0);
@@ -669,7 +639,7 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg,UINT message,WPARAM wPara
if (pszNick)
AppendToUploadLog(hwndDlg, ICQTranslateUtfStatic(LPGEN("Moving %s to group \"%s\"..."), str, MAX_PATH), pszNick, pszGroup);
- else
+ else
AppendToUploadLog(hwndDlg, ICQTranslateUtfStatic(LPGEN("Moving %s to group \"%s\"..."), str, MAX_PATH), strUID(dwUin, szUid), pszGroup);
currentAction = ACTION_MOVECONTACT;
@@ -686,8 +656,7 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg,UINT message,WPARAM wPara
}
hContact = db_find_next(hContact);
}
- if (!hContact)
- {
+ if (!hContact) {
currentState = STATE_VISIBILITY;
hCurrentContact = NULL;
PostMessage(hwndDlg, M_UPLOADMORE, 0, 0);
@@ -698,16 +667,14 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg,UINT message,WPARAM wPara
// Iterate over all contacts until one is found that
// needs to be updated on the server
if (hCurrentContact == NULL)
- hContact = ppro->FindFirstContact();
- else // we do not want to go thru all contacts over and over again
- {
+ hContact = db_find_first(ppro->m_szModuleName);
+ else { // we do not want to go thru all contacts over and over again
hContact = hCurrentContact;
if (lastAckResult) // if the last operation on this contact fail, do not do it again, go to next
- hContact = ppro->FindNextContact(hContact);
+ hContact = db_find_next(hContact, ppro->m_szModuleName);
}
- while (hContact)
- {
+ while (hContact) {
WORD wApparentMode = ppro->getWord(hContact, "ApparentMode", 0);
WORD wDenyId = ppro->getWord(hContact, DBSETTING_SERVLIST_DENY, 0);
WORD wPermitId = ppro->getWord(hContact, DBSETTING_SERVLIST_PERMIT, 0);
@@ -716,10 +683,8 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg,UINT message,WPARAM wPara
hCurrentContact = hContact;
ppro->getContactUid(hContact, &dwUin, &szUid);
- if (wApparentMode == ID_STATUS_ONLINE)
- { // contact is on the visible list
- if (wPermitId == 0)
- {
+ if (wApparentMode == ID_STATUS_ONLINE) { // contact is on the visible list
+ if (wPermitId == 0) {
currentAction = ACTION_ADDVISIBLE;
wNewContactId = ppro->GenerateServerID(SSIT_ITEM, 0);
AppendToUploadLog(hwndDlg, ICQTranslateUtfStatic(LPGEN("Adding %s to visible list..."), str, MAX_PATH), strUID(dwUin, szUid));
@@ -727,10 +692,8 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg,UINT message,WPARAM wPara
break;
}
}
- if (wApparentMode == ID_STATUS_OFFLINE)
- { // contact is on the invisible list
- if (wDenyId == 0 && wIgnoreId == 0)
- {
+ if (wApparentMode == ID_STATUS_OFFLINE) { // contact is on the invisible list
+ if (wDenyId == 0 && wIgnoreId == 0) {
currentAction = ACTION_ADDINVISIBLE;
wNewContactId = ppro->GenerateServerID(SSIT_ITEM, 0);
AppendToUploadLog(hwndDlg, ICQTranslateUtfStatic(LPGEN("Adding %s to invisible list..."), str, MAX_PATH), strUID(dwUin, szUid));
@@ -738,10 +701,8 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg,UINT message,WPARAM wPara
break;
}
}
- if (wApparentMode != ID_STATUS_ONLINE)
- { // contact is not on visible list
- if (wPermitId != 0)
- {
+ if (wApparentMode != ID_STATUS_ONLINE) { // contact is not on visible list
+ if (wPermitId != 0) {
currentAction = ACTION_REMOVEVISIBLE;
wNewContactId = wPermitId;
AppendToUploadLog(hwndDlg, ICQTranslateUtfStatic(LPGEN("Deleting %s from visible list..."), str, MAX_PATH), strUID(dwUin, szUid));
@@ -749,10 +710,8 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg,UINT message,WPARAM wPara
break;
}
}
- if (wApparentMode != ID_STATUS_OFFLINE)
- { // contact is not on invisible list
- if (wDenyId != 0)
- {
+ if (wApparentMode != ID_STATUS_OFFLINE) { // contact is not on invisible list
+ if (wDenyId != 0) {
currentAction = ACTION_REMOVEINVISIBLE;
wNewContactId = wDenyId;
AppendToUploadLog(hwndDlg, ICQTranslateUtfStatic(LPGEN("Deleting %s from invisible list..."), str, MAX_PATH), strUID(dwUin, szUid));
@@ -762,8 +721,7 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg,UINT message,WPARAM wPara
}
hContact = db_find_next(hContact);
}
- if (!hContact)
- {
+ if (!hContact) {
currentState = STATE_CONSOLIDATE;
AppendToUploadLog(hwndDlg, ICQTranslateUtfStatic(LPGEN("Cleaning groups"), str, MAX_PATH));
EnableDlgItem(hwndDlg, IDCANCEL, FALSE);
@@ -776,16 +734,14 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg,UINT message,WPARAM wPara
if (currentAction == ACTION_UPDATESTATE)
DeleteLastUploadLogLine(hwndDlg);
- if (cbGroupIds) // some groups in the list
- {
+ if (cbGroupIds) { // some groups in the list
void* groupData;
int groupSize;
cbGroupIds--;
wNewGroupId = pwGroupIds[cbGroupIds];
- if (groupData = ppro->collectBuddyGroup(wNewGroupId, &groupSize))
- { // the group is still not empty, just update it
+ if (groupData = ppro->collectBuddyGroup(wNewGroupId, &groupSize)) { // the group is still not empty, just update it
char* pszGroup = ppro->getServListGroupName(wNewGroupId);
cookie_servlist_action* ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action));
@@ -800,18 +756,15 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg,UINT message,WPARAM wPara
SAFE_FREE((void**)&pszGroup);
}
- else // the group is empty, delete it if it does not have sub-groups
- {
- if (!ppro->CheckServerID((WORD)(wNewGroupId+1), 0) || ppro->getServListGroupLevel((WORD)(wNewGroupId+1)) == 0)
- { // is next id an sub-group, if yes, we cannot delete this group
+ else { // the group is empty, delete it if it does not have sub-groups
+ if (!ppro->CheckServerID((WORD)(wNewGroupId + 1), 0) || ppro->getServListGroupLevel((WORD)(wNewGroupId + 1)) == 0) { // is next id an sub-group, if yes, we cannot delete this group
char *pszGroup = ppro->getServListGroupName(wNewGroupId);
currentAction = ACTION_REMOVEGROUP;
- AppendToUploadLog(hwndDlg, ICQTranslateUtfStatic(LPGEN("Deleting group \"%s\"..."), str, MAX_PATH), pszGroup);
+ AppendToUploadLog(hwndDlg, ICQTranslateUtfStatic(LPGEN("Deleting group \"%s\"..."), str, MAX_PATH), pszGroup);
currentSequence = sendUploadGroup(ppro, ICQ_LISTS_REMOVEFROMLIST, wNewGroupId, pszGroup);
SAFE_FREE((void**)&pszGroup);
}
- else // update empty group
- {
+ else { // update empty group
char *pszGroup = ppro->getServListGroupName(wNewGroupId);
cookie_servlist_action *ack = (cookie_servlist_action*)SAFE_MALLOC(sizeof(cookie_servlist_action));
@@ -829,39 +782,34 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg,UINT message,WPARAM wPara
}
SAFE_FREE((void**)&groupData); // free the memory
}
- else
- { // all groups processed
+ else { // all groups processed
SAFE_FREE((void**)&pwGroupIds);
currentState = STATE_READY;
}
break;
}
- if (currentState == STATE_READY)
- {
+ if (currentState == STATE_READY) {
// All contacts are in sync
AppendToUploadLog(hwndDlg, ICQTranslateUtfStatic(LPGEN("All operations complete"), str, MAX_PATH));
EnableDlgItem(hwndDlg, IDCANCEL, TRUE);
SetDlgItemText(hwndDlg, IDCANCEL, TranslateT("Close"));
+
// end server modifications here
ppro->servlistPostPacket(NULL, 0, SSO_END_OPERATION, 100);
working = 0;
- // SendMessage(hwndList, CLM_SETGREYOUTFLAGS,0,0);
UpdateCheckmarks(hwndList, ppro, hItemAll);
- // EnableWindow(hwndList, FALSE);
if (hProtoAckHook)
UnhookEvent(hProtoAckHook);
}
- break;
}
-
+ break;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK:
SendDlgItemMessage(hwndDlg, IDC_LOG, LB_RESETCONTENT, 0, 0);
- if (!ppro->icqOnline())
- {
+ if (!ppro->icqOnline()) {
char str[MAX_PATH];
AppendToUploadLog(hwndDlg, ICQTranslateUtfStatic(LPGEN("You have to be online to sychronize the server-list!"), str, MAX_PATH));
break;
@@ -887,12 +835,12 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg,UINT message,WPARAM wPara
break;
case WM_NOTIFY:
- switch(((NMHDR*)lParam)->idFrom) {
+ switch (((NMHDR*)lParam)->idFrom) {
case IDC_CLIST:
{
HWND hClist = GetDlgItem(hwndDlg, IDC_CLIST);
- switch(((NMHDR*)lParam)->code) {
+ switch (((NMHDR*)lParam)->code) {
case CLN_OPTIONSCHANGED:
ResetCListOptions(hClist);
break;
@@ -910,16 +858,14 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg,UINT message,WPARAM wPara
int bCheck = false;
// Delete non-icq contacts
- if ( ppro ) {
+ if (ppro) {
DeleteOtherContactsFromControl(hClist, ppro);
if (!bListInit) // do not enter twice
bCheck = UpdateCheckmarks(hClist, ppro, NULL);
}
- if (!hItemAll) // Add the "All contacts" item
- {
- CLCINFOITEM cii = {0};
-
+ 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 **"));
@@ -931,30 +877,20 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg,UINT message,WPARAM wPara
break;
case CLN_CHECKCHANGED:
- {
+ if (!bListInit) {
NMCLISTCONTROL *nm = (NMCLISTCONTROL*)lParam;
- MCONTACT hContact;
- HANDLE hItem;
+ if (nm->flags&CLNF_ISINFO) {
+ int check = SendMessage(hClist, CLM_GETCHECKMARK, (WPARAM)hItemAll, 0);
- if (bListInit) break;
-
- if (nm->flags&CLNF_ISINFO)
- {
- int check;
-
- check = SendMessage(hClist, CLM_GETCHECKMARK, (WPARAM)hItemAll, 0);
-
- hContact = ppro->FindFirstContact();
- while (hContact)
- {
- hItem = (HANDLE)SendMessage(hClist, CLM_FINDCONTACT, hContact, 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 = ppro->FindNextContact(hContact);
+ hContact = db_find_next(hContact, ppro->m_szModuleName);
}
}
- else
- UpdateAllContactsCheckmark(hClist, ppro, hItemAll);
+ else UpdateAllContactsCheckmark(hClist, ppro, hItemAll);
}
break;
}
@@ -970,10 +906,9 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg,UINT message,WPARAM wPara
case WM_DESTROY:
if (hProtoAckHook)
UnhookEvent(hProtoAckHook);
- if (working)
- { // end server modifications here
+ if (working) // end server modifications here
ppro->servlistPostPacket(NULL, 0, SSO_END_OPERATION, 100);
- }
+
hwndUploadContacts = NULL;
working = 0;
break;
@@ -984,8 +919,7 @@ static INT_PTR CALLBACK DlgProcUploadList(HWND hwndDlg,UINT message,WPARAM wPara
void CIcqProto::ShowUploadContactsDialog(void)
{
- if (hwndUploadContacts == NULL)
- {
+ if (hwndUploadContacts == NULL) {
hItemAll = NULL;
hwndUploadContacts = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ICQUPLOADLIST), NULL, DlgProcUploadList, LPARAM(this));
}