summaryrefslogtreecommitdiff
path: root/protocols/Skype/src
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Skype/src')
-rw-r--r--protocols/Skype/src/skype_contacts.cpp72
-rw-r--r--protocols/Skype/src/skype_events.cpp4
-rw-r--r--protocols/Skype/src/skype_menus.cpp58
-rw-r--r--protocols/Skype/src/skype_proto.cpp13
-rw-r--r--protocols/Skype/src/skype_proto.h2
5 files changed, 54 insertions, 95 deletions
diff --git a/protocols/Skype/src/skype_contacts.cpp b/protocols/Skype/src/skype_contacts.cpp
index e1d21ef8f8..60d062f9cd 100644
--- a/protocols/Skype/src/skype_contacts.cpp
+++ b/protocols/Skype/src/skype_contacts.cpp
@@ -19,14 +19,19 @@ void CSkypeProto::UpdateContactAuthState(HANDLE hContact, CContact::Ref contact)
DWORD oldTS = this->GetSettingDword(hContact, "AuthTS");
if (newTS > oldTS)
{
- CContact::AVAILABILITY data;
- contact->GetPropAvailability(data);
- this->SetSettingWord(hContact, SKYPE_SETTINGS_STATUS, this->SkypeToMirandaStatus(data));
-
- if (data == CContact::PENDINGAUTH)
- this->SetSettingWord(hContact, "Auth", 1);
+ bool result;
+ if (contact->HasAuthorizedMe(result) && !result)
+ {
+ this->SetSettingByte(hContact, "Auth", !result);
+ }
else
+ {
this->DeleteSetting(hContact, "Auth");
+ if (contact->IsMemberOfHardwiredGroup(CContactGroup::ALL_BUDDIES, result) && !result)
+ this->SetSettingByte(hContact, "Grant", !result);
+ else
+ this->DeleteSetting(hContact, "Grant");
+ }
this->SetSettingDword(hContact, "AuthTS", newTS);
}
@@ -681,47 +686,6 @@ void CSkypeProto::OnContactChanged(CContact::Ref contact, int prop)
break;
}
}
- else
- {
- }
- //else
- //{
- // switch(prop)
- // {
- // case CContact::P_RECEIVED_AUTHREQUEST:
- // contact->GetPropDisplayname(data);
- // wchar_t* displayName = ::mir_a2u((const char*)data);
-
- // CCSDATA ccs = {0};
- // ccs.szProtoService = PSR_AUTH;
- // ccs.hContact = this->AddContactBySkypeName(skypeName, displayName, PALF_TEMPORARY);
- // //pre.szMessage = (LPSTR)btBuff;
- // //CreateBlobFromContact(ccs.hContact, lpwszMessage, dwMessageSize, btBuff, SIZEOF(btBuff), (size_t*)&pre.lParam);
- // CallService(MS_PROTO_CHAINRECV, 0, (LPARAM)&ccs);
- // break;
- // }
- //}
-
- //if (prop == CContact::P_AVAILABILITY)
- //{
- // SEString data;
-
- // contact->GetPropSkypename(data);
- // wchar_t* skypeName = ::mir_a2u((const char*)data);
-
- // HANDLE hContact = this->GetContactBySkypeName(skypeName);
- // if (hContact)
- // {
- // CContact::AVAILABILITY availability;
- // contact->GetPropAvailability(availability);
- // this->SetSettingWord(hContact, SKYPE_SETTINGS_STATUS, this->SkypeToMirandaStatus(availability));
-
- // if (availability == CContact::PENDINGAUTH)
- // this->SetSettingWord(hContact, "Auth", 1);
- // else
- // this->DeleteSetting(hContact, "Auth");
- // }
- //}
}
void CSkypeProto::OnContactListChanged(const ContactRef& contact)
@@ -867,20 +831,6 @@ int CSkypeProto::SkypeToMirandaStatus(CContact::AVAILABILITY availability)
return status;
}
-void CSkypeProto::RemoveContact(HANDLE hContact)
-{
- if (this->IsOnline() && hContact)
- {
- CContact::Ref contact;
- SEString sid(::mir_u2a(this->GetSettingString(hContact, "sid")));
- if (g_skype->GetContact(sid, contact))
- {
- contact->SetBuddyStatus(false);
- this->contactList.remove_val(contact);
- }
- }
-}
-
CContact::AVAILABILITY CSkypeProto::MirandaToSkypeStatus(int status)
{
CContact::AVAILABILITY availability = CContact::UNKNOWN;
diff --git a/protocols/Skype/src/skype_events.cpp b/protocols/Skype/src/skype_events.cpp
index 99d5c6bb6e..aa08a532e7 100644
--- a/protocols/Skype/src/skype_events.cpp
+++ b/protocols/Skype/src/skype_events.cpp
@@ -17,9 +17,9 @@ int CSkypeProto::OnPreShutdown(WPARAM, LPARAM)
return 0;
}
-int CSkypeProto::OnContactDeleted(WPARAM wParam, LPARAM)
+int CSkypeProto::OnContactDeleted(WPARAM wParam, LPARAM lParam)
{
- this->RemoveContact((HANDLE)wParam);
+ this->RevokeAuth(wParam, lParam);
return 0;
}
diff --git a/protocols/Skype/src/skype_menus.cpp b/protocols/Skype/src/skype_menus.cpp
index 8cd8fa3bf3..7887bf9054 100644
--- a/protocols/Skype/src/skype_menus.cpp
+++ b/protocols/Skype/src/skype_menus.cpp
@@ -31,15 +31,16 @@ int CSkypeProto::OnPrebuildContactMenu(WPARAM wParam, LPARAM)
if (hContact == NULL)
return 0;
- if (this->IsOnline() && !DBGetContactSettingByte(hContact, m_szModuleName, "ChatRoom", 0))
+ if (this->IsOnline() && !::DBGetContactSettingByte(hContact, m_szModuleName, "ChatRoom", 0))
{
bool ctrlPressed = (GetKeyState(VK_CONTROL) & 0x8000) != 0;
- //BYTE type = DBGetContactSettingByte(hContact, m_szModuleName, FACEBOOK_KEY_CONTACT_TYPE, 0);
+ bool authNeed = this->GetSettingByte(hContact, "Auth");
+ bool grantNeed = this->GetSettingByte(hContact, "Grant");
- sttEnableMenuItem( g_hContactMenuItems[CMI_AUTH_REQUEST], ctrlPressed /*|| type == FACEBOOK_CONTACT_NONE || !type */);
- sttEnableMenuItem( g_hContactMenuItems[CMI_AUTH_GRANT], ctrlPressed /*|| type == FACEBOOK_CONTACT_APPROVE */);
- sttEnableMenuItem( g_hContactMenuItems[CMI_AUTH_REVOKE], ctrlPressed /*|| type == FACEBOOK_CONTACT_FRIEND */);
+ sttEnableMenuItem( g_hContactMenuItems[CMI_AUTH_REQUEST], ctrlPressed || authNeed);
+ sttEnableMenuItem( g_hContactMenuItems[CMI_AUTH_GRANT], ctrlPressed || grantNeed);
+ sttEnableMenuItem( g_hContactMenuItems[CMI_AUTH_REVOKE], ctrlPressed || (!grantNeed && !authNeed));
}
return 0;
@@ -67,21 +68,8 @@ INT_PTR GlobalService(WPARAM wParam, LPARAM lParam)
int CSkypeProto::RequestAuth(WPARAM wParam, LPARAM lParam)
{
- if (this->IsOnline() && wParam)
- {
- HANDLE hContact = (HANDLE)wParam;
- TCHAR* szMessage = (TCHAR*)lParam;
- CContact::Ref contact;
- SEString sid(::mir_u2a(this->GetSettingString(hContact, "sid")));
- g_skype->GetContact(sid, contact);
-
- contact->SendAuthRequest(::mir_u2a(szMessage));
- this->DeleteSetting(hContact, "Grant");
-
- return 0;
- }
-
- return 1;
+ // todo: set default auth request
+ this->AuthRequest((HANDLE)wParam, LPGENT(""));
}
int CSkypeProto::GrantAuth(WPARAM wParam, LPARAM lParam)
@@ -89,8 +77,11 @@ int CSkypeProto::GrantAuth(WPARAM wParam, LPARAM lParam)
CContact::Ref contact;
HANDLE hContact = (HANDLE)wParam;
SEString sid(::mir_u2a(this->GetSettingString(hContact, "sid")));
- g_skype->GetContact(sid, contact);
- contact->SetBuddyStatus(true/*Contact::AUTHORIZED_BY_ME*/);
+ if (g_skype->GetContact(sid, contact))
+ {
+ if (contact->SetBuddyStatus(true))
+ this->DeleteSetting(hContact, "Grant");
+ }
return 0;
}
@@ -100,8 +91,15 @@ int CSkypeProto::RevokeAuth(WPARAM wParam, LPARAM lParam)
CContact::Ref contact;
HANDLE hContact = (HANDLE)wParam;
SEString sid(::mir_u2a(this->GetSettingString(hContact, "sid")));
- g_skype->GetContact(sid, contact);
- contact->SetBuddyStatus(false/*CContact::BLOCKED_BY_ME*/);
+ if (g_skype->GetContact(sid, contact))
+ {
+ if (contact->SetBuddyStatus(false))
+ {
+ //this->DeleteSetting(hContact, "Auth");
+ this->SetSettingByte(hContact, "Grant", 1);
+ }
+ this->contactList.remove_val(contact);
+ }
return 0;
}
@@ -141,24 +139,24 @@ void CSkypeProto::InitMenus()
mi.position = -2000001000;
mi.icolibItem = CSkypeProto::GetIconHandle("authRequest");
mi.pszService = "Skype/ReqAuth";
- g_hContactMenuItems[CMI_AUTH_REQUEST] = Menu_AddContactMenuItem(&mi);
- g_hContactMenuSvc[CMI_AUTH_REQUEST] = CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::RequestAuth>);
+ g_hContactMenuItems[CMI_AUTH_REQUEST] = ::Menu_AddContactMenuItem(&mi);
+ g_hContactMenuSvc[CMI_AUTH_REQUEST] = ::CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::RequestAuth>);
// "Grant authorization"
mi.pszService = "Skype/GrantAuth";
mi.ptszName = LPGENT("Grant authorization");
mi.position = -2000001001;
mi.icolibItem = CSkypeProto::GetIconHandle("authGrant");
- g_hContactMenuItems[CMI_AUTH_GRANT] = Menu_AddContactMenuItem(&mi);
- g_hContactMenuSvc[CMI_AUTH_GRANT] = CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::GrantAuth>);
+ g_hContactMenuItems[CMI_AUTH_GRANT] = ::Menu_AddContactMenuItem(&mi);
+ g_hContactMenuSvc[CMI_AUTH_GRANT] = ::CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::GrantAuth>);
// Revoke auth
mi.pszService = "Skype/RevokeAuth";
mi.ptszName = LPGENT("Revoke authorization");
mi.position = -2000001002;
mi.icolibItem = CSkypeProto::GetIconHandle("authRevoke");
- g_hContactMenuItems[CMI_AUTH_REVOKE] = Menu_AddContactMenuItem(&mi);
- g_hContactMenuSvc[CMI_AUTH_REVOKE] = CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::RevokeAuth>);
+ g_hContactMenuItems[CMI_AUTH_REVOKE] = ::Menu_AddContactMenuItem(&mi);
+ g_hContactMenuSvc[CMI_AUTH_REVOKE] = ::CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::RevokeAuth>);
}
void CSkypeProto::UninitMenus()
diff --git a/protocols/Skype/src/skype_proto.cpp b/protocols/Skype/src/skype_proto.cpp
index 750ea27a12..a72ce2a76b 100644
--- a/protocols/Skype/src/skype_proto.cpp
+++ b/protocols/Skype/src/skype_proto.cpp
@@ -117,7 +117,18 @@ int __cdecl CSkypeProto::AuthRecv(HANDLE hContact, PROTORECVEVENT* pre)
int __cdecl CSkypeProto::AuthRequest(HANDLE hContact, const TCHAR* szMessage)
{
- return CSkypeProto::RequestAuth((WPARAM)hContact, (LPARAM)szMessage);
+ if (this->IsOnline() && hContact)
+ {
+ HANDLE hContact = (HANDLE)hContact;
+ CContact::Ref contact;
+ SEString sid(::mir_u2a(this->GetSettingString(hContact, "sid")));
+ if (g_skype->GetContact(sid, contact))
+ contact->SendAuthRequest(::mir_u2a(szMessage));
+
+ return 0;
+ }
+
+ return 1;
}
HANDLE __cdecl CSkypeProto::ChangeInfo( int iInfoType, void* pInfoData ) { return 0; }
diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h
index 6337a39b05..8529496b2c 100644
--- a/protocols/Skype/src/skype_proto.h
+++ b/protocols/Skype/src/skype_proto.h
@@ -162,7 +162,7 @@ protected:
HANDLE GetContactBySid(const wchar_t* sid);
HANDLE GetContactFromAuthEvent(HANDLE hEvent);
HANDLE AddContactBySid(const wchar_t* skypeName, const wchar_t* nick, DWORD flags = 0);
- void RemoveContact(HANDLE hContact);
+
int SkypeToMirandaStatus(CContact::AVAILABILITY availability);
CContact::AVAILABILITY MirandaToSkypeStatus(int status);
void SetAllContactStatus(int status);