From 95d3b549cc2771af8a648bba7bb8df8db0d65607 Mon Sep 17 00:00:00 2001 From: MikalaiR Date: Mon, 20 Apr 2015 18:23:20 +0000 Subject: SkypeWeb: Changing roles support part 2. git-svn-id: http://svn.miranda-ng.org/main/trunk@12981 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/SkypeWeb/src/skype_chatrooms.cpp | 49 +++++++++++++++++++++++++----- protocols/SkypeWeb/src/skype_proto.h | 2 +- 2 files changed, 43 insertions(+), 8 deletions(-) (limited to 'protocols/SkypeWeb') diff --git a/protocols/SkypeWeb/src/skype_chatrooms.cpp b/protocols/SkypeWeb/src/skype_chatrooms.cpp index 3ff67ac97c..237954214e 100644 --- a/protocols/SkypeWeb/src/skype_chatrooms.cpp +++ b/protocols/SkypeWeb/src/skype_chatrooms.cpp @@ -308,7 +308,7 @@ void CSkypeProto::OnChatEvent(JSONNODE *node) if (xml != NULL) { HXML xmlNode = xi.getChildByPath(xml, _T("target"), 0); - xtarget = node != NULL ? mir_t2a(xi.getText(xmlNode)) : NULL; + xtarget = xmlNode != NULL ? mir_t2a(xi.getText(xmlNode)) : NULL; xi.destroyNode(xml); } @@ -328,7 +328,7 @@ void CSkypeProto::OnChatEvent(JSONNODE *node) xinitiator = node != NULL ? mir_t2a(xi.getText(xmlNode)) : NULL; xmlNode = xi.getChildByPath(xml, _T("target"), 0); - xtarget = node != NULL ? mir_t2a(xi.getText(xmlNode)) : NULL; + xtarget = xmlNode != NULL ? mir_t2a(xi.getText(xmlNode)) : NULL; xi.destroyNode(xml); } @@ -357,10 +357,10 @@ void CSkypeProto::OnChatEvent(JSONNODE *node) HXML xml = xi.parseString(ptrT(mir_a2t(content)), 0, _T("topicupdate")); if (xml != NULL) { HXML xmlNode = xi.getChildByPath(xml, _T("initiator"), 0); - xinitiator = node != NULL ? mir_t2a(xi.getText(xmlNode)) : NULL; + xinitiator = xmlNode != NULL ? mir_t2a(xi.getText(xmlNode)) : NULL; xmlNode = xi.getChildByPath(xml, _T("value"), 0); - value = node != NULL ? mir_t2a(xi.getText(xmlNode)) : NULL; + value = xmlNode != NULL ? mir_t2a(xi.getText(xmlNode)) : NULL; xi.destroyNode(xml); } @@ -371,7 +371,42 @@ void CSkypeProto::OnChatEvent(JSONNODE *node) } else if (!mir_strcmpi(messageType, "ThreadActivity/RoleUpdate")) { + //content=14295512583638:user8:user1admin + ptrA xinitiator, xId, initiator, id, xRole; + HXML xml = xi.parseString(ptrT(mir_a2t(content)), 0, _T("roleupdate")); + if (xml != NULL) { + HXML xmlNode = xi.getChildByPath(xml, _T("initiator"), 0); + xinitiator = xmlNode != NULL ? mir_t2a(xi.getText(xmlNode)) : NULL; + + xmlNode = xi.getChildByPath(xml, _T("target"), 0); + if (xmlNode != NULL) + { + HXML xmlId = xi.getChildByPath(xmlNode, _T("id"), 0); + HXML xmlRole = xi.getChildByPath(xmlNode, _T("role"), 0); + xId = xmlNode != NULL ? mir_t2a(xi.getText(xmlId)) : NULL; + xRole = xmlNode != NULL ? mir_t2a(xi.getText(xmlRole)) : NULL; + } + xi.destroyNode(xml); + + initiator = ParseUrl(xinitiator, "8:"); + id = ParseUrl(xId, "8:"); + + GCDEST gcd = { m_szModuleName, _A2T(chatname), !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)); + ptrT tszInitiator(mir_a2t(initiator)); + gce.pDest = &gcd; + gce.dwFlags = GCEF_ADDTOLOG; + gce.ptszNick = tszId; + gce.ptszUID = tszId; + gce.ptszText = tszInitiator; + gce.time = time(NULL); + gce.bIsMe = IsMe(id); + gce.ptszStatus = TranslateT("Admin"); + CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce); + } } } @@ -393,7 +428,7 @@ void CSkypeProto::OnGetChatInfo(const NETLIBHTTPREQUEST *response) ptrA username(ContactUrlToName(ptrA(mir_t2a(ptrT(json_as_string(json_get(member, "userLink"))))))); ptrT role(json_as_string(json_get(member, "role"))); if (!IsChatContact(_A2T(chatId), username)) - AddChatContact(_A2T(chatId), username, username, role); + AddChatContact(_A2T(chatId), username, username, role, true); } } @@ -440,7 +475,7 @@ char *CSkypeProto::GetChatUsers(const TCHAR *chat_id) return gci.pszUsers; } -void CSkypeProto::AddChatContact(const TCHAR *tchat_id, const char *id, const char *name, const TCHAR *role) +void CSkypeProto::AddChatContact(const TCHAR *tchat_id, const char *id, const char *name, const TCHAR *role, bool isChange) { if (IsChatContact(tchat_id, id)) return; @@ -454,7 +489,7 @@ void CSkypeProto::AddChatContact(const TCHAR *tchat_id, const char *id, const ch gce.dwFlags = GCEF_ADDTOLOG; gce.ptszNick = tnick; gce.ptszUID = tid; - gce.time = time(NULL); + gce.time = !isChange ? time(NULL): NULL; gce.bIsMe = IsMe(id); gce.ptszStatus = TranslateTS(role); diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h index 16aa9df60d..8043b87a7c 100644 --- a/protocols/SkypeWeb/src/skype_proto.h +++ b/protocols/SkypeWeb/src/skype_proto.h @@ -237,7 +237,7 @@ private: char *GetChatUsers(const TCHAR *chat_id); bool IsChatContact(const TCHAR *chat_id, const char *id); - void AddChatContact(const TCHAR *tchat_id, const char *id, const char *name, const TCHAR *role); + void AddChatContact(const TCHAR *tchat_id, const char *id, const char *name, const TCHAR *role, bool isChange = false); void RemoveChatContact(const TCHAR *tchat_id, const char *id, const char *name, bool isKick = false, const char *initiator = ""); void RenameChat(const char *chat_id, const char *name); -- cgit v1.2.3