summaryrefslogtreecommitdiff
path: root/protocols/Facebook/src/server.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Facebook/src/server.cpp')
-rw-r--r--protocols/Facebook/src/server.cpp36
1 files changed, 34 insertions, 2 deletions
diff --git a/protocols/Facebook/src/server.cpp b/protocols/Facebook/src/server.cpp
index dba8178fa8..162c6f9fa6 100644
--- a/protocols/Facebook/src/server.cpp
+++ b/protocols/Facebook/src/server.cpp
@@ -36,8 +36,7 @@ void FacebookProto::ServerThread(void *)
pReq->flags = NLHRF_HTTP11 | NLHRF_REDIRECT;
pReq->m_szUrl = "https://www.facebook.com/v3.3/dialog/oauth?client_id=478386432928815&redirect_uri=https://oauth.miranda-ng.org/facebook.php&state=qq";
- JsonReply reply(ExecuteRequest(pReq));
- if (reply.error()) {
+ if (JsonReply(ExecuteRequest(pReq)).error()) {
FAIL:
ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_FAILED, (HANDLE)m_iStatus, m_iDesiredStatus);
@@ -46,4 +45,37 @@ FAIL:
return;
}
}
+
+ auto *pReq = CreateRequest("FetchContactsFullQuery", "get");
+ pReq->m_szUrl = "https://graph.facebook.com/me/friends";
+ pReq->CalcSig();
+
+ JsonReply reply(ExecuteRequest(pReq));
+ if (reply.error())
+ goto FAIL;
+
+ if (!MqttConnect())
+ goto FAIL;
+
+ MqttOpen();
+
+ int bufSize = 2048;
+ char *buf = (char*)mir_alloc(bufSize);
+
+ while (!Miranda_IsTerminated()) {
+ int ret = Netlib_Recv(m_mqttConn, buf, bufSize);
+ if (ret == SOCKET_ERROR) {
+ debugLogA("Netlib_Recv() failed, error=%d", WSAGetLastError());
+ break;
+ }
+ if (ret == 0) {
+ debugLogA("Connection closed gracefully");
+ break;
+ }
+ }
+
+ debugLogA("exiting ServerThread");
+ int oldStatus = m_iStatus;
+ m_iDesiredStatus = m_iStatus = ID_STATUS_OFFLINE;
+ ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus);
}