From bc163d5a92e2e8cbed401b299a68f39b91810ffc Mon Sep 17 00:00:00 2001 From: MikalaiR Date: Thu, 16 Apr 2015 14:14:21 +0000 Subject: SkypeWeb: Chats support part 2.1. git-svn-id: http://svn.miranda-ng.org/main/trunk@12861 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/SkypeWeb/src/common.h | 1 + protocols/SkypeWeb/src/main.cpp | 3 ++ protocols/SkypeWeb/src/skype_chatrooms.cpp | 63 +++++++++++++++++++++++++----- 3 files changed, 57 insertions(+), 10 deletions(-) diff --git a/protocols/SkypeWeb/src/common.h b/protocols/SkypeWeb/src/common.h index b2f54bb177..eb3c0a2e7e 100644 --- a/protocols/SkypeWeb/src/common.h +++ b/protocols/SkypeWeb/src/common.h @@ -55,6 +55,7 @@ along with this program. If not, see . #include #include #include +#include struct CSkypeProto; diff --git a/protocols/SkypeWeb/src/main.cpp b/protocols/SkypeWeb/src/main.cpp index 3c95a3cf8f..3b21efafb8 100644 --- a/protocols/SkypeWeb/src/main.cpp +++ b/protocols/SkypeWeb/src/main.cpp @@ -18,6 +18,7 @@ along with this program. If not, see . #include "common.h" int hLangpack; +XML_API xi; TIME_API tmi = { 0 }; HINSTANCE g_hInstance; @@ -68,6 +69,8 @@ extern "C" int __declspec(dllexport) Load(void) HookEvent(ME_SYSTEM_MODULESLOADED, &CSkypeProto::OnModulesLoaded); + mir_getXI(&xi); + return 0; } diff --git a/protocols/SkypeWeb/src/skype_chatrooms.cpp b/protocols/SkypeWeb/src/skype_chatrooms.cpp index c0e8b94a03..9a0d7b9d78 100644 --- a/protocols/SkypeWeb/src/skype_chatrooms.cpp +++ b/protocols/SkypeWeb/src/skype_chatrooms.cpp @@ -167,7 +167,7 @@ void CSkypeProto::OnChatEvent(JSONNODE *node) ptrA from(mir_t2a(ptrT(json_as_string(json_get(node, "from"))))); ptrT composeTime(json_as_string(json_get(node, "composetime"))); - //time_t timestamp = IsoToUnixTime(composeTime); + time_t timestamp = IsoToUnixTime(composeTime); ptrA content(mir_t2a(ptrT(json_as_string(json_get(node, "content"))))); //int emoteOffset = json_as_int(json_get(node, "skypeemoteoffset")); @@ -187,18 +187,61 @@ void CSkypeProto::OnChatEvent(JSONNODE *node) } else if (!mir_strcmpi(messageType, "ThreadActivity/AddMember")) { - /*GCDEST gcd = { m_szModuleName, , GC_EVENT_JOIN }; - GCEVENT gce = { sizeof(GCEVENT), &gcd }; - gce.bIsMe = uid == m_myUserId; - gce.ptszUID = tszId; - gce.ptszNick = tszNick; - gce.ptszStatus = TranslateTS(sttStatuses[uid == cc->m_admin_id]); - gce.dwItemData = (INT_PTR)cu; - CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);*/ + //content = 14291862291648:initiator8:user + + std::regex regex; + std::smatch match; + std::string strContent(content); + regex = "8:(.+?)"; + if (!std::regex_search(strContent, match, regex)) + return; + std::string initiator = match[1]; + + regex = "8:(.+?)"; + + 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.ptszStatus = L"User"; + gce.dwItemData = (INT_PTR)0; + gce.dwFlags = GCEF_ADDTOLOG; + gce.time = timestamp; + gce.ptszText = ptrT(mir_a2t(initiator.c_str())); + 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)) + return; + std::string initiator = match[1]; + + regex = "8:(.+?)"; + + if (!std::regex_search(strContent, match, regex)) + return; + std::string target = match[1]; + + GCDEST gcd = { m_szModuleName, ptrT(mir_a2t(chatname)), GC_EVENT_PART }; + 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.ptszStatus = L"User"; + gce.dwItemData = (INT_PTR)0; + gce.dwFlags = GCEF_ADDTOLOG; + gce.time = timestamp; + gce.ptszText = ptrT(mir_a2t(initiator.c_str())); + CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce); } else if (!mir_strcmpi(messageType, "ThreadActivity/TopicUpdate")) { -- cgit v1.2.3