From 93d2e2120e56bae6e62cf4297ea82c3dc0ab295a Mon Sep 17 00:00:00 2001 From: MikalaiR Date: Sun, 3 May 2015 14:47:25 +0000 Subject: SkypeWeb: Updating contact list & auth requests every 10 minutes. git-svn-id: http://svn.miranda-ng.org/main/trunk@13396 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/SkypeWeb/src/skype_login.cpp | 3 +++ protocols/SkypeWeb/src/skype_proto.cpp | 9 +++++++++ protocols/SkypeWeb/src/skype_proto.h | 10 ++++++++-- protocols/SkypeWeb/src/skype_utils.cpp | 28 ++++++++++++++++++++++++++++ protocols/SkypeWeb/src/stdafx.h | 2 ++ 5 files changed, 50 insertions(+), 2 deletions(-) (limited to 'protocols/SkypeWeb') diff --git a/protocols/SkypeWeb/src/skype_login.cpp b/protocols/SkypeWeb/src/skype_login.cpp index 6e00f87e7b..bcf1fd804a 100644 --- a/protocols/SkypeWeb/src/skype_login.cpp +++ b/protocols/SkypeWeb/src/skype_login.cpp @@ -112,6 +112,9 @@ void CSkypeProto::OnLoginSuccess() PushRequest(new GetProfileRequest(TokenSecret), &CSkypeProto::LoadProfile); PushRequest(new GetAvatarRequest(ptrA(getStringA("AvatarUrl"))), &CSkypeProto::OnReceiveAvatar, NULL); PushRequest(new GetContactListRequest(TokenSecret), &CSkypeProto::LoadContactList); + + if (!m_timer) + SkypeSetTimer(this); } void CSkypeProto::OnEndpointCreated(const NETLIBHTTPREQUEST *response) diff --git a/protocols/SkypeWeb/src/skype_proto.cpp b/protocols/SkypeWeb/src/skype_proto.cpp index 9c7acf6922..8cc60a5e28 100644 --- a/protocols/SkypeWeb/src/skype_proto.cpp +++ b/protocols/SkypeWeb/src/skype_proto.cpp @@ -17,6 +17,8 @@ along with this program. If not, see . #include "stdafx.h" +LIST skypeInstances(1, CSkypeProto::CompareAccounts); + CSkypeProto::CSkypeProto(const char* protoName, const TCHAR* userName) : PROTO(protoName, userName), password(NULL) { @@ -67,6 +69,8 @@ PROTO(protoName, userName), password(NULL) //sounds SkinAddNewSoundEx("skype_inc_call", "SkypeWeb", LPGEN("Incoming call sound") ); SkinAddNewSoundEx("skype_call_canceled", "SkypeWeb", LPGEN("Incoming call canceled sound") ); + + skypeInstances.insert(this); } CSkypeProto::~CSkypeProto() @@ -74,6 +78,7 @@ CSkypeProto::~CSkypeProto() delete requestQueue; Netlib_CloseHandle(m_hNetlibUser); m_hNetlibUser = NULL; + skypeInstances.remove(this); } DWORD_PTR CSkypeProto::GetCaps(int type, MCONTACT) @@ -221,6 +226,8 @@ int CSkypeProto::SetStatus(int iNewStatus) } requestQueue->Stop(); + SkypeUnsetTimer(this); + ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)m_iStatus, ID_STATUS_OFFLINE); m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE; @@ -289,6 +296,8 @@ int CSkypeProto::OnPreShutdown(WPARAM, LPARAM) CallService(MS_NETLIB_SHUTDOWN, (WPARAM)m_pollingConnection, 0); if (m_TrouterConnection) CallService(MS_NETLIB_SHUTDOWN, (WPARAM)m_TrouterConnection, 0); + if (m_timer) + SkypeUnsetTimer(this); requestQueue->Stop(); diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h index 1c68f1a1b6..9fcb5c1f21 100644 --- a/protocols/SkypeWeb/src/skype_proto.h +++ b/protocols/SkypeWeb/src/skype_proto.h @@ -81,6 +81,11 @@ public: //search void __cdecl SearchBasicThread(void* id); + //////////////////////////////////////////// + UINT_PTR m_timer; + static int CompareAccounts(const CSkypeProto *p1, const CSkypeProto *p2); + void CSkypeProto::ProcessTimer(); + private: char *password; RequestQueue *requestQueue; @@ -96,8 +101,6 @@ private: char *Server, *RegToken, *TokenSecret, *EndpointId, *SelfSkypeName; - static int CompareAccounts(const CSkypeProto *p1, const CSkypeProto *p2); - static CSkypeProto* GetContactAccount(MCONTACT hContact); int __cdecl OnAccountLoaded(WPARAM, LPARAM); @@ -296,6 +299,9 @@ private: LPCTSTR ClearText(CMString &value, const TCHAR *message); + void CALLBACK SkypeUnsetTimer(void*); + void CALLBACK SkypeSetTimer(void*); + //services INT_PTR __cdecl OnIncomingCallCLE (WPARAM wParam, LPARAM lParam); INT_PTR __cdecl OnIncomingCallPP (WPARAM wParam, LPARAM lParam); diff --git a/protocols/SkypeWeb/src/skype_utils.cpp b/protocols/SkypeWeb/src/skype_utils.cpp index 123c4945a8..81ccde08d5 100644 --- a/protocols/SkypeWeb/src/skype_utils.cpp +++ b/protocols/SkypeWeb/src/skype_utils.cpp @@ -729,4 +729,32 @@ HRESULT TestMarkupServices(BSTR bstrHtml, MarkupCallback *pCallback, BSTR &messa pHtmlDocRoot->Release(); } return hr; +} + +void CSkypeProto::ProcessTimer() +{ + if (IsOnline()) + { + PushRequest(new GetContactListRequest(TokenSecret), &CSkypeProto::LoadContactList); + } +} + +static VOID CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD) +{ + for (int i = 0; i < skypeInstances.getCount(); i++) + { + skypeInstances[i]->ProcessTimer(); + } +} + +void CSkypeProto::SkypeSetTimer(void*) +{ + CSkypeProto::m_timer = SetTimer(NULL, 0, 600000, TimerProc); +} + +void CSkypeProto::SkypeUnsetTimer(void*) +{ + if (CSkypeProto::m_timer) + KillTimer(NULL, CSkypeProto::m_timer); + CSkypeProto::m_timer = 0; } \ No newline at end of file diff --git a/protocols/SkypeWeb/src/stdafx.h b/protocols/SkypeWeb/src/stdafx.h index 63b16f163e..dd1b5411d3 100644 --- a/protocols/SkypeWeb/src/stdafx.h +++ b/protocols/SkypeWeb/src/stdafx.h @@ -62,6 +62,7 @@ struct CSkypeProto; extern HINSTANCE g_hInstance; extern char g_szMirVer[]; +extern LIST skypeInstances; #define SKYPE_ENDPOINTS_HOST "client-s.gateway.messenger.live.com" @@ -106,4 +107,5 @@ enum SKYPE_LOGIN_ERROR #define SKYPE_DB_EVENT_TYPE_ACTION 10001 #define SKYPE_DB_EVENT_TYPE_INCOMING_CALL 10002 + #endif //_COMMON_H_ \ No newline at end of file -- cgit v1.2.3