void GasTank::Close() { GetChat().PostSimpleText(name + " is closed", owner.ret_id()); open_ = false; SetFreq(0); }
void GameManager::ToggleGameMode(gameMode mode) { /*if (mode == MODE_DUEL && mGameMode != MODE_DUEL) EnableDuelMode(); else if (mGameMode == MODE_DUEL && mode != MODE_DUEL) //if we're switching FROM duel DisableDuelMode(); */ mGameMode = mode; Console* c = GetChat(); if (c) { if (mode == MODE_ACTION) { c->mInput->mReadOnly = true; c->mInput->SetText("Hit TAB to toggle chat mode"); //, or ENTER for quick chat"); } else if (c->IsVisible()) //has to be visible for chat mode { c->mInput->mReadOnly = false; c->mInput->Clear(); } } // Reset our speed if (mPlayer->GetSpeed() == SPEED_RUN) mPlayer->SetSpeed(SPEED_WALK); // Send an event MessageData md("GAME_MODE"); md.WriteInt("mode", mode); messenger.Dispatch(md); }
void GasTank::Open() { GetChat().PostSimpleText(name + " is open", owner.ret_id()); open_ = true; SetFreq(1); }
void AtmosTool::AttackBy(id_ptr_on<Item> item) { if (item.ret_id() == GetId()) { if (id_ptr_on<CubeTile> ct = GetOwner()->GetOwner()) { GetChat().PostTextFor(GetInfo(*ct->GetAtmosHolder()), GetOwner()); } } }
void Ghost::processGUImsg(const Message2& msg) { IMob::processGUImsg(msg); QJsonObject obj = Network2::ParseJson(msg); if (msg.type == MessageType::MESSAGE) { std::string text = obj["text"].toString().toStdString(); if (Chat::IsOOCMessage(text)) { GetChat().PostOOCText(name + " (ghost)", text.substr(3)); } } }
void InviteUser(const TCHAR *szChatId) { HMENU tMenu = CreatePopupMenu(); MCONTACT hContact = db_find_first(), hInvitedUser; DBVARIANT dbv; HWND tWindow; POINT pt; gchat_contacts *gc; int j; if (!szChatId || !(gc=GetChat(szChatId))) return; // add the heading AppendMenu(tMenu, MF_STRING|MF_GRAYED|MF_DISABLED, (UINT_PTR)0, TranslateT("&Invite user...")); AppendMenu(tMenu, MF_SEPARATOR, (UINT_PTR)1, NULL); // generate a list of contact while (hContact) { char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, hContact,0 ); if (szProto && !strcmp(SKYPE_PROTONAME, szProto) && !db_get_b(hContact, SKYPE_PROTONAME, "ChatRoom", 0) && db_get_w(hContact, SKYPE_PROTONAME, "Status", ID_STATUS_OFFLINE)!=ID_STATUS_OFFLINE) { BOOL alreadyInSession = FALSE; for (j=0; j<gc->mJoinedCount; j++) { if (gc->mJoinedContacts[j].hContact==hContact) { alreadyInSession = TRUE; break; } } if (!alreadyInSession) AppendMenu(tMenu, MF_STRING, (UINT_PTR)hContact, (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GCDNF_TCHAR)); } hContact = db_find_next(hContact); } tWindow = CreateWindow(_T("EDIT"),_T(""),0,1,1,1,1,NULL,NULL,hInst,NULL); GetCursorPos (&pt); hInvitedUser = (MCONTACT)TrackPopupMenu(tMenu, TPM_NONOTIFY | TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RETURNCMD, pt.x, pt.y, 0, tWindow, NULL); DestroyMenu(tMenu); DestroyWindow(tWindow); if (!hInvitedUser || db_get_s(hInvitedUser, SKYPE_PROTONAME, SKYPE_NAME, &dbv)) return; SkypeSend ("ALTER CHAT "STR" ADDMEMBERS %s", szChatId, dbv.pszVal); db_free(&dbv); }
void GasTank::AttackBy(id_ptr_on<Item> item) { if (id_ptr_on<AtmosTool> at = item) { GetChat().PostTextFor(AtmosTool::GetInfo(atmos_holder_), at->GetOwner()); return; } if (item) { return; } if (open_) { Close(); } else { Open(); } }
static void KickUser (MCONTACT hContact, GCHOOK *gch) { char *ptr; EnterCriticalSection(&m_GCMutex); if (SkypeSend ("ALTER CHAT "STR" KICK "STR, gch->pDest->ptszID, gch->ptszUID)!=-1) { if (ptr=SkypeRcv("ALTER CHAT KICK", 2000)) { if (strncmp(ptr, "ERROR", 5)) { GCDEST gcd = { SKYPE_PROTONAME, gch->pDest->ptszID, GC_EVENT_KICK }; GCEVENT gce = { sizeof(gce), &gcd }; gce.time = (DWORD)time(NULL); gce.dwFlags = GCEF_ADDTOLOG; gce.ptszUID = gch->ptszUID; CONTACTINFO ci = {0}; ci.cbSize = sizeof(ci); ci.szProto = SKYPE_PROTONAME; ci.dwFlag = CNF_DISPLAY | CNF_TCHAR; ci.hContact = hContact; if (hContact && !CallService(MS_CONTACT_GETCONTACTINFO,0,(LPARAM)&ci)) gce.ptszNick=ci.pszVal; else gce.ptszNick=gce.ptszUID; DBVARIANT dbv; if (!db_get_ts(NULL, SKYPE_PROTONAME, "Nick", &dbv)) { gce.ptszStatus = dbv.ptszVal; CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce); RemChatContact (GetChat(gcd.ptszID), gch->ptszUID); db_free(&dbv); } if (ci.pszVal) mir_free (ci.pszVal); } free (ptr); } } LeaveCriticalSection(&m_GCMutex); }
AP_MSG_HANDLER_METHOD(ChatModule, ChatWindow_Close) { ChatWindow* pChat = GetChat(pMsg->hChat); pChat->Close(); pMsg->apStatus = ApMessage::Ok; }
int __cdecl GCMenuHook(WPARAM wParam,LPARAM lParam) { GCMENUITEMS *gcmi= (GCMENUITEMS*) lParam; DBVARIANT dbv; TCHAR* szInvite = TranslateT("&Invite user..."); TCHAR* szLeave = TranslateT("&Leave chat session"); TCHAR* szTopic = TranslateT("Set &Topic..."); TCHAR* szDetails = TranslateT("User &details"); TCHAR* szHistory = TranslateT("User &history"); TCHAR* szKick = TranslateT("&Kick user"); static struct gc_item Item_log[] = { {NULL, 10, MENU_ITEM, FALSE}, {NULL, 30, MENU_ITEM, FALSE}, {NULL, 20, MENU_ITEM, FALSE} }; static struct gc_item Item_nicklist_me[] = { {NULL, 20, MENU_ITEM, FALSE}, {_T(""), 100, MENU_SEPARATOR, FALSE}, {NULL, 110, MENU_ITEM, FALSE} }; static struct gc_item Item_nicklist[] = { {NULL, 10, MENU_ITEM, FALSE}, {NULL, 20, MENU_ITEM, FALSE}, {NULL, 30, MENU_ITEM, FALSE} }; UNREFERENCED_PARAMETER(wParam); Item_log[0].pszDesc = szInvite; Item_log[1].pszDesc = szTopic; Item_log[2].pszDesc = szLeave; Item_nicklist_me[0].pszDesc = szHistory; Item_nicklist_me[2].pszDesc = szLeave; Item_nicklist[0].pszDesc = szDetails; Item_nicklist[1].pszDesc = szHistory; Item_nicklist[2].pszDesc = szKick; LOG (("GCMenuHook started.")); if(gcmi) { if (!_stricmp(gcmi->pszModule, SKYPE_PROTONAME)) { switch (gcmi->Type) { case MENU_ON_LOG: gcmi->nItems = sizeof(Item_log)/sizeof(Item_log[0]); gcmi->Item = &Item_log[0]; LOG (("GCMenuHook: Items in log window: %d", gcmi->nItems)); break; case MENU_ON_NICKLIST: if (db_get_ts(NULL, SKYPE_PROTONAME, SKYPE_NAME, &dbv)) return -1; if (!lstrcmp(dbv.ptszVal, gcmi->pszUID)) { gcmi->nItems = sizeof(Item_nicklist_me)/sizeof(Item_nicklist_me[0]); gcmi->Item = &Item_nicklist_me[0]; } else { gchat_contacts *gcs = GetChat(gcmi->pszID); gchat_contact *gc = gcs?GetChatContact(gcs, gcmi->pszUID):NULL; gcmi->nItems = sizeof(Item_nicklist)/sizeof(Item_nicklist[0]); Item_nicklist[2].bDisabled = FALSE; if (gc && !gc->hContact) { gcmi->nItems -= 2; gcmi->Item = &Item_nicklist[2]; } else gcmi->Item = &Item_nicklist[0]; /* if (protocol<7) Item_nicklist[2].bDisabled = TRUE; else { TCHAR *szChatRole; if (szChatRole = SkypeGetT ("CHAT", gcmi->pszID, "MYROLE")) { if (_tcscmp(szChatRole, _T("MASTER")) && _tcscmp(szChatRole, _T("CREATOR"))) Item_nicklist[2].bDisabled = TRUE; free (szChatRole); } }*/ } db_free(&dbv); break; } } else {LOG (("GCMenuHook: ERROR: Not our protocol."));} } else {LOG (("GCMenuHook: ERROR: No gcmi"));} LOG (("GCMenuHook: terminated.")); return 0; }
int GCEventHook(WPARAM wParam,LPARAM lParam) { GCHOOK *gch = (GCHOOK*) lParam; gchat_contacts *gc = GetChat(gch->pDest->ptszID); UNREFERENCED_PARAMETER(wParam); if(gch) { if (!_stricmp(gch->pDest->pszModule, SKYPE_PROTONAME)) { switch (gch->pDest->iType) { case GC_SESSION_TERMINATE: { MCONTACT hContact; if (gc->mJoinedCount == 1) { // switch back to normal session // I don't know if this behaviour isn't a bit annoying, therefore, we // don't do this now, until a user requests this feature :) // open up srmm dialog when quit while 1 person left // CallService(MS_MSG_SENDMESSAGE, (WPARAM)gc->mJoinedContacts[0].hContact, 0); RemChatContact(gc, gc->mJoinedContacts[0].who); } // Delete Chatroom from Contact list, as we don't need it anymore...? if (hContact = find_chat(gc->szChatName)) CallService(MS_DB_CONTACT_DELETE, hContact, 0); RemChat(gc->szChatName); break; } case GC_USER_MESSAGE: if(gch && gch->ptszText && _tcslen(gch->ptszText) > 0) { DBVARIANT dbv, dbv2; CCSDATA ccs = {0}; TCHAR *pEnd; // remove the ending linebreak for (pEnd = &gch->ptszText[_tcslen(gch->ptszText) - 1]; *pEnd==_T('\r') || *pEnd==_T('\n'); pEnd--) *pEnd=0; // Send message to the chat-contact if (ccs.hContact = find_chat(gch->pDest->ptszID)) { #ifdef _UNICODE // If PREF_UTF is supported, just convert it to UTF8 and pass the buffer to PSS_MESSAGE if (mirandaVersion >= 0x070000) { ccs.lParam = (LPARAM)make_utf8_string(gch->ptszText); ccs.wParam = PREF_UTF; CallProtoService (SKYPE_PROTONAME, PSS_MESSAGE, 0, (LPARAM)&ccs); free ((void*)ccs.lParam); } else { // Otherwise create this strange dual miranda-format ccs.lParam = (LPARAM)calloc(3, _tcslen(gch->ptszText)+1); wcstombs ((char*)ccs.lParam, gch->ptszText, _tcslen(gch->ptszText)+1); _tcscpy ((TCHAR*)((char*)ccs.lParam+strlen((char*)ccs.lParam)+1), gch->ptszText); ccs.wParam = PREF_UNICODE; CallProtoService (SKYPE_PROTONAME, PSS_MESSAGE, 0, (LPARAM)&ccs); free ((void*)ccs.lParam); } #else ccs.lParam = (LPARAM)gch->ptszText; ccs.wParam = PREF_TCHAR; CallProtoService (SKYPE_PROTONAME, PSS_MESSAGE, 0, (LPARAM)&ccs); #endif } // Add our line to the chatlog GCDEST gcd = { gch->pDest->pszModule, gch->pDest->ptszID, 0 }; GCEVENT gce = { sizeof(gce), &gcd }; if ( _tcsncmp(gch->ptszText, _T("/me "), 4)==0 && _tcslen(gch->ptszText)>4) { gce.ptszText = gch->ptszText+4; gcd.iType = GC_EVENT_ACTION; } else { gce.ptszText = gch->ptszText; gcd.iType = GC_EVENT_MESSAGE; } if (db_get_ts(NULL, SKYPE_PROTONAME, "Nick", &dbv)) gce.ptszNick = TranslateT("Me"); else gce.ptszNick = dbv.ptszVal; db_get_ts(NULL, SKYPE_PROTONAME, SKYPE_NAME, &dbv2); gce.ptszUID = dbv2.ptszVal; gce.time = (DWORD)time(NULL); gce.dwFlags = GCEF_ADDTOLOG; gce.bIsMe = TRUE; CallService(MS_GC_EVENT, 0, (LPARAM)&gce); if (dbv.pszVal) db_free(&dbv); if (dbv2.pszVal) db_free(&dbv2); } break; case GC_USER_CHANMGR: InviteUser(gch->pDest->ptszID); break; case GC_USER_PRIVMESS: { MCONTACT hContact = find_contactT(gch->ptszUID); if (hContact) CallService(MS_MSG_SENDMESSAGE, hContact, 0); break; } case GC_USER_LOGMENU: switch(gch->dwData) { case 10: InviteUser(gch->pDest->ptszID); break; case 20: KillChatSession(gch->pDest); break; case 30: { TCHAR *ptr, buf[MAX_BUF]; ptr = SkypeGetT ("CHAT", (TCHAR*)gch->pDest->ptszID, "TOPIC"); _tcscpy(buf, ptr); free(ptr); if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_INPUTBOX), NULL, InputBoxDlgProc, (LPARAM)&buf)) SetChatTopic(gch->pDest->ptszID, buf, TRUE); break; } } break; case GC_USER_NICKLISTMENU: { MCONTACT hContact = find_contactT(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: KickUser(hContact, gch); break; case 110: KillChatSession(gch->pDest); break; } break; } default: break; } } } return 0; }
int __cdecl AddMembers(char *szSkypeMsg) { BYTE *contactmask=NULL; DBVARIANT dbv2; CONTACTINFO ci={0}; char *ptr, *who, *nextoken; TCHAR *szChatId; int i, iRet = 0; gchat_contacts *gc; LOG(("AddMembers STARTED")); if (!(ptr=strstr(szSkypeMsg, " MEMBERS"))) return -1; EnterCriticalSection(&m_GCMutex); ptr[0]=0; szChatId = make_nonutf_tchar_string((const unsigned char*)szSkypeMsg+5); ptr+=9; if (find_chat(szChatId) && (gc=GetChat(szChatId)) && !db_get_s(NULL, SKYPE_PROTONAME, SKYPE_NAME, &dbv2)) { char *pszMemObjs, *token; if (protocol>=7 && (pszMemObjs = SkypeGet ("CHAT", szSkypeMsg+5, "MEMBEROBJECTS"))) { // Add new contacts (protocol 7+ with memberobjects, supports roles) for (token=strtok_r(pszMemObjs, ", ", &nextoken); token; token=strtok_r(NULL, ", ", &nextoken)) { if (!(who = SkypeGet ("CHATMEMBER", token, "IDENTITY"))) continue; if (strcmp(who, dbv2.pszVal)) { char *pszRole; TCHAR *ptszRole = NULL; if (pszRole = SkypeGet ("CHATMEMBER", token, "ROLE")) ptszRole = make_nonutf_tchar_string((const unsigned char*)pszRole); i=AddChatContact(gc, who, ptszRole); free_nonutf_tchar_string (ptszRole); if (pszRole) free (pszRole); if (i>=0 && !contactmask && !(contactmask = (unsigned char*)calloc(gc->mJoinedCount, 1))) i=-2; if (!(contactmask= (unsigned char *) realloc(contactmask, gc->mJoinedCount))) { iRet = -1; free (who); break; } contactmask[i]=TRUE; } free (who); } free (pszMemObjs); } else { // Add new contacts (normal) for (who=strtok_r(ptr, " ", &nextoken); who; who=strtok_r(NULL, " ", &nextoken)) { if (strcmp(who, dbv2.pszVal)) { i=AddChatContact(gc, who, NULL); if (i>=0 && !contactmask && !(contactmask = (unsigned char*)calloc(gc->mJoinedCount, 1))) i=-2; if (i<0 || !(contactmask= (unsigned char *) realloc(contactmask, gc->mJoinedCount))) { iRet = -1; break; } contactmask[i]=TRUE; } } } // Quit contacts which are no longer there if (iRet == 0 && contactmask) { GCDEST gcd = { SKYPE_PROTONAME, szChatId, GC_EVENT_QUIT }; GCEVENT gce = { sizeof(gce), &gcd }; gce.time = (DWORD)time(NULL); gce.dwFlags = GCEF_ADDTOLOG; ci.cbSize = sizeof(ci); ci.szProto = SKYPE_PROTONAME; ci.dwFlag = CNF_DISPLAY; for (i=0;i<gc->mJoinedCount;i++) if (!contactmask[i]) { ci.hContact = gc->mJoinedContacts[i].hContact; ci.dwFlag = CNF_TCHAR; if (ci.hContact && !CallService(MS_CONTACT_GETCONTACTINFO,0,(LPARAM)&ci)) gce.ptszNick=ci.pszVal; else gce.ptszNick=gc->mJoinedContacts[i].who; RemChatContact(gc, gc->mJoinedContacts[i].who); gce.ptszUID = gc->mJoinedContacts[i].who; CallService(MS_GC_EVENT, 0, (LPARAM)&gce); if (ci.pszVal) { mir_free (ci.pszVal); ci.pszVal=NULL; } } // We don't do this, because the dialog group-chat may have been started intentionally /* if (gc->mJoinedCount == 1) { // switch back to normal session KillChatSession(&gcd); } */ } if (contactmask) free(contactmask); db_free(&dbv2); } else iRet = -1; free_nonutf_tchar_string (szChatId); LeaveCriticalSection(&m_GCMutex); LOG(("AddMembers DONE")); return iRet; }