diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2012-10-02 18:39:38 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2012-10-02 18:39:38 +0000 |
commit | a6175cc98ca2b8ca61faa927e934f49375cee685 (patch) | |
tree | 26006550a4bfa7c36846e3b32d3cab9425a4d686 /protocols | |
parent | fa6e252a049cd32cbc9d2bf546b630f2178f6692 (diff) |
- added simple contacts loading
- added contact status updating
git-svn-id: http://svn.miranda-ng.org/main/trunk@1766 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/Skype/src/skype_contacts.cpp | 42 | ||||
-rw-r--r-- | protocols/Skype/src/skype_proto.cpp | 18 | ||||
-rw-r--r-- | protocols/Skype/src/skype_subclassing.cpp | 23 |
3 files changed, 46 insertions, 37 deletions
diff --git a/protocols/Skype/src/skype_contacts.cpp b/protocols/Skype/src/skype_contacts.cpp index c5b4aeb513..674c71adc6 100644 --- a/protocols/Skype/src/skype_contacts.cpp +++ b/protocols/Skype/src/skype_contacts.cpp @@ -3,11 +3,27 @@ void CSkypeProto::OnContactChanged(CContact* contact, int prop)
{
+ if (prop == CContact::P_AVAILABILITY)
+ {
+ SEString data;
+
+ contact->GetPropSkypename(data);
+ wchar_t* skypeName = ::mir_a2u((const char*)data);
+
+ contact->GetPropDisplayname(data);
+ wchar_t* displayName = ::mir_a2u((const char*)data);
+
+ HANDLE hContact = this->AddContactBySkypeName(skypeName, displayName, 0);
+
+ CContact::AVAILABILITY availability;
+ contact->GetPropAvailability(availability);
+ this->SetSettingWord(hContact, SKYPE_SETTINGS_STATUS, this->SkypeToMirandaStatus(availability));
+ }
}
bool CSkypeProto::IsSkypeContact(HANDLE hContact)
{
- return ::CallService(MS_PROTO_ISPROTOONCONTACT, (WPARAM)hContact, (LPARAM)this->m_szModuleName) > 0;
+ return (::CallService(MS_PROTO_ISPROTOONCONTACT, (WPARAM)hContact, (LPARAM)this->m_szModuleName));
}
HANDLE CSkypeProto::GetContactBySkypeName(wchar_t* skypeName)
@@ -37,7 +53,7 @@ HANDLE CSkypeProto::AddContactBySkypeName(wchar_t* skypeName, wchar_t* displayNa this->SetSettingString(hContact, "SkypeName", skypeName);
this->SetSettingString(hContact, "DisplayName", displayName);
- //::DBWriteContactSettingWString(hContact, "CList", "MyHandle", displayName);
+ ::DBWriteContactSettingWString(hContact, "CList", "MyHandle", displayName);
if (flags & PALF_TEMPORARY)
{
@@ -110,26 +126,26 @@ void __cdecl CSkypeProto::LoadContactList(void*) g_skype->GetHardwiredContactGroup(CContactGroup::ALL_KNOWN_CONTACTS, this->contactGroup);
this->contactGroup->GetContacts(this->contactGroup->ContactList);
- fetch(this->contactGroup->ContactList);
+ Sid::fetch(this->contactGroup->ContactList);
for (unsigned int i = 0; i < this->contactGroup->ContactList.size(); i++)
{
- //this->contactGroup->ContactList[i]->SetOnContactChangeCallback((OnContactChangeFunc)&CSkypeProto::OnContactChanged, this);
+ CContact::Ref contact = this->contactGroup->ContactList[i];
+
+ contact->SetOnContactChangeCallback((OnContactChangeFunc)&CSkypeProto::OnContactChanged, this);
+
+ SEString data;
- //SEString sn;
- //this->contactGroup->ContactList[i]->GetPropSkypename(sn);
- wchar_t* skypeName = L"1";//::mir_a2u((const char*)sn);
+ contact->GetPropSkypename(data);
+ wchar_t* skypeName = ::mir_a2u((const char*)data);
- //SEString dn;
- //this->contactGroup->ContactList[i]->GetPropDisplayname(dn);
- wchar_t* displayName = L"1";//::mir_a2u((const char*)dn);
+ contact->GetPropDisplayname(data);
+ wchar_t* displayName = ::mir_a2u((const char*)data);
- //HANDLE hContact = this->GetContactBySkypeName(L"321");
- //if (!hContact)
HANDLE hContact = this->AddContactBySkypeName(skypeName, displayName, 0);
CContact::AVAILABILITY availability;
- this->contactGroup->ContactList[i]->GetPropAvailability(availability);
+ contact->GetPropAvailability(availability);
this->SetSettingWord(hContact, SKYPE_SETTINGS_STATUS, this->SkypeToMirandaStatus(availability));
}
}
diff --git a/protocols/Skype/src/skype_proto.cpp b/protocols/Skype/src/skype_proto.cpp index 35920ac183..c21880caf4 100644 --- a/protocols/Skype/src/skype_proto.cpp +++ b/protocols/Skype/src/skype_proto.cpp @@ -138,7 +138,7 @@ int CSkypeProto::SetStatus(int new_status) {
this->m_iStatus = new_status;
//todo: set all status to offline
- this->account->Logout();
+ this->account->Logout(true);
this->account->BlockWhileLoggingOut();
this->account->SetAvailability(CContact::OFFLINE);
this->SetAllContactStatuses(ID_STATUS_OFFLINE);
@@ -154,8 +154,8 @@ int CSkypeProto::SetStatus(int new_status) this->m_iStatus = ID_STATUS_CONNECTING;
this->password = this->GetDecodeSettingString(SKYPE_SETTINGS_PASSWORD);
- //this->ForkThread(&CSkypeProto::SignIn, this);
- this->SignIn(this);
+ this->ForkThread(&CSkypeProto::SignIn, this);
+ //this->SignIn(this);
}
}
@@ -203,16 +203,14 @@ bool CSkypeProto::IsOffline() void __cdecl CSkypeProto::SignIn(void*)
{
- //WaitForSingleObject(&this->signin_lock, INFINITE);
+ WaitForSingleObject(&this->signin_lock, INFINITE);
- this->account->LoginWithPassword(::mir_u2a(this->password));
+ this->account->LoginWithPassword(::mir_u2a(this->password), false, false);
this->account->BlockWhileLoggingIn();
- //CContact::Ref()->SetOnChangeCallback((OnContactChangeFunc)&CSkypeProto::OnContactChanged, this);
-
this->SetStatus(this->m_iDesiredStatus);
- //this->ForkThread(&CSkypeProto::LoadContactList, this);
- this->LoadContactList(this);
+ this->ForkThread(&CSkypeProto::LoadContactList, this);
+ //this->LoadContactList(this);
- //ReleaseMutex(this->signin_lock);
+ ReleaseMutex(this->signin_lock);
}
\ No newline at end of file diff --git a/protocols/Skype/src/skype_subclassing.cpp b/protocols/Skype/src/skype_subclassing.cpp index c206f65ef5..bb943a708e 100644 --- a/protocols/Skype/src/skype_subclassing.cpp +++ b/protocols/Skype/src/skype_subclassing.cpp @@ -43,12 +43,6 @@ void CAccount::OnChange(int prop) } -void CContact::SetOnContactChangeCallback(OnContactChangeFunc callback, CSkypeProto* proto) -{ - this->proto = proto; - this->callback = callback; -} - void CAccount::BlockWhileLoggingIn() { while (this->isLoggedOut) @@ -72,17 +66,18 @@ void CContactGroup::OnChange(const ContactRef& contact) CContact::CContact(unsigned int oid, SERootObject* root) : Contact(oid, root) { + this->proto = NULL; + this->callback == NULL; } -//void CAccount::SetOnChangeCallback(OnContactChangeFunc callback, CSkypeProto* proto) -//{ -// this->proto = proto; -// this->callback = callback; -//} +void CContact::SetOnContactChangeCallback(OnContactChangeFunc callback, CSkypeProto* proto) +{ + this->proto = proto; + this->callback = callback; +} void CContact::OnChange(int prop) { - //SEString identity; - //this->GetIdentity(identity); - (proto->*callback)(this, prop); + if (this->callback && this->proto) + (proto->*callback)(this, prop); }
\ No newline at end of file |