diff options
author | Fishbone <fishbone@miranda-ng.org> | 2013-06-02 16:19:21 +0000 |
---|---|---|
committer | Fishbone <fishbone@miranda-ng.org> | 2013-06-02 16:19:21 +0000 |
commit | ab7e0b08fa8c31cf1d468ab4b3c660e2b1836811 (patch) | |
tree | 52977603ea0f431adff16573d3d5b46a95843c7f /protocols/WhatsApp/src/chat.cpp | |
parent | 8320783f99419db1e40346fdb292c19ee008948b (diff) |
Added WhatsApp-protocol
git-svn-id: http://svn.miranda-ng.org/main/trunk@4861 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/WhatsApp/src/chat.cpp')
-rw-r--r-- | protocols/WhatsApp/src/chat.cpp | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/protocols/WhatsApp/src/chat.cpp b/protocols/WhatsApp/src/chat.cpp new file mode 100644 index 0000000000..a53a5077ca --- /dev/null +++ b/protocols/WhatsApp/src/chat.cpp @@ -0,0 +1,77 @@ +#include "common.h"
+
+// #TODO Remove, as we are not using the chat-module for groups anymore
+
+int WhatsAppProto::OnJoinChat(WPARAM,LPARAM)
+{
+ return 0;
+}
+
+int WhatsAppProto::OnLeaveChat(WPARAM,LPARAM)
+{
+ return 0;
+}
+
+int WhatsAppProto::OnChatOutgoing(WPARAM wParam, LPARAM lParam)
+{
+ GCHOOK *hook = reinterpret_cast<GCHOOK*>(lParam);
+ char *text;
+ char *id;
+
+ if (strcmp(hook->pDest->pszModule,m_szModuleName))
+ return 0;
+
+ switch(hook->pDest->iType)
+ {
+ case GC_USER_MESSAGE:
+ {
+ text = mir_t2a_cp(hook->ptszText,CP_UTF8);
+ std::string msg = text;
+
+ id = mir_t2a_cp(hook->pDest->ptszID,CP_UTF8);
+ std::string chat_id = id;
+
+ mir_free(text);
+ mir_free(id);
+
+ if (isOnline()) {
+ HANDLE hContact = this->ContactIDToHContact(chat_id);
+ if (hContact)
+ {
+ LOG("**Chat - Outgoing message: %s", text);
+ this->SendMsg(hContact, IS_CHAT, msg.c_str());
+
+ // #TODO Move to SendMsgWorker, otherwise all messages are "acknowledged" by Miranda
+
+ GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_MESSAGE };
+ gcd.ptszID = hook->pDest->ptszID;
+
+ GCEVENT gce = {0};
+ gce.cbSize = sizeof(GCEVENT);
+ gce.dwFlags = GC_TCHAR | GCEF_ADDTOLOG;
+ gce.pDest = &gcd;
+ gce.ptszNick = mir_a2t(this->nick.c_str());
+ gce.ptszUID = mir_a2t(this->jid.c_str());
+ gce.time = time(NULL);
+ gce.ptszText = hook->ptszText;
+ gce.bIsMe = TRUE;
+ CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
+
+ mir_free((void*)gce.ptszUID);
+ mir_free((void*)gce.ptszNick);
+ }
+ }
+
+ break;
+ }
+
+ case GC_USER_LEAVE:
+ case GC_SESSION_TERMINATE:
+ {
+ break;
+ }
+ }
+
+ return 0;
+}
+
|