message.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // SPDX-FileCopyrightText: Copyright 2017 Citra Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include <utility>
  5. namespace NetworkMessage {
  6. class ConnectionError {
  7. public:
  8. explicit ConnectionError(std::string str) : err(std::move(str)) {}
  9. const std::string& GetString() const {
  10. return err;
  11. }
  12. private:
  13. std::string err;
  14. };
  15. class ErrorManager : QObject {
  16. Q_OBJECT
  17. public:
  18. /// When the nickname is considered invalid by the client
  19. static const ConnectionError USERNAME_NOT_VALID;
  20. static const ConnectionError ROOMNAME_NOT_VALID;
  21. /// When the nickname is considered invalid by the room server
  22. static const ConnectionError USERNAME_NOT_VALID_SERVER;
  23. static const ConnectionError IP_ADDRESS_NOT_VALID;
  24. static const ConnectionError PORT_NOT_VALID;
  25. static const ConnectionError GAME_NOT_SELECTED;
  26. static const ConnectionError NO_INTERNET;
  27. static const ConnectionError UNABLE_TO_CONNECT;
  28. static const ConnectionError ROOM_IS_FULL;
  29. static const ConnectionError COULD_NOT_CREATE_ROOM;
  30. static const ConnectionError HOST_BANNED;
  31. static const ConnectionError WRONG_VERSION;
  32. static const ConnectionError WRONG_PASSWORD;
  33. static const ConnectionError GENERIC_ERROR;
  34. static const ConnectionError LOST_CONNECTION;
  35. static const ConnectionError HOST_KICKED;
  36. static const ConnectionError IP_COLLISION;
  37. static const ConnectionError PERMISSION_DENIED;
  38. static const ConnectionError NO_SUCH_USER;
  39. static const ConnectionError NO_INTERFACE_SELECTED;
  40. /**
  41. * Shows a standard QMessageBox with a error message
  42. */
  43. static void ShowError(const ConnectionError& e);
  44. };
  45. /**
  46. * Show a standard QMessageBox with a warning message about joining a room when
  47. * the game is already running
  48. * return true if the user wants to close the network connection
  49. */
  50. bool WarnGameRunning();
  51. /**
  52. * Show a standard QMessageBox with a warning message about leaving the room
  53. * return true if the user wants to close the network connection
  54. */
  55. bool WarnCloseRoom();
  56. /**
  57. * Show a standard QMessageBox with a warning message about disconnecting from the room
  58. * return true if the user wants to disconnect
  59. */
  60. bool WarnDisconnect();
  61. } // namespace NetworkMessage