From 900cb3561405d385c70fc57c94e46bc1e4fa178b Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Thu, 28 Aug 2014 18:08:32 +0000 Subject: Tox: actions support (messages started with '/me') git-svn-id: http://svn.miranda-ng.org/main/trunk@10334 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Tox/src/tox_proto.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'protocols/Tox/src/tox_proto.cpp') diff --git a/protocols/Tox/src/tox_proto.cpp b/protocols/Tox/src/tox_proto.cpp index 9547b33f90..3693cfc741 100644 --- a/protocols/Tox/src/tox_proto.cpp +++ b/protocols/Tox/src/tox_proto.cpp @@ -30,6 +30,15 @@ CToxProto::CToxProto(const char* protoName, const TCHAR* userName) : sid.ptszDescription = LPGENT("Protocol icon"); sid.iDefaultIndex = -IDI_TOX; Skin_AddIcon(&sid); + + // custom event + DBEVENTTYPEDESCR dbEventType = { sizeof(dbEventType) }; + dbEventType.module = this->m_szModuleName; + dbEventType.flags = DETF_HISTORY | DETF_MSGWINDOW; + + dbEventType.eventType = TOX_DB_EVENT_TYPE_ACTION; + dbEventType.descr = "Tox action"; + CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType); } CToxProto::~CToxProto() @@ -235,7 +244,16 @@ int __cdecl CToxProto::SendMsg(MCONTACT hContact, int flags, const char* msg) uint32_t number = tox_get_friend_number(tox, clientId.data()); - int result = tox_send_message(tox, number, (uint8_t*)msg, (uint16_t)strlen(msg)); + int result = 0; + if (strncmp(msg, "/me ", 4) != 0) + { + result = tox_send_message(tox, number, (uint8_t*)msg, (uint16_t)strlen(msg)); + } + else + { + result = tox_send_action(tox, number, (uint8_t*)&msg[4], (uint16_t)strlen(msg) - 4); + } + if (result == 0) { debugLogA("CToxProto::SendMsg: could not to send message"); -- cgit v1.2.3