summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2012-10-07 17:10:29 +0000
committerAlexander Lantsev <aunsane@gmail.com>2012-10-07 17:10:29 +0000
commit8d42163a160b263abf709414db8b973f74b4d355 (patch)
treed44fc6a25ced661d493c5fa9f9b138680d47805b
parentecb5d187aec965f0fc021002dbf2afab22d300e8 (diff)
- second approach to adding/deleting contacts
git-svn-id: http://svn.miranda-ng.org/main/trunk@1806 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--protocols/Skype/src/skype.cpp14
-rw-r--r--protocols/Skype/src/skype_contacts.cpp158
-rw-r--r--protocols/Skype/src/skype_database.cpp6
-rw-r--r--protocols/Skype/src/skype_dialogs.cpp12
-rw-r--r--protocols/Skype/src/skype_proto.cpp10
-rw-r--r--protocols/Skype/src/skype_proto.h4
-rw-r--r--protocols/Skype/src/skype_settings.cpp23
-rw-r--r--protocols/Skype/src/skype_subclassing.cpp8
-rw-r--r--protocols/Skype/src/skype_subclassing.h4
9 files changed, 156 insertions, 83 deletions
diff --git a/protocols/Skype/src/skype.cpp b/protocols/Skype/src/skype.cpp
index b1b0b628f3..d156be206f 100644
--- a/protocols/Skype/src/skype.cpp
+++ b/protocols/Skype/src/skype.cpp
@@ -133,20 +133,20 @@ extern "C" int __declspec(dllexport) Load(void)
pd.fnUninit = (pfnUninitProto)CSkypeProto::UninitSkypeProto;
CallService(MS_PROTO_REGISTERMODULE, 0, reinterpret_cast<LPARAM>(&pd));
- CallService(
- MS_UTILS_GETCOUNTRYLIST,
- (WPARAM)&CSkypeProto::countriesCount,
- (LPARAM)&CSkypeProto::countryList);
+ //CallService(
+ // MS_UTILS_GETCOUNTRYLIST,
+ // (WPARAM)&CSkypeProto::countriesCount,
+ // (LPARAM)&CSkypeProto::countryList);
CSkypeProto::InitIcons();
- CSkypeProto::InitMenus();
-
+ /*CSkypeProto::InitMenus();
+*/
return 0;
}
extern "C" int __declspec(dllexport) Unload(void)
{
- CSkypeProto::UninitMenus();
+ //CSkypeProto::UninitMenus();
CSkypeProto::UninitIcons();
g_skype->stop();
diff --git a/protocols/Skype/src/skype_contacts.cpp b/protocols/Skype/src/skype_contacts.cpp
index 55fdb90b3d..5b878a26dc 100644
--- a/protocols/Skype/src/skype_contacts.cpp
+++ b/protocols/Skype/src/skype_contacts.cpp
@@ -44,7 +44,7 @@ void CSkypeProto::UpdateContactAvatar(HANDLE hContact, CContact::Ref contact)
if (data.size() > 0)
{
- wchar_t* path = this->GetAvatarFilePath(this->GetSettingString(hContact, "SkypeName"));
+ wchar_t* path = this->GetAvatarFilePath(this->GetSettingString(hContact, "sid"));
FILE* fp = _wfopen(path, L"w");
if (fp)
{
@@ -314,9 +314,18 @@ void CSkypeProto::OnContactChanged(CContact::Ref contact, int prop)
contact->GetPropReceivedAuthrequest(data);
char* reason = ::mir_utf8decodeA((const char*)data);
+
+ contact->GetPropFullname(data);
+ char* fullname = ::mir_utf8decodeA((const char*)data);
+
+ char* first = strtok(fullname, " ");
+ char* last = strtok(NULL, " ");
+ if (last == NULL)
+ {
+ last = "";
+ }
- //todo: add first/last name
- this->RaiseAuthRequestEvent(newTS, sid, nick, "", "", reason);
+ this->RaiseAuthRequestEvent(newTS, sid, nick, first, last, reason);
}
}
break;
@@ -376,6 +385,9 @@ void CSkypeProto::OnContactChanged(CContact::Ref contact, int prop)
break;
}
}
+ else
+ {
+ }
//else
//{
// switch(prop)
@@ -418,32 +430,51 @@ void CSkypeProto::OnContactChanged(CContact::Ref contact, int prop)
void CSkypeProto::OnContactListChanged(const ContactRef& contact)
{
- CContactGroup::TYPE type;
- this->contactList->GetPropType(type);
- //switch (type)
- //{
- //case CContactGroup::ALL_KNOWN_CONTACTS:
- // if ( !this->contactList->Contains(contact))
- // {
- // SEString data;
+ bool result;
- // contact->GetPropSkypename(data);
- // wchar_t* sid = ::mir_utf8decodeW((const char*)data);
- //
- // contact->GetPropDisplayname(data);
- // wchar_t* nick = ::mir_utf8decodeW((const char*)data);
- //
- // contact->GetPropReceivedAuthrequest(data);
- // wchar_t* reason = ::mir_utf8decodeW((const char*)data);
-
- // uint newTS = 0;
- // contact->GetPropAuthreqTimestamp(newTS);
- //
- // //todo: add first/last name
- // this->RaiseAuthRequestEvent(newTS, sid, nick, L"", L"", reason);
- // }
- // break;
- //}
+ contact->IsMemberOfHardwiredGroup(CContactGroup::ALL_BUDDIES, result);
+ if (result)
+ {
+ if ( !this->contactList.contains(contact))
+ {
+ CContact::Ref newContact(contact);
+ this->contactList.append(newContact);
+ newContact.fetch();
+ newContact->SetOnContactChangedCallback(
+ (CContact::OnContactChanged)&CSkypeProto::OnContactChanged,
+ this);
+ }
+ }
+
+ contact->IsMemberOfHardwiredGroup(CContactGroup::CONTACTS_WAITING_MY_AUTHORIZATION, result);
+ if (result)
+ {
+ SEString data;
+
+ uint newTS = 0;
+ contact->GetPropAuthreqTimestamp(newTS);
+
+ contact->GetPropSkypename(data);
+ char* sid = ::mir_utf8decodeA((const char*)data);
+
+ contact->GetPropDisplayname(data);
+ char* nick = ::mir_utf8decodeA((const char*)data);
+
+ contact->GetPropReceivedAuthrequest(data);
+ char* reason = ::mir_utf8decodeA((const char*)data);
+
+ contact->GetPropFullname(data);
+ char* fullname = ::mir_utf8decodeA((const char*)data);
+
+ char* first = strtok(fullname, " ");
+ char* last = strtok(NULL, " ");
+ if (last == NULL)
+ {
+ last = "";
+ }
+
+ this->RaiseAuthRequestEvent(newTS, sid, nick, first, last, reason);
+ }
}
bool CSkypeProto::IsProtoContact(HANDLE hContact)
@@ -544,19 +575,12 @@ void CSkypeProto::RemoveContact(HANDLE hContact)
{
if (this->IsOnline() && hContact)
{
- //bool canDelete = false;
CContact::Ref contact;
SEString sid(::mir_u2a(this->GetSettingString(hContact, "sid")));
- g_skype->GetContact(sid, contact);
- contact->SetBuddyStatus(CContact::BLOCKED_BY_ME);
-
- //this->contactList->CanRemoveContact(canDelete);
- //if (canDelete)
+ if (g_skype->GetContact(sid, contact))
{
- contact->SetBuddyStatus(false/*CContact::BLOCKED_BY_ME*/);
- this->contactList->ContactList.remove_val(contact);
- this->contactList->RemoveContact(contact);
- this->contactList.fetch();
+ contact->SetBuddyStatus(false);
+ this->contactList.remove_val(contact);
}
}
}
@@ -589,17 +613,17 @@ CContact::AVAILABILITY CSkypeProto::MirandaToSkypeStatus(int status)
void __cdecl CSkypeProto::LoadContactList(void*)
{
- g_skype->GetHardwiredContactGroup(CContactGroup::ALL_KNOWN_CONTACTS, this->contactList);
- this->contactList.fetch();
- this->contactList->SetOnContactListChangedCallback(
+ g_skype->GetHardwiredContactGroup(CContactGroup::ALL_BUDDIES, this->commonList);
+ this->commonList.fetch();
+ this->commonList->SetOnContactListChangedCallback(
(CContactGroup::OnContactListChanged)&CSkypeProto::OnContactListChanged,
this);
- this->contactList->GetContacts(this->contactList->ContactList);
- Sid::fetch(this->contactList->ContactList);
+ this->commonList->GetContacts(this->contactList);
+ Sid::fetch(this->contactList);
- for (unsigned int i = 0; i < this->contactList->ContactList.size(); i++)
+ for (unsigned int i = 0; i < this->contactList.size(); i++)
{
- CContact::Ref contact = this->contactList->ContactList[i];
+ CContact::Ref contact = this->contactList[i];
contact->SetOnContactChangedCallback(
(CContact::OnContactChanged)&CSkypeProto::OnContactChanged,
this);
@@ -629,6 +653,47 @@ void __cdecl CSkypeProto::LoadContactList(void*)
this->UpdateContactStatus(hContact, contact);
this->UpdateContactStatusMessage(hContact, contact);
}
+
+ // raise auth event for all non auth contacts
+ CContact::Refs authContacts;
+ g_skype->GetHardwiredContactGroup(CContactGroup::CONTACTS_WAITING_MY_AUTHORIZATION, this->authWaitList);
+ this->authWaitList.fetch();
+ this->authWaitList->SetOnContactListChangedCallback(
+ (CContactGroup::OnContactListChanged)&CSkypeProto::OnContactListChanged,
+ this);
+ this->authWaitList->GetContacts(authContacts);
+ //Sid::fetch(this->contactList);
+
+ for (unsigned int i = 0; i < authContacts.size(); i++)
+ {
+ CContact::Ref contact = authContacts[i];
+ /*contact->SetOnContactChangedCallback(
+ (CContact::OnContactChanged)&CSkypeProto::OnContactChanged,
+ this);*/
+
+ SEString data;
+
+ uint newTS = 0;
+ contact->GetPropAuthreqTimestamp(newTS);
+
+ contact->GetPropSkypename(data);
+ char* sid = ::mir_utf8decodeA((const char*)data);
+
+ contact->GetPropDisplayname(data);
+ char* nick = ::mir_utf8decodeA((const char*)data);
+
+ contact->GetPropReceivedAuthrequest(data);
+ char* reason = ::mir_utf8decodeA((const char*)data);
+
+ contact->GetPropFullname(data);
+ char* fullname = ::mir_utf8decodeA((const char*)data);
+
+ char* first = strtok(fullname, " ");
+ char* last = strtok(NULL, " ");
+ if (last == NULL) last = "";
+
+ this->RaiseAuthRequestEvent(newTS, sid, nick, first, last, reason);
+ }
}
void CSkypeProto::SetAllContactStatus(int status)
@@ -637,9 +702,8 @@ void CSkypeProto::SetAllContactStatus(int status)
while (hContact)
{
if (this->IsProtoContact(hContact))
- if ( !this->GetSettingWord(hContact, SKYPE_SETTINGS_STATUS, ID_STATUS_OFFLINE) == status)
+ //if ( !this->GetSettingWord(hContact, SKYPE_SETTINGS_STATUS, ID_STATUS_OFFLINE) == status)
this->SetSettingWord(hContact, SKYPE_SETTINGS_STATUS, status);
-
hContact = (HANDLE)::CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0);
}
} \ No newline at end of file
diff --git a/protocols/Skype/src/skype_database.cpp b/protocols/Skype/src/skype_database.cpp
index b22c632be0..38c08d80b8 100644
--- a/protocols/Skype/src/skype_database.cpp
+++ b/protocols/Skype/src/skype_database.cpp
@@ -27,7 +27,7 @@ void CSkypeProto::RaiseAuthRequestEvent(
CCSDATA ccs = {0};
ccs.szProtoService = PSR_AUTH;
- ccs.hContact = this->GetContactBySid(::mir_a2u(sid));
+ ccs.hContact = this->AddContactBySid(::mir_a2u(sid), ::mir_a2u(nick));
ccs.wParam = 0;
ccs.lParam = (LPARAM)&pre;
pre.timestamp = timestamp;
@@ -46,8 +46,8 @@ void CSkypeProto::RaiseAuthRequestEvent(
*((PDWORD)pCurBlob) = 0; pCurBlob += sizeof(DWORD);
*((PDWORD)pCurBlob) = (DWORD)ccs.hContact; pCurBlob += sizeof(DWORD);
::strcpy((char*)pCurBlob, nick); pCurBlob += ::strlen(nick) + 1;
- ::strcpy((char*)pCurBlob, firstName); pCurBlob += ::strlen(sid) + 1;
- ::strcpy((char*)pCurBlob, lastName); pCurBlob += ::strlen(sid) + 1;
+ ::strcpy((char*)pCurBlob, firstName); pCurBlob += ::strlen(firstName) + 1;
+ ::strcpy((char*)pCurBlob, lastName); pCurBlob += ::strlen(lastName) + 1;
::strcpy((char*)pCurBlob, sid); pCurBlob += ::strlen(sid) + 1;
::strcpy((char*)pCurBlob, reason);
diff --git a/protocols/Skype/src/skype_dialogs.cpp b/protocols/Skype/src/skype_dialogs.cpp
index 72fa4b2613..6f86907bfc 100644
--- a/protocols/Skype/src/skype_dialogs.cpp
+++ b/protocols/Skype/src/skype_dialogs.cpp
@@ -13,13 +13,13 @@ INT_PTR CALLBACK CSkypeProto::SkypeAccountProc(HWND hwnd, UINT message, WPARAM w
proto = reinterpret_cast<CSkypeProto*>(lparam);
SetWindowLongPtr(hwnd, GWLP_USERDATA, lparam);
- wchar_t* data = proto->GetSettingString(SKYPE_SETTINGS_LOGIN, L"");
- SetDlgItemText(hwnd, IDC_SL, data);
- ::mir_free(data);
+ wchar_t* sid = proto->GetSettingString(SKYPE_SETTINGS_LOGIN);
+ SetDlgItemText(hwnd, IDC_SL, sid);
+ ::mir_free(sid);
- data = proto->GetDecodeSettingString(SKYPE_SETTINGS_PASSWORD, L"");
- SetDlgItemText(hwnd, IDC_PW, data);
- ::mir_free(data);
+ wchar_t* pwd = proto->GetDecodeSettingString(SKYPE_SETTINGS_PASSWORD);
+ SetDlgItemText(hwnd, IDC_PW, pwd);
+ ::mir_free(pwd);
if ( proto->m_iStatus != ID_STATUS_OFFLINE)
{
diff --git a/protocols/Skype/src/skype_proto.cpp b/protocols/Skype/src/skype_proto.cpp
index 75f2686eae..b7a13163e1 100644
--- a/protocols/Skype/src/skype_proto.cpp
+++ b/protocols/Skype/src/skype_proto.cpp
@@ -90,7 +90,7 @@ int __cdecl CSkypeProto::AuthDeny(HANDLE hDbEvent, const TCHAR* szReason)
return 1;
CContact::Ref contact;
- SEString sid(::mir_u2a(this->GetSettingString(hContact, "SkypeName")));
+ SEString sid(::mir_u2a(this->GetSettingString(hContact, "sid")));
g_skype->GetContact(sid, contact);
contact->SetBuddyStatus(false/*CContact::BLOCKED_BY_ME*/);
@@ -126,7 +126,7 @@ int __cdecl CSkypeProto::AuthRequest(HANDLE hContact, const TCHAR* szMessage)
if (this->IsOnline() && hContact)
{
CContact::Ref contact;
- SEString sid(::mir_u2a(this->GetSettingString(hContact, "SkypeName")));
+ SEString sid(::mir_u2a(this->GetSettingString(hContact, "sid")));
g_skype->GetContact(sid, contact);
contact->SendAuthRequest(::mir_u2a(szMessage));
@@ -160,7 +160,7 @@ DWORD_PTR __cdecl CSkypeProto:: GetCaps(int type, HANDLE hContact)
case PFLAG_UNIQUEIDTEXT:
return (INT_PTR)Translate("Skype Name");
case PFLAG_UNIQUEIDSETTING:
- return (INT_PTR) L"SkypeName";
+ return (INT_PTR) L"sid";
default:
return 0;
}
@@ -271,8 +271,8 @@ void __cdecl CSkypeProto::SignIn(void*)
this->account->BlockWhileLoggingIn();
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);
}
diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h
index 37d869d581..3338a5e1ec 100644
--- a/protocols/Skype/src/skype_proto.h
+++ b/protocols/Skype/src/skype_proto.h
@@ -104,7 +104,9 @@ public:
protected:
CAccount::Ref account;
- CContactGroup::Ref contactList;
+ CContact::Refs contactList;
+ CContactGroup::Ref commonList;
+ CContactGroup::Ref authWaitList;
TCHAR* login;
TCHAR* password;
diff --git a/protocols/Skype/src/skype_settings.cpp b/protocols/Skype/src/skype_settings.cpp
index 88826fb613..71cf0e2b1c 100644
--- a/protocols/Skype/src/skype_settings.cpp
+++ b/protocols/Skype/src/skype_settings.cpp
@@ -33,15 +33,15 @@ DWORD CSkypeProto::GetSettingDword(const char *setting, DWORD errorValue)
wchar_t* CSkypeProto::GetSettingString(HANDLE hContact, const char *setting, wchar_t* errorValue)
{
DBVARIANT dbv;
- wchar_t* result = NULL;
+ wchar_t* result = errorValue;
if ( !::DBGetContactSettingWString(hContact, this->m_szModuleName, setting, &dbv))
{
- result = mir_wstrdup(dbv.pwszVal);
+ result = ::mir_wstrdup(dbv.pwszVal);
DBFreeVariant(&dbv);
}
- return result != NULL ? result : errorValue;
+ return result;
}
wchar_t* CSkypeProto::GetSettingString(const char *setting, wchar_t* errorValue)
@@ -51,12 +51,19 @@ wchar_t* CSkypeProto::GetSettingString(const char *setting, wchar_t* errorValue)
wchar_t* CSkypeProto::GetDecodeSettingString(HANDLE hContact, const char *setting, wchar_t* errorValue)
{
- TCHAR* result = this->GetSettingString(hContact, setting, errorValue);
+ DBVARIANT dbv;
+ wchar_t* result = errorValue;
- CallService(
- MS_DB_CRYPT_DECODESTRING,
- wcslen(result) + 1,
- reinterpret_cast<LPARAM>(result));
+ if ( !::DBGetContactSettingWString(hContact, this->m_szModuleName, setting, &dbv))
+ {
+ result = ::mir_wstrdup(dbv.pwszVal);
+ DBFreeVariant(&dbv);
+
+ CallService(
+ MS_DB_CRYPT_DECODESTRING,
+ wcslen(result) + 1,
+ reinterpret_cast<LPARAM>(result));
+ }
return result;
}
diff --git a/protocols/Skype/src/skype_subclassing.cpp b/protocols/Skype/src/skype_subclassing.cpp
index c7752eeca9..4f9f7bf2f4 100644
--- a/protocols/Skype/src/skype_subclassing.cpp
+++ b/protocols/Skype/src/skype_subclassing.cpp
@@ -78,10 +78,10 @@ void CContactGroup::SetOnContactListChangedCallback(OnContactListChanged callbac
this->callback = callback;
}
-bool CContactGroup::Contains(const ContactRef& contact)
-{
- return this->ContactList.contains(contact);
-}
+//bool CContactGroup::Contains(const ContactRef& contact)
+//{
+// return this->ContactList.contains(contact);
+//}
void CContactGroup::OnChange(const ContactRef& contact)
{
diff --git a/protocols/Skype/src/skype_subclassing.h b/protocols/Skype/src/skype_subclassing.h
index bef67606a8..46dad87fb6 100644
--- a/protocols/Skype/src/skype_subclassing.h
+++ b/protocols/Skype/src/skype_subclassing.h
@@ -47,10 +47,10 @@ public:
typedef DRefs<CContactGroup, ContactGroup> Refs;
CContactGroup(unsigned int oid, SERootObject* root);
- CContact::Refs ContactList;
+ //CContact::Refs ContactList;
void SetOnContactListChangedCallback(OnContactListChanged callback, CSkypeProto* proto);
- bool Contains(const ContactRef& contact);
+ //bool Contains(const ContactRef& contact);
private:
CSkypeProto* proto;