hedgeroid: adjust build.xml: fix app name; set java version; print hint if sdk build.xml is missing
#ifndef NET_SESSION_H
#define NET_SESSION_H
#include <QSharedPointer>
#include <QSslSocket>
#include <QStringList>
#include <QUrl>
class PlayersListModel;
class RoomsListModel;
class NetSession : public QObject {
Q_OBJECT
const int cMinServerVersion = 3;
const int cProtocolVersion = 60;
// clang-format off
Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged)
Q_PROPERTY(QAbstractSocket::SocketState state READ state NOTIFY stateChanged)
Q_PROPERTY(QString nickname READ nickname WRITE setNickname NOTIFY nicknameChanged)
Q_PROPERTY(SessionState sessionState READ sessionState NOTIFY sessionStateChanged)
Q_PROPERTY(QString room READ room NOTIFY roomChanged)
Q_PROPERTY(QString passwordHash READ passwordHash WRITE setPasswordHash NOTIFY passwordHashChanged)
// clang-format on
public:
enum SessionState { NotConnected, Login, Authentication, Lobby, Room, Game };
Q_ENUMS(SessionState)
explicit NetSession(QObject *parent = nullptr);
~NetSession() override;
QUrl url() const;
QAbstractSocket::SocketState state() const;
QString nickname() const;
SessionState sessionState() const;
QString room() const;
QString passwordHash() const;
public slots:
void open();
void close();
void setUrl(const QUrl &url);
void setNickname(const QString &nickname);
void setPasswordHash(const QString &passwordHash);
signals:
void urlChanged(const QUrl url);
void stateChanged(QAbstractSocket::SocketState state);
void nicknameChanged(const QString &nickname);
void sessionStateChanged(SessionState sessionState);
void warning(const QString &message);
void error(const QString &message);
void roomChanged(const QString &room);
void passwordHashChanged(const QString &passwordHash);
void passwordAsked();
private slots:
void onReadyRead();
void parseNetMessage(const QStringList &message);
void handleConnected(const QStringList ¶meters);
void handlePing(const QStringList ¶meters);
void handleBye(const QStringList ¶meters);
void handleUnknownCommand(const QStringList ¶meters);
void handleAddTeam(const QStringList ¶meters);
void handleAskPassword(const QStringList ¶meters);
void handleBanList(const QStringList ¶meters);
void handleCfg(const QStringList ¶meters);
void handleChat(const QStringList ¶meters);
void handleClientFlags(const QStringList ¶meters);
void handleEm(const QStringList ¶meters);
void handleError(const QStringList ¶meters);
void handleHhNum(const QStringList ¶meters);
void handleInfo(const QStringList ¶meters);
void handleJoined(const QStringList ¶meters);
void handleJoining(const QStringList ¶meters);
void handleKicked(const QStringList ¶meters);
void handleLeft(const QStringList ¶meters);
void handleLobbyJoined(const QStringList ¶meters);
void handleLobbyLeft(const QStringList ¶meters);
void handleNick(const QStringList ¶meters);
void handleNotice(const QStringList ¶meters);
void handlePong(const QStringList ¶meters);
void handleProto(const QStringList ¶meters);
void handleRedirect(const QStringList ¶meters);
void handleRemoveTeam(const QStringList ¶meters);
void handleReplayStart(const QStringList ¶meters);
void handleRoomAbandoned(const QStringList ¶meters);
void handleRoom(const QStringList ¶meters);
void handleRooms(const QStringList ¶meters);
void handleRoundFinished(const QStringList ¶meters);
void handleRunGame(const QStringList ¶meters);
void handleServerAuth(const QStringList ¶meters);
void handleServerMessage(const QStringList ¶meters);
void handleServerVars(const QStringList ¶meters);
void handleTeamAccepted(const QStringList ¶meters);
void handleTeamColor(const QStringList ¶meters);
void handleWarning(const QStringList ¶meters);
void send(const QString &message);
void send(const QString &message, const QString ¶m);
void send(const QString &message, const QStringList ¶meters);
void send(const QStringList &message);
void sendPassword();
void setSessionState(SessionState sessionState);
void setRoom(const QString &room);
private:
QUrl m_url;
QSharedPointer<QTcpSocket> m_socket;
QSharedPointer<PlayersListModel> m_playersModel;
QSharedPointer<RoomsListModel> m_roomsModel;
QString m_nickname;
QStringList m_buffer;
SessionState m_sessionState;
QString m_serverAuthHash;
QString m_room;
QString m_serverSalt;
QString m_serverHash;
QString m_clientSalt;
QString m_passwordHash;
Q_DISABLE_COPY(NetSession)
};
#endif // NET_SESSION_H