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_messages.cpp | 77 +++---------------------------- 1 file changed, 7 insertions(+), 70 deletions(-) (limited to 'protocols/SkypeWeb/src/skype_messages.cpp') diff --git a/protocols/SkypeWeb/src/skype_messages.cpp b/protocols/SkypeWeb/src/skype_messages.cpp index 7d39add241..5dbfbb78e0 100644 --- a/protocols/SkypeWeb/src/skype_messages.cpp +++ b/protocols/SkypeWeb/src/skype_messages.cpp @@ -171,7 +171,7 @@ void CSkypeProto::OnPrivateMessageEvent(const JSONNode &node) int hMessage = atoi(clientMsgId.c_str()); ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)hMessage, 0); debugLogA(__FUNCTION__" timestamp = %d clientmsgid = %s", timestamp, clientMsgId); - AddMessageToDb(hContact, timestamp, DBEF_UTF | DBEF_SENT, clientMsgId.c_str(), message, emoteOffset); + AddDbEvent(emoteOffset == 0 ? EVENTTYPE_MESSAGE : SKYPE_DB_EVENT_TYPE_ACTION, hContact, timestamp, DBEF_UTF | DBEF_SENT, &content.c_str()[emoteOffset], clientMsgId.c_str()); return; } CallService(MS_PROTO_CONTACTISTYPING, hContact, PROTOTYPE_CONTACTTYPING_OFF); @@ -198,7 +198,7 @@ void CSkypeProto::OnPrivateMessageEvent(const JSONNode &node) msg.AppendFormat("%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, DBEF_UTF, skypeEditedId.c_str(), ptrA(mir_utf8encode(msg.GetBuffer()))); + AddDbEvent(EVENTTYPE_MESSAGE, hContact, dbEventTimestamp, DBEF_UTF, ptrA(mir_utf8encode(msg.GetBuffer())), skypeEditedId.c_str()); } else OnReceiveMessage(clientMsgId.c_str(), conversationLink.c_str(), timestamp, message, emoteOffset); } @@ -208,83 +208,20 @@ void CSkypeProto::OnPrivateMessageEvent(const JSONNode &node) //content=user name6 //Echo / Sound Test Service6 //content=user name - int iType = 3, iDuration = 0; - 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); - } - - int flags = DBEF_UTF; - if (IsMe(from)) flags |= DBEF_SENT; - - 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; - HXML xmlNode = xmlGetNthChild(xml, _T("file"), i); - if (xmlNode == NULL) - break; - fileSize = _ttoi(xmlGetAttrValue(xmlNode, _T("size"))); - ptrA fileName(mir_utf8encodeT(xmlGetText(xmlNode))); - if (fileName == NULL || fileSize == NULL) - continue; - - CMStringA msg(FORMAT, "%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.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/Location")) {} 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()); - AddMessageToDb(hContact, timestamp, DBEF_UTF, clientMsgId.c_str(), data.GetBuffer()); - } + AddDbEvent(SKYPE_DB_EVENT_TYPE_URIOBJ, hContact, timestamp, DBEF_UTF, content.c_str(), clientMsgId.c_str()); } else if (!mir_strcmpi(messageType.c_str(), "RichText/Contacts")) {} -- cgit v1.2.3