From b22b6804903e1e8e0e51fd8c78d928f0204672b5 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Fri, 28 Sep 2012 05:35:12 +0000 Subject: - added some function to contacs loading git-svn-id: http://svn.miranda-ng.org/main/trunk@1697 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Skype/src/skype_proto.cpp | 56 ++++++++++++++++++++++++++++++- protocols/Skype/src/skype_proto.h | 5 ++- protocols/Skype/src/skype_subclassing.cpp | 23 +++++++++++-- protocols/Skype/src/skype_subclassing.h | 36 +++++++++++++++----- protocols/Skype/src/skype_utils.cpp | 2 +- 5 files changed, 108 insertions(+), 14 deletions(-) diff --git a/protocols/Skype/src/skype_proto.cpp b/protocols/Skype/src/skype_proto.cpp index 498239053b..aa9af339ae 100644 --- a/protocols/Skype/src/skype_proto.cpp +++ b/protocols/Skype/src/skype_proto.cpp @@ -39,7 +39,14 @@ CSkypeProto::~CSkypeProto() mir_free(this->m_tszUserName); } -HANDLE __cdecl CSkypeProto::AddToList( int flags, PROTOSEARCHRESULT* psr ) { return 0; } +HANDLE __cdecl CSkypeProto::AddToList(int flags, PROTOSEARCHRESULT* psr) +{ + if (psr->cbSize != sizeof(PROTOSEARCHRESULT)) + return 0; + + return this->AddToListBySkypeLogin(psr->id, psr->nick, psr->firstName, psr->lastName, flags); +} + HANDLE __cdecl CSkypeProto::AddToListByEvent( int flags, int iContact, HANDLE hDbEvent ) { return 0; } int __cdecl CSkypeProto::Authorize( HANDLE hDbEvent ) { return 0; } int __cdecl CSkypeProto::AuthDeny( HANDLE hDbEvent, const TCHAR* szReason ) { return 0; } @@ -203,6 +210,53 @@ void __cdecl CSkypeProto::SignIn(void*) this->account->LoginWithPassword(mir_u2a(this->password), false, false); this->account->BlockWhileLoggingIn(); this->SetStatus(this->m_iDesiredStatus); + this->ForkThread(&CSkypeProto::LoadContactList, this); ReleaseMutex(this->signin_lock); +} + +void __cdecl CSkypeProto::LoadContactList(void*) +{ + CContactGroup::Ref contacts; + g_skype->GetHardwiredContactGroup(CContactGroup::ALL_KNOWN_CONTACTS, contacts); + + contacts->GetContacts(contacts->ContactList); + fetch(contacts->ContactList); + + for (unsigned int i = 0; i < contacts->ContactList.size(); i++) + { + SEString contactName; + contacts->ContactList[i]->GetPropDisplayname(contactName); + printf("%3d. %s\n", i+1, (const char*)contactName); + + //HANDLE hContact = AddToContactList(fbu, FACEBOOK_CONTACT_APPROVE, false, fbu->real_name.c_str()); + //DBWriteContactSettingByte(hContact, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, FACEBOOK_CONTACT_APPROVE); + } +} + +HANDLE CSkypeProto::AddToListBySkypeLogin(TCHAR* skypeName, TCHAR* nickName, TCHAR* firstName, TCHAR* lastName, DWORD flags) +{ + //if (!skypeName) + return NULL; + + /*BOOL bAdded; + HANDLE hContact = MraHContactFromEmail( _T2A(plpsEMail), lstrlen(plpsEMail), TRUE, TRUE, &bAdded); + if (hContact) { + if (nickName) + mraSetStringW(hContact, "Nick", nickName); + if (firstName) + mraSetStringW(hContact, "FirstName", firstName); + if (lastName) + mraSetStringW(hContact, "LastName", lastName); + + if (flags & PALF_TEMPORARY) + DBWriteContactSettingByte(hContact, "CList", "Hidden", 1); + else + DBDeleteContactSetting(hContact, "CList", "NotOnList"); + + if (bAdded) + MraUpdateContactInfo(hContact); + } + + return hContact;*/ } \ No newline at end of file diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h index 5f41c3dc01..a5597c4c4f 100644 --- a/protocols/Skype/src/skype_proto.h +++ b/protocols/Skype/src/skype_proto.h @@ -85,12 +85,15 @@ protected: HANDLE signin_lock; void __cdecl SignIn(void*); + void __cdecl LoadContactList(void*); + + HANDLE AddToListBySkypeLogin(TCHAR* skypeName, TCHAR* nickName, TCHAR* firstName, TCHAR* lastName, DWORD flags); void CreateService(const char* szService, SkypeServiceFunc serviceProc); void CreateServiceParam(const char* szService, SkypeServiceFunc serviceProc, LPARAM lParam); - HANDLE CreateHookableEvent(const char* szService); + HANDLE CreateEvent(const char* szService); void HookEvent(const char*, SkypeEventFunc); int SendBroadcast(int type, int result, HANDLE hProcess, LPARAM lParam); diff --git a/protocols/Skype/src/skype_subclassing.cpp b/protocols/Skype/src/skype_subclassing.cpp index 0de069a243..1c067f4c3a 100644 --- a/protocols/Skype/src/skype_subclassing.cpp +++ b/protocols/Skype/src/skype_subclassing.cpp @@ -1,6 +1,6 @@ #include "skype_subclassing.h" -Account* CSkype::newAccount(int oid) +CAccount* CSkype::newAccount(int oid) { return new CAccount(oid, this); } @@ -30,7 +30,7 @@ void CAccount::OnChange(int prop) } } } -}; +} void CAccount::BlockWhileLoggingIn() { @@ -42,4 +42,21 @@ void CAccount::BlockWhileLoggingOut() { while ( !this->isLoggedOut) Sleep(1); -}; \ No newline at end of file +} + +CContactGroup::CContactGroup(unsigned int oid, SERootObject* root) : ContactGroup(oid, root) +{ +} + +void CContactGroup::OnChange(const ContactRef& contact) +{ +} + + +CContact::CContact(unsigned int oid, SERootObject* root) : Contact(oid, root) +{ +} + +void CContact::OnChange(int prop) +{ +} \ No newline at end of file diff --git a/protocols/Skype/src/skype_subclassing.h b/protocols/Skype/src/skype_subclassing.h index ffb971b828..5cd42cf5c3 100644 --- a/protocols/Skype/src/skype_subclassing.h +++ b/protocols/Skype/src/skype_subclassing.h @@ -2,14 +2,31 @@ #include -class CAccount; - -class CSkype : public Skype +class CContact : public Contact { public: - Account* newAccount(int oid); + typedef DRef Ref; + typedef DRefs Refs; + + CContact(unsigned int oid, SERootObject* root); + +protected: + void OnChange(int prop); }; +class CContactGroup : public ContactGroup +{ +public: + typedef DRef Ref; + typedef DRefs Refs; + CContactGroup(unsigned int oid, SERootObject* root); + + CContact::Refs ContactList; + +protected: + void OnChange(const ContactRef& contact); +}; + class CAccount : public Account { public: @@ -19,13 +36,16 @@ public: bool isLoggedOut; CAccount(unsigned int oid, SERootObject* root); - void OnChange(int prop); void BlockWhileLoggingIn(); void BlockWhileLoggingOut(); -}; -class CContact : public Contact -{ +protected: + void OnChange(int prop); }; +class CSkype : public Skype +{ +public: + CAccount* newAccount(int oid); +}; \ No newline at end of file diff --git a/protocols/Skype/src/skype_utils.cpp b/protocols/Skype/src/skype_utils.cpp index 34471d14be..057ce1aebd 100644 --- a/protocols/Skype/src/skype_utils.cpp +++ b/protocols/Skype/src/skype_utils.cpp @@ -28,7 +28,7 @@ void CSkypeProto::CreateServiceParam(const char* szService, SkypeServiceFunc ser CreateServiceFunctionObjParam(moduleName, (MIRANDASERVICEOBJPARAM)*(void**)&serviceProc, this, lParam); } -HANDLE CSkypeProto::CreateHookableEvent(const char* szService) +HANDLE CSkypeProto::CreateEvent(const char* szService) { char moduleName[MAXMODULELABELLENGTH]; -- cgit v1.2.3