App.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #ifndef APP_H
  2. #define APP_H
  3. #include <QCoreApplication>
  4. #include <QList>
  5. #include <QSettings>
  6. #include <QHostAddress>
  7. class SshClient;
  8. class QTcpSocket;
  9. class QTcpServer;
  10. class Client;
  11. class ActiveClient;
  12. class App : public QCoreApplication
  13. {
  14. Q_OBJECT
  15. public:
  16. explicit App(int &argc, char **argv);
  17. ~App();
  18. void print(const QString& msg);
  19. void broadcast(const QString& msg, int *serverCount, int *userCount);
  20. void broadcast(const QString& msg);
  21. void requestBroadcast(const QString& type, const QString& user, const QString& server, const QString& message);
  22. void setReplyHash(const QString& serverAddress, const QString& hash);
  23. void incrementReplyCounters(const QString& hash, int userCount, int channelCount, int playerCount, int serverCount);
  24. void activeClientsReplyCounters(int *serverCount, int *playerCount);
  25. protected:
  26. void timerEvent(QTimerEvent *e);
  27. private:
  28. QTcpSocket* mySocket;
  29. QTcpServer* myServer;
  30. bool mySocketConnectedFlag;
  31. SshClient* myQWNETSshClient;
  32. QList<ActiveClient*> myClients;
  33. quint32 myCurrentClient;
  34. QSettings mySettings;
  35. int myClientsFrameTimerID; //timer for mainloop
  36. void loadServerList();
  37. void saveServerList();
  38. void cleanup();
  39. /* TCP Server */
  40. bool checkPassword(const QString& password);
  41. void addClient(const QString& host, quint16 port);
  42. void removeClient(const QString& host, quint16 port);
  43. void parseAddClientCommand(const QString& args);
  44. void parseRemoveClientCommand(const QString& args);
  45. void say(const QString& msg, int *serverCount, int *userCount);
  46. void say(const QString& msg);
  47. void sayTeam(const QString& msg);
  48. void setTeam(const QString& team);
  49. void listClients();
  50. void setColor(const QString& args);
  51. void setNick(const QString& args);
  52. void setPing(const QString& args);
  53. void help();
  54. private slots:
  55. /* TCP server */
  56. void onDataArrival();
  57. void onNewConnection();
  58. void onDisconnection();
  59. };
  60. #endif // APP_H