summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-04-09 20:03:46 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-04-09 20:03:46 +0000
commitbcb27264ba737778e5d3edad36088bacf74f0236 (patch)
treefd1f57744dd380b7babe312a0ab5dc60b48854f2 /protocols
parent940231dc5a484b03a278900e1880aa083472b601 (diff)
- short function names allows to write database loops in one string;
- 'continue' operator can be used then; - multiple bugs fixed in clists; - code becomes much more compact; git-svn-id: http://svn.miranda-ng.org/main/trunk@4403 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r--protocols/AimOscar/src/theme.cpp24
-rw-r--r--protocols/AimOscar/src/utility.cpp89
-rw-r--r--protocols/EmLanProto/src/mlan.cpp14
-rw-r--r--protocols/FacebookRM/src/contacts.cpp15
-rw-r--r--protocols/FacebookRM/src/process.cpp5
-rw-r--r--protocols/Gadu-Gadu/src/core.cpp38
-rw-r--r--protocols/Gadu-Gadu/src/groupchat.cpp45
-rw-r--r--protocols/Gadu-Gadu/src/import.cpp12
-rw-r--r--protocols/IRCG/src/clist.cpp23
-rw-r--r--protocols/IRCG/src/commandmonitor.cpp14
-rw-r--r--protocols/IcqOscarJ/src/icq_uploadui.cpp12
-rw-r--r--protocols/JabberG/src/jabber_chat.cpp13
-rw-r--r--protocols/JabberG/src/jabber_icolib.cpp8
-rw-r--r--protocols/JabberG/src/jabber_iqid.cpp8
-rw-r--r--protocols/JabberG/src/jabber_misc.cpp8
-rw-r--r--protocols/JabberG/src/jabber_opt.cpp66
-rw-r--r--protocols/JabberG/src/jabber_privacy.cpp40
-rw-r--r--protocols/JabberG/src/jabber_proto.cpp18
-rw-r--r--protocols/JabberG/src/jabber_rc.cpp8
-rw-r--r--protocols/JabberG/src/jabber_thread.cpp8
-rw-r--r--protocols/JabberG/src/jabber_util.cpp17
-rw-r--r--protocols/MRA/src/Mra_functions.cpp12
-rw-r--r--protocols/MRA/src/Mra_proto.cpp2
-rw-r--r--protocols/MRA/src/Mra_svcs.cpp12
-rw-r--r--protocols/MSN/src/msn_lists.cpp3
-rw-r--r--protocols/MSN/src/msn_proto.cpp11
-rw-r--r--protocols/Tlen/src/jabber_iqid.cpp8
-rw-r--r--protocols/Tlen/src/jabber_misc.cpp17
-rw-r--r--protocols/Tlen/src/jabber_thread.cpp5
-rw-r--r--protocols/Tlen/src/tlen.cpp7
-rw-r--r--protocols/Tlen/src/tlen_muc.cpp11
-rw-r--r--protocols/Twitter/src/chat.cpp3
-rw-r--r--protocols/Xfire/src/main.cpp8
-rw-r--r--protocols/Yahoo/src/services.cpp6
-rw-r--r--protocols/Yahoo/src/yahoo.cpp26
35 files changed, 195 insertions, 421 deletions
diff --git a/protocols/AimOscar/src/theme.cpp b/protocols/AimOscar/src/theme.cpp
index b5c0ae20a7..3dc5dce55f 100644
--- a/protocols/AimOscar/src/theme.cpp
+++ b/protocols/AimOscar/src/theme.cpp
@@ -144,46 +144,30 @@ void set_contact_icon(CAimProto* ppro, HANDLE hContact)
void remove_AT_icons(CAimProto* ppro)
{
- HANDLE hContact = db_find_first();
- while (hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
if (ppro->is_my_contact(hContact) && !ppro->getByte(hContact, "ChatRoom", 0))
ExtraIcon_Clear(hExtraAT, hContact);
-
- hContact = db_find_next(hContact);
- }
}
void remove_ES_icons(CAimProto* ppro)
{
- HANDLE hContact = db_find_first();
- while (hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
if (ppro->is_my_contact(hContact) && !ppro->getByte(hContact, "ChatRoom", 0))
ExtraIcon_Clear(hExtraES, hContact);
-
- hContact = db_find_next(hContact);
- }
}
void add_AT_icons(CAimProto* ppro)
{
- HANDLE hContact = db_find_first();
- while (hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
if (ppro->is_my_contact(hContact))
set_AT_icon(ppro, hContact);
-
- hContact = db_find_next(hContact);
- }
}
void add_ES_icons(CAimProto* ppro)
{
- HANDLE hContact = db_find_first();
- while (hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
if (ppro->is_my_contact(hContact))
set_ES_icon(ppro, hContact);
-
- hContact = db_find_next(hContact);
- }
}
void InitExtraIcons(void)
diff --git a/protocols/AimOscar/src/utility.cpp b/protocols/AimOscar/src/utility.cpp
index cabadfffb0..4fbc7a03c5 100644
--- a/protocols/AimOscar/src/utility.cpp
+++ b/protocols/AimOscar/src/utility.cpp
@@ -168,69 +168,50 @@ bool CAimProto::is_my_contact(HANDLE hContact)
HANDLE CAimProto::find_chat_contact(const char* room)
{
- HANDLE hContact = db_find_first();
- while (hContact)
- {
- if (is_my_contact(hContact))
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ if (is_my_contact(hContact)) {
DBVARIANT dbv;
- if (!getString(hContact, "ChatRoomID", &dbv))
- {
+ if (!getString(hContact, "ChatRoomID", &dbv)) {
bool found = !strcmp(room, dbv.pszVal);
db_free(&dbv);
if (found) return hContact;
}
}
- hContact = db_find_next(hContact);
}
return NULL;
}
HANDLE CAimProto::contact_from_sn(const char* sn, bool addIfNeeded, bool temporary)
{
- char* norm_sn = normalize_name(sn);
+ mir_ptr<char> norm_sn( normalize_name(sn));
- HANDLE hContact = db_find_first();
- while (hContact)
- {
- if (is_my_contact(hContact))
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ if (is_my_contact(hContact)) {
DBVARIANT dbv;
- if (!getString(hContact, AIM_KEY_SN, &dbv))
- {
+ if (!getString(hContact, AIM_KEY_SN, &dbv)) {
bool found = !strcmp(norm_sn, dbv.pszVal);
db_free(&dbv);
if (found)
- {
- mir_free(norm_sn);
return hContact;
- }
}
}
- hContact = db_find_next(hContact);
}
- if (addIfNeeded)
- {
- hContact = (HANDLE)CallService(MS_DB_CONTACT_ADD, 0, 0);
- if (hContact)
- {
- if (CallService(MS_PROTO_ADDTOCONTACT, (WPARAM) hContact, (LPARAM) m_szModuleName) == 0)
- {
+ if (addIfNeeded) {
+ HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ if (hContact) {
+ if (CallService(MS_PROTO_ADDTOCONTACT, (WPARAM) hContact, (LPARAM) m_szModuleName) == 0) {
setString(hContact, AIM_KEY_SN, norm_sn);
setString(hContact, AIM_KEY_NK, sn);
LOG("Adding contact %s to client side list.",norm_sn);
if (temporary)
db_set_b(hContact, "CList", "NotOnList", 1);
- mir_free(norm_sn);
return hContact;
}
- else
- CallService(MS_DB_CONTACT_DELETE, (WPARAM) hContact, 0);
+ CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
}
}
- mir_free(norm_sn);
return NULL;
}
@@ -340,13 +321,10 @@ void CAimProto::offline_contact(HANDLE hContact, bool remove_settings)
void CAimProto::offline_contacts(void)
{
- HANDLE hContact = db_find_first();
- while (hContact)
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
if (is_my_contact(hContact))
offline_contact(hContact,true);
- hContact = db_find_next(hContact);
- }
+
allow_list.destroy();
block_list.destroy();
group_list.destroy();
@@ -409,20 +387,15 @@ unsigned short CAimProto::search_for_free_item_id(HANDLE hbuddy)//returns a free
retry:
id = get_random();
- HANDLE hContact = db_find_first();
- while (hContact)
- {
- if (is_my_contact(hContact))
- {
- for(int i=1; ;++i)
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ if (is_my_contact(hContact)) {
+ for(int i=1; ;++i) {
unsigned short item_id = getBuddyId(hContact, i);
if (item_id == 0) break;
if (item_id == id) goto retry; //found one no need to look through anymore
}
}
- hContact = db_find_next(hContact);
}
setBuddyId(hbuddy, 1, id);
@@ -435,44 +408,34 @@ unsigned short* CAimProto::get_members_of_group(unsigned short group_id, unsigne
unsigned short* list = NULL;
size = 0;
- HANDLE hContact = db_find_first();
- while (hContact)
- {
- if (is_my_contact(hContact))
- {
- for(int i=1; ;++i)
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ if (is_my_contact(hContact)) {
+ for(int i=1; ;++i) {
unsigned short user_group_id = getGroupId(hContact, i);
- if (user_group_id == 0) break;
+ if (user_group_id == 0)
+ break;
- if (group_id == user_group_id)
- {
+ if (group_id == user_group_id) {
unsigned short buddy_id = getBuddyId(hContact, i);
- if (buddy_id)
- {
+ if (buddy_id) {
list = (unsigned short*)mir_realloc(list, ++size*sizeof(list[0]));
list[size-1] = _htons(buddy_id);
}
}
}
}
- hContact = db_find_next(hContact);
}
return list;
}
void CAimProto::upload_nicks(void)
{
- HANDLE hContact = db_find_first();
- while (hContact)
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
DBVARIANT dbv;
- if (is_my_contact(hContact) && !db_get_utf(hContact, MOD_KEY_CL, "MyHandle", &dbv))
- {
+ if (is_my_contact(hContact) && !db_get_utf(hContact, MOD_KEY_CL, "MyHandle", &dbv)) {
set_local_nick(hContact, dbv.pszVal, NULL);
db_free(&dbv);
}
- hContact = db_find_next(hContact);
}
}
diff --git a/protocols/EmLanProto/src/mlan.cpp b/protocols/EmLanProto/src/mlan.cpp
index 165a18afa6..b17b7ef7c9 100644
--- a/protocols/EmLanProto/src/mlan.cpp
+++ b/protocols/EmLanProto/src/mlan.cpp
@@ -127,14 +127,12 @@ void CMLan::SetMirandaStatus(u_int status)
void CMLan::SetAllOffline()
{
- HANDLE hContact = db_find_first();
- while (hContact != NULL) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *svc = GetContactProto(hContact);
if (svc != NULL && lstrcmp(PROTONAME,svc) == 0) {
db_set_w(hContact,PROTONAME,"Status",ID_STATUS_OFFLINE);
db_unset(hContact, PROTONAME, "IP");
}
- hContact = db_find_next(hContact);
}
DeleteCache();
}
@@ -243,8 +241,7 @@ void CMLan::SendPacketExt(TPacket& pak, u_long addr)
HANDLE CMLan::FindContact(in_addr addr, const char* nick, bool add_to_list, bool make_permanent, bool make_visible, u_int status)
{
- HANDLE res = db_find_first();
- while (res != NULL) {
+ for (HANDLE res = db_find_first(); res; res = db_find_next(res)) {
char *szProto = GetContactProto(res);
if (szProto!=NULL && !lstrcmp(PROTONAME, szProto)) {
u_long caddr = db_get_dw(res, PROTONAME, "ipaddr", -1);
@@ -256,11 +253,10 @@ HANDLE CMLan::FindContact(in_addr addr, const char* nick, bool add_to_list, boo
return res;
}
}
- res = db_find_next(res);
}
if (add_to_list) {
- res=(HANDLE)CallService(MS_DB_CONTACT_ADD,0,0);
+ HANDLE res=(HANDLE)CallService(MS_DB_CONTACT_ADD,0,0);
CallService(MS_PROTO_ADDTOCONTACT,(WPARAM)res,(LPARAM)PROTONAME);
db_set_dw(res,PROTONAME, "ipaddr", addr.S_un.S_addr);
db_set_s(res,PROTONAME, "Nick", nick);
@@ -271,10 +267,10 @@ HANDLE CMLan::FindContact(in_addr addr, const char* nick, bool add_to_list, boo
db_set_b(res,"CList","Hidden",1);
db_set_w(res,PROTONAME, "Status", status);
+ return res;
}
- else res = NULL;
- return res;
+ return NULL;
}
void CMLan::OnRecvPacket(u_char* mes, int len, in_addr from)
diff --git a/protocols/FacebookRM/src/contacts.cpp b/protocols/FacebookRM/src/contacts.cpp
index abea7b8f49..392b95df82 100644
--- a/protocols/FacebookRM/src/contacts.cpp
+++ b/protocols/FacebookRM/src/contacts.cpp
@@ -38,10 +38,7 @@ bool FacebookProto::IsMyContact(HANDLE hContact, bool include_chat)
HANDLE FacebookProto::ChatIDToHContact(std::string chat_id)
{
- for(HANDLE hContact = db_find_first();
- hContact;
- hContact = db_find_next(hContact))
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if(!IsMyContact(hContact, true))
continue;
@@ -63,10 +60,7 @@ HANDLE FacebookProto::ChatIDToHContact(std::string chat_id)
HANDLE FacebookProto::ContactIDToHContact(std::string user_id)
{
- for(HANDLE hContact = db_find_first();
- hContact;
- hContact = db_find_next(hContact))
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if(!IsMyContact(hContact))
continue;
@@ -140,10 +134,7 @@ HANDLE FacebookProto::AddToContactList(facebook_user* fbu, BYTE type, bool dont_
void FacebookProto::SetAllContactStatuses(int status, bool reset_client)
{
- for (HANDLE hContact = db_find_first();
- hContact;
- hContact = db_find_next(hContact))
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if (!IsMyContact(hContact))
continue;
diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp
index d095118045..e3f1a014ba 100644
--- a/protocols/FacebookRM/src/process.cpp
+++ b/protocols/FacebookRM/src/process.cpp
@@ -160,10 +160,7 @@ void FacebookProto::ProcessFriendList( void* data )
// Check and update old contacts
- for(HANDLE hContact = db_find_first();
- hContact;
- hContact = db_find_next(hContact))
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if (!IsMyContact(hContact))
continue;
diff --git a/protocols/Gadu-Gadu/src/core.cpp b/protocols/Gadu-Gadu/src/core.cpp
index 6d3b91fe28..393157275d 100644
--- a/protocols/Gadu-Gadu/src/core.cpp
+++ b/protocols/Gadu-Gadu/src/core.cpp
@@ -1446,12 +1446,10 @@ void GGPROTO::setalloffline()
{
netlog("setalloffline(): started. Setting buddies offline");
db_set_w(NULL, m_szModuleName, GG_KEY_STATUS, ID_STATUS_OFFLINE);
- HANDLE hContact = db_find_first();
- while (hContact)
- {
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *szProto = GetContactProto(hContact);
- if (szProto != NULL && !strcmp(szProto, m_szModuleName))
- {
+ if (szProto != NULL && !strcmp(szProto, m_szModuleName)) {
db_set_w(hContact, m_szModuleName, GG_KEY_STATUS, ID_STATUS_OFFLINE);
// Clear IP and port settings
db_unset(hContact, m_szModuleName, GG_KEY_CLIENTIP);
@@ -1459,7 +1457,6 @@ void GGPROTO::setalloffline()
// Delete status descr
db_unset(hContact, "CList", GG_KEY_STATUSDESCR);
}
- hContact = db_find_next(hContact);
}
#ifdef DEBUGMODE
netlog("setalloffline(): End.");
@@ -1519,20 +1516,17 @@ void GGPROTO::notifyall()
netlog("notifyall(): Subscribing notification to all users");
// Readup count
- hContact = db_find_first();
- while (hContact)
- {
+
+ for (hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
szProto = GetContactProto(hContact);
- if (szProto != NULL && !strcmp(szProto, m_szModuleName)) count ++;
- hContact = db_find_next(hContact);
+ if (szProto != NULL && !strcmp(szProto, m_szModuleName))
+ count ++;
}
// Readup list
/* FIXME: If we have nothing on the list but we omit gg_notify_ex we have problem with receiving any contacts */
- if (count == 0)
- {
- if (isonline())
- {
+ if (count == 0) {
+ if (isonline()) {
gg_EnterCriticalSection(&sess_mutex, "notifyall", 29, "sess_mutex", 1);
gg_notify_ex(sess, NULL, NULL, 0);
gg_LeaveCriticalSection(&sess_mutex, "notifyall", 29, 1, "sess_mutex", 1);
@@ -1542,12 +1536,9 @@ void GGPROTO::notifyall()
uins = (uin_t*)calloc(sizeof(uin_t), count);
types = (char*)calloc(sizeof(char), count);
- hContact = db_find_first();
- while (hContact && cc < count)
- {
+ for (hContact = db_find_first(); hContact && cc < count; hContact = db_find_next(hContact)) {
szProto = GetContactProto(hContact);
- if (szProto != NULL && !strcmp(szProto, m_szModuleName) && (uins[cc] = db_get_dw(hContact, m_szModuleName, GG_KEY_UIN, 0)))
- {
+ if (szProto != NULL && !strcmp(szProto, m_szModuleName) && (uins[cc] = db_get_dw(hContact, m_szModuleName, GG_KEY_UIN, 0))) {
if ((db_get_w(hContact, m_szModuleName, GG_KEY_APPARENT, (WORD) ID_STATUS_ONLINE) == ID_STATUS_OFFLINE) ||
db_get_b(hContact, "CList", "NotOnList", 0))
types[cc] = GG_USER_OFFLINE;
@@ -1557,7 +1548,6 @@ void GGPROTO::notifyall()
types[cc] = GG_USER_NORMAL;
cc ++;
}
- hContact = db_find_next(hContact);
}
if (cc < count) count = cc;
@@ -1582,8 +1572,7 @@ HANDLE GGPROTO::getcontact(uin_t uin, int create, int inlist, TCHAR *szNick)
netlog("getcontact(): uin=%d create=%d inlist=%d", uin, create, inlist);
#endif
// Look for contact in DB
- HANDLE hContact = db_find_first();
- while (hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *szProto = GetContactProto(hContact);
if (szProto != NULL && !strcmp(szProto, m_szModuleName)) {
if ((uin_t)db_get_dw(hContact, m_szModuleName, GG_KEY_UIN, 0) == uin
@@ -1596,11 +1585,10 @@ HANDLE GGPROTO::getcontact(uin_t uin, int create, int inlist, TCHAR *szNick)
return hContact;
}
}
- hContact = db_find_next(hContact);
}
if (!create) return NULL;
- hContact = (HANDLE) CallService(MS_DB_CONTACT_ADD, 0, 0);
+ HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_ADD, 0, 0);
if (!hContact) {
netlog("getcontact(): Failed to create Gadu-Gadu contact %S", szNick);
return NULL;
diff --git a/protocols/Gadu-Gadu/src/groupchat.cpp b/protocols/Gadu-Gadu/src/groupchat.cpp
index 1f19e0c25c..1fd94d1fd1 100644
--- a/protocols/Gadu-Gadu/src/groupchat.cpp
+++ b/protocols/Gadu-Gadu/src/groupchat.cpp
@@ -137,23 +137,19 @@ int GGPROTO::gc_event(WPARAM wParam, LPARAM lParam)
// Window terminated (Miranda exit)
if (gch->pDest->iType == SESSION_TERMINATE)
{
- HANDLE hContact = NULL;
netlog("gc_event(): Terminating chat %x, id %S from chat window...", chat, gch->pDest->ptszID);
// Destroy chat entry
free(chat->recipients);
list_remove(&chats, chat, 1);
+
// Remove contact from contact list (duh!) should be done by chat.dll !!
- hContact = db_find_first();
- while (hContact)
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
DBVARIANT dbv;
- if (!db_get_s(hContact, m_szModuleName, "ChatRoomID", &dbv, DBVT_TCHAR))
- {
+ if (!db_get_s(hContact, m_szModuleName, "ChatRoomID", &dbv, DBVT_TCHAR)) {
if (dbv.ptszVal && !_tcscmp(gch->pDest->ptszID, dbv.ptszVal))
CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
db_free(&dbv);
}
- hContact = db_find_next(hContact);
}
return 1;
}
@@ -440,13 +436,10 @@ static void gg_gc_resetclistopts(HWND hwndList)
static int gg_gc_countcheckmarks(HWND hwndList)
{
int count = 0;
- HANDLE hItem, hContact = db_find_first();
- while (hContact)
- {
- hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0);
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0);
if (hItem && SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)hItem, 0))
count++;
- hContact = db_find_next(hContact);
}
return count;
}
@@ -494,17 +487,13 @@ static INT_PTR CALLBACK gg_gc_openconfdlg(HWND hwndDlg, UINT message, WPARAM wPa
// Create new participiants table
TCHAR* chat;
uin_t* participants = (uin_t*)calloc(count, sizeof(uin_t));
- HANDLE hItem, hContact = db_find_first();
gg->netlog("gg_gc_openconfdlg(): WM_COMMAND IDOK Opening new conference for %d contacts.", count);
- while (hContact && i < count)
- {
- hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0);
- if (hItem && SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)hItem, 0))
- {
+ for (HANDLE hContact = db_find_first(); hContact && i < count; hContact = db_find_next(hContact)) {
+ HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0);
+ if (hItem && SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)hItem, 0)) {
HANDLE hMetaContact = gg_getsubcontact(gg, hContact); // MetaContacts support
participants[i++] = db_get_dw(hMetaContact ? hMetaContact : hContact, gg->m_szModuleName, GG_KEY_UIN, 0);
}
- hContact = db_find_next(hContact);
}
if (count > i) i = count;
chat = gg->gc_getchat(0, participants, count);
@@ -545,8 +534,6 @@ static INT_PTR CALLBACK gg_gc_openconfdlg(HWND hwndDlg, UINT message, WPARAM wPa
case CLN_CONTACTMOVED:
case CLN_LISTREBUILT:
{
- HANDLE hContact;
- HANDLE hItem;
char* szProto;
uin_t uin;
GGPROTO* gg = (GGPROTO*)GetWindowLongPtr(hwndDlg, DWLP_USER);
@@ -554,20 +541,15 @@ static INT_PTR CALLBACK gg_gc_openconfdlg(HWND hwndDlg, UINT message, WPARAM wPa
if (!gg) break;
// Delete non-gg contacts
- hContact = db_find_first();
- while (hContact)
- {
- hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0);
- if (hItem)
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ HANDLE hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0);
+ if (hItem) {
HANDLE hMetaContact = gg_getsubcontact(gg, hContact); // MetaContacts support
- if (hMetaContact)
- {
+ if (hMetaContact) {
szProto = gg->m_szModuleName;
uin = (uin_t)db_get_dw(hMetaContact, gg->m_szModuleName, GG_KEY_UIN, 0);
}
- else
- {
+ else {
szProto = GetContactProto(hContact);
uin = (uin_t)db_get_dw(hContact, gg->m_szModuleName, GG_KEY_UIN, 0);
}
@@ -575,7 +557,6 @@ static INT_PTR CALLBACK gg_gc_openconfdlg(HWND hwndDlg, UINT message, WPARAM wPa
if (szProto == NULL || lstrcmpA(szProto, gg->m_szModuleName) || !uin || uin == db_get_dw(NULL, gg->m_szModuleName, GG_KEY_UIN, 0))
SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_DELETEITEM, (WPARAM)hItem, 0);
}
- hContact = db_find_next(hContact);
}
}
break;
diff --git a/protocols/Gadu-Gadu/src/import.cpp b/protocols/Gadu-Gadu/src/import.cpp
index abaa9799f6..0492ecb32b 100644
--- a/protocols/Gadu-Gadu/src/import.cpp
+++ b/protocols/Gadu-Gadu/src/import.cpp
@@ -101,12 +101,9 @@ char *gg_makecontacts(GGPROTO *gg, int cr)
char *contacts;
// Readup contacts
- HANDLE hContact = db_find_first();
- while (hContact)
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *szProto = GetContactProto(hContact);
- if (szProto != NULL && !strcmp(szProto, gg->m_szModuleName) && !db_get_b(hContact, gg->m_szModuleName, "ChatRoom", 0))
- {
+ if (szProto != NULL && !strcmp(szProto, gg->m_szModuleName) && !db_get_b(hContact, gg->m_szModuleName, "ChatRoom", 0)) {
DBVARIANT dbv;
// Readup FirstName
@@ -139,9 +136,9 @@ char *gg_makecontacts(GGPROTO *gg, int cr)
string_append(s, pszValA);
mir_free(pszValA);
db_free(&dbv2);
- } else {
- string_append(s, dbvA);
}
+ else string_append(s, dbvA);
+
string_append_c(s, ';');
string_append(s, dbvA);
mir_free(dbvA);
@@ -183,7 +180,6 @@ char *gg_makecontacts(GGPROTO *gg, int cr)
else
string_append(s, ";0;;0;\n");
}
- hContact = db_find_next(hContact);
}
contacts = string_free(s, 0);
diff --git a/protocols/IRCG/src/clist.cpp b/protocols/IRCG/src/clist.cpp
index d3f4aed5de..a60353a8e5 100644
--- a/protocols/IRCG/src/clist.cpp
+++ b/protocols/IRCG/src/clist.cpp
@@ -144,9 +144,8 @@ bool CIrcProto::CList_SetAllOffline(BYTE ChatsToo)
DisconnectAllDCCSessions(false);
- HANDLE hContact = db_find_first();
- while ( hContact ) {
- char* szProto = GetContactProto(hContact);
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ char *szProto = GetContactProto(hContact);
if (szProto != NULL && !lstrcmpiA( szProto, m_szModuleName)) {
if ( getByte( hContact, "ChatRoom", 0 ) == 0 ) {
if ( getByte(hContact, "DCC", 0 ) != 0 ) {
@@ -161,9 +160,8 @@ bool CIrcProto::CList_SetAllOffline(BYTE ChatsToo)
db_unset( hContact, m_szModuleName, "IP" );
setString( hContact, "User", "" );
setString( hContact, "Host", "" );
- } }
-
- hContact = db_find_next(hContact);
+ }
+ }
}
return true;
}
@@ -176,15 +174,14 @@ HANDLE CIrcProto::CList_FindContact (CONTACT* user)
TCHAR* lowercasename = mir_tstrdup( user->name );
CharLower(lowercasename);
- char *szProto;
DBVARIANT dbv1;
DBVARIANT dbv2;
DBVARIANT dbv3;
DBVARIANT dbv4;
DBVARIANT dbv5;
- HANDLE hContact = db_find_first();
- while (hContact) {
- szProto = GetContactProto(hContact);
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ char *szProto = GetContactProto(hContact);
if ( szProto != NULL && !lstrcmpiA( szProto, m_szModuleName )) {
if ( getByte( hContact, "ChatRoom", 0) == 0) {
HANDLE hContact_temp = NULL;
@@ -238,9 +235,9 @@ HANDLE CIrcProto::CList_FindContact (CONTACT* user)
if ( hContact_temp != (HANDLE)-1 )
return hContact_temp;
return 0;
- } } }
-
- hContact = db_find_next(hContact);
+ }
+ }
+ }
}
mir_free(lowercasename);
return 0;
diff --git a/protocols/IRCG/src/commandmonitor.cpp b/protocols/IRCG/src/commandmonitor.cpp
index a38c11fe2a..e91473722a 100644
--- a/protocols/IRCG/src/commandmonitor.cpp
+++ b/protocols/IRCG/src/commandmonitor.cpp
@@ -139,12 +139,9 @@ VOID CALLBACK OnlineNotifTimerProc( HWND, UINT, UINT_PTR idEvent, DWORD )
if ( name.IsEmpty() && name2.IsEmpty()) {
DBVARIANT dbv;
- char* szProto;
-
- HANDLE hContact = db_find_first();
- while ( hContact ) {
- szProto = GetContactProto(hContact);
- if ( szProto != NULL && !lstrcmpiA( szProto, ppro->m_szModuleName )) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ char *szProto = GetContactProto(hContact);
+ if (szProto != NULL && !lstrcmpiA( szProto, ppro->m_szModuleName)) {
BYTE bRoom = ppro->getByte(hContact, "ChatRoom", 0);
if ( bRoom == 0 ) {
BYTE bDCC = ppro->getByte(hContact, "DCC", 0);
@@ -177,10 +174,7 @@ VOID CALLBACK OnlineNotifTimerProc( HWND, UINT, UINT_PTR idEvent, DWORD )
if ( DBNick ) db_free(&dbv);
if ( DBWildcard ) db_free(&dbv2);
- } } } } }
-
- hContact = db_find_next(hContact);
- } }
+ } } } } } } }
if ( ppro->m_namesToWho.IsEmpty() && ppro->m_namesToUserhost.IsEmpty()) {
ppro->SetChatTimer( ppro->OnlineNotifTimer, 60*1000, OnlineNotifTimerProc );
diff --git a/protocols/IcqOscarJ/src/icq_uploadui.cpp b/protocols/IcqOscarJ/src/icq_uploadui.cpp
index 20285b193f..0b37e6ad22 100644
--- a/protocols/IcqOscarJ/src/icq_uploadui.cpp
+++ b/protocols/IcqOscarJ/src/icq_uploadui.cpp
@@ -112,19 +112,11 @@ static int UpdateCheckmarks(HWND hwndList, CIcqProto* ppro, HANDLE phItemAll)
static void DeleteOtherContactsFromControl(HWND hCtrl, CIcqProto* ppro)
{
- HANDLE hContact;
- HANDLE hItem;
-
- hContact = db_find_first();
- while (hContact)
- {
- hItem = (HANDLE)SendMessage(hCtrl, CLM_FINDCONTACT, (WPARAM)hContact, 0);
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ HANDLE hItem = (HANDLE)SendMessage(hCtrl, CLM_FINDCONTACT, (WPARAM)hContact, 0);
if (hItem)
- {
if (!ppro->IsICQContact(hContact))
SendMessage(hCtrl, CLM_DELETEITEM, (WPARAM)hItem, 0);
- }
- hContact = db_find_next(hContact);
}
}
diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp
index 36a4dbcf40..6a8adbc714 100644
--- a/protocols/JabberG/src/jabber_chat.cpp
+++ b/protocols/JabberG/src/jabber_chat.cpp
@@ -701,15 +701,13 @@ class CGroupchatInviteDlg : public CJabberDlgBase
void FilterList(CCtrlClc *)
{
- for (HANDLE hContact = db_find_first();
- hContact;
- hContact = db_find_next(hContact))
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *proto = GetContactProto(hContact);
if (lstrcmpA(proto, m_proto->m_szModuleName) || db_get_b(hContact, proto, "ChatRoom", 0))
if (HANDLE hItem = m_clc.FindContact(hContact))
m_clc.DeleteItem(hItem);
- } }
+ }
+ }
void ResetListOptions(CCtrlClc *)
{
@@ -819,10 +817,7 @@ public:
HWND hwndList = GetDlgItem(m_hwnd, IDC_CLIST);
// invite users from roster
- for (HANDLE hContact = db_find_first();
- hContact;
- hContact = db_find_next(hContact))
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *proto = GetContactProto(hContact);
if ( !lstrcmpA(proto, m_proto->m_szModuleName) && !db_get_b(hContact, proto, "ChatRoom", 0))
{
diff --git a/protocols/JabberG/src/jabber_icolib.cpp b/protocols/JabberG/src/jabber_icolib.cpp
index f727d0ee1f..ea7203bd5d 100644
--- a/protocols/JabberG/src/jabber_icolib.cpp
+++ b/protocols/JabberG/src/jabber_icolib.cpp
@@ -462,18 +462,14 @@ BOOL CJabberProto::DBCheckIsTransportedContact(const TCHAR *jid, HANDLE hContact
void CJabberProto::CheckAllContactsAreTransported()
{
- HANDLE hContact = (HANDLE)db_find_first();
- while (hContact != NULL) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *szProto = GetContactProto(hContact);
if ( !lstrcmpA(m_szModuleName, szProto)) {
DBVARIANT dbv;
if ( !JGetStringT(hContact, "jid", &dbv)) {
DBCheckIsTransportedContact(dbv.ptszVal, hContact);
db_free(&dbv);
- } }
-
- hContact = db_find_next(hContact);
-} }
+} } } }
/////////////////////////////////////////////////////////////////////////////////////////
// Cross-instance shared icons
diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp
index 9d3bb562cf..eced1ebbd9 100644
--- a/protocols/JabberG/src/jabber_iqid.cpp
+++ b/protocols/JabberG/src/jabber_iqid.cpp
@@ -535,8 +535,7 @@ void CJabberProto::OnIqResultGetRoster(HXML iqNode, CJabberIqInfo* pInfo)
if (m_options.RosterSync == TRUE) {
int listSize = 0, listAllocSize = 0;
HANDLE* list = NULL;
- HANDLE hContact = (HANDLE)db_find_first();
- while (hContact != NULL) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char* str = GetContactProto(hContact);
if (str != NULL && !strcmp(str, m_szModuleName)) {
DBVARIANT dbv;
@@ -553,9 +552,8 @@ void CJabberProto::OnIqResultGetRoster(HXML iqNode, CJabberIqInfo* pInfo)
list[listSize++] = hContact;
}
db_free(&dbv);
- } }
-
- hContact = db_find_next(hContact);
+ }
+ }
}
for (i=0; i < listSize; i++) {
diff --git a/protocols/JabberG/src/jabber_misc.cpp b/protocols/JabberG/src/jabber_misc.cpp
index 4ed270192e..10d23186a4 100644
--- a/protocols/JabberG/src/jabber_misc.cpp
+++ b/protocols/JabberG/src/jabber_misc.cpp
@@ -154,6 +154,7 @@ void CJabberProto::DBAddAuthRequest(const TCHAR *jid, const TCHAR *nick)
HANDLE CJabberProto::DBCreateContact(const TCHAR *jid, const TCHAR *nick, BOOL temporary, BOOL stripResource)
{
+ HANDLE hContact;
TCHAR* s, *p, *q;
size_t len;
char *szProto;
@@ -173,8 +174,7 @@ HANDLE CJabberProto::DBCreateContact(const TCHAR *jid, const TCHAR *nick, BOOL t
len = _tcslen(s);
// We can't use JabberHContactFromJID() here because of the stripResource option
- HANDLE hContact = (HANDLE)db_find_first();
- while (hContact != NULL) {
+ for (hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
szProto = GetContactProto(hContact);
if (szProto!=NULL && !strcmp(m_szModuleName, szProto)) {
DBVARIANT dbv;
@@ -185,8 +185,8 @@ HANDLE CJabberProto::DBCreateContact(const TCHAR *jid, const TCHAR *nick, BOOL t
break;
}
db_free(&dbv);
- } }
- hContact = db_find_next(hContact);
+ }
+ }
}
if (hContact == NULL) {
diff --git a/protocols/JabberG/src/jabber_opt.cpp b/protocols/JabberG/src/jabber_opt.cpp
index 614baef47f..dbe3ca3d1f 100644
--- a/protocols/JabberG/src/jabber_opt.cpp
+++ b/protocols/JabberG/src/jabber_opt.cpp
@@ -1055,47 +1055,41 @@ void CJabberProto::_RosterHandleGetRequest(HXML node)
group = xmlGetText(groupNode);
_RosterInsertListItem(hList, jid, name, group, subscription, TRUE);
}
+
// now it is require to process whole contact list to add not in roster contacts
- {
- HANDLE hContact = (HANDLE)db_find_first();
- while (hContact != NULL)
- {
- char* str = GetContactProto(hContact);
- if (str != NULL && !strcmp(str, m_szModuleName))
- {
- DBVARIANT dbv;
- if ( !JGetStringT(hContact, "jid", &dbv))
- {
- LVFINDINFO lvfi={0};
- lvfi.flags = LVFI_STRING;
- lvfi.psz = dbv.ptszVal;
- TCHAR *p = _tcschr(dbv.ptszVal,_T('@'));
- if (p) {
- p = _tcschr(dbv.ptszVal, _T('/'));
- if (p) *p = _T('\0');
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ char* str = GetContactProto(hContact);
+ if (str != NULL && !strcmp(str, m_szModuleName)) {
+ DBVARIANT dbv;
+ if ( !JGetStringT(hContact, "jid", &dbv)) {
+ LVFINDINFO lvfi={0};
+ lvfi.flags = LVFI_STRING;
+ lvfi.psz = dbv.ptszVal;
+ TCHAR *p = _tcschr(dbv.ptszVal,_T('@'));
+ if (p) {
+ p = _tcschr(dbv.ptszVal, _T('/'));
+ if (p) *p = _T('\0');
+ }
+ if (ListView_FindItem(hList, -1, &lvfi) == -1) {
+ TCHAR *jid = mir_tstrdup(dbv.ptszVal);
+ TCHAR *name = NULL;
+ TCHAR *group = NULL;
+ DBVARIANT dbvtemp;
+ if ( !db_get_ts(hContact, "CList", "MyHandle", &dbvtemp)) {
+ name = mir_tstrdup(dbvtemp.ptszVal);
+ db_free(&dbvtemp);
}
- if (ListView_FindItem(hList, -1, &lvfi) == -1) {
- TCHAR *jid = mir_tstrdup(dbv.ptszVal);
- TCHAR *name = NULL;
- TCHAR *group = NULL;
- DBVARIANT dbvtemp;
- if ( !db_get_ts(hContact, "CList", "MyHandle", &dbvtemp)) {
- name = mir_tstrdup(dbvtemp.ptszVal);
- db_free(&dbvtemp);
- }
- if ( !db_get_ts(hContact, "CList", "Group", &dbvtemp)) {
- group = mir_tstrdup(dbvtemp.ptszVal);
- db_free(&dbvtemp);
- }
- _RosterInsertListItem(hList, jid, name, group, NULL, FALSE);
- if (jid) mir_free(jid);
- if (name) mir_free(name);
- if (group) mir_free(group);
+ if ( !db_get_ts(hContact, "CList", "Group", &dbvtemp)) {
+ group = mir_tstrdup(dbvtemp.ptszVal);
+ db_free(&dbvtemp);
}
- db_free(&dbv);
+ _RosterInsertListItem(hList, jid, name, group, NULL, FALSE);
+ if (jid) mir_free(jid);
+ if (name) mir_free(name);
+ if (group) mir_free(group);
}
+ db_free(&dbv);
}
- hContact = db_find_next(hContact);
}
}
rrud.bReadyToDownload = FALSE;
diff --git a/protocols/JabberG/src/jabber_privacy.cpp b/protocols/JabberG/src/jabber_privacy.cpp
index e0c5f041f2..39da2ae3f1 100644
--- a/protocols/JabberG/src/jabber_privacy.cpp
+++ b/protocols/JabberG/src/jabber_privacy.cpp
@@ -424,8 +424,7 @@ public:
return;
LRESULT nItemData = SendDlgItemMessage(m_hwnd, IDC_COMBO_TYPE, CB_GETITEMDATA, nCurSel, 0);
- switch (nItemData)
- {
+ switch (nItemData) {
case Jid:
{
ShowWindow(GetDlgItem(m_hwnd, IDC_COMBO_VALUES), SW_SHOW);
@@ -433,20 +432,15 @@ public:
SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_RESETCONTENT, 0, 0);
- HANDLE hContact = (HANDLE)db_find_first();
- while (hContact != NULL)
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *szProto = GetContactProto(hContact);
- if (szProto != NULL && !strcmp(szProto, m_proto->m_szModuleName))
- {
+ if (szProto != NULL && !strcmp(szProto, m_proto->m_szModuleName)) {
DBVARIANT dbv;
- if ( !m_proto->JGetStringT(hContact, "jid", &dbv))
- {
+ if ( !m_proto->JGetStringT(hContact, "jid", &dbv)) {
SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_ADDSTRING, 0, (LPARAM)dbv.ptszVal);
db_free(&dbv);
}
}
- hContact = db_find_next(hContact);
}
// append known chatroom jids from bookmarks
@@ -1365,10 +1359,7 @@ void CJabberDlgPrivacyLists::CListResetOptions(HWND)
void CJabberDlgPrivacyLists::CListFilter(HWND)
{
- for (HANDLE hContact = db_find_first();
- hContact;
- hContact = db_find_next(hContact))
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *proto = GetContactProto(hContact);
if ( !proto || lstrcmpA(proto, m_proto->m_szModuleName))
if (HANDLE hItem = m_clcClist.FindContact(hContact))
@@ -1468,12 +1459,10 @@ void CJabberDlgPrivacyLists::CListApplyList(HWND hwndList, CPrivacyList *pList)
CListResetIcons(hwndList, hItem, bHideIcons);
}
- for (HANDLE hContact=db_find_first(); hContact;
- hContact=db_find_next(hContact))
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
HANDLE hItem = m_clcClist.FindContact(hContact);
- if ( !hItem) continue;
- CListResetIcons(hwndList, hItem, bHideIcons);
+ if (hItem)
+ CListResetIcons(hwndList, hItem, bHideIcons);
}
for (int iJid = 0; iJid < clc_info.newJids.getCount(); ++iJid)
@@ -1569,8 +1558,7 @@ void CJabberDlgPrivacyLists::CListBuildList(HWND hwndList, CPrivacyList *pList)
pList->RemoveAllRules();
- for (int iJid = 0; iJid < clc_info.newJids.getCount(); ++iJid)
- {
+ for (int iJid = 0; iJid < clc_info.newJids.getCount(); ++iJid) {
hItem = clc_info.newJids[iJid]->hItem;
szJid = clc_info.newJids[iJid]->jid;
@@ -1580,16 +1568,13 @@ void CJabberDlgPrivacyLists::CListBuildList(HWND hwndList, CPrivacyList *pList)
pList->AddRule(Jid, szJid, FALSE, dwOrder++, dwPackets);
}
- for (HANDLE hContact=db_find_first(); hContact;
- hContact=db_find_next(hContact))
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
hItem = m_clcClist.FindContact(hContact);
DBVARIANT dbv = {0};
- if (m_proto->JGetStringT(hContact, "jid", &dbv)) {
+ if (m_proto->JGetStringT(hContact, "jid", &dbv))
if (m_proto->JGetStringT(hContact, "ChatRoomID", &dbv))
continue;
- }
szJid = dbv.ptszVal;
@@ -1602,8 +1587,7 @@ void CJabberDlgPrivacyLists::CListBuildList(HWND hwndList, CPrivacyList *pList)
}
// group handles start with 1 (0 is "root")
- for (int iGroup = 1; ; ++iGroup)
- {
+ for (int iGroup = 1; ; ++iGroup) {
char idstr[33];
_itoa(iGroup-1, idstr, 10);
DBVARIANT dbv = {0};
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp
index fc296d7c18..25e9da3411 100644
--- a/protocols/JabberG/src/jabber_proto.cpp
+++ b/protocols/JabberG/src/jabber_proto.cpp
@@ -307,13 +307,9 @@ int CJabberProto::OnModulesLoadedEx(WPARAM, LPARAM)
JHookEvent(ME_MSG_ICONPRESSED, &CJabberProto::OnProcessSrmmIconClick);
JHookEvent(ME_MSG_WINDOWEVENT, &CJabberProto::OnProcessSrmmEvent);
- HANDLE hContact = (HANDLE)db_find_first();
- while (hContact != NULL) {
- char *szProto = GetContactProto(hContact);
- if (szProto != NULL && !strcmp(szProto, m_szModuleName))
- MenuHideSrmmIcon(hContact);
- hContact = db_find_next(hContact);
- } }
+ for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName))
+ MenuHideSrmmIcon(hContact);
+ }
DBEVENTTYPEDESCR dbEventType = {0};
dbEventType.cbSize = sizeof(DBEVENTTYPEDESCR);
@@ -332,8 +328,7 @@ int CJabberProto::OnModulesLoadedEx(WPARAM, LPARAM)
CheckAllContactsAreTransported();
// Set all contacts to offline
- HANDLE hContact = db_find_first();
- while (hContact != NULL) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *szProto = GetContactProto(hContact);
if (szProto != NULL && !strcmp(szProto, m_szModuleName)) {
SetContactOfflineStatus(hContact);
@@ -347,10 +342,7 @@ int CJabberProto::OnModulesLoadedEx(WPARAM, LPARAM)
*resourcepos = '\0';
m_lstTransports.insert(mir_tstrdup(domain));
db_free(&dbv);
- } } }
-
- hContact = db_find_next(hContact);
- }
+ } } } }
CleanLastResourceMap();
return 0;
diff --git a/protocols/JabberG/src/jabber_rc.cpp b/protocols/JabberG/src/jabber_rc.cpp
index 23800fc307..0081409290 100644
--- a/protocols/JabberG/src/jabber_rc.cpp
+++ b/protocols/JabberG/src/jabber_rc.cpp
@@ -477,8 +477,7 @@ int CJabberProto::AdhocOptionsHandler(HXML, CJabberIqInfo* pInfo, CJabberAdhocSe
int CJabberProto::RcGetUnreadEventsCount()
{
int nEventsSent = 0;
- HANDLE hContact = (HANDLE)db_find_first();
- while (hContact != NULL) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *szProto = GetContactProto(hContact);
if (szProto != NULL && !strcmp(szProto, m_szModuleName)) {
DBVARIANT dbv;
@@ -504,7 +503,6 @@ int CJabberProto::RcGetUnreadEventsCount()
db_free(&dbv);
}
}
- hContact = db_find_next(hContact);
}
return nEventsSent;
}
@@ -573,8 +571,7 @@ int CJabberProto::AdhocForwardHandler(HXML, CJabberIqInfo* pInfo, CJabberAdhocSe
m_options.RcMarkMessagesAsRead = bRemoveCListEvents ? 1 : 0;
int nEventsSent = 0;
- HANDLE hContact = (HANDLE)db_find_first();
- while (hContact != NULL) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *szProto = GetContactProto(hContact);
if (szProto != NULL && !strcmp(szProto, m_szModuleName)) {
DBVARIANT dbv;
@@ -631,7 +628,6 @@ int CJabberProto::AdhocForwardHandler(HXML, CJabberIqInfo* pInfo, CJabberAdhocSe
db_free(&dbv);
}
}
- hContact = db_find_next(hContact);
}
mir_sntprintf(szMsg, SIZEOF(szMsg), TranslateT("%d message(s) forwarded"), nEventsSent);
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp
index 3660fbce04..85cc395218 100644
--- a/protocols/JabberG/src/jabber_thread.cpp
+++ b/protocols/JabberG/src/jabber_thread.cpp
@@ -595,15 +595,11 @@ recvRest:
JSendBroadcast(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus);
// Set all contacts to offline
- HANDLE hContact = (HANDLE)db_find_first();
- while (hContact != NULL) {
- if ( !lstrcmpA(GetContactProto(hContact), m_szModuleName))
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ if ( !lstrcmpA(GetContactProto(hContact), m_szModuleName)) {
SetContactOfflineStatus(hContact);
MenuHideSrmmIcon(hContact);
}
-
- hContact = db_find_next(hContact);
}
mir_free(m_szJabberJID);
diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp
index 2a365c562e..2f5a02f792 100644
--- a/protocols/JabberG/src/jabber_util.cpp
+++ b/protocols/JabberG/src/jabber_util.cpp
@@ -75,8 +75,7 @@ HANDLE CJabberProto::ChatRoomHContactFromJID(const TCHAR *jid)
return (HANDLE)NULL;
HANDLE hContactMatched = NULL;
- HANDLE hContact = (HANDLE)db_find_first();
- while (hContact != NULL) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *szProto = GetContactProto(hContact);
if (szProto != NULL && !strcmp(m_szModuleName, szProto)) {
DBVARIANT dbv;
@@ -91,10 +90,7 @@ HANDLE CJabberProto::ChatRoomHContactFromJID(const TCHAR *jid)
if ( !result && JGetByte(hContact, "ChatRoom", 0) != 0) {
hContactMatched = hContact;
break;
- } } }
-
- hContact = db_find_next(hContact);
- }
+ } } } }
return hContactMatched;
}
@@ -110,8 +106,8 @@ HANDLE CJabberProto::HContactFromJID(const TCHAR *jid , BOOL bStripResource)
JABBER_LIST_ITEM* item = ListGetItemPtr(LIST_CHATROOM, jid);
HANDLE hContactMatched = NULL;
- HANDLE hContact = (HANDLE)db_find_first();
- while (hContact != NULL) {
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *szProto = GetContactProto(hContact);
if (szProto != NULL && !strcmp(m_szModuleName, szProto)) {
DBVARIANT dbv;
@@ -144,10 +140,7 @@ HANDLE CJabberProto::HContactFromJID(const TCHAR *jid , BOOL bStripResource)
if ( !result) {
hContactMatched = hContact;
break;
- } } }
-
- hContact = db_find_next(hContact);
- }
+ } } } }
return hContactMatched;
}
diff --git a/protocols/MRA/src/Mra_functions.cpp b/protocols/MRA/src/Mra_functions.cpp
index 9cdc9a4758..04fcac2504 100644
--- a/protocols/MRA/src/Mra_functions.cpp
+++ b/protocols/MRA/src/Mra_functions.cpp
@@ -571,8 +571,7 @@ HANDLE CMraProto::MraHContactFromEmail(LPSTR lpszEMail, size_t dwEMailSize, BOOL
if (dwEMailSize == -1) dwEMailSize = lstrlenA(lpszEMail);
//check not already on list
- for (hContact = db_find_first();hContact != NULL;hContact = db_find_next(hContact))
- {
+ for (hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if (IsContactMra(hContact))
if (mraGetStaticStringA(hContact, "e-mail", szEMailLocal, SIZEOF(szEMailLocal), &dwEMailLocalSize))
if (CompareStringA( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, szEMailLocal, dwEMailLocalSize, lpszEMail, dwEMailSize) == CSTR_EQUAL)
@@ -598,15 +597,12 @@ HANDLE CMraProto::MraHContactFromEmail(LPSTR lpszEMail, size_t dwEMailSize, BOOL
gcw.dwFlags = GC_UNICODE;
MultiByteToWideChar(MRA_CODE_PAGE, 0, lpszEMail, dwEMailSize, wszEMail, SIZEOF(wszEMail));
- if (CallServiceSync(MS_GC_NEWSESSION, NULL, (LPARAM)&gcw) == 0)
- {
+ if (CallServiceSync(MS_GC_NEWSESSION, NULL, (LPARAM)&gcw) == 0) {
BOOL bChatAdded = FALSE;
- for (hContact = db_find_first();hContact != NULL;hContact = db_find_next(hContact))
- {
+ for (hContact = db_find_first();hContact != NULL;hContact = db_find_next(hContact)) {
if (IsContactMra(hContact))
if (mraGetStaticStringA(hContact, "ChatRoomID", szEMailLocal, SIZEOF(szEMailLocal), &dwEMailLocalSize))
- if (CompareStringA( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, szEMailLocal, dwEMailLocalSize, lpszEMail, dwEMailSize) == CSTR_EQUAL)
- {
+ if (CompareStringA( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, szEMailLocal, dwEMailLocalSize, lpszEMail, dwEMailSize) == CSTR_EQUAL) {
bChatAdded = TRUE;
break;
}
diff --git a/protocols/MRA/src/Mra_proto.cpp b/protocols/MRA/src/Mra_proto.cpp
index e927d2dd0f..82dbb828d4 100644
--- a/protocols/MRA/src/Mra_proto.cpp
+++ b/protocols/MRA/src/Mra_proto.cpp
@@ -1516,7 +1516,7 @@ DWORD CMraProto::MraCommandDispatcher(mrim_packet_header_t *pmaHeader, DWORD *pd
dwAuthMessageSize = lstrlenW(wszAuthMessage);
}
- for (hContact = db_find_first();hContact != NULL;hContact = db_find_next(hContact)) {
+ for (hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if (GetContactBasicInfoW(hContact, &dwID, NULL, NULL, NULL, NULL, szEMail, SIZEOF(szEMail), &dwEMailSize, NULL, 0, NULL, NULL, 0, NULL) == NO_ERROR)
if (dwID == -1) {
if (IsEMailChatAgent(szEMail, dwEMailSize)) {// чат: ещё раз запросим авторизацию, пометим как видимый в списке, постоянный
diff --git a/protocols/MRA/src/Mra_svcs.cpp b/protocols/MRA/src/Mra_svcs.cpp
index 600331cff5..5e42aa4222 100644
--- a/protocols/MRA/src/Mra_svcs.cpp
+++ b/protocols/MRA/src/Mra_svcs.cpp
@@ -220,9 +220,7 @@ INT_PTR CMraProto::MraWebSearch(WPARAM wParam, LPARAM lParam)
INT_PTR CMraProto::MraUpdateAllUsersInfo(WPARAM wParam, LPARAM lParam)
{
if ( MessageBox(NULL, TranslateT("Are you sure?"), TranslateW(MRA_UPD_ALL_USERS_INFO_STR), MB_YESNO | MB_ICONQUESTION) == IDYES ) {
- for (HANDLE hContact = db_find_first();
- hContact != NULL;
- hContact = db_find_next(hContact)) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
size_t dwEMailSize;
CHAR szEMail[MAX_EMAIL_LEN];
if ( IsContactMra(hContact))
@@ -236,9 +234,7 @@ INT_PTR CMraProto::MraUpdateAllUsersInfo(WPARAM wParam, LPARAM lParam)
INT_PTR CMraProto::MraCheckUpdatesUsersAvt(WPARAM wParam, LPARAM lParam)
{
if ( MessageBox(NULL, TranslateT("Are you sure?"), TranslateW(MRA_CHK_USERS_AVATARS_STR), MB_YESNO | MB_ICONQUESTION) == IDYES) {
- for (HANDLE hContact = db_find_first();
- hContact != NULL;
- hContact = db_find_next(hContact)) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
size_t dwEMailSize;
CHAR szEMail[MAX_EMAIL_LEN];
@@ -254,9 +250,7 @@ INT_PTR CMraProto::MraCheckUpdatesUsersAvt(WPARAM wParam, LPARAM lParam)
INT_PTR CMraProto::MraRequestAuthForAll(WPARAM wParam, LPARAM lParam)
{
if ( MessageBox(NULL, TranslateT("Are you sure?"), TranslateW(MRA_REQ_AUTH_FOR_ALL_STR), MB_YESNO | MB_ICONQUESTION) == IDYES) {
- for (HANDLE hContact = db_find_first();
- hContact != NULL;
- hContact = db_find_next(hContact)) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
DWORD dwContactSeverFlags;
if (GetContactBasicInfoW(hContact, NULL, NULL, NULL, &dwContactSeverFlags, NULL, NULL, 0, NULL, NULL, 0, NULL, NULL, 0, NULL) == NO_ERROR)
if (dwContactSeverFlags&CONTACT_INTFLAG_NOT_AUTHORIZED && dwContactSeverFlags != -1)
diff --git a/protocols/MSN/src/msn_lists.cpp b/protocols/MSN/src/msn_lists.cpp
index bf23f84ce2..74961195f7 100644
--- a/protocols/MSN/src/msn_lists.cpp
+++ b/protocols/MSN/src/msn_lists.cpp
@@ -256,8 +256,7 @@ void CMsnProto::Lists_Populate(void)
else
Lists_Add(0, NETID_UNKNOWN, szEmail, hContact);
}
- else
- CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
+ else CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
}
hContact = hContactN;
}
diff --git a/protocols/MSN/src/msn_proto.cpp b/protocols/MSN/src/msn_proto.cpp
index bdf55a975f..a9da564cf3 100644
--- a/protocols/MSN/src/msn_proto.cpp
+++ b/protocols/MSN/src/msn_proto.cpp
@@ -92,17 +92,13 @@ CMsnProto::CMsnProto(const char* aProtoName, const TCHAR* aUserName) :
LoadOptions();
- HANDLE hContact = db_find_first();
- while (hContact != NULL)
- {
- if (MSN_IsMyContact(hContact))
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ if (MSN_IsMyContact(hContact)) {
deleteSetting(hContact, "Status");
deleteSetting(hContact, "IdleTS");
deleteSetting(hContact, "p2pMsgId");
deleteSetting(hContact, "AccList");
}
- hContact = db_find_next(hContact);
}
deleteSetting(NULL, "MobileEnabled");
deleteSetting(NULL, "MobileAllowed");
@@ -112,8 +108,7 @@ CMsnProto::CMsnProto(const char* aProtoName, const TCHAR* aUserName) :
strcmp(path, MSN_DEFAULT_GATEWAY) == 0))
deleteSetting(NULL, "LoginServer");
- if (MyOptions.SlowSend)
- {
+ if (MyOptions.SlowSend) {
if (db_get_dw(NULL, "SRMsg", "MessageTimeout", 10000) < 60000)
db_set_dw(NULL, "SRMsg", "MessageTimeout", 60000);
if (db_get_dw(NULL, "SRMM", "MessageTimeout", 10000) < 60000)
diff --git a/protocols/Tlen/src/jabber_iqid.cpp b/protocols/Tlen/src/jabber_iqid.cpp
index a94630b628..b77a367170 100644
--- a/protocols/Tlen/src/jabber_iqid.cpp
+++ b/protocols/Tlen/src/jabber_iqid.cpp
@@ -145,7 +145,6 @@ void JabberIqResultRoster(TlenProtocol *proto, XmlNode *iqNode)
XmlNode *itemNode, *groupNode;
JABBER_SUBSCRIPTION sub;
JABBER_LIST_ITEM *item;
- HANDLE hContact;
char *jid, *name, *nick;
int i, oldStatus;
@@ -166,6 +165,7 @@ void JabberIqResultRoster(TlenProtocol *proto, XmlNode *iqNode)
nick = JabberLocalNickFromJID(jid);
}
if (nick != NULL) {
+ HANDLE hContact;
item = JabberListAdd(proto, LIST_ROSTER, jid);
if (item->nick) mir_free(item->nick);
item->nick = nick;
@@ -211,8 +211,8 @@ void JabberIqResultRoster(TlenProtocol *proto, XmlNode *iqNode)
listSize = listAllocSize = 0;
list = NULL;
- hContact = db_find_first();
- while (hContact != NULL) {
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
str = GetContactProto(hContact);
if (str != NULL && !strcmp(str, proto->m_szModuleName)) {
if (!db_get(hContact, proto->m_szModuleName, "jid", &dbv)) {
@@ -230,8 +230,8 @@ void JabberIqResultRoster(TlenProtocol *proto, XmlNode *iqNode)
db_free(&dbv);
}
}
- hContact = db_find_next(hContact);
}
+
for (i=0; i<listSize; i++) {
JabberLog(proto, "Syncing roster: deleting 0x%x", list[i]);
CallService(MS_DB_CONTACT_DELETE, (WPARAM) list[i], 0);
diff --git a/protocols/Tlen/src/jabber_misc.cpp b/protocols/Tlen/src/jabber_misc.cpp
index 30ec49b67d..c20cc63c06 100644
--- a/protocols/Tlen/src/jabber_misc.cpp
+++ b/protocols/Tlen/src/jabber_misc.cpp
@@ -85,32 +85,27 @@ char *JabberJIDFromHContact(TlenProtocol *proto, HANDLE hContact)
HANDLE JabberHContactFromJID(TlenProtocol *proto, const char *jid)
{
- HANDLE hContact, hContactMatched;
DBVARIANT dbv;
char *szProto;
char *p;
- if (jid == NULL) return (HANDLE) NULL;
- hContactMatched = NULL;
- hContact = db_find_first();
- while (hContact != NULL) {
+ if (jid == NULL)
+ return NULL;
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
szProto = GetContactProto(hContact);
if (szProto != NULL && !strcmp(proto->m_szModuleName, szProto)) {
if (!db_get(hContact, proto->m_szModuleName, "jid", &dbv)) {
if ((p=dbv.pszVal) != NULL) {
if (!stricmp(p, jid)) { // exact match (node@domain/resource)
- hContactMatched = hContact;
db_free(&dbv);
- break;
+ return hContact;
}
}
db_free(&dbv);
}
}
- hContact = db_find_next(hContact);
- }
- if (hContactMatched != NULL) {
- return hContactMatched;
}
+
return NULL;
}
diff --git a/protocols/Tlen/src/jabber_thread.cpp b/protocols/Tlen/src/jabber_thread.cpp
index ce4a95f539..896bf29016 100644
--- a/protocols/Tlen/src/jabber_thread.cpp
+++ b/protocols/Tlen/src/jabber_thread.cpp
@@ -107,7 +107,6 @@ void __cdecl JabberServerThread(ThreadData *info)
char *buffer;
int datalen;
XmlState xmlState;
- HANDLE hContact;
int jabberNetworkBufferSize;
int oldStatus = ID_STATUS_OFFLINE;
int reconnectMaxTime;
@@ -363,15 +362,13 @@ void __cdecl JabberServerThread(ThreadData *info)
ProtoBroadcastAck(info->proto->m_szModuleName, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE) oldStatus, info->proto->m_iStatus);
// Set all contacts to offline
- hContact = db_find_first();
- while (hContact != NULL) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
str = GetContactProto(hContact);
if (str != NULL && !strcmp(str, info->proto->m_szModuleName)) {
if (db_get_w(hContact, info->proto->m_szModuleName, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) {
db_set_w(hContact, info->proto->m_szModuleName, "Status", ID_STATUS_OFFLINE);
}
}
- hContact = db_find_next(hContact);
}
JabberListWipeSpecial(info->proto);
diff --git a/protocols/Tlen/src/tlen.cpp b/protocols/Tlen/src/tlen.cpp
index 34e03d3071..8c76e78b42 100644
--- a/protocols/Tlen/src/tlen.cpp
+++ b/protocols/Tlen/src/tlen.cpp
@@ -252,20 +252,19 @@ INT_PTR TlenMenuHandleInbox(void *ptr, LPARAM wParam, LPARAM lParam)
int TlenOnModulesLoaded(void *ptr, WPARAM wParam, LPARAM lParam)
{
-
char str[128];
TlenProtocol *proto = (TlenProtocol *)ptr;
/* Set all contacts to offline */
- HANDLE hContact = db_find_first();
- while (hContact != NULL) {
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *szProto = GetContactProto(hContact);
if (szProto != NULL && !strcmp(szProto, proto->m_szModuleName)) {
if (db_get_w(hContact, proto->m_szModuleName, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) {
db_set_w(hContact, proto->m_szModuleName, "Status", ID_STATUS_OFFLINE);
}
}
- hContact = db_find_next(hContact);
}
+
TlenMUCInit(proto);
sprintf(str, "%s", LPGEN("Incoming mail"));
SkinAddNewSoundEx("TlenMailNotify", proto->m_szModuleName, str);
diff --git a/protocols/Tlen/src/tlen_muc.cpp b/protocols/Tlen/src/tlen_muc.cpp
index c43ee11edd..bf18a4a5ce 100644
--- a/protocols/Tlen/src/tlen_muc.cpp
+++ b/protocols/Tlen/src/tlen_muc.cpp
@@ -948,7 +948,6 @@ typedef struct {
static void __cdecl TlenMUCCSendQueryResultThread(void *ptr)
{
- HANDLE hContact;
MUCCQUERYRESULT queryResult;
DBVARIANT dbv;
MUCSENDQUERYTHREADDATA* threadData = (MUCSENDQUERYTHREADDATA*)ptr;
@@ -957,8 +956,8 @@ static void __cdecl TlenMUCCSendQueryResultThread(void *ptr)
queryResult.pszModule = threadData->proto->m_szModuleName;
queryResult.pszParent = threadData->roomId;
queryResult.iItemsNum = 0;
- hContact = db_find_first();
- while (hContact != NULL) {
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *str = GetContactProto(hContact);
if (str != NULL && !strcmp(str, threadData->proto->m_szModuleName)) {
if (!db_get_b(hContact, threadData->proto->m_szModuleName, "bChat", FALSE)) {
@@ -970,13 +969,12 @@ static void __cdecl TlenMUCCSendQueryResultThread(void *ptr)
}
}
}
- hContact = db_find_next(hContact);
}
queryResult.pItems = (MUCCQUERYITEM*)mir_alloc(sizeof(MUCCQUERYITEM) * queryResult.iItemsNum);
memset(queryResult.pItems, 0, sizeof(MUCCQUERYITEM) * queryResult.iItemsNum);
queryResult.iItemsNum = 0;
- hContact = db_find_first();
- while (hContact != NULL) {
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *baseProto = GetContactProto(hContact);
if (baseProto != NULL && !strcmp(baseProto, threadData->proto->m_szModuleName)) {
if (!db_get_b(hContact, threadData->proto->m_szModuleName, "bChat", FALSE)) {
@@ -990,7 +988,6 @@ static void __cdecl TlenMUCCSendQueryResultThread(void *ptr)
}
}
}
- hContact = db_find_next(hContact);
}
CallService(MS_MUCC_QUERY_RESULT, 0, (LPARAM) &queryResult);
TlenMUCFreeQueryResult(&queryResult);
diff --git a/protocols/Twitter/src/chat.cpp b/protocols/Twitter/src/chat.cpp
index 577dfd3be6..8bb15b85e9 100644
--- a/protocols/Twitter/src/chat.cpp
+++ b/protocols/Twitter/src/chat.cpp
@@ -197,8 +197,7 @@ void TwitterProto::SetChatStatus(int status)
if(status == ID_STATUS_ONLINE)
{
// Add all friends to contact list
- for(HANDLE hContact = db_find_first();hContact;hContact = db_find_next(hContact))
- {
+ for(HANDLE hContact = db_find_first();hContact;hContact = db_find_next(hContact)) {
if(!IsMyContact(hContact))
continue;
diff --git a/protocols/Xfire/src/main.cpp b/protocols/Xfire/src/main.cpp
index 320b2cd4c3..d0024ef48f 100644
--- a/protocols/Xfire/src/main.cpp
+++ b/protocols/Xfire/src/main.cpp
@@ -1802,14 +1802,12 @@ BOOL IsXFireContact(HANDLE hContact)
HANDLE CList_FindContact (int uid)
{
- HANDLE hContact = db_find_first();
- while (hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *szProto = GetContactProto(hContact);
if ( szProto != NULL && !lstrcmpiA( szProto, protocolname )) {
if ( db_get_dw(hContact, protocolname, "UserId",-1)==uid)
return hContact;
}
- hContact = db_find_next(hContact);
}
return 0;
}
@@ -1817,8 +1815,7 @@ HANDLE CList_FindContact (int uid)
void CList_MakeAllOffline()
{
vector<HANDLE> fhandles;
- HANDLE hContact = db_find_first();
- while (hContact) {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *szProto = GetContactProto(hContact);
if ( szProto != NULL && !lstrcmpiA( szProto, protocolname )) {
//freunde von freunden in eine seperate liste setzen
@@ -1878,7 +1875,6 @@ void CList_MakeAllOffline()
}
db_set_w(hContact,protocolname,"Status",ID_STATUS_OFFLINE);
}
- hContact = db_find_next(hContact);
}
//alle gefundenen handles lsцchen
diff --git a/protocols/Yahoo/src/services.cpp b/protocols/Yahoo/src/services.cpp
index c375f29330..b7db4b3c8d 100644
--- a/protocols/Yahoo/src/services.cpp
+++ b/protocols/Yahoo/src/services.cpp
@@ -31,9 +31,7 @@
void CYahooProto::logoff_buddies()
{
//set all contacts to 'offline'
- HANDLE hContact = db_find_first();
- while ( hContact != NULL)
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if (IsMyContact(hContact)) {
SetWord( hContact, "Status", ID_STATUS_OFFLINE );
SetDword(hContact, "IdleTS", 0);
@@ -44,8 +42,6 @@ void CYahooProto::logoff_buddies()
db_unset(hContact, m_szModuleName, "YGMsg");
//db_unset(hContact, m_szModuleName, "MirVer");
}
-
- hContact = db_find_next(hContact);
}
}
diff --git a/protocols/Yahoo/src/yahoo.cpp b/protocols/Yahoo/src/yahoo.cpp
index f7cce7d094..0f16a241e3 100644
--- a/protocols/Yahoo/src/yahoo.cpp
+++ b/protocols/Yahoo/src/yahoo.cpp
@@ -284,24 +284,16 @@ void CYahooProto::AddBuddy(HANDLE hContact, const char *group, const TCHAR *msg)
HANDLE CYahooProto::getbuddyH(const char *yahoo_id)
{
- HANDLE hContact;
-
- for ( hContact = db_find_first();
- hContact != NULL;
- hContact = db_find_next(hContact))
- {
- if (IsMyContact(hContact))
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ if (IsMyContact(hContact)) {
DBVARIANT dbv;
if (GetString(hContact, YAHOO_LOGINID, &dbv))
continue;
- {
- int tCompareResult = lstrcmpiA( dbv.pszVal, yahoo_id );
- db_free( &dbv );
- if ( tCompareResult )
- continue;
- }
+ int tCompareResult = lstrcmpiA( dbv.pszVal, yahoo_id );
+ db_free( &dbv );
+ if ( tCompareResult )
+ continue;
return hContact;
}
@@ -606,17 +598,13 @@ void CYahooProto::ext_got_stealth(char *stealthlist)
char **s;
int found = 0;
char **stealth = NULL;
- HANDLE hContact;
LOG(("[ext_got_stealth] list: %s", stealthlist));
if (stealthlist)
stealth = y_strsplit(stealthlist, ",", -1);
- for ( hContact = db_find_first();
- hContact != NULL;
- hContact = db_find_next(hContact))
- {
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if (IsMyContact(hContact)) {
DBVARIANT dbv;
if (GetString( hContact, YAHOO_LOGINID, &dbv))