diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2014-08-30 11:37:47 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2014-08-30 11:37:47 +0000 |
commit | ce49c84f3a26f016f9232d2bffdc830d7fd6169f (patch) | |
tree | c6bbdab7b5a42f65461a5d495d962c4ff69b9e97 /protocols/Tox/src/tox_messages.cpp | |
parent | beaf93e92827b7bcc77c9f6b2a0c7097d355151c (diff) |
Tox:
- switch to offline when connection is lost
- file transfer support
- code refactoring
- project reordering
- version bump
git-svn-id: http://svn.miranda-ng.org/main/trunk@10340 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Tox/src/tox_messages.cpp')
-rw-r--r-- | protocols/Tox/src/tox_messages.cpp | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/protocols/Tox/src/tox_messages.cpp b/protocols/Tox/src/tox_messages.cpp new file mode 100644 index 0000000000..0c57fbf68d --- /dev/null +++ b/protocols/Tox/src/tox_messages.cpp @@ -0,0 +1,83 @@ +#include "common.h"
+
+void CToxProto::OnFriendMessage(Tox *tox, const int number, const uint8_t *message, const uint16_t messageSize, void *arg)
+{
+ CToxProto *proto = (CToxProto*)arg;
+
+ MCONTACT hContact = proto->FindContact(number);
+ if (hContact)
+ {
+ PROTORECVEVENT recv = { 0 };
+ recv.flags = PREF_UTF;
+ recv.timestamp = time(NULL);
+ recv.szMessage = (char*)message;
+
+ ProtoChainRecvMsg(hContact, &recv);
+ }
+}
+
+void CToxProto::OnFriendAction(Tox *tox, const int number, const uint8_t *action, const uint16_t actionSize, void *arg)
+{
+ CToxProto *proto = (CToxProto*)arg;
+
+ MCONTACT hContact = proto->FindContact(number);
+ if (hContact)
+ {
+ proto->AddDbEvent(
+ hContact,
+ TOX_DB_EVENT_TYPE_ACTION,
+ time(NULL),
+ DBEF_UTF,
+ actionSize,
+ (BYTE*)action);
+ }
+}
+
+void CToxProto::OnTypingChanged(Tox *tox, const int number, uint8_t isTyping, void *arg)
+{
+ CToxProto *proto = (CToxProto*)arg;
+
+ MCONTACT hContact = proto->FindContact(number);
+ if (hContact)
+ {
+ CallService(MS_PROTO_CONTACTISTYPING, hContact, (LPARAM)isTyping);
+ }
+}
+
+void CToxProto::OnReadReceipt(Tox *tox, int32_t number, uint32_t receipt, void *arg)
+{
+ CToxProto *proto = (CToxProto*)arg;
+
+ MCONTACT hContact = proto->FindContact(number);
+ if (hContact)
+ {
+ proto->ProtoBroadcastAck(
+ hContact,
+ ACKTYPE_MESSAGE,
+ ACKRESULT_SUCCESS,
+ (HANDLE)receipt, 0);
+ }
+}
+
+int CToxProto::OnPreCreateMessage(WPARAM wParam, LPARAM lParam)
+{
+ MessageWindowEvent *evt = (MessageWindowEvent *)lParam;
+ if (strcmp(GetContactProto(evt->hContact), m_szModuleName))
+ {
+ return 0;
+ }
+
+ char *message = (char*)evt->dbei->pBlob;
+ if (strncmp(message, "/me ", 4) == 0)
+ {
+ BYTE *action = (BYTE*)mir_alloc(sizeof(BYTE)* (evt->dbei->cbBlob - 4));
+ memcpy(action, (char*)&evt->dbei->pBlob[4], evt->dbei->cbBlob - 4);
+ mir_free(evt->dbei->pBlob);
+ evt->dbei->pBlob = action;
+ evt->dbei->cbBlob -= 4;
+
+ evt->dbei->eventType = TOX_DB_EVENT_TYPE_ACTION;
+ }
+
+ return 1;
+}
\ No newline at end of file |