diff options
author | MikalaiR <nikolay.romanovich@narod.ru> | 2015-07-13 17:58:06 +0000 |
---|---|---|
committer | MikalaiR <nikolay.romanovich@narod.ru> | 2015-07-13 17:58:06 +0000 |
commit | ceae4e57634e4ff9efe506e3e937006d16f4787f (patch) | |
tree | baaa841c9bd72fce5a295ad29a9cd20784c9f069 /protocols/SkypeWeb/src/skype_messages.cpp | |
parent | a39bed945be56898d2eee18830ee3060f71b8ccd (diff) |
SkypeWeb: big refactoring
git-svn-id: http://svn.miranda-ng.org/main/trunk@14551 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/SkypeWeb/src/skype_messages.cpp')
-rw-r--r-- | protocols/SkypeWeb/src/skype_messages.cpp | 77 |
1 files changed, 7 insertions, 70 deletions
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=<partlist type="ended" alt=""><part identity="username"><name>user name</name><duration>6</duration></part>
//<part identity="echo123"><name>Echo / Sound Test Service</name><duration>6</duration></part></partlist>
//content=<partlist type="started" alt=""><part identity="username"><name>user name</name></part></partlist>
- 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=<files alt="отправил (-а) файл "run.bat""><file size="97" index="0" tid="4197760077">run.bat</file></files>
- 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=<URIObject type="Picture.1" uri="https://api.asm.skype.com/v1//objects/0-weu-d1-262f0a1ee256d03b8e4b8360d9208834" url_thumbnail="https://api.asm.skype.com/v1//objects/0-weu-d1-262f0a1ee256d03b8e4b8360d9208834/views/imgt1"><Title></Title><Description></Description>Для просмотра этого общего фото перейдите по ссылке: https://api.asm.skype.com/s/i?0-weu-d1-262f0a1ee256d03b8e4b8360d9208834<meta type="photo" originalName="ysd7ZE4BqOg.jpg"/><OriginalName v="ysd7ZE4BqOg.jpg"/></URIObject>
- 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")) {}
|