From b68362e4ca9a176bde960f20dce76822e0a5dd0e Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 17 Jan 2019 17:37:28 +0300 Subject: code cleaning --- protocols/FacebookRM/src/communication.cpp | 2 +- protocols/FacebookRM/src/main.cpp | 11 +++++++++++ protocols/FacebookRM/src/proto.cpp | 2 +- protocols/FacebookRM/src/stdafx.h | 3 ++- 4 files changed, 15 insertions(+), 3 deletions(-) (limited to 'protocols/FacebookRM/src') diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp index 4af77123c5..39f4a1866d 100644 --- a/protocols/FacebookRM/src/communication.cpp +++ b/protocols/FacebookRM/src/communication.cpp @@ -338,7 +338,7 @@ void facebook_client::insert_reader(MCONTACT hContact, time_t timestamp, const s parent->setDword(hContact, FACEBOOK_KEY_MESSAGE_READ, timestamp); readers.insert(std::make_pair(hContact, timestamp)); parent->MessageRead(hContact); - if (ServiceExists(MS_MESSAGESTATE_UPDATE)) { + if (g_bMessageState) { MessageReadData data(timestamp, MRD_TYPE_READTIME); CallService(MS_MESSAGESTATE_UPDATE, hContact, (LPARAM)&data); } diff --git a/protocols/FacebookRM/src/main.cpp b/protocols/FacebookRM/src/main.cpp index 6503feee49..ec84f62346 100644 --- a/protocols/FacebookRM/src/main.cpp +++ b/protocols/FacebookRM/src/main.cpp @@ -26,6 +26,7 @@ CMPlugin g_plugin; std::string g_strUserAgent; DWORD g_mirandaVersion; +bool g_bMessageState; ///////////////////////////////////////////////////////////////////////////////////////// @@ -56,8 +57,18 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOC ///////////////////////////////////////////////////////////////////////////////////////// // Load +static int OnModuleLoaded(WPARAM, LPARAM) +{ + g_bMessageState = ServiceExists(MS_MESSAGESTATE_UPDATE) != 0; + return 0; +} + int CMPlugin::Load() { + HookEvent(ME_SYSTEM_MODULELOAD, OnModuleLoaded); + HookEvent(ME_SYSTEM_MODULEUNLOAD, OnModuleLoaded); + OnModuleLoaded(0, 0); + InitIcons(); InitContactMenus(); diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp index b4eacb2407..fef127544d 100644 --- a/protocols/FacebookRM/src/proto.cpp +++ b/protocols/FacebookRM/src/proto.cpp @@ -1046,6 +1046,6 @@ void FacebookProto::MessageRead(MCONTACT hContact) ptrW treaders(getWStringA(hContact, FACEBOOK_KEY_MESSAGE_READERS)); Srmm_SetStatusText(hContact, CMStringW(FORMAT, TranslateT("Message read: %s by %s"), ttime, treaders ? treaders : L"???"), hIcon); } - else if (!ServiceExists(MS_MESSAGESTATE_UPDATE)) + else if (!g_bMessageState) Srmm_SetStatusText(hContact, CMStringW(FORMAT, TranslateT("Message read: %s"), ttime), hIcon); } diff --git a/protocols/FacebookRM/src/stdafx.h b/protocols/FacebookRM/src/stdafx.h index 7c0815d6aa..9077ed184c 100644 --- a/protocols/FacebookRM/src/stdafx.h +++ b/protocols/FacebookRM/src/stdafx.h @@ -81,10 +81,11 @@ class FacebookProto; extern std::string g_strUserAgent; extern DWORD g_mirandaVersion; +extern bool g_bMessageState; template __inline static void FreeList(const LIST &lst) { for (auto &it : lst) mir_free(it); -} \ No newline at end of file +} -- cgit v1.2.3