49 lines
1.1 KiB
C++
49 lines
1.1 KiB
C++
#ifndef DATAMANAGER_H
|
|
#define DATAMANAGER_H
|
|
|
|
#include <QObject>
|
|
#include <QMessageBox>
|
|
|
|
#include "protocol.h"
|
|
#include "tcpclient.h"
|
|
|
|
class DataManager : public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit DataManager(QObject *parent = nullptr);
|
|
static void recv_from_server(QString &peerAddress,quint16 peerPort,QByteArray &data);
|
|
static DataManager* getInstance();
|
|
|
|
private:
|
|
Protocol *protocol;
|
|
TCPClient *tcpclient;
|
|
QString username;
|
|
QString password;
|
|
bool connect_flag = false;
|
|
|
|
signals:
|
|
void connect_to_server();
|
|
void disconnect_from_server();
|
|
void signin_response(bool result);
|
|
void signup_response(bool result);
|
|
|
|
public slots:
|
|
/*******ui界面********/
|
|
void Register(QString username,QString password);
|
|
void signin_request(QString username,QString password);
|
|
|
|
/******MAINWIDGET*****/
|
|
void send_text(QString text);
|
|
void send_file_to_all(QByteArray file);
|
|
void send_file_private(QByteArray file,QString name);
|
|
void account_cancellation(QString username);
|
|
|
|
/******TCPClient******/
|
|
void TCPClientConnected();
|
|
void TCPClientDisconnected();
|
|
|
|
};
|
|
|
|
#endif // DATAMANAGER_H
|