void CLoginWindow::Notify(TNotifyUI& msg) { YTrace_(_T("CLoginWindow::Notify class:%s,id:%s,msg:%s"),msg.pSender->GetClass(),msg.pSender->GetName().GetData(),msg.sType.GetData()); CControlUI* pSender = msg.pSender; if (0 == msg.sType.Compare(kClick)) { if (pSender->IsName(_T("close"))) Close(0); else if (pSender->IsName(_T("login"))) OnLogin(); else if (pSender->IsName(_T("sina"))) OnSinaLogin(); else if (pSender->IsName(_T("QQ"))) OnQQLogin(); else if (pSender->IsName(_T("ForgetCode"))) OnForgetPassword(); else if (pSender->IsName(_T("register"))) OnReg(); } else if(0 == msg.sType.Compare(kReturn)) { OnLogin(); } }
//-------------------------------------------------------------------------------- void Login::Handle_Click(MyGUI::WidgetPtr _widget) { std::string lLogin = mEditUser->getOnlyText().asUTF8(); std::string lPassword = mEditPass->getOnlyText().asUTF8(); OnLogin(lLogin, lPassword); }
void CCmdProcess::ProcessCmd(unsigned int flow, Commpack *pPack) { unsigned int ulCmd = pPack->GetCmd(); Debug("new_cmd: %x", ulCmd); switch (ulCmd) { case CMD_TEST: OnTest(flow, pPack); break; case CMD_LOGIN: OnLogin(flow, pPack); break; case CMD_HEARTBEAT: OnHeartbeat(flow, pPack); break; case CMD_GETALLCLIENT: OnGetAllClient(flow, pPack); break; case CMD_TASK1: OnTask1(flow, pPack); break; case CMD_AGENT_GET_IP_BY_TS: GetIPByTS(flow, pPack); break; case CMD_AGENT_REPT_TASK: OnReptTask(flow, pPack); break; default: break; } }
void KUiSelServer::OnClickButton(KWndButton* pBtn) { if (pBtn == &m_Login) OnLogin(); else if(pBtn == &m_Cancel) OnCancel(); }
void CHTTPSock::ReadLine(const CString& sData) { if (m_bGotHeader) { return; } CString sLine = sData; sLine.TrimRight("\r\n"); CString sName = sLine.Token(0); if (sName.Equals("GET")) { m_bPost = false; m_sURI = sLine.Token(1); m_bHTTP10Client = sLine.Token(2).Equals("HTTP/1.0"); ParseURI(); } else if (sName.Equals("POST")) { m_bPost = true; m_sURI = sLine.Token(1); ParseURI(); } else if (sName.Equals("Cookie:")) { VCString vsNV; sLine.Token(1, true).Split(";", vsNV, false, "", "", true, true); for (unsigned int a = 0; a < vsNV.size(); a++) { CString s(vsNV[a]); m_msRequestCookies[s.Token(0, false, "=").Escape_n(CString::EURL, CString::EASCII)] = s.Token(1, true, "=").Escape_n(CString::EURL, CString::EASCII); } } else if (sName.Equals("Authorization:")) { CString sUnhashed; sLine.Token(2).Base64Decode(sUnhashed); m_sUser = sUnhashed.Token(0, false, ":"); m_sPass = sUnhashed.Token(1, true, ":"); m_bLoggedIn = OnLogin(m_sUser, m_sPass); } else if (sName.Equals("Content-Length:")) { m_uPostLen = sLine.Token(1).ToULong(); if (m_uPostLen > MAX_POST_SIZE) PrintErrorPage(413, "Request Entity Too Large", "The request you sent was too large."); } else if (sName.Equals("If-None-Match:")) { // this is for proper client cache support (HTTP 304) on static files: m_sIfNoneMatch = sLine.Token(1, true); } else if (sLine.empty()) { m_bGotHeader = true; if (m_bPost) { m_sPostData = GetInternalReadBuffer(); CheckPost(); } else { GetPage(); } DisableReadLine(); } }
void C图片管理器App::OnFileNew() { // TODO: 在此添加命令处理程序代码 while (!m_LoginStatus) { // AfxMessageBox("欢迎来到本系统,请您登陆"); OnLogin(); } CWinApp::OnFileNew(); }
void CRTConnHttp::OnHttpMessage(http_message* httpMsg) { const char* pPath = httpMsg->request_path; //const char* pQuery = httpMsg->query_string; const char* pContent = httpMsg->body; int nContentLen = (int)httpMsg->body_size; if (!pPath || !pContent) { LE("OnHttpMessage pPath or pContent error\n"); //SendResponse(HPS_NOT_ACCEPTABLE, ""); return; } MEETMSG m_mmsg; std::string str(pContent, nContentLen), err(""); m_mmsg.GetMsg(str, err); if (err.length() > 0) { LE("OnHttpMessage pContent error:%s\n", err.c_str()); //SendResponse(HPS_NOT_ACCEPTABLE, ""); return; } if (strcmp(pPath, "/login") == 0) { if (m_mmsg._from.length()>0 && m_mmsg._pass.length()>0 && m_mmsg._nname.length()>0) { OnLogin(m_mmsg._from.c_str(), m_mmsg._pass.c_str(), m_mmsg._nname.c_str()); } else { LE("login params errors\n"); } } else if(strcmp(pPath, "/sndmsg") == 0) { if (m_mmsg._from.length()>0) { const char* pContentDump = strdup(pContent); OnSndMsg(m_mmsg._from.c_str(), m_mmsg._mtype, pContentDump, (int)strlen(pContentDump)); free((void*)pContentDump); pContentDump = NULL; } else { LE("sndmsg params errors\n"); } } else if(strcmp(pPath, "/getmsg") == 0) { if (m_mmsg._from.length()>0) { OnGetMsg(m_mmsg._from.c_str(), m_mmsg._mtype); } else { LE("getmsg params errors\n"); } } else if (strcmp(pPath, "/logout") == 0) { if (m_mmsg._from.length()>0) { OnLogout(m_mmsg._from.c_str()); } else { LE("logout params errors\n"); } } else { SendResponse(HPS_NOT_ACCEPTABLE, ""); return; } }
LoginDialog::LoginDialog(QWidget *parent) : QDialog(parent) { setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint); setAttribute(Qt::WA_TranslucentBackground); ui.setupUi(this); connect(ui.loginButton, SIGNAL(clicked()), this, SLOT(OnLogin())); connect(ui.exitButton, SIGNAL(clicked()), this, SLOT(OnExit())); ui.usernameEdit->setPlaceholderText(USERNAME); ui.passwordEdit->setPlaceholderText(PASSWORD); ui.label->setFocus(); }
DWORD OnCommand(HWND hDlg, WPARAM wParam, LPARAM lParam) { switch( LOWORD( wParam ) ) { case IDC_BTN_LOGIN: OnLogin(hDlg); break; case IDC_BTN_SEND: OnSend(hDlg); break; case ID_LOGOUT: OnLogOut(hDlg); break; case ID_EXIT: case IDCANCEL: OnExit(hDlg); break; } return TRUE; }
int KUiSelServer::OnKeyDown(unsigned int uKey) { int nRet = 1; KWndWindow* pToActive = NULL; switch (uKey) { case VK_RETURN: if (m_Cancel.IsButtonActive()) OnCancel(); else OnLogin(); break; case VK_ESCAPE: OnCancel(); break; case VK_LEFT: if (m_Login.IsButtonActive() == 0) pToActive = &m_Login; break; case VK_RIGHT: if (m_Cancel.IsButtonActive() == 0) pToActive = &m_Cancel; break; case VK_UP: nRet = m_List.GetCurSel(); if (nRet > 0) m_List.SetCurSel(nRet - 1); else if (nRet < 0) m_List.SetCurSel(0); m_ScrollBar.SetScrollPos(m_List.GetTopItemIndex()); nRet = 1; break; case VK_DOWN: nRet = m_List.GetCurSel(); if (nRet < m_List.GetCount() - 1) m_List.SetCurSel(nRet + 1); else if (nRet < 0) m_List.SetCurSel(0); m_ScrollBar.SetScrollPos(m_List.GetTopItemIndex()); nRet = 1; break; default: nRet = 0; break; } if (pToActive) pToActive->SetCursorAbove(); return nRet; }
//-------------------------------------------------------------------------- // 功能:窗口函数 //-------------------------------------------------------------------------- int KUiSelServer::WndProc(unsigned int uMsg, unsigned int uParam, int nParam) { int nRet = 0; switch(uMsg) { case WND_N_BUTTON_CLICK: OnClickButton((KWndButton*)(KWndWindow*)uParam); break; case WND_N_SCORLLBAR_POS_CHANGED: m_List.SetTopItemIndex(nParam); break; case WM_KEYDOWN: nRet = OnKeyDown(uParam); break; case WND_N_LIST_ITEM_D_CLICK: if (nParam >= 0 && uParam == (unsigned int)(KWndWindow*)&m_List) OnLogin(); break; default: nRet = KWndShowAnimate::WndProc(uMsg, uParam, nParam); } return nRet; }
void CCmdProcess::ProcessCmd(unsigned int flow, Commpack *pPack) { unsigned int ulCmd = pPack->GetCmd(); switch (ulCmd) { case CMD_TEST: OnTest(flow, pPack); break; case CMD_LOGIN: OnLogin(flow, pPack); break; case CMD_HEARTBEAT: OnHeartbeat(flow, pPack); break; case CMD_GETALLCLIENT: OnGetAllClient(flow, pPack); break; case CMD_TASK1: OnTask1(flow, pPack); break; default: 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())); }
j_result_t CXlClient::OnHandleRead(J_AsioDataBase *pAsioData) { if (m_ioCmdState == CXlProtocol::xl_init_state) { pAsioData->ioCall = J_AsioDataBase::j_read_e; CXlHelper::MakeNetData(pAsioData, m_readBuff, sizeof(CXlProtocol::CmdHeader)); m_ioCmdState = CXlProtocol::xl_read_head_state; } else if (m_ioCmdState == CXlProtocol::xl_read_head_state) { CXlProtocol::CmdHeader cmdHeader = *((CXlProtocol::CmdHeader *)m_readBuff); //J_OS::LOGINFO("%d ", cmdHeader.cmd); //if (cmdHeader.length > 1000) //{ // J_OS::LOGINFO(""); //} CXlHelper::MakeNetData(pAsioData, m_readBuff + sizeof(CXlProtocol::CmdHeader), cmdHeader.length + sizeof(CXlProtocol::CmdTail)); pAsioData->ioCall = J_AsioDataBase::j_read_e; m_ioCmdState = CXlProtocol::xl_read_data_state; } else if (m_ioCmdState == CXlProtocol::xl_read_data_state) { CXlClientCmdData *pCmdData = (CXlClientCmdData *)m_readBuff; switch (pCmdData->cmdHeader.cmd) { case CXlProtocol::xlc_login: OnLogin(*pCmdData); break; case CXlProtocol::xlc_logout: OnLogout(*pCmdData); break; case CXlProtocol::xlc_heart_beat: OnHeartBeat(*pCmdData); break; case CXlProtocol::xlc_real_play: SaveRequest(*pCmdData, pCmdData->cmdHeader.flag == CXlProtocol::xl_ctrl_start); pCmdData->cmdRealPlay.pBuffer = &m_ringBuffer; JoDataBus->Request(pCmdData->cmdRealPlay.hostId, this, *pCmdData); break; case CXlProtocol::xlc_vod_play: case CXlProtocol::xlc_vod_download: SaveRequest(*pCmdData, pCmdData->cmdHeader.flag == CXlProtocol::xl_ctrl_start); pCmdData->cmdStartVod.pBuffer = &m_ringBuffer; JoDataBus->Request(pCmdData->cmdStartVod.hostId, this, *pCmdData); break; case CXlProtocol::xlc_real_alarm: EnableAlarm(*pCmdData, pCmdData->cmdHeader.flag == CXlProtocol::xl_ctrl_start); break; case CXlProtocol::xlc_trans_context: break; case CXlProtocol::xlc_upload_file: break; default: //assert(false); SendRequest(*pCmdData); break; } CXlHelper::MakeNetData(pAsioData, m_readBuff, sizeof(CXlProtocol::CmdHeader)); pAsioData->ioCall = J_AsioDataBase::j_read_e; m_ioCmdState = CXlProtocol::xl_read_head_state; } return J_OK; }
CWebSock::EPageReqResult CWebSock::OnPageRequestInternal(const CString& sURI, CString& sPageRet) { if (CZNC::Get().GetProtectWebSessions() && GetSession()->GetIP() != GetRemoteIP()) { DEBUG("Expected IP: " << GetSession()->GetIP()); DEBUG("Remote IP: " << GetRemoteIP()); PrintErrorPage(403, "Access denied", "This session does not belong to your IP."); return PAGE_DONE; } // Check that they really POSTed from one our forms by checking if they // know the "secret" CSRF check value. Don't do this for login since // CSRF against the login form makes no sense and the login form does a // cookies-enabled check which would break otherwise. if (IsPost() && GetParam("_CSRF_Check") != GetCSRFCheck() && sURI != "/login") { DEBUG("Expected _CSRF_Check: " << GetCSRFCheck()); DEBUG("Actual _CSRF_Check: " << GetParam("_CSRF_Check")); PrintErrorPage(403, "Access denied", "POST requests need to send " "a secret token to prevent cross-site request forgery attacks."); return PAGE_DONE; } SendCookie("SessionId", GetSession()->GetId()); if (GetSession()->IsLoggedIn()) { m_sUser = GetSession()->GetUser()->GetUserName(); m_bLoggedIn = true; } // Handle the static pages that don't require a login if (sURI == "/") { if(!m_bLoggedIn && GetParam("cookie_check", false).ToBool() && GetRequestCookie("SessionId").empty()) { GetSession()->AddError("Your browser does not have cookies enabled for this site!"); } return PrintTemplate("index", sPageRet); } else if (sURI == "/favicon.ico") { return PrintStaticFile("/pub/favicon.ico", sPageRet); } else if (sURI == "/robots.txt") { return PrintStaticFile("/pub/robots.txt", sPageRet); } else if (sURI == "/logout") { GetSession()->SetUser(NULL); SetLoggedIn(false); Redirect("/"); // We already sent a reply return PAGE_DONE; } else if (sURI == "/login") { if (GetParam("submitted").ToBool()) { m_sUser = GetParam("user"); m_sPass = GetParam("pass"); m_bLoggedIn = OnLogin(m_sUser, m_sPass); // AcceptedLogin()/RefusedLogin() will call Redirect() return PAGE_DEFERRED; } Redirect("/"); // the login form is here return PAGE_DONE; } else if (sURI.Left(5) == "/pub/") { return PrintStaticFile(sURI, sPageRet); } else if (sURI.Left(11) == "/skinfiles/") { CString sSkinName = sURI.substr(11); CString::size_type uPathStart = sSkinName.find("/"); if (uPathStart != CString::npos) { CString sFilePath = sSkinName.substr(uPathStart + 1); sSkinName.erase(uPathStart); m_Template.ClearPaths(); m_Template.AppendPath(GetSkinPath(sSkinName) + "pub"); if (PrintFile(m_Template.ExpandFile(sFilePath))) { return PAGE_DONE; } else { return PAGE_NOTFOUND; } } return PAGE_NOTFOUND; } else if (sURI.Left(6) == "/mods/" || sURI.Left(10) == "/modfiles/") { ParsePath(); // Make sure modules are treated as directories if (sURI.Right(1) != "/" && sURI.find(".") == CString::npos && sURI.TrimLeft_n("/mods/").TrimLeft_n("/").find("/") == CString::npos) { Redirect(sURI + "/"); return PAGE_DONE; } CModule *pModule = CZNC::Get().GetModules().FindModule(m_sModName); if (!pModule) { // Check if GetSession()->GetUser() is NULL and display // an error in that case if (!ForceLogin()) return PAGE_DONE; pModule = GetSession()->GetUser()->GetModules().FindModule(m_sModName); } if (!pModule) { return PAGE_NOTFOUND; } else if (pModule->WebRequiresLogin() && !ForceLogin()) { return PAGE_PRINT; } else if (pModule->WebRequiresAdmin() && !GetSession()->IsAdmin()) { PrintErrorPage(403, "Forbidden", "You need to be an admin to access this module"); return PAGE_DONE; } else if (!pModule->IsGlobal() && pModule->GetUser() != GetSession()->GetUser()) { PrintErrorPage(403, "Forbidden", "You must login as " + pModule->GetUser()->GetUserName() + " in order to view this page"); return PAGE_DONE; } else if (pModule->OnWebPreRequest(*this, m_sPage)) { return PAGE_DEFERRED; } VWebSubPages& vSubPages = pModule->GetSubPages(); for (unsigned int a = 0; a < vSubPages.size(); a++) { TWebSubPage& SubPage = vSubPages[a]; bool bActive = (m_sModName == pModule->GetModName() && m_sPage == SubPage->GetName()); if (bActive && SubPage->RequiresAdmin() && !GetSession()->IsAdmin()) { PrintErrorPage(403, "Forbidden", "You need to be an admin to access this page"); return PAGE_DONE; } } if (pModule && !pModule->IsGlobal() && (!IsLoggedIn() || pModule->GetUser() != GetSession()->GetUser())) { AddModLoop("UserModLoop", *pModule); } if (sURI.Left(10) == "/modfiles/") { m_Template.AppendPath(GetSkinPath(GetSkinName()) + "/mods/" + m_sModName + "/files/"); m_Template.AppendPath(pModule->GetModDataDir() + "/files/"); if (PrintFile(m_Template.ExpandFile(m_sPage.TrimLeft_n("/")))) { return PAGE_PRINT; } else { return PAGE_NOTFOUND; } } else { SetPaths(pModule, true); /* if a module returns false from OnWebRequest, it does not want the template to be printed, usually because it did a redirect. */ if (pModule->OnWebRequest(*this, m_sPage, m_Template)) { // If they already sent a reply, let's assume // they did what they wanted to do. if (SentHeader()) { return PAGE_DONE; } return PrintTemplate(m_sPage, sPageRet, pModule); } if (!SentHeader()) { PrintErrorPage(404, "Not Implemented", "The requested module does not acknowledge web requests"); } return PAGE_DONE; } } else { CString sPage(sURI.Trim_n("/")); if (sPage.length() < 32) { for (unsigned int a = 0; a < sPage.length(); a++) { unsigned char c = sPage[a]; if ((c < '0' || c > '9') && (c < 'a' || c > 'z') && (c < 'A' || c > 'Z') && c != '_') { return PAGE_NOTFOUND; } } return PrintTemplate(sPage, sPageRet); } } return PAGE_NOTFOUND; }
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); }
j_result_t CXlClient::ProcessRequest(J_AsioDataBase *pAsioData) { if (m_ioCmdState == xl_init_state) { pAsioData->ioCall = J_AsioDataBase::j_read_e; CXlHelper::MakeNetData(pAsioData, m_readBuff, sizeof(CmdHeader)); m_ioCmdState = xl_read_head_state; } else if (m_ioCmdState == xl_read_head_state) { CXlHelper::MakeNetData(pAsioData, m_readBuff + sizeof(CmdHeader), *((j_int32_t *)(m_readBuff + 4)) + sizeof(CmdTail)); pAsioData->ioCall = J_AsioDataBase::j_read_e; m_ioCmdState = xl_read_data_state; } else if (m_ioCmdState == xl_read_data_state) { CmdHeader *pHeader = (CmdHeader *)m_readBuff; switch (pHeader->cmd) { case xlc_login: OnLogin(pAsioData); m_ioCmdState = xl_write_body_state; break; case xlc_logout: OnLogout(pAsioData); m_ioCmdState = xl_write_body_state; break; case xlc_heart_beat: OnHeartBeat(pAsioData); m_ioCmdState = xl_read_head_state; break; case xlc_start_real_view: OnRealPlay(pAsioData); m_ioCmdState = xl_read_head_state; break; case xlc_stop_real_view: OnRealStop(pAsioData); m_ioCmdState = xl_write_body_state; break; case xlc_start_vod_view: OnVodPlay(pAsioData); m_ioCmdState = xl_read_head_state; break; case xlc_stop_vod_view: OnVodStop(pAsioData); m_ioCmdState = xl_write_body_state; break; case xlc_start_real_alarm_info: OnStartAlarm(pAsioData); m_ioCmdState = xl_read_head_state; break; case xlc_stop_real_alarm_info: OnStopAlarm(pAsioData); m_ioCmdState = xl_write_body_state; break; case xlc_send_msg: OnSendMsg(pAsioData); m_ioCmdState = xl_write_body_state; break; case xlc_get_rcd_info: OnGetRctInfo(pAsioData); m_ioCmdState = xl_read_head_state; break; case xlc_start_upload: OnUploadStart(pAsioData); m_ioCmdState = xl_write_body_state; break; case xlc_uploading: OnUploadFile(pAsioData); m_ioCmdState = xl_read_head_state; break; case xlc_stop_upload: OnUploadStop(pAsioData); m_ioCmdState = xl_write_body_state; break; default: J_OS::LOGINFO("%d %X", pHeader->cmd, pHeader->flag & 0xFF); break; } //J_OS::LOGINFO("%d %X", pHeader->cmd, pHeader->flag & 0xFF); } else { pAsioData->ioCall = J_AsioDataBase::j_read_e; CXlHelper::MakeNetData(pAsioData, m_readBuff, sizeof(CmdHeader)); m_ioCmdState = xl_read_head_state; } return J_OK; }
void WorldSession::HandlePlayerLogin(LoginQueryHolder *holder) { // The following fixes a crash. Use case: // Session1 created, requests login, kicked. // Session2 created, requests login, and receives 2 login callback. if (GetPlayer() || !m_playerLoading) { sLog.outInfo("[CRASH] HandlePlayerLogin on session %u with player %s [loading=%u]", GetAccountId(), GetPlayerName(), m_playerLoading); delete holder; m_playerLoading = false; return; } ObjectGuid playerGuid = holder->GetGuid(); ASSERT(playerGuid.IsPlayer()); // If the character is online (ALT-F4 logout for example) Player *pCurrChar = sObjectAccessor.FindPlayer(playerGuid); MasterPlayer* pCurrMasterPlayer = sObjectAccessor.FindMasterPlayer(playerGuid); bool alreadyOnline = false; if (pCurrChar) { // Hacking attempt if (pCurrChar->GetSession()->GetAccountId() != GetAccountId()) { KickPlayer(); delete holder; m_playerLoading = false; return; } pCurrChar->GetSession()->SetPlayer(NULL); pCurrChar->SetSession(this); // Need to attach packet bcaster to the new socket pCurrChar->m_broadcaster->ChangeSocket(GetSocket()); alreadyOnline = true; // If the character had a logout request, then he is articifially stunned (cf CMSG_LOGOUT_REQUEST handler). Fix it here. if (pCurrChar->CanFreeMove()) { pCurrChar->SetMovement(MOVE_UNROOT); pCurrChar->SetStandState(UNIT_STAND_STATE_STAND); pCurrChar->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); } } else { // Character found online but not in world ? if (HashMapHolder<Player>::Find(playerGuid)) { sLog.outInfo("[CRASH] Trying to login already ingame character guid %u", playerGuid.GetCounter()); KickPlayer(); delete holder; m_playerLoading = false; return; } pCurrChar = new Player(this); pCurrChar->GetMotionMaster()->Initialize(); } // "GetAccountId()==db stored account id" checked in LoadFromDB (prevent login not own character using cheating tools) if (alreadyOnline) pCurrChar->SendPacketsAtRelogin(); else if (!pCurrChar->LoadFromDB(playerGuid, holder)) { KickPlayer(); // disconnect client, player no set to session and it will not deleted or saved at kick delete pCurrChar; // delete it manually delete holder; // delete all unprocessed queries m_playerLoading = false; return; } ASSERT(pCurrChar->GetSession() == this); SetPlayer(pCurrChar); if (pCurrMasterPlayer) { pCurrMasterPlayer->GetSession()->SetMasterPlayer(NULL); pCurrMasterPlayer->SetSession(this); m_masterPlayer = pCurrMasterPlayer; } else { m_masterPlayer = new MasterPlayer(this); m_masterPlayer->LoadPlayer(GetPlayer()); m_masterPlayer->LoadActions(holder->GetResult(PLAYER_LOGIN_QUERY_LOADACTIONS)); m_masterPlayer->LoadSocial(holder->GetResult(PLAYER_LOGIN_QUERY_LOADSOCIALLIST)); m_masterPlayer->LoadMails(holder->GetResult(PLAYER_LOGIN_QUERY_LOADMAILS)); m_masterPlayer->LoadMailedItems(holder->GetResult(PLAYER_LOGIN_QUERY_LOADMAILEDITEMS)); } m_masterPlayer->UpdateNextMailTimeAndUnreads(); sObjectAccessor.AddObject(m_masterPlayer); WorldPacket data(SMSG_LOGIN_VERIFY_WORLD, 20); data << pCurrChar->GetMapId(); data << pCurrChar->GetPositionX(); data << pCurrChar->GetPositionY(); data << pCurrChar->GetPositionZ(); data << pCurrChar->GetOrientation(); SendPacket(&data); data.Initialize(SMSG_ACCOUNT_DATA_TIMES, 128); for (int i = 0; i < 32; ++i) data << uint32(0); SendPacket(&data); // Send MOTD (1.12.1 not have SMSG_MOTD, so do it in another way) { uint32 linecount = 0; std::string str_motd = sWorld.GetMotd(); std::string::size_type pos, nextpos; std::string motd; pos = 0; while ((nextpos = str_motd.find('@', pos)) != std::string::npos) { if (nextpos != pos) { ChatHandler(pCurrChar).PSendSysMessage(str_motd.substr(pos, nextpos - pos).c_str()); ++linecount; } pos = nextpos + 1; } if (pos < str_motd.length()) { ChatHandler(pCurrChar).PSendSysMessage(str_motd.substr(pos).c_str()); ++linecount; } DEBUG_LOG("WORLD: Sent motd (SMSG_MOTD)"); } if (!alreadyOnline) { //QueryResult *result = CharacterDatabase.PQuery("SELECT guildid,rank FROM guild_member WHERE guid = '%u'",pCurrChar->GetGUIDLow()); QueryResult *resultGuild = holder->GetResult(PLAYER_LOGIN_QUERY_LOADGUILD); if (resultGuild) { Field *fields = resultGuild->Fetch(); pCurrChar->SetInGuild(fields[0].GetUInt32()); pCurrChar->SetRank(fields[1].GetUInt32()); } else if (pCurrChar->GetGuildId()) // clear guild related fields in case wrong data about nonexistent membership { pCurrChar->SetInGuild(0); pCurrChar->SetRank(0); } if (pCurrChar->GetGuildId() != 0) { Guild* guild = sGuildMgr.GetGuildById(pCurrChar->GetGuildId()); if (guild) { data.Initialize(SMSG_GUILD_EVENT, (2 + guild->GetMOTD().size() + 1)); data << uint8(GE_MOTD); data << uint8(1); data << guild->GetMOTD(); SendPacket(&data); DEBUG_LOG("WORLD: Sent guild-motd (SMSG_GUILD_EVENT)"); guild->BroadcastEvent(GE_SIGNED_ON, pCurrChar->GetObjectGuid(), pCurrChar->GetName()); } else { // remove wrong guild data sLog.outError("Player %s (GUID: %u) marked as member of nonexistent guild (id: %u), removing guild membership for player.", pCurrChar->GetName(), pCurrChar->GetGUIDLow(), pCurrChar->GetGuildId()); pCurrChar->SetInGuild(0); } } } if (!pCurrChar->isAlive()) pCurrChar->SendCorpseReclaimDelay(true); pCurrChar->SendInitialPacketsBeforeAddToMap(); GetMasterPlayer()->SendInitialActionButtons(); //Show cinematic at the first time that player login if (!pCurrChar->getCinematic()) { pCurrChar->setCinematic(1); if (ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(pCurrChar->getRace())) pCurrChar->SendCinematicStart(rEntry->CinematicSequence); } if (!alreadyOnline && !pCurrChar->GetMap()->Add(pCurrChar)) { // normal delayed teleport protection not applied (and this correct) for this case (Player object just created) AreaTrigger const* at = sObjectMgr.GetGoBackTrigger(pCurrChar->GetMapId()); if (at) pCurrChar->TeleportTo(at->target_mapId, at->target_X, at->target_Y, at->target_Z, pCurrChar->GetOrientation()); else pCurrChar->TeleportToHomebind(); } if (alreadyOnline) pCurrChar->GetMap()->ExistingPlayerLogin(pCurrChar); // SendInitSelf ... else sObjectAccessor.AddObject(pCurrChar); //DEBUG_LOG("Player %s added to Map.",pCurrChar->GetName()); pCurrChar->GetSocial()->SendFriendList(); pCurrChar->GetSocial()->SendIgnoreList(); pCurrChar->SendInitialPacketsAfterAddToMap(); if (alreadyOnline) pCurrChar->SendInitWorldStates(pCurrChar->GetCachedZoneId()); static SqlStatementID updChars; static SqlStatementID updAccount; SqlStatement stmt = CharacterDatabase.CreateStatement(updChars, "UPDATE characters SET online = 1 WHERE guid = ?"); stmt.PExecute(pCurrChar->GetGUIDLow()); stmt = LoginDatabase.CreateStatement(updAccount, "UPDATE account SET current_realm = ?, online = 1 WHERE id = ?"); stmt.PExecute(realmID, GetAccountId()); pCurrChar->SetInGameTime(WorldTimer::getMSTime()); // announce group about member online (must be after add to player list to receive announce to self) if (Group *group = pCurrChar->GetGroup()) group->UpdatePlayerOnlineStatus(pCurrChar); // friend status // TODO: Call it when node finished loading also if (GetMasterPlayer()) sSocialMgr.SendFriendStatus(GetMasterPlayer(), FRIEND_ONLINE, GetMasterPlayer()->GetObjectGuid(), true); if (!alreadyOnline) { // Place character in world (and load zone) before some object loading pCurrChar->LoadCorpse(); // setting Ghost+speed if dead if (pCurrChar->m_deathState != ALIVE) { // not blizz like, we must correctly save and load player instead... if (pCurrChar->getRace() == RACE_NIGHTELF) pCurrChar->CastSpell(pCurrChar, 20584, true); // auras SPELL_AURA_INCREASE_SPEED(+speed in wisp form), SPELL_AURA_INCREASE_SWIM_SPEED(+swim speed in wisp form), SPELL_AURA_TRANSFORM (to wisp form) pCurrChar->CastSpell(pCurrChar, 8326, true); // auras SPELL_AURA_GHOST, SPELL_AURA_INCREASE_SPEED(why?), SPELL_AURA_INCREASE_SWIM_SPEED(why?) pCurrChar->SetMovement(MOVE_WATER_WALK); } } // Load pet if any (if player not alive and in taxi flight or another then pet will remember as temporary unsummoned) if (alreadyOnline) pCurrChar->PetSpellInitialize(); else { pCurrChar->ContinueTaxiFlight(); pCurrChar->LoadPet(); } // Set FFA PvP for non GM in non-rest mode if (sWorld.IsFFAPvPRealm() && !pCurrChar->isGameMaster() && !pCurrChar->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING)) pCurrChar->SetFFAPvP(true); if (pCurrChar->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP)) pCurrChar->SetContestedPvP(); // Apply at_login requests if (pCurrChar->HasAtLoginFlag(AT_LOGIN_RESET_SPELLS)) { pCurrChar->resetSpells(); SendNotification(LANG_RESET_SPELLS); } if (pCurrChar->HasAtLoginFlag(AT_LOGIN_RESET_TALENTS)) { pCurrChar->resetTalents(true); SendNotification(LANG_RESET_TALENTS); // we can use SMSG_TALENTS_INVOLUNTARILY_RESET here } if (pCurrChar->HasAtLoginFlag(AT_LOGIN_FIRST)) pCurrChar->RemoveAtLoginFlag(AT_LOGIN_FIRST); // show time before shutdown if shutdown planned. if (sWorld.IsShutdowning()) sWorld.ShutdownMsg(true, pCurrChar); if (sWorld.getConfig(CONFIG_BOOL_ALL_TAXI_PATHS)) pCurrChar->SetTaxiCheater(true); if (pCurrChar->isGameMaster()) SendNotification(LANG_GM_ON); if (!pCurrChar->isGMVisible()) SendNotification(LANG_INVISIBLE_INVISIBLE, pCurrChar->GetGMInvisibilityLevel()); std::string IP_str = GetRemoteAddress(); sLog.out(LOG_CHAR, "Account: %d (IP: %s) Login Character:[%s] (guid: %u)%s", GetAccountId(), IP_str.c_str(), pCurrChar->GetName(), pCurrChar->GetGUIDLow(), alreadyOnline ? " Player was already online" : ""); sWorld.LogCharacter(pCurrChar, "Login"); if (!alreadyOnline && !pCurrChar->IsStandState() && !pCurrChar->hasUnitState(UNIT_STAT_STUNNED)) pCurrChar->SetStandState(UNIT_STAND_STATE_STAND); m_playerLoading = false; _clientMoverGuid = pCurrChar->GetObjectGuid(); delete holder; if (alreadyOnline) { pCurrChar->UpdateControl(); // Send "Release spirit" timer, etc ... if (pCurrChar->getDeathState() == CORPSE) pCurrChar->KillPlayer(); } // Update warden speeds //if (GetWarden()) //for (int i = 0; i < MAX_MOVE_TYPE; ++i) //GetWarden()->SendSpeedChange(UnitMoveType(i), pCurrChar->GetSpeed(UnitMoveType(i))); ALL_SESSION_SCRIPTS(this, OnLogin(pCurrChar)); }
void KUiLogin::OnKeyDown(unsigned int uKey) { if (uKey == VK_RETURN) { if (m_Cancel.IsButtonActive()) OnCancel(); else OnLogin(); } else if (uKey == VK_TAB) { if ((GetKeyState(VK_SHIFT) & 0x8000) == 0) { // 如果没有按住Shift if (m_InvisibleLogin.IsButtonActive()) m_Login.SetCursorAbove(); else if (m_Login.IsButtonActive()) m_RememberAccount.SetCursorAbove(); else if (m_RememberAccount.IsButtonActive()) m_Cancel.SetCursorAbove(); else { int x, y, cx; m_Account.GetAbsolutePos(&x, &y); m_Account.GetSize(&cx, NULL); Wnd_SetCursorPos(x + cx, y); Wnd_SetFocusWnd(&m_Account); } } else { // 如果按住Shift if (m_InvisibleLogin.IsButtonActive()) { int x, y, cx; m_PassWord.GetAbsolutePos(&x, &y); m_PassWord.GetSize(&cx, NULL); Wnd_SetCursorPos(x + cx, y); Wnd_SetFocusWnd(&m_PassWord); } else if (m_Login.IsButtonActive()) { m_InvisibleLogin.SetCursorAbove(); } else if (m_RememberAccount.IsButtonActive()) { m_Login.SetCursorAbove(); } else // if m_Cancel.IsButtonActive() { m_RememberAccount.SetCursorAbove(); } } } else if (uKey == VK_SPACE) { if (m_Login.IsButtonActive()) OnLogin(); else if (m_Cancel.IsButtonActive()) OnCancel(); else if (m_RememberAccount.IsButtonActive()) m_RememberAccount.CheckButton(!m_RememberAccount.IsButtonChecked()); else if (m_InvisibleLogin.IsButtonActive()) m_InvisibleLogin.CheckButton(!m_InvisibleLogin.IsButtonChecked()); } else if (uKey == VK_LEFT) m_Login.SetCursorAbove(); else if (uKey == VK_RIGHT) m_Cancel.SetCursorAbove(); else if (uKey == VK_ESCAPE) OnCancel(); }
//-------------------------------------------------------------------------- // 功能:窗口函数 //-------------------------------------------------------------------------- int KUiLogin::WndProc(unsigned int uMsg, unsigned int uParam, int nParam) { int nRet = 0; switch(uMsg) { case WND_N_BUTTON_CLICK: if (uParam == (unsigned int)(KWndWindow*)&m_Login) OnLogin(); else if (uParam == (unsigned int)(KWndWindow*)&m_Cancel) OnCancel(); break; case WND_N_EDIT_SPECIAL_KEY_DOWN: if (nParam == VK_TAB) { if ((GetKeyState(VK_SHIFT) & 0x8000) == 0) { // 如果没有按住Shift if (uParam == (unsigned int)(KWndWindow*)&m_Account) { int x, y, cx; m_PassWord.GetAbsolutePos(&x, &y); m_PassWord.GetSize(&cx, NULL); Wnd_SetCursorPos(x + cx, y); Wnd_SetFocusWnd(&m_PassWord); nRet = 1; } else if (uParam == (unsigned int)(KWndWindow*)&m_PassWord) { Wnd_SetFocusWnd(NULL); m_InvisibleLogin.SetCursorAbove(); nRet = 1; } } else { // 如果按住Shift if (uParam == (unsigned int)(KWndWindow*)&m_Account) { Wnd_SetFocusWnd(NULL); m_Cancel.SetCursorAbove(); nRet = 1; } else if (uParam == (unsigned int)(KWndWindow*)&m_PassWord) { int x, y, cx; m_Account.GetAbsolutePos(&x, &y); m_Account.GetSize(&cx, NULL); Wnd_SetCursorPos(x + cx, y); Wnd_SetFocusWnd(&m_Account); nRet = 1; } } } else if (nParam == VK_RETURN) { if (uParam == (unsigned int)(KWndWindow*)&m_Account) { Wnd_SetFocusWnd(&m_PassWord); nRet = 1; } else if (uParam == (unsigned int)(KWndWindow*)&m_PassWord) { OnLogin(); nRet = 1; } } else if (nParam == VK_ESCAPE) { OnCancel(); nRet = 1; } break; case WM_KEYDOWN: OnKeyDown(uParam); nRet = 1; break; case WM_SYSKEYDOWN: if (uParam == 'A') OnEnableAutoLogin(); break; case WND_N_EDIT_CHANGE: if(uParam == (unsigned int)(&m_Account)) { char szBuffer[32]; m_Account.GetText(szBuffer, sizeof(szBuffer), true); g_LoginLogic.SetLoginAccount(szBuffer); g_LoginLogic.LoadAccountSetting(); m_InvisibleLogin.CheckButton(g_LoginLogic.IsInvisibleLogin()); } break; default: nRet = KWndShowAnimate::WndProc(uMsg, uParam, nParam); break; } return nRet; }