diff options
author | George Hazan <ghazan@miranda.im> | 2020-08-14 17:44:14 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2020-08-14 17:44:20 +0300 |
commit | 70c7eb36da13424bf1bfabb56977562fee7241de (patch) | |
tree | 533939357b485c0e53b43f267d9b938b5c758abf | |
parent | f937a646677d1eb3e139aacccc8ecf4064d6b145 (diff) |
fixes #2527 (Facebook: missing stickers)
-rw-r--r-- | protocols/Facebook/src/main.cpp | 1 | ||||
-rw-r--r-- | protocols/Facebook/src/proto.cpp | 22 |
2 files changed, 21 insertions, 2 deletions
diff --git a/protocols/Facebook/src/main.cpp b/protocols/Facebook/src/main.cpp index 6ed0c4cd35..bbeeb63860 100644 --- a/protocols/Facebook/src/main.cpp +++ b/protocols/Facebook/src/main.cpp @@ -68,6 +68,5 @@ int CMPlugin::Load() HookEvent(ME_SYSTEM_MODULESLOADED, OnModuleLoaded); // Initialize random generator (used only as fallback in utils) - srand(::time(0)); return 0; } diff --git a/protocols/Facebook/src/proto.cpp b/protocols/Facebook/src/proto.cpp index cc2092bda3..87ca21d84b 100644 --- a/protocols/Facebook/src/proto.cpp +++ b/protocols/Facebook/src/proto.cpp @@ -75,7 +75,9 @@ FacebookProto::FacebookProto(const char *proto_name, const wchar_t *username) : m_szClientID = getMStringA(DBKEY_CLIENT_ID); if (m_szClientID.IsEmpty()) { for (int i = 0; i < 20; i++) { - int c = rand() % 62; + DWORD dwRandon; + Utils_GetRandom(&dwRandon, sizeof(dwRandon)); + int c = dwRandon % 62; if (c >= 0 && c < 26) c += 'a'; else if (c >= 26 && c < 52) @@ -131,6 +133,24 @@ FacebookProto::~FacebookProto() void FacebookProto::OnModulesLoaded() { + CMStringW wszPath(FORMAT, L"%s\\%S\\Stickers\\*.png", VARSW(L"%miranda_avatarcache%").get(), m_szModuleName); + + WIN32_FIND_DATAW findData; + HANDLE hFind = FindFirstFileW(wszPath, &findData); + if (hFind != INVALID_HANDLE_VALUE) { + wszPath.Truncate(wszPath.GetLength() - 5); + do { + CMStringW wszFileName = wszPath + findData.cFileName; + + SMADD_CONT cont; + cont.cbSize = sizeof(SMADD_CONT); + cont.hContact = 0; + cont.type = 1; + cont.path = wszFileName.GetBuffer(); + CallService(MS_SMILEYADD_LOADCONTACTSMILEYS, 0, (LPARAM)&cont); + } + while (FindNextFileW(hFind, &findData)); + } } void FacebookProto::OnShutdown() |