diff options
author | MikalaiR <nikolay.romanovich@narod.ru> | 2015-04-16 20:00:46 +0000 |
---|---|---|
committer | MikalaiR <nikolay.romanovich@narod.ru> | 2015-04-16 20:00:46 +0000 |
commit | b7a256059160ff803004b7eb89c71e7a59a90a5b (patch) | |
tree | 75845179d56b1ee2bf9f157fc06d5df82f0330c8 | |
parent | 874c0baa9f70bc95d33a970bf0341036c1bdc94e (diff) |
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
-rw-r--r-- | protocols/SkypeWeb/src/skype_chatrooms.cpp | 63 |
1 files changed, 31 insertions, 32 deletions
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 = <addmember><eventtime>1429186229164</eventtime><initiator>8:initiator</initiator><target>8:user</target></addmember>
- std::regex regex;
- std::smatch match;
- std::string strContent(content);
- regex = "<initiator>8:(.+?)</initiator>";
- 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 = "<target>8:(.+?)</target>";
+ 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 = "<initiator>8:(.+?)</initiator>";
- if (!std::regex_search(strContent, match, regex))
- std::string initiator = "";
- std::string initiator = match[1];
- regex = "<target>8:(.+?)</target>";
-
- if (!std::regex_search(strContent, match, regex))
- return;
- std::string target = match[1];
+ ptrA initiator, target;
+ //content = <addmember><eventtime>1429186229164</eventtime><initiator>8:initiator</initiator><target>8:user</target></addmember>
+
+ 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);
}
|