summaryrefslogtreecommitdiff
path: root/protocols/SkypeWeb/src/skype_events.cpp
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2015-07-13 17:58:06 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2015-07-13 17:58:06 +0000
commitceae4e57634e4ff9efe506e3e937006d16f4787f (patch)
treebaaa841c9bd72fce5a295ad29a9cd20784c9f069 /protocols/SkypeWeb/src/skype_events.cpp
parenta39bed945be56898d2eee18830ee3060f71b8ccd (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_events.cpp')
-rw-r--r--protocols/SkypeWeb/src/skype_events.cpp93
1 files changed, 90 insertions, 3 deletions
diff --git a/protocols/SkypeWeb/src/skype_events.cpp b/protocols/SkypeWeb/src/skype_events.cpp
index bad357df93..99dd4a2b5e 100644
--- a/protocols/SkypeWeb/src/skype_events.cpp
+++ b/protocols/SkypeWeb/src/skype_events.cpp
@@ -22,7 +22,86 @@ INT_PTR CSkypeProto::GetCallEventText(WPARAM, LPARAM lParam)
DBEVENTGETTEXT *pEvent = (DBEVENTGETTEXT *)lParam;
INT_PTR nRetVal = 0;
- char *pszText = Translate("Incoming call");
+
+ ptrA pszText;
+
+ switch (pEvent->dbei->eventType)
+ {
+ case SKYPE_DB_EVENT_TYPE_CALL_INFO:
+ {
+ CMStringA text;
+ HXML xml = xmlParseString(ptrT(mir_utf8decodeT((char*)pEvent->dbei->pBlob)), 0, _T("partlist"));
+ if (xml != NULL)
+ {
+ ptrA type(mir_t2a(xmlGetAttrValue(xml, _T("type"))));
+ bool bType = (!mir_strcmpi(type, "started")) ? 1 : 0;
+
+ for (int i = 0; i < xmlGetChildCount(xml); i++)
+ {
+ HXML xmlPart = xmlGetNthChild(xml, _T("part"), i);
+ if (xmlPart != NULL)
+ {
+ HXML xmlName = xmlGetChildByPath(xmlPart, _T("name"), 0);
+ if (xmlName != NULL)
+ {
+ text.AppendFormat(Translate("%s %s this call. \n"), mir_t2a(xmlGetText(xmlName)), bType ? Translate("enter") : Translate("left"));
+ xmlDestroyNode(xmlName);
+ }
+ xmlDestroyNode(xmlPart);
+ }
+ }
+ xmlDestroyNode(xml);
+ }
+ pszText = mir_strdup(text.GetBuffer());
+ break;
+ }
+ case SKYPE_DB_EVENT_TYPE_FILETRANSFER_INFO:
+ {
+ CMStringA text;
+ HXML xml = xmlParseString(ptrT(mir_utf8decodeT((char*)pEvent->dbei->pBlob)), 0, _T("files"));
+ if (xml != NULL)
+ {
+ for (int i = 0; i < xmlGetChildCount(xml); i++)
+ {
+ size_t fileSize = 0;
+ HXML xmlNode = xmlGetNthChild(xml, _T("file"), i);
+ if (xmlNode != NULL)
+ {
+ 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"));
+ text.AppendFormat("%s\n", msg);
+ }
+ }
+ }
+ pszText = mir_strdup(text.GetBuffer());
+ break;
+ }
+ case SKYPE_DB_EVENT_TYPE_URIOBJ:
+ {
+ CMStringA text;
+ HXML xml = xmlParseString(ptrT(mir_utf8decodeT((char*)pEvent->dbei->pBlob)), 0, _T("URIObject"));
+ if (xml != NULL)
+ {
+ text.Append(mir_t2a(xmlGetText(xml)));
+ }
+ pszText = mir_strdup(text.GetBuffer());
+ break;
+
+ }
+ case SKYPE_DB_EVENT_TYPE_INCOMING_CALL:
+ {
+ pszText = Translate("Incoming call.");
+ break;
+ }
+ default:
+ {
+ pszText = mir_strdup((char*)pEvent->dbei->pBlob);
+ }
+ }
+
if (pEvent->datatype == DBVT_TCHAR)
{
@@ -31,7 +110,7 @@ INT_PTR CSkypeProto::GetCallEventText(WPARAM, LPARAM lParam)
}
else if (pEvent->datatype == DBVT_ASCIIZ)
- nRetVal = (INT_PTR)mir_strdup(Translate(pszText));
+ nRetVal = (INT_PTR)mir_strdup(pszText);
return nRetVal;
}
@@ -71,6 +150,7 @@ void CSkypeProto::InitDBEvents()
dbEventType.module = m_szModuleName;
dbEventType.flags = DETF_HISTORY | DETF_MSGWINDOW;
dbEventType.iconService = MODULE"/GetEventIcon";
+ dbEventType.textService = MODULE"/GetCallText";
dbEventType.eventType = SKYPE_DB_EVENT_TYPE_ACTION;
dbEventType.descr = Translate("Action");
@@ -80,9 +160,16 @@ void CSkypeProto::InitDBEvents()
dbEventType.descr = Translate("Call information.");
CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType);
+ dbEventType.eventType = SKYPE_DB_EVENT_TYPE_FILETRANSFER_INFO;
+ dbEventType.descr = Translate("File transfer information.");
+ CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType);
+
+ dbEventType.eventType = SKYPE_DB_EVENT_TYPE_URIOBJ;
+ dbEventType.descr = Translate("Uri object.");
+ CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType);
+
dbEventType.eventType = SKYPE_DB_EVENT_TYPE_INCOMING_CALL;
dbEventType.descr = Translate("Incoming call");
- dbEventType.textService = MODULE"/GetCallText";
dbEventType.flags |= DETF_NONOTIFY;
CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType);
}