From ceae4e57634e4ff9efe506e3e937006d16f4787f Mon Sep 17 00:00:00 2001 From: MikalaiR Date: Mon, 13 Jul 2015 17:58:06 +0000 Subject: SkypeWeb: big refactoring git-svn-id: http://svn.miranda-ng.org/main/trunk@14551 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/SkypeWeb/src/skype_history_sync.cpp | 78 +++------------------------ 1 file changed, 6 insertions(+), 72 deletions(-) (limited to 'protocols/SkypeWeb/src/skype_history_sync.cpp') diff --git a/protocols/SkypeWeb/src/skype_history_sync.cpp b/protocols/SkypeWeb/src/skype_history_sync.cpp index 9638e278a8..060855f72a 100644 --- a/protocols/SkypeWeb/src/skype_history_sync.cpp +++ b/protocols/SkypeWeb/src/skype_history_sync.cpp @@ -95,90 +95,24 @@ void CSkypeProto::OnGetServerHistory(const NETLIBHTTPREQUEST *response) CMStringA msg(FORMAT, "%s\n%s %s:\n%s", mir_utf8decodeA(dbMsgText), Translate("Edited at"), T2Utf(time), mir_utf8decodeA(message)); db_event_delete(hContact, dbevent); - AddMessageToDb(hContact, dbEventTimestamp, flags, clientMsgId.c_str(), mir_utf8encode(msg.GetBuffer()), emoteOffset); + AddDbEvent(EVENTTYPE_MESSAGE, hContact, dbEventTimestamp, flags, mir_utf8encode(&msg.GetBuffer()[emoteOffset]), clientMsgId.c_str()); } - else AddMessageToDb(hContact, timestamp, flags, clientMsgId.c_str(), message, emoteOffset); + else AddDbEvent(EVENTTYPE_MESSAGE, hContact, timestamp, flags, &message[emoteOffset], clientMsgId.c_str()); } else if (!mir_strcmpi(messageType.c_str(), "Event/Call")) { - //content=user name6 - //Echo / Sound Test Service6 - - //content=user name - int iType = 3, iDuration = 0; - CMStringA skypename(ContactUrlToName(from.c_str())); - HXML xml = xmlParseString(ptrT(mir_a2t(content.c_str())), 0, _T("partlist")); - if (xml != NULL) - { - - ptrA type(mir_t2a(xmlGetAttrValue(xml, _T("type")))); - - if (!mir_strcmpi(type, "ended")) iType = 0; - else if (!mir_strcmpi(type, "started")) iType = 1; - HXML xmlNode = xmlGetChildByPath(xml, _T("part"), 0); - HXML duration = xmlNode == NULL ? NULL : xmlGetChildByPath(xmlNode, _T("duration"), 0); - iDuration = duration != NULL ? atoi(mir_t2a(xmlGetText(duration))) : NULL; - - xmlDestroyNode(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) - (hours * 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); - } - AddCallInfoToDb(hContact, timestamp, flags, clientMsgId.c_str(), text.GetBuffer()); + AddDbEvent(SKYPE_DB_EVENT_TYPE_CALL_INFO, hContact, timestamp, DBEF_UTF, content.c_str(), clientMsgId.c_str()); } else if (!mir_strcmpi(messageType.c_str(), "RichText/Files")) { - //content=run.bat - HXML xml = xmlParseString(ptrT(mir_a2t(content.c_str())), 0, _T("files")); - if (xml != NULL) - { - for (int i = 0; i < xmlGetChildCount(xml); i++) - { - int fileSize; CMStringA msg = ""; - HXML xmlNode = xmlGetNthChild(xml, L"file", i); - if (xmlNode == NULL) - break; - fileSize = atoi(_T2A(xmlGetAttrValue(xmlNode, L"size"))); - ptrA fileName(mir_t2a(xmlGetText(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, flags, clientMsgId.c_str(), msg.GetBuffer()); - } - } + AddDbEvent(SKYPE_DB_EVENT_TYPE_FILETRANSFER_INFO, hContact, timestamp, DBEF_UTF, content.c_str(), clientMsgId.c_str()); } else if (!mir_strcmpi(messageType.c_str(), "RichText/UriObject")) { //content=Для просмотра этого общего фото перейдите по ссылке: https://api.asm.skype.com/s/i?0-weu-d1-262f0a1ee256d03b8e4b8360d9208834 - HXML xml = xmlParseString(ptrT(mir_a2t(content.c_str())), 0, _T("URIObject")); - if (xml != NULL) - { - CMStringA object(ParseUrl(_T2A(xmlGetAttrValue(xml, L"uri")), "/objects/")); - CMStringA data(FORMAT, "%s: https://api.asm.skype.com/s/i?%s", Translate("Image"), object.c_str()); + AddDbEvent(SKYPE_DB_EVENT_TYPE_URIOBJ, hContact, timestamp, DBEF_UTF, content.c_str(), clientMsgId.c_str()); - AddMessageToDb(hContact, timestamp, flags, clientMsgId.c_str(), data.GetBuffer()); - } - } //Picture + } } else if (conversationLink.find("/19:") != -1) { -- cgit v1.2.3