summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/Facebook/src/main.cpp2
-rw-r--r--protocols/Facebook/src/proto.cpp10
-rw-r--r--protocols/Facebook/src/proto.h12
-rw-r--r--protocols/Facebook/src/server.cpp48
4 files changed, 72 insertions, 0 deletions
diff --git a/protocols/Facebook/src/main.cpp b/protocols/Facebook/src/main.cpp
index 7a8b8aa641..a00c1cbe23 100644
--- a/protocols/Facebook/src/main.cpp
+++ b/protocols/Facebook/src/main.cpp
@@ -21,6 +21,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
#include "version.h"
+#pragma comment(lib, "Rpcrt4.lib")
+
CMPlugin g_plugin;
bool g_bMessageState;
diff --git a/protocols/Facebook/src/proto.cpp b/protocols/Facebook/src/proto.cpp
index 63860bc617..4ef785127d 100644
--- a/protocols/Facebook/src/proto.cpp
+++ b/protocols/Facebook/src/proto.cpp
@@ -23,6 +23,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
FacebookProto::FacebookProto(const char *proto_name, const wchar_t *username) :
PROTO<FacebookProto>(proto_name, username)
{
+ szDeviceID = getMStringA(DBKEY_DEVICE_ID);
+ if (szDeviceID.IsEmpty()) {
+ UUID deviceId;
+ UuidCreate(&deviceId);
+ RPC_CSTR szId;
+ UuidToStringA(&deviceId, &szId);
+ szDeviceID = szId;
+ setString(DBKEY_DEVICE_ID, szDeviceID);
+ RpcStringFreeA(&szId);
+ }
}
diff --git a/protocols/Facebook/src/proto.h b/protocols/Facebook/src/proto.h
index 6d5bf0c421..ed4342b773 100644
--- a/protocols/Facebook/src/proto.h
+++ b/protocols/Facebook/src/proto.h
@@ -20,8 +20,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
+#include "../../../miranda-private-keys/Facebook/app_secret.h"
+
+class FacebookProto;
+
+struct AsyncHttpRequest : public MTHttpRequest<FacebookProto>
+{
+ void CalcSig();
+};
+
class FacebookProto : public PROTO<FacebookProto>
{
+ AsyncHttpRequest* CreateGraphql(const char *szName, const char *szMethod);
+
+ CMStringA szDeviceID;
public:
FacebookProto(const char *proto_name, const wchar_t *username);
diff --git a/protocols/Facebook/src/server.cpp b/protocols/Facebook/src/server.cpp
new file mode 100644
index 0000000000..e8387997e0
--- /dev/null
+++ b/protocols/Facebook/src/server.cpp
@@ -0,0 +1,48 @@
+/*
+
+Facebook plugin for Miranda NG
+Copyright © 2019 Miranda NG team
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include "stdafx.h"
+
+AsyncHttpRequest* FacebookProto::CreateGraphql(const char *szName, const char *szMethod)
+{
+ AsyncHttpRequest *pReq = new AsyncHttpRequest();
+ pReq->requestType = REQUEST_POST;
+ pReq->szUrl = "https://graph.facebook.com/graphql";
+ pReq << CHAR_PARAM("api_key", FB_APP_KEY) << CHAR_PARAM("device_id", szDeviceID) << CHAR_PARAM("fb_api_req_friendly_name", szName)
+ << CHAR_PARAM("format", "json") << CHAR_PARAM("method", szMethod);
+
+ CMStringA szLocale = getMStringA(DBKEY_LOCALE);
+ if (szLocale.IsEmpty())
+ szLocale = "en";
+ pReq << CHAR_PARAM("locale", szLocale);
+
+ unsigned int id;
+ Utils_GetRandom(&id, sizeof(id));
+ id &= ~0x80000000;
+ pReq << INT_PARAM("queryid", id);
+
+ return pReq;
+}
+
+void AsyncHttpRequest::CalcSig()
+{
+ CMStringA szSrc = m_szParam;
+ szSrc.Append(FB_APP_SECRET);
+}