aboutsummaryrefslogtreecommitdiff
path: root/src/unittest/test_connection.cpp
Commit message (Collapse)AuthorAge
* Encode high codepoints as surrogates to safely transport wchar_t over networksfan52021-02-02
| | | | fixes #7643
* Add a MSVC / Windows compatible snprintf function (#7353)nOOb31672018-07-22
| | | Use sizeof where applicable for mt_snprintf
* Add session_t typedef + remove unused functions (#6470)Loïc Blot2017-09-27
| | | | | | * Add session_t typedef + remove unused functions u16 peer_id is used everywhere, to be more consistent and permit some evolutions on this type in the future (i'm working on a PoC), uniformize u16 peer_id to SessionId peer_id
* Remove DSTACK support (#6346)Loïc Blot2017-08-30
| | | Debugstacks is not useful, we don't really use it, the DebugStack is not pertinent, gdb and lldb are better if we really want to debug.
* Network proto handlers/container fixes (#6334)Loïc Blot2017-08-29
| | | | | | | | | | * Fix HP transport + some double <-> float problems TOCLIENT_HP transport u16 hp as a u8, use u16 HP, this prevent HP over 255 to overflow across network * Fix more double/float problem in serverpackethandler & remove implicit struct type for TileAnimationParams * Fix connection unittests container
* Network cleanup (#6310)Loïc Blot2017-08-25
| | | | | | | | | | | | | | * Move Connection threads to dedicated files + various cleanups * ConnectionReceiveThread::processPacket now uses function pointer table to route MT packet types * Various code style fixes * Code style with clang-format * Various SharedBuffer copy removal * SharedBuffer cannot be copied anymore using Buffer * Fix many SharedBuffer copy (thanks to delete operator)
* Network cleanup (#6302)Loïc Blot2017-08-24
| | | | | | | | | | | | | | | | | | | | | | | * Cleanup network headers * Move peerhandler to a specific header to reduce compilation times * Move socket.cpp/h to network folder * More work * Network code cleanups * Move socket.{cpp,h} to network folder * Move Address object to network/address.{cpp,h} * Move network exceptions to network/networkexceptions.h * Client: use unique_ptr for Connection * Server/ClientIface: use shared_ptr for Connection * Format fixes * Remove socket.cpp socket.h from clang-format whitelist * Also fix NetworkPacket code style & make it under clang-format
* Cleanup various headers to reduce compilation times (#6255)Loïc Blot2017-08-16
| | | | * Cleanup various headers to reduce compilation times
* C++11 cleanup on constructors (#6000)Vincent Glize2017-06-19
| | | | * C++11 cleanup on constructors dir script
* Fix Travis/unittest broken since b662a45SmallJoker2017-04-29
|
* Tests: Modularize unit testingkwolekr2015-04-26
Split unit tests into separate files under src/unittest/ Give better unittest diagnostics Clean up some code
R ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include "guiPasswordChange.h" #include "debug.h" #include "serialization.h" #include <string> #include <IGUICheckBox.h> #include <IGUIEditBox.h> #include <IGUIButton.h> #include <IGUIStaticText.h> #include <IGUIFont.h> #include "gettext.h" const int ID_oldPassword = 256; const int ID_newPassword1 = 257; const int ID_newPassword2 = 258; const int ID_change = 259; const int ID_message = 260; GUIPasswordChange::GUIPasswordChange(gui::IGUIEnvironment* env, gui::IGUIElement* parent, s32 id, IMenuManager *menumgr, Client* client ): GUIModalMenu(env, parent, id, menumgr), m_client(client) { } GUIPasswordChange::~GUIPasswordChange() { removeChildren(); } void GUIPasswordChange::removeChildren() { { gui::IGUIElement *e = getElementFromId(ID_oldPassword); if(e != NULL) e->remove(); } { gui::IGUIElement *e = getElementFromId(ID_newPassword1); if(e != NULL) e->remove(); } { gui::IGUIElement *e = getElementFromId(ID_newPassword2); if(e != NULL) e->remove(); } { gui::IGUIElement *e = getElementFromId(ID_change); if(e != NULL) e->remove(); } } void GUIPasswordChange::regenerateGui(v2u32 screensize) { /* Remove stuff */ removeChildren(); /* Calculate new sizes and positions */ core::rect<s32> rect( screensize.X/2 - 580/2, screensize.Y/2 - 300/2, screensize.X/2 + 580/2, screensize.Y/2 + 300/2 ); DesiredRect = rect; recalculateAbsolutePosition(false); v2s32 size = rect.getSize(); v2s32 topleft_client(40, 0); const wchar_t *text; /* Add stuff */ s32 ypos = 50; { core::rect<s32> rect(0, 0, 150, 20); rect += topleft_client + v2s32(25, ypos+6); text = wgettext("Old Password"); Environment->addStaticText(text, rect, false, true, this, -1); delete[] text; } { core::rect<s32> rect(0, 0, 230, 30); rect += topleft_client + v2s32(160, ypos); gui::IGUIEditBox *e = Environment->addEditBox(L"", rect, true, this, ID_oldPassword); Environment->setFocus(e); e->setPasswordBox(true); } ypos += 50; { core::rect<s32> rect(0, 0, 150, 20); rect += topleft_client + v2s32(25, ypos+6); text = wgettext("New Password"); Environment->addStaticText(text, rect, false, true, this, -1); delete[] text; } { core::rect<s32> rect(0, 0, 230, 30); rect += topleft_client + v2s32(160, ypos); gui::IGUIEditBox *e = Environment->addEditBox(L"", rect, true, this, ID_newPassword1); e->setPasswordBox(true); } ypos += 50; { core::rect<s32> rect(0, 0, 150, 20); rect += topleft_client + v2s32(25, ypos+6); text = wgettext("Confirm Password"); Environment->addStaticText(text, rect, false, true, this, -1); delete[] text; } { core::rect<s32> rect(0, 0, 230, 30); rect += topleft_client + v2s32(160, ypos); gui::IGUIEditBox *e = Environment->addEditBox(L"", rect, true, this, ID_newPassword2); e->setPasswordBox(true); } ypos += 50; { core::rect<s32> rect(0, 0, 140, 30); rect = rect + v2s32(size.X/2-140/2, ypos); text = wgettext("Change"); Environment->addButton(rect, this, ID_change, text); delete[] text; } ypos += 50; { core::rect<s32> rect(0, 0, 300, 20); rect += topleft_client + v2s32(35, ypos); text = wgettext("Passwords do not match!"); IGUIElement *e = Environment->addStaticText( text, rect, false, true, this, ID_message); e->setVisible(false); delete[] text; } } void GUIPasswordChange::drawMenu() { gui::IGUISkin* skin = Environment->getSkin(); if (!skin) return; video::IVideoDriver* driver = Environment->getVideoDriver(); video::SColor bgcolor(140,0,0,0); driver->draw2DRectangle(bgcolor, AbsoluteRect, &AbsoluteClippingRect); gui::IGUIElement::draw(); } bool GUIPasswordChange::acceptInput() { std::wstring oldpass; std::wstring newpass; gui::IGUIElement *e; e = getElementFromId(ID_oldPassword); if(e != NULL) oldpass = e->getText(); e = getElementFromId(ID_newPassword1); if(e != NULL) newpass = e->getText(); e = getElementFromId(ID_newPassword2); if(e != NULL && newpass != e->getText()) { e = getElementFromId(ID_message); if(e != NULL) e->setVisible(true); return false; } m_client->sendChangePassword(oldpass, newpass); return true; } bool GUIPasswordChange::OnEvent(const SEvent& event) { if(event.EventType==EET_KEY_INPUT_EVENT) { if(event.KeyInput.Key==KEY_ESCAPE && event.KeyInput.PressedDown) { quitMenu(); return true; } if(event.KeyInput.Key==KEY_RETURN && event.KeyInput.PressedDown) { if(acceptInput()) quitMenu(); return true; } } if(event.EventType==EET_GUI_EVENT) { if(event.GUIEvent.EventType==gui::EGET_ELEMENT_FOCUS_LOST && isVisible()) { if(!canTakeFocus(event.GUIEvent.Element)) { dstream<<"GUIPasswordChange: Not allowing focus change." <<std::endl; // Returning true disables focus change return true; } } if(event.GUIEvent.EventType==gui::EGET_BUTTON_CLICKED) { switch(event.GUIEvent.Caller->getID()) { case ID_change: if(acceptInput()) quitMenu(); return true; } } if(event.GUIEvent.EventType==gui::EGET_EDITBOX_ENTER) { switch(event.GUIEvent.Caller->getID()) { case ID_oldPassword: case ID_newPassword1: case ID_newPassword2: if(acceptInput()) quitMenu(); return true; } } } return Parent ? Parent->OnEvent(event) : false; }