diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2015-04-03 21:06:18 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2015-04-03 21:06:18 +0000 |
commit | 035b5186bba8c0cab7d349f849c5c1db7cad7e39 (patch) | |
tree | f494a37398b31665d4deb6ebd2e2e52eb98292ef /protocols/SkypeWeb/src/skype_messages.cpp | |
parent | 77633ec5799b374a1899d05ae69a2e5f978f2a7c (diff) |
SkypeWeb: messaging support (patch from MikalaiR)
git-svn-id: http://svn.miranda-ng.org/main/trunk@12595 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/SkypeWeb/src/skype_messages.cpp')
-rw-r--r-- | protocols/SkypeWeb/src/skype_messages.cpp | 60 |
1 files changed, 46 insertions, 14 deletions
diff --git a/protocols/SkypeWeb/src/skype_messages.cpp b/protocols/SkypeWeb/src/skype_messages.cpp index c4f9498885..869d7e75d5 100644 --- a/protocols/SkypeWeb/src/skype_messages.cpp +++ b/protocols/SkypeWeb/src/skype_messages.cpp @@ -3,21 +3,21 @@ /* MESSAGE RECEIVING */
// writing message/even into db
-int CSkypeProto::OnReceiveMessage(MCONTACT hContact, PROTORECVEVENT *pre)
+int CSkypeProto::OnReceiveMessage(const char *from, const char *convLink, time_t timeStamp, char *content)
{
- //return Proto_RecvMessage(hContact, pre);
- if (pre->szMessage == NULL)
- return NULL;
-
- DBEVENTINFO dbei = { sizeof(dbei) };
- dbei.szModule = GetContactProto(hContact);
- dbei.timestamp = pre->timestamp;
- dbei.flags = DBEF_UTF;
- dbei.eventType = pre->lParam;
- dbei.cbBlob = (DWORD)mir_strlen(pre->szMessage) + 1;
- dbei.pBlob = (PBYTE)pre->szMessage;
-
- return (INT_PTR)db_event_add(hContact, &dbei);
+ PROTORECVEVENT recv = { 0 };
+ recv.flags = PREF_UTF;
+ recv.timestamp = timeStamp;
+ recv.szMessage = content;
+ debugLogA("Incoming message from %s", ContactUrlToName(from));
+ if (IsMe(ContactUrlToName(from)))
+ {
+ recv.flags |= PREF_SENT;
+ MCONTACT hContact = GetContact(ContactUrlToName(convLink));
+ return ProtoChainRecvMsg(hContact, &recv);
+ }
+ MCONTACT hContact = GetContact(ContactUrlToName(from));
+ return ProtoChainRecvMsg(hContact, &recv);
}
/* MESSAGE SENDING */
@@ -26,4 +26,36 @@ int CSkypeProto::OnReceiveMessage(MCONTACT hContact, PROTORECVEVENT *pre) int CSkypeProto::OnSendMessage(MCONTACT hContact, int flags, const char *szMessage)
{
return 0;
+}
+
+void CSkypeProto::OnMessageSent(const NETLIBHTTPREQUEST *response, void *arg)
+{
+ SendMessageParam *param = (SendMessageParam*)arg;
+
+ ptrT error(mir_tstrdup(TranslateT("Unknown error")));
+ ptrT username(getTStringA(param->hContact, "Skypename"));
+
+ if (response != NULL && (response->resultCode == 201 || response->resultCode == 200))
+ {
+ JSONROOT root(response->pData);
+ JSONNODE *node = json_get(root, "errorCode");
+ if (node)
+ error = json_as_string(node);
+ }
+
+ int status = ACKRESULT_FAILED;
+
+ if (error == NULL)
+ {
+ status = ACKRESULT_SUCCESS;
+ }
+ else
+ debugLog(_T("CSkypeProto::OnMessageSent: failed to send message for %s (%s)"), username, error);
+
+ ProtoBroadcastAck(
+ param->hContact,
+ ACKTYPE_MESSAGE,
+ status,
+ param->hMessage,
+ error);
}
\ No newline at end of file |