diff options
author | Sergey Bolhovskoy <elzorfox@ya.ru> | 2014-10-07 16:52:47 +0000 |
---|---|---|
committer | Sergey Bolhovskoy <elzorfox@ya.ru> | 2014-10-07 16:52:47 +0000 |
commit | 492fc206271dd44d312a80b8ef6f91a7e360ce40 (patch) | |
tree | 9761798e3a20432d5062824b87c69745fc69d1e8 /protocols | |
parent | df0f5de95815eedd34834c9b4becb66c62b63033 (diff) |
VKontakte: add read notification in *srmm status bar
git-svn-id: http://svn.miranda-ng.org/main/trunk@10727 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/VKontakte/src/misc.cpp | 38 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk.h | 8 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.cpp | 1 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.h | 8 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_thread.cpp | 18 |
5 files changed, 67 insertions, 6 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index 9d299a31cc..14b2d13a3d 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -501,4 +501,42 @@ bool tlstrstr(TCHAR* _s1, TCHAR* _s2) CharLowerBuff(s1, SIZEOF(s1));
CharLowerBuff(s2, SIZEOF(s2));
return (_tcsstr(s1, s2) != NULL);
+}
+
+void CVkProto::ContactTypingThread(void *p)
+{
+ MCONTACT hContact = (MCONTACT)p;
+ CallService(MS_PROTO_CONTACTISTYPING, hContact, 5);
+ Sleep(5500);
+ CallService(MS_PROTO_CONTACTISTYPING, hContact, 0);
+ Sleep(1500);
+ SetSrmmReadStatus(hContact);
+}
+
+int CVkProto::OnProcessSrmmEvent(WPARAM, LPARAM lParam)
+{
+ MessageWindowEventData *event = (MessageWindowEventData *)lParam; + + if (event->uType == MSG_WINDOW_EVT_OPENING) + SetSrmmReadStatus(event->hContact); +
+ return 0;
+}
+
+
+void CVkProto::SetSrmmReadStatus(MCONTACT hContact)
+{
+ time_t time = getDword(hContact, "LastMsgReadTime", 0); + if (!time) + return; + + TCHAR ttime[64]; + _tcsftime(ttime, SIZEOF(ttime), _T("%X"), localtime(&time)); + + StatusTextData st = { 0 }; + st.cbSize = sizeof(st); + st.hIcon = LoadSkinnedIcon(SKINICON_OTHER_EMPTYBLOB); + mir_sntprintf(st.tszText, SIZEOF(st.tszText), TranslateT("Message read: %s"), ttime); + CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)hContact, NULL); + CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)hContact, (LPARAM)&st);
}
\ No newline at end of file diff --git a/protocols/VKontakte/src/vk.h b/protocols/VKontakte/src/vk.h index 9477be3d1c..3e523b4400 100644 --- a/protocols/VKontakte/src/vk.h +++ b/protocols/VKontakte/src/vk.h @@ -23,6 +23,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define VKPOLL_MSG_ADDFLAGS 2
#define VKPOLL_MSG_DELFLAGS 3
#define VKPOLL_MSG_ADDED 4
+#define VKPOLL_READ_ALL_IN 6
+#define VKPOLL_READ_ALL_OUT 7
#define VKPOLL_USR_ONLINE 8
#define VKPOLL_USR_OFFLINE 9
#define VKPOLL_CHAT_CHANGED 51
@@ -55,12 +57,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define VKERR_INVALID_SERVER 118 // Invalid server
#define VKERR_INVALID_HASH 121 // Invalid hash
#define VKERR_INVALID_AUDIO 123 // Invalid audio
-#define VKERR_AUDIO_DEL_COPYRIGHT 270 // The audio file was removed by the copyright holder and cannot be reuploaded.
-#define VKERR_INVALID_FILENAME 301 // Invalid filename
-#define VKERR_INVALID_FILESIZE 302 // Invalid filesize
#define VKERR_HIMSELF_AS_FRIEND 174 // Cannot add user himself as friend
#define VKERR_YOU_ON_BLACKLIST 175 // Cannot add this user to friends as they have put you on their blacklist
#define VKERR_USER_ON_BLACKLIST 176 // Cannot add this user to friends as you put him on blacklist
+#define VKERR_AUDIO_DEL_COPYRIGHT 270 // The audio file was removed by the copyright holder and cannot be reuploaded.
+#define VKERR_INVALID_FILENAME 301 // Invalid filename
+#define VKERR_INVALID_FILESIZE 302 // Invalid filesize
#define VK_API_VER "5.25"
#define VER_API CHAR_PARAM("v", VK_API_VER)
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index dfe178f683..daa371839d 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -103,6 +103,7 @@ int CVkProto::OnModulesLoaded(WPARAM wParam, LPARAM lParam) HookProtoEvent(ME_GC_EVENT, &CVkProto::OnChatEvent);
HookProtoEvent(ME_GC_BUILDMENU, &CVkProto::OnGcMenuHook);
+ HookProtoEvent(ME_MSG_WINDOWEVENT, &CVkProto::OnProcessSrmmEvent);
InitPopups();
InitMenus();
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index b79b7d18ab..4c2256a1d8 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -245,7 +245,11 @@ struct CVkProto : public PROTO<CVkProto> void InitPopups(void);
void MsgPopup(MCONTACT hContact, const TCHAR *szMsg, const TCHAR *szTitle, bool err = false);
-
+
+ //==== Hooks ====+====================================================================
+
+ int __cdecl OnProcessSrmmEvent(WPARAM, LPARAM);
+
//==== Search ========================================================================
void __cdecl SearchBasicThread(void* id);
@@ -315,6 +319,8 @@ struct CVkProto : public PROTO<CVkProto> __forceinline void setGroup(LPCTSTR grp) { m_defaultGroup = mir_tstrdup(grp); }
void SetMirVer(MCONTACT hContact, int platform);
+ void SetSrmmReadStatus(MCONTACT hContact);
+ void __cdecl ContactTypingThread(void *p);
static UINT_PTR m_timer;
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index 08b960c271..77a7857223 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -1051,6 +1051,14 @@ void CVkProto::PollUpdates(JSONNODE *pUpdates) JSONNODE *pChild;
for (int i = 0; (pChild = json_at(pUpdates, i)) != NULL; i++) {
switch (json_as_int(json_at(pChild, 0))) {
+ case VKPOLL_MSG_DELFLAGS:
+ flags = json_as_int(json_at(pChild, 2));
+ uid = json_as_int(json_at(pChild, 3));
+ if (((hContact = FindUser(uid)) != NULL) && (flags&VKFLAG_MSGUNREAD)){
+ setDword(hContact, "LastMsgReadTime", time(NULL));
+ SetSrmmReadStatus(hContact);
+ }
+ break;
case VKPOLL_MSG_ADDED: // new message
msgid = json_as_int(json_at(pChild, 1));
@@ -1064,7 +1072,13 @@ void CVkProto::PollUpdates(JSONNODE *pUpdates) mids.AppendChar(',');
mids.AppendFormat("%d", msgid);
break;
-
+ case VKPOLL_READ_ALL_OUT:
+ uid = json_as_int(json_at(pChild, 1));
+ if ((hContact = FindUser(uid)) != NULL){
+ setDword(hContact, "LastMsgReadTime", time(NULL));
+ SetSrmmReadStatus(hContact);
+ }
+ break;
case VKPOLL_USR_ONLINE:
uid = -json_as_int(json_at(pChild, 1));
if ((hContact = FindUser(uid)) != NULL)
@@ -1082,7 +1096,7 @@ void CVkProto::PollUpdates(JSONNODE *pUpdates) case VKPOLL_USR_UTN:
uid = json_as_int(json_at(pChild, 1));
if ((hContact = FindUser(uid)) != NULL)
- CallService(MS_PROTO_CONTACTISTYPING, hContact, 5);
+ ForkThread(&CVkProto::ContactTypingThread, (void *)hContact);
break;
case VKPOLL_CHAT_CHANGED:
|