summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2015-04-16 14:14:21 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2015-04-16 14:14:21 +0000
commitbc163d5a92e2e8cbed401b299a68f39b91810ffc (patch)
treea9b16bde9987e50b8d6562dca678d0ada8eff48f
parent8bd2456f654ef5eea44fcf4ad6ce5f7107f7d829 (diff)
SkypeWeb: Chats support part 2.1.
git-svn-id: http://svn.miranda-ng.org/main/trunk@12861 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--protocols/SkypeWeb/src/common.h1
-rw-r--r--protocols/SkypeWeb/src/main.cpp3
-rw-r--r--protocols/SkypeWeb/src/skype_chatrooms.cpp63
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 <http://www.gnu.org/licenses/>.
#include <m_version.h>
#include <m_gui.h>
#include <m_imgsrvc.h>
+#include <m_xml.h>
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 <http://www.gnu.org/licenses/>.
#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 = <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;
+ std::string initiator = match[1];
+
+ regex = "<target>8:(.+?)</target>";
+
+ 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 = "<initiator>8:(.+?)</initiator>";
+ if (!std::regex_search(strContent, match, regex))
+ return;
+ std::string initiator = match[1];
+
+ regex = "<target>8:(.+?)</target>";
+
+ 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"))
{