From ca553c73ad639dbcbc2b470ec3d8f3a6473b3d53 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 29 Jan 2020 21:32:51 +0300 Subject: =?UTF-8?q?fixes=20#2039=20(Jabber:=20=D1=80=D0=B5=D0=B0=D0=BB?= =?UTF-8?q?=D0=B8=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D1=8C=20=D0=BE=D0=B1=D0=BD?= =?UTF-8?q?=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20LastGetVCard=20?= =?UTF-8?q?=D0=BD=D0=B5=20=D1=82=D0=BE=D0=BB=D1=8C=D0=BA=D0=BE=20=D0=BF?= =?UTF-8?q?=D1=80=D0=B8=20=D0=B7=D0=B0=D0=BF=D1=83=D1=81=D0=BA=D0=B5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/JabberG/src/jabber_iqid.cpp | 6 ++++-- protocols/JabberG/src/jabber_proto.cpp | 1 + protocols/JabberG/src/jabber_proto.h | 28 +++++++++++++++++++++++++--- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp index c0b5f66d48..64ca5d58c1 100755 --- a/protocols/JabberG/src/jabber_iqid.cpp +++ b/protocols/JabberG/src/jabber_iqid.cpp @@ -210,9 +210,11 @@ void CJabberProto::OnLoggedIn() SendGetVcard(0); } else { - time_t lastReadVcard(getDword("LastGetVcard")); - if (time(0) - lastReadVcard > 84600) // read vcard on login once a day + time_t elapsed = time(0) - getDword("LastGetVcard"); + if (elapsed > 84600) // read vcard on login once a day SendGetVcard(0); + else + m_impl.m_heartBeat.Start(elapsed * 1000); } m_pepServices.ResetPublishAll(); diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index 03afdf9043..513a9dfd8f 100755 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -54,6 +54,7 @@ static int compareListItems(const JABBER_LIST_ITEM *p1, const JABBER_LIST_ITEM * CJabberProto::CJabberProto(const char *aProtoName, const wchar_t *aUserName) : PROTO(aProtoName, aUserName), + m_impl(*this), m_omemo(this), m_lstTransports(50, compareTransports), m_lstRoster(50, compareListItems), diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h index eab240ce21..20e6a34ee0 100755 --- a/protocols/JabberG/src/jabber_proto.h +++ b/protocols/JabberG/src/jabber_proto.h @@ -64,8 +64,30 @@ struct TFilterInfo struct CJabberProto : public PROTO, public IJabberInterface { - CJabberProto(const char*, const wchar_t*); - ~CJabberProto(); + class CJabberProtoImpl + { + friend struct CJabberProto; + CJabberProto &m_proto; + + CTimer m_heartBeat; + void OnHeartBeat(CTimer *pTimer) + { + m_proto.SendGetVcard(0); + + pTimer->Stop(); + pTimer->Start(86400 * 1000); + } + + CJabberProtoImpl(CJabberProto &pro) : + m_proto(pro), + m_heartBeat(Miranda_GetSystemWindow(), UINT_PTR(this)) + { + m_heartBeat.OnEvent = Callback(this, &CJabberProtoImpl::OnHeartBeat); + } + } m_impl; + + CJabberProto(const char *, const wchar_t *); + ~CJabberProto(); //==================================================================================== // PROTO_INTERFACE @@ -243,7 +265,7 @@ struct CJabberProto : public PROTO, public IJabberInterface CPrivacyListManager m_privacyListManager; CJabberSDManager m_SDManager; - //HWND m_hwndConsole; + // xml console CJabberDlgBase *m_pDlgConsole; HANDLE m_hThreadConsole; UINT m_dwConsoleThreadId; -- cgit v1.2.3