diff options
author | George Hazan <george.hazan@gmail.com> | 2013-04-09 21:40:22 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-04-09 21:40:22 +0000 |
commit | 3dc0d9b0b7c30ea2f77d74c4ce5b6ccd67bd525c (patch) | |
tree | efee912ee654baafeb98efcd117921db6b7489bc /protocols | |
parent | bcb27264ba737778e5d3edad36088bacf74f0236 (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
Diffstat (limited to 'protocols')
36 files changed, 645 insertions, 777 deletions
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(<ime);
- 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(<ime);
+ 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 );
}
}
|