From 035b5186bba8c0cab7d349f849c5c1db7cad7e39 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Fri, 3 Apr 2015 21:06:18 +0000 Subject: SkypeWeb: messaging support (patch from MikalaiR) git-svn-id: http://svn.miranda-ng.org/main/trunk@12595 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/SkypeWeb/src/skype_proto.cpp | 37 +++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) (limited to 'protocols/SkypeWeb/src/skype_proto.cpp') diff --git a/protocols/SkypeWeb/src/skype_proto.cpp b/protocols/SkypeWeb/src/skype_proto.cpp index 69d8eed9fc..61b8f2445a 100644 --- a/protocols/SkypeWeb/src/skype_proto.cpp +++ b/protocols/SkypeWeb/src/skype_proto.cpp @@ -108,15 +108,46 @@ int CSkypeProto::RecvContacts(MCONTACT, PROTORECVEVENT*) { return 0; } int CSkypeProto::RecvFile(MCONTACT hContact, PROTOFILEEVENT *pre) { return 0; } -int CSkypeProto::RecvMsg(MCONTACT hContact, PROTORECVEVENT *pre) { return 0; } - int CSkypeProto::RecvUrl(MCONTACT, PROTORECVEVENT*) { return 0; } int CSkypeProto::SendContacts(MCONTACT, int, int, MCONTACT*) { return 0; } HANDLE CSkypeProto::SendFile(MCONTACT hContact, const PROTOCHAR *szDescription, PROTOCHAR **ppszFiles) { return 0; } -int CSkypeProto::SendMsg(MCONTACT hContact, int flags, const char *msg) { return 0; } +int CSkypeProto::SendMsg(MCONTACT hContact, int flags, const char *msg) +{ + UINT hMessage = InterlockedIncrement(&hMessageProcess); + + SendMessageParam *param = (SendMessageParam*)mir_calloc(sizeof(SendMessageParam)); + param->hContact = hContact; + param->hMessage = (HANDLE)hMessage; + param->msg = msg; + param->flags = flags; + + ForkThread(&CSkypeProto::SendMsgThread, (void*)param); + + return hMessage; +} + +void CSkypeProto::SendMsgThread(void *arg) +{ + SendMessageParam *param = (SendMessageParam*)arg; + + if (!IsOnline()) + { + ProtoBroadcastAck(param->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, param->hMessage, (LPARAM)Translate("You cannot send messages when you are offline.")); + mir_free(param); + return; + } + + CMStringA message = (param->flags & PREF_UNICODE) ? ptrA(mir_utf8encode(param->msg)) : param->msg; // TODO: mir_utf8encode check taken from FacebookRM, is it needed? Usually we get PREF_UTF8 flag instead. + + ptrA token(getStringA("registrationToken")); + ptrA username(getStringA(param->hContact, "Skypename")); + PushRequest( + new SendMsgRequest(token, username, message, getStringA("Server"))/*, + &CSkypeProto::OnMessageSent*/); +} int CSkypeProto::SendUrl(MCONTACT, int, const char*) { return 0; } -- cgit v1.2.3