int CVkProto::OnChatEvent(WPARAM, LPARAM lParam) { GCHOOK *gch = (GCHOOK*)lParam; if (gch == NULL) return 0; if (lstrcmpiA(gch->pDest->pszModule, m_szModuleName)) return 0; CVkChatInfo *cc = GetChatById(gch->pDest->ptszID); if (cc == NULL) return 0; switch (gch->pDest->iType) { case GC_USER_MESSAGE: if (m_bOnline && lstrlen(gch->ptszText) > 0) { TCHAR *buf = NEWTSTR_ALLOCA(gch->ptszText); rtrimt(buf); UnEscapeChatTags(buf); Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/messages.send.json", true, &CVkProto::OnSendChatMsg) << INT_PARAM("type", 1) << INT_PARAM("chat_id", cc->m_chatid) << TCHAR_PARAM("message", buf)); } case GC_USER_LOGMENU: LogMenuHook(cc, gch); break; case GC_USER_NICKLISTMENU: NickMenuHook(cc, gch); break; } return 0; }
int JabberGcEventHook(WPARAM wParam,LPARAM lParam) { GCHOOK* gch = ( GCHOOK* )lParam; if ( gch == NULL ) return 0; if ( lstrcmpiA( gch->pDest->pszModule, jabberProtoName )) return 0; JABBER_LIST_ITEM* item = JabberListGetItemPtr( LIST_CHATROOM, gch->pDest->ptszID ); if ( item == NULL ) return 0; switch ( gch->pDest->iType ) { case GC_USER_MESSAGE: if ( gch->pszText && lstrlen( gch->ptszText) > 0 ) { rtrim( gch->ptszText ); if ( jabberOnline ) { XmlNode m( "message" ); m.addAttr( "to", item->jid ); m.addAttr( "type", "groupchat" ); XmlNode* b = m.addChild( "body", gch->ptszText ); if ( b->sendText != NULL ) UnEscapeChatTags( b->sendText ); JabberSend( jabberThreadInfo->s, m ); } } break; case GC_USER_PRIVMESS: sttSendPrivateMessage( item, gch->ptszUID ); break; case GC_USER_LOGMENU: sttLogListHook( item, gch ); break; case GC_USER_NICKLISTMENU: sttNickListHook( item, gch ); break; case GC_USER_CHANMGR: int iqId = JabberSerialNext(); JabberIqAdd( iqId, IQ_PROC_NONE, JabberIqResultGetMuc ); XmlNodeIq iq( "get", iqId, item->jid ); XmlNode* query = iq.addQuery( xmlnsOwner ); JabberSend( jabberThreadInfo->s, iq ); break; } return 0; }
int CMsnProto::MSN_GCEventHook(WPARAM, LPARAM lParam) { GCHOOK *gch = (GCHOOK*)lParam; if (!gch) return 1; if (_stricmp(gch->pDest->pszModule, m_szModuleName)) return 0; switch (gch->pDest->iType) { case GC_SESSION_TERMINATE: { GCThreadData* thread = MSN_GetThreadByChatId(gch->pDest->ptszID); if (thread != NULL) { m_arGCThreads.remove(thread); for (int i = 0; i < thread->mJoinedContacts.getCount(); i++) delete thread->mJoinedContacts[i]; delete thread; } } break; case GC_USER_MESSAGE: if (gch->ptszText && gch->ptszText[0]) { GCThreadData* thread = MSN_GetThreadByChatId(gch->pDest->ptszID); if (thread) { TCHAR* pszMsg = UnEscapeChatTags(NEWTSTR_ALLOCA(gch->ptszText)); rtrimt(pszMsg); // remove the ending linebreak msnNsThread->sendMessage('N', thread->szEmail, thread->netId, UTF8(pszMsg), 0); DBVARIANT dbv; int bError = getTString("Nick", &dbv); GCDEST gcd = { m_szModuleName, gch->pDest->ptszID, GC_EVENT_MESSAGE }; GCEVENT gce = { sizeof(gce), &gcd }; gce.dwFlags = GCEF_ADDTOLOG; gce.ptszNick = bError ? _T("") : dbv.ptszVal; gce.ptszUID = mir_a2t(MyOptions.szEmail); gce.time = time(NULL); gce.ptszText = gch->ptszText; gce.bIsMe = TRUE; CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce); mir_free((void*)gce.ptszUID); if (!bError) db_free(&dbv); } } break; case GC_USER_CHANMGR: DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_CHATROOM_INVITE), NULL, DlgInviteToChat, LPARAM(new InviteChatParam(gch->pDest->ptszID, NULL, this))); break; case GC_USER_PRIVMESS: { char *email = mir_t2a(gch->ptszUID); MCONTACT hContact = MSN_HContactFromEmail(email); CallService(MS_MSG_SENDMESSAGE, hContact, 0); mir_free(email); } break; case GC_USER_LOGMENU: switch (gch->dwData) { case 10: DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_CHATROOM_INVITE), NULL, DlgInviteToChat, LPARAM(new InviteChatParam(gch->pDest->ptszID, NULL, this))); break; case 20: MSN_KillChatSession(gch->pDest->ptszID); break; } break; case GC_USER_NICKLISTMENU: MCONTACT hContact = MSN_HContactFromEmail(_T2A(gch->ptszUID)); switch (gch->dwData) { case 10: CallService(MS_USERINFO_SHOWDIALOG, hContact, 0); break; case 20: CallService(MS_HISTORY_SHOWCONTACTHISTORY, hContact, 0); break; case 30: MSN_Kickuser(gch); break; case 110: MSN_KillChatSession(gch->pDest->ptszID); break; case 40: const TCHAR *pszRole = MSN_GCGetRole(MSN_GetThreadByChatId(gch->pDest->ptszID), _T2A(gch->ptszUID)); MSN_Promoteuser(gch, (pszRole && !mir_tstrcmp(pszRole, _T("admin"))) ? "user" : "admin"); break; } break; } return 0; }
int CMsnProto::MSN_GCEventHook(WPARAM, LPARAM lParam) { GCHOOK *gch = (GCHOOK*) lParam; if (!gch) return 1; if (_stricmp(gch->pDest->pszModule, m_szModuleName)) return 0; switch (gch->pDest->iType) { case GC_SESSION_TERMINATE: { ThreadData* thread = MSN_GetThreadByChatId(gch->pDest->ptszID); if (thread != NULL) thread->sendTerminate(); break; } case GC_USER_MESSAGE: if (gch->ptszText && gch->ptszText[0]) { ThreadData* thread = MSN_GetThreadByChatId(gch->pDest->ptszID); if (thread) { rtrim(gch->ptszText); // remove the ending linebreak TCHAR* pszMsg = UnEscapeChatTags(NEWTSTR_ALLOCA(gch->ptszText)); thread->sendMessage('N', NULL, NETID_MSN, UTF8(pszMsg), 0); DBVARIANT dbv; int bError = getTString("Nick", &dbv); GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_MESSAGE }; gcd.ptszID = gch->pDest->ptszID; GCEVENT gce = {0}; gce.cbSize = sizeof(GCEVENT); gce.dwFlags = GC_TCHAR | GCEF_ADDTOLOG; gce.pDest = &gcd; gce.ptszNick = bError ? _T("") : dbv.ptszVal; gce.ptszUID = mir_a2t(MyOptions.szEmail); gce.time = time(NULL); gce.ptszText = gch->ptszText; gce.bIsMe = TRUE; CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce); mir_free((void*)gce.ptszUID); if (!bError) MSN_FreeVariant(&dbv); } } break; case GC_USER_CHANMGR: DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_CHATROOM_INVITE), NULL, DlgInviteToChat, LPARAM(new InviteChatParam(gch->pDest->ptszID, NULL, this))); break; case GC_USER_PRIVMESS: { char *email = mir_t2a(gch->ptszUID); HANDLE hContact = MSN_HContactFromEmail(email); MSN_CallService(MS_MSG_SENDMESSAGE, (WPARAM)hContact, 0); mir_free(email); break; } case GC_USER_LOGMENU: switch(gch->dwData) { case 10: DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_CHATROOM_INVITE), NULL, DlgInviteToChat, LPARAM(new InviteChatParam(gch->pDest->ptszID, NULL, this))); break; case 20: MSN_KillChatSession(gch->pDest->ptszID); break; } break; case GC_USER_NICKLISTMENU: { char *email = mir_t2a(gch->ptszUID); HANDLE hContact = MSN_HContactFromEmail(email); mir_free(email); switch(gch->dwData) { case 10: MSN_CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)hContact, 0); break; case 20: MSN_CallService(MS_HISTORY_SHOWCONTACTHISTORY, (WPARAM)hContact, 0); break; case 110: MSN_KillChatSession(gch->pDest->ptszID); break; } break; } /* haven't implemented in chat.dll case GC_USER_TYPNOTIFY: { int chatID = atoi(p); ThreadData* thread = MSN_GetThreadByContact((HANDLE)-chatID); for (int j=0; j < thread->mJoinedCount; j++) { if ((long)thread->mJoinedContacts[j] > 0) CallService(MS_PROTO_SELFISTYPING, (WPARAM) thread->mJoinedContacts[j], (LPARAM) PROTOTYPE_SELFTYPING_ON); } break; } */ } return 0; }