void COpenGLDemo::HandleEvents() { SDL_Event ev; while ( SDL_PollEvent( &ev )) { switch( ev.type ) { case SDL_QUIT: OnQuit( ev.quit ); break; case SDL_KEYDOWN: OnKeyDown( ev.key ); break; case SDL_KEYUP: OnKeyUp( ev.key ); break; case SDL_MOUSEMOTION: OnMouseMotion( ev.motion ); break; case SDL_MOUSEBUTTONUP: OnMouseRelease( ev.button ); break; case SDL_MOUSEBUTTONDOWN: OnMousePress( ev.button ); break; } } }
int BaseApp::InternalCleanup() { try { InternalOnQuit(); if(!_internal_quitted) throw Exception("InternalOnQuit() was not called on BaseApp!"); OnQuit(); SaveCfg(); } catch(const std::exception & e) { InternalOnForceQuit(); if(!_internal_force_quitted) Log::Error("InternalOnForceQuit() was not called on BaseApp!"); Log::Error("Exception: {}", e.what()); OnForceQuit(); system("pause"); return EXIT_FAILURE; } return EXIT_SUCCESS; }
virtual void OnKeyDown(int nKey, int nMod) { switch(nKey) { case SDLK_ESCAPE: OnQuit(); break; case SDLK_MINUS: case SDLK_KP_MINUS: if(m_fExposure > 0.1f) m_fExposure -= 0.1f; break; case SDLK_PLUS: case SDLK_KP_PLUS: if(m_fExposure < 10.0f) m_fExposure += 0.1f; break; case SDLK_p: m_nPolygonMode = (m_nPolygonMode == GL_FILL) ? GL_LINE : GL_FILL; break; case SDLK_h: m_bHDR = !m_bHDR; break; } }
void wxHtmlHelpController::OnCloseFrame(wxCloseEvent& evt) { evt.Skip(); OnQuit(); m_helpFrame->SetController((wxHelpControllerBase*) NULL); m_helpFrame = NULL; }
void wxHtmlHelpControllerEx::OnCloseFrame(wxCloseEvent& evt) { evt.Skip(); OnQuit(); m_helpWindow->SetController(NULL); m_helpWindow = NULL; }
virtual void OnKeyDown(int nKey, int nMod) { switch(nKey) { case SDLK_ESCAPE: OnQuit(); break; case SDLK_p: m_nPolygonMode = (m_nPolygonMode == GL_FILL) ? GL_LINE : GL_FILL; break; } }
//---------------------------------------------------------------------------- void medLogicWithManagers::HandleException() //---------------------------------------------------------------------------- { int answare = wxMessageBox(_("Do you want to try to save the unsaved work ?"), _("Fatal Exception!!"), wxYES_NO|wxCENTER); if(answare == wxYES) { OnFileSaveAs(); if (m_OpManager->Running()) m_OpManager->StopCurrentOperation(); } OnQuit(); }
void wxHtmlHelpController::OnCloseFrame(wxCloseEvent& evt) { if (m_Config) WriteCustomization(m_Config, m_ConfigRoot); evt.Skip(); OnQuit(); if ( m_helpWindow ) m_helpWindow->SetController(NULL); m_helpWindow = NULL; m_helpDialog = NULL; m_helpFrame = NULL; }
MainWindow::MainWindow(Backend *backend) :m_backend(backend) { QAction *new_regtab_act = new QAction(QIcon::fromTheme("document-new"), tr("Register &Tab"), this); QAction *new_regedit_act = new QAction(QIcon::fromTheme("document-edit"), tr("Register &Editor"), this); QAction *load_desc_act = new QAction(QIcon::fromTheme("document-open"), tr("&Soc Description"), this); QAction *quit_act = new QAction(QIcon::fromTheme("application-exit"), tr("&Quit"), this); QAction *about_act = new QAction(QIcon::fromTheme("help-about"), tr("&About"), this); QAction *about_qt_act = new QAction(QIcon::fromTheme("help-about"), tr("About &Qt"), this); connect(new_regtab_act, SIGNAL(triggered()), this, SLOT(OnNewRegTab())); connect(new_regedit_act, SIGNAL(triggered()), this, SLOT(OnNewRegEdit())); connect(load_desc_act, SIGNAL(triggered()), this, SLOT(OnLoadDesc())); connect(quit_act, SIGNAL(triggered()), this, SLOT(OnQuit())); connect(about_act, SIGNAL(triggered()), this, SLOT(OnAbout())); connect(about_qt_act, SIGNAL(triggered()), this, SLOT(OnAboutQt())); QMenu *file_menu = menuBar()->addMenu(tr("&File")); QMenu *new_submenu = file_menu->addMenu(QIcon::fromTheme("document-new"), "&New"); QMenu *load_submenu = file_menu->addMenu(QIcon::fromTheme("document-open"), "&Load"); file_menu->addAction(quit_act); new_submenu->addAction(new_regtab_act); new_submenu->addAction(new_regedit_act); load_submenu->addAction(load_desc_act); QMenu *about_menu = menuBar()->addMenu(tr("&About")); about_menu->addAction(about_act); about_menu->addAction(about_qt_act); m_tab = new MyTabWidget(); setCentralWidget(m_tab); ReadSettings(); OnNewRegTab(); }
void EventHandler::HandleEvent(const SDL_Event& event) { switch (event.type) { case SDL_QUIT: OnQuit(); break; case SDL_KEYUP: case SDL_KEYDOWN: OnKeyboardEvent(event.key); break; case SDL_MOUSEMOTION: OnMouseMotionEvent(event.motion); break; case SDL_JOYAXISMOTION: OnJoystickAxisEvent(event.jaxis); break; } }
Logino::Logino(QWidget* parent) : QDialog(parent) { setFixedSize(300, 120); setWindowTitle("Form Login"); setModal(true); setAttribute(Qt::WA_DeleteOnClose); userLabel = new QLabel("Username:"******"Password:"******"Login"); quitButton = new QPushButton("Quit"); QVBoxLayout* vbox = new QVBoxLayout(this); QHBoxLayout* hbox1 = new QHBoxLayout(); QHBoxLayout* hbox2 = new QHBoxLayout(); QHBoxLayout* hbox3 = new QHBoxLayout(); hbox1->addWidget(userLabel, 1); hbox1->addWidget(userLineEdit, 2); hbox2->addWidget(passLabel, 1); hbox2->addWidget(passLineEdit, 2); hbox3->addWidget(loginButton, 1, Qt::AlignCenter); hbox3->addWidget(quitButton, 0, Qt::AlignCenter); vbox->addSpacing(1); vbox->addLayout(hbox1); vbox->addLayout(hbox2); vbox->addLayout(hbox3); connect(quitButton, SIGNAL(clicked()), this, SLOT(OnQuit())); connect(loginButton, SIGNAL(clicked()), this, SLOT(OnLogin())); }
int AngelFight::handle_data( sprite_t* p, int cmd, const uint8_t body[], int len ) { Player* player = GetPlayer( p ); if( !player ) { return GER_game_system_err; } if( cmd == proto_player_leave ) { return OnQuit( player, NULL, 0 ); } if( m_nGameState != GS_WAIT_CLIENT ) { DEBUG_LOG( "[%d] System Busy", p->id ); return send_to_player_err( p, p->waitcmd, -AFE_SYSTEM_BUSY ); } //invalid cmd if( cmd != AFP_CMD_HEAD ) { DEBUG_LOG( "[%d] Invalid Cmd;[%d]", p->id, cmd ); return send_to_player_err( p, p->waitcmd, -AFE_INVALID_CMD ); } //invalid data length if( len < 0 ) { DEBUG_LOG( "[%d] Invalid Cmd Len:[%d]", p->id, len ); return GER_invalid_data; } int cmd2; int expectLen = sizeof(cmd2); CHECK_BODY_LEN_GE( len, expectLen ); int j = 0; ant::unpack( body, cmd2, j ); if( !(player->GetValidCmd() & cmd2) ) { DEBUG_LOG( "[%d] Invalid Child Cmd:[%d] And The Valid Cmd is:[%d]", p->id, cmd2, player->GetValidCmd() ); return send_to_player_err( p, p->waitcmd, -AFE_INVALID_OPERATE ); } // DEBUG_LOG( "[%d] Child Cmd:[%d]", p->id, cmd2 ); const uint8_t* realBody = body + expectLen; int realLen = len - expectLen; switch( cmd2 ) { case AFC_ACTION: { return OnAction( player, realBody, realLen ); } case AFC_SELECT_MONSTER: { return OnSelectMonster( player, realBody, realLen ); } case AFC_QUIT: { return OnQuit( player, realBody, realLen ); } case AFC_DATA_OK: { return OnLoadDataOK( player, realBody, realLen ); } case AFC_ANI_OK: { return OnAniOK( player, realBody, realLen ); } case AFC_QUICK_GAME: { return OnQuickGame( player, realBody, realLen ); } default: return send_to_player_err( p, p->waitcmd, -AFE_INVALID_OPERATE ); } }
BOOL CDCNeighbour::OnPacket(CDCPacket* pPacket) { pPacket->SmartDump( &m_pHost, FALSE, FALSE, (DWORD_PTR)this ); m_nInputCount++; m_tLastPacket = GetTickCount(); if ( pPacket->m_nLength < 2 ) { return OnPing(); } else if ( *pPacket->m_pBuffer == '<' ) { return OnChat( pPacket ); } else if ( *pPacket->m_pBuffer != '$' ) { return OnUnknown( pPacket ); } if ( pPacket->Compare( _P("$Search ") ) ) { return OnQuery( pPacket ); } else if ( pPacket->Compare( _P("$To: ") ) ) { return OnChatPrivate( pPacket ); } else if ( pPacket->Compare( _P("$HubTopic ") ) ) { return OnHubTopic( pPacket ); } else if ( pPacket->Compare( _P("$HubName" ) ) ) { return OnHubName( pPacket ); } // Convert '|' to '\0' (make ASCIIZ) pPacket->m_pBuffer[ pPacket->m_nLength - 1 ] = 0; LPCSTR szCommand = (LPCSTR)pPacket->m_pBuffer; // Split off parameters LPSTR szParams = strchr( (LPSTR)pPacket->m_pBuffer, ' ' ); if ( szParams ) { *szParams++ = 0; } if ( strcmp( szCommand, "$MyINFO" ) == 0 ) { return OnUserInfo( szParams ); } else if ( strcmp( szCommand, "$Quit" ) == 0 ) { return OnQuit( szParams ); } else if ( strcmp( szCommand, "$Lock" ) == 0 ) { return OnLock( szParams ); } else if ( strcmp( szCommand, "$Supports" ) == 0 ) { return OnSupports( szParams ); } else if ( strcmp( szCommand, "$Hello" ) == 0 ) { return OnHello( szParams ); } else if ( strcmp( szCommand, "$OpList" ) == 0 ) { return OnOpList( szParams ); } else if ( strcmp( szCommand, "$ConnectToMe" ) == 0 ) { return OnConnectToMe( szParams ); } else if ( strcmp( szCommand, "$ForceMove " ) == 0 ) { return OnForceMove( szParams ); } else if ( strcmp( szCommand, "$ValidateDenide" ) == 0 ) { return OnValidateDenide(); } else if ( strcmp( szCommand, "$GetPass" ) == 0 ) { return OnGetPass(); } else if ( strcmp( szCommand, "$UserIP" ) == 0 ) { return OnUserIP( szParams ); } else if ( strcmp( szCommand, "$ZOn" ) == 0 ) { return OnZOn(); } else if ( strcmp( szCommand, "$RevConnectToMe" ) == 0 ) { return OnRevConnectToMe( szParams ); } return OnUnknown( pPacket ); }
void CIRCSock::ReadLine(const CString& sData) { CString sLine = sData; sLine.TrimRight("\n\r"); DEBUG("(" << m_pNetwork->GetUser()->GetUserName() << "/" << m_pNetwork->GetName() << ") IRC -> ZNC [" << sLine << "]"); NETWORKMODULECALL(OnRaw(sLine), m_pNetwork->GetUser(), m_pNetwork, NULL, return); if (sLine.Equals("PING ", false, 5)) { // Generate a reply and don't forward this to any user, // we don't want any PING forwarded PutIRC("PONG " + sLine.substr(5)); return; } else if (sLine.Token(1).Equals("PONG")) { // Block PONGs, we already responded to the pings return; } else if (sLine.Equals("ERROR ", false, 6)) { //ERROR :Closing Link: nick[24.24.24.24] (Excess Flood) CString sError(sLine.substr(6)); sError.TrimPrefix(); m_pNetwork->PutStatus("Error from Server [" + sError + "]"); return; } CString sCmd = sLine.Token(1); if ((sCmd.length() == 3) && (isdigit(sCmd[0])) && (isdigit(sCmd[1])) && (isdigit(sCmd[2]))) { CString sServer = sLine.Token(0).LeftChomp_n(); unsigned int uRaw = sCmd.ToUInt(); CString sNick = sLine.Token(2); CString sRest = sLine.Token(3, true); switch (uRaw) { case 1: { // :irc.server.com 001 nick :Welcome to the Internet Relay Network nick if (m_bAuthed && sServer == "irc.znc.in") { // m_bAuthed == true => we already received another 001 => we might be in a traffic loop m_pNetwork->PutStatus("ZNC seems to be connected to itself, disconnecting..."); Quit(); return; } m_pNetwork->SetIRCServer(sServer); SetTimeout(540, TMO_READ); // Now that we are connected, let nature take its course PutIRC("WHO " + sNick); m_bAuthed = true; m_pNetwork->PutStatus("Connected!"); vector<CClient*>& vClients = m_pNetwork->GetClients(); for (unsigned int a = 0; a < vClients.size(); a++) { CClient* pClient = vClients[a]; CString sClientNick = pClient->GetNick(false); if (!sClientNick.Equals(sNick)) { // If they connected with a nick that doesn't match the one we got on irc, then we need to update them pClient->PutClient(":" + sClientNick + "!" + m_Nick.GetIdent() + "@" + m_Nick.GetHost() + " NICK :" + sNick); } } SetNick(sNick); NETWORKMODULECALL(OnIRCConnected(), m_pNetwork->GetUser(), m_pNetwork, NULL, NOTHING); m_pNetwork->ClearRawBuffer(); m_pNetwork->AddRawBuffer(":" + sServer + " " + sCmd + " ", " " + sRest); break; } case 5: ParseISupport(sRest); m_pNetwork->UpdateExactRawBuffer(":" + sServer + " " + sCmd + " ", " " + sRest); break; case 10: { // :irc.server.com 010 nick <hostname> <port> :<info> CString sHost = sRest.Token(0); CString sPort = sRest.Token(1); CString sInfo = sRest.Token(2, true).TrimPrefix_n(); m_pNetwork->PutStatus("Server [" + m_pNetwork->GetCurrentServer()->GetString(false) + "] redirects us to [" + sHost + ":" + sPort + "] with reason [" + sInfo + "]"); m_pNetwork->PutStatus("Perhaps you want to add it as a new server."); // Don't send server redirects to the client return; } case 2: case 3: case 4: case 250: // highest connection count case 251: // user count case 252: // oper count case 254: // channel count case 255: // client count case 265: // local users case 266: // global users m_pNetwork->UpdateRawBuffer(":" + sServer + " " + sCmd + " ", " " + sRest); break; case 305: m_pNetwork->SetIRCAway(false); break; case 306: m_pNetwork->SetIRCAway(true); break; case 324: { // MODE sRest.Trim(); CChan* pChan = m_pNetwork->FindChan(sRest.Token(0)); if (pChan) { pChan->SetModes(sRest.Token(1, true)); // We don't SetModeKnown(true) here, // because a 329 will follow if (!pChan->IsModeKnown()) { // When we JOIN, we send a MODE // request. This makes sure the // reply isn't forwarded. return; } } } break; case 329: { sRest.Trim(); CChan* pChan = m_pNetwork->FindChan(sRest.Token(0)); if (pChan) { unsigned long ulDate = sLine.Token(4).ToULong(); pChan->SetCreationDate(ulDate); if (!pChan->IsModeKnown()) { pChan->SetModeKnown(true); // When we JOIN, we send a MODE // request. This makes sure the // reply isn't forwarded. return; } } } break; case 331: { // :irc.server.com 331 yournick #chan :No topic is set. CChan* pChan = m_pNetwork->FindChan(sLine.Token(3)); if (pChan) { pChan->SetTopic(""); } break; } case 332: { // :irc.server.com 332 yournick #chan :This is a topic CChan* pChan = m_pNetwork->FindChan(sLine.Token(3)); if (pChan) { CString sTopic = sLine.Token(4, true); sTopic.LeftChomp(); pChan->SetTopic(sTopic); } break; } case 333: { // :irc.server.com 333 yournick #chan setternick 1112320796 CChan* pChan = m_pNetwork->FindChan(sLine.Token(3)); if (pChan) { sNick = sLine.Token(4); unsigned long ulDate = sLine.Token(5).ToULong(); pChan->SetTopicOwner(sNick); pChan->SetTopicDate(ulDate); } break; } case 352: { // :irc.yourserver.com 352 yournick #chan ident theirhost.com irc.theirserver.com theirnick H :0 Real Name sServer = sLine.Token(0); sNick = sLine.Token(7); CString sIdent = sLine.Token(4); CString sHost = sLine.Token(5); sServer.LeftChomp(); if (sNick.Equals(GetNick())) { m_Nick.SetIdent(sIdent); m_Nick.SetHost(sHost); } m_pNetwork->SetIRCNick(m_Nick); m_pNetwork->SetIRCServer(sServer); const vector<CChan*>& vChans = m_pNetwork->GetChans(); for (unsigned int a = 0; a < vChans.size(); a++) { vChans[a]->OnWho(sNick, sIdent, sHost); } break; } case 353: { // NAMES sRest.Trim(); // Todo: allow for non @+= server msgs CChan* pChan = m_pNetwork->FindChan(sRest.Token(1)); // If we don't know that channel, some client might have // requested a /names for it and we really should forward this. if (pChan) { CString sNicks = sRest.Token(2, true).TrimPrefix_n(); pChan->AddNicks(sNicks); } ForwardRaw353(sLine); // We forwarded it already, so return return; } case 366: { // end of names list m_pNetwork->PutUser(sLine); // First send them the raw // :irc.server.com 366 nick #chan :End of /NAMES list. CChan* pChan = m_pNetwork->FindChan(sRest.Token(0)); if (pChan) { if (pChan->IsOn()) { // If we are the only one in the chan, set our default modes if (pChan->GetNickCount() == 1) { CString sModes = pChan->GetDefaultModes(); if (sModes.empty()) { sModes = m_pNetwork->GetUser()->GetDefaultChanModes(); } if (!sModes.empty()) { PutIRC("MODE " + pChan->GetName() + " " + sModes); } } } } return; // return so we don't send them the raw twice } case 375: // begin motd case 422: // MOTD File is missing m_pNetwork->ClearMotdBuffer(); case 372: // motd case 376: // end motd m_pNetwork->AddMotdBuffer(":" + sServer + " " + sCmd + " ", " " + sRest); break; case 437: // :irc.server.net 437 * badnick :Nick/channel is temporarily unavailable // :irc.server.net 437 mynick badnick :Nick/channel is temporarily unavailable // :irc.server.net 437 mynick badnick :Cannot change nickname while banned on channel if (m_pNetwork->IsChan(sRest.Token(0)) || sNick != "*") break; case 432: // :irc.server.com 432 * nick :Erroneous Nickname: Illegal characters case 433: { CString sBadNick = sRest.Token(0); if (!m_bAuthed) { SendAltNick(sBadNick); return; } break; } case 451: // :irc.server.com 451 CAP :You have not registered // Servers that dont support CAP will give us this error, dont send it to the client if (sNick.Equals("CAP")) return; case 470: { // :irc.unreal.net 470 mynick [Link] #chan1 has become full, so you are automatically being transferred to the linked channel #chan2 // :mccaffrey.freenode.net 470 mynick #electronics ##electronics :Forwarding to another channel // freenode style numeric CChan* pChan = m_pNetwork->FindChan(sRest.Token(0)); if (!pChan) { // unreal style numeric pChan = m_pNetwork->FindChan(sRest.Token(1)); } if (pChan) { pChan->Disable(); m_pNetwork->PutStatus("Channel [" + pChan->GetName() + "] is linked to " "another channel and was thus disabled."); } break; } } } else { CNick Nick(sLine.Token(0).TrimPrefix_n()); sCmd = sLine.Token(1); CString sRest = sLine.Token(2, true); if (sCmd.Equals("NICK")) { CString sNewNick = sRest.TrimPrefix_n(); bool bIsVisible = false; vector<CChan*> vFoundChans; const vector<CChan*>& vChans = m_pNetwork->GetChans(); for (unsigned int a = 0; a < vChans.size(); a++) { CChan* pChan = vChans[a]; if (pChan->ChangeNick(Nick.GetNick(), sNewNick)) { vFoundChans.push_back(pChan); if (!pChan->IsDetached()) { bIsVisible = true; } } } // Todo: use nick compare function here if (Nick.GetNick().Equals(GetNick())) { // We are changing our own nick, the clients always must see this! bIsVisible = true; SetNick(sNewNick); } NETWORKMODULECALL(OnNick(Nick, sNewNick, vFoundChans), m_pNetwork->GetUser(), m_pNetwork, NULL, NOTHING); if (!bIsVisible) { return; } } else if (sCmd.Equals("QUIT")) { CString sMessage = sRest.TrimPrefix_n(); bool bIsVisible = false; // :[email protected] QUIT :message if (Nick.GetNick().Equals(GetNick())) { m_pNetwork->PutStatus("You quit [" + sMessage + "]"); // We don't call module hooks and we don't // forward this quit to clients (Some clients // disconnect if they receive such a QUIT) return; } vector<CChan*> vFoundChans; const vector<CChan*>& vChans = m_pNetwork->GetChans(); for (unsigned int a = 0; a < vChans.size(); a++) { CChan* pChan = vChans[a]; if (pChan->RemNick(Nick.GetNick())) { vFoundChans.push_back(pChan); if (!pChan->IsDetached()) { bIsVisible = true; } } } NETWORKMODULECALL(OnQuit(Nick, sMessage, vFoundChans), m_pNetwork->GetUser(), m_pNetwork, NULL, NOTHING); if (!bIsVisible) { return; } } else if (sCmd.Equals("JOIN")) { CString sChan = sRest.Token(0).TrimPrefix_n(); CChan* pChan; // Todo: use nick compare function if (Nick.GetNick().Equals(GetNick())) { m_pNetwork->AddChan(sChan, false); pChan = m_pNetwork->FindChan(sChan); if (pChan) { pChan->ResetJoinTries(); pChan->Enable(); pChan->SetIsOn(true); PutIRC("MODE " + sChan); } } else { pChan = m_pNetwork->FindChan(sChan); } if (pChan) { pChan->AddNick(Nick.GetNickMask()); NETWORKMODULECALL(OnJoin(Nick.GetNickMask(), *pChan), m_pNetwork->GetUser(), m_pNetwork, NULL, NOTHING); if (pChan->IsDetached()) { return; } } } else if (sCmd.Equals("PART")) { CString sChan = sRest.Token(0).TrimPrefix_n(); CString sMsg = sRest.Token(1, true).TrimPrefix_n(); CChan* pChan = m_pNetwork->FindChan(sChan); bool bDetached = false; if (pChan) { pChan->RemNick(Nick.GetNick()); NETWORKMODULECALL(OnPart(Nick.GetNickMask(), *pChan, sMsg), m_pNetwork->GetUser(), m_pNetwork, NULL, NOTHING); if (pChan->IsDetached()) bDetached = true; } // Todo: use nick compare function if (Nick.GetNick().Equals(GetNick())) { m_pNetwork->DelChan(sChan); } /* * We use this boolean because * m_pNetwork->DelChan() will delete this channel * and thus we would dereference an * already-freed pointer! */ if (bDetached) { return; } } else if (sCmd.Equals("MODE")) { CString sTarget = sRest.Token(0); CString sModes = sRest.Token(1, true); if (sModes.Left(1) == ":") sModes = sModes.substr(1); CChan* pChan = m_pNetwork->FindChan(sTarget); if (pChan) { pChan->ModeChange(sModes, &Nick); if (pChan->IsDetached()) { return; } } else if (sTarget == m_Nick.GetNick()) { CString sModeArg = sModes.Token(0); bool bAdd = true; /* no module call defined (yet?) MODULECALL(OnRawUserMode(*pOpNick, *this, sModeArg, sArgs), m_pNetwork->GetUser(), NULL, ); */ for (unsigned int a = 0; a < sModeArg.size(); a++) { const unsigned char& uMode = sModeArg[a]; if (uMode == '+') { bAdd = true; } else if (uMode == '-') { bAdd = false; } else { if (bAdd) { m_scUserModes.insert(uMode); } else { m_scUserModes.erase(uMode); } } } } } else if (sCmd.Equals("KICK")) { // :[email protected] KICK #chan nick :msg CString sChan = sRest.Token(0); CString sKickedNick = sRest.Token(1); CString sMsg = sRest.Token(2, true); sMsg.LeftChomp(); CChan* pChan = m_pNetwork->FindChan(sChan); if (pChan) { NETWORKMODULECALL(OnKick(Nick, sKickedNick, *pChan, sMsg), m_pNetwork->GetUser(), m_pNetwork, NULL, NOTHING); // do not remove the nick till after the OnKick call, so modules // can do Chan.FindNick or something to get more info. pChan->RemNick(sKickedNick); } if (GetNick().Equals(sKickedNick) && pChan) { pChan->SetIsOn(false); // Don't try to rejoin! pChan->Disable(); } if ((pChan) && (pChan->IsDetached())) { return; } } else if (sCmd.Equals("NOTICE")) { // :[email protected] NOTICE #chan :Message CString sTarget = sRest.Token(0); CString sMsg = sRest.Token(1, true); sMsg.LeftChomp(); if (sMsg.WildCmp("\001*\001")) { sMsg.LeftChomp(); sMsg.RightChomp(); if (sTarget.Equals(GetNick())) { if (OnCTCPReply(Nick, sMsg)) { return; } } m_pNetwork->PutUser(":" + Nick.GetNickMask() + " NOTICE " + sTarget + " :\001" + sMsg + "\001"); return; } else { if (sTarget.Equals(GetNick())) { if (OnPrivNotice(Nick, sMsg)) { return; } } else { if (OnChanNotice(Nick, sTarget, sMsg)) { return; } } } if (Nick.GetNick().Equals(m_pNetwork->GetIRCServer())) { m_pNetwork->PutUser(":" + Nick.GetNick() + " NOTICE " + sTarget + " :" + sMsg); } else { m_pNetwork->PutUser(":" + Nick.GetNickMask() + " NOTICE " + sTarget + " :" + sMsg); } return; } else if (sCmd.Equals("TOPIC")) { // :[email protected] TOPIC #chan :This is a topic CChan* pChan = m_pNetwork->FindChan(sLine.Token(2)); if (pChan) { CString sTopic = sLine.Token(3, true); sTopic.LeftChomp(); NETWORKMODULECALL(OnTopic(Nick, *pChan, sTopic), m_pNetwork->GetUser(), m_pNetwork, NULL, return); pChan->SetTopicOwner(Nick.GetNick()); pChan->SetTopicDate((unsigned long) time(NULL)); pChan->SetTopic(sTopic); if (pChan->IsDetached()) { return; // Don't forward this } sLine = ":" + Nick.GetNickMask() + " TOPIC " + pChan->GetName() + " :" + sTopic; } } else if (sCmd.Equals("PRIVMSG")) {
void CCallThread::DispatchCallerCmd(CallerCmd& callerCmd) { switch(callerCmd.GetCmdType()) { case cmdLogin: { OnLogin(callerCmd); } break; case cmdQuit: { OnQuit(callerCmd); } break; case cmdCall: { OnCall(callerCmd); } break; case cmdRecall: { OnRecall(callerCmd); } break; case cmdDiscard: { OnDiscard(callerCmd); } break; case cmdWait: { OnWait(callerCmd); } break; case cmdEvaReq: { OnEvaReq(callerCmd); } break; case cmdPause: { OnPause(callerCmd); } break; case cmdResume: { OnResume(callerCmd); } break; case cmdCallNum: { OnCallNum(callerCmd); } break; case cmdCallSec: { OnCallSec(callerCmd); } break; case cmdCallMana: { OnCallMana(callerCmd); } break; case cmdCallBusc: { OnCallBusc(callerCmd); } break; case cmdExChange: { OnExChange(callerCmd); } break; case callerCmdShowAdd: break; default: { return; } break; } ///处理完后返回 ReturnToCaller(callerCmd); }
void CSDL_EventHandler::HandleEvents() { OnPreEvents(); while(::SDL_PollEvent(&event)) { switch (event.type) { case SDL_ACTIVEEVENT: switch(event.active.state) { case SDL_APPMOUSEFOCUS: OnAppMouseFocus(event.active.gain); break; case SDL_APPINPUTFOCUS: OnAppInputFocus(event.active.gain); break; case SDL_APPACTIVE: if(event.active.gain) { OnRestore(); } else { OnMinimize(); } break; } break; case SDL_KEYDOWN: case SDL_KEYUP: OnKeypress(event.key, event.key.keysym.mod); break; case SDL_MOUSEMOTION: OnMouseMotion(event.motion); break; case SDL_MOUSEBUTTONDOWN: break; case SDL_MOUSEBUTTONUP: break; case SDL_JOYAXISMOTION: break; case SDL_JOYBALLMOTION: break; case SDL_JOYHATMOTION: break; case SDL_JOYBUTTONDOWN: break; case SDL_JOYBUTTONUP: break; case SDL_QUIT: OnQuit(); break; case SDL_SYSWMEVENT: break; case SDL_VIDEORESIZE: break; case SDL_VIDEOEXPOSE: break; case SDL_USEREVENT: break; default: break; } } OnPostEvents(); } // HandleEvents()
void Logino::reject() { OnQuit(); }
void Events::Poll() { GamePad::Clear(); Joystick::Clear(); Keyboard::Clear(); Mouse::Clear(); while (SDL_PollEvent(&mEvent)) { switch (mEvent.type) { case SDL_QUIT: OnQuit(); break; case SDL_APP_TERMINATING: OnAppTerminating(); break; case SDL_APP_LOWMEMORY: OnAppLowMemory(); break; case SDL_APP_WILLENTERBACKGROUND: OnAppWillEnterBackground(); break; case SDL_APP_DIDENTERBACKGROUND: OnAppDidEnterBackground(); break; case SDL_APP_WILLENTERFOREGROUND: OnAppWillEnterForeground(); break; case SDL_APP_DIDENTERFOREGROUND: OnAppDidEnterForeground(); break; case SDL_WINDOWEVENT: OnWindowEvent(); break; case SDL_SYSWMEVENT: OnSysWMEvent(); break; case SDL_KEYDOWN: OnKeyDown(mEvent.key.keysym.sym, mEvent.key.keysym.mod, mEvent.key.repeat); Keyboard::SetKey(mEvent.key.keysym.sym, true); break; case SDL_KEYUP: OnKeyUp(mEvent.key.keysym.sym, mEvent.key.keysym.mod, mEvent.key.repeat); Keyboard::SetKey(mEvent.key.keysym.sym, false); break; case SDL_TEXTEDITING: OnTextEditing(); break; case SDL_TEXTINPUT: OnTextInput(); break; case SDL_MOUSEMOTION: OnMouseMotion(mEvent.motion.x, mEvent.motion.y, mEvent.motion.xrel, mEvent.motion.yrel); Mouse::SetPosition(mEvent.motion.x, mEvent.motion.y); break; case SDL_MOUSEBUTTONDOWN: switch(mEvent.button.button) { case SDL_BUTTON_LEFT: OnMouseLeftButtonDown(mEvent.button.x, mEvent.button.y); break; case SDL_BUTTON_RIGHT: OnMouseRightButtonDown(mEvent.button.x, mEvent.button.y); break; case SDL_BUTTON_MIDDLE: OnMouseMiddleButtonDown(mEvent.button.x, mEvent.button.y); break; case SDL_BUTTON_X1: OnMouseLeftButtonDown(mEvent.button.x, mEvent.button.y); break; case SDL_BUTTON_X2: OnMouseLeftButtonDown(mEvent.button.x, mEvent.button.y); break; } break; case SDL_MOUSEBUTTONUP: switch(mEvent.button.button) { case SDL_BUTTON_LEFT: OnMouseLeftButtonUp(mEvent.button.x, mEvent.button.y); break; case SDL_BUTTON_RIGHT: OnMouseRightButtonUp(mEvent.button.x, mEvent.button.y); break; case SDL_BUTTON_MIDDLE: OnMouseMiddleButtonUp(mEvent.button.x, mEvent.button.y); break; case SDL_BUTTON_X1: OnMouseLeftButtonUp(mEvent.button.x, mEvent.button.y); break; case SDL_BUTTON_X2: OnMouseLeftButtonUp(mEvent.button.x, mEvent.button.y); break; } break; case SDL_MOUSEWHEEL: OnMouseWheel(mEvent.wheel.x, mEvent.wheel.y); Mouse::SetScroll(mEvent.wheel.x, mEvent.wheel.y); break; case SDL_JOYAXISMOTION: OnJoyAxisMotion(); break; case SDL_JOYBALLMOTION: OnJoyBallMotion(); break; case SDL_JOYHATMOTION: OnJoyHatMotion(); break; case SDL_JOYBUTTONDOWN: OnJoyBallButtonDown(); break; case SDL_JOYBUTTONUP: OnJoyBallButtonUp(); break; case SDL_JOYDEVICEADDED: OnJoyDeviceAdded(); break; case SDL_JOYDEVICEREMOVED: OnJoyDeviceRemoved(); break; case SDL_CONTROLLERAXISMOTION: OnControllerAxisMotion(mEvent.caxis.axis, mEvent.caxis.value, mEvent.caxis.which); GamePad::SetAxis(mEvent.caxis.axis, mEvent.caxis.value, mEvent.caxis.which); break; case SDL_CONTROLLERBUTTONDOWN: OnControllerButtonDown(mEvent.cbutton.button, mEvent.cbutton.which); GamePad::SetButton(mEvent.cbutton.button, true, mEvent.cbutton.which); break; case SDL_CONTROLLERBUTTONUP: OnControllerButtonUp(mEvent.cbutton.button, mEvent.cbutton.which); GamePad::SetButton(mEvent.cbutton.button, false, mEvent.cbutton.which); break; case SDL_CONTROLLERDEVICEADDED: OnControllerDeviceAdded(mEvent.cdevice.which); GamePad::Add(mEvent.cdevice.which); break; case SDL_CONTROLLERDEVICEREMOVED: OnControllerDeviceRemoved(mEvent.cdevice.which); GamePad::Remove(mEvent.cdevice.which); break; case SDL_CONTROLLERDEVICEREMAPPED: OnControllerDeviceRemapped(mEvent.cdevice.which); break; case SDL_FINGERDOWN: OnFingerDown(); break; case SDL_FINGERUP: OnFingerUp(); break; case SDL_FINGERMOTION: OnFingerMotion(); break; case SDL_DOLLARGESTURE: OnDollarGesture(); break; case SDL_DOLLARRECORD: OnDollarRecord(); break; case SDL_MULTIGESTURE: OnMultiGesture(); break; case SDL_CLIPBOARDUPDATE: OnClipboardUpdate(); break; case SDL_DROPFILE: OnDropFile(); break; case SDL_USEREVENT: OnUserEvent(); break; default: OnUndefined(); break; } } }
void VorbitalDlg::closeEvent(QCloseEvent* event) { OnQuit(); event->accept(); }
virtual void OnKeyDown(int nKey, int nMod) { switch(nKey) { case SDLK_ESCAPE: OnQuit(); break; case SDLK_p: m_nPolygonMode = (m_nPolygonMode == GL_FILL) ? GL_LINE : GL_FILL; break; case SDLK_h: m_bHDR = !m_bHDR; break; case SDLK_F5: if(CInputTask::GetPtr()->IsKeyDown(SDLK_LSHIFT) || CInputTask::GetPtr()->IsKeyDown(SDLK_RSHIFT)) m_Kr = CMath::Max(0.0f, m_Kr - 0.0001f); else m_Kr += 0.0001f; m_Kr4PI = m_Kr*4.0f*PI; break; case SDLK_F6: if(CInputTask::GetPtr()->IsKeyDown(SDLK_LSHIFT) || CInputTask::GetPtr()->IsKeyDown(SDLK_RSHIFT)) m_Km = CMath::Max(0.0f, m_Km - 0.0001f); else m_Km += 0.0001f; m_Km4PI = m_Km*4.0f*PI; break; case SDLK_F7: if(CInputTask::GetPtr()->IsKeyDown(SDLK_LSHIFT) || CInputTask::GetPtr()->IsKeyDown(SDLK_RSHIFT)) m_g = CMath::Max(-1.0f, m_g-0.01f); else m_g = CMath::Min(1.0f, m_g+0.01f); break; case SDLK_F8: if(CInputTask::GetPtr()->IsKeyDown(SDLK_LSHIFT) || CInputTask::GetPtr()->IsKeyDown(SDLK_RSHIFT)) m_ESun = CMath::Max(0.0f, m_ESun - 0.1f); else m_ESun += 0.1f; break; case SDLK_F9: if(CInputTask::GetPtr()->IsKeyDown(SDLK_LSHIFT) || CInputTask::GetPtr()->IsKeyDown(SDLK_RSHIFT)) m_fWavelength[0] = CMath::Max(0.001f, m_fWavelength[0] -= 0.001f); else m_fWavelength[0] += 0.001f; m_fWavelength4[0] = powf(m_fWavelength[0], 4.0f); break; case SDLK_F10: if(CInputTask::GetPtr()->IsKeyDown(SDLK_LSHIFT) || CInputTask::GetPtr()->IsKeyDown(SDLK_RSHIFT)) m_fWavelength[1] = CMath::Max(0.001f, m_fWavelength[1] -= 0.001f); else m_fWavelength[1] += 0.001f; m_fWavelength4[1] = powf(m_fWavelength[1], 4.0f); break; case SDLK_F11: if(CInputTask::GetPtr()->IsKeyDown(SDLK_LSHIFT) || CInputTask::GetPtr()->IsKeyDown(SDLK_RSHIFT)) m_fWavelength[2] = CMath::Max(0.001f, m_fWavelength[2] -= 0.001f); else m_fWavelength[2] += 0.001f; m_fWavelength4[2] = powf(m_fWavelength[2], 4.0f); break; case SDLK_PLUS: case SDLK_KP_PLUS: case SDLK_EQUALS: if(m_bHDR) { if(m_fExposure < 10.0f) m_fExposure += 0.1f; } else m_nSamples = CMath::Min(m_nSamples+1, 25); break; case SDLK_MINUS: case SDLK_KP_MINUS: if(m_bHDR) { if(m_fExposure > 0.1f) m_fExposure -= 0.1f; } else m_nSamples = CMath::Max(m_nSamples-1, 1); break; } }
bool CModules::OnQuit(const CNick& Nick, const CString& sMessage, const vector<CChan*>& vChans) { MODUNLOADCHK(OnQuit(Nick, sMessage, vChans)); return false; }
STDMETHODIMP DWebBrowserEventsImpl::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) { switch (dispIdMember) { ///////////////////////////////////////////////////////// // The parameters for this DISPID are as follows: // [0]: Cancel flag - VT_BYREF|VT_BOOL // [1]: IDispatch* - Pointer to an IDispatch interface. // You can set this parameter to the IDispatch of // a WebBrowser Control that you've created. When // you pass back an IDispatch like this, MSHTML will // use the control you've given it to open the link. // case DISPID_NEWWINDOW2: { NewWindow2(pDispParams->rgvarg[1].ppdispVal, pDispParams->rgvarg[0].pboolVal); } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID are as follows: // [0]: Cancel flag - VT_BYREF|VT_BOOL // [1]: HTTP headers - VT_BYREF|VT_VARIANT // [2]: Address of HTTP POST data - VT_BYREF|VT_VARIANT // [3]: Target frame name - VT_BYREF|VT_VARIANT // [4]: Option flags - VT_BYREF|VT_VARIANT // [5]: URL to navigate to - VT_BYREF|VT_VARIANT // [6]: An object that evaluates to the top-level or frame // WebBrowser object corresponding to the event. // // User clicked a link or launched the browser. // case DISPID_BEFORENAVIGATE2: { BeforeNavigate2(pDispParams->rgvarg[6].pdispVal, pDispParams->rgvarg[5].pvarVal, pDispParams->rgvarg[4].pvarVal, pDispParams->rgvarg[3].pvarVal, pDispParams->rgvarg[2].pvarVal, pDispParams->rgvarg[1].pvarVal, pDispParams->rgvarg[0].pboolVal); } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID: // [0]: URL navigated to - VT_BYREF|VT_VARIANT // [1]: An object that evaluates to the top-level or frame // WebBrowser object corresponding to the event. // // Fires after a navigation to a link is completed on either // a window or frameSet element. // case DISPID_NAVIGATECOMPLETE2: { NavigateComplete2(pDispParams->rgvarg[1].pdispVal, pDispParams->rgvarg[0].pvarVal); // Check if m_lpDocCompleteDisp is NULL. If NULL, that means it is // the top level NavigateComplete2. Save the LPDISPATCH if (!m_lpDocCompleteDisp) { VARIANTARG varDisp = pDispParams->rgvarg[1]; m_lpDocCompleteDisp = varDisp.pdispVal; } } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID: // [0]: New status bar text - VT_BSTR // case DISPID_STATUSTEXTCHANGE: { StatusTextChange(pDispParams->rgvarg[0].bstrVal); } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID: // [0]: Maximum progress - VT_I4 // [1]: Amount of total progress - VT_I4 // case DISPID_PROGRESSCHANGE: { ProgressChange(pDispParams->rgvarg[1].intVal, pDispParams->rgvarg[0].intVal); } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID: // [0]: URL navigated to - VT_BYREF|VT_VARIANT // [1]: An object that evaluates to the top-level or frame // WebBrowser object corresponding to the event. // // Fires when a document has been completely loaded and initialized. // Unreliable -- currently, the DWebBrowserEvents2::DocumentComplete // does not fire when the IWebBrowser2::Visible property of the // WebBrowser Control is set to false (see Q259935). Also, multiple // DISPID_DOCUMENTCOMPLETE events can be fired before the final // READYSTATE_COMPLETE (see Q180366). // case DISPID_DOCUMENTCOMPLETE: { DocumentComplete(pDispParams->rgvarg[1].pdispVal, pDispParams->rgvarg[0].pvarVal); VARIANTARG varDisp = pDispParams->rgvarg[1]; if (m_lpDocCompleteDisp && m_lpDocCompleteDisp == varDisp.pdispVal) { // if the LPDISPATCH are same, that means // it is the final DocumentComplete. Reset m_lpDocCompleteDisp m_lpDocCompleteDisp = NULL; // Handle new doc. DocumentReallyComplete(pDispParams->rgvarg[1].pdispVal, pDispParams->rgvarg[0].pvarVal); } } break; /////////////////////////////////////////////////////////// // No parameters // // Fires when a navigation operation is beginning. // case DISPID_DOWNLOADBEGIN: DownloadBegin(); break; /////////////////////////////////////////////////////////// // No parameters // // Fires when a navigation operation finishes, is halted, or fails. // case DISPID_DOWNLOADCOMPLETE: DownloadComplete(); break; /////////////////////////////////////////////////////////// // The parameters for this DISPID: // [0]: Enabled state - VT_BOOL // [1]: Command identifier - VT_I4 // case DISPID_COMMANDSTATECHANGE: { CommandStateChange(pDispParams->rgvarg[1].intVal, pDispParams->rgvarg[0].boolVal); } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID: // [0]: Document title - VT_BSTR // [1]: An object that evaluates to the top-level or frame // WebBrowser object corresponding to the event. // case DISPID_TITLECHANGE: { TitleChange(pDispParams->rgvarg[0].bstrVal); } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID: // [0]: Name of property that changed - VT_BSTR // case DISPID_PROPERTYCHANGE: { PropertyChange(pDispParams->rgvarg[0].bstrVal); } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID: // [0]: Cancel flag - VT_BYREF|VT_BOOL // [1]: Child Window (created from script) - VT_BOOL // // case DISPID_WINDOWCLOSING: { WindowClosing(pDispParams->rgvarg[1].boolVal, pDispParams->rgvarg[0].pboolVal); } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID: // [0]: Cancel flag - VT_BYREF|VT_BOOL // // case DISPID_FILEDOWNLOAD: { FileDownload(pDispParams->rgvarg[0].pboolVal); } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID are as follows: // [0]: Cancel flag - VT_BYREF|VT_BOOL // [1]: Error status code - VT_BYREF|VT_VARIANT // [2]: Target frame name - VT_BYREF|VT_VARIANT // [3]: URL where navigate failed - VT_BYREF|VT_VARIANT // [4]: An object that evaluates to the top-level or frame // WebBrowser object corresponding to the event. // // case DISPID_NAVIGATEERROR: { NavigateError(pDispParams->rgvarg[4].pdispVal, pDispParams->rgvarg[3].pvarVal, pDispParams->rgvarg[2].pvarVal, pDispParams->rgvarg[1].pvarVal, pDispParams->rgvarg[0].pboolVal); m_lpDocCompleteDisp = NULL; } break; /////////////////////////////////////////////////////////// // The parameters for this DISPID: // [0]: Visible - VT_BOOL // case DISPID_ONVISIBLE: { OnVisible(pDispParams->rgvarg[0].boolVal); } break; /////////////////////////////////////////////////////////// // No parameters // // The BHO docs in MSDN say to use DISPID_QUIT, but this is an error. // The BHO never gets a DISPID_QUIT and thus the browser connection // never gets unadvised and so the BHO never gets the FinalRelease(). // This is bad. So use DISPID_ONQUIT instead and everything is cool -- // EXCEPT when you exit the browser when viewing a page that launches // a popup in the onunload event! In that case the BHO is already // unadvised so it does not intercept the popup. So the trick is to // navigate to a known page (I used the about:blank page) that does // not have a popup in the onunload event before unadvising. // case DISPID_ONQUIT: OnQuit(); break; default: { } break; } return NOERROR; }