diff options
author | Robert Pösel <robyer@seznam.cz> | 2012-05-25 19:19:29 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2012-05-25 19:19:29 +0000 |
commit | 8b40cd9cc08fa1f252948db272c148cc72adccec (patch) | |
tree | 0dd2a06e547fc298785c5036c285ee0760abfed2 | |
parent | 6f21483e7347b4a6e3ec24856cba12147ba11fc3 (diff) |
Facebook: Fixed auths through auth dialog
git-svn-id: http://svn.miranda-ng.org/main/trunk@178 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | protocols/FacebookRM/proto.cpp | 55 | ||||
-rw-r--r-- | protocols/FacebookRM/proto.h | 1 |
2 files changed, 51 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
+}
diff --git a/protocols/FacebookRM/proto.h b/protocols/FacebookRM/proto.h index d4966874ce..8a10c5629a 100644 --- a/protocols/FacebookRM/proto.h +++ b/protocols/FacebookRM/proto.h @@ -168,6 +168,7 @@ public: HANDLE ContactIDToHContact(std::string);
HANDLE AddToContactList(facebook_user*, BYTE type, bool dont_check = false, const char *new_name = "");
void SetAllContactStatuses(int);
+ HANDLE HContactFromAuthEvent(HANDLE hEvent);
// Chats handling
void AddChat(const char *id, const char *name);
|