summaryrefslogtreecommitdiff
path: root/protocols/Skype/src
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2013-05-10 18:31:32 +0000
committerAlexander Lantsev <aunsane@gmail.com>2013-05-10 18:31:32 +0000
commitc16bfe00dc27525c03e36cca6930abe5a9fd43a7 (patch)
tree2af9b262bc48ef0a3bf004fab9fdbc1c969fe86a /protocols/Skype/src
parent9403f94a71782e106d29f1ca2df5aa682ea3f746 (diff)
- added search by names
git-svn-id: http://svn.miranda-ng.org/main/trunk@4624 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Skype/src')
-rw-r--r--protocols/Skype/src/skype_contacts.cpp50
-rw-r--r--protocols/Skype/src/skype_proto.cpp18
-rw-r--r--protocols/Skype/src/skypekit/contact.cpp6
3 files changed, 62 insertions, 12 deletions
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;