From 68a3fc7b15763f415970ec49623a449fbae41e7c Mon Sep 17 00:00:00 2001 From: MikalaiR Date: Fri, 14 Aug 2015 18:28:24 +0000 Subject: SkypeWeb: Unneeded code removed git-svn-id: http://svn.miranda-ng.org/main/trunk@14954 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/SkypeWeb/src/skype_events.cpp | 10 -- protocols/SkypeWeb/src/skype_poll_processing.cpp | 130 --------------- protocols/SkypeWeb/src/skype_polling.cpp | 200 ++++++++++++++++++----- protocols/SkypeWeb/src/skype_proto.h | 17 +- protocols/SkypeWeb/src/skype_utils.cpp | 18 -- 5 files changed, 163 insertions(+), 212 deletions(-) delete mode 100644 protocols/SkypeWeb/src/skype_poll_processing.cpp (limited to 'protocols/SkypeWeb') diff --git a/protocols/SkypeWeb/src/skype_events.cpp b/protocols/SkypeWeb/src/skype_events.cpp index 7d7d51adc1..4c160cc976 100644 --- a/protocols/SkypeWeb/src/skype_events.cpp +++ b/protocols/SkypeWeb/src/skype_events.cpp @@ -230,13 +230,3 @@ INT_PTR CSkypeProto::EventGetIcon(WPARAM wParam, LPARAM lParam) return (INT_PTR)((wParam & LR_SHARED) ? icon : CopyIcon(icon)); } -int CSkypeProto::ProcessSrmmEvent(WPARAM, LPARAM lParam) -{ - debugLogA(__FUNCTION__); - MessageWindowEventData *event = (MessageWindowEventData *)lParam; - - if (event->uType == MSG_WINDOW_EVT_OPENING) - SetSrmmReadStatus(event->hContact); - - return 0; -} diff --git a/protocols/SkypeWeb/src/skype_poll_processing.cpp b/protocols/SkypeWeb/src/skype_poll_processing.cpp deleted file mode 100644 index b005047d69..0000000000 --- a/protocols/SkypeWeb/src/skype_poll_processing.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/* -Copyright (c) 2015 Miranda NG project (http://miranda-ng.org) - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation version 2 -of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#include "stdafx.h" - -void CSkypeProto::ProcessEndpointPresenceRes(const JSONNode &node) -{ - debugLogA("CSkypeProto::ProcessEndpointPresenceRes"); - std::string selfLink = node["selfLink"].as_string(); - CMStringA skypename(UrlToSkypename(selfLink.c_str())); - - MCONTACT hContact = FindContact(skypename); - if (hContact == NULL) - return; - - const JSONNode &publicInfo = node["publicInfo"]; - const JSONNode &privateInfo = node["privateInfo"]; - CMStringA MirVer; - if (publicInfo) - { - std::string skypeNameVersion = publicInfo["skypeNameVersion"].as_string(); - std::string version = publicInfo["version"].as_string(); - std::string typ = publicInfo["typ"].as_string(); - int iTyp = atoi(typ.c_str()); - switch (iTyp) - { - case 0: - case 1: - MirVer.AppendFormat("Skype (Web) %s", ParseUrl(version.c_str(), "/")); - break; - case 10: - MirVer.AppendFormat("Skype (XBOX) %s", ParseUrl(skypeNameVersion.c_str(), "/")); - break; - case 17: - MirVer.AppendFormat("Skype (Android) %s", ParseUrl(skypeNameVersion.c_str(), "/")); - break; - case 16: - MirVer.AppendFormat("Skype (iOS) %s", ParseUrl(skypeNameVersion.c_str(), "/")); - break; - case 12: - MirVer.AppendFormat("Skype (WinRT) %s", ParseUrl(skypeNameVersion.c_str(), "/")); - break; - case 15: - MirVer.AppendFormat("Skype (WP) %s", ParseUrl(skypeNameVersion.c_str(), "/")); - break; - case 13: - MirVer.AppendFormat("Skype (OSX) %s", ParseUrl(skypeNameVersion.c_str(), "/")); - break; - case 11: - MirVer.AppendFormat("Skype (Windows) %s", ParseUrl(skypeNameVersion.c_str(), "/")); - break; - case 14: - MirVer.AppendFormat("Skype (Linux) %s", ParseUrl(skypeNameVersion.c_str(), "/")); - break; - case 125: - MirVer.AppendFormat("Miranda NG Skype %s", version.c_str()); - break; - default: - MirVer.Append("Skype (Unknown)"); - } - } - if (privateInfo != NULL) - { - std::string epname = privateInfo["epname"].as_string(); - if (!epname.empty()) - { - MirVer.AppendFormat(" [%s]", epname.c_str()); - } - } - db_set_s(hContact, m_szModuleName, "MirVer", MirVer); -} - -void CSkypeProto::ProcessUserPresenceRes(const JSONNode &node) -{ - debugLogA("CSkypeProto::ProcessUserPresenceRes"); - - std::string selfLink = node["selfLink"].as_string(); - std::string status = node["status"].as_string(); - CMStringA skypename = UrlToSkypename(selfLink.c_str()); - - if (!skypename.IsEmpty()) - { - if (IsMe(skypename)) - { - int iNewStatus = SkypeToMirandaStatus(status.c_str()); - int old_status = m_iStatus; - m_iDesiredStatus = iNewStatus; - m_iStatus = iNewStatus; - if (old_status != iNewStatus) - { - ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, iNewStatus); - } - } - else - { - MCONTACT hContact = FindContact(skypename); - if (hContact != NULL) - SetContactStatus(hContact, SkypeToMirandaStatus(status.c_str())); - } - } -} - -void CSkypeProto::ProcessNewMessageRes(const JSONNode &node) -{ - debugLogA(__FUNCTION__); - - std::string conversationLink = node["conversationLink"].as_string(); - - if (conversationLink.find("/8:") != std::string::npos) - OnPrivateMessageEvent(node); - else if (conversationLink.find("/19:") != std::string::npos) - OnChatEvent(node); -} - -void CSkypeProto::ProcessConversationUpdateRes(const JSONNode&){} -void CSkypeProto::ProcessThreadUpdateRes(const JSONNode&){} \ No newline at end of file diff --git a/protocols/SkypeWeb/src/skype_polling.cpp b/protocols/SkypeWeb/src/skype_polling.cpp index bf2fc714ff..4d9fd04318 100644 --- a/protocols/SkypeWeb/src/skype_polling.cpp +++ b/protocols/SkypeWeb/src/skype_polling.cpp @@ -17,49 +17,9 @@ along with this program. If not, see . #include "stdafx.h" -void CSkypeProto::ParsePollData(void *pData) -{ - debugLogA("CSkypeProto::ParsePollData"); - - JSONNode data = JSONNode::parse(ptrA((char*)pData)); - if (!data) return; - - const JSONNode &node = data["eventMessages"]; - if (!node) return; - - for (auto it = node.begin(); it != node.end(); ++it) - { - const JSONNode &message = *it; - const JSONNode &resType = message["resourceType"]; - const JSONNode &resource = message["resource"]; - - std::string resourceType = resType.as_string(); - if (resourceType == "NewMessage") - { - ProcessNewMessageRes(resource); - } - else if (resourceType == "UserPresence") - { - ProcessUserPresenceRes(resource); - } - else if (resourceType == "EndpointPresence") - { - ProcessEndpointPresenceRes(resource); - } - else if (resourceType == "ConversationUpdate") - { - ProcessConversationUpdateRes(resource); - } - else if (resourceType == "ThreadUpdate") - { - ProcessThreadUpdateRes(resource); - } - } -} - void CSkypeProto::PollingThread(void*) { - debugLogA(__FUNCTION__": entering"); + debugLogA(__FUNCTION__ ": entering"); int errors = 0; isTerminated = false; @@ -110,10 +70,162 @@ void CSkypeProto::PollingThread(void*) if (!isTerminated) { - debugLogA(__FUNCTION__": unexpected termination; switching protocol to offline"); + debugLogA(__FUNCTION__ ": unexpected termination; switching protocol to offline"); SetStatus(ID_STATUS_OFFLINE); } m_hPollingThread = NULL; m_pollingConnection = NULL; - debugLogA(__FUNCTION__": leaving"); -} \ No newline at end of file + debugLogA(__FUNCTION__ ": leaving"); +} + +void CSkypeProto::ParsePollData(void *pData) +{ + debugLogA(__FUNCTION__); + + JSONNode data = JSONNode::parse(ptrA((char*)pData)); + if (!data) return; + + const JSONNode &node = data["eventMessages"]; + if (!node) return; + + for (auto it = node.begin(); it != node.end(); ++it) + { + const JSONNode &message = *it; + const JSONNode &resType = message["resourceType"]; + const JSONNode &resource = message["resource"]; + + std::string resourceType = resType.as_string(); + if (resourceType == "NewMessage") + { + ProcessNewMessage(resource); + } + else if (resourceType == "UserPresence") + { + ProcessUserPresence(resource); + } + else if (resourceType == "EndpointPresence") + { + ProcessEndpointPresence(resource); + } + else if (resourceType == "ConversationUpdate") + { + ProcessConversationUpdate(resource); + } + else if (resourceType == "ThreadUpdate") + { + ProcessThreadUpdate(resource); + } + } +} + +void CSkypeProto::ProcessEndpointPresence(const JSONNode &node) +{ + debugLogA("CSkypeProto::ProcessEndpointPresenceRes"); + std::string selfLink = node["selfLink"].as_string(); + CMStringA skypename(UrlToSkypename(selfLink.c_str())); + + MCONTACT hContact = FindContact(skypename); + if (hContact == NULL) + return; + + const JSONNode &publicInfo = node["publicInfo"]; + const JSONNode &privateInfo = node["privateInfo"]; + CMStringA MirVer; + if (publicInfo) + { + std::string skypeNameVersion = publicInfo["skypeNameVersion"].as_string(); + std::string version = publicInfo["version"].as_string(); + std::string typ = publicInfo["typ"].as_string(); + int iTyp = atoi(typ.c_str()); + switch (iTyp) + { + case 0: + case 1: + MirVer.AppendFormat("Skype (Web) %s", ParseUrl(version.c_str(), "/")); + break; + case 10: + MirVer.AppendFormat("Skype (XBOX) %s", ParseUrl(skypeNameVersion.c_str(), "/")); + break; + case 17: + MirVer.AppendFormat("Skype (Android) %s", ParseUrl(skypeNameVersion.c_str(), "/")); + break; + case 16: + MirVer.AppendFormat("Skype (iOS) %s", ParseUrl(skypeNameVersion.c_str(), "/")); + break; + case 12: + MirVer.AppendFormat("Skype (WinRT) %s", ParseUrl(skypeNameVersion.c_str(), "/")); + break; + case 15: + MirVer.AppendFormat("Skype (WP) %s", ParseUrl(skypeNameVersion.c_str(), "/")); + break; + case 13: + MirVer.AppendFormat("Skype (OSX) %s", ParseUrl(skypeNameVersion.c_str(), "/")); + break; + case 11: + MirVer.AppendFormat("Skype (Windows) %s", ParseUrl(skypeNameVersion.c_str(), "/")); + break; + case 14: + MirVer.AppendFormat("Skype (Linux) %s", ParseUrl(skypeNameVersion.c_str(), "/")); + break; + case 125: + MirVer.AppendFormat("Miranda NG Skype %s", version.c_str()); + break; + default: + MirVer.Append("Skype (Unknown)"); + } + } + if (privateInfo != NULL) + { + std::string epname = privateInfo["epname"].as_string(); + if (!epname.empty()) + { + MirVer.AppendFormat(" [%s]", epname.c_str()); + } + } + db_set_s(hContact, m_szModuleName, "MirVer", MirVer); +} + +void CSkypeProto::ProcessUserPresence(const JSONNode &node) +{ + debugLogA("CSkypeProto::ProcessUserPresenceRes"); + + std::string selfLink = node["selfLink"].as_string(); + std::string status = node["status"].as_string(); + CMStringA skypename = UrlToSkypename(selfLink.c_str()); + + if (!skypename.IsEmpty()) + { + if (IsMe(skypename)) + { + int iNewStatus = SkypeToMirandaStatus(status.c_str()); + int old_status = m_iStatus; + m_iDesiredStatus = iNewStatus; + m_iStatus = iNewStatus; + if (old_status != iNewStatus) + { + ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, iNewStatus); + } + } + else + { + MCONTACT hContact = FindContact(skypename); + if (hContact != NULL) + SetContactStatus(hContact, SkypeToMirandaStatus(status.c_str())); + } + } +} + +void CSkypeProto::ProcessNewMessage(const JSONNode &node) +{ + debugLogA(__FUNCTION__); + + std::string conversationLink = node["conversationLink"].as_string(); + + if (conversationLink.find("/8:") != std::string::npos) + OnPrivateMessageEvent(node); + else if (conversationLink.find("/19:") != std::string::npos) + OnChatEvent(node); +} + +void CSkypeProto::ProcessConversationUpdate(const JSONNode&){} +void CSkypeProto::ProcessThreadUpdate(const JSONNode&){} \ No newline at end of file diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h index dba8fd238e..66be5509b1 100644 --- a/protocols/SkypeWeb/src/skype_proto.h +++ b/protocols/SkypeWeb/src/skype_proto.h @@ -292,13 +292,13 @@ private: void SetChatStatus(MCONTACT hContact, int iStatus); //polling - void __cdecl PollingThread(void*); - void __cdecl ParsePollData(void *pData); - void ProcessEndpointPresenceRes(const JSONNode &node); - void ProcessUserPresenceRes(const JSONNode &node); - void ProcessNewMessageRes(const JSONNode &node); - void ProcessConversationUpdateRes(const JSONNode &node); - void ProcessThreadUpdateRes(const JSONNode &node); + void __cdecl PollingThread (void*); + void __cdecl ParsePollData (void *pData); + void ProcessEndpointPresence (const JSONNode &node); + void ProcessUserPresence (const JSONNode &node); + void ProcessNewMessage (const JSONNode &node); + void ProcessConversationUpdate (const JSONNode &node); + void ProcessThreadUpdate (const JSONNode &node); // utils static void FreeCharList(const LIST &lst); @@ -327,8 +327,6 @@ private: static CMStringA ParseUrl(const char *url, const char *token); - void SetSrmmReadStatus(MCONTACT hContact); - static CMStringA UrlToSkypename(const char *url); static CMStringA GetServerFromUrl(const char *url); @@ -345,7 +343,6 @@ private: void CloseDialogs(); //events void InitDBEvents(); - int __cdecl ProcessSrmmEvent(WPARAM, LPARAM); //services INT_PTR __cdecl OnIncomingCallCLE(WPARAM wParam, LPARAM lParam); diff --git a/protocols/SkypeWeb/src/skype_utils.cpp b/protocols/SkypeWeb/src/skype_utils.cpp index bfdaf2ab56..72e912cd61 100644 --- a/protocols/SkypeWeb/src/skype_utils.cpp +++ b/protocols/SkypeWeb/src/skype_utils.cpp @@ -25,24 +25,6 @@ void CSkypeProto::FreeCharList(const LIST &lst) mir_free(lst[i]); } -void CSkypeProto::SetSrmmReadStatus(MCONTACT hContact) -{ - time_t time = getDword(hContact, "LastMsgReadTime", 0); - if (!time) - return; - - TCHAR ttime[64]; - _locale_t locale = _create_locale(LC_ALL, ""); - _tcsftime_l(ttime, _countof(ttime), _T("%X - %x"), localtime(&time), locale); - _free_locale(locale); - - StatusTextData st = { 0 }; - st.cbSize = sizeof(st); - st.hIcon = Skin_LoadIcon(SKINICON_OTHER_HISTORY); - mir_sntprintf(st.tszText, _countof(st.tszText), TranslateT("Message read: %s"), ttime); - CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)hContact, (LPARAM)&st); -} - time_t CSkypeProto::IsoToUnixTime(const char *stamp) { char date[9]; -- cgit v1.2.3