From b7a256059160ff803004b7eb89c71e7a59a90a5b Mon Sep 17 00:00:00 2001 From: MikalaiR Date: Thu, 16 Apr 2015 20:00:46 +0000 Subject: SkypeWeb: Chats support part 2.3 rewritted (not tested). git-svn-id: http://svn.miranda-ng.org/main/trunk@12874 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/SkypeWeb/src/skype_chatrooms.cpp | 63 +++++++++++++++--------------- 1 file changed, 31 insertions(+), 32 deletions(-) (limited to 'protocols') diff --git a/protocols/SkypeWeb/src/skype_chatrooms.cpp b/protocols/SkypeWeb/src/skype_chatrooms.cpp index ac262389f0..6643581f2c 100644 --- a/protocols/SkypeWeb/src/skype_chatrooms.cpp +++ b/protocols/SkypeWeb/src/skype_chatrooms.cpp @@ -206,58 +206,57 @@ void CSkypeProto::OnChatEvent(JSONNODE *node) } else if (!mir_strcmpi(messageType, "ThreadActivity/AddMember")) { + ptrA initiator, target; //content = 14291862291648:initiator8:user - std::regex regex; - std::smatch match; - std::string strContent(content); - regex = "8:(.+?)"; - if (!std::regex_search(strContent, match, regex)) - return; + HXML xml = xi.parseString(ptrT(mir_a2t(content)), 0, _T("addmember")); + if (xml != NULL) { + HXML node = xi.getChildByPath(xml, _T("initiator"), 0); + initiator = node != NULL ? mir_t2a(xi.getText(node)) : NULL; - std::string initiator = match[1]; + node = xi.getChildByPath(xml, _T("target"), 0); + target = node != NULL ? mir_t2a(xi.getText(node)) : NULL; - regex = "8:(.+?)"; + xi.destroyNode(xml); + } - if (!std::regex_search(strContent, match, regex)) - return; - std::string target = match[1]; GCDEST gcd = { m_szModuleName, ptrT(mir_a2t(chatname)), GC_EVENT_JOIN }; GCEVENT gce = { sizeof(GCEVENT), &gcd }; - gce.bIsMe = IsMe(target.c_str()); - gce.ptszUID = ptrT(mir_a2t(target.c_str())); - gce.ptszNick = ptrT(mir_a2t(target.c_str())); + gce.bIsMe = IsMe(target); + gce.ptszUID = ptrT(mir_a2t(target)); + gce.ptszNick = ptrT(mir_a2t(target)); gce.ptszStatus = TranslateT("User"); gce.time = timestamp; CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce); } else if (!mir_strcmpi(messageType, "ThreadActivity/DeleteMember")) { - std::regex regex; - std::smatch match; - std::string strContent(content); - regex = "8:(.+?)"; - if (!std::regex_search(strContent, match, regex)) - std::string initiator = ""; - std::string initiator = match[1]; - regex = "8:(.+?)"; - - if (!std::regex_search(strContent, match, regex)) - return; - std::string target = match[1]; + ptrA initiator, target; + //content = 14291862291648:initiator8:user + + HXML xml = xi.parseString(ptrT(mir_a2t(content)), 0, _T("addmember")); + if (xml != NULL) { + HXML node = xi.getChildByPath(xml, _T("initiator"), 0); + initiator = node != NULL ? mir_t2a(xi.getText(node)) : NULL; + + node = xi.getChildByPath(xml, _T("target"), 0); + target = node != NULL ? mir_t2a(xi.getText(node)) : NULL; + + xi.destroyNode(xml); + } bool isKick = false; - if (initiator == "") + if (initiator != NULL) bool isKick = true; if (isKick) { GCDEST gcd = { m_szModuleName, ptrT(mir_a2t(chatname)), GC_EVENT_KICK }; GCEVENT gce = { sizeof(GCEVENT), &gcd }; - gce.ptszUID = ptrT(mir_a2t(target.c_str())); - gce.ptszNick = ptrT(mir_a2t(target.c_str())); - gce.ptszStatus = ptrT(mir_a2t(initiator.c_str())); + gce.ptszUID = ptrT(mir_a2t(target)); + gce.ptszNick = ptrT(mir_a2t(target)); + gce.ptszStatus = ptrT(mir_a2t(initiator)); gce.time = timestamp; CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce); } @@ -265,8 +264,8 @@ void CSkypeProto::OnChatEvent(JSONNODE *node) { GCDEST gcd = { m_szModuleName, ptrT(mir_a2t(chatname)), GC_EVENT_PART }; GCEVENT gce = { sizeof(GCEVENT), &gcd }; - gce.ptszUID = ptrT(mir_a2t(target.c_str())); - gce.ptszNick = ptrT(mir_a2t(target.c_str())); + gce.ptszUID = ptrT(mir_a2t(target)); + gce.ptszNick = ptrT(mir_a2t(target)); gce.time = timestamp; CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce); } -- cgit v1.2.3