summaryrefslogtreecommitdiff
path: root/protocols/Facebook
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-08-18 18:09:03 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-08-18 18:09:03 +0300
commit0dbba78f4fb4a05945be5aab0848c01881b8ac12 (patch)
tree22202337f33799f5aef325ac24bae201f724e939 /protocols/Facebook
parent5793d48b5574e234397f6cb7a96997342ba44ac0 (diff)
SmileyAdd:
- fixes #2545 (SmileyAdd: missing assigned per-contact smileys categories); - unused service MS_SMILEYADD_SHOWSELECTION removed; - name conflict resolution; - version bump;
Diffstat (limited to 'protocols/Facebook')
-rw-r--r--protocols/Facebook/src/proto.cpp7
-rw-r--r--protocols/Facebook/src/server.cpp47
2 files changed, 34 insertions, 20 deletions
diff --git a/protocols/Facebook/src/proto.cpp b/protocols/Facebook/src/proto.cpp
index d2011579de..1cf3d3156c 100644
--- a/protocols/Facebook/src/proto.cpp
+++ b/protocols/Facebook/src/proto.cpp
@@ -133,10 +133,15 @@ FacebookProto::~FacebookProto()
void FacebookProto::OnModulesLoaded()
{
- CMStringW wszPath(FORMAT, L"%s\\%S\\Stickers\\*.png", VARSW(L"%miranda_avatarcache%").get(), m_szModuleName);
+ VARSW wszCache(L"%miranda_avatarcache%");
+
+ CMStringW wszPath(FORMAT, L"%s\\%S\\Stickers\\*.png", wszCache.get(), m_szModuleName);
SMADD_CONT cont = { 2, m_szModuleName, wszPath };
CallService(MS_SMILEYADD_LOADCONTACTSMILEYS, 0, LPARAM(&cont));
+ wszPath.Format(L"%s\\%S\\Stickers\\*.webp", wszCache.get(), m_szModuleName);
+ cont.path = wszPath;
+ CallService(MS_SMILEYADD_LOADCONTACTSMILEYS, 0, LPARAM(&cont));
}
void FacebookProto::OnShutdown()
diff --git a/protocols/Facebook/src/server.cpp b/protocols/Facebook/src/server.cpp
index 67e0ba323e..036c8f2db4 100644
--- a/protocols/Facebook/src/server.cpp
+++ b/protocols/Facebook/src/server.cpp
@@ -96,8 +96,8 @@ FacebookUser* FacebookProto::AddContact(const CMStringW &wszId, bool bTemp)
Contact_RemoveFromList(hContact);
auto* ret = new FacebookUser(_wtoi64(wszId), hContact);
-
m_users.insert(ret);
+
return ret;
}
@@ -527,7 +527,7 @@ void FacebookProto::OnPublishPresence(FbThriftReader &rdr)
rdr.readField(fieldType, fieldId);
assert(fieldType == FB_THRIFT_TYPE_I64);
- assert(fieldId == 1 || fieldId == 4);
+ assert(fieldId == 1 || fieldId == 3 || fieldId == 4);
rdr.readInt64(timestamp);
while (!rdr.isStop()) {
@@ -710,7 +710,14 @@ void FacebookProto::OnPublishPrivateMessage(const JSONNode &root)
bool bSuccess = false;
CMStringW wszFileName(FORMAT, L"%s\\STK{%S}.png", wszPath.c_str(), stickerId.c_str());
- if (GetFileAttributesW(wszFileName) == INVALID_FILE_ATTRIBUTES) {
+ DWORD dwAttrib = GetFileAttributesW(wszFileName);
+ if (dwAttrib == INVALID_FILE_ATTRIBUTES) {
+ wszFileName.Format(L"%s\\STK{%S}.webp", wszPath.c_str(), stickerId.c_str());
+ dwAttrib = GetFileAttributesW(wszFileName);
+ }
+
+ // new sticker
+ if (dwAttrib == INVALID_FILE_ATTRIBUTES) {
auto *pReq = CreateRequestGQL(FB_API_QUERY_STICKER);
pReq << CHAR_PARAM("query_params", CMStringA(FORMAT, "{\"0\":[\"%s\"]}", stickerId.c_str()));
pReq->CalcSig();
@@ -718,22 +725,24 @@ void FacebookProto::OnPublishPrivateMessage(const JSONNode &root)
JsonReply reply(ExecuteRequest(pReq));
if (!reply.error()) {
for (auto &sticker : reply.data()) {
- for (auto &img : sticker["thread_image"]) {
- CMStringA szUrl(img.as_mstring());
-
- NETLIBHTTPREQUEST req = {};
- req.cbSize = sizeof(req);
- req.flags = NLHRF_NODUMP | NLHRF_SSL | NLHRF_HTTP11 | NLHRF_REDIRECT;
- req.requestType = REQUEST_GET;
- req.szUrl = szUrl.GetBuffer();
-
- NETLIBHTTPREQUEST *pReply = Netlib_HttpTransaction(m_hNetlibUser, &req);
- if (pReply != nullptr && pReply->resultCode == 200 && pReply->pData && pReply->dataLength) {
- bSuccess = true;
- FILE *out = _wfopen(wszFileName, L"wb");
- fwrite(pReply->pData, 1, pReply->dataLength, out);
- fclose(out);
- }
+ std::string szUrl = sticker["animated_image"]["uri"].as_string();
+ if (szUrl.empty())
+ szUrl = sticker["thread_image"]["uri"].as_string();
+ else
+ wszFileName.Format(L"%s\\STK{%S}.webp", wszPath.c_str(), stickerId.c_str());
+
+ NETLIBHTTPREQUEST req = {};
+ req.cbSize = sizeof(req);
+ req.flags = NLHRF_NODUMP | NLHRF_SSL | NLHRF_HTTP11 | NLHRF_REDIRECT;
+ req.requestType = REQUEST_GET;
+ req.szUrl = (char*)szUrl.c_str();
+
+ NETLIBHTTPREQUEST *pReply = Netlib_HttpTransaction(m_hNetlibUser, &req);
+ if (pReply != nullptr && pReply->resultCode == 200 && pReply->pData && pReply->dataLength) {
+ bSuccess = true;
+ FILE *out = _wfopen(wszFileName, L"wb");
+ fwrite(pReply->pData, 1, pReply->dataLength, out);
+ fclose(out);
}
}
}