summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2015-08-25 12:58:13 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2015-08-25 12:58:13 +0000
commitc9e610c405ec66764de279ff797ffa48964936be (patch)
tree48b5035d4afabfc7a3a00b0c9030b4baae5fd80e /protocols
parent419ee3af2ba3f822b6cbd01ebaf29c10e3bcc039 (diff)
SkypeWeb: Contacts receiving
git-svn-id: http://svn.miranda-ng.org/main/trunk@15028 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r--protocols/SkypeWeb/src/skype_history_sync.cpp4
-rw-r--r--protocols/SkypeWeb/src/skype_messages.cpp64
-rw-r--r--protocols/SkypeWeb/src/skype_proto.cpp36
-rw-r--r--protocols/SkypeWeb/src/skype_proto.h4
-rw-r--r--protocols/SkypeWeb/src/skype_utils.cpp3
5 files changed, 105 insertions, 6 deletions
diff --git a/protocols/SkypeWeb/src/skype_history_sync.cpp b/protocols/SkypeWeb/src/skype_history_sync.cpp
index 03c786cfe3..2dc48c65b9 100644
--- a/protocols/SkypeWeb/src/skype_history_sync.cpp
+++ b/protocols/SkypeWeb/src/skype_history_sync.cpp
@@ -93,6 +93,10 @@ void CSkypeProto::OnGetServerHistory(const NETLIBHTTPREQUEST *response)
{
AddDbEvent(SKYPE_DB_EVENT_TYPE_URIOBJ, hContact, timestamp, iFlags, content.c_str(), szMessageId);
}
+ else if (messageType == "RichText/Contacts")
+ {
+ ProcessContactRecv(hContact, timestamp, content.c_str(), szMessageId);
+ }
else
{
AddDbEvent(SKYPE_DB_EVENT_TYPE_UNKNOWN, hContact, timestamp, iFlags, content.c_str(), szMessageId);
diff --git a/protocols/SkypeWeb/src/skype_messages.cpp b/protocols/SkypeWeb/src/skype_messages.cpp
index b8483e7b46..45fe0177d3 100644
--- a/protocols/SkypeWeb/src/skype_messages.cpp
+++ b/protocols/SkypeWeb/src/skype_messages.cpp
@@ -28,7 +28,6 @@ int CSkypeProto::OnReceiveMessage(MCONTACT hContact, const char *szContent, cons
recv.lParam = emoteOffset;
recv.pCustomData = (void*)mir_strdup(szMessageId);
recv.cbCustomDataSize = (DWORD)mir_strlen(szMessageId);
-
if (isRead)
recv.flags |= PREF_CREATEREAD;
@@ -234,8 +233,11 @@ void CSkypeProto::OnPrivateMessageEvent(const JSONNode &node)
{
AddDbEvent(SKYPE_DB_EVENT_TYPE_URIOBJ, hContact, timestamp, DBEF_UTF, strContent.c_str(), szMessageId);
}
+ else if (strMessageType == "RichText/Contacts")
+ {
+ ProcessContactRecv(hContact, timestamp, strContent.c_str(), szMessageId);
+ }
//else if (messageType == "Event/SkypeVideoMessage") {}
- //else if (messageType.c_str() == "RichText/Contacts") {}
//else if (messageType.c_str() == "RichText/Location") {}
else
{
@@ -263,3 +265,61 @@ void CSkypeProto::MarkMessagesRead(MCONTACT hContact, MEVENT hDbEvent)
if(db_get_dw(hContact, m_szModuleName, "LastMsgTime", 0) > (timestamp - 300))
PushRequest(new MarkMessageReadRequest(username, timestamp, timestamp, false, li));
}
+
+
+void CSkypeProto::ProcessContactRecv(MCONTACT hContact, time_t timestamp, const char *szContent, const char *szMessageId)
+{
+ HXML xmlNode = xmlParseString(mir_utf8decodeT(szContent), 0, _T("contacts"));
+ if (xmlNode)
+ {
+ int nCount = 0;
+ PROTOSEARCHRESULT **psr;
+ for (int i = 0; i < xmlGetChildCount(xmlNode); i++) nCount++;
+
+ if (psr = (PROTOSEARCHRESULT**)mir_calloc(sizeof(PROTOSEARCHRESULT*) * nCount))
+ {
+ nCount = 0;
+ for (int i = 0; i < xmlGetChildCount(xmlNode); i++)
+ {
+ HXML xmlContact = xmlGetNthChild(xmlNode, _T("c"), i);
+ if (xmlContact != NULL)
+ {
+ const TCHAR *tszContactId = xmlGetAttrValue(xmlContact, L"s");
+ //const TCHAR *tszContactName = xmlGetAttrValue(xmlContact, L"f");
+
+ psr[nCount] = (PROTOSEARCHRESULT*)mir_calloc(sizeof(PROTOSEARCHRESULT));
+ psr[nCount]->cbSize = sizeof(psr);
+ psr[nCount]->flags = PSR_TCHAR;
+ psr[nCount]->id.t = mir_tstrdup(tszContactId);
+ //psr[nCount]->nick.t = mir_tstrdup(tszContactName == NULL ? L"" : tszContactName);
+ nCount++;
+ }
+ }
+ if (nCount)
+ {
+ PROTORECVEVENT pre = { 0 };
+ pre.timestamp = (DWORD)timestamp;
+ pre.szMessage = (char*)psr;
+
+ PBYTE b = (PBYTE)mir_calloc(sizeof(DWORD) + mir_strlen(szMessageId) + 1);
+ PBYTE pCur = b;
+ *((PDWORD)pCur) = nCount;
+ pCur += sizeof(DWORD);
+
+ mir_strcpy((char*)pCur, szMessageId);
+
+ pre.lParam = (LPARAM)b;
+
+ ProtoChainRecv(hContact, PSR_CONTACTS, 0, (LPARAM)&pre);
+ for (nCount = 0; nCount < *((PDWORD)b); nCount++)
+ {
+ mir_free(psr[nCount]->id.t);
+ mir_free(psr[nCount]->nick.t);
+ mir_free(psr[nCount]);
+ }
+ mir_free(b);
+ }
+ mir_free(psr);
+ }
+ }
+} \ No newline at end of file
diff --git a/protocols/SkypeWeb/src/skype_proto.cpp b/protocols/SkypeWeb/src/skype_proto.cpp
index 0b66f02421..4d1e236bce 100644
--- a/protocols/SkypeWeb/src/skype_proto.cpp
+++ b/protocols/SkypeWeb/src/skype_proto.cpp
@@ -304,4 +304,40 @@ int CSkypeProto::OnEvent(PROTOEVENTTYPE iEventType, WPARAM wParam, LPARAM lParam
}
return 1;
+}
+
+int CSkypeProto::RecvContacts(MCONTACT hContact, PROTORECVEVENT* pre)
+{
+ PROTOSEARCHRESULT **isrList = (PROTOSEARCHRESULT**)pre->szMessage;
+ DWORD cbBlob = 0;
+ BYTE *pBlob;
+ BYTE *pCurBlob;
+ int i;
+
+ int nCount = *((LPARAM*)pre->lParam);
+ char* szMessageId = ((char*)pre->lParam + sizeof(LPARAM));
+
+ //if (GetMessageFromDb(hContact, szMessageId, pre->timestamp)) return 0;
+
+ for (i = 0; i < nCount; i++)
+ cbBlob += int(/*mir_tstrlen(isrList[i]->nick.t)*/0 + 2 + mir_tstrlen(isrList[i]->id.t) + mir_strlen(szMessageId));
+
+ pBlob = (PBYTE)mir_calloc(cbBlob);
+
+ for (i = 0, pCurBlob = pBlob; i < nCount; i++)
+ {
+ //mir_strcpy((char*)pCurBlob, _T2A(isrList[i]->nick.t));
+ pCurBlob += mir_strlen((PCHAR)pCurBlob) + 1;
+
+ mir_strcpy((char*)pCurBlob, _T2A(isrList[i]->id.t));
+ pCurBlob += mir_strlen((char*)pCurBlob) + 1;
+ }
+
+ //memcpy(pCurBlob + 1, szMessageId, mir_strlen(szMessageId));
+
+ AddEventToDb(hContact, EVENTTYPE_CONTACTS, pre->timestamp, (pre->flags & PREF_CREATEREAD) ? DBEF_READ : 0, cbBlob, pBlob);
+
+ mir_free(pBlob);
+
+ return 0;
} \ No newline at end of file
diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h
index 5aee7df862..da1ae3f713 100644
--- a/protocols/SkypeWeb/src/skype_proto.h
+++ b/protocols/SkypeWeb/src/skype_proto.h
@@ -51,7 +51,7 @@ public:
virtual int __cdecl SetStatus(int iNewStatus);
virtual int __cdecl UserIsTyping(MCONTACT hContact, int type);
virtual int __cdecl OnEvent(PROTOEVENTTYPE iEventType, WPARAM wParam, LPARAM lParam);
-
+ virtual int __cdecl RecvContacts(MCONTACT hContact, PROTORECVEVENT*);
// accounts
static CSkypeProto* InitAccount(const char *protoName, const TCHAR *userName);
static int UninitAccount(CSkypeProto *proto);
@@ -262,6 +262,8 @@ private:
void OnPrivateMessageEvent(const JSONNode &node);
+ void ProcessContactRecv(MCONTACT hContact, time_t timestamp, const char *szContent, const char *szMessageId);
+
// sync
void OnGetServerHistory(const NETLIBHTTPREQUEST *response);
void OnSyncHistory(const NETLIBHTTPREQUEST *response);
diff --git a/protocols/SkypeWeb/src/skype_utils.cpp b/protocols/SkypeWeb/src/skype_utils.cpp
index ab8b614131..f7f287fd04 100644
--- a/protocols/SkypeWeb/src/skype_utils.cpp
+++ b/protocols/SkypeWeb/src/skype_utils.cpp
@@ -347,9 +347,6 @@ char *CSkypeProto::RemoveHtml(const char *text)
std::string new_string = "";
std::string data = text;
- if (data.find("\x1b\xe3\xac\x8d\x1d") != -1)
- data = "CONVERSATION MEMBERS:" + data.substr(5, data.length() - 5);
-
for (std::string::size_type i = 0; i < data.length(); i++)
{
if (data.at(i) == '<')