From cd45782fb74301b3806afa796bb6a6ac104817dd Mon Sep 17 00:00:00 2001 From: MikalaiR Date: Fri, 31 Jul 2015 10:42:27 +0000 Subject: SkypeWeb: small fixes git-svn-id: http://svn.miranda-ng.org/main/trunk@14764 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/SkypeWeb/src/skype_chatrooms.cpp | 51 ++++++++++++++---------------- protocols/SkypeWeb/src/skype_db.h | 21 ++++++++++++ protocols/SkypeWeb/src/skype_network.cpp | 17 ++++++++++ protocols/SkypeWeb/src/skype_timers.cpp | 17 ++++++++++ protocols/SkypeWeb/src/skype_trouter.h | 17 ++++++++++ protocols/SkypeWeb/src/version.h | 2 +- 6 files changed, 97 insertions(+), 28 deletions(-) (limited to 'protocols') diff --git a/protocols/SkypeWeb/src/skype_chatrooms.cpp b/protocols/SkypeWeb/src/skype_chatrooms.cpp index 7317a38cac..522e844232 100644 --- a/protocols/SkypeWeb/src/skype_chatrooms.cpp +++ b/protocols/SkypeWeb/src/skype_chatrooms.cpp @@ -272,35 +272,32 @@ INT_PTR CSkypeProto::OnLeaveChatRoom(WPARAM hContact, LPARAM) void CSkypeProto::OnChatEvent(const JSONNode &node) { - //std::string clientMsgId = node["clientmessageid"].as_string(); - //std::string skypeEditedId = node["skypeeditedid"].as_string(); + //CMStringA szMessageId = node["clientmessageid"] ? node["clientmessageid"].as_string().c_str() : node["skypeeditedid"].as_string().c_str(); + CMStringA szConversationName(UrlToSkypename(node["conversationLink"].as_string().c_str())); + CMStringA szFromSkypename(UrlToSkypename(node["from"].as_string().c_str())); - std::string fromLink = node["from"].as_string(); - CMStringA from(UrlToSkypename(fromLink.c_str())); + CMString szTopic(node["threadtopic"].as_mstring()); time_t timestamp = IsoToUnixTime(node["composetime"].as_string().c_str()); - std::string content = node["content"].as_string(); - int emoteOffset = node["skypeemoteoffset"].as_int(); + std::string strContent = node["content"].as_string(); + int nEmoteOffset = node["skypeemoteoffset"].as_int(); - std::string conversationLink = node["conversationLink"].as_string(); - CMStringA chatname(UrlToSkypename(conversationLink.c_str())); - - CMString topic(node["threadtopic"].as_mstring()); - if (FindChatRoom(chatname) == NULL) - SendRequest(new GetChatInfoRequest(m_szRegToken, chatname, m_szServer), &CSkypeProto::OnGetChatInfo, topic.Detach()); + + if (FindChatRoom(szConversationName) == NULL) + SendRequest(new GetChatInfoRequest(m_szRegToken, szConversationName, m_szServer), &CSkypeProto::OnGetChatInfo, szTopic.Detach()); std::string messageType = node["messagetype"].as_string(); - if (!mir_strcmpi(messageType.c_str(), "Text") || !mir_strcmpi(messageType.c_str(), "RichText")) + if (messageType == "Text" || messageType == "RichText") { - AddMessageToChat(_A2T(chatname), _A2T(from), content.c_str(), emoteOffset != NULL, emoteOffset, timestamp); + AddMessageToChat(_A2T(szConversationName), _A2T(szFromSkypename), strContent.c_str(), nEmoteOffset != NULL, nEmoteOffset, timestamp); } - else if (!mir_strcmpi(messageType.c_str(), "ThreadActivity/AddMember")) + else if (messageType == "ThreadActivity/AddMember") { ptrA xinitiator, xtarget, initiator; //content = 14291862291648:initiator8:user - HXML xml = xmlParseString(ptrT(mir_a2t(content.c_str())), 0, _T("addmember")); + HXML xml = xmlParseString(ptrT(mir_utf8decodeT(strContent.c_str())), 0, _T("addmember")); if (xml == NULL) return; @@ -313,16 +310,16 @@ void CSkypeProto::OnChatEvent(const JSONNode &node) xtarget = mir_t2a(xmlGetText(xmlNode)); CMStringA target = ParseUrl(xtarget, "8:"); - AddChatContact(_A2T(chatname), target, target, L"User"); + AddChatContact(_A2T(szConversationName), target, target, L"User"); } xmlDestroyNode(xml); } - else if (!mir_strcmpi(messageType.c_str(), "ThreadActivity/DeleteMember")) + else if (messageType == "ThreadActivity/DeleteMember") { ptrA xinitiator, xtarget; //content = 14291862291648:initiator8:user - HXML xml = xmlParseString(ptrT(mir_a2t(content.c_str())), 0, _T("deletemember")); + HXML xml = xmlParseString(ptrT(mir_utf8decodeT(strContent.c_str())), 0, _T("deletemember")); if (xml != NULL) { HXML xmlNode = xmlGetChildByPath(xml, _T("initiator"), 0); xinitiator = node != NULL ? mir_t2a(xmlGetText(xmlNode)) : NULL; @@ -337,14 +334,14 @@ void CSkypeProto::OnChatEvent(const JSONNode &node) CMStringA target = ParseUrl(xtarget, "8:"); CMStringA initiator = ParseUrl(xinitiator, "8:"); - RemoveChatContact(_A2T(chatname), target, target, true, initiator); + RemoveChatContact(_A2T(szConversationName), target, target, true, initiator); } - else if (!mir_strcmpi(messageType.c_str(), "ThreadActivity/TopicUpdate")) + else if (messageType.c_str() == "ThreadActivity/TopicUpdate") { //content=14295327021308:usertest topic ptrA xinitiator, value; - HXML xml = xmlParseString(ptrT(mir_a2t(content.c_str())), 0, _T("topicupdate")); + HXML xml = xmlParseString(ptrT(mir_utf8decodeT(strContent.c_str())), 0, _T("topicupdate")); if (xml != NULL) { HXML xmlNode = xmlGetChildByPath(xml, _T("initiator"), 0); xinitiator = xmlNode != NULL ? mir_t2a(xmlGetText(xmlNode)) : NULL; @@ -356,14 +353,14 @@ void CSkypeProto::OnChatEvent(const JSONNode &node) } CMStringA initiator = ParseUrl(xinitiator, "8:"); - RenameChat(chatname, value); - ChangeChatTopic(chatname, value, initiator); + RenameChat(szConversationName, value); + ChangeChatTopic(szConversationName, value, initiator); } - else if (!mir_strcmpi(messageType.c_str(), "ThreadActivity/RoleUpdate")) + else if (messageType == "ThreadActivity/RoleUpdate") { //content=14295512583638:user8:user1admin ptrA xinitiator, xId, xRole; - HXML xml = xmlParseString(ptrT(mir_a2t(content.c_str())), 0, _T("roleupdate")); + HXML xml = xmlParseString(ptrT(mir_utf8decodeT(strContent.c_str())), 0, _T("roleupdate")); if (xml != NULL) { HXML xmlNode = xmlGetChildByPath(xml, _T("initiator"), 0); xinitiator = xmlNode != NULL ? mir_t2a(xmlGetText(xmlNode)) : NULL; @@ -381,7 +378,7 @@ void CSkypeProto::OnChatEvent(const JSONNode &node) CMStringA initiator = ParseUrl(xinitiator, "8:"); CMStringA id = ParseUrl(xId, "8:"); - GCDEST gcd = { m_szModuleName, _A2T(chatname), !mir_strcmpi(xRole, "Admin") ? GC_EVENT_ADDSTATUS : GC_EVENT_REMOVESTATUS }; + GCDEST gcd = { m_szModuleName, _A2T(szConversationName), !mir_strcmpi(xRole, "Admin") ? GC_EVENT_ADDSTATUS : GC_EVENT_REMOVESTATUS }; GCEVENT gce = { sizeof(gce), &gcd }; ptrT tszId(mir_a2t(id)); ptrT tszRole(mir_a2t(xRole)); diff --git a/protocols/SkypeWeb/src/skype_db.h b/protocols/SkypeWeb/src/skype_db.h index 089dde16b9..48a8a86185 100644 --- a/protocols/SkypeWeb/src/skype_db.h +++ b/protocols/SkypeWeb/src/skype_db.h @@ -1,3 +1,22 @@ +/* +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 . +*/ + +#ifndef _SKYPE_DB_H_ +#define _SKYPE_DB_H_ enum SKYPE_DB_EVENT_TYPE { @@ -13,3 +32,5 @@ enum SKYPE_DB_EVENT_TYPE #define SKYPE_SETTINGS_ID "Skypename" #define SKYPE_SETTINGS_PASSWORD "Password" #define SKYPE_SETTINGS_GROUP "DefaultGroup" + +#endif //_SKYPE_DB_H_ \ No newline at end of file diff --git a/protocols/SkypeWeb/src/skype_network.cpp b/protocols/SkypeWeb/src/skype_network.cpp index f6f94b91e1..75fa95adfe 100644 --- a/protocols/SkypeWeb/src/skype_network.cpp +++ b/protocols/SkypeWeb/src/skype_network.cpp @@ -1,3 +1,20 @@ +/* +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::InitNetwork() diff --git a/protocols/SkypeWeb/src/skype_timers.cpp b/protocols/SkypeWeb/src/skype_timers.cpp index ddc72aaa1b..cd25a8165e 100644 --- a/protocols/SkypeWeb/src/skype_timers.cpp +++ b/protocols/SkypeWeb/src/skype_timers.cpp @@ -1,3 +1,20 @@ +/* +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" mir_cs CSkypeProto::timerLock; diff --git a/protocols/SkypeWeb/src/skype_trouter.h b/protocols/SkypeWeb/src/skype_trouter.h index fc1becacd5..8be933e445 100644 --- a/protocols/SkypeWeb/src/skype_trouter.h +++ b/protocols/SkypeWeb/src/skype_trouter.h @@ -1,3 +1,20 @@ +/* +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 . +*/ + #ifndef _SKYPE_TROUTER_H_ #define _SKYPE_TROUTER_H_ diff --git a/protocols/SkypeWeb/src/version.h b/protocols/SkypeWeb/src/version.h index 97ac5d4775..b79da3e3b2 100644 --- a/protocols/SkypeWeb/src/version.h +++ b/protocols/SkypeWeb/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 12 #define __RELEASE_NUM 2 -#define __BUILD_NUM 1 +#define __BUILD_NUM 2 #include -- cgit v1.2.3