diff options
author | George Hazan <ghazan@miranda.im> | 2019-01-17 17:37:28 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-01-17 17:37:39 +0300 |
commit | b68362e4ca9a176bde960f20dce76822e0a5dd0e (patch) | |
tree | 9985b477a54aa7d16f782f408cf74e828b8a3fed /protocols/VKontakte/src | |
parent | 7623a366aeedaffb50057fc7ae01ad47925bb7fd (diff) |
code cleaning
Diffstat (limited to 'protocols/VKontakte/src')
-rw-r--r-- | protocols/VKontakte/src/main.cpp | 11 | ||||
-rw-r--r-- | protocols/VKontakte/src/misc.cpp | 4 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk.h | 3 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_history.cpp | 2 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_messages.cpp | 2 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_pollserver.cpp | 4 |
6 files changed, 19 insertions, 7 deletions
diff --git a/protocols/VKontakte/src/main.cpp b/protocols/VKontakte/src/main.cpp index 8e2909bfa5..c304f57adb 100644 --- a/protocols/VKontakte/src/main.cpp +++ b/protocols/VKontakte/src/main.cpp @@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "version.h"
CMPlugin g_plugin;
+bool g_bMessageState;
/////////////////////////////////////////////////////////////////////////////////////////
@@ -49,8 +50,18 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOC /////////////////////////////////////////////////////////////////////////////////////////
// OnLoad - initialize the plugin instance
+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();
return 0;
}
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index 196f76f29f..582aa00481 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -701,7 +701,7 @@ void CVkProto::ContactTypingThread(void *p) Sleep(4500);
CallService(MS_PROTO_CONTACTISTYPING, hContact);
- if (!ServiceExists(MS_MESSAGESTATE_UPDATE)) {
+ if (!g_bMessageState) {
Sleep(1500);
SetSrmmReadStatus(hContact);
}
@@ -739,7 +739,7 @@ int CVkProto::OnProcessSrmmEvent(WPARAM, LPARAM lParam) if (szProto.IsEmpty() || szProto != m_szModuleName)
return 0;
- if (event->uType == MSG_WINDOW_EVT_OPENING && !ServiceExists(MS_MESSAGESTATE_UPDATE))
+ if (event->uType == MSG_WINDOW_EVT_OPENING && !g_bMessageState)
SetSrmmReadStatus(event->hContact);
if (event->uType == MSG_WINDOW_EVT_OPENING && m_vkOptions.bLoadLastMessageOnMsgWindowsOpen
diff --git a/protocols/VKontakte/src/vk.h b/protocols/VKontakte/src/vk.h index 77aed6241c..acc4ae940f 100644 --- a/protocols/VKontakte/src/vk.h +++ b/protocols/VKontakte/src/vk.h @@ -102,6 +102,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. struct CVkProto;
extern mir_cs csInstances;
+extern bool g_bMessageState;
LPCSTR findHeader(NETLIBHTTPREQUEST *hdr, LPCSTR szField);
bool wlstrstr(wchar_t *_s1, wchar_t *_s2);
@@ -112,4 +113,4 @@ HANDLE GetIconHandle(int iCommand); char* ExpUrlEncode(const char *szUrl, bool strict = false);
bool IsEmpty(LPCWSTR str);
-bool IsEmpty(LPCSTR str);
\ No newline at end of file +bool IsEmpty(LPCSTR str);
diff --git a/protocols/VKontakte/src/vk_history.cpp b/protocols/VKontakte/src/vk_history.cpp index 2b3e00952b..2de3001185 100644 --- a/protocols/VKontakte/src/vk_history.cpp +++ b/protocols/VKontakte/src/vk_history.cpp @@ -309,7 +309,7 @@ void CVkProto::OnReceiveHistoryMessages(NETLIBHTTPREQUEST *reply, AsyncHttpReque setDword(param->hContact, "lastmsgid", iLastMsgId);
- if (ServiceExists(MS_MESSAGESTATE_UPDATE)) {
+ if (g_bMessageState) {
MessageReadData data(tLastReadMessageTime, MRD_TYPE_MESSAGETIME);
CallService(MS_MESSAGESTATE_UPDATE, param->hContact, (LPARAM)&data);
}
diff --git a/protocols/VKontakte/src/vk_messages.cpp b/protocols/VKontakte/src/vk_messages.cpp index 349cd997e7..35156eedcf 100644 --- a/protocols/VKontakte/src/vk_messages.cpp +++ b/protocols/VKontakte/src/vk_messages.cpp @@ -438,7 +438,7 @@ void CVkProto::OnReceiveDlgs(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq) if (IsGroupUser(hContact))
szGroupIds.AppendFormat(szGroupIds.IsEmpty() ? "%d" : ",%d", -1 * uid);
- if (ServiceExists(MS_MESSAGESTATE_UPDATE)) {
+ if (g_bMessageState) {
time_t tLastReadMessageTime = jnDlg["date"].as_int();
bool isOut = jnDlg["out"].as_bool();
bool isRead = jnDlg["read_state"].as_bool();
diff --git a/protocols/VKontakte/src/vk_pollserver.cpp b/protocols/VKontakte/src/vk_pollserver.cpp index c023dd0825..5be1d266a8 100644 --- a/protocols/VKontakte/src/vk_pollserver.cpp +++ b/protocols/VKontakte/src/vk_pollserver.cpp @@ -101,7 +101,7 @@ void CVkProto::PollUpdates(const JSONNode &jnUpdates) if (hContact != 0 && (flags & VKFLAG_MSGUNREAD) && !IsMessageExist(msgid, vkIN)) {
setDword(hContact, "LastMsgReadTime", time(0));
- if (ServiceExists(MS_MESSAGESTATE_UPDATE)) {
+ if (g_bMessageState) {
MessageReadData data(time(0), MRD_TYPE_READTIME);
CallService(MS_MESSAGESTATE_UPDATE, hContact, (LPARAM)&data);
}
@@ -175,7 +175,7 @@ void CVkProto::PollUpdates(const JSONNode &jnUpdates) hContact = FindUser(uid);
if (hContact != 0) {
setDword(hContact, "LastMsgReadTime", time(0));
- if (ServiceExists(MS_MESSAGESTATE_UPDATE)) {
+ if (g_bMessageState) {
MessageReadData data(time(0), MRD_TYPE_READTIME);
CallService(MS_MESSAGESTATE_UPDATE, hContact, (LPARAM)&data);
}
|