diff options
author | George Hazan <ghazan@miranda.im> | 2019-06-15 19:35:15 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-06-15 19:35:15 +0300 |
commit | 34967c6ad0a420ac99c1b873b569208bdb88782e (patch) | |
tree | eeb70963e18bf47b59451f9b294d500fa65704f8 /protocols | |
parent | 42756760a38d948a9ae898db08071e9ceb0324b0 (diff) |
Facebook: first server query
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/Facebook/src/main.cpp | 2 | ||||
-rw-r--r-- | protocols/Facebook/src/proto.cpp | 10 | ||||
-rw-r--r-- | protocols/Facebook/src/proto.h | 12 | ||||
-rw-r--r-- | protocols/Facebook/src/server.cpp | 48 |
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); +} |