From 01decc6f90584cea4020275f24b00ecbd861a0e0 Mon Sep 17 00:00:00 2001 From: MikalaiR Date: Sun, 26 Apr 2015 16:55:06 +0000 Subject: SkypeWeb: Filetransfers in history. Chats work without AutoSynchronization. git-svn-id: http://svn.miranda-ng.org/main/trunk@13171 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/SkypeWeb/src/skype_history_sync.cpp | 32 ++++++-- protocols/SkypeWeb/src/skype_login.cpp | 5 +- protocols/SkypeWeb/src/skype_messages.cpp | 106 +++++++++++++++----------- 3 files changed, 92 insertions(+), 51 deletions(-) (limited to 'protocols/SkypeWeb/src') diff --git a/protocols/SkypeWeb/src/skype_history_sync.cpp b/protocols/SkypeWeb/src/skype_history_sync.cpp index 1e4f4641fb..f4dfda202b 100644 --- a/protocols/SkypeWeb/src/skype_history_sync.cpp +++ b/protocols/SkypeWeb/src/skype_history_sync.cpp @@ -53,6 +53,7 @@ void CSkypeProto::OnGetServerHistory(const NETLIBHTTPREQUEST *response) time_t timestamp = IsoToUnixTime(composeTime); ptrA skypename(ContactUrlToName(from)); bool isEdited = (json_get(message, "skypeeditedid") != NULL); + MCONTACT hContact = FindContact(ptrA(ContactUrlToName(conversationLink))); if (conversationLink != NULL && strstr(conversationLink, "/8:")) { if (!mir_strcmpi(messageType, "Text") || !mir_strcmpi(messageType, "RichText")) @@ -63,8 +64,6 @@ void CSkypeProto::OnGetServerHistory(const NETLIBHTTPREQUEST *response) if (isMe) flags |= DBEF_SENT; - MCONTACT hContact = FindContact(ptrA(ContactUrlToName(conversationLink))); - ptrA message(RemoveHtml(content)); MEVENT dbevent = GetMessageFromDb(hContact, skypeEditedId); @@ -101,8 +100,6 @@ void CSkypeProto::OnGetServerHistory(const NETLIBHTTPREQUEST *response) //Echo / Sound Test Service6 //content=user name - MCONTACT hContact = FindContact(ptrA(ContactUrlToName(conversationLink))); - ptrA name; int iType = 3, iDuration = 0; ptrA skypename(ContactUrlToName(from)); bool isMe = IsMe(skypename); @@ -146,6 +143,30 @@ void CSkypeProto::OnGetServerHistory(const NETLIBHTTPREQUEST *response) } AddMessageToDb(hContact, timestamp, flags, clientMsgId, text.GetBuffer()); } + else if (!mir_strcmpi(messageType, "RichText/Files")) + { + //content=run.bat + HXML xml = xi.parseString(ptrT(mir_a2t(content)), 0, _T("files")); + if (xml != NULL) + { + for (int i=0; i < xi.getChildCount(xml); i++) + { + int fileSize; CMStringA msg = ""; + HXML xmlNode = xi.getNthChild(xml, L"file", i); + if (xmlNode == NULL) + break; + fileSize = atoi(_T2A(xi.getAttrValue(xmlNode, L"size"))); + ptrA fileName(mir_t2a(xi.getText(xmlNode))); + if (fileName == NULL || fileSize == NULL) + continue; + + msg.Empty(); + msg.AppendFormat("%s:\n\t%s: %s\n\t%s: %d %s", Translate("File transfer"), Translate("File name"), fileName, Translate("Size"), fileSize , Translate("bytes")); + AddMessageToDb(hContact, timestamp, DBEF_UTF | DBEF_READ, clientMsgId, msg.GetBuffer()); + + } + } + } } else if (conversationLink != NULL && strstr(conversationLink, "/19:")) { @@ -199,13 +220,14 @@ void CSkypeProto::OnSyncHistory(const NETLIBHTTPREQUEST *response) char *skypeEditedId = mir_t2a(json_as_string(json_get(lastMessage, "skypeeditedid"))); bool isEdited = (skypeEditedId != NULL); char *conversationLink = mir_t2a(json_as_string(json_get(lastMessage, "conversationLink"))); - time_t composeTime(IsoToUnixTime(ptrT(json_as_string(json_get(lastMessage, "conversationLink"))))); + time_t composeTime(IsoToUnixTime(ptrT(json_as_string(json_get(lastMessage, "composetime"))))); ptrA skypename; TCHAR *topic; if (conversationLink != NULL && strstr(conversationLink, "/8:")) { + if (!getByte("AutoSync", 1)) continue; skypename = ContactUrlToName(conversationLink); } else if (conversationLink != NULL && strstr(conversationLink, "/19:")) diff --git a/protocols/SkypeWeb/src/skype_login.cpp b/protocols/SkypeWeb/src/skype_login.cpp index c93c850d76..4c91ce49e2 100644 --- a/protocols/SkypeWeb/src/skype_login.cpp +++ b/protocols/SkypeWeb/src/skype_login.cpp @@ -105,7 +105,7 @@ void CSkypeProto::OnLoginSecond(const NETLIBHTTPREQUEST *response) void CSkypeProto::OnLoginSuccess() { - SelfSkypeName = getStringA("Skypename"); + SelfSkypeName = getStringA(SKYPE_SETTINGS_ID); TokenSecret = getStringA("TokenSecret"); Server = getStringA("registrationToken"); SendRequest(new CreateEndpointRequest(TokenSecret), &CSkypeProto::OnEndpointCreated); @@ -203,8 +203,7 @@ void CSkypeProto::OnCapabilitiesSended(const NETLIBHTTPREQUEST *response) m_hPollingThread = ForkThreadEx(&CSkypeProto::PollingThread, 0, NULL); - if (getByte("AutoSync", 1)) - SyncHistory(); + SyncHistory(); if (response == NULL || response->pData == NULL) return; diff --git a/protocols/SkypeWeb/src/skype_messages.cpp b/protocols/SkypeWeb/src/skype_messages.cpp index 8177d9c9f7..f1ecd66091 100644 --- a/protocols/SkypeWeb/src/skype_messages.cpp +++ b/protocols/SkypeWeb/src/skype_messages.cpp @@ -264,58 +264,78 @@ void CSkypeProto::OnPrivateMessageEvent(JSONNODE *node) } else OnReceiveMessage(clientMsgId, conversationLink, timestamp, message, emoteOffset); - } - else if (!mir_strcmpi(messageType, "Event/SkypeVideoMessage")){} - else if (!mir_strcmpi(messageType, "Event/Call")) + } + else if (!mir_strcmpi(messageType, "Event/SkypeVideoMessage")){} + else if (!mir_strcmpi(messageType, "Event/Call")) + { + //content=user name6 + //Echo / Sound Test Service6 + //content=user name + int iType = 3, iDuration = 0; + HXML xml = xi.parseString(ptrT(mir_a2t(content)), 0, _T("partlist")); + if (xml != NULL) { - //content=user name6 - //Echo / Sound Test Service6 - - //content=user name - ptrA name; - int iType = 3, iDuration = 0; - HXML xml = xi.parseString(ptrT(mir_a2t(content)), 0, _T("partlist")); - if (xml != NULL) - { - ptrA type(mir_t2a(xi.getAttrValue(xml, _T("type")))); + ptrA type(mir_t2a(xi.getAttrValue(xml, _T("type")))); - if (!mir_strcmpi(type, "ended")) iType = 0; - else if (!mir_strcmpi(type, "started")) iType = 1; + if (!mir_strcmpi(type, "ended")) iType = 0; + else if (!mir_strcmpi(type, "started")) iType = 1; - HXML xmlNode = xi.getChildByPath(xml, _T("part"), 0); - HXML duration = xmlNode == NULL ? NULL : xi.getChildByPath(xmlNode, _T("duration"), 0); - iDuration = duration != NULL ? atoi(mir_t2a(xi.getText(duration))) : NULL; + HXML xmlNode = xi.getChildByPath(xml, _T("part"), 0); + HXML duration = xmlNode == NULL ? NULL : xi.getChildByPath(xmlNode, _T("duration"), 0); + iDuration = duration != NULL ? atoi(mir_t2a(xi.getText(duration))) : NULL; - xi.destroyNode(xml); + xi.destroyNode(xml); + } + CMStringA text = ""; + if (iType == 1) + text.Append(Translate("Call started")); + else if (iType == 0) + { + CMStringA chours = "", cmins = "", csec = ""; + int hours=0, mins=0, sec=0; + if (iDuration != NULL) + { + hours = iDuration / 3600; + mins = iDuration / 60; + sec = iDuration % 60; } - CMStringA text = ""; - if (iType == 1) - text.Append(Translate("Call started")); - else if (iType == 0) + else + hours = mins = sec = 0; + + chours.AppendFormat(hours < 10 ? "0%d" : "%d", hours); + cmins.AppendFormat(mins < 10 ? "0%d" : "%d", mins); + csec.AppendFormat(sec < 10 ? "0%d" : "%d", sec); + text.AppendFormat("%s\n%s: %s:%s:%s", Translate("Call ended"), Translate("Duration"), chours, cmins, csec); + } + if (IsMe(from)) + AddMessageToDb(hContact, timestamp, DBEF_UTF | DBEF_SENT, clientMsgId, text.GetBuffer()); + else + OnReceiveMessage(clientMsgId, conversationLink, timestamp, text.GetBuffer()); + } + else if (!mir_strcmpi(messageType, "RichText/Files")) + { + //content=run.bat + HXML xml = xi.parseString(ptrT(mir_a2t(content)), 0, _T("files")); + if (xml != NULL) + { + for (int i=0; i < xi.getChildCount(xml); i++) { - CMStringA chours = "", cmins = "", csec = ""; - int hours=0, mins=0, sec=0; - if (iDuration != NULL) - { - hours = iDuration / 3600; - mins = iDuration / 60; - sec = iDuration % 60; - } - else - hours = mins = sec = 0; - - chours.AppendFormat(hours < 10 ? "0%d" : "%d", hours); - cmins.AppendFormat(mins < 10 ? "0%d" : "%d", mins); - csec.AppendFormat(sec < 10 ? "0%d" : "%d", sec); - text.AppendFormat("%s\n%s: %s:%s:%s", Translate("Call ended"), Translate("Duration"), chours, cmins, csec); + int fileSize; CMStringA msg = ""; + HXML xmlNode = xi.getNthChild(xml, L"file", i); + if (xmlNode == NULL) + break; + fileSize = atoi(_T2A(xi.getAttrValue(xmlNode, L"size"))); + ptrA fileName(mir_t2a(xi.getText(xmlNode))); + if (fileName == NULL || fileSize == NULL) + continue; + + msg.Empty(); + msg.AppendFormat("%s:\n\t%s: %s\n\t%s: %d %s", Translate("File transfer"), Translate("File name"), fileName, Translate("Size"), fileSize , Translate("bytes")); + AddMessageToDb(hContact, timestamp, DBEF_UTF | DBEF_READ, clientMsgId, msg.GetBuffer()); } - if (IsMe(from)) - AddMessageToDb(hContact, timestamp, DBEF_UTF | DBEF_SENT, clientMsgId, text.GetBuffer()); - else - OnReceiveMessage(clientMsgId, conversationLink, timestamp, text.GetBuffer()); } - + } } int CSkypeProto::OnDbEventRead(WPARAM hContact, LPARAM hDbEvent) -- cgit v1.2.3