summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-01-17 17:37:28 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-01-17 17:37:39 +0300
commitb68362e4ca9a176bde960f20dce76822e0a5dd0e (patch)
tree9985b477a54aa7d16f782f408cf74e828b8a3fed /protocols/FacebookRM
parent7623a366aeedaffb50057fc7ae01ad47925bb7fd (diff)
code cleaning
Diffstat (limited to 'protocols/FacebookRM')
-rw-r--r--protocols/FacebookRM/src/communication.cpp2
-rw-r--r--protocols/FacebookRM/src/main.cpp11
-rw-r--r--protocols/FacebookRM/src/proto.cpp2
-rw-r--r--protocols/FacebookRM/src/stdafx.h3
4 files changed, 15 insertions, 3 deletions
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 <typename T>
__inline static void FreeList(const LIST<T> &lst)
{
for (auto &it : lst)
mir_free(it);
-} \ No newline at end of file
+}