summaryrefslogtreecommitdiff
path: root/protocols/VKontakte
diff options
context:
space:
mode:
authorSergey Bolhovskoy <elzorfox@ya.ru>2015-11-13 13:03:43 +0000
committerSergey Bolhovskoy <elzorfox@ya.ru>2015-11-13 13:03:43 +0000
commit7b5190da46bf7ed59c78cc1d521a32cf82db870e (patch)
tree48a1a78973dbaf7f5c48401f7cef1c21d594cc4f /protocols/VKontakte
parent9bf748443d5162fd07e1a8d3baa4e0f285539d5d (diff)
VKontakte:
return back sleep interval for ContactTypingThread change processing for muc typing notification git-svn-id: http://svn.miranda-ng.org/main/trunk@15717 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte')
-rw-r--r--protocols/VKontakte/src/misc.cpp2
-rw-r--r--protocols/VKontakte/src/vk_chats.cpp78
-rw-r--r--protocols/VKontakte/src/vk_proto.cpp3
-rw-r--r--protocols/VKontakte/src/vk_proto.h7
4 files changed, 76 insertions, 14 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp
index d136b0b828..c02477735e 100644
--- a/protocols/VKontakte/src/misc.cpp
+++ b/protocols/VKontakte/src/misc.cpp
@@ -631,7 +631,7 @@ void CVkProto::ContactTypingThread(void *p)
debugLogA("CVkProto::ContactTypingThread");
MCONTACT hContact = (UINT_PTR)p;
CallService(MS_PROTO_CONTACTISTYPING, hContact, 5);
- Sleep(9500);
+ Sleep(4500);
CallService(MS_PROTO_CONTACTISTYPING, hContact);
if (!ServiceExists(MS_MESSAGESTATE_UPDATE)) {
diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp
index 866a9778ab..5a5e396721 100644
--- a/protocols/VKontakte/src/vk_chats.cpp
+++ b/protocols/VKontakte/src/vk_chats.cpp
@@ -432,6 +432,7 @@ void CVkProto::AppendChatMessage(CVkChatInfo *cc, int uid, int msgTime, LPCTSTR
gce.ptszNick = cu->m_tszNick ? mir_tstrdup(cu->m_tszNick) : mir_tstrdup(hContact ? ptrT(db_get_tsa(hContact, m_szModuleName, "Nick")) : TranslateT("Unknown"));
gce.ptszText = IsEmpty((TCHAR *)ptszBody) ? mir_tstrdup(_T("...")) : mir_tstrdup(ptszBody);
CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
+ StopChatContactTyping(cc->m_chatid, uid);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -877,6 +878,8 @@ int CVkProto::OnGcMenuHook(WPARAM, LPARAM lParam)
return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
void CVkProto::ChatContactTypingThread(void * p)
{
CVKChatContactTypingParam *param = (CVKChatContactTypingParam *)p;
@@ -886,27 +889,80 @@ void CVkProto::ChatContactTypingThread(void * p)
int iChatId = param->m_ChatId;
int iUserId = param->m_UserId;
- delete param;
+ debugLogA("CVkProto::ChatContactTypingThread %d %d", iChatId, iUserId);
MCONTACT hChatContact = FindChat(iChatId);
- if (hChatContact && getBool(hChatContact, "off"))
+ if (hChatContact && getBool(hChatContact, "off")) {
+ delete param;
return;
-
+ }
CVkChatInfo *cc = (CVkChatInfo*)m_chats.find((CVkChatInfo*)&iChatId);
- if (cc == NULL)
+ if (cc == NULL) {
+ delete param;
return;
-
+ }
CVkChatUser* cu = cc->GetUserById(iUserId);
- if (cu == NULL)
+ if (cu == NULL) {
+ delete param;
return;
+ }
- StatusTextData st = { 0 };
- st.cbSize = sizeof(st);
- mir_sntprintf(st.tszText, TranslateT("%s is typing a message..."), cu->m_tszNick);
+ {
+ mir_cslock lck(m_csChatTyping);
+ CVKChatContactTypingParam *cp = (CVKChatContactTypingParam *)m_ChatsTyping.find((CVKChatContactTypingParam *)&iChatId);
+ if (cp != NULL)
+ m_ChatsTyping.remove(cp);
+ m_ChatsTyping.insert(param);
+
+ StatusTextData st = { 0 };
+ st.cbSize = sizeof(st);
+ mir_sntprintf(st.tszText, TranslateT("%s is typing a message..."), cu->m_tszNick);
- CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)hChatContact, (LPARAM)&st);
+ CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)hChatContact, (LPARAM)&st);
+ }
+
Sleep(9500);
- CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)hChatContact);
+ StopChatContactTyping(iChatId, iUserId);
+}
+
+
+void CVkProto::StopChatContactTyping(int iChatId, int iUserId)
+{
+ debugLogA("CVkProto::StopChatContactTyping %d %d", iChatId, iUserId);
+ MCONTACT hChatContact = FindChat(iChatId);
+ if (hChatContact && getBool(hChatContact, "off"))
+ return;
+
+ CVkChatInfo *cc = (CVkChatInfo*)m_chats.find((CVkChatInfo*)&iChatId);
+ if (cc == NULL)
+ return;
+
+ CVkChatUser* cu = cc->GetUserById(iUserId);
+ if (cu == NULL)
+ return;
+
+ mir_cslock lck(m_csChatTyping);
+ CVKChatContactTypingParam *cp = (CVKChatContactTypingParam *)m_ChatsTyping.find((CVKChatContactTypingParam *)&iChatId);
+
+ if (cp != NULL && cp->m_UserId == iUserId) {
+ m_ChatsTyping.remove(cp);
+
+ StatusTextData st = { 0 };
+ st.cbSize = sizeof(st);
+ mir_sntprintf(st.tszText, _T(" "));
+
+ // CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)hChatContact, NULL) clears statusbar very slowly.
+ // (1-10 sec(!!!) for me on tabSRMM O_o)
+ // So I call MS_MSG_SETSTATUSTEXT with st.tszText = " " for cleaning of "... is typing a message..." string.
+ // It works instantly!
+
+ CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)hChatContact, (LPARAM)&st);
+
+ // After that I call standard cleaning procedure:
+
+ CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)hChatContact);
+
+ }
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp
index bac95a1898..0a2a31729c 100644
--- a/protocols/VKontakte/src/vk_proto.cpp
+++ b/protocols/VKontakte/src/vk_proto.cpp
@@ -40,7 +40,8 @@ CVkProto::CVkProto(const char *szModuleName, const TCHAR *ptszUserName) :
m_incIds(3, PtrKeySortT),
m_cookies(5),
m_msgId(1),
- m_chats(1, NumericKeySortT)
+ m_chats(1, NumericKeySortT),
+ m_ChatsTyping (1, NumericKeySortT)
{
InitQueue();
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h
index 70c5643093..757c1eb779 100644
--- a/protocols/VKontakte/src/vk_proto.h
+++ b/protocols/VKontakte/src/vk_proto.h
@@ -200,7 +200,6 @@ struct CVkProto : public PROTO<CVkProto>
void SetMirVer(MCONTACT hContact, int platform);
void __cdecl ContactTypingThread(void *p);
- void __cdecl ChatContactTypingThread(void *p);
void SetSrmmReadStatus(MCONTACT hContact);
void MarkDialogAsRead(MCONTACT hContact);
@@ -449,6 +448,12 @@ private:
static INT_PTR CALLBACK OptionsViewProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
OBJLIST<CVkChatInfo> m_chats;
+
+ OBJLIST<CVKChatContactTypingParam> m_ChatsTyping;
+ mir_cs m_csChatTyping;
+ void __cdecl ChatContactTypingThread(void *p);
+ void StopChatContactTyping(int iChatId, int iUserId);
+
CVkChatInfo* AppendChat(int id, const JSONNode &jnNode);
void SetChatTitle(CVkChatInfo *cc, LPCTSTR tszTopic);
void AppendChatMessage(int id, const JSONNode &jnMsg, const JSONNode &jnFUsers, bool bIsHistory);