summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM/proto.cpp
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2012-05-25 19:19:29 +0000
committerRobert Pösel <robyer@seznam.cz>2012-05-25 19:19:29 +0000
commit8b40cd9cc08fa1f252948db272c148cc72adccec (patch)
tree0dd2a06e547fc298785c5036c285ee0760abfed2 /protocols/FacebookRM/proto.cpp
parent6f21483e7347b4a6e3ec24856cba12147ba11fc3 (diff)
Facebook: Fixed auths through auth dialog
git-svn-id: http://svn.miranda-ng.org/main/trunk@178 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM/proto.cpp')
-rw-r--r--protocols/FacebookRM/proto.cpp55
1 files changed, 50 insertions, 5 deletions
diff --git a/protocols/FacebookRM/proto.cpp b/protocols/FacebookRM/proto.cpp
index fd203dffb2..820a1c3fb6 100644
--- a/protocols/FacebookRM/proto.cpp
+++ b/protocols/FacebookRM/proto.cpp
@@ -287,15 +287,38 @@ int FacebookProto::AuthRequest(HANDLE hContact,const PROTOCHAR *message)
return RequestFriendship((WPARAM)hContact, NULL);
}
-int FacebookProto::Authorize(HANDLE hContact)
+int FacebookProto::Authorize(HANDLE hDbEvent)
{
- return ApproveFriendship((WPARAM)hContact, NULL);
+ if (!isOffline() && hDbEvent)
+ {
+ HANDLE hContact = HContactFromAuthEvent( hDbEvent );
+ if (hContact == INVALID_HANDLE_VALUE)
+ return 1;
+
+ return ApproveFriendship((WPARAM)hContact, NULL);
+ }
+
+ return 1;
}
-int FacebookProto::AuthDeny(HANDLE hContact,const PROTOCHAR *reason)
+int FacebookProto::AuthDeny(HANDLE hDbEvent, const PROTOCHAR *reason)
{
- // TODO: hide from facebook requests list
- return 0;
+
+ if (!isOffline() && hDbEvent)
+ {
+ HANDLE hContact = HContactFromAuthEvent(hDbEvent);
+ if (hContact == INVALID_HANDLE_VALUE)
+ return 1;
+
+ // TODO: hide from facebook requests list
+
+ if (DBGetContactSettingByte(hContact, "CList", "NotOnList", 0))
+ CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
+
+ return 0;
+ }
+
+ return 1;
}
//////////////////////////////////////////////////////////////////////////////
@@ -531,3 +554,25 @@ int FacebookProto::ApproveFriendship(WPARAM wParam,LPARAM lParam)
return 0;
}
+
+HANDLE FacebookProto::HContactFromAuthEvent(HANDLE hEvent)
+{
+ DBEVENTINFO dbei;
+ DWORD body[3];
+
+ ZeroMemory(&dbei, sizeof(dbei));
+ dbei.cbSize = sizeof(dbei);
+ dbei.cbBlob = sizeof(DWORD) + sizeof(HANDLE);
+ dbei.pBlob = (PBYTE)&body;
+
+ if (CallService(MS_DB_EVENT_GET, (WPARAM)hEvent, (LPARAM)&dbei))
+ return INVALID_HANDLE_VALUE;
+
+ if (dbei.eventType != EVENTTYPE_AUTHREQUEST)
+ return INVALID_HANDLE_VALUE;
+
+ if (strcmp(dbei.szModule, m_szModuleName))
+ return INVALID_HANDLE_VALUE;
+
+ return *(HANDLE*)&body[1]; // this is bad - needs new auth system
+}