summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-02-16 19:56:59 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-02-16 19:56:59 +0000
commitcf2966326de39e86fa52b34c91aee2a29a31bdab (patch)
treea6a05803cbb85146c3f1fee249ad0e8998959e51 /protocols
parent2053ba5bd4f1f43d960ddeb40fa10568e2254f25 (diff)
old helpers FindFirstContact/FindNextContact removed
git-svn-id: http://svn.miranda-ng.org/main/trunk@8144 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r--protocols/IcqOscarJ/src/fam_01service.cpp4
-rw-r--r--protocols/IcqOscarJ/src/icq_db.cpp21
-rw-r--r--protocols/IcqOscarJ/src/icq_infoupdate.cpp4
-rw-r--r--protocols/IcqOscarJ/src/icq_proto.cpp22
-rw-r--r--protocols/IcqOscarJ/src/icq_proto.h3
-rw-r--r--protocols/IcqOscarJ/src/icq_server.cpp4
-rw-r--r--protocols/IcqOscarJ/src/icq_servlist.cpp12
-rw-r--r--protocols/IcqOscarJ/src/icq_uploadui.cpp542
-rw-r--r--protocols/IcqOscarJ/src/utilities.cpp24
9 files changed, 273 insertions, 363 deletions
diff --git a/protocols/IcqOscarJ/src/fam_01service.cpp b/protocols/IcqOscarJ/src/fam_01service.cpp
index 0e18163289..2debcedfeb 100644
--- a/protocols/IcqOscarJ/src/fam_01service.cpp
+++ b/protocols/IcqOscarJ/src/fam_01service.cpp
@@ -544,7 +544,7 @@ char* CIcqProto::buildUinList(int subtype, WORD wMaxLen, MCONTACT *hContactResum
if (*hContactResume)
hContact = *hContactResume;
else
- hContact = FindFirstContact();
+ hContact = db_find_first(m_szModuleName);
while (hContact != NULL)
{
@@ -601,7 +601,7 @@ char* CIcqProto::buildUinList(int subtype, WORD wMaxLen, MCONTACT *hContactResum
}
}
- hContact = FindNextContact(hContact);
+ hContact = db_find_next(hContact, m_szModuleName);
}
*hContactResume = NULL;
diff --git a/protocols/IcqOscarJ/src/icq_db.cpp b/protocols/IcqOscarJ/src/icq_db.cpp
index 8246b7ffa1..e99ffa649f 100644
--- a/protocols/IcqOscarJ/src/icq_db.cpp
+++ b/protocols/IcqOscarJ/src/icq_db.cpp
@@ -190,27 +190,6 @@ HANDLE CIcqProto::AddEvent(MCONTACT hContact, WORD wType, DWORD dwTime, DWORD fl
return db_event_add(hContact, &dbei);
}
-MCONTACT CIcqProto::FindFirstContact()
-{
- MCONTACT hContact = db_find_first(m_szModuleName);
-
- if (IsICQContact(hContact))
- return hContact;
-
- return FindNextContact(hContact);
-}
-
-MCONTACT CIcqProto::FindNextContact(MCONTACT hContact)
-{
- hContact = db_find_next(hContact, m_szModuleName);
- while (hContact != NULL) {
- if (IsICQContact(hContact))
- return hContact;
- hContact = db_find_next(hContact, m_szModuleName);
- }
- return hContact;
-}
-
char* CIcqProto::getContactCListGroup(MCONTACT hContact)
{
return getSettingStringUtf(hContact, "CList", "Group", NULL);
diff --git a/protocols/IcqOscarJ/src/icq_infoupdate.cpp b/protocols/IcqOscarJ/src/icq_infoupdate.cpp
index 3771044872..fcba9444f1 100644
--- a/protocols/IcqOscarJ/src/icq_infoupdate.cpp
+++ b/protocols/IcqOscarJ/src/icq_infoupdate.cpp
@@ -155,7 +155,7 @@ void CIcqProto::icq_RescanInfoUpdate()
bInfoUpdateEnabled = 0; // freeze thread
// Queue all outdated users
- MCONTACT hContact = FindFirstContact();
+ MCONTACT hContact = db_find_first(m_szModuleName);
while (hContact != NULL)
{
if (IsMetaInfoChanged(hContact))
@@ -166,7 +166,7 @@ void CIcqProto::icq_RescanInfoUpdate()
break;
}
}
- hContact = FindNextContact(hContact);
+ hContact = db_find_next(hContact, m_szModuleName);
}
bInfoUpdateEnabled = TRUE;
diff --git a/protocols/IcqOscarJ/src/icq_proto.cpp b/protocols/IcqOscarJ/src/icq_proto.cpp
index 02aa469ba6..e5072dd48f 100644
--- a/protocols/IcqOscarJ/src/icq_proto.cpp
+++ b/protocols/IcqOscarJ/src/icq_proto.cpp
@@ -35,7 +35,7 @@ extern PLUGININFOEX pluginInfo;
#pragma warning(disable:4355)
-static int CompareConns(const directconnect* p1, const directconnect* p2)
+static int CompareConns(const directconnect *p1, const directconnect *p2)
{
if (p1 < p2)
return -1;
@@ -43,7 +43,7 @@ static int CompareConns(const directconnect* p1, const directconnect* p2)
return (p1 == p2) ? 0 : 1;
}
-static int CompareCookies(const icq_cookie_info* p1, const icq_cookie_info* p2)
+static int CompareCookies(const icq_cookie_info *p1, const icq_cookie_info *p2)
{
if (p1->dwCookie < p2->dwCookie)
return -1;
@@ -51,7 +51,7 @@ static int CompareCookies(const icq_cookie_info* p1, const icq_cookie_info* p2)
return (p1->dwCookie == p2->dwCookie) ? 0 : 1;
}
-static int CompareFT(const filetransfer* p1, const filetransfer* p2)
+static int CompareFT(const filetransfer *p1, const filetransfer *p2)
{
if (p1->dwCookie < p2->dwCookie)
return -1;
@@ -71,12 +71,12 @@ static int CompareContactsCache(const icq_contacts_cache *p1, const icq_contacts
}
CIcqProto::CIcqProto(const char* aProtoName, const TCHAR* aUserName) :
-PROTO<CIcqProto>(aProtoName, aUserName),
-cookies(10, CompareCookies),
-directConns(10, CompareConns),
-expectedFileRecvs(10, CompareFT),
-contactsCache(10, CompareContactsCache),
-cheekySearchId(-1)
+ PROTO<CIcqProto>(aProtoName, aUserName),
+ cookies(10, CompareCookies),
+ directConns(10, CompareConns),
+ expectedFileRecvs(10, CompareFT),
+ contactsCache(10, CompareContactsCache),
+ cheekySearchId(-1)
{
debugLogA("Setting protocol/module name to '%s'", m_szModuleName);
@@ -291,13 +291,13 @@ int CIcqProto::OnModulesLoaded(WPARAM wParam, LPARAM lParam)
ModuleLoad(0, 0);
InitXStatusItems(FALSE);
- MCONTACT hContact = FindFirstContact();
+ MCONTACT hContact = db_find_first(m_szModuleName);
while (hContact != NULL) {
DWORD bXStatus = getContactXStatus(hContact);
if (bXStatus > 0)
setContactExtraIcon(hContact, bXStatus);
- hContact = FindNextContact(hContact);
+ hContact = db_find_next(hContact, m_szModuleName);
}
return 0;
diff --git a/protocols/IcqOscarJ/src/icq_proto.h b/protocols/IcqOscarJ/src/icq_proto.h
index 1f8e28dcdf..5b412c3390 100644
--- a/protocols/IcqOscarJ/src/icq_proto.h
+++ b/protocols/IcqOscarJ/src/icq_proto.h
@@ -419,9 +419,6 @@ struct CIcqProto : public PROTO<CIcqProto>
HANDLE AddEvent(MCONTACT hContact, WORD wType, DWORD dwTime, DWORD flags, DWORD cbBlob, PBYTE pBlob);
int IsICQContact(MCONTACT hContact);
- MCONTACT FindFirstContact();
- MCONTACT FindNextContact(MCONTACT hContact);
-
int getSetting(MCONTACT hContact, const char *szSetting, DBVARIANT *dbv);
double getSettingDouble(MCONTACT hContact, const char *szSetting, double dDef);
int getSettingStringStatic(MCONTACT hContact, const char *szSetting, char *dest, int dest_len);
diff --git a/protocols/IcqOscarJ/src/icq_server.cpp b/protocols/IcqOscarJ/src/icq_server.cpp
index e5691b1215..d32369a0c9 100644
--- a/protocols/IcqOscarJ/src/icq_server.cpp
+++ b/protocols/IcqOscarJ/src/icq_server.cpp
@@ -192,7 +192,7 @@ void __cdecl CIcqProto::ServerThread(serverthread_start_info *infoParam)
StopAvatarThread();
// Offline all contacts
- MCONTACT hContact = FindFirstContact();
+ MCONTACT hContact = db_find_first(m_szModuleName);
while (hContact)
{
DWORD dwUIN;
@@ -210,7 +210,7 @@ void __cdecl CIcqProto::ServerThread(serverthread_start_info *infoParam)
}
}
- hContact = FindNextContact(hContact);
+ hContact = db_find_next(hContact, m_szModuleName);
}
setDword("LogonTS", 0); // clear logon time
diff --git a/protocols/IcqOscarJ/src/icq_servlist.cpp b/protocols/IcqOscarJ/src/icq_servlist.cpp
index ae2497dabe..dac87bdf52 100644
--- a/protocols/IcqOscarJ/src/icq_servlist.cpp
+++ b/protocols/IcqOscarJ/src/icq_servlist.cpp
@@ -975,7 +975,7 @@ void CIcqProto::LoadServerIDs()
nGroups = nServerIDListCount - nStart;
- MCONTACT hContact = FindFirstContact();
+ MCONTACT hContact = db_find_first(m_szModuleName);
while (hContact)
{ // search all our contacts, reserve their server IDs
@@ -1000,7 +1000,7 @@ void CIcqProto::LoadServerIDs()
nIgnores++;
}
- hContact = FindNextContact(hContact);
+ hContact = db_find_next(hContact, m_szModuleName);
}
servlistMutex->Leave();
@@ -1363,7 +1363,7 @@ void* CIcqProto::collectBuddyGroup(WORD wGroupID, int *count)
MCONTACT hContact;
WORD wItemID;
- hContact = FindFirstContact();
+ hContact = db_find_first(m_szModuleName);
while (hContact)
{ // search all contacts
@@ -1380,7 +1380,7 @@ void* CIcqProto::collectBuddyGroup(WORD wGroupID, int *count)
}
}
- hContact = FindNextContact(hContact);
+ hContact = db_find_next(hContact, m_szModuleName);
}
if (count)
@@ -1398,7 +1398,7 @@ void* CIcqProto::collectGroups(int *count)
MCONTACT hContact;
WORD wGroupID;
- hContact = FindFirstContact();
+ hContact = db_find_first(m_szModuleName);
while (hContact)
{ // search all contacts
@@ -1417,7 +1417,7 @@ void* CIcqProto::collectGroups(int *count)
}
}
- hContact = FindNextContact(hContact);
+ hContact = db_find_next(hContact, m_szModuleName);
}
*count = cnt<<1;
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));
}
diff --git a/protocols/IcqOscarJ/src/utilities.cpp b/protocols/IcqOscarJ/src/utilities.cpp
index 29e88eb9e2..848081765c 100644
--- a/protocols/IcqOscarJ/src/utilities.cpp
+++ b/protocols/IcqOscarJ/src/utilities.cpp
@@ -372,7 +372,7 @@ void CIcqProto::InitContactsCache()
// build cache
icq_lock l(contactsCacheMutex);
- MCONTACT hContact = FindFirstContact();
+ MCONTACT hContact = db_find_first(m_szModuleName);
while (hContact) {
DWORD dwUin;
@@ -381,7 +381,7 @@ void CIcqProto::InitContactsCache()
if (!getContactUid(hContact, &dwUin, &szUid))
AddToContactsCache(hContact, dwUin, szUid);
- hContact = FindNextContact(hContact);
+ hContact = db_find_next(hContact, m_szModuleName);
}
}
@@ -454,7 +454,7 @@ MCONTACT CIcqProto::HContactFromUIN(DWORD dwUin, int *Added)
if (hContact)
return hContact;
- hContact = FindFirstContact();
+ hContact = db_find_first(m_szModuleName);
while (hContact) {
DWORD dwContactUin;
@@ -464,7 +464,7 @@ MCONTACT CIcqProto::HContactFromUIN(DWORD dwUin, int *Added)
return hContact;
}
- hContact = FindNextContact(hContact);
+ hContact = db_find_next(hContact, m_szModuleName);
}
//not present: add
@@ -522,7 +522,7 @@ MCONTACT CIcqProto::HContactFromUID(DWORD dwUin, const char *szUid, int *Added)
MCONTACT hContact = HandleFromCacheByUid(dwUin, szUid);
if (hContact) return hContact;
- hContact = FindFirstContact();
+ hContact = db_find_first(m_szModuleName);
while (hContact) {
DWORD dwContactUin;
uid_str szContactUid;
@@ -535,7 +535,7 @@ MCONTACT CIcqProto::HContactFromUID(DWORD dwUin, const char *szUid, int *Added)
return hContact;
}
}
- hContact = FindNextContact(hContact);
+ hContact = db_find_next(hContact, m_szModuleName);
}
//not present: add
@@ -888,7 +888,7 @@ void CIcqProto::ResetSettingsOnListReload()
setWord("SrvRecordCount", 0);
delSetting(DBSETTING_SERVLIST_UNHANDLED);
- MCONTACT hContact = FindFirstContact();
+ MCONTACT hContact = db_find_first(m_szModuleName);
while (hContact) {
// All these values will be restored during the serv-list receive
@@ -900,7 +900,7 @@ void CIcqProto::ResetSettingsOnListReload()
setByte(hContact, "Auth", 0);
delSetting(hContact, DBSETTING_SERVLIST_DATA);
- hContact = FindNextContact(hContact);
+ hContact = db_find_next(hContact, m_szModuleName);
}
FlushSrvGroupsCache();
@@ -912,7 +912,7 @@ void CIcqProto::ResetSettingsOnConnect()
setByte("SrvVisibility", 0);
setDword("IdleTS", 0);
- MCONTACT hContact = FindFirstContact();
+ MCONTACT hContact = db_find_first(m_szModuleName);
while (hContact) {
setDword(hContact, "LogonTS", 0);
@@ -924,7 +924,7 @@ void CIcqProto::ResetSettingsOnConnect()
if (getContactStatus(hContact) != ID_STATUS_OFFLINE)
setWord(hContact, "Status", ID_STATUS_OFFLINE);
- hContact = FindNextContact(hContact);
+ hContact = db_find_next(hContact, m_szModuleName);
}
}
@@ -933,7 +933,7 @@ void CIcqProto::ResetSettingsOnLoad()
setDword("IdleTS", 0);
setDword("LogonTS", 0);
- MCONTACT hContact = FindFirstContact();
+ MCONTACT hContact = db_find_first(m_szModuleName);
while (hContact) {
setDword(hContact, "LogonTS", 0);
@@ -948,7 +948,7 @@ void CIcqProto::ResetSettingsOnLoad()
}
setByte(hContact, "DCStatus", 0);
- hContact = FindNextContact(hContact);
+ hContact = db_find_next(hContact, m_szModuleName);
}
}