From 22d948a4cd28ccf08008db597e4f7470c3a57219 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Thu, 9 Apr 2015 20:51:56 +0000 Subject: SkypeWeb: ugly contacts lookup hack git-svn-id: http://svn.miranda-ng.org/main/trunk@12718 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/SkypeWeb/src/skype_contacts.cpp | 17 ++++++++++++----- protocols/SkypeWeb/src/skype_proto.cpp | 3 ++- protocols/SkypeWeb/src/skype_proto.h | 1 + 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/protocols/SkypeWeb/src/skype_contacts.cpp b/protocols/SkypeWeb/src/skype_contacts.cpp index 4e34d1b2e0..e4a46cd0e3 100644 --- a/protocols/SkypeWeb/src/skype_contacts.cpp +++ b/protocols/SkypeWeb/src/skype_contacts.cpp @@ -47,15 +47,22 @@ MCONTACT CSkypeProto::GetContact(const char *skypename) if (it != contactMap.end()) return it->second; - for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) + MCONTACT hContact = NULL; + if (contactMap.empty()) + MCONTACT hContact = db_find_first(m_szModuleName); + else + { + hContact = db_find_next(lastMapContact, m_szModuleName); + } + for (; hContact; hContact = db_find_next(hContact, m_szModuleName)) { std::string cSkypename = ptrA(getStringA(hContact, SKYPE_SETTINGS_ID)); if (!contactMap.count(cSkypename)) - contactMap[cSkypename] = hContact; + contactMap[cSkypename] = lastMapContact = hContact; if (mir_strcmpi(skypename, cSkypename.c_str()) == 0) - return hContact; + break; } - return NULL; + return hContact; } MCONTACT CSkypeProto::AddContact(const char *skypename, bool isTemporary) @@ -66,7 +73,7 @@ MCONTACT CSkypeProto::AddContact(const char *skypename, bool isTemporary) hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0); CallService(MS_PROTO_ADDTOCONTACT, hContact, (LPARAM)m_szModuleName); - contactMap[skypename] = hContact; + contactMap[skypename] = lastMapContact = hContact; setString(hContact, SKYPE_SETTINGS_ID, skypename); diff --git a/protocols/SkypeWeb/src/skype_proto.cpp b/protocols/SkypeWeb/src/skype_proto.cpp index 0056b2e330..1a5f7e1f71 100644 --- a/protocols/SkypeWeb/src/skype_proto.cpp +++ b/protocols/SkypeWeb/src/skype_proto.cpp @@ -37,11 +37,12 @@ PROTO(protoName, userName), password(NULL) CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType); // make contact map + lastMapContact = NULL; for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { std::string cSkypename = ptrA(getStringA(hContact, SKYPE_SETTINGS_ID)); if (!contactMap.count(cSkypename)) - contactMap[cSkypename] = hContact; + contactMap[cSkypename] = lastMapContact = hContact; } } diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h index 0d6203655c..005616acc4 100644 --- a/protocols/SkypeWeb/src/skype_proto.h +++ b/protocols/SkypeWeb/src/skype_proto.h @@ -164,6 +164,7 @@ private: void LoadProfile(const NETLIBHTTPREQUEST *response); // contacts + MCONTACT lastMapContact; std::map contactMap; WORD GetContactStatus(MCONTACT hContact); -- cgit v1.2.3