summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-04-09 21:40:22 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-04-09 21:40:22 +0000
commit3dc0d9b0b7c30ea2f77d74c4ce5b6ccd67bd525c (patch)
treeefee912ee654baafeb98efcd117921db6b7489bc
parentbcb27264ba737778e5d3edad36088bacf74f0236 (diff)
- the kernel filters out contacts by proto names much faster than a plugin;
- database cycles simplified git-svn-id: http://svn.miranda-ng.org/main/trunk@4404 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--plugins/AVS/src/options.cpp10
-rw-r--r--plugins/Clist_modern/src/modern_viewmodebar.cpp24
-rw-r--r--plugins/Clist_nicer/src/extBackg.cpp97
-rw-r--r--plugins/MetaContacts/src/meta_main.cpp21
-rw-r--r--plugins/NewsAggregator/Src/Options.cpp214
-rw-r--r--plugins/NewsAggregator/Src/Services.cpp21
-rw-r--r--plugins/NewsAggregator/Src/Update.cpp14
-rw-r--r--plugins/NewsAggregator/Src/Utils.cpp38
-rw-r--r--plugins/Non-IM Contact/src/files.cpp47
-rw-r--r--plugins/Non-IM Contact/src/timer.cpp12
-rw-r--r--plugins/QuickContacts/src/quickcontacts.cpp124
-rw-r--r--plugins/Quotes/src/ImportExport.cpp2
-rw-r--r--plugins/Quotes/src/QuotesProviders.cpp2
-rw-r--r--plugins/Scriver/src/chat/clist.cpp26
-rw-r--r--plugins/SeenPlugin/src/utils.cpp12
-rw-r--r--plugins/SimpleStatusMsg/src/main.cpp7
-rwxr-xr-xplugins/StopSpamMod/src/utilities.cpp23
-rw-r--r--plugins/StopSpamPlus/src/services.cpp6
-rw-r--r--plugins/TabSRMM/src/chat/clist.cpp22
-rw-r--r--plugins/TabSRMM/src/typingnotify.cpp6
-rw-r--r--plugins/TipperYM/src/options.cpp92
-rw-r--r--plugins/TipperYM/src/popwin.cpp62
-rw-r--r--plugins/Weather/src/weather_contacts.cpp32
-rw-r--r--plugins/Weather/src/weather_data.cpp83
-rw-r--r--plugins/Weather/src/weather_mwin.cpp22
-rw-r--r--plugins/Weather/src/weather_update.cpp10
-rw-r--r--plugins/YAMN/src/proto/pop3/pop3comm.cpp28
-rw-r--r--protocols/AimOscar/src/services.cpp3
-rw-r--r--protocols/AimOscar/src/theme.cpp18
-rw-r--r--protocols/AimOscar/src/ui.cpp2
-rw-r--r--protocols/AimOscar/src/utility.cpp76
-rw-r--r--protocols/EmLanProto/src/mlan.cpp30
-rw-r--r--protocols/FacebookRM/src/contacts.cpp8
-rw-r--r--protocols/FacebookRM/src/process.cpp4
-rw-r--r--protocols/Gadu-Gadu/src/core.cpp49
-rw-r--r--protocols/Gadu-Gadu/src/import.cpp139
-rw-r--r--protocols/IRCG/src/clist.cpp136
-rw-r--r--protocols/IRCG/src/commandmonitor.cpp74
-rw-r--r--protocols/JabberG/src/jabber_chat.cpp25
-rw-r--r--protocols/JabberG/src/jabber_icolib.cpp16
-rw-r--r--protocols/JabberG/src/jabber_iqid.cpp31
-rw-r--r--protocols/JabberG/src/jabber_misc.cpp26
-rw-r--r--protocols/JabberG/src/jabber_opt.cpp57
-rw-r--r--protocols/JabberG/src/jabber_privacy.cpp22
-rw-r--r--protocols/JabberG/src/jabber_proto.cpp31
-rw-r--r--protocols/JabberG/src/jabber_rc.cpp143
-rw-r--r--protocols/JabberG/src/jabber_thread.cpp8
-rw-r--r--protocols/JabberG/src/jabber_util.cpp96
-rw-r--r--protocols/MRA/src/Mra_functions.cpp9
-rw-r--r--protocols/MRA/src/Mra_svcs.cpp8
-rw-r--r--protocols/MSN/src/msn_lists.cpp32
-rw-r--r--protocols/MSN/src/msn_proto.cpp12
-rw-r--r--protocols/Tlen/src/jabber_iqid.cpp28
-rw-r--r--protocols/Tlen/src/jabber_misc.cpp18
-rw-r--r--protocols/Tlen/src/jabber_thread.cpp26
-rw-r--r--protocols/Tlen/src/tlen.cpp11
-rw-r--r--protocols/Tlen/src/tlen_muc.cpp51
-rw-r--r--protocols/Twitter/src/chat.cpp4
-rw-r--r--protocols/Twitter/src/contacts.cpp14
-rw-r--r--protocols/Twitter/src/proto.cpp7
-rw-r--r--protocols/Xfire/src/main.cpp113
-rw-r--r--protocols/Yahoo/src/services.cpp19
-rw-r--r--protocols/Yahoo/src/yahoo.cpp76
-rw-r--r--src/core/stdchat/src/clist.cpp27
-rw-r--r--src/modules/clist/clistmod.cpp12
-rw-r--r--src/modules/visibility/visibility.cpp62
66 files changed, 1181 insertions, 1399 deletions
diff --git a/plugins/AVS/src/options.cpp b/plugins/AVS/src/options.cpp
index 4cd2748660..f151f8c370 100644
--- a/plugins/AVS/src/options.cpp
+++ b/plugins/AVS/src/options.cpp
@@ -429,13 +429,9 @@ INT_PTR CALLBACK DlgProcOptionsProtos(HWND hwndDlg, UINT msg, WPARAM wParam, LPA
BOOL oldVal = db_get_b(NULL, AVS_MODULE, szProto, 1);
BOOL newVal = ListView_GetCheckState(hwndList, i);
- if (oldVal && !newVal) {
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- char *szContactProto = GetContactProto(hContact);
- if (szContactProto != NULL && !strcmp(szContactProto, szProto))
- DeleteAvatarFromCache(hContact, TRUE);
- }
- }
+ if (oldVal && !newVal)
+ for (HANDLE hContact = db_find_first(szProto); hContact; hContact = db_find_next(hContact, szProto))
+ DeleteAvatarFromCache(hContact, TRUE);
if (newVal)
db_set_b(NULL, AVS_MODULE, szProto, 1);
diff --git a/plugins/Clist_modern/src/modern_viewmodebar.cpp b/plugins/Clist_modern/src/modern_viewmodebar.cpp
index 79f399a174..de73bccc46 100644
--- a/plugins/Clist_modern/src/modern_viewmodebar.cpp
+++ b/plugins/Clist_modern/src/modern_viewmodebar.cpp
@@ -474,19 +474,17 @@ void SaveState()
dwGlobalMask = GetMaskForItem(hInfoItem);
for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
hItem = (HANDLE)SendDlgItemMessage(clvmHwnd, IDC_CLIST, CLM_FINDCONTACT, (WPARAM)hContact, 0);
- if (hItem)
- {
- if (SendDlgItemMessage(clvmHwnd, IDC_CLIST, CLM_GETCHECKMARK, (WPARAM)hItem, 0))
- {
- dwLocalMask = GetMaskForItem(hItem);
- db_set_dw(hContact, CLVM_MODULE, szModeName, MAKELONG(1, (unsigned short)dwLocalMask));
- stickies++;
- }
- else
- {
- if (db_get_dw(hContact, CLVM_MODULE, szModeName, 0))
- db_set_dw(hContact, CLVM_MODULE, szModeName, 0);
- }
+ if (hItem == NULL)
+ continue;
+
+ if (SendDlgItemMessage(clvmHwnd, IDC_CLIST, CLM_GETCHECKMARK, (WPARAM)hItem, 0)) {
+ dwLocalMask = GetMaskForItem(hItem);
+ db_set_dw(hContact, CLVM_MODULE, szModeName, MAKELONG(1, (unsigned short)dwLocalMask));
+ stickies++;
+ }
+ else {
+ if (db_get_dw(hContact, CLVM_MODULE, szModeName, 0))
+ db_set_dw(hContact, CLVM_MODULE, szModeName, 0);
}
}
diff --git a/plugins/Clist_nicer/src/extBackg.cpp b/plugins/Clist_nicer/src/extBackg.cpp
index 7e4f351407..b9a69e5e86 100644
--- a/plugins/Clist_nicer/src/extBackg.cpp
+++ b/plugins/Clist_nicer/src/extBackg.cpp
@@ -1223,7 +1223,7 @@ void IMG_LoadItems()
void LoadPerContactSkins(TCHAR *tszFileName)
{
- char *p, *szProto, *uid, szItem[100];
+ char *p, szItem[100];
char *szSections = reinterpret_cast<char *>(malloc(3002));
StatusItems_t *items = NULL, *this_item;
int i = 1;
@@ -1261,58 +1261,57 @@ void LoadPerContactSkins(TCHAR *tszFileName)
if (items) {
for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- char UIN[40];
- int j;
+ char *szProto = GetContactProto(hContact);
+ if (szProto == NULL)
+ continue;
- szProto = GetContactProto(hContact);
- if (szProto) {
- uid = (char *)CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
- if ((INT_PTR) uid != CALLSERVICE_NOTFOUND && uid != NULL) {
- DBVARIANT dbv = {0};
+ char *uid = (char *)CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
+ if ((INT_PTR) uid != CALLSERVICE_NOTFOUND && uid != NULL) {
+ DBVARIANT dbv = {0};
+ db_get(hContact, szProto, uid, &dbv);
- db_get(hContact, szProto, uid, &dbv);
- switch(dbv.type) {
- case DBVT_DWORD:
- mir_snprintf(UIN, 40, "%d", dbv.dVal);
- break;
- case DBVT_ASCIIZ:
- mir_snprintf(UIN, 40, "%s", dbv.pszVal);
- db_free(&dbv);
- break;
- default:
- UIN[0] = 0;
+ char UIN[40];
+ switch(dbv.type) {
+ case DBVT_DWORD:
+ mir_snprintf(UIN, 40, "%d", dbv.dVal);
+ break;
+ case DBVT_ASCIIZ:
+ mir_snprintf(UIN, 40, "%s", dbv.pszVal);
+ db_free(&dbv);
+ break;
+ default:
+ UIN[0] = 0;
+ break;
+ }
+
+ int j;
+ for (j = 0; j < i - 1; j++) {
+ if ( !strcmp(szProto, items[j].szName) && !strcmp(UIN, items[j].szDBname) &&
+ lstrlenA(szProto) == lstrlenA(items[j].szName) && lstrlenA(UIN) == lstrlenA(items[j].szDBname)) {
+ cfg::writeDword(hContact, "EXTBK", "TEXT", items[j].TEXTCOLOR);
+ cfg::writeDword(hContact, "EXTBK", "COLOR1", items[j].COLOR);
+ cfg::writeDword(hContact, "EXTBK", "COLOR2", items[j].COLOR2);
+ cfg::writeByte(hContact, "EXTBK", "ALPHA", (BYTE)items[j].ALPHA);
+
+ cfg::writeByte(hContact, "EXTBK", "LEFT", (BYTE)items[j].MARGIN_LEFT);
+ cfg::writeByte(hContact, "EXTBK", "RIGHT", (BYTE)items[j].MARGIN_RIGHT);
+ cfg::writeByte(hContact, "EXTBK", "TOP", (BYTE)items[j].MARGIN_TOP);
+ cfg::writeByte(hContact, "EXTBK", "BOTTOM", (BYTE)items[j].MARGIN_BOTTOM);
+
+ cfg::writeByte(hContact, "EXTBK", "TRANS", items[j].COLOR2_TRANSPARENT);
+ cfg::writeDword(hContact, "EXTBK", "BDR", items[j].BORDERSTYLE);
+
+ cfg::writeByte(hContact, "EXTBK", "CORNER", items[j].CORNER);
+ cfg::writeByte(hContact, "EXTBK", "GRAD", items[j].GRADIENT);
+ cfg::writeByte(hContact, "EXTBK", "TRANS", items[j].COLOR2_TRANSPARENT);
+
+ cfg::writeByte(hContact, "EXTBK", "VALID", 1);
break;
}
- for (j = 0; j < i - 1; j++) {
- if ( !strcmp(szProto, items[j].szName) && !strcmp(UIN, items[j].szDBname)
- && lstrlenA(szProto) == lstrlenA(items[j].szName) && lstrlenA(UIN) == lstrlenA(items[j].szDBname)) {
-
- //_DebugPopup(hContact, "Found: %s, %s", szProto, UIN);
- cfg::writeDword(hContact, "EXTBK", "TEXT", items[j].TEXTCOLOR);
- cfg::writeDword(hContact, "EXTBK", "COLOR1", items[j].COLOR);
- cfg::writeDword(hContact, "EXTBK", "COLOR2", items[j].COLOR2);
- cfg::writeByte(hContact, "EXTBK", "ALPHA", (BYTE)items[j].ALPHA);
-
- cfg::writeByte(hContact, "EXTBK", "LEFT", (BYTE)items[j].MARGIN_LEFT);
- cfg::writeByte(hContact, "EXTBK", "RIGHT", (BYTE)items[j].MARGIN_RIGHT);
- cfg::writeByte(hContact, "EXTBK", "TOP", (BYTE)items[j].MARGIN_TOP);
- cfg::writeByte(hContact, "EXTBK", "BOTTOM", (BYTE)items[j].MARGIN_BOTTOM);
-
- cfg::writeByte(hContact, "EXTBK", "TRANS", items[j].COLOR2_TRANSPARENT);
- cfg::writeDword(hContact, "EXTBK", "BDR", items[j].BORDERSTYLE);
-
- cfg::writeByte(hContact, "EXTBK", "CORNER", items[j].CORNER);
- cfg::writeByte(hContact, "EXTBK", "GRAD", items[j].GRADIENT);
- cfg::writeByte(hContact, "EXTBK", "TRANS", items[j].COLOR2_TRANSPARENT);
-
- cfg::writeByte(hContact, "EXTBK", "VALID", 1);
- break;
- }
- }
- if (j == i - 1) { // disable the db copy if it has been disabled in the skin .ini file
- if (cfg::getByte(hContact, "EXTBK", "VALID", 0))
- cfg::writeByte(hContact, "EXTBK", "VALID", 0);
- }
+ }
+ if (j == i - 1) { // disable the db copy if it has been disabled in the skin .ini file
+ if (cfg::getByte(hContact, "EXTBK", "VALID", 0))
+ cfg::writeByte(hContact, "EXTBK", "VALID", 0);
}
}
}
diff --git a/plugins/MetaContacts/src/meta_main.cpp b/plugins/MetaContacts/src/meta_main.cpp
index 3361bdc475..023bca8a82 100644
--- a/plugins/MetaContacts/src/meta_main.cpp
+++ b/plugins/MetaContacts/src/meta_main.cpp
@@ -151,18 +151,15 @@ extern "C" __declspec(dllexport) int Load(void)
CallService(MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)(META_PROTO "/WindowOpen"));
//set all contacts to 'offline', and initialize subcontact counter for db consistency check
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- char *proto = GetContactProto(hContact);
- if (proto && !lstrcmpA( META_PROTO, proto)) {
- db_set_w(hContact, META_PROTO, "Status", ID_STATUS_OFFLINE);
- db_set_dw(hContact, META_PROTO, "IdleTS", 0);
- db_set_b(hContact, META_PROTO, "ContactCountCheck", 0);
-
- // restore any saved defaults that might have remained if miranda was closed or crashed while a convo was happening
- if (db_get_dw(hContact, META_PROTO, "SavedDefault", (DWORD)-1) != (DWORD)-1) {
- db_set_dw(hContact, META_PROTO, "Default", db_get_dw(hContact, META_PROTO, "SavedDefault", 0));
- db_set_dw(hContact, META_PROTO, "SavedDefault", (DWORD)-1);
- }
+ for (HANDLE hContact = db_find_first(META_PROTO); hContact; hContact = db_find_next(hContact, META_PROTO)) {
+ db_set_w(hContact, META_PROTO, "Status", ID_STATUS_OFFLINE);
+ db_set_dw(hContact, META_PROTO, "IdleTS", 0);
+ db_set_b(hContact, META_PROTO, "ContactCountCheck", 0);
+
+ // restore any saved defaults that might have remained if miranda was closed or crashed while a convo was happening
+ if (db_get_dw(hContact, META_PROTO, "SavedDefault", (DWORD)-1) != (DWORD)-1) {
+ db_set_dw(hContact, META_PROTO, "Default", db_get_dw(hContact, META_PROTO, "SavedDefault", 0));
+ db_set_dw(hContact, META_PROTO, "SavedDefault", (DWORD)-1);
}
}
diff --git a/plugins/NewsAggregator/Src/Options.cpp b/plugins/NewsAggregator/Src/Options.cpp
index 44a3a4a5a7..697d5d8bc7 100644
--- a/plugins/NewsAggregator/Src/Options.cpp
+++ b/plugins/NewsAggregator/Src/Options.cpp
@@ -154,49 +154,47 @@ INT_PTR CALLBACK DlgProcChangeFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
SendDlgItemMessage(hwndDlg, IDC_TIMEOUT_VALUE_SPIN, UDM_SETRANGE32, 0, 999);
HANDLE hContact;
- for (hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- if (IsMyContact(hContact)) {
- DBVARIANT dbNick = {0};
- if (db_get_ts(hContact, MODULE, "Nick", &dbNick))
+ for (hContact = db_find_first(MODULE); hContact; hContact = db_find_next(hContact, MODULE)) {
+ DBVARIANT dbNick = {0};
+ if (db_get_ts(hContact, MODULE, "Nick", &dbNick))
+ continue;
+ else if (lstrcmp(dbNick.ptszVal, SelItem.nick) == 0) {
+ db_free(&dbNick);
+ DBVARIANT dbURL = {0};
+ if (db_get_ts(hContact, MODULE, "URL", &dbURL))
continue;
- else if (lstrcmp(dbNick.ptszVal, SelItem.nick) == 0) {
- db_free(&dbNick);
- DBVARIANT dbURL = {0};
- if (db_get_ts(hContact, MODULE, "URL", &dbURL))
- continue;
- else if (lstrcmp(dbURL.ptszVal, SelItem.url) == 0) {
- db_free(&dbURL);
- nSelItem->hContact = hContact;
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG)nSelItem);
- SetDlgItemText(hwndDlg, IDC_FEEDURL, SelItem.url);
- SetDlgItemText(hwndDlg, IDC_FEEDTITLE, SelItem.nick);
- SetDlgItemInt(hwndDlg, IDC_CHECKTIME, db_get_dw(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME), TRUE);
- DBVARIANT dbMsg = {0};
- if (!db_get_ts(hContact, MODULE, "MsgFormat", &dbMsg)) {
- SetDlgItemText(hwndDlg, IDC_TAGSEDIT, dbMsg.ptszVal);
- db_free(&dbMsg);
+ else if (lstrcmp(dbURL.ptszVal, SelItem.url) == 0) {
+ db_free(&dbURL);
+ nSelItem->hContact = hContact;
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG)nSelItem);
+ SetDlgItemText(hwndDlg, IDC_FEEDURL, SelItem.url);
+ SetDlgItemText(hwndDlg, IDC_FEEDTITLE, SelItem.nick);
+ SetDlgItemInt(hwndDlg, IDC_CHECKTIME, db_get_dw(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME), TRUE);
+ DBVARIANT dbMsg = {0};
+ if (!db_get_ts(hContact, MODULE, "MsgFormat", &dbMsg)) {
+ SetDlgItemText(hwndDlg, IDC_TAGSEDIT, dbMsg.ptszVal);
+ db_free(&dbMsg);
+ }
+ if (db_get_b(hContact, MODULE, "UseAuth", 0)) {
+ CheckDlgButton(hwndDlg, IDC_USEAUTH, BST_CHECKED);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_LOGIN), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), TRUE);
+ DBVARIANT dbLogin = {0};
+ if (!db_get_ts(hContact, MODULE, "Login", &dbLogin)) {
+ SetDlgItemText(hwndDlg, IDC_LOGIN, dbLogin.ptszVal);
+ db_free(&dbLogin);
}
- if (db_get_b(hContact, MODULE, "UseAuth", 0)) {
- CheckDlgButton(hwndDlg, IDC_USEAUTH, BST_CHECKED);
- EnableWindow(GetDlgItem(hwndDlg, IDC_LOGIN), TRUE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), TRUE);
- DBVARIANT dbLogin = {0};
- if (!db_get_ts(hContact, MODULE, "Login", &dbLogin)) {
- SetDlgItemText(hwndDlg, IDC_LOGIN, dbLogin.ptszVal);
- db_free(&dbLogin);
- }
- DBVARIANT dbPass = {0};
- if (!db_get_ts(hContact, MODULE, "Password", &dbPass)) {
- SetDlgItemText(hwndDlg, IDC_PASSWORD, dbPass.ptszVal);
- db_free(&dbPass);
- }
+ DBVARIANT dbPass = {0};
+ if (!db_get_ts(hContact, MODULE, "Password", &dbPass)) {
+ SetDlgItemText(hwndDlg, IDC_PASSWORD, dbPass.ptszVal);
+ db_free(&dbPass);
}
- break;
}
- db_free(&dbURL);
+ break;
}
- db_free(&dbNick);
+ db_free(&dbURL);
}
+ db_free(&dbNick);
}
WindowList_Add(hChangeFeedDlgList, hwndDlg, hContact);
Utils_RestoreWindowPositionNoSize(hwndDlg, hContact, MODULE, "ChangeDlg");
@@ -492,26 +490,24 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA
ListView_GetItemText(hwndList, sel, 0, nick, MAX_PATH);
ListView_GetItemText(hwndList, sel, 1, url, MAX_PATH);
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- if(IsMyContact(hContact)) {
- DBVARIANT dbNick = {0};
- if (db_get_ts(hContact, MODULE, "Nick", &dbNick))
+ for (HANDLE hContact = db_find_first(MODULE); hContact; hContact = db_find_next(hContact, MODULE)) {
+ DBVARIANT dbNick = {0};
+ if (db_get_ts(hContact, MODULE, "Nick", &dbNick))
+ break;
+ else if (lstrcmp(dbNick.ptszVal, nick) == 0) {
+ db_free(&dbNick);
+ DBVARIANT dbURL = {0};
+ if (db_get_ts(hContact, MODULE, "URL", &dbURL))
break;
- else if (lstrcmp(dbNick.ptszVal, nick) == 0) {
- db_free(&dbNick);
- DBVARIANT dbURL = {0};
- if (db_get_ts(hContact, MODULE, "URL", &dbURL))
- break;
- else if (lstrcmp(dbURL.ptszVal, url) == 0) {
- db_free(&dbURL);
- CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
- ListView_DeleteItem(hwndList, sel);
- break;
- }
+ else if (lstrcmp(dbURL.ptszVal, url) == 0) {
db_free(&dbURL);
+ CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
+ ListView_DeleteItem(hwndList, sel);
+ break;
}
- db_free(&dbNick);
+ db_free(&dbURL);
}
+ db_free(&dbNick);
}
}
return FALSE;
@@ -714,57 +710,55 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA
HXML title = xi.addChild(header, _T("title"), _T("Miranda NG NewsAggregator plugin export"));
header = xi.addChild(hXml, _T("body"), NULL);
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- if (IsMyContact(hContact)) {
- TCHAR *title = NULL, *url = NULL, *siteurl = NULL, *group = NULL;
- DBVARIANT dbv = {0};
- if (!db_get_ts(hContact, MODULE, "Nick", &dbv)) {
- title = mir_tstrdup(dbv.ptszVal);
- db_free(&dbv);
- }
- if (!db_get_ts(hContact, MODULE, "URL", &dbv)) {
- url = mir_tstrdup(dbv.ptszVal);
- db_free(&dbv);
- }
- if (!db_get_ts(hContact, MODULE, "Homepage", &dbv)) {
- siteurl = mir_tstrdup(dbv.ptszVal);
- db_free(&dbv);
- }
- if (!db_get_ts(hContact, "CList", "Group", &dbv)) {
- group = mir_tstrdup(dbv.ptszVal);
- db_free(&dbv);
- }
- HXML elem = header;
- if (group)
+ for (HANDLE hContact = db_find_first(MODULE); hContact; hContact = db_find_next(hContact, MODULE)) {
+ TCHAR *title = NULL, *url = NULL, *siteurl = NULL, *group = NULL;
+ DBVARIANT dbv = {0};
+ if (!db_get_ts(hContact, MODULE, "Nick", &dbv)) {
+ title = mir_tstrdup(dbv.ptszVal);
+ db_free(&dbv);
+ }
+ if (!db_get_ts(hContact, MODULE, "URL", &dbv)) {
+ url = mir_tstrdup(dbv.ptszVal);
+ db_free(&dbv);
+ }
+ if (!db_get_ts(hContact, MODULE, "Homepage", &dbv)) {
+ siteurl = mir_tstrdup(dbv.ptszVal);
+ db_free(&dbv);
+ }
+ if (!db_get_ts(hContact, "CList", "Group", &dbv)) {
+ group = mir_tstrdup(dbv.ptszVal);
+ db_free(&dbv);
+ }
+ HXML elem = header;
+ if (group)
+ {
+ TCHAR *section = _tcstok(group, _T("\\"));
+ while (section != NULL)
{
- TCHAR *section = _tcstok(group, _T("\\"));
- while (section != NULL)
+ HXML existgroup = xi.getChildByAttrValue(header, _T("outline"), _T("title"), section);
+ if ( !existgroup)
{
- HXML existgroup = xi.getChildByAttrValue(header, _T("outline"), _T("title"), section);
- if ( !existgroup)
- {
- elem = xi.addChild(elem, _T("outline"), NULL);
- xi.addAttr(elem, _T("title"), section);
- xi.addAttr(elem, _T("text"), section);
- } else {
- elem = existgroup;
- }
- section = _tcstok(NULL, _T("\\"));
+ elem = xi.addChild(elem, _T("outline"), NULL);
+ xi.addAttr(elem, _T("title"), section);
+ xi.addAttr(elem, _T("text"), section);
+ } else {
+ elem = existgroup;
}
- elem = xi.addChild(elem, _T("outline"), NULL);
- } else
- elem = xi.addChild(elem, _T("outline"), NULL);
- xi.addAttr(elem, _T("text"), title);
- xi.addAttr(elem, _T("title"), title);
- xi.addAttr(elem, _T("type"), _T("rss"));
- xi.addAttr(elem, _T("xmlUrl"), url);
- xi.addAttr(elem, _T("htmlUrl"), siteurl);
-
- mir_free(title);
- mir_free(url);
- mir_free(siteurl);
- mir_free(group);
- }
+ section = _tcstok(NULL, _T("\\"));
+ }
+ elem = xi.addChild(elem, _T("outline"), NULL);
+ } else
+ elem = xi.addChild(elem, _T("outline"), NULL);
+ xi.addAttr(elem, _T("text"), title);
+ xi.addAttr(elem, _T("title"), title);
+ xi.addAttr(elem, _T("type"), _T("rss"));
+ xi.addAttr(elem, _T("xmlUrl"), url);
+ xi.addAttr(elem, _T("htmlUrl"), siteurl);
+
+ mir_free(title);
+ mir_free(url);
+ mir_free(siteurl);
+ mir_free(group);
}
xi.toFile(hXml, FileName, 1);
xi.destroyNode(hXml);
@@ -786,18 +780,16 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA
{
db_set_b(NULL, MODULE, "StartupRetrieve", IsDlgButtonChecked(hwndDlg, IDC_STARTUPRETRIEVE));
int i = 0;
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- if(IsMyContact(hContact)) {
- db_set_b(hContact, MODULE, "CheckState", ListView_GetCheckState(hwndList, i));
- if (!ListView_GetCheckState(hwndList, i))
- db_set_b(hContact, "CList", "Hidden", 1);
- else
- db_unset(hContact,"CList","Hidden");
- i += 1;
- }
+ for (HANDLE hContact = db_find_first(MODULE); hContact; hContact = db_find_next(hContact, MODULE)) {
+ db_set_b(hContact, MODULE, "CheckState", ListView_GetCheckState(hwndList, i));
+ if (!ListView_GetCheckState(hwndList, i))
+ db_set_b(hContact, "CList", "Hidden", 1);
+ else
+ db_unset(hContact,"CList","Hidden");
+ i += 1;
}
- break;
}
+ break;
case NM_DBLCLK:
{
diff --git a/plugins/NewsAggregator/Src/Services.cpp b/plugins/NewsAggregator/Src/Services.cpp
index da1c899b86..43ecd6bd14 100644
--- a/plugins/NewsAggregator/Src/Services.cpp
+++ b/plugins/NewsAggregator/Src/Services.cpp
@@ -33,9 +33,8 @@ static void __cdecl WorkingThread(void* param)
{
int nStatus = (int)param;
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
- if(IsMyContact(hContact))
- SetContactStatus(hContact, nStatus);
+ for (HANDLE hContact = db_find_first(MODULE); hContact; hContact = db_find_next(hContact, MODULE))
+ SetContactStatus(hContact, nStatus);
}
int OnFoldersChanged(WPARAM, LPARAM)
@@ -52,12 +51,10 @@ int NewsAggrInit(WPARAM wParam, LPARAM lParam)
else
lstrcpyn(tszRoot, VARST( _T("%miranda_userdata%\\Avatars\\"_T(DEFAULT_AVATARS_FOLDER))), SIZEOF(tszRoot));
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- if(IsMyContact(hContact)) {
- if (!db_get_b(NULL, MODULE, "StartupRetrieve", 1))
- db_set_dw(hContact, MODULE, "LastCheck", time(NULL));
- SetContactStatus(hContact, ID_STATUS_ONLINE);
- }
+ for (HANDLE hContact = db_find_first(MODULE); hContact; hContact = db_find_next(hContact, MODULE)) {
+ if (!db_get_b(NULL, MODULE, "StartupRetrieve", 1))
+ db_set_dw(hContact, MODULE, "LastCheck", time(NULL));
+ SetContactStatus(hContact, ID_STATUS_ONLINE);
}
NetlibInit();
@@ -154,10 +151,10 @@ INT_PTR NewsAggrGetInfo(WPARAM wParam,LPARAM lParam)
INT_PTR CheckAllFeeds(WPARAM wParam,LPARAM lParam)
{
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- if (IsMyContact(hContact) && lParam && db_get_dw(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME))
+ for (HANDLE hContact = db_find_first(MODULE); hContact; hContact = db_find_next(hContact, MODULE)) {
+ if (lParam && db_get_dw(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME))
UpdateListAdd(hContact);
- else if (IsMyContact(hContact) && !lParam)
+ else if (!lParam)
UpdateListAdd(hContact);
}
if (!ThreadRunning)
diff --git a/plugins/NewsAggregator/Src/Update.cpp b/plugins/NewsAggregator/Src/Update.cpp
index 7acc0373cc..c104a7d949 100644
--- a/plugins/NewsAggregator/Src/Update.cpp
+++ b/plugins/NewsAggregator/Src/Update.cpp
@@ -30,14 +30,12 @@ VOID CALLBACK timerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
// only run if it is not current updating and the auto update option is enabled
if (!ThreadRunning && !Miranda_Terminated()) {
BOOL HaveUpdates = FALSE;
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- if(IsMyContact(hContact)) {
- if (db_get_dw(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME)) {
- double diff = difftime(time(NULL), db_get_dw(hContact, MODULE, "LastCheck", 0));
- if (db_get_b(NULL, MODULE, "AutoUpdate", 1) != 0 && diff >= db_get_dw(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME) * 60) {
- UpdateListAdd(hContact);
- HaveUpdates = TRUE;
- }
+ for (HANDLE hContact = db_find_first(MODULE); hContact; hContact = db_find_next(hContact, MODULE)) {
+ if (db_get_dw(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME)) {
+ double diff = difftime(time(NULL), db_get_dw(hContact, MODULE, "LastCheck", 0));
+ if (db_get_b(NULL, MODULE, "AutoUpdate", 1) != 0 && diff >= db_get_dw(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME) * 60) {
+ UpdateListAdd(hContact);
+ HaveUpdates = TRUE;
}
}
}
diff --git a/plugins/NewsAggregator/Src/Utils.cpp b/plugins/NewsAggregator/Src/Utils.cpp
index 745869e27d..5658a25c5f 100644
--- a/plugins/NewsAggregator/Src/Utils.cpp
+++ b/plugins/NewsAggregator/Src/Utils.cpp
@@ -240,27 +240,25 @@ VOID UpdateList(HWND hwndList)
// Initialize LVITEM members that are common to all
// items.
int i = 0;
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- if (IsMyContact(hContact)) {
- UpdateListFlag = TRUE;
- lvI.mask = LVIF_TEXT;
- lvI.iSubItem = 0;
- DBVARIANT dbNick = {0};
- if (!db_get_ts(hContact, MODULE, "Nick", &dbNick)) {
- lvI.pszText = dbNick.ptszVal;
- lvI.iItem = i;
- ListView_InsertItem(hwndList, &lvI);
- lvI.iSubItem = 1;
- DBVARIANT dbURL = {0};
- if (!db_get_ts(hContact, MODULE, "URL", &dbURL)) {
- lvI.pszText = dbURL.ptszVal;
- ListView_SetItem(hwndList, &lvI);
- i += 1;
- ListView_SetCheckState(hwndList, lvI.iItem, db_get_b(hContact, MODULE, "CheckState", 1));
- db_free(&dbURL);
- }
- db_free(&dbNick);
+ for (HANDLE hContact = db_find_first(MODULE); hContact; hContact = db_find_next(hContact, MODULE)) {
+ UpdateListFlag = TRUE;
+ lvI.mask = LVIF_TEXT;
+ lvI.iSubItem = 0;
+ DBVARIANT dbNick = {0};
+ if (!db_get_ts(hContact, MODULE, "Nick", &dbNick)) {
+ lvI.pszText = dbNick.ptszVal;
+ lvI.iItem = i;
+ ListView_InsertItem(hwndList, &lvI);
+ lvI.iSubItem = 1;
+ DBVARIANT dbURL = {0};
+ if (!db_get_ts(hContact, MODULE, "URL", &dbURL)) {
+ lvI.pszText = dbURL.ptszVal;
+ ListView_SetItem(hwndList, &lvI);
+ i += 1;
+ ListView_SetCheckState(hwndList, lvI.iItem, db_get_b(hContact, MODULE, "CheckState", 1));
+ db_free(&dbURL);
}
+ db_free(&dbNick);
}
}
UpdateListFlag = FALSE;
diff --git a/plugins/Non-IM Contact/src/files.cpp b/plugins/Non-IM Contact/src/files.cpp
index cdf17aed7c..d559fc6df8 100644
--- a/plugins/Non-IM Contact/src/files.cpp
+++ b/plugins/Non-IM Contact/src/files.cpp
@@ -14,31 +14,28 @@ INT_PTR exportContacts(WPARAM wParam,LPARAM lParam)
if (!file)
return 0;
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- const char* proto = GetContactProto(hContact);
- if (proto && !strcmp(proto, MODNAME)) {
- int tmp;
- char DBVar[1024];
- if (db_get_static(hContact, MODNAME, "Name", DBVar)) {
- fprintf(file, "\r\n[Non-IM Contact]\r\nName=%s\r\n", DBVar);
- if (db_get_static(hContact, MODNAME, "ProgramString", DBVar))
- fprintf(file, "ProgramString=%s\r\n", DBVar);
- if (db_get_static(hContact, MODNAME, "ProgramParamString", DBVar))
- fprintf(file, "ProgramParamString=%s\r\n", DBVar);
- if (db_get_static(hContact, MODNAME, "ToolTip", DBVar))
- fprintf(file, "ToolTip=%s</tooltip>\r\n", DBVar);
- if (db_get_static(hContact, "CList", "Group", DBVar))
- fprintf(file, "Group=%s\r\n", DBVar);
- if (tmp = db_get_w(hContact, MODNAME, "Icon", 40072))
- fprintf(file, "Icon=%d\r\n", tmp);
- if (tmp = db_get_b(hContact, MODNAME, "UseTimer", 0))
- fprintf(file, "UseTimer=%d\r\n", tmp);
- if (tmp = db_get_b(hContact, MODNAME, "Minutes", 1))
- fprintf(file, "Minutes=%d\r\n", tmp);
- if (tmp = db_get_w(hContact, MODNAME, "Timer", 0))
- fprintf(file, "Timer=%d\r\n", tmp);
- fprintf(file, "[/Non-IM Contact]\r\n");
- }
+ for (HANDLE hContact = db_find_first(MODNAME); hContact; hContact = db_find_next(hContact, MODNAME)) {
+ int tmp;
+ char DBVar[1024];
+ if (db_get_static(hContact, MODNAME, "Name", DBVar)) {
+ fprintf(file, "\r\n[Non-IM Contact]\r\nName=%s\r\n", DBVar);
+ if (db_get_static(hContact, MODNAME, "ProgramString", DBVar))
+ fprintf(file, "ProgramString=%s\r\n", DBVar);
+ if (db_get_static(hContact, MODNAME, "ProgramParamString", DBVar))
+ fprintf(file, "ProgramParamString=%s\r\n", DBVar);
+ if (db_get_static(hContact, MODNAME, "ToolTip", DBVar))
+ fprintf(file, "ToolTip=%s</tooltip>\r\n", DBVar);
+ if (db_get_static(hContact, "CList", "Group", DBVar))
+ fprintf(file, "Group=%s\r\n", DBVar);
+ if (tmp = db_get_w(hContact, MODNAME, "Icon", 40072))
+ fprintf(file, "Icon=%d\r\n", tmp);
+ if (tmp = db_get_b(hContact, MODNAME, "UseTimer", 0))
+ fprintf(file, "UseTimer=%d\r\n", tmp);
+ if (tmp = db_get_b(hContact, MODNAME, "Minutes", 1))
+ fprintf(file, "Minutes=%d\r\n", tmp);
+ if (tmp = db_get_w(hContact, MODNAME, "Timer", 0))
+ fprintf(file, "Timer=%d\r\n", tmp);
+ fprintf(file, "[/Non-IM Contact]\r\n");
}
}
fclose(file);
diff --git a/plugins/Non-IM Contact/src/timer.cpp b/plugins/Non-IM Contact/src/timer.cpp
index 42e2b47df1..0abd79e458 100644
--- a/plugins/Non-IM Contact/src/timer.cpp
+++ b/plugins/Non-IM Contact/src/timer.cpp
@@ -40,13 +40,11 @@ void timerFunc(LPVOID di)
}
/* update all the contacts */
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- if (!strcmp(MODNAME, GetContactProto(hContact))) {
- int timer = db_get_w(hContact, MODNAME, "Timer", 15);
- if (timer && !(timerCount % timer))
- if (db_get_static(hContact, MODNAME, "Name", text))
- replaceAllStrings(hContact);
- }
+ for (HANDLE hContact = db_find_first(MODNAME); hContact; hContact = db_find_next(hContact, MODNAME)) {
+ int timer = db_get_w(hContact, MODNAME, "Timer", 15);
+ if (timer && !(timerCount % timer))
+ if (db_get_static(hContact, MODNAME, "Name", text))
+ replaceAllStrings(hContact);
}
}
diff --git a/plugins/QuickContacts/src/quickcontacts.cpp b/plugins/QuickContacts/src/quickcontacts.cpp
index 1a978df72b..d554ecf031 100644
--- a/plugins/QuickContacts/src/quickcontacts.cpp
+++ b/plugins/QuickContacts/src/quickcontacts.cpp
@@ -361,89 +361,89 @@ void LoadContacts(HWND hwndDlg, BOOL show_all)
for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
char *pszProto = GetContactProto(hContact);
- if(pszProto != NULL)
+ if(pszProto == NULL)
+ continue;
+
+ // Get meta
+ HANDLE hMeta = NULL;
+ if (metacontactsEnabled)
{
- // Get meta
- HANDLE hMeta = NULL;
- if (metacontactsEnabled)
- {
- if ((!show_all && opts.hide_subcontacts) || opts.group_append)
- hMeta = (HANDLE) CallService(MS_MC_GETMETACONTACT, (WPARAM)hContact, 0);
- }
- else
- {
- if (metacontacts_proto != NULL && strcmp(metacontacts_proto, pszProto) == 0)
- continue;
- }
+ if ((!show_all && opts.hide_subcontacts) || opts.group_append)
+ hMeta = (HANDLE) CallService(MS_MC_GETMETACONTACT, (WPARAM)hContact, 0);
+ }
+ else
+ {
+ if (metacontacts_proto != NULL && strcmp(metacontacts_proto, pszProto) == 0)
+ continue;
+ }
- if (!show_all)
+ if (!show_all)
+ {
+ // Check if is offline and have to show
+ if (GetStatus(hContact, pszProto) <= ID_STATUS_OFFLINE)
{
- // Check if is offline and have to show
- if (GetStatus(hContact, pszProto) <= ID_STATUS_OFFLINE)
- {
- // See if has to show
- char setting[128];
- mir_snprintf(setting, sizeof(setting), "ShowOffline%s", pszProto);
+ // See if has to show
+ char setting[128];
+ mir_snprintf(setting, sizeof(setting), "ShowOffline%s", pszProto);
- if (!db_get_b(NULL, MODULE_NAME, setting, FALSE))
- continue;
+ if (!db_get_b(NULL, MODULE_NAME, setting, FALSE))
+ continue;
- // Check if proto offline
- else if (opts.hide_from_offline_proto
- && CallProtoService(pszProto, PS_GETSTATUS, 0, 0) <= ID_STATUS_OFFLINE)
- continue;
+ // Check if proto offline
+ else if (opts.hide_from_offline_proto
+ && CallProtoService(pszProto, PS_GETSTATUS, 0, 0) <= ID_STATUS_OFFLINE)
+ continue;
- }
+ }
- // Check if is subcontact
- if (opts.hide_subcontacts && hMeta != NULL)
- {
- if (!opts.keep_subcontacts_from_offline)
- continue;
+ // Check if is subcontact
+ if (opts.hide_subcontacts && hMeta != NULL)
+ {
+ if (!opts.keep_subcontacts_from_offline)
+ continue;
- if (GetStatus(hMeta, metacontacts_proto) > ID_STATUS_OFFLINE)
- {
+ if (GetStatus(hMeta, metacontacts_proto) > ID_STATUS_OFFLINE)
+ {
+ continue;
+ }
+ else
+ {
+ char setting[128];
+ mir_snprintf(setting, sizeof(setting), "ShowOffline%s", metacontacts_proto);
+ if (db_get_b(NULL, MODULE_NAME, setting, FALSE))
continue;
- }
- else
- {
- char setting[128];
- mir_snprintf(setting, sizeof(setting), "ShowOffline%s", metacontacts_proto);
- if (db_get_b(NULL, MODULE_NAME, setting, FALSE))
- continue;
- }
}
}
+ }
- // Add to list
+ // Add to list
- // Get group
- c_struct *contact = new c_struct();
+ // Get group
+ c_struct *contact = new c_struct();
- if (opts.group_append)
+ if (opts.group_append)
+ {
+ DBVARIANT dbv;
+ if (db_get_ts(hMeta == NULL ? hContact : hMeta, "CList", "Group", &dbv) == 0)
{
- DBVARIANT dbv;
- if (db_get_ts(hMeta == NULL ? hContact : hMeta, "CList", "Group", &dbv) == 0)
- {
- if (dbv.ptszVal != NULL)
- lstrcpyn(contact->szgroup, dbv.ptszVal, SIZEOF(contact->szgroup));
+ if (dbv.ptszVal != NULL)
+ lstrcpyn(contact->szgroup, dbv.ptszVal, SIZEOF(contact->szgroup));
- db_free(&dbv);
- }
+ db_free(&dbv);
}
+ }
- // Make contact name
- TCHAR *tmp = (TCHAR *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) hContact, GCDNF_TCHAR);
- lstrcpyn(contact->szname, tmp, SIZEOF(contact->szname));
+ // Make contact name
+ TCHAR *tmp = (TCHAR *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) hContact, GCDNF_TCHAR);
+ lstrcpyn(contact->szname, tmp, SIZEOF(contact->szname));
- PROTOACCOUNT *acc = ProtoGetAccount(pszProto);
- if (acc != NULL)
- lstrcpyn(contact->proto, acc->tszAccountName, SIZEOF(contact->proto));
+ PROTOACCOUNT *acc = ProtoGetAccount(pszProto);
+ if (acc != NULL)
+ lstrcpyn(contact->proto, acc->tszAccountName, SIZEOF(contact->proto));
- contact->hcontact = hContact;
- contacts.insert(contact);
- }
+ contact->hcontact = hContact;
+ contacts.insert(contact);
}
SortArray();
diff --git a/plugins/Quotes/src/ImportExport.cpp b/plugins/Quotes/src/ImportExport.cpp
index c8b7d9afbf..6ffaef1594 100644
--- a/plugins/Quotes/src/ImportExport.cpp
+++ b/plugins/Quotes/src/ImportExport.cpp
@@ -298,7 +298,7 @@ INT_PTR Quotes_Export(WPARAM wp,LPARAM lp)
}
else
{
- for(hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ for(hContact = db_find_first(QUOTES_MODULE_NAME); hContact; hContact = db_find_next(hContact, QUOTES_MODULE_NAME))
{
CQuotesProviders::TQuotesProviderPtr pProvider = pProviders->GetContactProviderPtr(hContact);
if(pProvider)
diff --git a/plugins/Quotes/src/QuotesProviders.cpp b/plugins/Quotes/src/QuotesProviders.cpp
index 8047977983..cfab6903ab 100644
--- a/plugins/Quotes/src/QuotesProviders.cpp
+++ b/plugins/Quotes/src/QuotesProviders.cpp
@@ -60,7 +60,7 @@ void CQuotesProviders::InitProviders()
const WORD nCurrentVersion = 17;
WORD nVersion = db_get_w(NULL,QUOTES_MODULE_NAME,LAST_RUN_VERSION,1);
- for(HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ for(HANDLE hContact = db_find_first(QUOTES_MODULE_NAME); hContact; hContact = db_find_next(hContact, QUOTES_MODULE_NAME))
{
TQuotesProviderPtr pProvider = GetContactProviderPtr(hContact);
if(pProvider)
diff --git a/plugins/Scriver/src/chat/clist.cpp b/plugins/Scriver/src/chat/clist.cpp
index 91c3e3f78c..857380f87e 100644
--- a/plugins/Scriver/src/chat/clist.cpp
+++ b/plugins/Scriver/src/chat/clist.cpp
@@ -282,20 +282,20 @@ BOOL CList_AddEvent(HANDLE hContact, HICON Icon, HANDLE event, int type, TCHAR*
return TRUE;
}
-HANDLE CList_FindRoom ( const char* pszModule, const TCHAR* pszRoom)
+HANDLE CList_FindRoom(const char* pszModule, const TCHAR* pszRoom)
{
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- char *szProto = GetContactProto(hContact);
- if (szProto && !lstrcmpiA(szProto, pszModule)) {
- if ( db_get_b( hContact, szProto, "ChatRoom", 0) != 0) {
- DBVARIANT dbv;
- if ( !db_get_ts( hContact, szProto, "ChatRoomID", &dbv)) {
- if ( !lstrcmpi(dbv.ptszVal, pszRoom)) {
- db_free(&dbv);
- return hContact;
- }
- db_free(&dbv);
- } } }
+ for (HANDLE hContact = db_find_first(pszModule); hContact; hContact = db_find_next(hContact, pszModule)) {
+ if ( !db_get_b( hContact, pszModule, "ChatRoom", 0))
+ continue;
+
+ DBVARIANT dbv;
+ if ( !db_get_ts( hContact, pszModule, "ChatRoomID", &dbv)) {
+ if ( !lstrcmpi(dbv.ptszVal, pszRoom)) {
+ db_free(&dbv);
+ return hContact;
+ }
+ db_free(&dbv);
+ }
}
return 0;
}
diff --git a/plugins/SeenPlugin/src/utils.cpp b/plugins/SeenPlugin/src/utils.cpp
index 41c4271955..22f41290f9 100644
--- a/plugins/SeenPlugin/src/utils.cpp
+++ b/plugins/SeenPlugin/src/utils.cpp
@@ -653,20 +653,14 @@ int UpdateValues(WPARAM wparam,LPARAM lparam)
static void cleanThread(void *param)
{
logthread_info* infoParam = (logthread_info*)param;
+ char *szProto = infoParam->sProtoName;
// I hope in 10 secons all logged-in contacts will be listed
if ( WaitForSingleObject(g_hShutdownEvent, 10000) == WAIT_TIMEOUT) {
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- char *contactProto = GetContactProto(hContact);
- if (!contactProto)
- continue;
-
- if ( strncmp(infoParam->sProtoName, contactProto, MAXMODULELABELLENGTH))
- continue;
-
+ for (HANDLE hContact = db_find_first(szProto); hContact; hContact = db_find_next(hContact, szProto)) {
WORD oldStatus = db_get_w(hContact,S_MOD,"StatusTriger",ID_STATUS_OFFLINE) | 0x8000;
if (oldStatus > ID_STATUS_OFFLINE) {
- if (db_get_w(hContact,contactProto,"Status",ID_STATUS_OFFLINE)==ID_STATUS_OFFLINE){
+ if (db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE)==ID_STATUS_OFFLINE){
db_set_w(hContact,S_MOD,"OldStatus",(WORD)(oldStatus|0x8000));
if (includeIdle)db_set_b(hContact,S_MOD,"OldIdle",(BYTE)((oldStatus&0x8000)?0:1));
db_set_w(hContact,S_MOD,"StatusTriger",ID_STATUS_OFFLINE);
diff --git a/plugins/SimpleStatusMsg/src/main.cpp b/plugins/SimpleStatusMsg/src/main.cpp
index e3150943da..792367ff8c 100644
--- a/plugins/SimpleStatusMsg/src/main.cpp
+++ b/plugins/SimpleStatusMsg/src/main.cpp
@@ -1813,13 +1813,12 @@ static int OnICQStatusMsgRequest(WPARAM wParam, LPARAM lParam, LPARAM lMirParam)
if (db_get_b(NULL, "SimpleStatusMsg", "NoUpdateOnICQReq", 1))
return 0;
- char *szProto;
+ char *szProto = (char *)lMirParam;
BOOL bContactFound = FALSE;
HANDLE hContact;
- for (hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- szProto = GetContactProto(hContact);
- if (szProto != NULL && !strcmp(szProto, (char *)lMirParam) && db_get_dw(hContact, szProto, "UIN", 0) == (DWORD)lParam) {
+ for (hContact = db_find_first(szProto); hContact; hContact = db_find_next(hContact, szProto)) {
+ if (db_get_dw(hContact, szProto, "UIN", 0) == (DWORD)lParam) {
bContactFound = TRUE;
break;
}
diff --git a/plugins/StopSpamMod/src/utilities.cpp b/plugins/StopSpamMod/src/utilities.cpp
index 4e31ebfbb3..c61b47f2d2 100755
--- a/plugins/StopSpamMod/src/utilities.cpp
+++ b/plugins/StopSpamMod/src/utilities.cpp
@@ -310,13 +310,10 @@ void CleanProtocolTmpThread(std::string proto)
}
std::list<HANDLE> contacts;
- for(HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- char *proto_tmp = GetContactProto(hContact);
- if(proto_tmp)
- if(!strcmp(proto.c_str(), proto_tmp))
- if(db_get_b(hContact, "CList", "NotOnList", 0)|| (_T("Not In List")== DBGetContactSettingStringPAN(hContact,"CList","Group",_T(""))))
- contacts.push_back(hContact);
- }
+ for(HANDLE hContact = db_find_first(proto.c_str()); hContact; hContact = db_find_next(hContact, proto.c_str()))
+ if(db_get_b(hContact, "CList", "NotOnList", 0)|| (_T("Not In List")== DBGetContactSettingStringPAN(hContact,"CList","Group",_T(""))))
+ contacts.push_back(hContact);
+
boost::this_thread::sleep(boost::posix_time::seconds(5));
clean_mutex.lock();
std::list<HANDLE>::iterator end = contacts.end();
@@ -340,14 +337,10 @@ void CleanProtocolExclThread(std::string proto)
}
std::list<HANDLE> contacts;
- for(HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
- {
- char *proto_tmp = GetContactProto(hContact);
- if(proto_tmp)
- if(!strcmp(proto.c_str(), proto_tmp))
- if(db_get_b(hContact, "CList", "NotOnList", 0) && db_get_b(hContact, pluginName, "Excluded", 0))
- contacts.push_back(hContact);
- }
+ for(HANDLE hContact = db_find_first(proto.c_str()); hContact; hContact = db_find_next(hContact, proto.c_str()))
+ if(db_get_b(hContact, "CList", "NotOnList", 0) && db_get_b(hContact, pluginName, "Excluded", 0))
+ contacts.push_back(hContact);
+
boost::this_thread::sleep(boost::posix_time::seconds(5));
clean_mutex.lock();
std::list<HANDLE>::iterator end = contacts.end();
diff --git a/plugins/StopSpamPlus/src/services.cpp b/plugins/StopSpamPlus/src/services.cpp
index 21b77e14f4..43470f8de7 100644
--- a/plugins/StopSpamPlus/src/services.cpp
+++ b/plugins/StopSpamPlus/src/services.cpp
@@ -22,10 +22,7 @@ INT_PTR IsContactPassed(WPARAM wParam, LPARAM /*lParam*/)
INT_PTR RemoveTempContacts(WPARAM wParam,LPARAM lParam)
{
- HANDLE hContact = db_find_first();
- while ( hContact ) {
- HANDLE hNext = db_find_next(hContact);
-
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
DBVARIANT dbv = { 0 };
if ( db_get_ts( hContact, "CList", "Group", &dbv ))
dbv.ptszVal = NULL;
@@ -48,7 +45,6 @@ INT_PTR RemoveTempContacts(WPARAM wParam,LPARAM lParam)
}
db_free( &dbv );
- hContact = hNext;
}
int hGroup = 1;
diff --git a/plugins/TabSRMM/src/chat/clist.cpp b/plugins/TabSRMM/src/chat/clist.cpp
index 483603b24d..cab020142b 100644
--- a/plugins/TabSRMM/src/chat/clist.cpp
+++ b/plugins/TabSRMM/src/chat/clist.cpp
@@ -291,19 +291,17 @@ BOOL CList_AddEvent(HANDLE hContact, HICON Icon, HANDLE event, int type, const T
HANDLE CList_FindRoom(const char* pszModule, const TCHAR* pszRoom)
{
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- char *szProto = GetContactProto(hContact);
- if (szProto && !lstrcmpiA(szProto, pszModule)) {
- if (M->GetByte(hContact, szProto, "ChatRoom", 0) != 0) {
- DBVARIANT dbv;
- if (!M->GetTString(hContact, szProto, "ChatRoomID", &dbv)) {
- if (!lstrcmpi(dbv.ptszVal, pszRoom)) {
- db_free(&dbv);
- return hContact;
- }
- db_free(&dbv);
- }
+ for (HANDLE hContact = db_find_first(pszModule); hContact; hContact = db_find_next(hContact, pszModule)) {
+ if ( !M->GetByte(hContact, pszModule, "ChatRoom", 0))
+ continue;
+
+ DBVARIANT dbv;
+ if (!M->GetTString(hContact, pszModule, "ChatRoomID", &dbv)) {
+ if (!lstrcmpi(dbv.ptszVal, pszRoom)) {
+ db_free(&dbv);
+ return hContact;
}
+ db_free(&dbv);
}
}
return 0;
diff --git a/plugins/TabSRMM/src/typingnotify.cpp b/plugins/TabSRMM/src/typingnotify.cpp
index 3bef236dce..1b13fb3fea 100644
--- a/plugins/TabSRMM/src/typingnotify.cpp
+++ b/plugins/TabSRMM/src/typingnotify.cpp
@@ -303,12 +303,6 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
case IDC_PREVIEW:
if (PluginConfig.g_PopupAvail) {
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- char *szProto = GetContactProto(hContact);
- if (szProto != NULL)
- break;
- }
-
POPUPDATAT ppd = { 0 };
for (i=0; i < 2; i++) {
int notyping;
diff --git a/plugins/TipperYM/src/options.cpp b/plugins/TipperYM/src/options.cpp
index 84ad4272c8..f422396f33 100644
--- a/plugins/TipperYM/src/options.cpp
+++ b/plugins/TipperYM/src/options.cpp
@@ -2072,71 +2072,61 @@ INT_PTR CALLBACK DlgProcOptsSkin(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
INT_PTR CALLBACK DlgProcFavouriteContacts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
- {
- case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
+ switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
- if (CallService(MS_CLUI_GETCAPS, 0, 0) & CLUIF_DISABLEGROUPS && !db_get_b(NULL, "CList", "UseGroups", SETTING_USEGROUPS_DEFAULT))
- SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETUSEGROUPS, (WPARAM) FALSE, 0);
- else
- SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETUSEGROUPS, (WPARAM) TRUE, 0);
-
- SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETHIDEEMPTYGROUPS, 1, 0);
- SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETGREYOUTFLAGS, 0, 0);
- SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETLEFTMARGIN, 2, 0);
+ if (CallService(MS_CLUI_GETCAPS, 0, 0) & CLUIF_DISABLEGROUPS && !db_get_b(NULL, "CList", "UseGroups", SETTING_USEGROUPS_DEFAULT))
+ SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETUSEGROUPS, (WPARAM) FALSE, 0);
+ else
+ SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETUSEGROUPS, (WPARAM) TRUE, 0);
+ SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETHIDEEMPTYGROUPS, 1, 0);
+ SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETGREYOUTFLAGS, 0, 0);
+ SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETLEFTMARGIN, 2, 0);
+ {
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 && db_get_b(hContact, MODULE, "FavouriteContact", 0))
SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETCHECKMARK, (WPARAM)hItem, 1);
}
-
- CheckDlgButton(hwndDlg, IDC_CHK_HIDEOFFLINE, opt.iFavoriteContFlags & FAVCONT_HIDE_OFFLINE);
- CheckDlgButton(hwndDlg, IDC_CHK_APPENDPROTO, opt.iFavoriteContFlags & FAVCONT_APPEND_PROTO);
-
- return TRUE;
}
- case WM_COMMAND:
- {
- switch(LOWORD(wParam))
- {
- case IDC_BTN_OK:
- {
- BYTE isChecked;
- int count = 0;
+ CheckDlgButton(hwndDlg, IDC_CHK_HIDEOFFLINE, opt.iFavoriteContFlags & FAVCONT_HIDE_OFFLINE);
+ CheckDlgButton(hwndDlg, IDC_CHK_APPENDPROTO, opt.iFavoriteContFlags & FAVCONT_APPEND_PROTO);
+ return TRUE;
- 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)
- {
- isChecked = (BYTE)SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_GETCHECKMARK, (WPARAM)hItem, 0);
- db_set_b(hContact, MODULE, "FavouriteContact", isChecked);
- if (isChecked) count++;
- }
+ case WM_COMMAND:
+ switch(LOWORD(wParam)) {
+ case IDC_BTN_OK:
+ {
+ BYTE isChecked;
+ int count = 0;
+
+ 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) {
+ isChecked = (BYTE)SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_GETCHECKMARK, (WPARAM)hItem, 0);
+ db_set_b(hContact, MODULE, "FavouriteContact", isChecked);
+ if (isChecked) count++;
}
- db_set_dw(0, MODULE, "FavouriteContactsCount", count);
+ }
+ db_set_dw(0, MODULE, "FavouriteContactsCount", count);
- opt.iFavoriteContFlags = 0;
- opt.iFavoriteContFlags |= IsDlgButtonChecked(hwndDlg, IDC_CHK_HIDEOFFLINE) ? FAVCONT_HIDE_OFFLINE : 0 |
- IsDlgButtonChecked(hwndDlg, IDC_CHK_APPENDPROTO) ? FAVCONT_APPEND_PROTO : 0;
+ opt.iFavoriteContFlags = 0;
+ opt.iFavoriteContFlags |= IsDlgButtonChecked(hwndDlg, IDC_CHK_HIDEOFFLINE) ? FAVCONT_HIDE_OFFLINE : 0 |
+ IsDlgButtonChecked(hwndDlg, IDC_CHK_APPENDPROTO) ? FAVCONT_APPEND_PROTO : 0;
- db_set_dw(0, MODULE, "FavContFlags", opt.iFavoriteContFlags);
- } // fall through
- case IDC_BTN_CANCEL:
- {
- DestroyWindow(hwndDlg);
- break;
- }
- }
- return TRUE;
- }
- case WM_CLOSE:
- {
+ db_set_dw(0, MODULE, "FavContFlags", opt.iFavoriteContFlags);
+ } // fall through
+ case IDC_BTN_CANCEL:
DestroyWindow(hwndDlg);
- return TRUE;
+ break;
}
+ return TRUE;
+
+ case WM_CLOSE:
+ DestroyWindow(hwndDlg);
+ return TRUE;
}
return FALSE;
diff --git a/plugins/TipperYM/src/popwin.cpp b/plugins/TipperYM/src/popwin.cpp
index 290c1fcdd6..03682178bb 100644
--- a/plugins/TipperYM/src/popwin.cpp
+++ b/plugins/TipperYM/src/popwin.cpp
@@ -1551,13 +1551,10 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
if (dwItems & TRAYTIP_NUMCONTACTS) {
int iCount = 0, iCountOnline = 0;
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- char *proto = GetContactProto(hContact);
- if (proto && !strcmp(proto, pa->szModuleName)) {
- if (db_get_w(hContact, proto, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE)
- iCountOnline++;
- iCount++;
- }
+ for (HANDLE hContact = db_find_first(pa->szModuleName); hContact; hContact = db_find_next(hContact, pa->szModuleName)) {
+ if (db_get_w(hContact, pa->szModuleName, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE)
+ iCountOnline++;
+ iCount++;
}
mir_sntprintf(buff, 64, _T("(%d/%d)"), iCountOnline, iCount);
}
@@ -1679,32 +1676,33 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
if (db_get_b(hContact, MODULE, "FavouriteContact", 0)) {
char *proto = GetContactProto(hContact);
- if (proto) {
- WORD wStatus = db_get_w(hContact, proto, "Status", ID_STATUS_OFFLINE);
- WordToStatusDesc(hContact, proto, "Status", swzStatus, 256);
-
- if (wStatus != ID_STATUS_OFFLINE)
- iCountOnline++;
-
- iCount++;
-
- if ( !(opt.iFavoriteContFlags & FAVCONT_HIDE_OFFLINE && wStatus == ID_STATUS_OFFLINE)) {
- if (!bTitlePainted) {
- AddRow(pwd, TranslateT("Fav. contacts"), NULL, NULL, false, false, !bFirstItem, true, NULL);
- bFirstItem = false;
- bTitlePainted = true;
- }
-
- TCHAR *swzNick = (TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR);
- if (opt.iFavoriteContFlags & FAVCONT_APPEND_PROTO) {
- TCHAR *swzProto = a2t(proto);
- mir_sntprintf(swzName, 256, _T("%s (%s)"), swzNick, swzProto);
- mir_free(swzProto);
- }
- else _tcscpy(swzName, swzNick);
-
- AddRow(pwd, swzName, swzStatus, NULL, false, false, false);
+ if (proto == NULL)
+ continue;
+
+ WORD wStatus = db_get_w(hContact, proto, "Status", ID_STATUS_OFFLINE);
+ WordToStatusDesc(hContact, proto, "Status", swzStatus, 256);
+
+ if (wStatus != ID_STATUS_OFFLINE)
+ iCountOnline++;
+
+ iCount++;
+
+ if ( !(opt.iFavoriteContFlags & FAVCONT_HIDE_OFFLINE && wStatus == ID_STATUS_OFFLINE)) {
+ if (!bTitlePainted) {
+ AddRow(pwd, TranslateT("Fav. contacts"), NULL, NULL, false, false, !bFirstItem, true, NULL);
+ bFirstItem = false;
+ bTitlePainted = true;
}
+
+ TCHAR *swzNick = (TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR);
+ if (opt.iFavoriteContFlags & FAVCONT_APPEND_PROTO) {
+ TCHAR *swzProto = a2t(proto);
+ mir_sntprintf(swzName, 256, _T("%s (%s)"), swzNick, swzProto);
+ mir_free(swzProto);
+ }
+ else _tcscpy(swzName, swzNick);
+
+ AddRow(pwd, swzName, swzStatus, NULL, false, false, false);
}
}
}
diff --git a/plugins/Weather/src/weather_contacts.cpp b/plugins/Weather/src/weather_contacts.cpp
index a52727f002..2cc4187bf1 100644
--- a/plugins/Weather/src/weather_contacts.cpp
+++ b/plugins/Weather/src/weather_contacts.cpp
@@ -448,26 +448,24 @@ int ContactDeleted(WPARAM wParam, LPARAM lParam)
// now the default station is deleted, try to get a new one
// start looking for other weather stations
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- if (IsMyContact(hContact)) {
- if ( !db_get_ts(hContact, WEATHERPROTONAME, "ID", &dbv)) {
- // if the station is not a default station, set it as the new default station
- // this is the first weather station encountered from the search
- if ( _tcscmp(opt.Default, dbv.ptszVal)) {
- _tcscpy(opt.Default, dbv.ptszVal);
- opt.DefStn = hContact;
+ for (HANDLE hContact = db_find_first(WEATHERPROTONAME); hContact; hContact = db_find_next(hContact, WEATHERPROTONAME)) {
+ if ( !db_get_ts(hContact, WEATHERPROTONAME, "ID", &dbv)) {
+ // if the station is not a default station, set it as the new default station
+ // this is the first weather station encountered from the search
+ if ( _tcscmp(opt.Default, dbv.ptszVal)) {
+ _tcscpy(opt.Default, dbv.ptszVal);
+ opt.DefStn = hContact;
+ db_free(&dbv);
+ if ( !db_get_ts(hContact, WEATHERPROTONAME, "Nick", &dbv)) {
+ TCHAR str[255];
+ mir_sntprintf(str, SIZEOF(str), TranslateT("%s is now the default weather station"), dbv.ptszVal);
db_free(&dbv);
- if ( !db_get_ts(hContact, WEATHERPROTONAME, "Nick", &dbv)) {
- TCHAR str[255];
- mir_sntprintf(str, SIZEOF(str), TranslateT("%s is now the default weather station"), dbv.ptszVal);
- db_free(&dbv);
- MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK | MB_ICONINFORMATION);
- }
- db_set_ts(NULL, WEATHERPROTONAME, "Default", opt.Default);
- return 0; // exit this function quickly
+ MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK | MB_ICONINFORMATION);
}
- db_free(&dbv);
+ db_set_ts(NULL, WEATHERPROTONAME, "Default", opt.Default);
+ return 0; // exit this function quickly
}
+ db_free(&dbv);
}
}
// got here if no more weather station left
diff --git a/plugins/Weather/src/weather_data.cpp b/plugins/Weather/src/weather_data.cpp
index 3f6ce3b0f2..bcf0e22139 100644
--- a/plugins/Weather/src/weather_data.cpp
+++ b/plugins/Weather/src/weather_data.cpp
@@ -124,54 +124,51 @@ void EraseAllInfo()
HANDLE LastContact = NULL;
DBVARIANT dbv;
// loop through all contacts
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- // see if the contact is a weather contact
- if ( IsMyContact(hContact)) {
- db_set_w(hContact,WEATHERPROTONAME, "Status",ID_STATUS_OFFLINE);
- db_set_w(hContact,WEATHERPROTONAME, "StatusIcon",ID_STATUS_OFFLINE);
- db_unset(hContact, "CList", "MyHandle");
- // clear all data
- if ( db_get_ts(hContact, WEATHERPROTONAME, "Nick", &dbv)) {
- db_set_ts(hContact, WEATHERPROTONAME, "Nick", TranslateT("<Enter city name here>"));
- db_set_s(hContact, WEATHERPROTONAME, "LastLog", "never");
- db_set_s(hContact, WEATHERPROTONAME, "LastCondition", "None");
- db_set_s(hContact, WEATHERPROTONAME, "LastTemperature", "None");
- }
- else db_free(&dbv);
-
- DBDataManage(hContact, WDBM_REMOVE, 0, 0);
- db_set_s(hContact, "UserInfo", "MyNotes", "");
- // reset update tag
- db_set_b(hContact,WEATHERPROTONAME, "IsUpdated",FALSE);
- // reset logging settings
- if ( !db_get_ts(hContact,WEATHERPROTONAME, "Log", &dbv)) {
- db_set_b(hContact,WEATHERPROTONAME, "File",(BYTE)(dbv.ptszVal[0] != 0));
- db_free(&dbv);
- }
- else db_set_b(hContact,WEATHERPROTONAME, "File",FALSE);
+ for (HANDLE hContact = db_find_first(WEATHERPROTONAME); hContact; hContact = db_find_next(hContact, WEATHERPROTONAME)) {
+ db_set_w(hContact,WEATHERPROTONAME, "Status",ID_STATUS_OFFLINE);
+ db_set_w(hContact,WEATHERPROTONAME, "StatusIcon",ID_STATUS_OFFLINE);
+ db_unset(hContact, "CList", "MyHandle");
+ // clear all data
+ if ( db_get_ts(hContact, WEATHERPROTONAME, "Nick", &dbv)) {
+ db_set_ts(hContact, WEATHERPROTONAME, "Nick", TranslateT("<Enter city name here>"));
+ db_set_s(hContact, WEATHERPROTONAME, "LastLog", "never");
+ db_set_s(hContact, WEATHERPROTONAME, "LastCondition", "None");
+ db_set_s(hContact, WEATHERPROTONAME, "LastTemperature", "None");
+ }
+ else db_free(&dbv);
+
+ DBDataManage(hContact, WDBM_REMOVE, 0, 0);
+ db_set_s(hContact, "UserInfo", "MyNotes", "");
+ // reset update tag
+ db_set_b(hContact,WEATHERPROTONAME, "IsUpdated",FALSE);
+ // reset logging settings
+ if ( !db_get_ts(hContact,WEATHERPROTONAME, "Log", &dbv)) {
+ db_set_b(hContact,WEATHERPROTONAME, "File",(BYTE)(dbv.ptszVal[0] != 0));
+ db_free(&dbv);
+ }
+ else db_set_b(hContact,WEATHERPROTONAME, "File",FALSE);
- // if no default station find, assign a new one
- if (opt.Default[0] == 0) {
- GetStationID(hContact, opt.Default, SIZEOF(opt.Default));
+ // if no default station find, assign a new one
+ if (opt.Default[0] == 0) {
+ GetStationID(hContact, opt.Default, SIZEOF(opt.Default));
- opt.DefStn = hContact;
- if ( !db_get_ts(hContact,WEATHERPROTONAME, "Nick",&dbv)) {
- wsprintf(str, TranslateT("%s is now the default weather station"), dbv.ptszVal);
- db_free(&dbv);
- MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK|MB_ICONINFORMATION);
- }
+ opt.DefStn = hContact;
+ if ( !db_get_ts(hContact,WEATHERPROTONAME, "Nick",&dbv)) {
+ wsprintf(str, TranslateT("%s is now the default weather station"), dbv.ptszVal);
+ db_free(&dbv);
+ MessageBox(NULL, str, TranslateT("Weather Protocol"), MB_OK|MB_ICONINFORMATION);
}
- // get the handle of the default station
- if (opt.DefStn == NULL) {
- if ( !db_get_ts(hContact,WEATHERPROTONAME, "ID",&dbv)) {
- if ( !_tcscmp(dbv.ptszVal, opt.Default))
- opt.DefStn = hContact;
- db_free(&dbv);
- }
+ }
+ // get the handle of the default station
+ if (opt.DefStn == NULL) {
+ if ( !db_get_ts(hContact,WEATHERPROTONAME, "ID",&dbv)) {
+ if ( !_tcscmp(dbv.ptszVal, opt.Default))
+ opt.DefStn = hContact;
+ db_free(&dbv);
}
- ContactCount++; // increment counter
- LastContact = hContact;
}
+ ContactCount++; // increment counter
+ LastContact = hContact;
}
// if weather contact exists, set the status to online so it is ready for update
diff --git a/plugins/Weather/src/weather_mwin.cpp b/plugins/Weather/src/weather_mwin.cpp
index 7f70b659d0..c127214999 100644
--- a/plugins/Weather/src/weather_mwin.cpp
+++ b/plugins/Weather/src/weather_mwin.cpp
@@ -384,25 +384,19 @@ void InitMwin(void)
FontRegisterT(&fontid);
}
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- // see if the contact is a weather contact
- if (IsMyContact(hContact)) {
- if (db_get_dw(hContact, WEATHERPROTONAME, "mwin", 0))
- addWindow(hContact);
- }
- }
+ for (HANDLE hContact = db_find_first(WEATHERPROTONAME); hContact; hContact = db_find_next(hContact, WEATHERPROTONAME))
+ if (db_get_dw(hContact, WEATHERPROTONAME, "mwin", 0))
+ addWindow(hContact);
+
hFontHook = HookEvent(ME_FONT_RELOAD, RedrawFrame);
}
void DestroyMwin(void)
{
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- // see if the contact is a weather contact
- if (IsMyContact(hContact)) {
- DWORD frameId = db_get_dw(hContact, WEATHERPROTONAME, "mwin", 0);
- if (frameId)
- CallService(MS_CLIST_FRAMES_REMOVEFRAME, frameId, 0);
- }
+ for (HANDLE hContact = db_find_first(WEATHERPROTONAME); hContact; hContact = db_find_next(hContact, WEATHERPROTONAME)) {
+ DWORD frameId = db_get_dw(hContact, WEATHERPROTONAME, "mwin", 0);
+ if (frameId)
+ CallService(MS_CLIST_FRAMES_REMOVEFRAME, frameId, 0);
}
UnregisterClass( _T("WeatherFrame"), hInst);
UnhookEvent(hFontHook);
diff --git a/plugins/Weather/src/weather_update.cpp b/plugins/Weather/src/weather_update.cpp
index 4c7f819b1f..a6cee642ff 100644
--- a/plugins/Weather/src/weather_update.cpp
+++ b/plugins/Weather/src/weather_update.cpp
@@ -282,12 +282,10 @@ void DestroyUpdateList(void)
void UpdateAll(BOOL AutoUpdate, BOOL RemoveData)
{
// add all weather contact to the update queue list
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- if (IsMyContact(hContact)) {
- if ( !db_get_b(hContact,WEATHERPROTONAME, "AutoUpdate",FALSE) || !AutoUpdate) {
- if (RemoveData) DBDataManage((HANDLE)hContact, WDBM_REMOVE, 0, 0);
- UpdateListAdd(hContact);
- }
+ for (HANDLE hContact = db_find_first(WEATHERPROTONAME); hContact; hContact = db_find_next(hContact, WEATHERPROTONAME)) {
+ if ( !db_get_b(hContact,WEATHERPROTONAME, "AutoUpdate",FALSE) || !AutoUpdate) {
+ if (RemoveData) DBDataManage((HANDLE)hContact, WDBM_REMOVE, 0, 0);
+ UpdateListAdd(hContact);
}
}
diff --git a/plugins/YAMN/src/proto/pop3/pop3comm.cpp b/plugins/YAMN/src/proto/pop3/pop3comm.cpp
index dcb2d55b59..da50c74b56 100644
--- a/plugins/YAMN/src/proto/pop3/pop3comm.cpp
+++ b/plugins/YAMN/src/proto/pop3/pop3comm.cpp
@@ -278,23 +278,19 @@ int RegisterPOP3Plugin(WPARAM,LPARAM)
for (Finder=POP3Plugin->FirstAccount;Finder != NULL;Finder=Finder->Next)
{
Finder->hContact = NULL;
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- szProto = GetContactProto(hContact);
- if (szProto != NULL && strcmp(szProto, YAMN_DBMODULE)==0)
- {
- if (!db_get_s(hContact,YAMN_DBMODULE,"Id",&dbv)) {
- if ( strcmp( dbv.pszVal, Finder->Name) == 0) {
- Finder->hContact = hContact;
- db_set_w(Finder->hContact, YAMN_DBMODULE, "Status", ID_STATUS_ONLINE);
- db_set_s(Finder->hContact, "CList", "StatusMsg", Translate("No new mail message"));
- if ((Finder->Flags & YAMN_ACC_ENA) && (Finder->NewMailN.Flags & YAMN_ACC_CONT))
- db_unset(Finder->hContact, "CList", "Hidden");
-
- if (!(Finder->Flags & YAMN_ACC_ENA) || !(Finder->NewMailN.Flags & YAMN_ACC_CONT))
- db_set_b(Finder->hContact, "CList", "Hidden", 1);
- }
- db_free(&dbv);
+ for (HANDLE hContact = db_find_first(YAMN_DBMODULE); hContact; hContact = db_find_next(hContact, YAMN_DBMODULE)) {
+ if (!db_get_s(hContact,YAMN_DBMODULE,"Id",&dbv)) {
+ if ( strcmp( dbv.pszVal, Finder->Name) == 0) {
+ Finder->hContact = hContact;
+ db_set_w(Finder->hContact, YAMN_DBMODULE, "Status", ID_STATUS_ONLINE);
+ db_set_s(Finder->hContact, "CList", "StatusMsg", Translate("No new mail message"));
+ if ((Finder->Flags & YAMN_ACC_ENA) && (Finder->NewMailN.Flags & YAMN_ACC_CONT))
+ db_unset(Finder->hContact, "CList", "Hidden");
+
+ if (!(Finder->Flags & YAMN_ACC_ENA) || !(Finder->NewMailN.Flags & YAMN_ACC_CONT))
+ db_set_b(Finder->hContact, "CList", "Hidden", 1);
}
+ db_free(&dbv);
}
}
diff --git a/protocols/AimOscar/src/services.cpp b/protocols/AimOscar/src/services.cpp
index 52c9bf37ce..bfc0ca83ed 100644
--- a/protocols/AimOscar/src/services.cpp
+++ b/protocols/AimOscar/src/services.cpp
@@ -236,8 +236,7 @@ int CAimProto::OnGroupChange(WPARAM wParam,LPARAM lParam)
}
else
{
- if (is_my_contact(hContact) && getBuddyId(hContact, 1) &&
- !db_get_b(hContact, MOD_KEY_CL, AIM_KEY_NL, 0))
+ if (is_my_contact(hContact) && getBuddyId(hContact, 1) && !db_get_b(hContact, MOD_KEY_CL, AIM_KEY_NL, 0))
{
if (grpchg->pszNewName)
{
diff --git a/protocols/AimOscar/src/theme.cpp b/protocols/AimOscar/src/theme.cpp
index 3dc5dce55f..5f595d2cc6 100644
--- a/protocols/AimOscar/src/theme.cpp
+++ b/protocols/AimOscar/src/theme.cpp
@@ -144,30 +144,28 @@ void set_contact_icon(CAimProto* ppro, HANDLE hContact)
void remove_AT_icons(CAimProto* ppro)
{
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
- if (ppro->is_my_contact(hContact) && !ppro->getByte(hContact, "ChatRoom", 0))
+ for (HANDLE hContact = db_find_first(ppro->m_szModuleName); hContact; hContact = db_find_next(hContact, ppro->m_szModuleName))
+ if (!ppro->getByte(hContact, "ChatRoom", 0))
ExtraIcon_Clear(hExtraAT, hContact);
}
void remove_ES_icons(CAimProto* ppro)
{
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
- if (ppro->is_my_contact(hContact) && !ppro->getByte(hContact, "ChatRoom", 0))
+ for (HANDLE hContact = db_find_first(ppro->m_szModuleName); hContact; hContact = db_find_next(hContact, ppro->m_szModuleName))
+ if (!ppro->getByte(hContact, "ChatRoom", 0))
ExtraIcon_Clear(hExtraES, hContact);
}
void add_AT_icons(CAimProto* ppro)
{
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
- if (ppro->is_my_contact(hContact))
- set_AT_icon(ppro, hContact);
+ for (HANDLE hContact = db_find_first(ppro->m_szModuleName); hContact; hContact = db_find_next(hContact, ppro->m_szModuleName))
+ set_AT_icon(ppro, hContact);
}
void add_ES_icons(CAimProto* ppro)
{
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
- if (ppro->is_my_contact(hContact))
- set_ES_icon(ppro, hContact);
+ for (HANDLE hContact = db_find_first(ppro->m_szModuleName); hContact; hContact = db_find_next(hContact, ppro->m_szModuleName))
+ set_ES_icon(ppro, hContact);
}
void InitExtraIcons(void)
diff --git a/protocols/AimOscar/src/ui.cpp b/protocols/AimOscar/src/ui.cpp
index 25e04fd38e..f98f643db2 100644
--- a/protocols/AimOscar/src/ui.cpp
+++ b/protocols/AimOscar/src/ui.cpp
@@ -1403,7 +1403,7 @@ static void clist_chat_invite_send(HANDLE hItem, HWND hwndList, chat_list_item*
static void clist_validate_contact(HANDLE hItem, HWND hwndList, CAimProto* ppro)
{
if (!ppro->is_my_contact(hItem) || ppro->getByte(hItem, "ChatRoom", 0) ||
- ppro->getWord(hItem, AIM_KEY_ST, ID_STATUS_OFFLINE) == ID_STATUS_ONTHEPHONE)
+ ppro->getWord(hItem, AIM_KEY_ST, ID_STATUS_OFFLINE) == ID_STATUS_ONTHEPHONE)
SendMessage(hwndList, CLM_DELETEITEM, (WPARAM)hItem, 0);
}
diff --git a/protocols/AimOscar/src/utility.cpp b/protocols/AimOscar/src/utility.cpp
index 4fbc7a03c5..e2ba0bc4f1 100644
--- a/protocols/AimOscar/src/utility.cpp
+++ b/protocols/AimOscar/src/utility.cpp
@@ -168,14 +168,13 @@ bool CAimProto::is_my_contact(HANDLE hContact)
HANDLE CAimProto::find_chat_contact(const char* room)
{
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- if (is_my_contact(hContact)) {
- DBVARIANT dbv;
- if (!getString(hContact, "ChatRoomID", &dbv)) {
- bool found = !strcmp(room, dbv.pszVal);
- db_free(&dbv);
- if (found) return hContact;
- }
+ for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
+ DBVARIANT dbv;
+ if (!getString(hContact, "ChatRoomID", &dbv)) {
+ bool found = !strcmp(room, dbv.pszVal);
+ db_free(&dbv);
+ if (found)
+ return hContact;
}
}
return NULL;
@@ -185,15 +184,13 @@ HANDLE CAimProto::contact_from_sn(const char* sn, bool addIfNeeded, bool tempora
{
mir_ptr<char> norm_sn( normalize_name(sn));
- 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)) {
- bool found = !strcmp(norm_sn, dbv.pszVal);
- db_free(&dbv);
- if (found)
- return hContact;
- }
+ for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
+ DBVARIANT dbv;
+ if (!getString(hContact, AIM_KEY_SN, &dbv)) {
+ bool found = !strcmp(norm_sn, dbv.pszVal);
+ db_free(&dbv);
+ if (found)
+ return hContact;
}
}
@@ -321,9 +318,8 @@ void CAimProto::offline_contact(HANDLE hContact, bool remove_settings)
void CAimProto::offline_contacts(void)
{
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
- if (is_my_contact(hContact))
- offline_contact(hContact,true);
+ for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName))
+ offline_contact(hContact,true);
allow_list.destroy();
block_list.destroy();
@@ -387,14 +383,12 @@ unsigned short CAimProto::search_for_free_item_id(HANDLE hbuddy)//returns a free
retry:
id = get_random();
- 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;
+ for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
+ 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
- }
+ if (item_id == id) goto retry; //found one no need to look through anymore
}
}
@@ -408,19 +402,17 @@ unsigned short* CAimProto::get_members_of_group(unsigned short group_id, unsigne
unsigned short* list = NULL;
size = 0;
- 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 (group_id == user_group_id) {
- unsigned short buddy_id = getBuddyId(hContact, i);
- if (buddy_id) {
- list = (unsigned short*)mir_realloc(list, ++size*sizeof(list[0]));
- list[size-1] = _htons(buddy_id);
- }
+ for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
+ for(int i=1; ;++i) {
+ unsigned short user_group_id = getGroupId(hContact, i);
+ if (user_group_id == 0)
+ break;
+
+ if (group_id == user_group_id) {
+ unsigned short buddy_id = getBuddyId(hContact, i);
+ if (buddy_id) {
+ list = (unsigned short*)mir_realloc(list, ++size*sizeof(list[0]));
+ list[size-1] = _htons(buddy_id);
}
}
}
@@ -430,9 +422,9 @@ unsigned short* CAimProto::get_members_of_group(unsigned short group_id, unsigne
void CAimProto::upload_nicks(void)
{
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
DBVARIANT dbv;
- if (is_my_contact(hContact) && !db_get_utf(hContact, MOD_KEY_CL, "MyHandle", &dbv)) {
+ if ( !db_get_utf(hContact, MOD_KEY_CL, "MyHandle", &dbv)) {
set_local_nick(hContact, dbv.pszVal, NULL);
db_free(&dbv);
}
diff --git a/protocols/EmLanProto/src/mlan.cpp b/protocols/EmLanProto/src/mlan.cpp
index b17b7ef7c9..653557e160 100644
--- a/protocols/EmLanProto/src/mlan.cpp
+++ b/protocols/EmLanProto/src/mlan.cpp
@@ -127,12 +127,9 @@ void CMLan::SetMirandaStatus(u_int status)
void CMLan::SetAllOffline()
{
- 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");
- }
+ for (HANDLE hContact = db_find_first(PROTONAME); hContact; hContact = db_find_next(hContact, PROTONAME)) {
+ db_set_w(hContact, PROTONAME, "Status", ID_STATUS_OFFLINE);
+ db_unset(hContact, PROTONAME, "IP");
}
DeleteCache();
}
@@ -241,18 +238,15 @@ 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)
{
- 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);
- if (caddr==addr.S_un.S_addr) {
- if (make_permanent)
- db_unset(res,"CList","NotOnList");
- if (make_visible)
- db_unset(res,"CList","Hidden");
- return res;
- }
- }
+ for (HANDLE res = db_find_first(PROTONAME); res; res = db_find_next(res, PROTONAME)) {
+ u_long caddr = db_get_dw(res, PROTONAME, "ipaddr", -1);
+ if (caddr==addr.S_un.S_addr) {
+ if (make_permanent)
+ db_unset(res,"CList","NotOnList");
+ if (make_visible)
+ db_unset(res,"CList","Hidden");
+ return res;
+ }
}
if (add_to_list) {
diff --git a/protocols/FacebookRM/src/contacts.cpp b/protocols/FacebookRM/src/contacts.cpp
index 392b95df82..0d3ba50bfe 100644
--- a/protocols/FacebookRM/src/contacts.cpp
+++ b/protocols/FacebookRM/src/contacts.cpp
@@ -38,7 +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(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
if(!IsMyContact(hContact, true))
continue;
@@ -60,8 +60,8 @@ 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)) {
- if(!IsMyContact(hContact))
+ for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
+ if (!IsMyContact(hContact))
continue;
DBVARIANT dbv;
@@ -135,7 +135,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)) {
- if (!IsMyContact(hContact))
+ if ( db_get_b(hContact,m_szModuleName,"ChatRoom",0))
continue;
if (reset_client) {
diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp
index e3f1a014ba..ae0911e3f0 100644
--- a/protocols/FacebookRM/src/process.cpp
+++ b/protocols/FacebookRM/src/process.cpp
@@ -160,8 +160,8 @@ void FacebookProto::ProcessFriendList( void* data )
// Check and update old contacts
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- if (!IsMyContact(hContact))
+ for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
+ if ( db_get_b(hContact,m_szModuleName,"ChatRoom",0))
continue;
DBVARIANT dbv;
diff --git a/protocols/Gadu-Gadu/src/core.cpp b/protocols/Gadu-Gadu/src/core.cpp
index 393157275d..e54f313070 100644
--- a/protocols/Gadu-Gadu/src/core.cpp
+++ b/protocols/Gadu-Gadu/src/core.cpp
@@ -1447,16 +1447,13 @@ void GGPROTO::setalloffline()
netlog("setalloffline(): started. Setting buddies offline");
db_set_w(NULL, m_szModuleName, GG_KEY_STATUS, ID_STATUS_OFFLINE);
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- char *szProto = GetContactProto(hContact);
- 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);
- db_unset(hContact, m_szModuleName, GG_KEY_CLIENTPORT);
- // Delete status descr
- db_unset(hContact, "CList", GG_KEY_STATUSDESCR);
- }
+ for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, 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);
+ db_unset(hContact, m_szModuleName, GG_KEY_CLIENTPORT);
+ // Delete status descr
+ db_unset(hContact, "CList", GG_KEY_STATUSDESCR);
}
#ifdef DEBUGMODE
netlog("setalloffline(): End.");
@@ -1517,11 +1514,8 @@ void GGPROTO::notifyall()
netlog("notifyall(): Subscribing notification to all users");
// Readup count
- for (hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- szProto = GetContactProto(hContact);
- if (szProto != NULL && !strcmp(szProto, m_szModuleName))
- count ++;
- }
+ for (hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, 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 */
@@ -1536,9 +1530,8 @@ void GGPROTO::notifyall()
uins = (uin_t*)calloc(sizeof(uin_t), count);
types = (char*)calloc(sizeof(char), 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))) {
+ for (hContact = db_find_first(m_szModuleName); hContact && cc < count; hContact = db_find_next(hContact, m_szModuleName)) {
+ if (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;
@@ -1572,21 +1565,17 @@ 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
- 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
- && db_get_b(hContact, m_szModuleName, "ChatRoom", 0) == 0)
- {
- if (inlist) {
- db_unset(hContact, "CList", "NotOnList");
- db_unset(hContact, "CList", "Hidden");
- }
- return hContact;
+ for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
+ if ((uin_t)db_get_dw(hContact, m_szModuleName, GG_KEY_UIN, 0) == uin && !db_get_b(hContact, m_szModuleName, "ChatRoom", 0)) {
+ if (inlist) {
+ db_unset(hContact, "CList", "NotOnList");
+ db_unset(hContact, "CList", "Hidden");
}
+ return hContact;
}
}
- if (!create) return NULL;
+ if (!create)
+ return NULL;
HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_ADD, 0, 0);
if (!hContact) {
diff --git a/protocols/Gadu-Gadu/src/import.cpp b/protocols/Gadu-Gadu/src/import.cpp
index 0492ecb32b..1e899588db 100644
--- a/protocols/Gadu-Gadu/src/import.cpp
+++ b/protocols/Gadu-Gadu/src/import.cpp
@@ -101,85 +101,84 @@ char *gg_makecontacts(GGPROTO *gg, int cr)
char *contacts;
// Readup contacts
- 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)) {
- DBVARIANT dbv;
+ for (HANDLE hContact = db_find_first(gg->m_szModuleName); hContact; hContact = db_find_next(hContact, gg->m_szModuleName)) {
+ if (db_get_b(hContact, gg->m_szModuleName, "ChatRoom", 0))
+ continue;
- // Readup FirstName
- if (!db_get_s(hContact, gg->m_szModuleName, GG_KEY_PD_FIRSTNAME, &dbv, DBVT_WCHAR))
- {
- char* pszValA = mir_t2a(dbv.ptszVal);
- string_append(s, dbv.pszVal);
- mir_free(pszValA);
- db_free(&dbv);
- }
- string_append_c(s, ';');
- // Readup LastName
- if (!db_get_s(hContact, gg->m_szModuleName, GG_KEY_PD_LASTNAME, &dbv, DBVT_WCHAR))
+ // Readup FirstName
+ DBVARIANT dbv;
+ if (!db_get_s(hContact, gg->m_szModuleName, GG_KEY_PD_FIRSTNAME, &dbv, DBVT_WCHAR))
+ {
+ char* pszValA = mir_t2a(dbv.ptszVal);
+ string_append(s, dbv.pszVal);
+ mir_free(pszValA);
+ db_free(&dbv);
+ }
+ string_append_c(s, ';');
+ // Readup LastName
+ if (!db_get_s(hContact, gg->m_szModuleName, GG_KEY_PD_LASTNAME, &dbv, DBVT_WCHAR))
+ {
+ char* pszValA = mir_t2a(dbv.ptszVal);
+ string_append(s, dbv.pszVal);
+ mir_free(pszValA);
+ db_free(&dbv);
+ }
+ string_append_c(s, ';');
+
+ // Readup Nick
+ if (!db_get_s(hContact, "CList", "MyHandle", &dbv, DBVT_TCHAR) || !db_get_s(hContact, gg->m_szModuleName, GG_KEY_NICK, &dbv, DBVT_TCHAR))
+ {
+ char* dbvA = mir_t2a(dbv.ptszVal);
+ DBVARIANT dbv2;
+ if (!db_get_s(hContact, gg->m_szModuleName, GG_KEY_PD_NICKNAME, &dbv2, DBVT_WCHAR))
{
- char* pszValA = mir_t2a(dbv.ptszVal);
- string_append(s, dbv.pszVal);
+ char* pszValA = mir_t2a(dbv2.ptszVal);
+ string_append(s, pszValA);
mir_free(pszValA);
- db_free(&dbv);
+ db_free(&dbv2);
}
- string_append_c(s, ';');
+ else string_append(s, dbvA);
- // Readup Nick
- if (!db_get_s(hContact, "CList", "MyHandle", &dbv, DBVT_TCHAR) || !db_get_s(hContact, gg->m_szModuleName, GG_KEY_NICK, &dbv, DBVT_TCHAR))
- {
- char* dbvA = mir_t2a(dbv.ptszVal);
- DBVARIANT dbv2;
- if (!db_get_s(hContact, gg->m_szModuleName, GG_KEY_PD_NICKNAME, &dbv2, DBVT_WCHAR))
- {
- char* pszValA = mir_t2a(dbv2.ptszVal);
- string_append(s, pszValA);
- mir_free(pszValA);
- db_free(&dbv2);
- }
- else string_append(s, dbvA);
-
- string_append_c(s, ';');
- string_append(s, dbvA);
- mir_free(dbvA);
- db_free(&dbv);
- }
- else
- string_append_c(s, ';');
string_append_c(s, ';');
+ string_append(s, dbvA);
+ mir_free(dbvA);
+ db_free(&dbv);
+ }
+ else
+ string_append_c(s, ';');
+ string_append_c(s, ';');
- // Readup Phone (fixed: uses stored editable phones)
- if (!db_get_s(hContact, "UserInfo", "MyPhone0", &dbv, DBVT_ASCIIZ))
- {
- // Remove SMS postfix
- char *sms = strstr(dbv.pszVal, " SMS");
- if (sms) *sms = 0;
+ // Readup Phone (fixed: uses stored editable phones)
+ if (!db_get_s(hContact, "UserInfo", "MyPhone0", &dbv, DBVT_ASCIIZ))
+ {
+ // Remove SMS postfix
+ char *sms = strstr(dbv.pszVal, " SMS");
+ if (sms) *sms = 0;
- string_append(s, dbv.pszVal);
- db_free(&dbv);
- }
- string_append_c(s, ';');
- // Readup Group
- if (!db_get_s(hContact, "CList", "Group", &dbv, DBVT_ASCIIZ))
- {
- string_append(s, dbv.pszVal);
- db_free(&dbv);
- }
- string_append_c(s, ';');
- // Readup Uin
- string_append(s, ditoa(db_get_dw(hContact, gg->m_szModuleName, GG_KEY_UIN, 0)));
- string_append_c(s, ';');
- // Readup Mail (fixed: uses stored editable mails)
- if (!db_get_s(hContact, "UserInfo", "Mye-mail0", &dbv, DBVT_ASCIIZ))
- {
- string_append(s, dbv.pszVal);
- db_free(&dbv);
- }
- if (cr)
- string_append(s, ";0;;0;\r\n");
- else
- string_append(s, ";0;;0;\n");
+ string_append(s, dbv.pszVal);
+ db_free(&dbv);
+ }
+ string_append_c(s, ';');
+ // Readup Group
+ if (!db_get_s(hContact, "CList", "Group", &dbv, DBVT_ASCIIZ))
+ {
+ string_append(s, dbv.pszVal);
+ db_free(&dbv);
+ }
+ string_append_c(s, ';');
+ // Readup Uin
+ string_append(s, ditoa(db_get_dw(hContact, gg->m_szModuleName, GG_KEY_UIN, 0)));
+ string_append_c(s, ';');
+ // Readup Mail (fixed: uses stored editable mails)
+ if (!db_get_s(hContact, "UserInfo", "Mye-mail0", &dbv, DBVT_ASCIIZ))
+ {
+ string_append(s, dbv.pszVal);
+ db_free(&dbv);
}
+ if (cr)
+ string_append(s, ";0;;0;\r\n");
+ else
+ string_append(s, ";0;;0;\n");
}
contacts = string_free(s, 0);
diff --git a/protocols/IRCG/src/clist.cpp b/protocols/IRCG/src/clist.cpp
index a60353a8e5..9ea40c9512 100644
--- a/protocols/IRCG/src/clist.cpp
+++ b/protocols/IRCG/src/clist.cpp
@@ -144,24 +144,22 @@ bool CIrcProto::CList_SetAllOffline(BYTE ChatsToo)
DisconnectAllDCCSessions(false);
- 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 ) {
- if ( ChatsToo )
- setWord(hContact, "Status", ID_STATUS_OFFLINE);
- }
- else if ( !getTString( hContact, "Default", &dbv )) {
- setTString( hContact, "Nick", dbv.ptszVal);
- setWord( hContact, "Status", ID_STATUS_OFFLINE );
- db_free( &dbv );
- }
- db_unset( hContact, m_szModuleName, "IP" );
- setString( hContact, "User", "" );
- setString( hContact, "Host", "" );
- }
+ for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
+ if ( getByte( hContact, "ChatRoom", 0 ))
+ continue;
+
+ if ( getByte(hContact, "DCC", 0 ) != 0 ) {
+ if ( ChatsToo )
+ setWord(hContact, "Status", ID_STATUS_OFFLINE);
+ }
+ else if ( !getTString( hContact, "Default", &dbv )) {
+ setTString( hContact, "Nick", dbv.ptszVal);
+ setWord( hContact, "Status", ID_STATUS_OFFLINE );
+ db_free( &dbv );
}
+ db_unset( hContact, m_szModuleName, "IP" );
+ setString( hContact, "User", "" );
+ setString( hContact, "Host", "" );
}
return true;
}
@@ -180,64 +178,62 @@ HANDLE CIrcProto::CList_FindContact (CONTACT* user)
DBVARIANT dbv4;
DBVARIANT dbv5;
- 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;
- TCHAR* DBDefault = NULL;
- TCHAR* DBNick = NULL;
- TCHAR* DBWildcard = NULL;
- TCHAR* DBUser = NULL;
- TCHAR* DBHost = NULL;
- if ( !getTString(hContact, "Default", &dbv1)) DBDefault = dbv1.ptszVal;
- if ( !getTString(hContact, "Nick", &dbv2)) DBNick = dbv2.ptszVal;
- if ( !getTString(hContact, "UWildcard", &dbv3)) DBWildcard = dbv3.ptszVal;
- if ( !getTString(hContact, "UUser", &dbv4)) DBUser = dbv4.ptszVal;
- if ( !getTString(hContact, "UHost", &dbv5)) DBHost = dbv5.ptszVal;
+ for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
+ if ( getByte( hContact, "ChatRoom", 0))
+ continue;
+
+ HANDLE hContact_temp = NULL;
+ TCHAR* DBDefault = NULL;
+ TCHAR* DBNick = NULL;
+ TCHAR* DBWildcard = NULL;
+ TCHAR* DBUser = NULL;
+ TCHAR* DBHost = NULL;
+ if ( !getTString(hContact, "Default", &dbv1)) DBDefault = dbv1.ptszVal;
+ if ( !getTString(hContact, "Nick", &dbv2)) DBNick = dbv2.ptszVal;
+ if ( !getTString(hContact, "UWildcard", &dbv3)) DBWildcard = dbv3.ptszVal;
+ if ( !getTString(hContact, "UUser", &dbv4)) DBUser = dbv4.ptszVal;
+ if ( !getTString(hContact, "UHost", &dbv5)) DBHost = dbv5.ptszVal;
- if ( DBWildcard )
- CharLower( DBWildcard );
- if ( IsChannel( user->name )) {
- if ( DBDefault && !lstrcmpi( DBDefault, user->name ))
- hContact_temp = (HANDLE)-1;
- }
- else if ( user->ExactNick && DBNick && !lstrcmpi( DBNick, user->name ))
- hContact_temp = hContact;
+ if ( DBWildcard )
+ CharLower( DBWildcard );
+ if ( IsChannel( user->name )) {
+ if ( DBDefault && !lstrcmpi( DBDefault, user->name ))
+ hContact_temp = (HANDLE)-1;
+ }
+ else if ( user->ExactNick && DBNick && !lstrcmpi( DBNick, user->name ))
+ hContact_temp = hContact;
- else if ( user->ExactOnly && DBDefault && !lstrcmpi( DBDefault, user->name ))
- hContact_temp = hContact;
+ else if ( user->ExactOnly && DBDefault && !lstrcmpi( DBDefault, user->name ))
+ hContact_temp = hContact;
- else if ( user->ExactWCOnly ) {
- if ( DBWildcard && !lstrcmpi( DBWildcard, lowercasename )
- || ( DBWildcard && !lstrcmpi( DBNick, lowercasename ) && !WCCmp( DBWildcard, lowercasename ))
- || ( !DBWildcard && !lstrcmpi(DBNick, lowercasename)))
- {
- hContact_temp = hContact;
- }
- }
- else if ( _tcschr(user->name, ' ' ) == 0 ) {
- if (( DBDefault && !lstrcmpi(DBDefault, user->name) || DBNick && !lstrcmpi(DBNick, user->name) ||
- DBWildcard && WCCmp( DBWildcard, lowercasename ))
- && ( WCCmp(DBUser, user->user) && WCCmp(DBHost, user->host)))
- {
- hContact_temp = hContact;
- } }
-
- if ( DBDefault ) db_free(&dbv1);
- if ( DBNick ) db_free(&dbv2);
- if ( DBWildcard ) db_free(&dbv3);
- if ( DBUser ) db_free(&dbv4);
- if ( DBHost ) db_free(&dbv5);
-
- if ( hContact_temp != NULL ) {
- mir_free(lowercasename);
- if ( hContact_temp != (HANDLE)-1 )
- return hContact_temp;
- return 0;
- }
+ else if ( user->ExactWCOnly ) {
+ if ( DBWildcard && !lstrcmpi( DBWildcard, lowercasename )
+ || ( DBWildcard && !lstrcmpi( DBNick, lowercasename ) && !WCCmp( DBWildcard, lowercasename ))
+ || ( !DBWildcard && !lstrcmpi(DBNick, lowercasename)))
+ {
+ hContact_temp = hContact;
}
}
+ else if ( _tcschr(user->name, ' ' ) == 0 ) {
+ if (( DBDefault && !lstrcmpi(DBDefault, user->name) || DBNick && !lstrcmpi(DBNick, user->name) ||
+ DBWildcard && WCCmp( DBWildcard, lowercasename ))
+ && ( WCCmp(DBUser, user->user) && WCCmp(DBHost, user->host)))
+ {
+ hContact_temp = hContact;
+ } }
+
+ if ( DBDefault ) db_free(&dbv1);
+ if ( DBNick ) db_free(&dbv2);
+ if ( DBWildcard ) db_free(&dbv3);
+ if ( DBUser ) db_free(&dbv4);
+ if ( DBHost ) db_free(&dbv5);
+
+ if ( hContact_temp != NULL ) {
+ mir_free(lowercasename);
+ if ( hContact_temp != (HANDLE)-1 )
+ return hContact_temp;
+ return 0;
+ }
}
mir_free(lowercasename);
return 0;
diff --git a/protocols/IRCG/src/commandmonitor.cpp b/protocols/IRCG/src/commandmonitor.cpp
index e91473722a..085431f8de 100644
--- a/protocols/IRCG/src/commandmonitor.cpp
+++ b/protocols/IRCG/src/commandmonitor.cpp
@@ -139,42 +139,46 @@ VOID CALLBACK OnlineNotifTimerProc( HWND, UINT, UINT_PTR idEvent, DWORD )
if ( name.IsEmpty() && name2.IsEmpty()) {
DBVARIANT dbv;
- 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);
- BYTE bHidden = db_get_b(hContact,"CList", "Hidden", 0);
- if ( bDCC == 0 && bHidden == 0 ) {
- if ( !ppro->getTString( hContact, "Default", &dbv )) {
- BYTE bAdvanced = ppro->getByte(hContact, "AdvancedMode", 0) ;
- if ( !bAdvanced ) {
- db_free( &dbv );
- if ( !ppro->getTString( hContact, "Nick", &dbv )) {
- ppro->m_namesToUserhost += CMString(dbv.ptszVal) + _T(" ");
- db_free( &dbv );
- }
- }
- else {
- db_free( &dbv );
- DBVARIANT dbv2;
+ for (HANDLE hContact = db_find_first(ppro->m_szModuleName); hContact; hContact = db_find_next(hContact, ppro->m_szModuleName)) {
+ if ( ppro->getByte(hContact, "ChatRoom", 0))
+ continue;
+
+ BYTE bDCC = ppro->getByte(hContact, "DCC", 0);
+ BYTE bHidden = db_get_b(hContact,"CList", "Hidden", 0);
+ if ( bDCC || bHidden)
+ continue;
+ if ( ppro->getTString( hContact, "Default", &dbv ))
+ continue;
+
+ BYTE bAdvanced = ppro->getByte(hContact, "AdvancedMode", 0) ;
+ if ( !bAdvanced ) {
+ db_free( &dbv );
+ if ( !ppro->getTString( hContact, "Nick", &dbv )) {
+ ppro->m_namesToUserhost += CMString(dbv.ptszVal) + _T(" ");
+ db_free( &dbv );
+ }
+ }
+ else {
+ db_free( &dbv );
+ DBVARIANT dbv2;
- TCHAR* DBNick = NULL;
- TCHAR* DBWildcard = NULL;
- if ( !ppro->getTString( hContact, "Nick", &dbv ))
- DBNick = dbv.ptszVal;
- if ( !ppro->getTString( hContact, "UWildcard", &dbv2 ))
- DBWildcard = dbv2.ptszVal;
-
- if ( DBNick && ( !DBWildcard || !WCCmp(CharLower(DBWildcard), CharLower(DBNick))))
- ppro->m_namesToWho += CMString(DBNick) + _T(" ");
- else if ( DBWildcard )
- ppro->m_namesToWho += CMString(DBWildcard) + _T(" ");
-
- if ( DBNick ) db_free(&dbv);
- if ( DBWildcard ) db_free(&dbv2);
- } } } } } } }
+ TCHAR* DBNick = NULL;
+ TCHAR* DBWildcard = NULL;
+ if ( !ppro->getTString( hContact, "Nick", &dbv ))
+ DBNick = dbv.ptszVal;
+ if ( !ppro->getTString( hContact, "UWildcard", &dbv2 ))
+ DBWildcard = dbv2.ptszVal;
+
+ if ( DBNick && ( !DBWildcard || !WCCmp(CharLower(DBWildcard), CharLower(DBNick))))
+ ppro->m_namesToWho += CMString(DBNick) + _T(" ");
+ else if ( DBWildcard )
+ ppro->m_namesToWho += CMString(DBWildcard) + _T(" ");
+
+ if ( DBNick ) db_free(&dbv);
+ if ( DBWildcard ) db_free(&dbv2);
+ }
+ }
+ }
if ( ppro->m_namesToWho.IsEmpty() && ppro->m_namesToUserhost.IsEmpty()) {
ppro->SetChatTimer( ppro->OnlineNotifTimer, 60*1000, OnlineNotifTimerProc );
diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp
index 6a8adbc714..ff98ee0034 100644
--- a/protocols/JabberG/src/jabber_chat.cpp
+++ b/protocols/JabberG/src/jabber_chat.cpp
@@ -817,20 +817,17 @@ public:
HWND hwndList = GetDlgItem(m_hwnd, IDC_CLIST);
// invite users from roster
- 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 (int hItem = SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0))
- {
- if (SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)hItem, 0))
- {
- DBVARIANT dbv={0};
- m_proto->JGetStringT(hContact, "jid", &dbv);
- if (dbv.ptszVal && (dbv.type == DBVT_ASCIIZ || dbv.type == DBVT_WCHAR))
- InviteUser(dbv.ptszVal, text);
- db_free(&dbv);
- }
+ for (HANDLE hContact = db_find_first(m_proto->m_szModuleName); hContact; hContact = db_find_next(hContact, m_proto->m_szModuleName)) {
+ if ( db_get_b(hContact, m_proto->m_szModuleName, "ChatRoom", 0))
+ continue;
+
+ if (int hItem = SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0)) {
+ if (SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)hItem, 0)) {
+ DBVARIANT dbv={0};
+ m_proto->JGetStringT(hContact, "jid", &dbv);
+ if (dbv.ptszVal && (dbv.type == DBVT_ASCIIZ || dbv.type == DBVT_WCHAR))
+ InviteUser(dbv.ptszVal, text);
+ db_free(&dbv);
}
}
}
diff --git a/protocols/JabberG/src/jabber_icolib.cpp b/protocols/JabberG/src/jabber_icolib.cpp
index ea7203bd5d..e1a582c51b 100644
--- a/protocols/JabberG/src/jabber_icolib.cpp
+++ b/protocols/JabberG/src/jabber_icolib.cpp
@@ -462,14 +462,14 @@ BOOL CJabberProto::DBCheckIsTransportedContact(const TCHAR *jid, HANDLE hContact
void CJabberProto::CheckAllContactsAreTransported()
{
- 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);
-} } } }
+ for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
+ DBVARIANT dbv;
+ if ( !JGetStringT(hContact, "jid", &dbv)) {
+ DBCheckIsTransportedContact(dbv.ptszVal, hContact);
+ db_free(&dbv);
+ }
+ }
+}
/////////////////////////////////////////////////////////////////////////////////////////
// Cross-instance shared icons
diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp
index eced1ebbd9..3dbfd2d69d 100644
--- a/protocols/JabberG/src/jabber_iqid.cpp
+++ b/protocols/JabberG/src/jabber_iqid.cpp
@@ -535,24 +535,21 @@ void CJabberProto::OnIqResultGetRoster(HXML iqNode, CJabberIqInfo* pInfo)
if (m_options.RosterSync == TRUE) {
int listSize = 0, listAllocSize = 0;
HANDLE* list = 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;
- if ( !JGetStringT(hContact, "jid", &dbv)) {
- if ( !ListExist(LIST_ROSTER, dbv.ptszVal)) {
- Log("Syncing roster: preparing to delete %S (hContact=0x%x)", dbv.ptszVal, hContact);
- if (listSize >= listAllocSize) {
- listAllocSize = listSize + 100;
- if ((list=(HANDLE *) mir_realloc(list, listAllocSize * sizeof(HANDLE))) == NULL) {
- listSize = 0;
- break;
- } }
-
- list[listSize++] = hContact;
- }
- db_free(&dbv);
+ for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
+ DBVARIANT dbv;
+ if ( !JGetStringT(hContact, "jid", &dbv)) {
+ if ( !ListExist(LIST_ROSTER, dbv.ptszVal)) {
+ Log("Syncing roster: preparing to delete %S (hContact=0x%x)", dbv.ptszVal, hContact);
+ if (listSize >= listAllocSize) {
+ listAllocSize = listSize + 100;
+ if ((list=(HANDLE *) mir_realloc(list, listAllocSize * sizeof(HANDLE))) == NULL) {
+ listSize = 0;
+ break;
+ } }
+
+ list[listSize++] = hContact;
}
+ db_free(&dbv);
}
}
diff --git a/protocols/JabberG/src/jabber_misc.cpp b/protocols/JabberG/src/jabber_misc.cpp
index 10d23186a4..935662d9f6 100644
--- a/protocols/JabberG/src/jabber_misc.cpp
+++ b/protocols/JabberG/src/jabber_misc.cpp
@@ -157,7 +157,6 @@ HANDLE CJabberProto::DBCreateContact(const TCHAR *jid, const TCHAR *nick, BOOL t
HANDLE hContact;
TCHAR* s, *p, *q;
size_t len;
- char *szProto;
if (jid==NULL || jid[0]=='\0')
return NULL;
@@ -174,18 +173,15 @@ 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
- for (hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- szProto = GetContactProto(hContact);
- if (szProto!=NULL && !strcmp(m_szModuleName, szProto)) {
- DBVARIANT dbv;
- if ( !JGetStringT(hContact, "jid", &dbv)) {
- p = dbv.ptszVal;
- if (p && _tcslen(p)>=len && (p[len]=='\0'||p[len]=='/') && !_tcsnicmp(p, s, len)) {
- db_free(&dbv);
- break;
- }
+ for (hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
+ DBVARIANT dbv;
+ if ( !JGetStringT(hContact, "jid", &dbv)) {
+ p = dbv.ptszVal;
+ if (p && _tcslen(p) >= len && (p[len]=='\0'||p[len]=='/') && !_tcsnicmp(p, s, len)) {
db_free(&dbv);
+ break;
}
+ db_free(&dbv);
}
}
@@ -318,13 +314,9 @@ void CJabberProto::ResolveTransportNicks(const TCHAR *jid)
// Set all contacts to offline
HANDLE hContact = m_ThreadInfo->resolveContact;
if (hContact == NULL)
- hContact = (HANDLE)db_find_first();
-
- for (; hContact != NULL; hContact = db_find_next(hContact)) {
- char *szProto = GetContactProto(hContact);
- if (lstrcmpA(szProto, m_szModuleName))
- continue;
+ hContact = (HANDLE)db_find_first(m_szModuleName);
+ for (; hContact != NULL; hContact = db_find_next(hContact, m_szModuleName)) {
if ( !JGetByte(hContact, "IsTransported", 0))
continue;
diff --git a/protocols/JabberG/src/jabber_opt.cpp b/protocols/JabberG/src/jabber_opt.cpp
index dbe3ca3d1f..e3397736fe 100644
--- a/protocols/JabberG/src/jabber_opt.cpp
+++ b/protocols/JabberG/src/jabber_opt.cpp
@@ -1057,39 +1057,36 @@ void CJabberProto::_RosterHandleGetRequest(HXML node)
}
// now it is require to process whole contact list to add not in roster contacts
- 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');
+ for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, 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);
}
}
rrud.bReadyToDownload = FALSE;
diff --git a/protocols/JabberG/src/jabber_privacy.cpp b/protocols/JabberG/src/jabber_privacy.cpp
index 39da2ae3f1..2e4e1bd282 100644
--- a/protocols/JabberG/src/jabber_privacy.cpp
+++ b/protocols/JabberG/src/jabber_privacy.cpp
@@ -432,14 +432,11 @@ public:
SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_RESETCONTENT, 0, 0);
- 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)) {
- DBVARIANT dbv;
- if ( !m_proto->JGetStringT(hContact, "jid", &dbv)) {
- SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_ADDSTRING, 0, (LPARAM)dbv.ptszVal);
- db_free(&dbv);
- }
+ for (HANDLE hContact = db_find_first(m_proto->m_szModuleName); hContact; hContact = db_find_next(hContact, m_proto->m_szModuleName)) {
+ DBVARIANT dbv;
+ if ( !m_proto->JGetStringT(hContact, "jid", &dbv)) {
+ SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUES, CB_ADDSTRING, 0, (LPARAM)dbv.ptszVal);
+ db_free(&dbv);
}
}
@@ -1359,12 +1356,9 @@ void CJabberDlgPrivacyLists::CListResetOptions(HWND)
void CJabberDlgPrivacyLists::CListFilter(HWND)
{
- 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))
- m_clcClist.DeleteItem(hItem);
- }
+ for (HANDLE hContact = db_find_first(m_proto->m_szModuleName); hContact; hContact = db_find_next(hContact, m_proto->m_szModuleName))
+ if (HANDLE hItem = m_clcClist.FindContact(hContact))
+ m_clcClist.DeleteItem(hItem);
}
bool CJabberDlgPrivacyLists::CListIsGroup(HANDLE hGroup)
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp
index 25e9da3411..aa705faea9 100644
--- a/protocols/JabberG/src/jabber_proto.cpp
+++ b/protocols/JabberG/src/jabber_proto.cpp
@@ -328,21 +328,22 @@ int CJabberProto::OnModulesLoadedEx(WPARAM, LPARAM)
CheckAllContactsAreTransported();
// Set all contacts to offline
- 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);
-
- if (JGetByte(hContact, "IsTransport", 0)) {
- DBVARIANT dbv;
- if ( !JGetStringT(hContact, "jid", &dbv)) {
- TCHAR* domain = NEWTSTR_ALLOCA(dbv.ptszVal);
- TCHAR* resourcepos = _tcschr(domain, '/');
- if (resourcepos != NULL)
- *resourcepos = '\0';
- m_lstTransports.insert(mir_tstrdup(domain));
- db_free(&dbv);
- } } } }
+ for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
+ SetContactOfflineStatus(hContact);
+
+ if ( !JGetByte(hContact, "IsTransport", 0))
+ continue;
+
+ DBVARIANT dbv;
+ if ( !JGetStringT(hContact, "jid", &dbv)) {
+ TCHAR* domain = NEWTSTR_ALLOCA(dbv.ptszVal);
+ TCHAR* resourcepos = _tcschr(domain, '/');
+ if (resourcepos != NULL)
+ *resourcepos = '\0';
+ m_lstTransports.insert(mir_tstrdup(domain));
+ db_free(&dbv);
+ }
+ }
CleanLastResourceMap();
return 0;
diff --git a/protocols/JabberG/src/jabber_rc.cpp b/protocols/JabberG/src/jabber_rc.cpp
index 0081409290..05adbeb2e6 100644
--- a/protocols/JabberG/src/jabber_rc.cpp
+++ b/protocols/JabberG/src/jabber_rc.cpp
@@ -477,31 +477,28 @@ int CJabberProto::AdhocOptionsHandler(HXML, CJabberIqInfo* pInfo, CJabberAdhocSe
int CJabberProto::RcGetUnreadEventsCount()
{
int nEventsSent = 0;
- 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;
- if ( !JGetStringT(hContact, "jid", &dbv)) {
- HANDLE hDbEvent = db_event_firstUnread(hContact);
- while (hDbEvent) {
- DBEVENTINFO dbei = { sizeof(dbei) };
- dbei.cbBlob = db_event_getBlobSize(hDbEvent);
- if (dbei.cbBlob != -1) {
- dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob + 1);
- int nGetTextResult = db_event_get(hDbEvent, &dbei);
- if ( !nGetTextResult && dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_READ) && !(dbei.flags & DBEF_SENT)) {
- TCHAR* szEventText = DbGetEventTextT(&dbei, CP_ACP);
- if (szEventText) {
- nEventsSent++;
- mir_free(szEventText);
- }
+ for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
+ DBVARIANT dbv;
+ if ( !JGetStringT(hContact, "jid", &dbv)) {
+ HANDLE hDbEvent = db_event_firstUnread(hContact);
+ while (hDbEvent) {
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ dbei.cbBlob = db_event_getBlobSize(hDbEvent);
+ if (dbei.cbBlob != -1) {
+ dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob + 1);
+ int nGetTextResult = db_event_get(hDbEvent, &dbei);
+ if ( !nGetTextResult && dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_READ) && !(dbei.flags & DBEF_SENT)) {
+ TCHAR* szEventText = DbGetEventTextT(&dbei, CP_ACP);
+ if (szEventText) {
+ nEventsSent++;
+ mir_free(szEventText);
}
- mir_free(dbei.pBlob);
}
- hDbEvent = db_event_next(hDbEvent);
+ mir_free(dbei.pBlob);
}
- db_free(&dbv);
+ hDbEvent = db_event_next(hDbEvent);
}
+ db_free(&dbv);
}
}
return nEventsSent;
@@ -571,63 +568,61 @@ int CJabberProto::AdhocForwardHandler(HXML, CJabberIqInfo* pInfo, CJabberAdhocSe
m_options.RcMarkMessagesAsRead = bRemoveCListEvents ? 1 : 0;
int nEventsSent = 0;
- 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;
- if ( !JGetStringT(hContact, "jid", &dbv)) {
- HANDLE hDbEvent = db_event_firstUnread(hContact);
- while (hDbEvent) {
- DBEVENTINFO dbei = { 0 };
- dbei.cbSize = sizeof(dbei);
- dbei.cbBlob = db_event_getBlobSize(hDbEvent);
- if (dbei.cbBlob != -1) {
- dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob + 1);
- int nGetTextResult = db_event_get(hDbEvent, &dbei);
- if ( !nGetTextResult && dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_READ) && !(dbei.flags & DBEF_SENT)) {
- TCHAR* szEventText = DbGetEventTextT(&dbei, CP_ACP);
- if (szEventText) {
- XmlNode msg(_T("message"));
- msg << XATTR(_T("to"), pInfo->GetFrom()) << XATTRID(SerialNext())
- << XCHILD(_T("body"), szEventText);
-
- HXML addressesNode = msg << XCHILDNS(_T("addresses"), _T(JABBER_FEAT_EXT_ADDRESSING));
- TCHAR szOFrom[ JABBER_MAX_JID_LEN ];
- EnterCriticalSection(&m_csLastResourceMap);
- TCHAR *szOResource = FindLastResourceByDbEvent(hDbEvent);
- if (szOResource)
- mir_sntprintf(szOFrom, SIZEOF(szOFrom), _T("%s/%s"), dbv.ptszVal, szOResource);
- else
- mir_sntprintf(szOFrom, SIZEOF(szOFrom), _T("%s"), dbv.ptszVal);
- LeaveCriticalSection(&m_csLastResourceMap);
- addressesNode << XCHILD(_T("address")) << XATTR(_T("type"), _T("ofrom")) << XATTR(_T("jid"), szOFrom);
- addressesNode << XCHILD(_T("address")) << XATTR(_T("type"), _T("oto")) << XATTR(_T("jid"), m_ThreadInfo->fullJID);
-
- time_t ltime = (time_t)dbei.timestamp;
- struct tm *gmt = gmtime(&ltime);
- TCHAR stime[ 512 ];
- wsprintf(stime, _T("%.4i-%.2i-%.2iT%.2i:%.2i:%.2iZ"), gmt->tm_year + 1900, gmt->tm_mon + 1, gmt->tm_mday,
- gmt->tm_hour, gmt->tm_min, gmt->tm_sec);
- msg << XCHILDNS(_T("delay"), _T("urn:xmpp:delay")) << XATTR(_T("stamp"), stime);
-
- m_ThreadInfo->send(msg);
-
- nEventsSent++;
-
- db_event_markRead(hContact, hDbEvent);
- if (bRemoveCListEvents)
- CallService(MS_CLIST_REMOVEEVENT, (WPARAM)hContact, (LPARAM)hDbEvent);
-
- mir_free(szEventText);
- }
- }
- mir_free(dbei.pBlob);
+ for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
+ DBVARIANT dbv;
+ if ( JGetStringT(hContact, "jid", &dbv))
+ continue;
+
+ HANDLE hDbEvent = db_event_firstUnread(hContact);
+ while (hDbEvent) {
+ DBEVENTINFO dbei = { 0 };
+ dbei.cbSize = sizeof(dbei);
+ dbei.cbBlob = db_event_getBlobSize(hDbEvent);
+ if (dbei.cbBlob != -1) {
+ dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob + 1);
+ int nGetTextResult = db_event_get(hDbEvent, &dbei);
+ if ( !nGetTextResult && dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & DBEF_READ) && !(dbei.flags & DBEF_SENT)) {
+ TCHAR* szEventText = DbGetEventTextT(&dbei, CP_ACP);
+ if (szEventText) {
+ XmlNode msg(_T("message"));
+ msg << XATTR(_T("to"), pInfo->GetFrom()) << XATTRID(SerialNext())
+ << XCHILD(_T("body"), szEventText);
+
+ HXML addressesNode = msg << XCHILDNS(_T("addresses"), _T(JABBER_FEAT_EXT_ADDRESSING));
+ TCHAR szOFrom[ JABBER_MAX_JID_LEN ];
+ EnterCriticalSection(&m_csLastResourceMap);
+ TCHAR *szOResource = FindLastResourceByDbEvent(hDbEvent);
+ if (szOResource)
+ mir_sntprintf(szOFrom, SIZEOF(szOFrom), _T("%s/%s"), dbv.ptszVal, szOResource);
+ else
+ mir_sntprintf(szOFrom, SIZEOF(szOFrom), _T("%s"), dbv.ptszVal);
+ LeaveCriticalSection(&m_csLastResourceMap);
+ addressesNode << XCHILD(_T("address")) << XATTR(_T("type"), _T("ofrom")) << XATTR(_T("jid"), szOFrom);
+ addressesNode << XCHILD(_T("address")) << XATTR(_T("type"), _T("oto")) << XATTR(_T("jid"), m_ThreadInfo->fullJID);
+
+ time_t ltime = (time_t)dbei.timestamp;
+ struct tm *gmt = gmtime(&ltime);
+ TCHAR stime[ 512 ];
+ wsprintf(stime, _T("%.4i-%.2i-%.2iT%.2i:%.2i:%.2iZ"), gmt->tm_year + 1900, gmt->tm_mon + 1, gmt->tm_mday,
+ gmt->tm_hour, gmt->tm_min, gmt->tm_sec);
+ msg << XCHILDNS(_T("delay"), _T("urn:xmpp:delay")) << XATTR(_T("stamp"), stime);
+
+ m_ThreadInfo->send(msg);
+
+ nEventsSent++;
+
+ db_event_markRead(hContact, hDbEvent);
+ if (bRemoveCListEvents)
+ CallService(MS_CLIST_REMOVEEVENT, (WPARAM)hContact, (LPARAM)hDbEvent);
+
+ mir_free(szEventText);
}
- hDbEvent = db_event_next(hDbEvent);
}
- db_free(&dbv);
+ mir_free(dbei.pBlob);
}
+ hDbEvent = db_event_next(hDbEvent);
}
+ db_free(&dbv);
}
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 85cc395218..f1331af187 100644
--- a/protocols/JabberG/src/jabber_thread.cpp
+++ b/protocols/JabberG/src/jabber_thread.cpp
@@ -595,11 +595,9 @@ recvRest:
JSendBroadcast(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus);
// Set all contacts to offline
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- if ( !lstrcmpA(GetContactProto(hContact), m_szModuleName)) {
- SetContactOfflineStatus(hContact);
- MenuHideSrmmIcon(hContact);
- }
+ for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
+ SetContactOfflineStatus(hContact);
+ MenuHideSrmmIcon(hContact);
}
mir_free(m_szJabberJID);
diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp
index 2f5a02f792..35acf12005 100644
--- a/protocols/JabberG/src/jabber_util.cpp
+++ b/protocols/JabberG/src/jabber_util.cpp
@@ -72,27 +72,23 @@ void CJabberProto::Log(const char* fmt, ...)
HANDLE CJabberProto::ChatRoomHContactFromJID(const TCHAR *jid)
{
if (jid == NULL)
- return (HANDLE)NULL;
+ return NULL;
- HANDLE hContactMatched = 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;
- int result = JGetStringT(hContact, "ChatRoomID", &dbv);
- if (result)
- result = JGetStringT(hContact, "jid", &dbv);
-
- if ( !result) {
- int result;
- result = lstrcmpi(jid, dbv.ptszVal);
- db_free(&dbv);
- if ( !result && JGetByte(hContact, "ChatRoom", 0) != 0) {
- hContactMatched = hContact;
- break;
- } } } }
+ for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
+ DBVARIANT dbv;
+ int result = JGetStringT(hContact, "ChatRoomID", &dbv);
+ if (result)
+ result = JGetStringT(hContact, "jid", &dbv);
- return hContactMatched;
+ if ( !result) {
+ int result;
+ result = lstrcmpi(jid, dbv.ptszVal);
+ db_free(&dbv);
+ if ( !result && JGetByte(hContact, "ChatRoom", 0) != 0)
+ return hContact;
+ } }
+
+ return NULL;
}
///////////////////////////////////////////////////////////////////////////////
@@ -105,44 +101,40 @@ HANDLE CJabberProto::HContactFromJID(const TCHAR *jid , BOOL bStripResource)
JABBER_LIST_ITEM* item = ListGetItemPtr(LIST_CHATROOM, jid);
- HANDLE hContactMatched = NULL;
+ for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
+ DBVARIANT dbv;
+ int result;
+ //safer way to check UID (coz some contact have both setting from convert to chat)
+ if (db_get_b(hContact, m_szModuleName, "ChatRoom",0))
+ result = JGetStringT(hContact, "ChatRoomID", &dbv);
+ else
+ result = JGetStringT(hContact, "jid", &dbv);
- 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;
+ if ( !result) {
int result;
- //safer way to check UID (coz some contact have both setting from convert to chat)
- if (db_get_b(hContact, szProto, "ChatRoom",0))
- result = JGetStringT(hContact, "ChatRoomID", &dbv);
- else
- result = JGetStringT(hContact, "jid", &dbv);
-
- if ( !result) {
- int result;
- if (item != NULL)
- result = lstrcmpi(jid, dbv.ptszVal);
- else {
- if (bStripResource == 3) {
- if (JGetByte(hContact, "ChatRoom", 0))
- result = lstrcmpi(jid, dbv.ptszVal); // for chat room we have to have full contact matched
- else if (TRUE)
- result = _tcsnicmp(jid, dbv.ptszVal, _tcslen(dbv.ptszVal));
- else
- result = JabberCompareJids(jid, dbv.ptszVal);
- }
- // most probably it should just look full matching contact
+ if (item != NULL)
+ result = lstrcmpi(jid, dbv.ptszVal);
+ else {
+ if (bStripResource == 3) {
+ if (JGetByte(hContact, "ChatRoom", 0))
+ result = lstrcmpi(jid, dbv.ptszVal); // for chat room we have to have full contact matched
+ else if (TRUE)
+ result = _tcsnicmp(jid, dbv.ptszVal, _tcslen(dbv.ptszVal));
else
- result = lstrcmpi(jid, dbv.ptszVal);
-
+ result = JabberCompareJids(jid, dbv.ptszVal);
}
- db_free(&dbv);
- if ( !result) {
- hContactMatched = hContact;
- break;
- } } } }
+ // most probably it should just look full matching contact
+ else
+ result = lstrcmpi(jid, dbv.ptszVal);
- return hContactMatched;
+ }
+ db_free(&dbv);
+ if ( !result)
+ return hContact;
+ }
+ }
+
+ return NULL;
}
TCHAR* __stdcall JabberNickFromJID(const TCHAR *jid)
diff --git a/protocols/MRA/src/Mra_functions.cpp b/protocols/MRA/src/Mra_functions.cpp
index 04fcac2504..1d2c70fde8 100644
--- a/protocols/MRA/src/Mra_functions.cpp
+++ b/protocols/MRA/src/Mra_functions.cpp
@@ -571,11 +571,9 @@ 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; hContact = db_find_next(hContact)) {
- if (IsContactMra(hContact))
+ for (hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
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)
- {
+ if (CompareStringA( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, szEMailLocal, dwEMailLocalSize, lpszEMail, dwEMailSize) == CSTR_EQUAL) {
if (bTemporary == FALSE) db_unset(hContact, "CList", "NotOnList");
bFound = TRUE;
break;
@@ -599,8 +597,7 @@ HANDLE CMraProto::MraHContactFromEmail(LPSTR lpszEMail, size_t dwEMailSize, BOOL
if (CallServiceSync(MS_GC_NEWSESSION, NULL, (LPARAM)&gcw) == 0) {
BOOL bChatAdded = FALSE;
- for (hContact = db_find_first();hContact != NULL;hContact = db_find_next(hContact)) {
- if (IsContactMra(hContact))
+ for (hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
if (mraGetStaticStringA(hContact, "ChatRoomID", szEMailLocal, SIZEOF(szEMailLocal), &dwEMailLocalSize))
if (CompareStringA( MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), NORM_IGNORECASE, szEMailLocal, dwEMailLocalSize, lpszEMail, dwEMailSize) == CSTR_EQUAL) {
bChatAdded = TRUE;
diff --git a/protocols/MRA/src/Mra_svcs.cpp b/protocols/MRA/src/Mra_svcs.cpp
index 5e42aa4222..075fd72040 100644
--- a/protocols/MRA/src/Mra_svcs.cpp
+++ b/protocols/MRA/src/Mra_svcs.cpp
@@ -220,10 +220,9 @@ 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; hContact = db_find_next(hContact)) {
+ for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
size_t dwEMailSize;
CHAR szEMail[MAX_EMAIL_LEN];
- if ( IsContactMra(hContact))
if ( mraGetStaticStringA(hContact, "e-mail", szEMail, SIZEOF(szEMail), &dwEMailSize))
MraWPRequestByEMail(hContact, ACKTYPE_GETINFO, szEMail, dwEMailSize);
}
@@ -234,11 +233,10 @@ 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; hContact = db_find_next(hContact)) {
+ for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
size_t dwEMailSize;
CHAR szEMail[MAX_EMAIL_LEN];
- if (IsContactMra(hContact))
if (mraGetStaticStringA(hContact, "e-mail", szEMail, SIZEOF(szEMail), &dwEMailSize))
if (IsEMailChatAgent(szEMail, dwEMailSize) == FALSE)// только для оптимизации, MraAvatarsQueueGetAvatarSimple сама умеет фильтровать чатконтакты
MraAvatarsQueueGetAvatarSimple(hAvatarsQueueHandle, 0/*GAIF_FORCE*/, hContact, 0);
@@ -253,7 +251,7 @@ INT_PTR CMraProto::MraRequestAuthForAll(WPARAM wParam, LPARAM lParam)
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)
+ if (dwContactSeverFlags & CONTACT_INTFLAG_NOT_AUTHORIZED && dwContactSeverFlags != -1)
MraRequestAuthorization((WPARAM)hContact, 0);
}
}
diff --git a/protocols/MSN/src/msn_lists.cpp b/protocols/MSN/src/msn_lists.cpp
index 74961195f7..1f6134e2b7 100644
--- a/protocols/MSN/src/msn_lists.cpp
+++ b/protocols/MSN/src/msn_lists.cpp
@@ -238,27 +238,19 @@ void CMsnProto::Lists_Remove(int list, const char* email)
void CMsnProto::Lists_Populate(void)
{
- HANDLE hContact = db_find_first();
- while (hContact != NULL)
- {
- HANDLE hContactN = db_find_next(hContact);
- if (MSN_IsMyContact(hContact))
- {
- char szEmail[MSN_MAX_EMAIL_LEN] = "";;
- if (getStaticString(hContact, "wlid", szEmail, sizeof(szEmail)))
- getStaticString(hContact, "e-mail", szEmail, sizeof(szEmail));
-
- if (szEmail[0])
- {
- bool localList = getByte(hContact, "LocalList", 0) != 0;
- if (localList)
- Lists_Add(LIST_LL, NETID_MSN, szEmail, hContact);
- else
- Lists_Add(0, NETID_UNKNOWN, szEmail, hContact);
- }
- else CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
+ for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
+ char szEmail[MSN_MAX_EMAIL_LEN] = "";;
+ if (getStaticString(hContact, "wlid", szEmail, sizeof(szEmail)))
+ getStaticString(hContact, "e-mail", szEmail, sizeof(szEmail));
+
+ if (szEmail[0]) {
+ bool localList = getByte(hContact, "LocalList", 0) != 0;
+ if (localList)
+ Lists_Add(LIST_LL, NETID_MSN, szEmail, hContact);
+ else
+ Lists_Add(0, NETID_UNKNOWN, szEmail, hContact);
}
- hContact = hContactN;
+ else CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
}
}
diff --git a/protocols/MSN/src/msn_proto.cpp b/protocols/MSN/src/msn_proto.cpp
index a9da564cf3..e2b1cf2763 100644
--- a/protocols/MSN/src/msn_proto.cpp
+++ b/protocols/MSN/src/msn_proto.cpp
@@ -92,13 +92,11 @@ CMsnProto::CMsnProto(const char* aProtoName, const TCHAR* aUserName) :
LoadOptions();
- 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");
- }
+ for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
+ deleteSetting(hContact, "Status");
+ deleteSetting(hContact, "IdleTS");
+ deleteSetting(hContact, "p2pMsgId");
+ deleteSetting(hContact, "AccList");
}
deleteSetting(NULL, "MobileEnabled");
deleteSetting(NULL, "MobileAllowed");
diff --git a/protocols/Tlen/src/jabber_iqid.cpp b/protocols/Tlen/src/jabber_iqid.cpp
index b77a367170..f0a35837c2 100644
--- a/protocols/Tlen/src/jabber_iqid.cpp
+++ b/protocols/Tlen/src/jabber_iqid.cpp
@@ -212,24 +212,22 @@ void JabberIqResultRoster(TlenProtocol *proto, XmlNode *iqNode)
listSize = listAllocSize = 0;
list = 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)) {
- if (!JabberListExist(proto, LIST_ROSTER, dbv.pszVal)) {
- JabberLog(proto, "Syncing roster: preparing to delete %s (hContact=0x%x)", dbv.pszVal, hContact);
- if (listSize >= listAllocSize) {
- listAllocSize = listSize + 100;
- if ((list=(HANDLE *) mir_realloc(list, listAllocSize)) == NULL) {
- listSize = 0;
- break;
- }
- }
- list[listSize++] = hContact;
+ for (HANDLE hContact = db_find_first(proto->m_szModuleName); hContact; hContact = db_find_next(hContact, proto->m_szModuleName)) {
+ if ( db_get(hContact, proto->m_szModuleName, "jid", &dbv))
+ continue;
+
+ if (!JabberListExist(proto, LIST_ROSTER, dbv.pszVal)) {
+ JabberLog(proto, "Syncing roster: preparing to delete %s (hContact=0x%x)", dbv.pszVal, hContact);
+ if (listSize >= listAllocSize) {
+ listAllocSize = listSize + 100;
+ if ((list=(HANDLE *) mir_realloc(list, listAllocSize)) == NULL) {
+ listSize = 0;
+ break;
}
- db_free(&dbv);
}
+ list[listSize++] = hContact;
}
+ db_free(&dbv);
}
for (i=0; i<listSize; i++) {
diff --git a/protocols/Tlen/src/jabber_misc.cpp b/protocols/Tlen/src/jabber_misc.cpp
index c20cc63c06..73ac847836 100644
--- a/protocols/Tlen/src/jabber_misc.cpp
+++ b/protocols/Tlen/src/jabber_misc.cpp
@@ -91,19 +91,17 @@ HANDLE JabberHContactFromJID(TlenProtocol *proto, const char *jid)
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)
- db_free(&dbv);
- return hContact;
- }
- }
+ for (HANDLE hContact = db_find_first(proto->m_szModuleName); hContact; hContact = db_find_next(hContact, proto->m_szModuleName)) {
+ if ( db_get(hContact, proto->m_szModuleName, "jid", &dbv))
+ continue;
+
+ if ((p=dbv.pszVal) != NULL) {
+ if (!stricmp(p, jid)) { // exact match (node@domain/resource)
db_free(&dbv);
+ return hContact;
}
}
+ db_free(&dbv);
}
return NULL;
diff --git a/protocols/Tlen/src/jabber_thread.cpp b/protocols/Tlen/src/jabber_thread.cpp
index 896bf29016..0cc09e86c4 100644
--- a/protocols/Tlen/src/jabber_thread.cpp
+++ b/protocols/Tlen/src/jabber_thread.cpp
@@ -274,18 +274,6 @@ void __cdecl JabberServerThread(ThreadData *info)
return;
}
- // Determine local IP
- /*
- socket = CallService(MS_NETLIB_GETSOCKET, (WPARAM) proto, 0);
- struct sockaddr_in saddr;
- int len;
-
- len = sizeof(saddr);
- getsockname(socket, (struct sockaddr *) &saddr, &len);
- jabberLocalIP = saddr.sin_addr.S_un.S_addr;
- JabberLog("Local IP = %s", inet_ntoa(saddr.sin_addr));
- */
-
// User may change status to OFFLINE while we are connecting above
if (info->proto->m_iDesiredStatus != ID_STATUS_OFFLINE) {
@@ -357,19 +345,15 @@ void __cdecl JabberServerThread(ThreadData *info)
Menu_ModifyItem(info->proto->hMenuChats, &mi);
// Set status to offline
+ char *szProto = info->proto->m_szModuleName;
oldStatus = info->proto->m_iStatus;
info->proto->m_iStatus = ID_STATUS_OFFLINE;
- ProtoBroadcastAck(info->proto->m_szModuleName, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE) oldStatus, info->proto->m_iStatus);
+ ProtoBroadcastAck(szProto, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE) oldStatus, info->proto->m_iStatus);
// Set all contacts to offline
- 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);
- }
- }
- }
+ for (HANDLE hContact = db_find_first(szProto); hContact; hContact = db_find_next(hContact, szProto))
+ if (db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE)
+ db_set_w(hContact, szProto, "Status", ID_STATUS_OFFLINE);
JabberListWipeSpecial(info->proto);
}
diff --git a/protocols/Tlen/src/tlen.cpp b/protocols/Tlen/src/tlen.cpp
index 8c76e78b42..19267b90c2 100644
--- a/protocols/Tlen/src/tlen.cpp
+++ b/protocols/Tlen/src/tlen.cpp
@@ -256,14 +256,9 @@ int TlenOnModulesLoaded(void *ptr, WPARAM wParam, LPARAM lParam)
TlenProtocol *proto = (TlenProtocol *)ptr;
/* Set all contacts to offline */
- 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);
- }
- }
- }
+ for (HANDLE hContact = db_find_first(proto->m_szModuleName); hContact; hContact = db_find_next(hContact, 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);
TlenMUCInit(proto);
sprintf(str, "%s", LPGEN("Incoming mail"));
diff --git a/protocols/Tlen/src/tlen_muc.cpp b/protocols/Tlen/src/tlen_muc.cpp
index bf18a4a5ce..9498f12ead 100644
--- a/protocols/Tlen/src/tlen_muc.cpp
+++ b/protocols/Tlen/src/tlen_muc.cpp
@@ -948,47 +948,48 @@ typedef struct {
static void __cdecl TlenMUCCSendQueryResultThread(void *ptr)
{
- MUCCQUERYRESULT queryResult;
DBVARIANT dbv;
MUCSENDQUERYTHREADDATA* threadData = (MUCSENDQUERYTHREADDATA*)ptr;
+ char *szProto = threadData->proto->m_szModuleName;
+
+ MUCCQUERYRESULT queryResult;
queryResult.cbSize = sizeof (MUCCQUERYRESULT);
queryResult.iType = MUCC_EVENT_QUERY_CONTACTS;
- queryResult.pszModule = threadData->proto->m_szModuleName;
+ queryResult.pszModule = szProto;
queryResult.pszParent = threadData->roomId;
queryResult.iItemsNum = 0;
- 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)) {
- if (!db_get(hContact, threadData->proto->m_szModuleName, "jid", &dbv)) {
- if (strcmp(dbv.pszVal, "b73@tlen.pl")) {
- queryResult.iItemsNum++;
- }
- db_free(&dbv);
- }
- }
+
+ for (HANDLE hContact = db_find_first(szProto); hContact; hContact = db_find_next(hContact, szProto)) {
+ if ( db_get_b(hContact, szProto, "bChat", FALSE))
+ continue;
+
+ if ( !db_get_s(hContact, szProto, "jid", &dbv)) {
+ if (strcmp(dbv.pszVal, "b73@tlen.pl"))
+ queryResult.iItemsNum++;
+
+ db_free(&dbv);
}
}
+
queryResult.pItems = (MUCCQUERYITEM*)mir_alloc(sizeof(MUCCQUERYITEM) * queryResult.iItemsNum);
memset(queryResult.pItems, 0, sizeof(MUCCQUERYITEM) * queryResult.iItemsNum);
queryResult.iItemsNum = 0;
- 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)) {
- if (!db_get(hContact, threadData->proto->m_szModuleName, "jid", &dbv)) {
- if (strcmp(dbv.pszVal, "b73@tlen.pl")) {
- queryResult.pItems[queryResult.iItemsNum].pszID = mir_strdup(dbv.pszVal);
- queryResult.pItems[queryResult.iItemsNum].pszName = mir_strdup((char *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) hContact, 0));
- queryResult.iItemsNum++;
- }
- db_free(&dbv);
- }
+ for (HANDLE hContact = db_find_first(szProto); hContact; hContact = db_find_next(hContact, szProto)) {
+ if ( db_get_b(hContact, szProto, "bChat", FALSE))
+ continue;
+
+ if (!db_get(hContact, szProto, "jid", &dbv)) {
+ if (strcmp(dbv.pszVal, "b73@tlen.pl")) {
+ queryResult.pItems[queryResult.iItemsNum].pszID = mir_strdup(dbv.pszVal);
+ queryResult.pItems[queryResult.iItemsNum].pszName = mir_strdup((char *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) hContact, 0));
+ queryResult.iItemsNum++;
}
+ db_free(&dbv);
}
}
+
CallService(MS_MUCC_QUERY_RESULT, 0, (LPARAM) &queryResult);
TlenMUCFreeQueryResult(&queryResult);
mir_free(threadData->roomId);
diff --git a/protocols/Twitter/src/chat.cpp b/protocols/Twitter/src/chat.cpp
index 8bb15b85e9..2f2baf6649 100644
--- a/protocols/Twitter/src/chat.cpp
+++ b/protocols/Twitter/src/chat.cpp
@@ -197,8 +197,8 @@ 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)) {
- if(!IsMyContact(hContact))
+ for(HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
+ if( db_get_b(hContact, m_szModuleName, "ChatRoom", 0))
continue;
DBVARIANT uid,nick;
diff --git a/protocols/Twitter/src/contacts.cpp b/protocols/Twitter/src/contacts.cpp
index 1eb1314086..3d4d7f9d58 100644
--- a/protocols/Twitter/src/contacts.cpp
+++ b/protocols/Twitter/src/contacts.cpp
@@ -221,9 +221,9 @@ bool TwitterProto::IsMyContact(HANDLE hContact,bool include_chat)
HANDLE TwitterProto::UsernameToHContact(const char *name)
{
- for(HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ for(HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName))
{
- if(!IsMyContact(hContact))
+ if( db_get_b(hContact, m_szModuleName, "ChatRoom", 0))
continue;
DBVARIANT dbv;
@@ -284,13 +284,9 @@ HANDLE TwitterProto::AddToClientList(const char *name,const char *status)
void TwitterProto::SetAllContactStatuses(int status)
{
- for(HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
- {
- if(!IsMyContact(hContact))
- continue;
-
- db_set_w(hContact,m_szModuleName,"Status",status);
- }
+ for(HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName))
+ if( !db_get_b(hContact, m_szModuleName, "ChatRoom", 0))
+ db_set_w(hContact,m_szModuleName,"Status",status);
SetChatStatus(status);
} \ No newline at end of file
diff --git a/protocols/Twitter/src/proto.cpp b/protocols/Twitter/src/proto.cpp
index 71d200b0cf..03b2538910 100644
--- a/protocols/Twitter/src/proto.cpp
+++ b/protocols/Twitter/src/proto.cpp
@@ -496,14 +496,9 @@ void TwitterProto::UpdateSettings()
if(in_chat_)
OnLeaveChat(0,0);
- for(HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
- {
- if(!IsMyContact(hContact,true))
- continue;
-
+ for(HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName))
if(db_get_b(hContact,m_szModuleName,"ChatRoom",0))
CallService(MS_DB_CONTACT_DELETE,reinterpret_cast<WPARAM>(hContact),0);
- }
}
}
diff --git a/protocols/Xfire/src/main.cpp b/protocols/Xfire/src/main.cpp
index d0024ef48f..c01716807b 100644
--- a/protocols/Xfire/src/main.cpp
+++ b/protocols/Xfire/src/main.cpp
@@ -1802,79 +1802,68 @@ BOOL IsXFireContact(HANDLE hContact)
HANDLE CList_FindContact (int uid)
{
- 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;
- }
- }
+ for (HANDLE hContact = db_find_first(protocolname); hContact; hContact = db_find_next(hContact, protocolname))
+ if ( db_get_dw(hContact, protocolname, "UserId", -1) == uid)
+ return hContact;
+
return 0;
}
void CList_MakeAllOffline()
{
vector<HANDLE> fhandles;
- 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
- //nur wenn das nicht abgestellt wurde
- if(db_get_b(hContact,protocolname,"friendoffriend",0)==1&&
- db_get_b(NULL,protocolname,"fofdbremove",0)==1)
- {
- fhandles.push_back(hContact);
- }
-
- db_unset(hContact, "CList", "StatusMsg");
- db_unset(hContact, protocolname, "ServerIP");
- db_unset(hContact, protocolname, "Port");
- db_unset(hContact, protocolname, "ServerName");
- db_unset(hContact, protocolname, "GameType");
- db_unset(hContact, protocolname, "Map");
- db_unset(hContact, protocolname, "Players");
- db_unset(hContact, protocolname, "Passworded");
-
- db_unset(hContact, protocolname, "XStatusMsg");
- db_unset(hContact, protocolname, "XStatusId");
- db_unset(hContact, protocolname, "XStatusName");
-
- if(db_get_b(NULL,protocolname,"noavatars",-1)==1)
- {
- db_unset(hContact, "ContactPhoto", "File");
- db_unset(hContact, "ContactPhoto", "RFile");
- db_unset(hContact, "ContactPhoto", "Backup");
- db_unset(hContact, "ContactPhoto", "Format");
- db_unset(hContact, "ContactPhoto", "ImageHash");
- db_unset(hContact, "ContactPhoto", "XFireAvatarId");
- db_unset(hContact, "ContactPhoto", "XFireAvatarMode");
- }
- else
+ for (HANDLE hContact = db_find_first(protocolname); hContact; hContact = db_find_next(hContact, protocolname)) {
+ //freunde von freunden in eine seperate liste setzen
+ //nur wenn das nicht abgestellt wurde
+ if(db_get_b(hContact,protocolname,"friendoffriend",0)==1 && db_get_b(NULL,protocolname,"fofdbremove",0)==1)
+ fhandles.push_back(hContact);
+
+ db_unset(hContact, "CList", "StatusMsg");
+ db_unset(hContact, protocolname, "ServerIP");
+ db_unset(hContact, protocolname, "Port");
+ db_unset(hContact, protocolname, "ServerName");
+ db_unset(hContact, protocolname, "GameType");
+ db_unset(hContact, protocolname, "Map");
+ db_unset(hContact, protocolname, "Players");
+ db_unset(hContact, protocolname, "Passworded");
+
+ db_unset(hContact, protocolname, "XStatusMsg");
+ db_unset(hContact, protocolname, "XStatusId");
+ db_unset(hContact, protocolname, "XStatusName");
+
+ if(db_get_b(NULL,protocolname,"noavatars",-1)==1)
+ {
+ db_unset(hContact, "ContactPhoto", "File");
+ db_unset(hContact, "ContactPhoto", "RFile");
+ db_unset(hContact, "ContactPhoto", "Backup");
+ db_unset(hContact, "ContactPhoto", "Format");
+ db_unset(hContact, "ContactPhoto", "ImageHash");
+ db_unset(hContact, "ContactPhoto", "XFireAvatarId");
+ db_unset(hContact, "ContactPhoto", "XFireAvatarMode");
+ }
+ else
+ {
+ //prьf ob der avatar noch existiert
+ DBVARIANT dbv;
+ if(!db_get_s(hContact, "ContactPhoto", "File",&dbv))
{
- //prьf ob der avatar noch existiert
- DBVARIANT dbv;
- if(!db_get_s(hContact, "ContactPhoto", "File",&dbv))
+ FILE*f=fopen(dbv.pszVal,"r");
+ if(f==NULL)
{
- FILE*f=fopen(dbv.pszVal,"r");
- if(f==NULL)
- {
- db_unset(hContact, "ContactPhoto", "File");
- db_unset(hContact, "ContactPhoto", "RFile");
- db_unset(hContact, "ContactPhoto", "Backup");
- db_unset(hContact, "ContactPhoto", "Format");
- db_unset(hContact, "ContactPhoto", "ImageHash");
- db_unset(hContact, "ContactPhoto", "XFireAvatarId");
- db_unset(hContact, "ContactPhoto", "XFireAvatarMode");
- }
- else
- {
- fclose(f);
- }
- db_free(&dbv);
+ db_unset(hContact, "ContactPhoto", "File");
+ db_unset(hContact, "ContactPhoto", "RFile");
+ db_unset(hContact, "ContactPhoto", "Backup");
+ db_unset(hContact, "ContactPhoto", "Format");
+ db_unset(hContact, "ContactPhoto", "ImageHash");
+ db_unset(hContact, "ContactPhoto", "XFireAvatarId");
+ db_unset(hContact, "ContactPhoto", "XFireAvatarMode");
}
+ else fclose(f);
+
+ db_free(&dbv);
}
- db_set_w(hContact,protocolname,"Status",ID_STATUS_OFFLINE);
}
+ db_set_w(hContact,protocolname,"Status",ID_STATUS_OFFLINE);
}
//alle gefundenen handles lsцchen
diff --git a/protocols/Yahoo/src/services.cpp b/protocols/Yahoo/src/services.cpp
index b7db4b3c8d..2e91c9fdb6 100644
--- a/protocols/Yahoo/src/services.cpp
+++ b/protocols/Yahoo/src/services.cpp
@@ -31,17 +31,14 @@
void CYahooProto::logoff_buddies()
{
//set all contacts to 'offline'
- 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);
- SetDword(hContact, "PictLastCheck", 0);
- SetDword(hContact, "PictLoading", 0);
- db_unset(hContact, "CList", "StatusMsg");
- db_unset(hContact, m_szModuleName, "YMsg");
- db_unset(hContact, m_szModuleName, "YGMsg");
- //db_unset(hContact, m_szModuleName, "MirVer");
- }
+ for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
+ SetWord( hContact, "Status", ID_STATUS_OFFLINE );
+ SetDword(hContact, "IdleTS", 0);
+ SetDword(hContact, "PictLastCheck", 0);
+ SetDword(hContact, "PictLoading", 0);
+ db_unset(hContact, "CList", "StatusMsg");
+ db_unset(hContact, m_szModuleName, "YMsg");
+ db_unset(hContact, m_szModuleName, "YGMsg");
}
}
diff --git a/protocols/Yahoo/src/yahoo.cpp b/protocols/Yahoo/src/yahoo.cpp
index 0f16a241e3..cfbff5ebfd 100644
--- a/protocols/Yahoo/src/yahoo.cpp
+++ b/protocols/Yahoo/src/yahoo.cpp
@@ -284,19 +284,17 @@ void CYahooProto::AddBuddy(HANDLE hContact, const char *group, const TCHAR *msg)
HANDLE CYahooProto::getbuddyH(const char *yahoo_id)
{
- 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;
-
- return hContact;
- }
+ for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
+ DBVARIANT dbv;
+ if (GetString(hContact, YAHOO_LOGINID, &dbv))
+ continue;
+
+ int tCompareResult = lstrcmpiA( dbv.pszVal, yahoo_id );
+ db_free( &dbv );
+ if ( tCompareResult )
+ continue;
+
+ return hContact;
}
return NULL;
@@ -604,39 +602,37 @@ void CYahooProto::ext_got_stealth(char *stealthlist)
if (stealthlist)
stealth = y_strsplit(stealthlist, ",", -1);
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- if (IsMyContact(hContact)) {
- DBVARIANT dbv;
- if (GetString( hContact, YAHOO_LOGINID, &dbv))
- continue;
+ for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
+ DBVARIANT dbv;
+ if (GetString( hContact, YAHOO_LOGINID, &dbv))
+ continue;
- found = 0;
+ found = 0;
- for(s = stealth; s && *s; s++) {
+ for(s = stealth; s && *s; s++) {
- if (lstrcmpiA(*s, dbv.pszVal) == 0) {
- YAHOO_DEBUGLOG("GOT id = %s", dbv.pszVal);
- found = 1;
- break;
- }
+ if (lstrcmpiA(*s, dbv.pszVal) == 0) {
+ YAHOO_DEBUGLOG("GOT id = %s", dbv.pszVal);
+ found = 1;
+ break;
}
+ }
- /* Check the stealth list */
- if (found) { /* we have him on our Stealth List */
- YAHOO_DEBUGLOG("Setting STEALTH for id = %s", dbv.pszVal);
- /* need to set the ApparentMode thingy */
- if (ID_STATUS_OFFLINE != GetWord(hContact, "ApparentMode", 0))
- GetWord(hContact, "ApparentMode", ID_STATUS_OFFLINE);
-
- } else { /* he is not on the Stealth List */
- //LOG(("Resetting STEALTH for id = %s", dbv.pszVal));
- /* need to delete the ApparentMode thingy */
- if (GetWord(hContact, "ApparentMode", 0))
- db_unset(hContact, m_szModuleName, "ApparentMode");
- }
+ /* Check the stealth list */
+ if (found) { /* we have him on our Stealth List */
+ YAHOO_DEBUGLOG("Setting STEALTH for id = %s", dbv.pszVal);
+ /* need to set the ApparentMode thingy */
+ if (ID_STATUS_OFFLINE != GetWord(hContact, "ApparentMode", 0))
+ GetWord(hContact, "ApparentMode", ID_STATUS_OFFLINE);
+
+ } else { /* he is not on the Stealth List */
+ //LOG(("Resetting STEALTH for id = %s", dbv.pszVal));
+ /* need to delete the ApparentMode thingy */
+ if (GetWord(hContact, "ApparentMode", 0))
+ db_unset(hContact, m_szModuleName, "ApparentMode");
+ }
- db_free( &dbv );
- }
+ db_free( &dbv );
}
}
diff --git a/src/core/stdchat/src/clist.cpp b/src/core/stdchat/src/clist.cpp
index 63a4a5687a..fb147bf717 100644
--- a/src/core/stdchat/src/clist.cpp
+++ b/src/core/stdchat/src/clist.cpp
@@ -281,20 +281,21 @@ BOOL CList_AddEvent(HANDLE hContact, HICON hIcon, HANDLE hEvent, int type, TCHAR
return TRUE;
}
-HANDLE CList_FindRoom ( const char* pszModule, const TCHAR* pszRoom)
+HANDLE CList_FindRoom (const char* pszModule, const TCHAR* pszRoom)
{
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- char *szProto = GetContactProto(hContact);
- if ( szProto && !lstrcmpiA( szProto, pszModule )) {
- if ( db_get_b( hContact, szProto, "ChatRoom", 0) != 0 ) {
- DBVARIANT dbv;
- if ( !db_get_ts( hContact, szProto, "ChatRoomID", &dbv )) {
- if ( !lstrcmpi(dbv.ptszVal, pszRoom)) {
- db_free( &dbv );
- return hContact;
- }
- db_free(&dbv);
- } } } }
+ for (HANDLE hContact = db_find_first(pszModule); hContact; hContact = db_find_next(hContact, pszModule)) {
+ if ( !db_get_b(hContact, pszModule, "ChatRoom", 0))
+ continue;
+
+ DBVARIANT dbv;
+ if ( !db_get_ts( hContact, pszModule, "ChatRoomID", &dbv )) {
+ if ( !lstrcmpi(dbv.ptszVal, pszRoom)) {
+ db_free(&dbv);
+ return hContact;
+ }
+ db_free(&dbv);
+ }
+ }
return 0;
}
diff --git a/src/modules/clist/clistmod.cpp b/src/modules/clist/clistmod.cpp
index 3b3797a90e..9ab769b65a 100644
--- a/src/modules/clist/clistmod.cpp
+++ b/src/modules/clist/clistmod.cpp
@@ -143,14 +143,10 @@ static int ProtocolAck(WPARAM, LPARAM lParam)
if ((int)ack->hProcess < ID_STATUS_ONLINE && ack->lParam >= ID_STATUS_ONLINE) {
DWORD caps = (DWORD)CallProtoServiceInt(NULL,ack->szModule, PS_GETCAPS, PFLAGNUM_1, 0);
- if (caps & PF1_SERVERCLIST) {
- for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- char *szProto = GetContactProto(hContact);
- if (szProto != NULL && !strcmp(szProto, ack->szModule))
- if (db_get_b(hContact, "CList", "Delete", 0))
- CallService(MS_DB_CONTACT_DELETE, (WPARAM) hContact, 0);
- }
- }
+ if (caps & PF1_SERVERCLIST)
+ for (HANDLE hContact = db_find_first(ack->szModule); hContact; hContact = db_find_next(hContact, ack->szModule))
+ if (db_get_b(hContact, "CList", "Delete", 0))
+ CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
}
cli.pfnTrayIconUpdateBase(ack->szModule);
diff --git a/src/modules/visibility/visibility.cpp b/src/modules/visibility/visibility.cpp
index 5204a0a622..7f805e2b99 100644
--- a/src/modules/visibility/visibility.cpp
+++ b/src/modules/visibility/visibility.cpp
@@ -108,27 +108,28 @@ static void SetAllContactIcons(HWND hwndList)
{
for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0);
- if (hItem) {
- DWORD flags;
- WORD status;
- char *szProto = GetContactProto(hContact);
- if (szProto == NULL) {
- flags = 0;
- status = 0;
- }
- else {
- flags = CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAGNUM_1, 0);
- status = db_get_w(hContact, szProto, "ApparentMode", 0);
- }
+ if (hItem == NULL)
+ continue;
+
+ DWORD flags;
+ WORD status;
+ char *szProto = GetContactProto(hContact);
+ if (szProto == NULL) {
+ flags = 0;
+ status = 0;
+ }
+ else {
+ flags = CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAGNUM_1, 0);
+ status = db_get_w(hContact, szProto, "ApparentMode", 0);
+ }
- if (flags & PF1_INVISLIST)
- if (SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(0, 0)) == EMPTY_EXTRA_ICON)
- SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(0, status == ID_STATUS_ONLINE ? 1 : 0));
+ if (flags & PF1_INVISLIST)
+ if (SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(0, 0)) == EMPTY_EXTRA_ICON)
+ SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(0, status == ID_STATUS_ONLINE ? 1 : 0));
- if (flags & PF1_VISLIST)
- if (SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(1, 0)) == EMPTY_EXTRA_ICON)
- SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(1, status == ID_STATUS_OFFLINE ? 2 : 0));
- }
+ if (flags & PF1_VISLIST)
+ if (SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(1, 0)) == EMPTY_EXTRA_ICON)
+ SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(1, status == ID_STATUS_OFFLINE ? 2 : 0));
}
}
@@ -244,19 +245,20 @@ static INT_PTR CALLBACK DlgProcVisibilityOpts(HWND hwndDlg, UINT msg, WPARAM, LP
if (((LPNMHDR)lParam)->code == PSN_APPLY) {
for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
HANDLE hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_FINDCONTACT, (WPARAM)hContact, 0);
- if (hItem) {
- int set = 0;
- for (int i=0; i < 2; i++) {
- int iImage = SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(i, 0));
- if (iImage == i+1) {
- CallContactService(hContact, PSS_SETAPPARENTMODE, iImage == 1?ID_STATUS_ONLINE:ID_STATUS_OFFLINE, 0);
- set = 1;
- break;
- }
+ if (hItem == NULL)
+ continue;
+
+ int set = 0;
+ for (int i=0; i < 2; i++) {
+ int iImage = SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(i, 0));
+ if (iImage == i+1) {
+ CallContactService(hContact, PSS_SETAPPARENTMODE, iImage == 1?ID_STATUS_ONLINE:ID_STATUS_OFFLINE, 0);
+ set = 1;
+ break;
}
- if ( !set)
- CallContactService(hContact, PSS_SETAPPARENTMODE, 0, 0);
}
+ if ( !set)
+ CallContactService(hContact, PSS_SETAPPARENTMODE, 0, 0);
}
return TRUE;
}