From c16bfe00dc27525c03e36cca6930abe5a9fd43a7 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Fri, 10 May 2013 18:31:32 +0000 Subject: - added search by names git-svn-id: http://svn.miranda-ng.org/main/trunk@4624 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Skype/src/skype_contacts.cpp | 50 ++++++++++++++++++++++++++++++++ protocols/Skype/src/skype_proto.cpp | 18 ++++++------ protocols/Skype/src/skypekit/contact.cpp | 6 ++-- 3 files changed, 62 insertions(+), 12 deletions(-) (limited to 'protocols/Skype') diff --git a/protocols/Skype/src/skype_contacts.cpp b/protocols/Skype/src/skype_contacts.cpp index e64194bdd5..bf2582b71a 100644 --- a/protocols/Skype/src/skype_contacts.cpp +++ b/protocols/Skype/src/skype_contacts.cpp @@ -438,4 +438,54 @@ void __cdecl CSkypeProto::SearchByNamesAsync(void* arg) { //todo: write me PROTOSEARCHRESULT *psr = (PROTOSEARCHRESULT *)arg; + + std::string nick = ::mir_utf8encodeW(psr->nick); + std::string fName = ::mir_utf8encodeW(psr->firstName); + std::string lName = " "; lName += ::mir_utf8encodeW(psr->lastName); + + CContactSearch::Ref search; + g_skype->CreateContactSearch(search); + search.fetch(); + search->SetProtoInfo(this, (HANDLE)SKYPE_SEARCH_BYNAMES); + search->SetOnContactFindedCallback( + (CContactSearch::OnContactFinded)&CSkypeProto::OnContactFinded); + search->SetOnSearchCompleatedCallback( + (CContactSearch::OnSearchCompleted)&CSkypeProto::OnSearchCompleted); + + bool valid; + if (nick.length() != 0) + { + search->AddStrTerm( + Contact::P_FULLNAME, + CContactSearch::CONTAINS_WORD_PREFIXES, + nick.c_str(), + valid, + true); + } + if (fName.length() != 0) + { + search->AddOr(); + search->AddStrTerm( + Contact::P_FULLNAME, + CContactSearch::CONTAINS_WORD_PREFIXES, + fName.c_str(), + valid, + true); + } + if (lName.length() != 0) + { + search->AddOr(); + search->AddStrTerm( + Contact::P_FULLNAME, + CContactSearch::CONTAINS_WORD_PREFIXES, + lName.c_str(), + valid, + true); + } + + if (!search->Submit()) + return; + + search->BlockWhileSearch(); + search->Release(); } \ No newline at end of file diff --git a/protocols/Skype/src/skype_proto.cpp b/protocols/Skype/src/skype_proto.cpp index 9cca6581d6..ec39286302 100644 --- a/protocols/Skype/src/skype_proto.cpp +++ b/protocols/Skype/src/skype_proto.cpp @@ -215,7 +215,7 @@ DWORD_PTR __cdecl CSkypeProto:: GetCaps(int type, HANDLE hContact) switch(type) { case PFLAGNUM_1: - return PF1_IM | PF1_FILE | PF1_BASICSEARCH | PF1_ADDSEARCHRES | PF1_SEARCHBYEMAIL/* | PF1_SEARCHBYNAME*/; + return PF1_IM | PF1_FILE | PF1_BASICSEARCH | PF1_ADDSEARCHRES | PF1_SEARCHBYEMAIL | PF1_SEARCHBYNAME; case PFLAGNUM_2: case PFLAGNUM_3: return PF2_ONLINE | PF2_SHORTAWAY | PF2_HEAVYDND | PF2_INVISIBLE; @@ -255,14 +255,14 @@ HANDLE __cdecl CSkypeProto::SearchByEmail(const TCHAR* email) HANDLE __cdecl CSkypeProto::SearchByName(const TCHAR* nick, const TCHAR* firstName, const TCHAR* lastName) { - PROTOSEARCHRESULT psr = {0}; - psr.cbSize = sizeof(psr); - psr.flags = PSR_TCHAR; - psr.nick = ::mir_wstrdup(nick); - psr.firstName = ::mir_wstrdup(firstName); - psr.lastName = ::mir_wstrdup(lastName); - - this->ForkThread(&CSkypeProto::SearchByNamesAsync, &psr); + PROTOSEARCHRESULT *psr = new PROTOSEARCHRESULT(); + psr->cbSize = sizeof(psr); + psr->flags = PSR_TCHAR; + psr->nick = ::mir_wstrdup(nick); + psr->firstName = ::mir_wstrdup(firstName); + psr->lastName = ::mir_wstrdup(lastName); + + this->ForkThread(&CSkypeProto::SearchByNamesAsync, psr); return (HANDLE)SKYPE_SEARCH_BYNAMES; } diff --git a/protocols/Skype/src/skypekit/contact.cpp b/protocols/Skype/src/skypekit/contact.cpp index e1629fb460..6031837afe 100644 --- a/protocols/Skype/src/skypekit/contact.cpp +++ b/protocols/Skype/src/skypekit/contact.cpp @@ -35,10 +35,10 @@ bool CContact::GetFullname(SEString &firstName, SEString &lastName) SEString fullname; this->GetPropFullname(fullname); int pos = fullname.find(" "); - if (pos && pos < (int)fullname.length()) + if (pos != -1) { - firstName = fullname.substr(0, pos); - lastName = fullname.right(pos); + firstName = fullname.substr(0, pos - 1); + lastName = fullname.right(fullname.size() - pos - 1); } else firstName = fullname; -- cgit v1.2.3