summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2012-10-20 18:58:08 +0000
committerAlexander Lantsev <aunsane@gmail.com>2012-10-20 18:58:08 +0000
commit0414c927e4a23bd6232e0ef64c34dbc3482793b1 (patch)
tree472cadf74a4a6cf48b46fe68a448248f23f8abd6 /protocols
parent13ff5e8e9ff54af333a2d11d439122515addb0b5 (diff)
- added basic search
git-svn-id: http://svn.miranda-ng.org/main/trunk@2002 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r--protocols/Skype/src/skype_contacts.cpp64
-rw-r--r--protocols/Skype/src/skype_proto.cpp27
-rw-r--r--protocols/Skype/src/skype_proto.h1
-rw-r--r--protocols/Skype/src/skype_subclassing.cpp39
-rw-r--r--protocols/Skype/src/skype_subclassing.h21
5 files changed, 147 insertions, 5 deletions
diff --git a/protocols/Skype/src/skype_contacts.cpp b/protocols/Skype/src/skype_contacts.cpp
index e67abebf76..086c197c2c 100644
--- a/protocols/Skype/src/skype_contacts.cpp
+++ b/protocols/Skype/src/skype_contacts.cpp
@@ -706,4 +706,68 @@ void CSkypeProto::SetAllContactStatus(int status)
this->SetSettingWord(hContact, SKYPE_SETTINGS_STATUS, status);
hContact = (HANDLE)::CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, (LPARAM)this->m_szModuleName);
}
+}
+
+void __cdecl CSkypeProto::SearchContactBySidAsync(void* arg)
+{
+ const wchar_t *sid = (wchar_t *)arg;
+
+ HANDLE hContact = this->GetContactBySid(sid);
+ if (hContact)
+ {
+ //ShowPopup(is, _T("Contact already in your contact list"), ALLOW_MSGBOX, NULL);
+ this->SendBroadcast(ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)sid, 0);
+ return;
+ }
+
+ CContactSearch::Ref search;
+ g_skype->CreateIdentitySearch(::mir_u2a(sid), search);
+
+ bool valid;
+ if (!search->IsValid(valid) || !valid || !search->Submit())
+ {
+ return;
+ }
+
+ CContact::Refs contacts;
+ search->GetResults(contacts);
+ for (int i = 0 ; i < contacts.size(); i++)
+ {
+ PROTOSEARCHRESULT isr = {0};
+ isr.cbSize = sizeof(isr);
+ isr.flags = PSR_TCHAR;
+
+ SEString data;
+ contacts[i]->GetPropSkypename(data);
+ isr.id = ::mir_utf8decodeW((const char *)data);
+ contacts[i]->GetPropDisplayname(data);
+ isr.nick = ::mir_utf8decodeW((const char *)data);
+ {
+ contacts[i]->GetPropFullname(data);
+ wchar_t *fullname = ::mir_utf8decodeW((const char*)data);
+
+ wchar_t *first = wcstok(fullname, L" ");
+ wchar_t *last = wcstok(NULL, L" ");
+ if (last == NULL)
+ {
+ last = L"";
+ }
+ isr.firstName = first;
+ isr.lastName = last;
+ }
+ {
+ contacts[i]->GetPropEmails(data);
+ wchar_t *emails = ::mir_utf8decodeW((const char*)data);
+
+ wchar_t* main = wcstok(emails, L" ");
+ if (main == NULL)
+ {
+ isr.email = main;
+ }
+ }
+
+ this->SendBroadcast(ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)sid, (LPARAM)&isr);
+ }
+
+ this->SendBroadcast(ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)sid, 0);
} \ No newline at end of file
diff --git a/protocols/Skype/src/skype_proto.cpp b/protocols/Skype/src/skype_proto.cpp
index 609450a2b6..c40ce6c854 100644
--- a/protocols/Skype/src/skype_proto.cpp
+++ b/protocols/Skype/src/skype_proto.cpp
@@ -154,7 +154,7 @@ DWORD_PTR __cdecl CSkypeProto:: GetCaps(int type, HANDLE hContact)
switch(type)
{
case PFLAGNUM_1:
- return PF1_IM | PF1_PEER2PEER;
+ return PF1_IM | PF1_BASICSEARCH | PF1_ADDSEARCHRES/* | PF1_SEARCHBYEMAIL | PF1_SEARCHBYNAME*/;
case PFLAGNUM_2:
case PFLAGNUM_3:
return PF2_ONLINE | PF2_SHORTAWAY | PF2_HEAVYDND | PF2_INVISIBLE;
@@ -182,11 +182,28 @@ HICON __cdecl CSkypeProto::GetIcon( int iconIndex )
int __cdecl CSkypeProto::GetInfo( HANDLE hContact, int infoType ) { return 0; }
-HANDLE __cdecl CSkypeProto::SearchBasic( const TCHAR* id ) { return 0; }
-HANDLE __cdecl CSkypeProto::SearchByEmail( const TCHAR* email ) { return 0; }
-HANDLE __cdecl CSkypeProto::SearchByName( const TCHAR* nick, const TCHAR* firstName, const TCHAR* lastName ) { return 0; }
+HANDLE __cdecl CSkypeProto::SearchBasic(const TCHAR* id)
+{
+ if ( !this->IsOnline())
+ return 0;
+
+ wchar_t *sid = ::mir_tstrdup(id);
+ this->ForkThread(&CSkypeProto::SearchContactBySidAsync, sid);
+
+ return sid;
+}
+
+HANDLE __cdecl CSkypeProto::SearchByEmail( const TCHAR* email )
+{
+ return 0;
+}
+HANDLE __cdecl CSkypeProto::SearchByName( const TCHAR* nick, const TCHAR* firstName, const TCHAR* lastName )
+{
+ return 0;
+}
HWND __cdecl CSkypeProto::SearchAdvanced( HWND owner ) { return 0; }
-HWND __cdecl CSkypeProto::CreateExtendedSearchUI( HWND owner ) { return 0; }
+
+HWND __cdecl CSkypeProto::CreateExtendedSearchUI( HWND owner ){ return 0; }
int __cdecl CSkypeProto::RecvContacts( HANDLE hContact, PROTORECVEVENT* ) { return 0; }
int __cdecl CSkypeProto::RecvFile( HANDLE hContact, PROTORECVFILET* ) { return 0; }
diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h
index f9f1a24a1a..669ec40b09 100644
--- a/protocols/Skype/src/skype_proto.h
+++ b/protocols/Skype/src/skype_proto.h
@@ -152,6 +152,7 @@ protected:
void SetAllContactStatus(int status);
void __cdecl LoadContactList(void*);
+ void __cdecl SearchContactBySidAsync(void*);
// utils
static char* GetCountryNameById(int countryId);
diff --git a/protocols/Skype/src/skype_subclassing.cpp b/protocols/Skype/src/skype_subclassing.cpp
index ad3c265749..587a4ba6cf 100644
--- a/protocols/Skype/src/skype_subclassing.cpp
+++ b/protocols/Skype/src/skype_subclassing.cpp
@@ -94,6 +94,45 @@ void CContactGroup::OnChange(const ContactRef& contact)
(proto->*callback)(contact);
}
+// CContactSearch
+
+CContactSearch::CContactSearch(unsigned int oid, SERootObject* root) : ContactSearch(oid, root)
+{
+ this->isSeachFailed = false;
+ this->isSeachFinished = false;
+}
+
+void CContactSearch::OnChange(int prop)
+{
+ if (prop == P_CONTACT_SEARCH_STATUS)
+ {
+ CContactSearch::STATUS status;
+ this->GetPropContactSearchStatus(status);
+ if (status == FINISHED)
+ this->isSeachFinished = true;
+ if (status == FAILED)
+ this->isSeachFailed = true;
+ }
+
+ //SEString value = GetProp(prop);
+ //List_String dbg = getPropDebug(prop, value);
+ //fprintf(stdout,"CONTACTSEARCH.%d:%s = %s\n", getOID(), (const char*)dbg[1], (const char*)dbg[2]);
+}
+
+void CContactSearch::OnNewResult(const ContactRef& contact, const uint& rankValue)
+{
+ Sid::String identity;
+ contact->GetIdentity(identity);
+}
+
+void CContactSearch::BlockWhileSearching()
+{
+ this->isSeachFailed = false;
+ this->isSeachFinished = false;
+ while ( !this->isSeachFailed && !this->isSeachFinished)
+ Sleep(1);
+}
+
// CContact
CContact::CContact(unsigned int oid, SERootObject* root) : Contact(oid, root)
diff --git a/protocols/Skype/src/skype_subclassing.h b/protocols/Skype/src/skype_subclassing.h
index 97ff2952eb..a8f87a6e50 100644
--- a/protocols/Skype/src/skype_subclassing.h
+++ b/protocols/Skype/src/skype_subclassing.h
@@ -38,6 +38,27 @@ private:
void OnChange(int prop);
};
+class CContactSearch : public ContactSearch
+{
+public:
+ typedef DRef<CContactSearch, ContactSearch> Ref;
+ typedef DRefs<CContactSearch, ContactSearch> Refs;
+
+ bool isSeachFailed;
+ bool isSeachFinished;
+
+ CContactSearch(unsigned int oid, SERootObject* root);
+
+ //void set_controller(CommandContactSearch* controller) { m_controller = controller; }
+
+ void OnChange(int prop);
+ void OnNewResult(const ContactRef& contact, const uint& rankValue);
+
+ void BlockWhileSearching();
+
+ //CommandContactSearch* m_controller;
+};
+
class CContactGroup : public ContactGroup
{
public: