From a39bed945be56898d2eee18830ee3060f71b8ccd Mon Sep 17 00:00:00 2001 From: MikalaiR Date: Mon, 13 Jul 2015 14:21:03 +0000 Subject: SkypeWeb: More fixes. git-svn-id: http://svn.miranda-ng.org/main/trunk@14550 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/SkypeWeb/src/skype_accounts.cpp | 3 +++ protocols/SkypeWeb/src/skype_events.cpp | 40 +++++++++++++++++++++++++++++++ protocols/SkypeWeb/src/skype_login.cpp | 3 --- protocols/SkypeWeb/src/skype_proto.cpp | 9 ++++--- protocols/SkypeWeb/src/skype_proto.h | 2 ++ protocols/SkypeWeb/src/skype_utils.cpp | 32 +------------------------ 6 files changed, 50 insertions(+), 39 deletions(-) (limited to 'protocols/SkypeWeb/src') diff --git a/protocols/SkypeWeb/src/skype_accounts.cpp b/protocols/SkypeWeb/src/skype_accounts.cpp index afb741ac6a..c306668496 100644 --- a/protocols/SkypeWeb/src/skype_accounts.cpp +++ b/protocols/SkypeWeb/src/skype_accounts.cpp @@ -26,6 +26,7 @@ int CSkypeProto::CompareAccounts(const CSkypeProto *p1, const CSkypeProto *p2) CSkypeProto* CSkypeProto::InitAccount(const char *protoName, const wchar_t *userName) { + mir_cslock lck(accountsLock); CSkypeProto *proto = new CSkypeProto(protoName, userName); Accounts.insert(proto); return proto; @@ -33,6 +34,7 @@ CSkypeProto* CSkypeProto::InitAccount(const char *protoName, const wchar_t *user int CSkypeProto::UninitAccount(CSkypeProto *proto) { + mir_cslock lck(accountsLock); Accounts.remove(proto); delete proto; return 0; @@ -40,6 +42,7 @@ int CSkypeProto::UninitAccount(CSkypeProto *proto) CSkypeProto* CSkypeProto::GetContactAccount(MCONTACT hContact) { + mir_cslock lck(accountsLock); for (int i = 0; i < Accounts.getCount(); i++) if (mir_strcmpi(GetContactProto(hContact), Accounts[i]->m_szModuleName) == 0) return Accounts[i]; diff --git a/protocols/SkypeWeb/src/skype_events.cpp b/protocols/SkypeWeb/src/skype_events.cpp index 66402d442a..bad357df93 100644 --- a/protocols/SkypeWeb/src/skype_events.cpp +++ b/protocols/SkypeWeb/src/skype_events.cpp @@ -135,4 +135,44 @@ int CSkypeProto::ProcessSrmmEvent(WPARAM, LPARAM lParam) SetSrmmReadStatus(event->hContact); return 0; +} + +//Timers + +mir_cs timerLock; +mir_cs CSkypeProto::accountsLock; + +void CSkypeProto::ProcessTimer() +{ + if (IsOnline()) + { + PushRequest(new GetContactListRequest(m_szTokenSecret), &CSkypeProto::LoadContactList); + SendPresence(false); + if (!m_hTrouterThread) + SendRequest(new CreateTrouterRequest(), &CSkypeProto::OnCreateTrouter); + } +} + +static VOID CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD) +{ + mir_cslock lck(CSkypeProto::accountsLock); + for (int i = 0; i < Accounts.getCount(); i++) + { + Accounts[i]->ProcessTimer(); + } +} + +void CSkypeProto::SkypeSetTimer(void*) +{ + mir_cslock lck(timerLock); + if (!CSkypeProto::m_timer) + CSkypeProto::m_timer = SetTimer(NULL, 0, 600000, TimerProc); +} + +void CSkypeProto::SkypeUnsetTimer(void*) +{ + mir_cslock lck(timerLock); + 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/skype_login.cpp b/protocols/SkypeWeb/src/skype_login.cpp index dc9c678519..54879eb61a 100644 --- a/protocols/SkypeWeb/src/skype_login.cpp +++ b/protocols/SkypeWeb/src/skype_login.cpp @@ -128,9 +128,6 @@ void CSkypeProto::OnLoginSuccess() m_szServer = mir_strdup(SKYPE_ENDPOINTS_HOST); SendRequest(new CreateEndpointRequest(m_szTokenSecret, m_szServer), &CSkypeProto::OnEndpointCreated); PushRequest(new GetProfileRequest(m_szTokenSecret), &CSkypeProto::LoadProfile); - - 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 867dd99d7a..e9b6d2b816 100644 --- a/protocols/SkypeWeb/src/skype_proto.cpp +++ b/protocols/SkypeWeb/src/skype_proto.cpp @@ -59,6 +59,8 @@ PROTO(protoName, userName), password(NULL) SkinAddNewSoundEx("skype_call_canceled", "SkypeWeb", LPGEN("Incoming call canceled sound")); m_hTrouterEvent = CreateEvent(NULL, FALSE, FALSE, NULL); + + SkypeSetTimer(this); } CSkypeProto::~CSkypeProto() @@ -73,6 +75,7 @@ CSkypeProto::~CSkypeProto() Popup_UnregisterClass(m_hPopupClassCall); if (m_hPopupClassNotify) Popup_UnregisterClass(m_hPopupClassNotify); + SkypeUnsetTimer(this); } DWORD_PTR CSkypeProto::GetCaps(int type, MCONTACT) @@ -125,9 +128,7 @@ MCONTACT CSkypeProto::AddToListByEvent(int, int, MEVENT hDbEvent) char *lastName = firstName + mir_strlen(firstName) + 1; char *skypename = lastName + mir_strlen(lastName) + 1; - char *newSkypename = (dbei.flags & DBEF_UTF) ? mir_utf8decodeA(skypename) : skypename; - MCONTACT hContact = AddContact(newSkypename); - mir_free(newSkypename); + MCONTACT hContact = AddContact(skypename); return hContact; } @@ -230,8 +231,6 @@ 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; diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h index fd5bb7be75..d6b3fbc021 100644 --- a/protocols/SkypeWeb/src/skype_proto.h +++ b/protocols/SkypeWeb/src/skype_proto.h @@ -101,6 +101,7 @@ public: void ProcessTimer(); static INT_PTR EventGetIcon(WPARAM wParam, LPARAM lParam); static INT_PTR GetCallEventText(WPARAM, LPARAM lParam); + static mir_cs accountsLock; private: char *password; @@ -121,6 +122,7 @@ private: m_hPopupClassNotify; // accounts + ptrA m_szServer, m_szRegToken, m_szTokenSecret, m_szEndpointId, m_szSelfSkypeName; static CSkypeProto* GetContactAccount(MCONTACT hContact); diff --git a/protocols/SkypeWeb/src/skype_utils.cpp b/protocols/SkypeWeb/src/skype_utils.cpp index 1647d57682..ca560b5e65 100644 --- a/protocols/SkypeWeb/src/skype_utils.cpp +++ b/protocols/SkypeWeb/src/skype_utils.cpp @@ -660,40 +660,10 @@ INT_PTR CSkypeProto::ParseSkypeUriService(WPARAM, LPARAM lParam) INT_PTR CSkypeProto::GlobalParseSkypeUriService(WPARAM wParam, LPARAM lParam) { + mir_cslock lck(accountsLock); for (int i = 0; i < Accounts.getCount(); i++) if (Accounts[i]->IsOnline()) return Accounts[i]->ParseSkypeUriService(wParam, lParam); return 1; -} - -void CSkypeProto::ProcessTimer() -{ - if (IsOnline()) - { - PushRequest(new GetContactListRequest(m_szTokenSecret), &CSkypeProto::LoadContactList); - SendPresence(false); - if (!m_hTrouterThread) - SendRequest(new CreateTrouterRequest(), &CSkypeProto::OnCreateTrouter); - } -} - -static VOID CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD) -{ - for (int i = 0; i < Accounts.getCount(); i++) - { - Accounts[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 -- cgit v1.2.3